1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +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:
Philip Rebohle 2018-03-26 23:13:33 +02:00
parent f02b44f440
commit fc47fb8f6c
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 49 additions and 41 deletions

View File

@ -1604,6 +1604,7 @@ namespace dxvk {
VkPipelineBindPoint bindPoint,
const DxvkBindingState& bindingState,
const Rc<DxvkPipelineLayout>& layout) {
if (layout->bindingCount() != 0) {
const VkDescriptorSet dset =
m_cmd->allocateDescriptorSet(
layout->descriptorSetLayout());
@ -1615,6 +1616,7 @@ namespace dxvk {
m_cmd->cmdBindDescriptorSet(bindPoint,
layout->pipelineLayout(), dset);
}
}
void DxvkContext::updateIndexBufferBinding() {

View File

@ -70,7 +70,9 @@ namespace dxvk {
tEntries[i].stride = 0;
}
// Create descriptor set layout
// Create descriptor set layout. We do not need to
// create one if there are no active resource bindings.
if (bindingCount > 0) {
VkDescriptorSetLayoutCreateInfo dsetInfo;
dsetInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
dsetInfo.pNext = nullptr;
@ -81,13 +83,14 @@ namespace dxvk {
if (m_vkd->vkCreateDescriptorSetLayout(m_vkd->device(),
&dsetInfo, nullptr, &m_descriptorSetLayout) != VK_SUCCESS)
throw DxvkError("DxvkPipelineLayout: Failed to create descriptor set layout");
}
// Create pipeline layout
// Create pipeline layout with the given descriptor set layout
VkPipelineLayoutCreateInfo pipeInfo;
pipeInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipeInfo.pNext = nullptr;
pipeInfo.flags = 0;
pipeInfo.setLayoutCount = 1;
pipeInfo.setLayoutCount = bindingCount > 0 ? 1 : 0;
pipeInfo.pSetLayouts = &m_descriptorSetLayout;
pipeInfo.pushConstantRangeCount = 0;
pipeInfo.pPushConstantRanges = nullptr;
@ -98,7 +101,9 @@ namespace dxvk {
throw DxvkError("DxvkPipelineLayout: Failed to create pipeline layout");
}
// Create descriptor update template
// Create descriptor update template. If there are no active
// resource bindings, there won't be any descriptors to update.
if (bindingCount > 0) {
VkDescriptorUpdateTemplateCreateInfoKHR templateInfo;
templateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR;
templateInfo.pNext = nullptr;
@ -111,13 +116,14 @@ namespace dxvk {
templateInfo.pipelineLayout = m_pipelineLayout;
templateInfo.set = 0;
if (m_vkd->vkCreateDescriptorUpdateTemplateKHR(m_vkd->device(),
&templateInfo, nullptr, &m_descriptorTemplate) != VK_SUCCESS) {
if (m_vkd->vkCreateDescriptorUpdateTemplateKHR(
m_vkd->device(), &templateInfo, nullptr, &m_descriptorTemplate) != VK_SUCCESS) {
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");
}
}
}
DxvkPipelineLayout::~DxvkPipelineLayout() {