[Mesa-dev] [PATCH 13/17] glsl: export accessor for builtin-uniform descriptors
Rob Clark
robdclark at gmail.com
Fri Apr 15 14:49:48 UTC 2016
From: Rob Clark <robclark at freedesktop.org>
We'll need this for a nir pass to lower builtin-uniform access.
Signed-off-by: Rob Clark <robclark at freedesktop.org>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/compiler/glsl/builtin_variables.cpp | 23 ++++++++++++++---------
src/compiler/glsl/ir.h | 3 +++
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index f31f9f6..14bc0ef 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -527,6 +527,18 @@ 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 +546,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;
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index b1a1d56..d7b22b7 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -2621,6 +2621,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
--
2.5.5
More information about the mesa-dev
mailing list