mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +01:00
[dxvk] Do not create descriptor set layout/template if binding count is 0
Fixes a validation error in case an application renders geometry without any active shader resource slots.
This commit is contained in:
parent
f02b44f440
commit
fc47fb8f6c
@ -1604,16 +1604,18 @@ namespace dxvk {
|
|||||||
VkPipelineBindPoint bindPoint,
|
VkPipelineBindPoint bindPoint,
|
||||||
const DxvkBindingState& bindingState,
|
const DxvkBindingState& bindingState,
|
||||||
const Rc<DxvkPipelineLayout>& layout) {
|
const Rc<DxvkPipelineLayout>& layout) {
|
||||||
const VkDescriptorSet dset =
|
if (layout->bindingCount() != 0) {
|
||||||
m_cmd->allocateDescriptorSet(
|
const VkDescriptorSet dset =
|
||||||
layout->descriptorSetLayout());
|
m_cmd->allocateDescriptorSet(
|
||||||
|
layout->descriptorSetLayout());
|
||||||
m_cmd->updateDescriptorSetWithTemplate(
|
|
||||||
dset, layout->descriptorTemplate(),
|
m_cmd->updateDescriptorSetWithTemplate(
|
||||||
m_descInfos.data());
|
dset, layout->descriptorTemplate(),
|
||||||
|
m_descInfos.data());
|
||||||
m_cmd->cmdBindDescriptorSet(bindPoint,
|
|
||||||
layout->pipelineLayout(), dset);
|
m_cmd->cmdBindDescriptorSet(bindPoint,
|
||||||
|
layout->pipelineLayout(), dset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,24 +70,27 @@ namespace dxvk {
|
|||||||
tEntries[i].stride = 0;
|
tEntries[i].stride = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create descriptor set layout
|
// Create descriptor set layout. We do not need to
|
||||||
VkDescriptorSetLayoutCreateInfo dsetInfo;
|
// create one if there are no active resource bindings.
|
||||||
dsetInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
if (bindingCount > 0) {
|
||||||
dsetInfo.pNext = nullptr;
|
VkDescriptorSetLayoutCreateInfo dsetInfo;
|
||||||
dsetInfo.flags = 0;
|
dsetInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||||
dsetInfo.bindingCount = bindings.size();
|
dsetInfo.pNext = nullptr;
|
||||||
dsetInfo.pBindings = bindings.data();
|
dsetInfo.flags = 0;
|
||||||
|
dsetInfo.bindingCount = bindings.size();
|
||||||
|
dsetInfo.pBindings = bindings.data();
|
||||||
|
|
||||||
|
if (m_vkd->vkCreateDescriptorSetLayout(m_vkd->device(),
|
||||||
|
&dsetInfo, nullptr, &m_descriptorSetLayout) != VK_SUCCESS)
|
||||||
|
throw DxvkError("DxvkPipelineLayout: Failed to create descriptor set layout");
|
||||||
|
}
|
||||||
|
|
||||||
if (m_vkd->vkCreateDescriptorSetLayout(m_vkd->device(),
|
// Create pipeline layout with the given descriptor set layout
|
||||||
&dsetInfo, nullptr, &m_descriptorSetLayout) != VK_SUCCESS)
|
|
||||||
throw DxvkError("DxvkPipelineLayout: Failed to create descriptor set layout");
|
|
||||||
|
|
||||||
// Create pipeline layout
|
|
||||||
VkPipelineLayoutCreateInfo pipeInfo;
|
VkPipelineLayoutCreateInfo pipeInfo;
|
||||||
pipeInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
pipeInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||||
pipeInfo.pNext = nullptr;
|
pipeInfo.pNext = nullptr;
|
||||||
pipeInfo.flags = 0;
|
pipeInfo.flags = 0;
|
||||||
pipeInfo.setLayoutCount = 1;
|
pipeInfo.setLayoutCount = bindingCount > 0 ? 1 : 0;
|
||||||
pipeInfo.pSetLayouts = &m_descriptorSetLayout;
|
pipeInfo.pSetLayouts = &m_descriptorSetLayout;
|
||||||
pipeInfo.pushConstantRangeCount = 0;
|
pipeInfo.pushConstantRangeCount = 0;
|
||||||
pipeInfo.pPushConstantRanges = nullptr;
|
pipeInfo.pPushConstantRanges = nullptr;
|
||||||
@ -98,24 +101,27 @@ namespace dxvk {
|
|||||||
throw DxvkError("DxvkPipelineLayout: Failed to create pipeline layout");
|
throw DxvkError("DxvkPipelineLayout: Failed to create pipeline layout");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create descriptor update template
|
// Create descriptor update template. If there are no active
|
||||||
VkDescriptorUpdateTemplateCreateInfoKHR templateInfo;
|
// resource bindings, there won't be any descriptors to update.
|
||||||
templateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR;
|
if (bindingCount > 0) {
|
||||||
templateInfo.pNext = nullptr;
|
VkDescriptorUpdateTemplateCreateInfoKHR templateInfo;
|
||||||
templateInfo.flags = 0;
|
templateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR;
|
||||||
templateInfo.descriptorUpdateEntryCount = tEntries.size();
|
templateInfo.pNext = nullptr;
|
||||||
templateInfo.pDescriptorUpdateEntries = tEntries.data();
|
templateInfo.flags = 0;
|
||||||
templateInfo.templateType = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR;
|
templateInfo.descriptorUpdateEntryCount = tEntries.size();
|
||||||
templateInfo.descriptorSetLayout = m_descriptorSetLayout;
|
templateInfo.pDescriptorUpdateEntries = tEntries.data();
|
||||||
templateInfo.pipelineBindPoint = pipelineBindPoint;
|
templateInfo.templateType = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR;
|
||||||
templateInfo.pipelineLayout = m_pipelineLayout;
|
templateInfo.descriptorSetLayout = m_descriptorSetLayout;
|
||||||
templateInfo.set = 0;
|
templateInfo.pipelineBindPoint = pipelineBindPoint;
|
||||||
|
templateInfo.pipelineLayout = m_pipelineLayout;
|
||||||
if (m_vkd->vkCreateDescriptorUpdateTemplateKHR(m_vkd->device(),
|
templateInfo.set = 0;
|
||||||
&templateInfo, nullptr, &m_descriptorTemplate) != VK_SUCCESS) {
|
|
||||||
m_vkd->vkDestroyDescriptorSetLayout(m_vkd->device(), m_descriptorSetLayout, nullptr);
|
if (m_vkd->vkCreateDescriptorUpdateTemplateKHR(
|
||||||
m_vkd->vkDestroyPipelineLayout(m_vkd->device(), m_pipelineLayout, nullptr);
|
m_vkd->device(), &templateInfo, nullptr, &m_descriptorTemplate) != VK_SUCCESS) {
|
||||||
throw DxvkError("DxvkPipelineLayout: Failed to create descriptor update template");
|
m_vkd->vkDestroyDescriptorSetLayout(m_vkd->device(), m_descriptorSetLayout, nullptr);
|
||||||
|
m_vkd->vkDestroyPipelineLayout(m_vkd->device(), m_pipelineLayout, nullptr);
|
||||||
|
throw DxvkError("DxvkPipelineLayout: Failed to create descriptor update template");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user