diff options
author | Timothy Arceri <[email protected]> | 2019-12-04 00:14:03 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2019-12-05 13:18:23 +1100 |
commit | f0cb0fe1c0804ce87bb66d0ad4c9d31e36ef985f (patch) | |
tree | 25dd2f00a996a106d36e57654844d39a43040733 /src/compiler | |
parent | 50dc4b77f6ba7f70c110b8b35479c8ee8ddaaa96 (diff) |
glsl: don't set uniform block as used when its not
The spec requires unused uniform block to be set as active in the
program resource list. To support this we tell opt dead code not to
remove them. However we can mark them as unused internally and
avoid unnecessarily state changes.
This change is also required for the folowing clean-up patch.
Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/glsl/link_uniforms.cpp | 3 | ||||
-rw-r--r-- | src/compiler/glsl/opt_dead_code.cpp | 9 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp index c7ca7034a51..6518ec10f34 100644 --- a/src/compiler/glsl/link_uniforms.cpp +++ b/src/compiler/glsl/link_uniforms.cpp @@ -1059,7 +1059,8 @@ private: this->uniforms[id].opaque[shader_type].index = ~0; this->uniforms[id].opaque[shader_type].active = false; - this->uniforms[id].active_shader_mask |= 1 << shader_type; + if (current_var->data.used || base_type->is_subroutine()) + this->uniforms[id].active_shader_mask |= 1 << shader_type; /* This assigns uniform indices to sampler and image uniforms. */ handle_samplers(base_type, &this->uniforms[id], name); diff --git a/src/compiler/glsl/opt_dead_code.cpp b/src/compiler/glsl/opt_dead_code.cpp index 1eff3f2fd14..3e571fc7dd0 100644 --- a/src/compiler/glsl/opt_dead_code.cpp +++ b/src/compiler/glsl/opt_dead_code.cpp @@ -144,8 +144,15 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned) */ if (entry->var->is_in_buffer_block()) { if (entry->var->get_interface_type_packing() != - GLSL_INTERFACE_PACKING_PACKED) + GLSL_INTERFACE_PACKING_PACKED) { + /* Set used to false so it doesn't get set as referenced by + * the shader in the program resource list. This will also + * help avoid the state being unnecessarily flushed for the + * shader stage. + */ + entry->var->data.used = false; continue; + } } if (entry->var->type->is_subroutine()) |