From f5af56528b5d1b7df1a68844ede7a02e2595be71 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Sun, 21 Jul 2024 11:40:16 +0300 Subject: [PATCH] anv: split sampler from anv_device.c Signed-off-by: Lionel Landwerlin Acked-by: Ivan Briano Part-of: --- src/intel/vulkan/anv_device.c | 44 ------------------------------ src/intel/vulkan/anv_sampler.c | 49 ++++++++++++++++++++++++++++++++++ src/intel/vulkan/meson.build | 1 + 3 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 src/intel/vulkan/anv_sampler.c diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 482c4365a10..ba2a30b1c54 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -1893,50 +1893,6 @@ void anv_GetDeviceMemoryCommitment( *pCommittedMemoryInBytes = 0; } -VkResult anv_GetSamplerOpaqueCaptureDescriptorDataEXT( - VkDevice _device, - const VkSamplerCaptureDescriptorDataInfoEXT* pInfo, - void* pData) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - ANV_FROM_HANDLE(anv_sampler, sampler, pInfo->sampler); - - if (sampler->custom_border_color.alloc_size != 0) { - *((uint32_t *)pData) = - anv_state_reserved_array_pool_state_index( - &device->custom_border_colors, - sampler->custom_border_color); - } else { - *((uint32_t *)pData) = 0; - } - - return VK_SUCCESS; -} - -void anv_DestroySampler( - VkDevice _device, - VkSampler _sampler, - const VkAllocationCallbacks* pAllocator) -{ - ANV_FROM_HANDLE(anv_device, device, _device); - ANV_FROM_HANDLE(anv_sampler, sampler, _sampler); - - if (!sampler) - return; - - if (sampler->bindless_state.map) { - anv_state_pool_free(&device->dynamic_state_pool, - sampler->bindless_state); - } - - if (sampler->custom_border_color.map) { - anv_state_reserved_array_pool_free(&device->custom_border_colors, - sampler->custom_border_color); - } - - vk_sampler_destroy(&device->vk, pAllocator, &sampler->vk); -} - static inline clockid_t anv_get_default_cpu_clock_id(void) { diff --git a/src/intel/vulkan/anv_sampler.c b/src/intel/vulkan/anv_sampler.c new file mode 100644 index 00000000000..1c5563ae413 --- /dev/null +++ b/src/intel/vulkan/anv_sampler.c @@ -0,0 +1,49 @@ +/* Copyright © 2024 Intel Corporation + * SPDX-License-Identifier: MIT + */ + +#include "anv_private.h" + +VkResult anv_GetSamplerOpaqueCaptureDescriptorDataEXT( + VkDevice _device, + const VkSamplerCaptureDescriptorDataInfoEXT* pInfo, + void* pData) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_sampler, sampler, pInfo->sampler); + + if (sampler->custom_border_color.alloc_size != 0) { + *((uint32_t *)pData) = + anv_state_reserved_array_pool_state_index( + &device->custom_border_colors, + sampler->custom_border_color); + } else { + *((uint32_t *)pData) = 0; + } + + return VK_SUCCESS; +} + +void anv_DestroySampler( + VkDevice _device, + VkSampler _sampler, + const VkAllocationCallbacks* pAllocator) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_sampler, sampler, _sampler); + + if (!sampler) + return; + + if (sampler->bindless_state.map) { + anv_state_pool_free(&device->dynamic_state_pool, + sampler->bindless_state); + } + + if (sampler->custom_border_color.map) { + anv_state_reserved_array_pool_free(&device->custom_border_colors, + sampler->custom_border_color); + } + + vk_sampler_destroy(&device->vk, pAllocator, &sampler->vk); +} diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index 94180796eed..1d1c1a5d043 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -180,6 +180,7 @@ libanv_files = files( 'anv_queue.c', 'anv_rmv.c', 'anv_rmv.h', + 'anv_sampler.c', 'anv_sparse.c', 'anv_util.c', 'anv_utrace.c',