diff options
author | Timothy Arceri <[email protected]> | 2020-01-10 12:28:24 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2020-01-12 11:02:20 +1100 |
commit | 6bafd230e37c78829bae680a36e1565df03731f6 (patch) | |
tree | 23d6cd75635dedee8ae17872915713dd75649628 /src/compiler | |
parent | db7967ef9f08e1430bbebc752bcbb63e8c921c29 (diff) |
glsl: fix potential bug in nir uniform linker
The state value of main_uniform_storage_index will be wrong for
add_parameter() when find_and_update_previous_uniform_storage()
finds a uniform if there is more than 1 uniform used in
multiple shader stages.
The new code is also simpler.
Reviewed-by: Alejandro Piñeiro <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/glsl/gl_nir_link_uniforms.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index b68a8e56502..4ecd34da2b2 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -257,7 +257,6 @@ struct nir_link_uniforms_state { bool var_is_in_block; int top_level_array_size; int top_level_array_stride; - int main_uniform_storage_index; struct type_tree_entry *current_type; }; @@ -394,7 +393,7 @@ add_parameter(struct gl_uniform_storage *uniform, for (unsigned i = 0; i < num_params; i++) { struct gl_program_parameter *param = ¶ms->Parameters[base_index + i]; param->UniformStorageIndex = uniform - prog->data->UniformStorage; - param->MainUniformStorageIndex = state->main_uniform_storage_index; + param->MainUniformStorageIndex = state->current_var->data.location; } } @@ -490,9 +489,6 @@ nir_link_uniform(struct gl_context *ctx, return -1; } - if (state->main_uniform_storage_index == -1) - state->main_uniform_storage_index = prog->data->NumUniformStorage; - uniform = &prog->data->UniformStorage[prog->data->NumUniformStorage]; prog->data->NumUniformStorage++; @@ -703,6 +699,8 @@ gl_nir_link_uniforms(struct gl_context *ctx, nir_foreach_variable(var, &nir->uniforms) { struct gl_uniform_storage *uniform = NULL; + state.current_var = var; + /* Check if the uniform has been processed already for * other stage. If so, validate they are compatible and update * the active stage mask. @@ -721,12 +719,10 @@ gl_nir_link_uniforms(struct gl_context *ctx, /* From now on the variable’s location will be its uniform index */ var->data.location = prog->data->NumUniformStorage; - state.current_var = var; state.offset = 0; state.var_is_in_block = nir_variable_is_in_block(var); state.top_level_array_size = 0; state.top_level_array_stride = 0; - state.main_uniform_storage_index = -1; /* * From ARB_program_interface spec, issue (16): |