From 7386342a19a35ecd3e51abdb0053079ab43a82cf Mon Sep 17 00:00:00 2001 From: Karmjit Mahil Date: Thu, 5 Jan 2023 11:41:26 +0000 Subject: [PATCH] pvr: Add PVR_SELECT() helper macro For pvr_setup_descriptor_mappings_new() there will be quite a few variables of which the value depend on the stage so rather than having all that selection in the `switch` at the beginning of the function the helper macro provides a compact selection in the desired scope. Signed-off-by: Karmjit Mahil Reviewed-by: Frank Binns Part-of: --- src/imagination/vulkan/pvr_cmd_buffer.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c b/src/imagination/vulkan/pvr_cmd_buffer.c index ed1ce3d..8a95f74 100644 --- a/src/imagination/vulkan/pvr_cmd_buffer.c +++ b/src/imagination/vulkan/pvr_cmd_buffer.c @@ -3206,6 +3206,11 @@ static VkResult pvr_setup_descriptor_mappings_old( return VK_SUCCESS; } +#define PVR_SELECT(_geom, _frag, _compute) \ + (stage == PVR_STAGE_ALLOCATION_VERTEX_GEOMETRY) \ + ? (_geom) \ + : (stage == PVR_STAGE_ALLOCATION_FRAGMENT) ? (_frag) : (_compute) + static VkResult pvr_cmd_buffer_upload_desc_set_table(struct pvr_cmd_buffer *const cmd_buffer, enum pvr_stage_allocation stage, @@ -3219,11 +3224,7 @@ pvr_cmd_buffer_upload_desc_set_table(struct pvr_cmd_buffer *const cmd_buffer, switch (stage) { case PVR_STAGE_ALLOCATION_VERTEX_GEOMETRY: case PVR_STAGE_ALLOCATION_FRAGMENT: - desc_state = &cmd_buffer->state.gfx_desc_state; - break; - case PVR_STAGE_ALLOCATION_COMPUTE: - desc_state = &cmd_buffer->state.compute_desc_state; break; default: @@ -3231,6 +3232,10 @@ pvr_cmd_buffer_upload_desc_set_table(struct pvr_cmd_buffer *const cmd_buffer, break; } + desc_state = PVR_SELECT(&cmd_buffer->state.gfx_desc_state, + &cmd_buffer->state.gfx_desc_state, + &cmd_buffer->state.compute_desc_state); + for (uint32_t set = 0; set < ARRAY_SIZE(bound_desc_sets); set++) { if (!(desc_state->valid_mask & BITFIELD_BIT(set))) { bound_desc_sets[set] = PVR_DEV_ADDR_INVALID.addr; @@ -3280,6 +3285,8 @@ pvr_process_addr_literal(struct pvr_cmd_buffer *cmd_buffer, return VK_SUCCESS; } +#undef PVR_SELECT + static VkResult pvr_setup_descriptor_mappings_new( struct pvr_cmd_buffer *const cmd_buffer, enum pvr_stage_allocation stage, -- 2.7.4