[Mesa-dev] [PATCH 49/87] glsl: skip more uniform initialisation when doing fallback linking

Timothy Arceri timothy.arceri at collabora.com
Wed Jul 13 02:47:44 UTC 2016


We already pull these values from the metadata cache so no need to
recreate them.
---
 src/compiler/glsl/linker.cpp | 22 ++++++++++++++--------
 src/mesa/main/shaderobj.c    |  8 +++++---
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 76e75e5..7b5bdd3 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4529,6 +4529,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
       return;
 #endif
 
+   bool create_program_metadata = !is_cache_fallback || !prog->UniformStorage;
+
    void *mem_ctx = ralloc_context(NULL); // temporary linker context
 
    prog->ARB_fragment_coord_conventions_enable = false;
@@ -4715,8 +4717,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
       last = i;
    }
 
-   num_explicit_uniform_locs = check_explicit_uniform_locations(ctx, prog);
-   link_assign_subroutine_types(prog);
+   if (create_program_metadata) {
+      num_explicit_uniform_locs = check_explicit_uniform_locations(ctx, prog);
+      link_assign_subroutine_types(prog);
+   }
 
    if (!prog->LinkStatus)
       goto done;
@@ -4998,14 +5002,16 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
                                  num_explicit_uniform_locs,
                                  ctx->Const.MaxUserAssignableUniformLocations,
                                  is_cache_fallback);
-   link_assign_atomic_counter_resources(ctx, prog);
    store_fragdepth_layout(prog);
 
-   link_calculate_subroutine_compat(prog);
-   check_resources(ctx, prog);
-   check_subroutine_resources(prog);
-   check_image_resources(ctx, prog);
-   link_check_atomic_counter_resources(ctx, prog);
+   if (create_program_metadata) {
+      link_assign_atomic_counter_resources(ctx, prog);
+      link_calculate_subroutine_compat(prog);
+      check_resources(ctx, prog);
+      check_subroutine_resources(prog);
+      check_image_resources(ctx, prog);
+      link_check_atomic_counter_resources(ctx, prog);
+   }
 
    if (!prog->LinkStatus)
       goto done;
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 6fa100c..73fbb15 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -325,9 +325,11 @@ _mesa_clear_shader_program_data(struct gl_shader_program *shProg,
    shProg->ShaderStorageBlocks = NULL;
    shProg->NumShaderStorageBlocks = 0;
 
-   ralloc_free(shProg->AtomicBuffers);
-   shProg->AtomicBuffers = NULL;
-   shProg->NumAtomicBuffers = 0;
+   if (shProg->AtomicBuffers && !is_cache_fallback) {
+      ralloc_free(shProg->AtomicBuffers);
+      shProg->AtomicBuffers = NULL;
+      shProg->NumAtomicBuffers = 0;
+   }
 
    if (shProg->ProgramResourceList) {
       ralloc_free(shProg->ProgramResourceList);
-- 
2.7.4



More information about the mesa-dev mailing list