Commit 72438f16 by Ben Clayton

Fix DescriptorUpdateTemplate::updateDescriptorSet

The logic did not handle desciptor arrays, or the descriptor overflow case. Bug: b/123244275 Tests: *with_template* Change-Id: Idf3f70848136865d1d76dc4f2f41b4c35d9230db Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28388Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Presubmit-Ready: Ben Clayton <bclayton@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 47747616
......@@ -220,8 +220,8 @@ size_t DescriptorSetLayout::getDynamicDescriptorOffset(uint32_t binding) const
VkDescriptorSetLayoutBinding const & DescriptorSetLayout::getBindingLayout(uint32_t binding) const
{
ASSERT(binding < bindingCount);
return bindings[binding];
uint32_t index = getBindingIndex(binding);
return bindings[index];
}
uint8_t* DescriptorSetLayout::getOffsetPointer(DescriptorSet *descriptorSet, uint32_t binding, uint32_t arrayElement, uint32_t count, size_t* typeSize) const
......
......@@ -62,8 +62,7 @@ public:
// VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
bool isBindingDynamic(uint32_t binding) const;
// Returns the VkDescriptorSetLayoutBinding for the binding with the given
// index.
// Returns the VkDescriptorSetLayoutBinding for the given binding.
VkDescriptorSetLayoutBinding const & getBindingLayout(uint32_t binding) const;
uint8_t* getOffsetPointer(DescriptorSet *descriptorSet, uint32_t binding, uint32_t arrayElement, uint32_t count, size_t* typeSize) const;
......
......@@ -41,13 +41,33 @@ namespace vk
for(uint32_t i = 0; i < descriptorUpdateEntryCount; i++)
{
for(uint32_t j = 0; j < descriptorUpdateEntries[i].descriptorCount; j++)
auto const &entry = descriptorUpdateEntries[i];
auto binding = entry.dstBinding;
auto arrayElement = entry.dstArrayElement;
for (uint32_t descriptorIndex = 0; descriptorIndex < entry.descriptorCount; descriptorIndex++)
{
const char *memToRead = (const char *)pData + descriptorUpdateEntries[i].offset + j * descriptorUpdateEntries[i].stride;
while (arrayElement == descriptorSetLayout->getBindingLayout(binding).descriptorCount)
{
// If descriptorCount is greater than the number of remaining
// array elements in the destination binding, those affect
// consecutive bindings in a manner similar to
// VkWriteDescriptorSet.
// If a binding has a descriptorCount of zero, it is skipped.
arrayElement = 0;
binding++;
}
uint8_t *memToRead = (uint8_t *)pData + entry.offset + descriptorIndex * entry.stride;
size_t typeSize = 0;
uint8_t* memToWrite = descriptorSetLayout->getOffsetPointer(
descriptorSet, descriptorUpdateEntries[i].dstBinding, descriptorUpdateEntries[i].dstArrayElement, 1, &typeSize);
descriptorSet,
binding,
arrayElement,
1, // count
&typeSize);
memcpy(memToWrite, memToRead, typeSize);
arrayElement++;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment