1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 22:08:59 +01:00

[dxvk] Don't use MaxNumActiveBindings for descriptor updates

This commit is contained in:
Philip Rebohle 2022-08-06 01:44:56 +02:00
parent 6fba4c47fe
commit b950102233
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 37 additions and 13 deletions

View File

@ -21,16 +21,6 @@ namespace dxvk {
// Init framebuffer info with default render pass in case
// the app does not explicitly bind any render targets
m_state.om.framebufferInfo = makeFramebufferInfo(m_state.om.renderTargets);
for (uint32_t i = 0; i < MaxNumActiveBindings; i++) {
m_descriptorWrites[i] = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET };
m_descriptorWrites[i].descriptorCount = 1;
m_descriptorWrites[i].descriptorType = VK_DESCRIPTOR_TYPE_MAX_ENUM;
m_descriptorWrites[i].pImageInfo = &m_descriptors[i].image;
m_descriptorWrites[i].pBufferInfo = &m_descriptors[i].buffer;
m_descriptorWrites[i].pTexelBufferView = &m_descriptors[i].texelBuffer;
}
m_descriptorManager = new DxvkDescriptorManager(device.ptr(), type);
// Default destination barriers for graphics pipelines
@ -4661,6 +4651,10 @@ namespace dxvk {
void DxvkContext::updateResourceBindings(const DxvkBindingLayoutObjects* layout) {
const auto& bindings = layout->layout();
// Ensure that the arrays we write descriptor info to are big enough
if (unlikely(layout->getBindingCount() > m_descriptors.size()))
this->resizeDescriptorArrays(layout->getBindingCount());
// On 32-bit wine, vkUpdateDescriptorSets has significant overhead due
// to struct conversion, so we should use descriptor update templates.
// For 64-bit applications, using templates is slower on some drivers.
@ -5849,4 +5843,20 @@ namespace dxvk {
return m_zeroBuffer;
}
void DxvkContext::resizeDescriptorArrays(
uint32_t bindingCount) {
m_descriptors.resize(bindingCount);
m_descriptorWrites.resize(bindingCount);
for (uint32_t i = 0; i < bindingCount; i++) {
m_descriptorWrites[i] = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET };
m_descriptorWrites[i].descriptorCount = 1;
m_descriptorWrites[i].descriptorType = VK_DESCRIPTOR_TYPE_MAX_ENUM;
m_descriptorWrites[i].pImageInfo = &m_descriptors[i].image;
m_descriptorWrites[i].pBufferInfo = &m_descriptors[i].buffer;
m_descriptorWrites[i].pTexelBufferView = &m_descriptors[i].texelBuffer;
}
}
}

View File

@ -1237,8 +1237,8 @@ namespace dxvk {
std::vector<DxvkDeferredClear> m_deferredClears;
std::array<VkWriteDescriptorSet, MaxNumActiveBindings> m_descriptorWrites;
std::array<DxvkDescriptorInfo, MaxNumActiveBindings> m_descriptors;
std::vector<VkWriteDescriptorSet> m_descriptorWrites;
std::vector<DxvkDescriptorInfo> m_descriptors;
std::array<DxvkShaderResourceSlot, MaxNumResourceSlots> m_rc;
std::array<DxvkGraphicsPipeline*, 4096> m_gpLookupCache = { };
@ -1499,6 +1499,9 @@ namespace dxvk {
Rc<DxvkBuffer> createZeroBuffer(
VkDeviceSize size);
void resizeDescriptorArrays(
uint32_t bindingCount);
};
}

View File

@ -324,8 +324,10 @@ namespace dxvk {
m_mapping.insert({ binding.resourceBinding, mapping });
}
if (bindingCount)
if (bindingCount) {
m_bindingCount += bindingCount;
m_setMask |= 1u << i;
}
}
}

View File

@ -411,6 +411,14 @@ namespace dxvk {
return m_layout;
}
/**
* \brief Queries total number of bindings
* \returns Binding count in all sets
*/
uint32_t getBindingCount() const {
return m_bindingCount;
}
/**
* \brief Queries active descriptor set mask
* \returns Bit mask of non-empty descriptor sets
@ -483,6 +491,7 @@ namespace dxvk {
VkPipelineLayout m_completeLayout = VK_NULL_HANDLE;
VkPipelineLayout m_independentLayout = VK_NULL_HANDLE;
uint32_t m_bindingCount = 0;
uint32_t m_setMask = 0;
std::array<const DxvkBindingSetLayout*, DxvkDescriptorSets::SetCount> m_bindingObjects = { };