Mesa (master): mesa: Fill Parameter storage indices even when not using SPIR-V

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Sep 10 22:07:02 UTC 2019


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

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Wed Sep  4 09:28:54 2019 -0700

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 <tarceri at itsqueeze.com>

---

 src/mesa/program/ir_to_mesa.cpp | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

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 = &params->Parameters[index + i];
+      param->UniformStorageIndex = location;
+      param->MainUniformStorageIndex = params->Parameters[this->idx].UniformStorageIndex;
+   }
 }
 
 /**




More information about the mesa-commit mailing list