pvr: remove image pointer from image view struct
authorFrank Binns <frank.binns@imgtec.com>
Fri, 26 Aug 2022 13:57:36 +0000 (14:57 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 09:21:54 +0000 (09:21 +0000)
A pointer is also stored in the base vk_image_view struct, so we can use this
one instead.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18373>

src/imagination/vulkan/pvr_cmd_buffer.c
src/imagination/vulkan/pvr_descriptor_set.c
src/imagination/vulkan/pvr_image.c
src/imagination/vulkan/pvr_private.h
src/imagination/vulkan/pvr_queue.c

index b0db987..d64d8e3 100644 (file)
@@ -740,7 +740,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 = iview->image;
+   const struct pvr_image *image = vk_to_pvr_image(iview->vk.image);
    uint32_t level_pitch = image->mip_levels[iview->vk.base_mip_level].pitch;
 
    struct pvr_pbe_surf_params surface_params;
@@ -1004,7 +1004,7 @@ static VkResult pvr_sub_cmd_gfx_job_init(const struct pvr_device_info *dev_info,
    if (hw_render->ds_surface_id != -1) {
       struct pvr_image_view *iview =
          render_pass_info->attachments[hw_render->ds_surface_id];
-      const struct pvr_image *image = iview->image;
+      const struct pvr_image *image = vk_to_pvr_image(iview->vk.image);
 
       if (vk_format_has_depth(image->vk.format)) {
          uint32_t level_pitch =
index b2e9a48..0f410cb 100644 (file)
@@ -1489,16 +1489,16 @@ 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)) {
-      uint64_t addr = iview->image->dev_addr.addr +
-                      iview->vk.base_array_layer * iview->image->layer_size;
+      const struct pvr_image *image = vk_to_pvr_image(iview->vk.image);
+      uint64_t addr =
+         image->dev_addr.addr + iview->vk.base_array_layer * image->layer_size;
 
       secondary[PVR_DESC_IMAGE_SECONDARY_OFFSET_ARRAYBASE] = (uint32_t)addr;
       secondary[PVR_DESC_IMAGE_SECONDARY_OFFSET_ARRAYBASE + 1U] =
          (uint32_t)(addr >> 32U);
 
       secondary[PVR_DESC_IMAGE_SECONDARY_OFFSET_ARRAYSTRIDE] =
-         cube_array_adjust ? iview->image->layer_size * 6
-                           : iview->image->layer_size;
+         cube_array_adjust ? image->layer_size * 6 : image->layer_size;
    }
 
    if (cube_array_adjust) {
index 4a8a68d..d6f9239 100644 (file)
@@ -258,11 +258,11 @@ VkResult pvr_CreateImageView(VkDevice _device,
                              const VkAllocationCallbacks *pAllocator,
                              VkImageView *pView)
 {
-   PVR_FROM_HANDLE(pvr_image, image, pCreateInfo->image);
    PVR_FROM_HANDLE(pvr_device, device, _device);
    struct pvr_texture_state_info info;
    unsigned char input_swizzle[4];
    const uint8_t *format_swizzle;
+   const struct pvr_image *image;
    struct pvr_image_view *iview;
    VkResult result;
 
@@ -274,7 +274,7 @@ VkResult pvr_CreateImageView(VkDevice _device,
    if (!iview)
       return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
 
-   iview->image = image;
+   image = vk_to_pvr_image(iview->vk.image);
 
    info.type = iview->vk.view_type;
    info.base_level = iview->vk.base_mip_level;
index 874d7b4..e35c966 100644 (file)
@@ -349,9 +349,6 @@ struct pvr_buffer {
 struct pvr_image_view {
    struct vk_image_view vk;
 
-   /* Saved information from pCreateInfo. */
-   const struct pvr_image *image;
-
    /* Prepacked Texture Image dword 0 and 1. It will be copied to the
     * descriptor info during pvr_UpdateDescriptorSets().
     *
@@ -1354,6 +1351,12 @@ to_pvr_graphics_pipeline(struct pvr_pipeline *pipeline)
    return container_of(pipeline, struct pvr_graphics_pipeline, base);
 }
 
+static inline const struct pvr_image *
+vk_to_pvr_image(const struct vk_image *image)
+{
+   return container_of(image, const struct pvr_image, vk);
+}
+
 static enum pvr_pipeline_stage_bits
 pvr_stage_mask(VkPipelineStageFlags2 stage_mask)
 {
index d74c157..3b85040 100644 (file)
@@ -240,10 +240,13 @@ pvr_process_graphics_cmd(struct pvr_device *device,
 
    /* Get any imported buffers used in framebuffer attachments. */
    for (uint32_t i = 0U; i < framebuffer->attachment_count; i++) {
-      if (!framebuffer->attachments[i]->image->vma->bo->is_imported)
+      const struct pvr_image *image =
+         vk_to_pvr_image(framebuffer->attachments[i]->vk.image);
+
+      if (!image->vma->bo->is_imported)
          continue;
 
-      bos[bo_count].bo = framebuffer->attachments[i]->image->vma->bo;
+      bos[bo_count].bo = image->vma->bo;
       bos[bo_count].flags = PVR_WINSYS_JOB_BO_FLAG_WRITE;
       bo_count++;
    }