summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2020-04-23 15:55:14 +1000
committerMarge Bot <[email protected]>2020-04-24 08:31:01 +0000
commitffbec55072ed952db034779e3d0505a61c833397 (patch)
tree866384f0fd2ba8cd45d8313a96229a0b52261447 /src/compiler
parent9df1d92bbd5b2c6d6382e5d9bd640313fb279e1a (diff)
glsl: some nir uniform linker fixes
This fixes find_and_update_named_uniform_storage() for subroutines and also updates num_shader_uniform_components for non opaque uniforms. The following patch will ensure this type of bug won't happen again. Reviewed-by: Alejandro PiƱeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4721>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/gl_nir_link_uniforms.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c
index 175af7c7edb..6e24647d586 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -466,13 +466,13 @@ struct nir_link_uniforms_state {
unsigned num_hidden_uniforms;
unsigned num_values;
unsigned max_uniform_location;
- unsigned next_subroutine;
/* per-shader stage */
unsigned next_bindless_image_index;
unsigned next_bindless_sampler_index;
unsigned next_image_index;
unsigned next_sampler_index;
+ unsigned next_subroutine;
unsigned num_shader_samplers;
unsigned num_shader_images;
unsigned num_shader_uniform_components;
@@ -770,6 +770,23 @@ find_and_update_named_uniform_storage(struct gl_context *ctx,
if (!uniform->is_shader_storage)
state->num_shader_uniform_components += values;
+ } else {
+ if (glsl_get_base_type(type_no_array) == GLSL_TYPE_SUBROUTINE) {
+ struct gl_linked_shader *sh = prog->_LinkedShaders[stage];
+
+ uniform->opaque[stage].index = state->next_subroutine;
+ uniform->opaque[stage].active = true;
+
+ sh->Program->sh.NumSubroutineUniforms++;
+
+ /* Increment the subroutine index by 1 for non-arrays and by the
+ * number of array elements for arrays.
+ */
+ state->next_subroutine += MAX2(1, uniform->array_elements);
+ }
+
+ if (!state->var_is_in_block)
+ state->num_shader_uniform_components += values;
}
struct hash_entry *entry =