diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2020-03-05 12:33:05 -0800 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2020-03-12 13:18:54 -0700 |
commit | f8051f77ea00934cc00d9f55f1a737c50037af65 (patch) | |
tree | 3f12661a8847f11fb2cc0b82d977c545a08c0147 /src/intel | |
parent | 0a5053b687e7c9b69ecc743a770dff99952071b3 (diff) |
anv: Remove duplicate code in anv_cmd_buffer_bind_descriptor_set
Also use a single condition statement instead of two.
Reviewed-by: Jason Ekstrand <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4040>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4040>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/vulkan/anv_cmd_buffer.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c index 790f1433e0a..0b8e04dd633 100644 --- a/src/intel/vulkan/anv_cmd_buffer.c +++ b/src/intel/vulkan/anv_cmd_buffer.c @@ -618,22 +618,28 @@ anv_cmd_buffer_bind_descriptor_set(struct anv_cmd_buffer *cmd_buffer, struct anv_descriptor_set_layout *set_layout = layout->set[set_index].layout; - VkShaderStageFlags stages = set_layout->shader_stages & - (bind_point == VK_PIPELINE_BIND_POINT_COMPUTE ? - VK_SHADER_STAGE_COMPUTE_BIT : VK_SHADER_STAGE_ALL_GRAPHICS); + VkShaderStageFlags stages = set_layout->shader_stages; + struct anv_cmd_pipeline_state *pipe_state; + + switch (bind_point) { + case VK_PIPELINE_BIND_POINT_GRAPHICS: + stages &= VK_SHADER_STAGE_ALL_GRAPHICS; + pipe_state = &cmd_buffer->state.gfx.base; + break; + + case VK_PIPELINE_BIND_POINT_COMPUTE: + stages &= VK_SHADER_STAGE_COMPUTE_BIT; + pipe_state = &cmd_buffer->state.compute.base; + break; + + default: + unreachable("invalid bind point"); + } VkShaderStageFlags dirty_stages = 0; - if (bind_point == VK_PIPELINE_BIND_POINT_COMPUTE) { - if (cmd_buffer->state.compute.base.descriptors[set_index] != set) { - cmd_buffer->state.compute.base.descriptors[set_index] = set; - dirty_stages |= stages; - } - } else { - assert(bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS); - if (cmd_buffer->state.gfx.base.descriptors[set_index] != set) { - cmd_buffer->state.gfx.base.descriptors[set_index] = set; - dirty_stages |= stages; - } + if (pipe_state->descriptors[set_index] != set) { + pipe_state->descriptors[set_index] = set; + dirty_stages |= stages; } /* If it's a push descriptor set, we have to flag things as dirty |