mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-14 00:48:44 +01:00
[dxvk] Don't use MaxNumActiveBindings when creating descriptor set layouts
This commit is contained in:
parent
2fe61675bf
commit
6fba4c47fe
@ -1,4 +1,5 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "dxvk_device.h"
|
#include "dxvk_device.h"
|
||||||
#include "dxvk_descriptor.h"
|
#include "dxvk_descriptor.h"
|
||||||
@ -158,38 +159,43 @@ namespace dxvk {
|
|||||||
: m_device(device) {
|
: m_device(device) {
|
||||||
auto vk = m_device->vkd();
|
auto vk = m_device->vkd();
|
||||||
|
|
||||||
std::array<VkDescriptorSetLayoutBinding, MaxNumActiveBindings> bindingInfos;
|
std::vector<VkDescriptorSetLayoutBinding> bindingInfos;
|
||||||
std::array<VkDescriptorUpdateTemplateEntry, MaxNumActiveBindings> templateInfos;
|
std::vector<VkDescriptorUpdateTemplateEntry> templateInfos;
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo layoutInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO };
|
bindingInfos.reserve(key.getBindingCount());
|
||||||
layoutInfo.bindingCount = key.getBindingCount();
|
templateInfos.reserve(key.getBindingCount());
|
||||||
layoutInfo.pBindings = bindingInfos.data();
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < key.getBindingCount(); i++) {
|
for (uint32_t i = 0; i < key.getBindingCount(); i++) {
|
||||||
auto entry = key.getBinding(i);
|
auto entry = key.getBinding(i);
|
||||||
|
|
||||||
VkDescriptorSetLayoutBinding& bindingInfo = bindingInfos[i];
|
VkDescriptorSetLayoutBinding bindingInfo;
|
||||||
bindingInfo.binding = i;
|
bindingInfo.binding = i;
|
||||||
bindingInfo.descriptorType = entry.descriptorType;
|
bindingInfo.descriptorType = entry.descriptorType;
|
||||||
bindingInfo.descriptorCount = 1;
|
bindingInfo.descriptorCount = 1;
|
||||||
bindingInfo.stageFlags = entry.stages;
|
bindingInfo.stageFlags = entry.stages;
|
||||||
bindingInfo.pImmutableSamplers = nullptr;
|
bindingInfo.pImmutableSamplers = nullptr;
|
||||||
|
bindingInfos.push_back(bindingInfo);
|
||||||
|
|
||||||
VkDescriptorUpdateTemplateEntry& templateInfo = templateInfos[i];
|
VkDescriptorUpdateTemplateEntry templateInfo;
|
||||||
templateInfo.dstBinding = i;
|
templateInfo.dstBinding = i;
|
||||||
templateInfo.dstArrayElement = 0;
|
templateInfo.dstArrayElement = 0;
|
||||||
templateInfo.descriptorCount = 1;
|
templateInfo.descriptorCount = 1;
|
||||||
templateInfo.descriptorType = entry.descriptorType;
|
templateInfo.descriptorType = entry.descriptorType;
|
||||||
templateInfo.offset = sizeof(DxvkDescriptorInfo) * i;
|
templateInfo.offset = sizeof(DxvkDescriptorInfo) * i;
|
||||||
templateInfo.stride = sizeof(DxvkDescriptorInfo);
|
templateInfo.stride = sizeof(DxvkDescriptorInfo);
|
||||||
|
templateInfos.push_back(templateInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkDescriptorSetLayoutCreateInfo layoutInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO };
|
||||||
|
layoutInfo.bindingCount = bindingInfos.size();
|
||||||
|
layoutInfo.pBindings = bindingInfos.data();
|
||||||
|
|
||||||
if (vk->vkCreateDescriptorSetLayout(vk->device(), &layoutInfo, nullptr, &m_layout) != VK_SUCCESS)
|
if (vk->vkCreateDescriptorSetLayout(vk->device(), &layoutInfo, nullptr, &m_layout) != VK_SUCCESS)
|
||||||
throw DxvkError("DxvkBindingSetLayoutKey: Failed to create descriptor set layout");
|
throw DxvkError("DxvkBindingSetLayoutKey: Failed to create descriptor set layout");
|
||||||
|
|
||||||
if (layoutInfo.bindingCount) {
|
if (layoutInfo.bindingCount) {
|
||||||
VkDescriptorUpdateTemplateCreateInfo templateInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO };
|
VkDescriptorUpdateTemplateCreateInfo templateInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO };
|
||||||
templateInfo.descriptorUpdateEntryCount = layoutInfo.bindingCount;
|
templateInfo.descriptorUpdateEntryCount = templateInfos.size();
|
||||||
templateInfo.pDescriptorUpdateEntries = templateInfos.data();
|
templateInfo.pDescriptorUpdateEntries = templateInfos.data();
|
||||||
templateInfo.templateType = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET;
|
templateInfo.templateType = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET;
|
||||||
templateInfo.descriptorSetLayout = m_layout;
|
templateInfo.descriptorSetLayout = m_layout;
|
||||||
|
Loading…
Reference in New Issue
Block a user