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

Timothy Arceri timothy.arceri at collabora.com
Sat Sep 24 05:25:30 UTC 2016


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

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index d492997..2f1be1f 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4382,7 +4382,9 @@ disable_varying_optimizations_for_sso(struct gl_shader_program *prog)
 static bool
 link_varyings_and_uniforms(unsigned first, unsigned last,
                            unsigned num_explicit_uniform_locs,
-                           bool is_cache_fallback, struct gl_context *ctx,
+                           bool is_cache_fallback,
+                           bool create_program_metadata,
+                           struct gl_context *ctx,
                            struct gl_shader_program *prog, void *mem_ctx)
 {
    bool has_xfb_qualifiers = false;
@@ -4567,13 +4569,15 @@ link_varyings_and_uniforms(unsigned first, unsigned last,
                                  num_explicit_uniform_locs,
                                  ctx->Const.MaxUserAssignableUniformLocations,
                                  is_cache_fallback);
-   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 (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)
       return false;
@@ -4647,6 +4651,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;
@@ -4833,8 +4839,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;
@@ -4942,7 +4950,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
    store_fragdepth_layout(prog);
 
    if(!link_varyings_and_uniforms(first, last, num_explicit_uniform_locs,
-                                  is_cache_fallback, ctx, prog, mem_ctx))
+                                  is_cache_fallback, create_program_metadata,
+                                  ctx, prog, mem_ctx))
       goto done;
 
    /* OpenGL ES < 3.1 requires that a vertex shader and a fragment shader both
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index b6b6c99..0d40953 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