From 13e85fa911b8aa787ee65ec957be8437bfb90b9b Mon Sep 17 00:00:00 2001 From: Matt Coster Date: Thu, 21 Sep 2023 12:13:14 +0100 Subject: [PATCH] pvr: Use vk_buffer_view base Signed-off-by: Matt Coster Acked-by: Alyssa Rosenzweig Part-of: --- src/imagination/vulkan/pvr_descriptor_set.c | 2 +- src/imagination/vulkan/pvr_image.c | 23 +++++++++------------ src/imagination/vulkan/pvr_private.h | 8 +++---- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/imagination/vulkan/pvr_descriptor_set.c b/src/imagination/vulkan/pvr_descriptor_set.c index 012f36b29ac..f19fa7320eb 100644 --- a/src/imagination/vulkan/pvr_descriptor_set.c +++ b/src/imagination/vulkan/pvr_descriptor_set.c @@ -1683,7 +1683,7 @@ static void pvr_write_buffer_descriptor(const struct pvr_device_info *dev_info, * compiler change to allow us to skip the range check. */ secondary[PVR_DESC_IMAGE_SECONDARY_OFFSET_WIDTH(dev_info)] = - (uint32_t)(bview->range / vk_format_get_blocksize(bview->format)); + (uint32_t)(bview->vk.elements); secondary[PVR_DESC_IMAGE_SECONDARY_OFFSET_HEIGHT(dev_info)] = 1; } } diff --git a/src/imagination/vulkan/pvr_image.c b/src/imagination/vulkan/pvr_image.c index a8f6fed799b..7d8bc25ced7 100644 --- a/src/imagination/vulkan/pvr_image.c +++ b/src/imagination/vulkan/pvr_image.c @@ -433,30 +433,27 @@ VkResult pvr_CreateBufferView(VkDevice _device, struct pvr_buffer_view *bview; VkResult result; - bview = vk_object_alloc(&device->vk, - pAllocator, - sizeof(*bview), - VK_OBJECT_TYPE_BUFFER_VIEW); + bview = vk_buffer_view_create(&device->vk, + pCreateInfo, + pAllocator, + sizeof(*bview)); if (!bview) return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); - bview->format = pCreateInfo->format; - bview->range = - vk_buffer_range(&buffer->vk, pCreateInfo->offset, pCreateInfo->range); - /* If the remaining size of the buffer is not a multiple of the element * size of the format, the nearest smaller multiple is used. */ - bview->range -= bview->range % vk_format_get_blocksize(bview->format); + bview->vk.range -= + bview->vk.range % vk_format_get_blocksize(bview->vk.format); /* The range of the buffer view shouldn't be smaller than one texel. */ - assert(bview->range >= vk_format_get_blocksize(bview->format)); + assert(bview->vk.range >= vk_format_get_blocksize(bview->vk.format)); info.base_level = 0U; info.mip_levels = 1U; info.mipmaps_present = false; info.extent.width = 8192U; - info.extent.height = bview->range / vk_format_get_blocksize(bview->format); + info.extent.height = bview->vk.elements; info.extent.height = DIV_ROUND_UP(info.extent.height, info.extent.width); info.extent.depth = 0U; info.sample_count = 1U; @@ -467,7 +464,7 @@ VkResult pvr_CreateBufferView(VkDevice _device, info.is_cube = false; info.type = VK_IMAGE_VIEW_TYPE_2D; info.tex_state_type = PVR_TEXTURE_STATE_SAMPLE; - info.format = bview->format; + info.format = bview->vk.format; info.flags = PVR_TEXFLAGS_INDEX_LOOKUP; info.aspect_mask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -501,5 +498,5 @@ void pvr_DestroyBufferView(VkDevice _device, if (!bview) return; - vk_object_free(&device->vk, pAllocator, bview); + vk_buffer_view_destroy(&device->vk, pAllocator, &bview->vk); } diff --git a/src/imagination/vulkan/pvr_private.h b/src/imagination/vulkan/pvr_private.h index f326afaa877..1f1725b440c 100644 --- a/src/imagination/vulkan/pvr_private.h +++ b/src/imagination/vulkan/pvr_private.h @@ -61,6 +61,7 @@ #include "util/u_dynarray.h" #include "util/u_math.h" #include "vk_buffer.h" +#include "vk_buffer_view.h" #include "vk_command_buffer.h" #include "vk_device.h" #include "vk_enum_to_str.h" @@ -344,10 +345,7 @@ struct pvr_image_view { }; struct pvr_buffer_view { - struct vk_object_base base; - - uint64_t range; - VkFormat format; + struct vk_buffer_view vk; /* Prepacked Texture dword 0 and 1. It will be copied to the descriptor * during pvr_UpdateDescriptorSets(). @@ -1485,7 +1483,7 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_image_view, VkImageView, VK_OBJECT_TYPE_IMAGE_VIEW) VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_buffer_view, - base, + vk.base, VkBufferView, VK_OBJECT_TYPE_BUFFER_VIEW) VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_descriptor_set_layout,