Mesa (10.1): linker: Split set_uniform_binding into separate functions for blocks and samplers

Carl Worth cworth at kemper.freedesktop.org
Thu Apr 17 15:12:20 UTC 2014


Module: Mesa
Branch: 10.1
Commit: dab5a7a9f95e557097823a24b9e482cd10e30d31
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dab5a7a9f95e557097823a24b9e482cd10e30d31

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Apr  4 10:45:38 2014 -0700

linker: Split set_uniform_binding into separate functions for blocks and samplers

The two code paths are quite different, and there are some problems in
the handling of uniform blocks.  Future changes will cause these paths
to diverge further.  Ultimately, selecting between the two functions
will happen at the set_uniform_binding call site, and
set_uniform_binding will be deleted.

NOTE: This patch just moves code around.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76323
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Cc: "10.1" <mesa-stable at lists.freedesktop.org>
Cc: github at socker.lepus.uberspace.de
(cherry picked from commit 6e2f63b69e37c365094ce9bf7e2f9cd118cea01a)

---

 src/glsl/link_uniform_initializers.cpp |   42 +++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp
index 7d5c147..4f5048b 100644
--- a/src/glsl/link_uniform_initializers.cpp
+++ b/src/glsl/link_uniform_initializers.cpp
@@ -83,7 +83,7 @@ copy_constant_to_storage(union gl_constant_value *storage,
 }
 
 void
-set_uniform_binding(void *mem_ctx, gl_shader_program *prog,
+set_sampler_binding(void *mem_ctx, gl_shader_program *prog,
                     const char *name, const glsl_type *type, int binding)
 {
    struct gl_uniform_storage *const storage =
@@ -94,7 +94,7 @@ set_uniform_binding(void *mem_ctx, gl_shader_program *prog,
       return;
    }
 
-   if (storage->type->is_sampler()) {
+   {
       unsigned elements = MAX2(storage->array_elements, 1);
 
       /* From section 4.4.4 of the GLSL 4.20 specification:
@@ -117,7 +117,24 @@ set_uniform_binding(void *mem_ctx, gl_shader_program *prog,
             }
          }
       }
-   } else if (storage->block_index != -1) {
+   }
+
+   storage->initialized = true;
+}
+
+void
+set_block_binding(void *mem_ctx, gl_shader_program *prog,
+                  const char *name, const glsl_type *type, int binding)
+{
+   struct gl_uniform_storage *const storage =
+      get_storage(prog->UniformStorage, prog->NumUserUniformStorage, name);
+
+   if (storage == NULL) {
+      assert(storage != NULL);
+      return;
+   }
+
+   if (storage->block_index != -1) {
       /* This is a field of a UBO.  val is the binding index. */
       for (int i = 0; i < MESA_SHADER_STAGES; i++) {
          int stage_index = prog->UniformBlockStageIndex[i][storage->block_index];
@@ -133,6 +150,25 @@ set_uniform_binding(void *mem_ctx, gl_shader_program *prog,
 }
 
 void
+set_uniform_binding(void *mem_ctx, gl_shader_program *prog,
+                    const char *name, const glsl_type *type, int binding)
+{
+   struct gl_uniform_storage *const storage =
+      get_storage(prog->UniformStorage, prog->NumUserUniformStorage, name);
+
+   if (storage == NULL) {
+      assert(storage != NULL);
+      return;
+   }
+
+   if (storage->type->is_sampler()) {
+      set_sampler_binding(mem_ctx, prog, name, type, binding);
+   } else if (storage->block_index != -1) {
+      set_block_binding(mem_ctx, prog, name, type, binding);
+   }
+}
+
+void
 set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
 			const char *name, const glsl_type *type,
 			ir_constant *val)




More information about the mesa-commit mailing list