Vulkan: Fix texture descriptor set alloc count.
We were reserving half the required descriptor sets for our pool. This
fixes the counting and ensures we won't regress by adding a test.
Also enables the cube map texture sample, and removes an UNIMPLEMENTED
warning that was spurious.
Bug: angleproject:2318
Change-Id: I371cd7c5b42e1ce980cce7bb0ef04885db72b614
Reviewed-on: https://chromium-review.googlesource.com/1014165
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Luc Ferron <lucferron@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/ProgramVk.cpp b/src/libANGLE/renderer/vulkan/ProgramVk.cpp
index 6fb33e0..989232f 100644
--- a/src/libANGLE/renderer/vulkan/ProgramVk.cpp
+++ b/src/libANGLE/renderer/vulkan/ProgramVk.cpp
@@ -431,7 +431,8 @@
if (linkedUniform.isSampler())
{
- UNIMPLEMENTED();
+ // We could potentially cache some indexing here. For now this is a no-op since the mapping
+ // is handled entirely in ContextVk.
return;
}
diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.cpp b/src/libANGLE/renderer/vulkan/vk_helpers.cpp
index dba6875..4261879 100644
--- a/src/libANGLE/renderer/vulkan/vk_helpers.cpp
+++ b/src/libANGLE/renderer/vulkan/vk_helpers.cpp
@@ -19,7 +19,7 @@
namespace
{
// TODO(jmadill): Pick non-arbitrary max.
-constexpr uint32_t kDynamicDescriptorPoolMaxSets = 2048;
+constexpr uint32_t kDefaultDynamicDescriptorPoolMaxSets = 2048;
constexpr VkBufferUsageFlags kLineLoopDynamicBufferUsage =
(VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT);
@@ -239,7 +239,8 @@
// DynamicDescriptorPool implementation.
DynamicDescriptorPool::DynamicDescriptorPool()
- : mCurrentAllocatedDescriptorSetCount(0),
+ : mMaxSetsPerPool(kDefaultDynamicDescriptorPoolMaxSets),
+ mCurrentAllocatedDescriptorSetCount(0),
mUniformBufferDescriptorsPerSet(0),
mCombinedImageSamplerDescriptorsPerSet(0)
{
@@ -274,7 +275,7 @@
uint32_t descriptorSetCount,
VkDescriptorSet *descriptorSetsOut)
{
- if (descriptorSetCount + mCurrentAllocatedDescriptorSetCount > kDynamicDescriptorPoolMaxSets)
+ if (descriptorSetCount + mCurrentAllocatedDescriptorSetCount > mMaxSetsPerPool)
{
RendererVk *renderer = contextVk->getRenderer();
Serial currentSerial = renderer->getCurrentQueueSerial();
@@ -303,17 +304,16 @@
VkDescriptorPoolSize poolSizes[DescriptorPoolIndexCount];
poolSizes[UniformBufferIndex].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
poolSizes[UniformBufferIndex].descriptorCount =
- mUniformBufferDescriptorsPerSet * kDynamicDescriptorPoolMaxSets / DescriptorPoolIndexCount;
+ mUniformBufferDescriptorsPerSet * mMaxSetsPerPool;
poolSizes[TextureIndex].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
- poolSizes[TextureIndex].descriptorCount = mCombinedImageSamplerDescriptorsPerSet *
- kDynamicDescriptorPoolMaxSets /
- DescriptorPoolIndexCount;
+ poolSizes[TextureIndex].descriptorCount =
+ mCombinedImageSamplerDescriptorsPerSet * mMaxSetsPerPool;
VkDescriptorPoolCreateInfo descriptorPoolInfo;
descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
descriptorPoolInfo.pNext = nullptr;
descriptorPoolInfo.flags = 0;
- descriptorPoolInfo.maxSets = kDynamicDescriptorPoolMaxSets;
+ descriptorPoolInfo.maxSets = mMaxSetsPerPool;
// Reserve pools for uniform blocks and textures.
descriptorPoolInfo.poolSizeCount = DescriptorPoolIndexCount;
@@ -324,6 +324,12 @@
return NoError();
}
+void DynamicDescriptorPool::setMaxSetsPerPoolForTesting(uint32_t maxSetsPerPool)
+{
+ mMaxSetsPerPool = maxSetsPerPool;
+}
+
+// LineLoopHelper implementation.
LineLoopHelper::LineLoopHelper()
: mDynamicIndexBuffer(kLineLoopDynamicBufferUsage, kLineLoopDynamicBufferMinSize)
{
diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.h b/src/libANGLE/renderer/vulkan/vk_helpers.h
index 3b6c628..09cf845 100644
--- a/src/libANGLE/renderer/vulkan/vk_helpers.h
+++ b/src/libANGLE/renderer/vulkan/vk_helpers.h
@@ -101,9 +101,13 @@
uint32_t descriptorSetCount,
VkDescriptorSet *descriptorSetsOut);
+ // For testing only!
+ void setMaxSetsPerPoolForTesting(uint32_t maxSetsPerPool);
+
private:
Error allocateNewPool(const VkDevice &device);
+ uint32_t mMaxSetsPerPool;
DescriptorPool mCurrentDescriptorSetPool;
size_t mCurrentAllocatedDescriptorSetCount;
uint32_t mUniformBufferDescriptorsPerSet;