mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-08 20:50:39 +01:00
vk/descriptor_set_layout: Add optional destructor
Drivers implementing descriptor buffers will want to allocate and free descriptors with the layout for embedded samplers, so we need a hook to allow them to free any GPU buffers. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19849>
This commit is contained in:
parent
56e4359542
commit
b28899a261
2 changed files with 15 additions and 1 deletions
|
|
@ -35,6 +35,7 @@ vk_descriptor_set_layout_init(struct vk_device *device,
|
|||
VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT);
|
||||
|
||||
layout->ref_cnt = 1;
|
||||
layout->destroy = vk_descriptor_set_layout_destroy;
|
||||
}
|
||||
|
||||
void *
|
||||
|
|
@ -73,6 +74,13 @@ vk_descriptor_set_layout_multizalloc(struct vk_device *device,
|
|||
return layout;
|
||||
}
|
||||
|
||||
void
|
||||
vk_descriptor_set_layout_destroy(struct vk_device *device,
|
||||
struct vk_descriptor_set_layout *layout)
|
||||
{
|
||||
vk_object_free(device, NULL, layout);
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
vk_common_DestroyDescriptorSetLayout(VkDevice _device,
|
||||
VkDescriptorSetLayout descriptorSetLayout,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ extern "C" {
|
|||
struct vk_descriptor_set_layout {
|
||||
struct vk_object_base base;
|
||||
|
||||
void (*destroy)(struct vk_device *device,
|
||||
struct vk_descriptor_set_layout *layout);
|
||||
|
||||
/** Reference count
|
||||
*
|
||||
* It's often necessary to store a pointer to the descriptor set layout in
|
||||
|
|
@ -60,6 +63,9 @@ void *vk_descriptor_set_layout_zalloc(struct vk_device *device, size_t size);
|
|||
void *vk_descriptor_set_layout_multizalloc(struct vk_device *device,
|
||||
struct vk_multialloc *ma);
|
||||
|
||||
void vk_descriptor_set_layout_destroy(struct vk_device *device,
|
||||
struct vk_descriptor_set_layout *layout);
|
||||
|
||||
static inline struct vk_descriptor_set_layout *
|
||||
vk_descriptor_set_layout_ref(struct vk_descriptor_set_layout *layout)
|
||||
{
|
||||
|
|
@ -74,7 +80,7 @@ vk_descriptor_set_layout_unref(struct vk_device *device,
|
|||
{
|
||||
assert(layout && layout->ref_cnt >= 1);
|
||||
if (p_atomic_dec_zero(&layout->ref_cnt))
|
||||
vk_object_free(device, NULL, layout);
|
||||
layout->destroy(device, layout);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue