From 0b72ff00b155e709dc656307f027d9f0fe2e7b67 Mon Sep 17 00:00:00 2001 From: Karmjit Mahil Date: Thu, 20 Oct 2022 11:24:14 +0100 Subject: [PATCH] pvr: Remove PVR_STATIC_CLEAR_.*_BIT and use VkImageAspectFlags. This commit removes the PVR_STATIC_CLEAR_.*_BIT used to index the static clear templates in the device. Now we use the Vulkan flags so no need for any conversion of the flags. Signed-off-by: Karmjit Mahil Reviewed-by: Frank Binns Part-of: --- src/imagination/vulkan/pvr_blit.c | 46 ++++--------------------- src/imagination/vulkan/pvr_clear.c | 6 ++-- src/imagination/vulkan/pvr_clear.h | 8 +---- src/imagination/vulkan/pvr_cmd_buffer.c | 4 +-- src/imagination/vulkan/pvr_private.h | 1 + 5 files changed, 14 insertions(+), 51 deletions(-) diff --git a/src/imagination/vulkan/pvr_blit.c b/src/imagination/vulkan/pvr_blit.c index ff5e7e96f84..af1605b536c 100644 --- a/src/imagination/vulkan/pvr_blit.c +++ b/src/imagination/vulkan/pvr_blit.c @@ -229,34 +229,6 @@ pvr_clear_needs_rt_id_output(struct pvr_device_info *dev_info, return false; } -static inline uint32_t -pvr_clear_template_idx_from_aspect(VkImageAspectFlags aspect) -{ - switch (aspect) { - case VK_IMAGE_ASPECT_COLOR_BIT: - /* From the Vulkan 1.3.229 spec VUID-VkClearAttachment-aspectMask-00019: - * - * "If aspectMask includes VK_IMAGE_ASPECT_COLOR_BIT, it must not - * include VK_IMAGE_ASPECT_DEPTH_BIT or VK_IMAGE_ASPECT_STENCIL_BIT" - * - */ - return PVR_STATIC_CLEAR_COLOR_BIT; - - case VK_IMAGE_ASPECT_DEPTH_BIT: - return PVR_STATIC_CLEAR_DEPTH_BIT; - - case VK_IMAGE_ASPECT_STENCIL_BIT: - return PVR_STATIC_CLEAR_STENCIL_BIT; - - case VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT: - return PVR_STATIC_CLEAR_DEPTH_BIT | PVR_STATIC_CLEAR_STENCIL_BIT; - - default: - unreachable("Invalid aspect mask for clear."); - return 0; - } -} - static VkResult pvr_clear_color_attachment_static_create_consts_buffer( struct pvr_cmd_buffer *cmd_buffer, const struct pvr_shader_factory_info *shader_info, @@ -470,6 +442,7 @@ static VkResult pvr_clear_color_attachment_static( texturedatabase.addr = PVR_DEV_ADDR(pds_texture_program_addr); } + assert(template_idx < PVR_STATIC_CLEAR_VARIANT_COUNT); template = cmd_buffer->device->static_clear_state.ppp_templates[template_idx]; @@ -478,7 +451,7 @@ static VkResult pvr_clear_color_attachment_static( template.config.ispctl.upass = cmd_buffer->state.render_pass_info.isp_userpass; - if (template_idx & PVR_STATIC_CLEAR_STENCIL_BIT) + if (template_idx & VK_IMAGE_ASPECT_STENCIL_BIT) template.config.ispa.sref = stencil; if (vs_has_rt_id_output) { @@ -582,7 +555,7 @@ static void pvr_clear_attachments(struct pvr_cmd_buffer *cmd_buffer, mrt_resource, format, packed_clear_color, - PVR_STATIC_CLEAR_COLOR_BIT, + VK_IMAGE_ASPECT_COLOR_BIT, 0, vs_has_rt_id_output); if (result != VK_SUCCESS) @@ -592,15 +565,11 @@ static void pvr_clear_attachments(struct pvr_cmd_buffer *cmd_buffer, const VkClearColorValue clear_color = { .float32 = { [0] = attachment->clearValue.depthStencil.depth, }, }; + const uint32_t template_idx = attachment->aspectMask | + VK_IMAGE_ASPECT_COLOR_BIT; const uint32_t stencil = attachment->clearValue.depthStencil.stencil; uint32_t packed_clear_color[PVR_CLEAR_COLOR_ARRAY_SIZE]; const struct usc_mrt_resource *mrt_resource; - uint32_t template_idx; - - template_idx = - pvr_clear_template_idx_from_aspect(attachment->aspectMask); - - template_idx |= PVR_STATIC_CLEAR_COLOR_BIT; assert(hw_pass->z_replicate > 0); mrt_resource = &hw_pass->setup.mrt_resources[hw_pass->z_replicate]; @@ -619,12 +588,11 @@ static void pvr_clear_attachments(struct pvr_cmd_buffer *cmd_buffer, if (result != VK_SUCCESS) return; } else { + const uint32_t template_idx = attachment->aspectMask; struct pvr_static_clear_ppp_template template; - uint32_t template_idx; struct pvr_bo *pvr_bo; - template_idx = - pvr_clear_template_idx_from_aspect(attachment->aspectMask); + assert(template_idx < PVR_STATIC_CLEAR_VARIANT_COUNT); template = cmd_buffer->device->static_clear_state.ppp_templates[template_idx]; diff --git a/src/imagination/vulkan/pvr_clear.c b/src/imagination/vulkan/pvr_clear.c index 5f39a3c0aea..a5b782e2abd 100644 --- a/src/imagination/vulkan/pvr_clear.c +++ b/src/imagination/vulkan/pvr_clear.c @@ -62,9 +62,9 @@ static void pvr_device_setup_graphics_static_clear_ppp_templates( templates[static PVR_STATIC_CLEAR_VARIANT_COUNT]) { for (uint32_t i = 0; i < PVR_STATIC_CLEAR_VARIANT_COUNT; i++) { - const bool has_depth = !!(i & PVR_STATIC_CLEAR_DEPTH_BIT); - const bool has_stencil = !!(i & PVR_STATIC_CLEAR_STENCIL_BIT); - const bool has_color = !!(i & PVR_STATIC_CLEAR_COLOR_BIT); + const bool has_color = !!(i & VK_IMAGE_ASPECT_COLOR_BIT); + const bool has_depth = !!(i & VK_IMAGE_ASPECT_DEPTH_BIT); + const bool has_stencil = !!(i & VK_IMAGE_ASPECT_STENCIL_BIT); struct pvr_static_clear_ppp_template *const template = &templates[i]; diff --git a/src/imagination/vulkan/pvr_clear.h b/src/imagination/vulkan/pvr_clear.h index 826ee7ba045..01a4047f3e9 100644 --- a/src/imagination/vulkan/pvr_clear.h +++ b/src/imagination/vulkan/pvr_clear.h @@ -75,13 +75,7 @@ static_assert(PVR_STATIC_CLEAR_PPP_PDS_TYPE_TEXTUREDATABASE + 1 == PVR_STATIC_CLEAR_PDS_STATE_COUNT, "pvr_static_clear_ppp_pds_state_type might require fixing."); -enum pvr_static_clear_variant_bits { - PVR_STATIC_CLEAR_DEPTH_BIT = BITFIELD_BIT(0), - PVR_STATIC_CLEAR_STENCIL_BIT = BITFIELD_BIT(1), - PVR_STATIC_CLEAR_COLOR_BIT = BITFIELD_BIT(2), -}; - -#define PVR_STATIC_CLEAR_VARIANT_COUNT (PVR_STATIC_CLEAR_COLOR_BIT << 1U) +#define PVR_STATIC_CLEAR_VARIANT_COUNT (VK_IMAGE_ASPECT_STENCIL_BIT << 1U) struct pvr_bo; struct pvr_cmd_buffer; diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c b/src/imagination/vulkan/pvr_cmd_buffer.c index 4fe1e5eb702..52644672d60 100644 --- a/src/imagination/vulkan/pvr_cmd_buffer.c +++ b/src/imagination/vulkan/pvr_cmd_buffer.c @@ -2421,7 +2421,7 @@ static VkResult pvr_cs_write_load_op(struct pvr_cmd_buffer *cmd_buffer, { const struct pvr_device *device = cmd_buffer->device; struct pvr_static_clear_ppp_template template = - device->static_clear_state.ppp_templates[PVR_STATIC_CLEAR_COLOR_BIT]; + device->static_clear_state.ppp_templates[VK_IMAGE_ASPECT_COLOR_BIT]; uint32_t pds_state[PVR_STATIC_CLEAR_PDS_STATE_COUNT]; struct pvr_pds_upload shareds_update_program; struct pvr_bo *pvr_bo; @@ -6034,7 +6034,7 @@ static void pvr_insert_transparent_obj(struct pvr_cmd_buffer *const cmd_buffer, * in parallel so writing the template in place could cause problems. */ struct pvr_static_clear_ppp_template clear = - device->static_clear_state.ppp_templates[PVR_STATIC_CLEAR_COLOR_BIT]; + device->static_clear_state.ppp_templates[VK_IMAGE_ASPECT_COLOR_BIT]; uint32_t pds_state[PVR_STATIC_CLEAR_PDS_STATE_COUNT] = { 0 }; struct pvr_csb *csb = &sub_cmd->control_stream; struct pvr_bo *ppp_bo; diff --git a/src/imagination/vulkan/pvr_private.h b/src/imagination/vulkan/pvr_private.h index 83a7f5c9599..fe4df7a19a0 100644 --- a/src/imagination/vulkan/pvr_private.h +++ b/src/imagination/vulkan/pvr_private.h @@ -342,6 +342,7 @@ struct pvr_device { struct pvr_bo *usc_multi_layer_vertex_shader_bo; struct pvr_static_clear_ppp_base ppp_base; + /* Indexable using VkImageAspectFlags. */ struct pvr_static_clear_ppp_template ppp_templates[PVR_STATIC_CLEAR_VARIANT_COUNT];