venus: descriptor layout to track more binding infos

Rename existing max_binding to last_binding to be consistent.

1. layout to track last binding index
2. binding to track descriptor type
3. binding to track descriptor count

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12501>
This commit is contained in:
Yiwei Zhang 2021-08-20 18:57:43 +00:00 committed by Marge Bot
parent ad934eb680
commit d8e89b4e33
2 changed files with 17 additions and 5 deletions

View file

@ -36,18 +36,24 @@ static void
vn_descriptor_set_layout_init(
struct vn_device *dev,
const VkDescriptorSetLayoutCreateInfo *create_info,
uint32_t last_binding,
struct vn_descriptor_set_layout *layout)
{
VkDevice dev_handle = vn_device_to_handle(dev);
VkDescriptorSetLayout layout_handle =
vn_descriptor_set_layout_to_handle(layout);
layout->last_binding = last_binding;
for (uint32_t i = 0; i < create_info->bindingCount; i++) {
const VkDescriptorSetLayoutBinding *binding_info =
&create_info->pBindings[i];
struct vn_descriptor_set_layout_binding *binding =
&layout->bindings[binding_info->binding];
binding->type = binding_info->descriptorType;
binding->count = binding_info->descriptorCount;
switch (binding_info->descriptorType) {
case VK_DESCRIPTOR_TYPE_SAMPLER:
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
@ -73,7 +79,7 @@ vn_CreateDescriptorSetLayout(
const VkAllocationCallbacks *alloc =
pAllocator ? pAllocator : &dev->base.base.alloc;
uint32_t max_binding = 0;
uint32_t last_binding = 0;
VkDescriptorSetLayoutBinding *local_bindings = NULL;
VkDescriptorSetLayoutCreateInfo local_create_info;
if (pCreateInfo->bindingCount) {
@ -91,8 +97,8 @@ vn_CreateDescriptorSetLayout(
for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) {
VkDescriptorSetLayoutBinding *binding = &local_bindings[i];
if (max_binding < binding->binding)
max_binding = binding->binding;
if (last_binding < binding->binding)
last_binding = binding->binding;
switch (binding->descriptorType) {
case VK_DESCRIPTOR_TYPE_SAMPLER:
@ -110,7 +116,7 @@ vn_CreateDescriptorSetLayout(
}
const size_t layout_size =
offsetof(struct vn_descriptor_set_layout, bindings[max_binding + 1]);
offsetof(struct vn_descriptor_set_layout, bindings[last_binding + 1]);
struct vn_descriptor_set_layout *layout =
vk_zalloc(alloc, layout_size, VN_DEFAULT_ALIGN,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
@ -122,7 +128,7 @@ vn_CreateDescriptorSetLayout(
vn_object_base_init(&layout->base, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT,
&dev->base);
vn_descriptor_set_layout_init(dev, pCreateInfo, layout);
vn_descriptor_set_layout_init(dev, pCreateInfo, last_binding, layout);
vk_free(alloc, local_bindings);

View file

@ -14,11 +14,17 @@
#include "vn_common.h"
struct vn_descriptor_set_layout_binding {
VkDescriptorType type;
uint32_t count;
bool has_immutable_samplers;
};
struct vn_descriptor_set_layout {
struct vn_object_base base;
uint32_t last_binding;
/* bindings must be the last field in the layout */
struct vn_descriptor_set_layout_binding bindings[];
};
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_set_layout,