[Mesa-dev] [PATCH v2 2/4] glsl: simplify add_uniform_to_shader::visit_field

Nicolai Hähnle nhaehnle at gmail.com
Mon Jul 3 12:34:33 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Each field gets a distinct name, so we should never hit the case where
the name already exists in the parameter list.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
---
 src/mesa/program/ir_to_mesa.cpp | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 93c6946..ac12b59 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2443,27 +2443,26 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
                                    const glsl_type * /* record_type */,
                                    const enum glsl_interface_packing,
                                    bool /* last_field */)
 {
    /* opaque types don't use storage in the param list unless they are
     * bindless samplers or images.
     */
    if (type->contains_opaque() && !var->data.bindless)
       return;
 
-   int index = _mesa_lookup_parameter_index(params, name);
-   if (index < 0) {
-      unsigned size = type_size(type) * 4;
+   assert(_mesa_lookup_parameter_index(params, name) < 0);
 
-      index = _mesa_add_parameter(params, PROGRAM_UNIFORM, name, size,
-                                  type->gl_type, NULL, NULL);
-   }
+   unsigned size = type_size(type) * 4;
+
+   int index = _mesa_add_parameter(params, PROGRAM_UNIFORM, name, size,
+                                   type->gl_type, NULL, NULL);
 
    /* The first part of the uniform that's processed determines the base
     * location of the whole uniform (for structures).
     */
    if (this->idx < 0)
       this->idx = index;
 }
 
 /**
  * Generate the program parameters list for the user uniforms in a shader
-- 
2.9.3



More information about the mesa-dev mailing list