st/mesa: don't propagate uniforms when restoring from cache
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 3 Mar 2017 05:59:48 +0000 (16:59 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 7 Mar 2017 22:45:48 +0000 (09:45 +1100)
We will have already loaded the uniforms when the parameter list
was restored from cache.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/program/ir_to_mesa.cpp
src/mesa/program/ir_to_mesa.h
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp
src/mesa/state_tracker/st_shader_cache.c

index a4f61ac23ef3f134f05b33bba2e3a9332a04af0b..3898cb8d09ac51ccd67f22b7d25d2d76c0de2337 100644 (file)
@@ -2532,7 +2532,8 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
 void
 _mesa_associate_uniform_storage(struct gl_context *ctx,
                                struct gl_shader_program *shader_program,
-                               struct gl_program_parameter_list *params)
+                                struct gl_program_parameter_list *params,
+                                bool propagate_to_storage)
 {
    /* After adding each uniform to the parameter list, connect the storage for
     * the parameter with the tracking structure used by the API for the
@@ -2622,9 +2623,11 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
          * data from the linker's backing store.  This will cause values from
          * initializers in the source code to be copied over.
          */
-        _mesa_propagate_uniforms_to_driver_storage(storage,
-                                                   0,
-                                                   MAX2(1, storage->array_elements));
+         if (propagate_to_storage) {
+            unsigned array_elements = MAX2(1, storage->array_elements);
+            _mesa_propagate_uniforms_to_driver_storage(storage, 0,
+                                                       array_elements);
+         }
 
         last_location = location;
       }
@@ -2984,7 +2987,8 @@ get_mesa_program(struct gl_context *ctx,
     * prog->ParameterValues to get reallocated (e.g., anything that adds a
     * program constant) has to happen before creating this linkage.
     */
-   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters);
+   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
+                                   true);
    if (!shader_program->data->LinkStatus) {
       goto fail_exit;
    }
index be45ba0ebca9be3171b6c96779780bbefb1bb9ca..c46d090b774efd43893e424203568d548cab1442 100644 (file)
@@ -45,7 +45,8 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
 void
 _mesa_associate_uniform_storage(struct gl_context *ctx,
                                struct gl_shader_program *shader_program,
-                               struct gl_program_parameter_list *params);
+                                struct gl_program_parameter_list *params,
+                                bool propagate_to_storage);
 
 #ifdef __cplusplus
 }
index 60d101c91d8a559c77b6189819173f9dcae631ed..674ccd07a4cce364f750495e93236f71600b481f 100644 (file)
@@ -426,7 +426,8 @@ st_nir_get_mesa_program(struct gl_context *ctx,
     * prog->ParameterValues to get reallocated (e.g., anything that adds a
     * program constant) has to happen before creating this linkage.
     */
-   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters);
+   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
+                                   true);
 
    struct st_vertex_program *stvp;
    struct st_fragment_program *stfp;
index af41bdbbea10d622824823a8d516e3de597d858a..0757d141fcc5a1b0ef5259d5eb310e81fd51a3b2 100644 (file)
@@ -6770,7 +6770,8 @@ get_mesa_program_tgsi(struct gl_context *ctx,
     * prog->ParameterValues to get reallocated (e.g., anything that adds a
     * program constant) has to happen before creating this linkage.
     */
-   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters);
+   _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
+                                   true);
    if (!shader_program->data->LinkStatus) {
       free_glsl_to_tgsi_visitor(v);
       _mesa_reference_program(ctx, &shader->Program, NULL);
index fba4b0a3a03bc9aa22d23863fbb8514766646394..f22380ce729c4e2f09d4f8fc5fbacecabb92c73f 100644 (file)
@@ -379,7 +379,8 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
          }
 
          st_set_prog_affected_state_flags(glprog);
-         _mesa_associate_uniform_storage(ctx, prog, glprog->Parameters);
+         _mesa_associate_uniform_storage(ctx, prog, glprog->Parameters,
+                                         false);
 
          free(buffer);
       } else {