Module: Mesa
Branch: master
Commit: 1a96811fe1059de097a70121a8d1b905089422fd
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a96811fe1059de097a70121a8d1b905089422fd

Author: Caio Marcelo de Oliveira Filho <caio.olive...@intel.com>
Date:   Wed Aug 21 09:38:10 2019 -0700

mesa/st: Do not rely on name to identify special uniforms

Every uniform that have the "gl_" name also have some state slots.  So
use the state_slots like we did in 57b61849310 ("i965: account for NIR
uniforms without name").

This removes the dependency on names, which are optional when using
ARB_gl_spirv.

Reviewed-by: Alejandro PiƱeiro <apinhe...@igalia.com>

---

 src/mesa/state_tracker/st_glsl_to_nir.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index b9ce22c4a6e..dac5ba2378d 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -183,7 +183,7 @@ st_nir_assign_uniform_locations(struct gl_context *ctx,
             loc = imageidx;
             imageidx += type_size(uniform->type);
          }
-      } else if (strncmp(uniform->name, "gl_", 3) == 0) {
+      } else if (uniform->state_slots) {
          const gl_state_index16 *const stateTokens = 
uniform->state_slots[0].tokens;
          /* This state reference has already been setup by ir_to_mesa, but 
we'll
           * get the same index back here.
@@ -409,10 +409,8 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct 
gl_program *prog,
     * get sent to the shader.
     */
    nir_foreach_variable(var, &nir->uniforms) {
-      if (strncmp(var->name, "gl_", 3) == 0) {
-         const nir_state_slot *const slots = var->state_slots;
-         assert(var->state_slots != NULL);
-
+      const nir_state_slot *const slots = var->state_slots;
+      if (slots != NULL) {
          const struct glsl_type *type = glsl_without_array(var->type);
          for (unsigned int i = 0; i < var->num_state_slots; i++) {
             unsigned comps;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to