lavapipe: Use the vk_descriptor_set_layout base struct
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17286>
This commit is contained in:

committed by
Marge Bot

parent
e6c75bcd9c
commit
003f401342
@@ -62,14 +62,10 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDescriptorSetLayout(
|
||||
num_bindings * sizeof(set_layout->binding[0]) +
|
||||
immutable_sampler_count * sizeof(struct lvp_sampler *);
|
||||
|
||||
set_layout = vk_zalloc(&device->vk.alloc, size, 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
|
||||
set_layout = vk_descriptor_set_layout_zalloc(&device->vk, size);
|
||||
if (!set_layout)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
vk_object_base_init(&device->vk, &set_layout->base,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT);
|
||||
set_layout->ref_cnt = 1;
|
||||
set_layout->immutable_sampler_count = immutable_sampler_count;
|
||||
/* We just allocate all the samplers at the end of the struct */
|
||||
struct lvp_sampler **samplers =
|
||||
@@ -84,8 +80,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDescriptorSetLayout(
|
||||
pCreateInfo->bindingCount,
|
||||
&bindings);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_object_base_finish(&set_layout->base);
|
||||
vk_free(&device->vk.alloc, set_layout);
|
||||
vk_descriptor_set_layout_unref(&device->vk, &set_layout->vk);
|
||||
return vk_error(device, result);
|
||||
}
|
||||
|
||||
@@ -224,29 +219,6 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDescriptorSetLayout(
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
lvp_descriptor_set_layout_destroy(struct lvp_device *device,
|
||||
struct lvp_descriptor_set_layout *layout)
|
||||
{
|
||||
assert(layout->ref_cnt == 0);
|
||||
vk_object_base_finish(&layout->base);
|
||||
vk_free(&device->vk.alloc, layout);
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL lvp_DestroyDescriptorSetLayout(
|
||||
VkDevice _device,
|
||||
VkDescriptorSetLayout _set_layout,
|
||||
const VkAllocationCallbacks* pAllocator)
|
||||
{
|
||||
LVP_FROM_HANDLE(lvp_device, device, _device);
|
||||
LVP_FROM_HANDLE(lvp_descriptor_set_layout, set_layout, _set_layout);
|
||||
|
||||
if (!_set_layout)
|
||||
return;
|
||||
|
||||
lvp_descriptor_set_layout_unref(device, set_layout);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL lvp_CreatePipelineLayout(
|
||||
VkDevice _device,
|
||||
const VkPipelineLayoutCreateInfo* pCreateInfo,
|
||||
@@ -286,7 +258,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreatePipelineLayout(
|
||||
}
|
||||
layout->stage[i].uniform_block_count += set_layout->stage[i].uniform_block_count;
|
||||
}
|
||||
lvp_descriptor_set_layout_ref(set_layout);
|
||||
vk_descriptor_set_layout_ref(&set_layout->vk);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
@@ -341,7 +313,7 @@ void lvp_pipeline_layout_destroy(struct lvp_device *device,
|
||||
assert(pipeline_layout->ref_cnt == 0);
|
||||
|
||||
for (uint32_t i = 0; i < pipeline_layout->num_sets; i++)
|
||||
lvp_descriptor_set_layout_unref(device, pipeline_layout->set[i].layout);
|
||||
vk_descriptor_set_layout_unref(&device->vk, &pipeline_layout->set[i].layout->vk);
|
||||
|
||||
vk_object_base_finish(&pipeline_layout->base);
|
||||
vk_free(&device->vk.alloc, pipeline_layout);
|
||||
@@ -384,7 +356,7 @@ lvp_descriptor_set_create(struct lvp_device *device,
|
||||
vk_object_base_init(&device->vk, &set->base,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
set->layout = layout;
|
||||
lvp_descriptor_set_layout_ref(layout);
|
||||
vk_descriptor_set_layout_ref(&layout->vk);
|
||||
|
||||
/* Go through and fill out immutable samplers if we have any */
|
||||
struct lvp_descriptor *desc = set->descriptors;
|
||||
@@ -412,7 +384,7 @@ void
|
||||
lvp_descriptor_set_destroy(struct lvp_device *device,
|
||||
struct lvp_descriptor_set *set)
|
||||
{
|
||||
lvp_descriptor_set_layout_unref(device, set->layout);
|
||||
vk_descriptor_set_layout_unref(&device->vk, &set->layout->vk);
|
||||
vk_object_base_finish(&set->base);
|
||||
vk_free(&device->vk.alloc, set);
|
||||
}
|
||||
@@ -629,7 +601,7 @@ static void lvp_reset_descriptor_pool(struct lvp_device *device,
|
||||
{
|
||||
struct lvp_descriptor_set *set, *tmp;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(set, tmp, &pool->sets, link) {
|
||||
lvp_descriptor_set_layout_unref(device, set->layout);
|
||||
vk_descriptor_set_layout_unref(&device->vk, &set->layout->vk);
|
||||
list_del(&set->link);
|
||||
vk_free(&device->vk.alloc, set);
|
||||
}
|
||||
|
@@ -1252,7 +1252,7 @@ static bool
|
||||
layouts_equal(const struct lvp_descriptor_set_layout *a, const struct lvp_descriptor_set_layout *b)
|
||||
{
|
||||
const uint8_t *pa = (const uint8_t*)a, *pb = (const uint8_t*)b;
|
||||
uint32_t hash_start_offset = offsetof(struct lvp_descriptor_set_layout, ref_cnt) + sizeof(uint32_t);
|
||||
uint32_t hash_start_offset = sizeof(struct vk_descriptor_set_layout);
|
||||
uint32_t binding_offset = offsetof(struct lvp_descriptor_set_layout, binding);
|
||||
/* base equal */
|
||||
if (memcmp(pa + hash_start_offset, pb + hash_start_offset, binding_offset - hash_start_offset))
|
||||
|
@@ -67,6 +67,7 @@ typedef uint32_t xcb_window_t;
|
||||
#include "vk_cmd_queue.h"
|
||||
#include "vk_command_buffer.h"
|
||||
#include "vk_command_pool.h"
|
||||
#include "vk_descriptor_set_layout.h"
|
||||
#include "vk_queue.h"
|
||||
#include "vk_sync.h"
|
||||
#include "vk_sync_timeline.h"
|
||||
@@ -286,10 +287,8 @@ struct lvp_descriptor_set_binding_layout {
|
||||
};
|
||||
|
||||
struct lvp_descriptor_set_layout {
|
||||
struct vk_object_base base;
|
||||
struct vk_descriptor_set_layout vk;
|
||||
|
||||
/* Descriptor set layouts can be destroyed at almost any time */
|
||||
uint32_t ref_cnt;
|
||||
/* add new members after this */
|
||||
|
||||
uint32_t immutable_sampler_count;
|
||||
@@ -321,27 +320,6 @@ struct lvp_descriptor_set_layout {
|
||||
struct lvp_descriptor_set_binding_layout binding[0];
|
||||
};
|
||||
|
||||
void lvp_descriptor_set_layout_destroy(struct lvp_device *device,
|
||||
struct lvp_descriptor_set_layout *layout);
|
||||
|
||||
static inline void
|
||||
lvp_descriptor_set_layout_ref(struct lvp_descriptor_set_layout *layout)
|
||||
{
|
||||
assert(layout && layout->ref_cnt >= 1);
|
||||
p_atomic_inc(&layout->ref_cnt);
|
||||
}
|
||||
|
||||
static inline void
|
||||
lvp_descriptor_set_layout_unref(struct lvp_device *device,
|
||||
struct lvp_descriptor_set_layout *layout)
|
||||
{
|
||||
if (!layout)
|
||||
return;
|
||||
assert(layout->ref_cnt >= 1);
|
||||
if (p_atomic_dec_zero(&layout->ref_cnt))
|
||||
lvp_descriptor_set_layout_destroy(device, layout);
|
||||
}
|
||||
|
||||
union lvp_descriptor_info {
|
||||
struct {
|
||||
struct lvp_sampler *sampler;
|
||||
@@ -579,7 +557,7 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_descriptor_pool, base, VkDescriptorPool,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_POOL)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_descriptor_set, base, VkDescriptorSet,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_descriptor_set_layout, base, VkDescriptorSetLayout,
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_descriptor_set_layout, vk.base, VkDescriptorSetLayout,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT)
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(lvp_descriptor_update_template, base, VkDescriptorUpdateTemplate,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE)
|
||||
|
Reference in New Issue
Block a user