mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-15 16:00:20 +01:00
lavapipe: sort bindings before creating descriptor set
This ensures the dynamic offsets are correct
Fixes: b38879f8c5 ("vallium: initial import of the vulkan frontend")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10144>
This commit is contained in:
parent
73704f149f
commit
662cef76da
1 changed files with 32 additions and 2 deletions
|
|
@ -25,6 +25,28 @@
|
|||
#include "vk_util.h"
|
||||
#include "u_math.h"
|
||||
|
||||
static int binding_compare(const void* av, const void *bv)
|
||||
{
|
||||
const VkDescriptorSetLayoutBinding *a = (const VkDescriptorSetLayoutBinding*)av;
|
||||
const VkDescriptorSetLayoutBinding *b = (const VkDescriptorSetLayoutBinding*)bv;
|
||||
|
||||
return (a->binding < b->binding) ? -1 : (a->binding > b->binding) ? 1 : 0;
|
||||
}
|
||||
|
||||
static VkDescriptorSetLayoutBinding *
|
||||
create_sorted_bindings(const VkDescriptorSetLayoutBinding *bindings, unsigned count) {
|
||||
VkDescriptorSetLayoutBinding *sorted_bindings = malloc(MAX2(count * sizeof(VkDescriptorSetLayoutBinding), 1));
|
||||
if (!sorted_bindings)
|
||||
return NULL;
|
||||
|
||||
if (count) {
|
||||
memcpy(sorted_bindings, bindings, count * sizeof(VkDescriptorSetLayoutBinding));
|
||||
qsort(sorted_bindings, count, sizeof(VkDescriptorSetLayoutBinding), binding_compare);
|
||||
}
|
||||
|
||||
return sorted_bindings;
|
||||
}
|
||||
|
||||
VkResult lvp_CreateDescriptorSetLayout(
|
||||
VkDevice _device,
|
||||
const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
|
||||
|
|
@ -62,10 +84,18 @@ VkResult lvp_CreateDescriptorSetLayout(
|
|||
set_layout->shader_stages = 0;
|
||||
set_layout->size = 0;
|
||||
|
||||
uint32_t dynamic_offset_count = 0;
|
||||
VkDescriptorSetLayoutBinding *bindings = create_sorted_bindings(pCreateInfo->pBindings,
|
||||
pCreateInfo->bindingCount);
|
||||
if (!bindings) {
|
||||
vk_object_base_finish(&set_layout->base);
|
||||
vk_free2(&device->vk.alloc, pAllocator, set_layout);
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
}
|
||||
|
||||
|
||||
uint32_t dynamic_offset_count = 0;
|
||||
for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) {
|
||||
const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[j];
|
||||
const VkDescriptorSetLayoutBinding *binding = bindings + j;
|
||||
uint32_t b = binding->binding;
|
||||
|
||||
set_layout->binding[b].array_size = binding->descriptorCount;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue