[Mesa-dev] [PATCH 56/77] i965: don't rebuild param list after cache miss

Timothy Arceri timothy.arceri at collabora.com
Mon Oct 3 06:05:15 UTC 2016


Previously we ended up with the same param list but in a different
location, which will mess up the pointers stored in the new cache
object if all stages were not fully rebuilt e.g. after a fragment
program cache miss.

This also stops the list from being leaked on fallback.
---
 src/mesa/drivers/dri/i965/brw_link.cpp | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp
index 9acbaa3..6c236b6 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -228,7 +228,6 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg,
                                 0);
       if (!prog)
         return false;
-      prog->Parameters = _mesa_new_parameter_list();
 
       _mesa_copy_linked_program_data((gl_shader_stage) stage, shProg, prog);
 
@@ -241,19 +240,22 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg,
        * too late.  At that point, the values for the built-in uniforms won't
        * get sent to the shader.
        */
-      foreach_in_list(ir_instruction, node, shader->ir) {
-         ir_variable *var = node->as_variable();
-
-         if ((var == NULL) || (var->data.mode != ir_var_uniform)
-             || (strncmp(var->name, "gl_", 3) != 0))
-            continue;
-
-         const ir_state_slot *const slots = var->get_state_slots();
-         assert(slots != NULL);
-
-         for (unsigned int i = 0; i < var->get_num_state_slots(); i++) {
-            _mesa_add_state_reference(prog->Parameters,
-                                      (gl_state_index *) slots[i].tokens);
+      if (!is_cache_fallback) {
+         prog->Parameters = _mesa_new_parameter_list();
+         foreach_in_list(ir_instruction, node, shader->ir) {
+            ir_variable *var = node->as_variable();
+
+            if ((var == NULL) || (var->data.mode != ir_var_uniform)
+                || (strncmp(var->name, "gl_", 3) != 0))
+               continue;
+
+            const ir_state_slot *const slots = var->get_state_slots();
+            assert(slots != NULL);
+
+            for (unsigned int i = 0; i < var->get_num_state_slots(); i++) {
+               _mesa_add_state_reference(prog->Parameters,
+                                         (gl_state_index *) slots[i].tokens);
+            }
          }
       }
 
-- 
2.7.4



More information about the mesa-dev mailing list