glsl: simplify add_uniform_to_shader::visit_field
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 23 Jun 2017 18:20:31 +0000 (20:20 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 5 Jul 2017 10:25:49 +0000 (12:25 +0200)
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@itsqueeze.com>
src/mesa/program/ir_to_mesa.cpp

index 93c6946fd63ff73e072283372fe45a007e74a9f6..ac12b59d0751399c1889d381b5b6d50b711a717c 100644 (file)
@@ -2450,13 +2450,12 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
    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).