xref: /aosp_15_r20/external/mesa3d/src/intel/vulkan/anv_sampler.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /* Copyright © 2024 Intel Corporation
2  * SPDX-License-Identifier: MIT
3  */
4 
5 #include "anv_private.h"
6 
anv_GetSamplerOpaqueCaptureDescriptorDataEXT(VkDevice _device,const VkSamplerCaptureDescriptorDataInfoEXT * pInfo,void * pData)7 VkResult anv_GetSamplerOpaqueCaptureDescriptorDataEXT(
8     VkDevice                                    _device,
9     const VkSamplerCaptureDescriptorDataInfoEXT* pInfo,
10     void*                                       pData)
11 {
12    ANV_FROM_HANDLE(anv_device, device, _device);
13    ANV_FROM_HANDLE(anv_sampler, sampler, pInfo->sampler);
14 
15    if (sampler->custom_border_color.alloc_size != 0) {
16       *((uint32_t *)pData) =
17          anv_state_reserved_array_pool_state_index(
18             &device->custom_border_colors,
19             sampler->custom_border_color);
20    } else {
21       *((uint32_t *)pData) = 0;
22    }
23 
24    return VK_SUCCESS;
25 }
26 
anv_DestroySampler(VkDevice _device,VkSampler _sampler,const VkAllocationCallbacks * pAllocator)27 void anv_DestroySampler(
28     VkDevice                                    _device,
29     VkSampler                                   _sampler,
30     const VkAllocationCallbacks*                pAllocator)
31 {
32    ANV_FROM_HANDLE(anv_device, device, _device);
33    ANV_FROM_HANDLE(anv_sampler, sampler, _sampler);
34 
35    if (!sampler)
36       return;
37 
38    if (sampler->bindless_state.map) {
39       anv_state_pool_free(&device->dynamic_state_pool,
40                           sampler->bindless_state);
41    }
42 
43    if (sampler->custom_border_color.map) {
44       anv_state_reserved_array_pool_free(&device->custom_border_colors,
45                                          sampler->custom_border_color);
46    }
47 
48    vk_sampler_destroy(&device->vk, pAllocator, &sampler->vk);
49 }
50