<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 26, 2016 at 2:02 PM, Rob Clark <span dir="ltr"><<a href="mailto:robdclark@gmail.com" target="_blank">robdclark@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Rob Clark <<a href="mailto:robclark@freedesktop.org">robclark@freedesktop.org</a>><br>
<br>
We'll need this for a nir pass to lower builtin-uniform access.<br>
<br>
Signed-off-by: Rob Clark <<a href="mailto:robclark@freedesktop.org">robclark@freedesktop.org</a>><br>
---<br>
 src/compiler/glsl/builtin_variables.cpp | 24 +++++++++++++++---------<br>
 src/compiler/glsl/ir.h                  |  3 +++<br>
 2 files changed, 18 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp<br>
index 4e2de37..994a122 100644<br>
--- a/src/compiler/glsl/builtin_variables.cpp<br>
+++ b/src/compiler/glsl/builtin_variables.cpp<br>
@@ -524,23 +524,29 @@ builtin_variable_generator::add_variable(const char *name,<br>
    return var;<br>
 }<br>
<br>
-<br>
-ir_variable *<br>
-builtin_variable_generator::add_uniform(const glsl_type *type,<br>
-                                        const char *name)<br>
+extern "C" {<br>
+const struct gl_builtin_uniform_desc *<br>
+_mesa_glsl_get_builtin_uniform_desc(const char *name)<br>
 {<br>
-   ir_variable *const uni = add_variable(name, type, ir_var_uniform, -1);<br>
-<br>
    unsigned i;<br></blockquote><div><br></div><div>You can pull this inside the loop now.  Otherwise, looks good.<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    for (i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) {<br>
       if (strcmp(_mesa_builtin_uniform_desc[i].name, name) == 0) {<br>
-        break;<br>
+         return &_mesa_builtin_uniform_desc[i];<br>
       }<br>
    }<br>
+   return NULL;<br>
+}<br>
+}<br>
+<br>
+ir_variable *<br>
+builtin_variable_generator::add_uniform(const glsl_type *type,<br>
+                                        const char *name)<br>
+{<br>
+   ir_variable *const uni = add_variable(name, type, ir_var_uniform, -1);<br>
<br>
-   assert(_mesa_builtin_uniform_desc[i].name != NULL);<br>
    const struct gl_builtin_uniform_desc* const statevar =<br>
-      &_mesa_builtin_uniform_desc[i];<br>
+      _mesa_glsl_get_builtin_uniform_desc(name);<br>
+   assert(statevar != NULL);<br>
<br>
    const unsigned array_count = type->is_array() ? type->length : 1;<br>
<br>
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h<br>
index b74d68a..4c27f1c 100644<br>
--- a/src/compiler/glsl/ir.h<br>
+++ b/src/compiler/glsl/ir.h<br>
@@ -2608,6 +2608,9 @@ extern void _mesa_print_ir(FILE *f, struct exec_list *instructions,<br>
 extern void<br>
 fprint_ir(FILE *f, const void *instruction);<br>
<br>
+extern const struct gl_builtin_uniform_desc *<br>
+_mesa_glsl_get_builtin_uniform_desc(const char *name);<br>
+<br>
 #ifdef __cplusplus<br>
 } /* extern "C" */<br>
 #endif<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.5<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>