glsl: export accessor for builtin-uniform descriptors
authorRob Clark <robclark@freedesktop.org>
Fri, 29 Jan 2016 16:18:11 +0000 (11:18 -0500)
committerRob Clark <robclark@freedesktop.org>
Wed, 11 May 2016 16:20:12 +0000 (12:20 -0400)
We'll need this for a nir pass to lower builtin-uniform access.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/glsl/builtin_variables.cpp
src/compiler/glsl/ir.h

index f31f9f61ef6126077e78e7ef02e70b67e7518661..cc32990fc2f346616952c8cbaf8d2f9ccdeef7e8 100644 (file)
@@ -527,6 +527,16 @@ builtin_variable_generator::add_variable(const char *name,
    return var;
 }
 
+extern "C" const struct gl_builtin_uniform_desc *
+_mesa_glsl_get_builtin_uniform_desc(const char *name)
+{
+   for (unsigned i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) {
+      if (strcmp(_mesa_builtin_uniform_desc[i].name, name) == 0) {
+         return &_mesa_builtin_uniform_desc[i];
+      }
+   }
+   return NULL;
+}
 
 ir_variable *
 builtin_variable_generator::add_uniform(const glsl_type *type,
@@ -534,16 +544,9 @@ builtin_variable_generator::add_uniform(const glsl_type *type,
 {
    ir_variable *const uni = add_variable(name, type, ir_var_uniform, -1);
 
-   unsigned i;
-   for (i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) {
-      if (strcmp(_mesa_builtin_uniform_desc[i].name, name) == 0) {
-        break;
-      }
-   }
-
-   assert(_mesa_builtin_uniform_desc[i].name != NULL);
    const struct gl_builtin_uniform_desc* const statevar =
-      &_mesa_builtin_uniform_desc[i];
+      _mesa_glsl_get_builtin_uniform_desc(name);
+   assert(statevar != NULL);
 
    const unsigned array_count = type->is_array() ? type->length : 1;
 
index 0c319ea8f27788d2259321841d47b0e923004234..6e0dc0b1bcdd1edf5bc7e74e926633b34406d979 100644 (file)
@@ -2626,6 +2626,9 @@ extern void _mesa_print_ir(FILE *f, struct exec_list *instructions,
 extern void
 fprint_ir(FILE *f, const void *instruction);
 
+extern const struct gl_builtin_uniform_desc *
+_mesa_glsl_get_builtin_uniform_desc(const char *name);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif