diff options
author | Mohan Maiya <m.maiya@samsung.com> | 2024-04-17 06:12:14 -0700 |
---|---|---|
committer | Angle LUCI CQ <angle-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-04-17 22:18:24 +0000 |
commit | b2aad1bbb7ce8f333e0463744c919f5239edabe2 (patch) | |
tree | 37ea1e45b5f39ce4e05d94498293116cf84b4728 | |
parent | d71b8ee0f0e26b14a8fa642460df2635c2d7db2f (diff) | |
download | angle-b2aad1bbb7ce8f333e0463744c919f5239edabe2.tar.gz |
Vulkan: Track valid descriptor set layouts
Instead of looping through kMaxDescriptorSetLayoutBindings in
`DescriptorSetLayoutDesc::unpackBindings` track valid descriptor set
layouts in `DescriptorSetLayoutDesc::update`
Bug: angleproject:2462
Change-Id: I1ca2ba72875d9306b6059b14cde39c5d16250be6
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5464160
Reviewed-by: Charlie Lao <cclao@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: mohan maiya <m.maiya@samsung.com>
-rw-r--r-- | src/libANGLE/renderer/vulkan/vk_cache_utils.cpp | 13 | ||||
-rw-r--r-- | src/libANGLE/renderer/vulkan/vk_cache_utils.h | 9 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp b/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp index 4680ccfb81..ff2e4259f8 100644 --- a/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp +++ b/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp @@ -4294,7 +4294,9 @@ bool operator==(const AttachmentOpsArray &lhs, const AttachmentOpsArray &rhs) } // DescriptorSetLayoutDesc implementation. -DescriptorSetLayoutDesc::DescriptorSetLayoutDesc() : mPackedDescriptorSetLayout{} {} +DescriptorSetLayoutDesc::DescriptorSetLayoutDesc() + : mPackedDescriptorSetLayout{}, mValidDescriptorSetLayoutIndexMask() +{} DescriptorSetLayoutDesc::~DescriptorSetLayoutDesc() = default; @@ -4336,19 +4338,20 @@ void DescriptorSetLayoutDesc::update(uint32_t bindingIndex, ASSERT(count == 1); packedBinding.immutableSampler = immutableSampler->getHandle(); } + + mValidDescriptorSetLayoutIndexMask.set(bindingIndex, count > 0); } void DescriptorSetLayoutDesc::unpackBindings(DescriptorSetLayoutBindingVector *bindings, std::vector<VkSampler> *immutableSamplers) const { - for (uint32_t bindingIndex = 0; bindingIndex < kMaxDescriptorSetLayoutBindings; ++bindingIndex) + for (size_t bindingIndex : mValidDescriptorSetLayoutIndexMask) { const PackedDescriptorSetBinding &packedBinding = mPackedDescriptorSetLayout[bindingIndex]; - if (packedBinding.count == 0) - continue; + ASSERT(packedBinding.count != 0); VkDescriptorSetLayoutBinding binding = {}; - binding.binding = bindingIndex; + binding.binding = static_cast<uint32_t>(bindingIndex); binding.descriptorCount = packedBinding.count; binding.descriptorType = static_cast<VkDescriptorType>(packedBinding.type); binding.stageFlags = static_cast<VkShaderStageFlags>(packedBinding.stages); diff --git a/src/libANGLE/renderer/vulkan/vk_cache_utils.h b/src/libANGLE/renderer/vulkan/vk_cache_utils.h index b1d70bfdaf..056d350503 100644 --- a/src/libANGLE/renderer/vulkan/vk_cache_utils.h +++ b/src/libANGLE/renderer/vulkan/vk_cache_utils.h @@ -993,6 +993,11 @@ constexpr uint32_t kMaxDescriptorSetLayoutBindings = using DescriptorSetLayoutBindingVector = angle::FixedVector<VkDescriptorSetLayoutBinding, kMaxDescriptorSetLayoutBindings>; +// Technically this needs to only be kMaxDescriptorSetLayoutBindings but due to struct padding +// issues round up size to 64. +constexpr uint32_t kMaxDescriptorSetLayoutCount = roundUpPow2(kMaxDescriptorSetLayoutBindings, 64u); +using DescriptorSetLayoutIndexMask = angle::BitSet<kMaxDescriptorSetLayoutCount>; + // A packed description of a descriptor set layout. Use similarly to RenderPassDesc and // GraphicsPipelineDesc. Currently we only need to differentiate layouts based on sampler and ubo // usage. In the future we could generalize this. @@ -1016,7 +1021,7 @@ class DescriptorSetLayoutDesc final void unpackBindings(DescriptorSetLayoutBindingVector *bindings, std::vector<VkSampler> *immutableSamplers) const; - bool empty() const { return *this == DescriptorSetLayoutDesc(); } + bool empty() const { return !mValidDescriptorSetLayoutIndexMask.any(); } private: // There is a small risk of an issue if the sampler cache is evicted but not the descriptor @@ -1037,6 +1042,8 @@ class DescriptorSetLayoutDesc final // This is a compact representation of a descriptor set layout. std::array<PackedDescriptorSetBinding, kMaxDescriptorSetLayoutBindings> mPackedDescriptorSetLayout; + + DescriptorSetLayoutIndexMask mValidDescriptorSetLayoutIndexMask; }; // The following are for caching descriptor set layouts. Limited to max three descriptor set |