From: Caio Marcelo de Oliveira Filho Date: Wed, 4 Sep 2019 16:28:54 +0000 (-0700) Subject: mesa: Fill Parameter storage indices even when not using SPIR-V X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4dd1ef9d0a39c52231e880b4900655991a7ced1d;p=mesa.git mesa: Fill Parameter storage indices even when not using SPIR-V When creating Parameters, fill in the associated uniform storage indices, like it is done with the NIR linker used for SPIR-V. This will allow later code to not rely on names (which would never work for SPIR-V where names are optional). Reviewed-by: Timothy Arceri --- diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 053912a8410..30e8606b253 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2390,7 +2390,7 @@ public: add_uniform_to_shader(struct gl_context *ctx, struct gl_shader_program *shader_program, struct gl_program_parameter_list *params) - : ctx(ctx), params(params), idx(-1) + : ctx(ctx), shader_program(shader_program), params(params), idx(-1) { /* empty */ } @@ -2411,6 +2411,7 @@ private: bool last_field); struct gl_context *ctx; + struct gl_shader_program *shader_program; struct gl_program_parameter_list *params; int idx; ir_variable *var; @@ -2472,6 +2473,21 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name, */ if (this->idx < 0) this->idx = index; + + /* Each Parameter will hold the index to the backing uniform storage. + * This avoids relying on names to match parameters and uniform + * storages later when associating uniform storage. + */ + unsigned location; + const bool found = + shader_program->UniformHash->get(location, params->Parameters[index].Name); + assert(found); + + for (unsigned i = 0; i < num_params; i++) { + struct gl_program_parameter *param = ¶ms->Parameters[index + i]; + param->UniformStorageIndex = location; + param->MainUniformStorageIndex = params->Parameters[this->idx].UniformStorageIndex; + } } /**