[Mesa-dev] [PATCH 3/4] glsl: create a new link_and_validate_uniforms() helper

Timothy Arceri timothy.arceri at collabora.com
Thu Dec 29 03:15:12 UTC 2016


Currently this just breaks up the linking code a bit but in the
future i965 will call this from the backend via Driver.LinkShader()
so that we can do NIR optimisations before assigning uniform
locations.
---
 src/compiler/glsl/linker.cpp | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index e755ece..366fa3f 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4526,6 +4526,24 @@ disable_varying_optimizations_for_sso(struct gl_shader_program *prog)
    }
 }
 
+static void
+link_and_validate_uniforms(struct gl_context *ctx,
+                           struct gl_shader_program *prog,
+                           unsigned num_explicit_uniform_locs)
+{
+   update_array_sizes(prog);
+   link_assign_uniform_locations(prog, ctx, num_explicit_uniform_locs);
+
+   if (!prog->data->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);
+   }
+}
+
 static bool
 link_varyings_and_uniforms(unsigned first, unsigned last,
                            unsigned num_explicit_uniform_locs,
@@ -4590,17 +4608,7 @@ link_varyings_and_uniforms(unsigned first, unsigned last,
    if (!link_varyings(prog, first, last, ctx, mem_ctx))
       return false;
 
-   update_array_sizes(prog);
-   link_assign_uniform_locations(prog, ctx, num_explicit_uniform_locs);
-
-   if (!prog->data->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);
-   }
+   link_and_validate_uniforms(ctx, prog, num_explicit_uniform_locs);
 
    if (!prog->data->LinkStatus)
       return false;
-- 
2.9.3



More information about the mesa-dev mailing list