Module: Mesa Branch: main Commit: efb9b036373e07bef811e98f648f366d5b63a41f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=efb9b036373e07bef811e98f648f366d5b63a41f
Author: Matt Coster <[email protected]> Date: Fri Aug 11 12:07:12 2023 +0100 pvr: Use vk_sampler base Signed-off-by: Matt Coster <[email protected]> Reviewed-by: Karmjit Mahil <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25270> --- src/imagination/vulkan/pvr_border.c | 6 +++--- src/imagination/vulkan/pvr_border.h | 11 +++++++---- src/imagination/vulkan/pvr_common.h | 3 ++- src/imagination/vulkan/pvr_device.c | 11 +++++------ src/imagination/vulkan/pvr_private.h | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/imagination/vulkan/pvr_border.c b/src/imagination/vulkan/pvr_border.c index f2d874f183d..e8decfa8e6c 100644 --- a/src/imagination/vulkan/pvr_border.c +++ b/src/imagination/vulkan/pvr_border.c @@ -1132,10 +1132,10 @@ void pvr_border_color_table_finish(struct pvr_border_color_table *const table, VkResult pvr_border_color_table_get_or_create_entry( UNUSED struct pvr_border_color_table *const table, - const struct VkSamplerCreateInfo *const sampler_create_info, + const struct pvr_sampler *const sampler, uint32_t *const index_out) { - const VkBorderColor vk_type = sampler_create_info->borderColor; + const VkBorderColor vk_type = sampler->vk.border_color; if (vk_type <= PVR_BORDER_COLOR_TABLE_NR_BUILTIN_ENTRIES) { *index_out = vk_type; @@ -1143,5 +1143,5 @@ VkResult pvr_border_color_table_get_or_create_entry( } pvr_finishme("VK_EXT_custom_border_color is currently unsupported."); - return vk_error(NULL, VK_ERROR_EXTENSION_NOT_PRESENT); + return vk_error(sampler, VK_ERROR_EXTENSION_NOT_PRESENT); } diff --git a/src/imagination/vulkan/pvr_border.h b/src/imagination/vulkan/pvr_border.h index 4c190f0d0ba..358db65a732 100644 --- a/src/imagination/vulkan/pvr_border.h +++ b/src/imagination/vulkan/pvr_border.h @@ -41,6 +41,9 @@ (PVR_BORDER_COLOR_TABLE_NR_ENTRIES - \ PVR_BORDER_COLOR_TABLE_NR_BUILTIN_ENTRIES) +/* Forward declaration from "pvr_common.h" */ +struct pvr_sampler; + /* Forward declaration from "pvr_bo.h" */ struct pvr_bo; @@ -61,10 +64,10 @@ VkResult pvr_border_color_table_init(struct pvr_border_color_table *table, void pvr_border_color_table_finish(struct pvr_border_color_table *table, struct pvr_device *device); -VkResult pvr_border_color_table_get_or_create_entry( - struct pvr_border_color_table *table, - const struct VkSamplerCreateInfo *sampler_create_info, - uint32_t *index_out); +VkResult +pvr_border_color_table_get_or_create_entry(struct pvr_border_color_table *table, + const struct pvr_sampler *sampler, + uint32_t *index_out); static inline bool pvr_border_color_table_is_index_valid( const struct pvr_border_color_table *const table, diff --git a/src/imagination/vulkan/pvr_common.h b/src/imagination/vulkan/pvr_common.h index 3d135a68cef..79ce23f0a3b 100644 --- a/src/imagination/vulkan/pvr_common.h +++ b/src/imagination/vulkan/pvr_common.h @@ -45,6 +45,7 @@ #include "util/list.h" #include "util/macros.h" #include "vk_object.h" +#include "vk_sampler.h" #include "vk_sync.h" #define VK_VENDOR_ID_IMAGINATION 0x1010 @@ -238,7 +239,7 @@ CHECK_STRUCT_FIELD_SIZE(pvr_combined_image_sampler_descriptor, #undef CHECK_STRUCT_FIELD_SIZE struct pvr_sampler { - struct vk_object_base base; + struct vk_sampler vk; union pvr_sampler_descriptor descriptor; }; diff --git a/src/imagination/vulkan/pvr_device.c b/src/imagination/vulkan/pvr_device.c index c9d69ee344d..43502175bf5 100644 --- a/src/imagination/vulkan/pvr_device.c +++ b/src/imagination/vulkan/pvr_device.c @@ -71,6 +71,7 @@ #include "vk_alloc.h" #include "vk_log.h" #include "vk_object.h" +#include "vk_sampler.h" #include "vk_util.h" #define PVR_GLOBAL_FREE_LIST_INITIAL_SIZE (2U * 1024U * 1024U) @@ -3138,10 +3139,8 @@ VkResult pvr_CreateSampler(VkDevice _device, STATIC_ASSERT(sizeof(((union pvr_sampler_descriptor *)NULL)->data) == sizeof(((union pvr_sampler_descriptor *)NULL)->words)); - sampler = vk_object_alloc(&device->vk, - pAllocator, - sizeof(*sampler), - VK_OBJECT_TYPE_SAMPLER); + sampler = + vk_sampler_create(&device->vk, pCreateInfo, pAllocator, sizeof(*sampler)); if (!sampler) { result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); goto err_out; @@ -3152,7 +3151,7 @@ VkResult pvr_CreateSampler(VkDevice _device, result = pvr_border_color_table_get_or_create_entry(&device->border_color_table, - pCreateInfo, + sampler, &border_color_table_index); if (result != VK_SUCCESS) goto err_free_sampler; @@ -3285,7 +3284,7 @@ void pvr_DestroySampler(VkDevice _device, if (!sampler) return; - vk_object_free(&device->vk, pAllocator, sampler); + vk_sampler_destroy(&device->vk, pAllocator, &sampler->vk); } void pvr_GetBufferMemoryRequirements2( diff --git a/src/imagination/vulkan/pvr_private.h b/src/imagination/vulkan/pvr_private.h index 2a452af327f..5ff20e35bbc 100644 --- a/src/imagination/vulkan/pvr_private.h +++ b/src/imagination/vulkan/pvr_private.h @@ -1503,7 +1503,7 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_descriptor_pool, VkDescriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL) VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_sampler, - base, + vk.base, VkSampler, VK_OBJECT_TYPE_SAMPLER) VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_pipeline_layout,
