[Mesa-dev] [PATCH 10/11] glsl: Handle the binding qualifier for UBO variables.

Kenneth Graunke kenneth at whitecape.org
Wed Jul 17 18:24:10 PDT 2013


layout(binding = N) is equivalent to calling glUniformBlockBinding(_,N).

This currently only handles the GLSL 1.40 case - no interface names, no
arrays of uniform blocks.  This is okay since we don't yet support GLSL
1.50, and don't expose ARB_shading_language_420pack in ES 3.0.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/link_uniform_initializers.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp
index f42b06b..f398bb2 100644
--- a/src/glsl/link_uniform_initializers.cpp
+++ b/src/glsl/link_uniform_initializers.cpp
@@ -144,6 +144,16 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
             }
          }
       }
+   } else if (storage->block_index != -1) {
+      /* This is a field of a UBO.  val is the binding index. */
+      for (int i = 0; i < MESA_SHADER_TYPES; i++) {
+         int stage_index = prog->UniformBlockStageIndex[i][storage->block_index];
+
+         if (stage_index != -1) {
+            struct gl_shader *sh = prog->_LinkedShaders[i];
+            sh->UniformBlocks[stage_index].Binding = val->value.i[0];
+         }
+      }
    } else if (val->type->is_array()) {
       const enum glsl_base_type base_type =
 	 val->array_elements[0]->type->base_type;
-- 
1.8.3.2



More information about the mesa-dev mailing list