Vulkan: Add a DynamicDescriptorPool class.
In order to manage the life of descriptor sets better and allow
allocating descriptor sets infinitely.
Bug:angleproject:2392
Change-Id: Ia3c7145d85d697c04e8008e8d8839c428dd2e864
Reviewed-on: https://chromium-review.googlesource.com/966786
Commit-Queue: Luc Ferron <lucferron@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp
index 4e5f833..fe5737a 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.cpp
+++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp
@@ -33,6 +33,9 @@
namespace
{
+// We currently only allocate 2 uniform buffer per descriptor set, one for the fragment shader and
+// one for the vertex shader.
+constexpr size_t kUniformBufferDescriptorsPerDescriptorSet = 2;
VkResult VerifyExtensionsPresent(const std::vector<VkExtensionProperties> &extensionProps,
const std::vector<const char *> &enabledExtensionNames)
@@ -593,6 +596,18 @@
return mNativeLimitations;
}
+uint32_t RendererVk::getMaxActiveTextures()
+{
+ // TODO(lucferron): expose this limitation to GL in Context Caps
+ return std::min<uint32_t>(mPhysicalDeviceProperties.limits.maxPerStageDescriptorSamplers,
+ gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES);
+}
+
+uint32_t RendererVk::getUniformBufferDescriptorCount()
+{
+ return kUniformBufferDescriptorsPerDescriptorSet;
+}
+
const vk::CommandPool &RendererVk::getCommandPool() const
{
return mCommandPool;
@@ -847,10 +862,7 @@
mGraphicsDescriptorSetLayouts.push_back(std::move(uniformLayout));
}
- // TODO(lucferron): expose this limitation to GL in Context Caps
- std::vector<VkDescriptorSetLayoutBinding> textureBindings(
- std::min<size_t>(mPhysicalDeviceProperties.limits.maxPerStageDescriptorSamplers,
- gl::IMPLEMENTATION_MAX_ACTIVE_TEXTURES));
+ std::vector<VkDescriptorSetLayoutBinding> textureBindings(getMaxActiveTextures());
// TODO(jmadill): This approach might not work well for texture arrays.
for (uint32_t textureIndex = 0; textureIndex < textureBindings.size(); ++textureIndex)