i965/fs: Default all constants to a location of -1
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 10 May 2016 20:54:58 +0000 (13:54 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 10 May 2016 22:25:30 +0000 (15:25 -0700)
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.

Reviewed-by: Mark Janes <mark.a.janes@intel.com>
src/mesa/drivers/dri/i965/brw_fs.cpp

index b479684fc675b0a9ca7467b20b11e8a37c929c2a..2a542b8e510049f6187d843b84a0c497c348e104 100644 (file)
@@ -2138,6 +2138,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 */
@@ -2145,9 +2149,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,
@@ -2161,9 +2162,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,