Descriptor sets update mechanism This cl adds proper storage and update of descriptor sets. The added functionality includes: - The descriptor pool now allocates the proper larger required storage needed to actually store descriptor set data. - Descriptor sets, when allocated, also get initialized with some basic header data (set layout) and also some Descriptor data when available (a.k.a: immutable samplers) - Descriptors are currently bindless, since it is simpler as a first implementation, but can easily be modified, which is intended to be done in the near future. For now, each descriptor set is either a VkDescriptorImageInfo, a VkDescriptorBufferInfo or a VkBufferView - Descriptors can be updated from either a VkWriteDescriptorSet or a VkCopyDescriptorSet structure. The update supports writing to multiple descriptor sets in a single operation and supports array sizes mismatch properly according to the spec Bug b/123244275 Change-Id: I1e0430e0014e26a304632a4b2b10ad0f69b06180 Reviewed-on: https://swiftshader-review.googlesource.com/c/24910 Tested-by: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: Corentin Wallez <cwallez@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Vulkan/VkDevice.cpp b/src/Vulkan/VkDevice.cpp index 4b3ae65..60e13f1 100644 --- a/src/Vulkan/VkDevice.cpp +++ b/src/Vulkan/VkDevice.cpp
@@ -16,6 +16,7 @@ #include "VkConfig.h" #include "VkDebug.hpp" +#include "VkDescriptorSetLayout.hpp" #include "VkQueue.hpp" #include <new> // Must #include this to use "placement new" @@ -99,4 +100,18 @@ pSupport->supported = VK_FALSE; } +void Device::updateDescriptorSets(uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, + uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies) +{ + for(uint32_t i = 0; i < descriptorWriteCount; i++) + { + DescriptorSetLayout::WriteDescriptorSet(pDescriptorWrites[i]); + } + + for(uint32_t i = 0; i < descriptorCopyCount; i++) + { + DescriptorSetLayout::CopyDescriptorSet(pDescriptorCopies[i]); + } +} + } // namespace vk