Mesa (main): Add the iub binding count tracking
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 7 02:45:46 UTC 2022
Module: Mesa
Branch: main
Commit: abae9d4831b5e983385d988ef95874e449887cc1
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=abae9d4831b5e983385d988ef95874e449887cc1
Author: Dawn Han <dawnhan at google.com>
Date: Thu Jun 30 00:33:33 2022 +0000
Add the iub binding count tracking
Signed-off-by: Dawn Han <dawnhan at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16699>
---
src/virtio/vulkan/vn_descriptor_set.c | 20 ++++++++++++++++++++
src/virtio/vulkan/vn_descriptor_set.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/src/virtio/vulkan/vn_descriptor_set.c b/src/virtio/vulkan/vn_descriptor_set.c
index b1f8fef42fe..7698163f895 100644
--- a/src/virtio/vulkan/vn_descriptor_set.c
+++ b/src/virtio/vulkan/vn_descriptor_set.c
@@ -306,6 +306,9 @@ vn_CreateDescriptorPool(VkDevice device,
pool->max.set_count = pCreateInfo->maxSets;
+ if (iub_info)
+ pool->max.iub_binding_count = iub_info->maxInlineUniformBlockBindings;
+
for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; i++) {
const VkDescriptorPoolSize *pool_size = &pCreateInfo->pPoolSizes[i];
const uint32_t type_index = vn_descriptor_type_index(pool_size->type);
@@ -385,6 +388,20 @@ vn_descriptor_pool_alloc_descriptors(
? last_binding_descriptor_count
: layout->bindings[i].count;
+ /* Allocation may fail if a call to vkAllocateDescriptorSets would cause
+ * the total number of inline uniform block bindings allocated from the
+ * pool to exceed the value of
+ * VkDescriptorPoolInlineUniformBlockCreateInfo::maxInlineUniformBlockBindings
+ * used to create the descriptor pool.
+ */
+ if (type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK) {
+ if (++pool->used.iub_binding_count > pool->max.iub_binding_count) {
+ /* restore pool state before this allocation */
+ pool->used = recovery;
+ return false;
+ }
+ }
+
const uint32_t type_index = vn_descriptor_type_index(type);
pool->used.descriptor_counts[type_index] += count;
@@ -415,6 +432,9 @@ vn_descriptor_pool_free_descriptors(
pool->used.descriptor_counts[vn_descriptor_type_index(
layout->bindings[i].type)] -= count;
+
+ if (layout->bindings[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK)
+ --pool->used.iub_binding_count;
}
--pool->used.set_count;
diff --git a/src/virtio/vulkan/vn_descriptor_set.h b/src/virtio/vulkan/vn_descriptor_set.h
index 780c429e16b..9e4de072da6 100644
--- a/src/virtio/vulkan/vn_descriptor_set.h
+++ b/src/virtio/vulkan/vn_descriptor_set.h
@@ -60,6 +60,7 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_set_layout,
struct vn_descriptor_pool_state {
uint32_t set_count;
+ uint32_t iub_binding_count;
uint32_t descriptor_counts[VN_NUM_DESCRIPTOR_TYPES];
};
More information about the mesa-commit
mailing list