radv: stop allocating an array of BO for descriptors
They are no longer added to the per cmdbuf BO list. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40466>
This commit is contained in:
parent
375c82a27e
commit
2cf84eedb9
7 changed files with 2 additions and 77 deletions
|
|
@ -57,7 +57,7 @@ radv_create_descriptor_pool(struct radv_device *device, const VkDescriptorPoolCr
|
|||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
struct radv_descriptor_pool *pool;
|
||||
uint64_t size = sizeof(struct radv_descriptor_pool);
|
||||
uint64_t bo_size = 0, bo_count = 0, range_count = 0;
|
||||
uint64_t bo_size = 0, range_count = 0;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
const VkMutableDescriptorTypeCreateInfoEXT *mutable_info =
|
||||
|
|
@ -81,9 +81,6 @@ radv_create_descriptor_pool(struct radv_device *device, const VkDescriptorPoolCr
|
|||
|
||||
uint64_t num_16byte_descriptors = 0;
|
||||
for (unsigned i = 0; i < pCreateInfo->poolSizeCount; ++i) {
|
||||
bo_count += radv_descriptor_type_buffer_count(pCreateInfo->pPoolSizes[i].type) *
|
||||
pCreateInfo->pPoolSizes[i].descriptorCount;
|
||||
|
||||
switch (pCreateInfo->pPoolSizes[i].type) {
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
||||
|
|
@ -146,7 +143,6 @@ radv_create_descriptor_pool(struct radv_device *device, const VkDescriptorPoolCr
|
|||
|
||||
if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) {
|
||||
size += pCreateInfo->maxSets * sizeof(struct radv_descriptor_set);
|
||||
size += sizeof(struct radeon_winsys_bo *) * bo_count;
|
||||
size += sizeof(struct radv_descriptor_range) * range_count;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
|
|||
set_layout->has_immutable_samplers = false;
|
||||
set_layout->size = 0;
|
||||
|
||||
uint32_t buffer_count = 0;
|
||||
uint32_t dynamic_offset_count = 0;
|
||||
|
||||
uint32_t first_alignment = 32;
|
||||
|
|
@ -118,7 +117,6 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
|
|||
const VkDescriptorSetLayoutBinding *binding = bindings + j;
|
||||
uint32_t b = binding->binding;
|
||||
uint32_t alignment = radv_descriptor_alignment(binding->descriptorType);
|
||||
unsigned binding_buffer_count = radv_descriptor_type_buffer_count(binding->descriptorType);
|
||||
uint32_t descriptor_count = binding->descriptorCount;
|
||||
uint32_t max_sampled_image_descriptors = 1;
|
||||
bool has_ycbcr_sampler = false;
|
||||
|
|
@ -193,7 +191,6 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
|
|||
set_layout->binding[b].type = binding->descriptorType;
|
||||
set_layout->binding[b].array_size = descriptor_count;
|
||||
set_layout->binding[b].offset = set_layout->size;
|
||||
set_layout->binding[b].buffer_offset = buffer_count;
|
||||
set_layout->binding[b].dynamic_offset_offset = dynamic_offset_count;
|
||||
set_layout->binding[b].has_ycbcr_sampler = has_ycbcr_sampler;
|
||||
|
||||
|
|
@ -232,14 +229,12 @@ radv_CreateDescriptorSetLayout(VkDevice _device, const VkDescriptorSetLayoutCrea
|
|||
}
|
||||
|
||||
set_layout->size += descriptor_count * set_layout->binding[b].size;
|
||||
buffer_count += descriptor_count * binding_buffer_count;
|
||||
dynamic_offset_count += descriptor_count * set_layout->binding[b].dynamic_offset_count;
|
||||
}
|
||||
}
|
||||
|
||||
free(bindings);
|
||||
|
||||
set_layout->buffer_count = buffer_count;
|
||||
set_layout->dynamic_offset_count = dynamic_offset_count;
|
||||
|
||||
/* Hash the entire set layout except vk_descriptor_set_layout. The rest of the set layout is
|
||||
|
|
@ -416,13 +411,7 @@ radv_descriptor_set_create(struct radv_device *device, struct radv_descriptor_po
|
|||
return VK_ERROR_OUT_OF_POOL_MEMORY;
|
||||
|
||||
struct radv_descriptor_set *set;
|
||||
uint32_t buffer_count = layout->buffer_count;
|
||||
if (variable_count) {
|
||||
unsigned stride = radv_descriptor_type_buffer_count(layout->binding[layout->binding_count - 1].type);
|
||||
buffer_count = layout->binding[layout->binding_count - 1].buffer_offset + variable_count * stride;
|
||||
}
|
||||
unsigned range_offset =
|
||||
offsetof(struct radv_descriptor_set, descriptors) + sizeof(struct radeon_winsys_bo *) * buffer_count;
|
||||
unsigned range_offset = sizeof(struct radv_descriptor_set);
|
||||
const unsigned dynamic_offset_count = layout->dynamic_offset_count;
|
||||
unsigned mem_size = range_offset + sizeof(struct radv_descriptor_range) * dynamic_offset_count;
|
||||
|
||||
|
|
@ -448,7 +437,6 @@ radv_descriptor_set_create(struct radv_device *device, struct radv_descriptor_po
|
|||
}
|
||||
|
||||
set->header.layout = layout;
|
||||
set->header.buffer_count = buffer_count;
|
||||
uint32_t layout_size = layout->size;
|
||||
if (variable_count) {
|
||||
uint32_t stride = layout->binding[layout->binding_count - 1].size;
|
||||
|
|
@ -575,7 +563,6 @@ radv_update_descriptor_sets_impl(struct radv_device *device, struct radv_cmd_buf
|
|||
const struct radv_descriptor_set_binding_layout *binding_layout =
|
||||
set->header.layout->binding + writeset->dstBinding;
|
||||
uint32_t *ptr = set->header.mapped_ptr;
|
||||
struct radeon_winsys_bo **buffer_list = set->descriptors;
|
||||
/* Immutable samplers are not copied into push descriptors when they are
|
||||
* allocated, so if we are writing push descriptors we have to copy the
|
||||
* immutable samplers into them now.
|
||||
|
|
@ -594,8 +581,6 @@ radv_update_descriptor_sets_impl(struct radv_device *device, struct radv_cmd_buf
|
|||
}
|
||||
|
||||
ptr += binding_layout->size * writeset->dstArrayElement / 4;
|
||||
buffer_list += binding_layout->buffer_offset;
|
||||
buffer_list += writeset->dstArrayElement * radv_descriptor_type_buffer_count(writeset->descriptorType);
|
||||
for (j = 0; j < writeset->descriptorCount; ++j) {
|
||||
switch (writeset->descriptorType) {
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||
|
|
@ -660,7 +645,6 @@ radv_update_descriptor_sets_impl(struct radv_device *device, struct radv_cmd_buf
|
|||
break;
|
||||
}
|
||||
ptr += binding_layout->size / 4;
|
||||
buffer_list += radv_descriptor_type_buffer_count(writeset->descriptorType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -674,8 +658,6 @@ radv_update_descriptor_sets_impl(struct radv_device *device, struct radv_cmd_buf
|
|||
dst_set->header.layout->binding + copyset->dstBinding;
|
||||
uint32_t *src_ptr = src_set->header.mapped_ptr;
|
||||
uint32_t *dst_ptr = dst_set->header.mapped_ptr;
|
||||
struct radeon_winsys_bo **src_buffer_list = src_set->descriptors;
|
||||
struct radeon_winsys_bo **dst_buffer_list = dst_set->descriptors;
|
||||
|
||||
src_ptr += src_binding_layout->offset / 4;
|
||||
dst_ptr += dst_binding_layout->offset / 4;
|
||||
|
|
@ -691,12 +673,6 @@ radv_update_descriptor_sets_impl(struct radv_device *device, struct radv_cmd_buf
|
|||
src_ptr += src_binding_layout->size * copyset->srcArrayElement / 4;
|
||||
dst_ptr += dst_binding_layout->size * copyset->dstArrayElement / 4;
|
||||
|
||||
src_buffer_list += src_binding_layout->buffer_offset;
|
||||
src_buffer_list += copyset->srcArrayElement;
|
||||
|
||||
dst_buffer_list += dst_binding_layout->buffer_offset;
|
||||
dst_buffer_list += copyset->dstArrayElement;
|
||||
|
||||
/* In case of copies between mutable descriptor types
|
||||
* and non-mutable descriptor types. */
|
||||
size_t copy_size = MIN2(src_binding_layout->size, dst_binding_layout->size);
|
||||
|
|
@ -717,18 +693,6 @@ radv_update_descriptor_sets_impl(struct radv_device *device, struct radv_cmd_buf
|
|||
|
||||
src_ptr += src_binding_layout->size / 4;
|
||||
dst_ptr += dst_binding_layout->size / 4;
|
||||
|
||||
unsigned src_buffer_count = radv_descriptor_type_buffer_count(src_binding_layout->type);
|
||||
unsigned dst_buffer_count = radv_descriptor_type_buffer_count(dst_binding_layout->type);
|
||||
for (unsigned k = 0; k < dst_buffer_count; k++) {
|
||||
if (k < src_buffer_count)
|
||||
dst_buffer_list[k] = src_buffer_list[k];
|
||||
else
|
||||
dst_buffer_list[k] = NULL;
|
||||
}
|
||||
|
||||
dst_buffer_list += dst_buffer_count;
|
||||
src_buffer_list += src_buffer_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ struct radv_descriptor_set_binding_layout {
|
|||
uint32_t array_size;
|
||||
|
||||
uint32_t offset;
|
||||
uint32_t buffer_offset;
|
||||
uint16_t dynamic_offset_offset;
|
||||
|
||||
uint16_t dynamic_offset_count;
|
||||
|
|
@ -64,9 +63,6 @@ struct radv_descriptor_set_layout {
|
|||
/* Shader stages affected by this descriptor set */
|
||||
uint16_t dynamic_shader_stages;
|
||||
|
||||
/* Number of buffers in this descriptor set */
|
||||
uint32_t buffer_count;
|
||||
|
||||
/* Number of dynamic offsets used by this descriptor set */
|
||||
uint16_t dynamic_offset_count;
|
||||
|
||||
|
|
@ -92,7 +88,6 @@ struct radv_descriptor_set_header {
|
|||
struct radv_descriptor_set_layout *layout;
|
||||
uint32_t offset;
|
||||
uint32_t size;
|
||||
uint32_t buffer_count;
|
||||
|
||||
struct radeon_winsys_bo *bo;
|
||||
uint64_t va;
|
||||
|
|
@ -105,8 +100,6 @@ struct radv_descriptor_set {
|
|||
|
||||
/* Link in radv_descriptor_pool::sets */
|
||||
struct list_head link;
|
||||
|
||||
struct radeon_winsys_bo *descriptors[];
|
||||
};
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_set, header.base, VkDescriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ radv_CreateDescriptorUpdateTemplate(VkDevice _device, const VkDescriptorUpdateTe
|
|||
for (i = 0; i < entry_count; i++) {
|
||||
const VkDescriptorUpdateTemplateEntry *entry = &pCreateInfo->pDescriptorUpdateEntries[i];
|
||||
const struct radv_descriptor_set_binding_layout *binding_layout = set_layout->binding + entry->dstBinding;
|
||||
const uint32_t buffer_offset = binding_layout->buffer_offset + entry->dstArrayElement;
|
||||
const uint32_t *immutable_samplers = NULL;
|
||||
uint32_t dst_offset;
|
||||
uint32_t dst_stride;
|
||||
|
|
@ -90,7 +89,6 @@ radv_CreateDescriptorUpdateTemplate(VkDevice _device, const VkDescriptorUpdateTe
|
|||
.src_stride = entry->stride,
|
||||
.dst_offset = dst_offset,
|
||||
.dst_stride = dst_stride,
|
||||
.buffer_offset = buffer_offset,
|
||||
.has_sampler = !binding_layout->immutable_samplers_offset,
|
||||
.has_ycbcr_sampler = binding_layout->has_ycbcr_sampler,
|
||||
.immutable_samplers = immutable_samplers};
|
||||
|
|
@ -124,7 +122,6 @@ radv_update_descriptor_set_with_template_impl(struct radv_device *device, struct
|
|||
uint32_t i;
|
||||
|
||||
for (i = 0; i < templ->entry_count; ++i) {
|
||||
struct radeon_winsys_bo **buffer_list = set->descriptors + templ->entry[i].buffer_offset;
|
||||
uint32_t *pDst = set->header.mapped_ptr + templ->entry[i].dst_offset;
|
||||
const uint8_t *pSrc = ((const uint8_t *)pData) + templ->entry[i].src_offset;
|
||||
uint32_t j;
|
||||
|
|
@ -196,8 +193,6 @@ radv_update_descriptor_set_with_template_impl(struct radv_device *device, struct
|
|||
}
|
||||
pSrc += templ->entry[i].src_stride;
|
||||
pDst += templ->entry[i].dst_stride;
|
||||
|
||||
buffer_list += radv_descriptor_type_buffer_count(templ->entry[i].descriptor_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ struct radv_descriptor_update_template_entry {
|
|||
/* In dwords. Not valid/used for dynamic descriptors */
|
||||
uint32_t dst_stride;
|
||||
|
||||
uint32_t buffer_offset;
|
||||
|
||||
/* Only valid for combined image samplers and samplers */
|
||||
uint8_t has_sampler;
|
||||
uint8_t has_ycbcr_sampler;
|
||||
|
|
|
|||
|
|
@ -16,25 +16,6 @@
|
|||
static_assert(RADV_SAMPLER_DESC_SIZE == 16 && RADV_BUFFER_DESC_SIZE == 16 && RADV_ACCEL_STRUCT_DESC_SIZE == 16,
|
||||
"Sampler/buffer/acceleration structure descriptor sizes must match.");
|
||||
|
||||
unsigned
|
||||
radv_descriptor_type_buffer_count(VkDescriptorType type)
|
||||
{
|
||||
switch (type) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK:
|
||||
case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR:
|
||||
return 0;
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||
case VK_DESCRIPTOR_TYPE_MUTABLE_EXT:
|
||||
return 3;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
radv_descriptor_alignment(VkDescriptorType type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
unsigned radv_descriptor_type_buffer_count(VkDescriptorType type);
|
||||
|
||||
uint32_t radv_descriptor_alignment(VkDescriptorType type);
|
||||
|
||||
bool radv_mutable_descriptor_type_size_alignment(const struct radv_device *device,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue