From 4488b577a18e51ccb0dc229499bc2bf50255d044 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Tue, 12 Oct 2021 13:38:46 +1100 Subject: [PATCH] glsl/nir: skip adding hidden uniforms to the remap tables The remap tables are used with the GL API so there is no need to add hidden uniforms to them. Also when we switch to lowering some constant arrays to uniforms in NIR in a following patch there will no longer be enough room in the tables as we assign their size in the GLSL IR linker not the NIR linker currently. Acked-by: Emma Anholt Part-of: --- src/compiler/glsl/gl_nir_link_uniforms.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index aa77225600b..cc223b9fafb 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -211,6 +211,9 @@ nir_setup_uniform_remap_tables(const struct gl_constants *consts, for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) { struct gl_uniform_storage *uniform = &prog->data->UniformStorage[i]; + if (uniform->hidden) + continue; + if (uniform->is_shader_storage || glsl_get_base_type(uniform->type) == GLSL_TYPE_SUBROUTINE) continue; @@ -240,6 +243,9 @@ nir_setup_uniform_remap_tables(const struct gl_constants *consts, for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) { struct gl_uniform_storage *uniform = &prog->data->UniformStorage[i]; + if (uniform->hidden) + continue; + if (uniform->is_shader_storage || glsl_get_base_type(uniform->type) == GLSL_TYPE_SUBROUTINE) continue; @@ -383,6 +389,24 @@ nir_setup_uniform_remap_tables(const struct gl_constants *consts, p->sh.NumSubroutineUniformRemapTable += entries; } } + + /* assign storage to hidden uniforms */ + for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) { + struct gl_uniform_storage *uniform = &prog->data->UniformStorage[i]; + + if (!uniform->hidden || + glsl_get_base_type(uniform->type) == GLSL_TYPE_SUBROUTINE) + continue; + + const unsigned entries = + MAX2(1, prog->data->UniformStorage[i].array_elements); + + uniform->storage = &data[data_pos]; + + unsigned num_slots = glsl_get_component_slots(uniform->type); + for (unsigned k = 0; k < entries; k++) + data_pos += num_slots; + } } static void