[Mesa-dev] [PATCH] i965/fs: Default all constants to a location of -1

Mark Janes mark.a.janes at intel.com
Tue May 10 21:40:25 UTC 2016


Reviewed-by: Mark Janes <mark.a.janes at intel.com>

Jason Ekstrand <jason at jlekstrand.net> writes:

> Otherwise constants which aren't live get an undefined constant location.
> When we go to set up param and pull_param we end up assigning all unused
> uniforms to slot 0.  This cases the Vulkan driver to segfault because it
> doesn't have pull_param.
>
> This fixes bugs in the Vulkan driver introduced in c3fab3d000.
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 88d6722..ac714c5 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -2124,6 +2124,10 @@ fs_visitor::assign_constant_locations()
>     push_constant_loc = ralloc_array(mem_ctx, int, uniforms);
>     pull_constant_loc = ralloc_array(mem_ctx, int, uniforms);
>  
> +   /* Default to -1 meaning no location */
> +   memset(push_constant_loc, -1, uniforms * sizeof(*push_constant_loc));
> +   memset(pull_constant_loc, -1, uniforms * sizeof(*pull_constant_loc));
> +
>     int chunk_start = -1;
>  
>     /* First push 64-bit uniforms to ensure they are properly aligned */
> @@ -2131,9 +2135,6 @@ fs_visitor::assign_constant_locations()
>        if (!is_live[u] || !is_live_64bit[u])
>           continue;
>  
> -      pull_constant_loc[u] = -1;
> -      push_constant_loc[u] = -1;
> -
>        set_push_pull_constant_loc(u, &chunk_start, contiguous[u],
>                                   push_constant_loc, pull_constant_loc,
>                                   &num_push_constants, &num_pull_constants,
> @@ -2147,9 +2148,6 @@ fs_visitor::assign_constant_locations()
>        if (!is_live[u] || is_live_64bit[u])
>           continue;
>  
> -      pull_constant_loc[u] = -1;
> -      push_constant_loc[u] = -1;
> -
>        set_push_pull_constant_loc(u, &chunk_start, contiguous[u],
>                                   push_constant_loc, pull_constant_loc,
>                                   &num_push_constants, &num_pull_constants,
> -- 
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list