From c31998b7d376d9c94b406e141a937d88e3455b01 Mon Sep 17 00:00:00 2001 From: Matt Coster Date: Mon, 27 Feb 2023 09:08:02 +0000 Subject: [PATCH] pvr: Add pvr_image_view_get_image() This replaces the pattern of vk_to_pvr_image(iview->vk.image). Signed-off-by: Matt Coster Reviewed-by: Karmjit Mahil Part-of: --- src/imagination/vulkan/pvr_cmd_buffer.c | 6 +++--- src/imagination/vulkan/pvr_descriptor_set.c | 2 +- src/imagination/vulkan/pvr_image.c | 4 ++-- src/imagination/vulkan/pvr_private.h | 6 ++++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c b/src/imagination/vulkan/pvr_cmd_buffer.c index 1a9075241ca..ad249b23dfb 100644 --- a/src/imagination/vulkan/pvr_cmd_buffer.c +++ b/src/imagination/vulkan/pvr_cmd_buffer.c @@ -925,7 +925,7 @@ static void pvr_setup_pbe_state( uint32_t pbe_cs_words[static const ROGUE_NUM_PBESTATE_STATE_WORDS], uint64_t pbe_reg_words[static const ROGUE_NUM_PBESTATE_REG_WORDS]) { - const struct pvr_image *image = vk_to_pvr_image(iview->vk.image); + const struct pvr_image *image = pvr_image_view_get_image(iview); uint32_t level_pitch = image->mip_levels[iview->vk.base_mip_level].pitch; struct pvr_pbe_surf_params surface_params; @@ -1305,7 +1305,7 @@ static VkResult pvr_sub_cmd_gfx_job_init(const struct pvr_device_info *dev_info, if (hw_render->ds_attach_idx != VK_ATTACHMENT_UNUSED) { struct pvr_image_view *iview = render_pass_info->attachments[hw_render->ds_attach_idx]; - const struct pvr_image *image = vk_to_pvr_image(iview->vk.image); + const struct pvr_image *image = pvr_image_view_get_image(iview); job->has_depth_attachment = vk_format_has_depth(image->vk.format); job->has_stencil_attachment = vk_format_has_stencil(image->vk.format); @@ -1419,7 +1419,7 @@ static VkResult pvr_sub_cmd_gfx_job_init(const struct pvr_device_info *dev_info, if (hw_render->ds_attach_idx != VK_ATTACHMENT_UNUSED) { struct pvr_image_view *iview = render_pass_info->attachments[hw_render->ds_attach_idx]; - const struct pvr_image *image = vk_to_pvr_image(iview->vk.image); + const struct pvr_image *image = pvr_image_view_get_image(iview); /* If the HW render pass has a valid depth/stencil surface, determine the * sample count from the attachment's image. diff --git a/src/imagination/vulkan/pvr_descriptor_set.c b/src/imagination/vulkan/pvr_descriptor_set.c index 1a6b2d8b140..7d34e5ea0e1 100644 --- a/src/imagination/vulkan/pvr_descriptor_set.c +++ b/src/imagination/vulkan/pvr_descriptor_set.c @@ -1493,7 +1493,7 @@ pvr_write_image_descriptor_secondaries(const struct pvr_device_info *dev_info, iview->vk.view_type == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; if (!PVR_HAS_FEATURE(dev_info, tpu_array_textures)) { - const struct pvr_image *image = vk_to_pvr_image(iview->vk.image); + const struct pvr_image *image = pvr_image_view_get_image(iview); uint64_t addr = image->dev_addr.addr + iview->vk.base_array_layer * image->layer_size; diff --git a/src/imagination/vulkan/pvr_image.c b/src/imagination/vulkan/pvr_image.c index c9067750db7..2858eb76c2c 100644 --- a/src/imagination/vulkan/pvr_image.c +++ b/src/imagination/vulkan/pvr_image.c @@ -280,7 +280,7 @@ VkResult pvr_CreateImageView(VkDevice _device, if (!iview) return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); - image = vk_to_pvr_image(iview->vk.image); + image = pvr_image_view_get_image(iview); info.type = iview->vk.view_type; info.base_level = iview->vk.base_mip_level; @@ -342,7 +342,7 @@ VkResult pvr_CreateImageView(VkDevice _device, info.base_level = 0; info.tex_state_type = PVR_TEXTURE_STATE_ATTACHMENT; - if (iview->vk.image->image_type == VK_IMAGE_TYPE_3D && + if (image->vk.image_type == VK_IMAGE_TYPE_3D && iview->vk.view_type == VK_IMAGE_VIEW_TYPE_2D) { info.type = VK_IMAGE_VIEW_TYPE_3D; } else { diff --git a/src/imagination/vulkan/pvr_private.h b/src/imagination/vulkan/pvr_private.h index 584838cb565..aea5fabfe5b 100644 --- a/src/imagination/vulkan/pvr_private.h +++ b/src/imagination/vulkan/pvr_private.h @@ -1285,6 +1285,12 @@ vk_to_pvr_image(const struct vk_image *image) return container_of(image, const struct pvr_image, vk); } +static inline const struct pvr_image * +pvr_image_view_get_image(const struct pvr_image_view *const iview) +{ + return vk_to_pvr_image(iview->vk.image); +} + static enum pvr_pipeline_stage_bits pvr_stage_mask(VkPipelineStageFlags2 stage_mask) {