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

Timothy Arceri timothy.arceri at collabora.com
Wed Jul 13 02:47:58 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 aa1a1f2..7bc3052 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -221,7 +221,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);
 
@@ -234,19 +233,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