Mesa (master): st/glsl_to_nir: Calculate num_uniforms from NumParameterValues

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Mar 27 21:35:41 UTC 2019


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

Author: Kristian H. Kristensen <hoegsberg at chromium.org>
Date:   Tue Mar 26 09:53:38 2019 -0700

st/glsl_to_nir: Calculate num_uniforms from NumParameterValues

We don't need to determine the number of uniform slots here, it's
already available as prog->Parameters->NumParameterValues.  The way we
previously determined the number of slots was also broken for
PackedDriverUniformStorage, where we would add loc (in dwords) and
type_size() (in vec4s).

Signed-off-by: Kristian H. Kristensen <hoegsberg at chromium.org>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Rob Clark <robdclark at gmail.com>

---

 src/mesa/state_tracker/st_glsl_to_nir.cpp | 10 +++++-----
 1 file changed, 5 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 e5d5fe21e27..78ca83c76e7 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -240,9 +240,8 @@ st_nir_lookup_parameter_index(const struct gl_program_parameter_list *params,
 static void
 st_nir_assign_uniform_locations(struct gl_context *ctx,
                                 struct gl_program *prog,
-                                struct exec_list *uniform_list, unsigned *size)
+                                struct exec_list *uniform_list)
 {
-   int max = 0;
    int shaderidx = 0;
    int imageidx = 0;
 
@@ -298,9 +297,7 @@ st_nir_assign_uniform_locations(struct gl_context *ctx,
       }
 
       uniform->data.driver_location = loc;
-      max = MAX2(max, loc + type_size(uniform->type));
    }
-   *size = max;
 }
 
 void
@@ -934,7 +931,10 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
          st->ctx->Const.Program[nir->info.stage].MaxAtomicBuffers);
 
    st_nir_assign_uniform_locations(st->ctx, prog,
-                                   &nir->uniforms, &nir->num_uniforms);
+                                   &nir->uniforms);
+
+   /* Set num_uniforms in number of attribute slots (vec4s) */
+   nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);
 
    if (st->ctx->Const.PackedDriverUniformStorage) {
       NIR_PASS_V(nir, nir_lower_io, nir_var_uniform, st_glsl_type_dword_size,




More information about the mesa-commit mailing list