Mesa (main): dzn: Split the write desc helpers in two halves
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 10:51:16 UTC 2022
Module: Mesa
Branch: main
Commit: 4da5524c9b43b488f7572a3516a8fa045a456cd4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4da5524c9b43b488f7572a3516a8fa045a456cd4
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Thu Apr 14 14:34:19 2022 +0200
dzn: Split the write desc helpers in two halves
Split the write desc helpers in two halves, one taking a descriptor
offset directly, and the other one taking a descriptor set pointer.
This will allow us to pre-calculate descriptor offsets when creating
a descriptor_update template and speed up a bit the write step in that
case.
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15691>
---
src/microsoft/vulkan/dzn_descriptor_set.c | 138 +++++++++++++++++++++---------
1 file changed, 96 insertions(+), 42 deletions(-)
diff --git a/src/microsoft/vulkan/dzn_descriptor_set.c b/src/microsoft/vulkan/dzn_descriptor_set.c
index 33098c30ad7..4af5dc85337 100644
--- a/src/microsoft/vulkan/dzn_descriptor_set.c
+++ b/src/microsoft/vulkan/dzn_descriptor_set.c
@@ -1050,6 +1050,23 @@ dzn_descriptor_set_ptr_get_heap_offset(const struct dzn_descriptor_set_layout *l
return base + ptr->elem;
}
+static void
+dzn_descriptor_set_write_sampler_desc(struct dzn_descriptor_set *set,
+ uint32_t heap_offset,
+ const struct dzn_sampler *sampler)
+{
+ if (heap_offset == ~0)
+ return;
+
+ D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER;
+
+ mtx_lock(&set->pool->defragment_lock);
+ dzn_descriptor_heap_write_sampler_desc(&set->pool->heaps[type],
+ set->heap_offsets[type] + heap_offset,
+ sampler);
+ mtx_unlock(&set->pool->defragment_lock);
+}
+
static void
dzn_descriptor_set_ptr_write_sampler_desc(struct dzn_descriptor_set *set,
const struct dzn_descriptor_set_ptr *ptr,
@@ -1059,13 +1076,7 @@ dzn_descriptor_set_ptr_write_sampler_desc(struct dzn_descriptor_set *set,
uint32_t heap_offset =
dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, false);
- if (heap_offset != ~0) {
- mtx_lock(&set->pool->defragment_lock);
- dzn_descriptor_heap_write_sampler_desc(&set->pool->heaps[type],
- set->heap_offsets[type] + heap_offset,
- sampler);
- mtx_unlock(&set->pool->defragment_lock);
- }
+ dzn_descriptor_set_write_sampler_desc(set, heap_offset, sampler);
}
static uint32_t
@@ -1083,6 +1094,18 @@ dzn_descriptor_set_ptr_get_dynamic_buffer_idx(const struct dzn_descriptor_set_la
return base + ptr->elem;
}
+static void
+dzn_descriptor_set_write_dynamic_buffer_desc(struct dzn_descriptor_set *set,
+ uint32_t dynamic_buffer_idx,
+ const struct dzn_buffer_desc *info)
+{
+ if (dynamic_buffer_idx == ~0)
+ return;
+
+ assert(dynamic_buffer_idx < set->layout->dynamic_buffers.count);
+ set->dynamic_buffers[dynamic_buffer_idx] = *info;
+}
+
static void
dzn_descriptor_set_ptr_write_dynamic_buffer_desc(struct dzn_descriptor_set *set,
const struct dzn_descriptor_set_ptr *ptr,
@@ -1090,11 +1113,8 @@ dzn_descriptor_set_ptr_write_dynamic_buffer_desc(struct dzn_descriptor_set *set,
{
uint32_t dynamic_buffer_idx =
dzn_descriptor_set_ptr_get_dynamic_buffer_idx(set->layout, ptr);
- if (dynamic_buffer_idx == ~0)
- return;
- assert(dynamic_buffer_idx < set->layout->dynamic_buffers.count);
- set->dynamic_buffers[dynamic_buffer_idx] = *info;
+ dzn_descriptor_set_write_dynamic_buffer_desc(set, dynamic_buffer_idx, info);
}
static VkDescriptorType
@@ -1108,14 +1128,14 @@ dzn_descriptor_set_ptr_get_vk_type(const struct dzn_descriptor_set_layout *layou
}
static void
-dzn_descriptor_set_ptr_write_image_view_desc(struct dzn_descriptor_set *set,
- const struct dzn_descriptor_set_ptr *ptr,
- bool cube_as_2darray,
- const struct dzn_image_view *iview)
+dzn_descriptor_set_write_image_view_desc(struct dzn_descriptor_set *set,
+ uint32_t heap_offset,
+ uint32_t alt_heap_offset,
+ bool cube_as_2darray,
+ const struct dzn_image_view *iview)
{
D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
- uint32_t heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, false);
+
if (heap_offset == ~0)
return;
@@ -1125,13 +1145,9 @@ dzn_descriptor_set_ptr_write_image_view_desc(struct dzn_descriptor_set *set,
false, cube_as_2darray,
iview);
- VkDescriptorType vk_type = dzn_descriptor_set_ptr_get_vk_type(set->layout, ptr);
- if (dzn_descriptor_type_depends_on_shader_usage(vk_type)) {
- heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, true);
- assert(heap_offset != ~0);
+ if (alt_heap_offset != ~0) {
dzn_descriptor_heap_write_image_view_desc(&set->pool->heaps[type],
- set->heap_offsets[type] + heap_offset,
+ set->heap_offsets[type] + alt_heap_offset,
true, cube_as_2darray,
iview);
}
@@ -1139,41 +1155,68 @@ dzn_descriptor_set_ptr_write_image_view_desc(struct dzn_descriptor_set *set,
}
static void
-dzn_descriptor_set_ptr_write_buffer_view_desc(struct dzn_descriptor_set *set,
- const struct dzn_descriptor_set_ptr *ptr,
- const struct dzn_buffer_view *bview)
+dzn_descriptor_set_ptr_write_image_view_desc(struct dzn_descriptor_set *set,
+ const struct dzn_descriptor_set_ptr *ptr,
+ bool cube_as_2darray,
+ const struct dzn_image_view *iview)
{
D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
uint32_t heap_offset =
dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, false);
+ uint32_t alt_heap_offset =
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, true);
+
+ dzn_descriptor_set_write_image_view_desc(set, heap_offset, alt_heap_offset,
+ cube_as_2darray, iview);
+}
+
+static void
+dzn_descriptor_set_write_buffer_view_desc(struct dzn_descriptor_set *set,
+ uint32_t heap_offset,
+ uint32_t alt_heap_offset,
+ const struct dzn_buffer_view *bview)
+{
if (heap_offset == ~0)
return;
+ D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
+
mtx_lock(&set->pool->defragment_lock);
dzn_descriptor_heap_write_buffer_view_desc(&set->pool->heaps[type],
- set->heap_offsets[type] + heap_offset,
+ set->heap_offsets[type] +
+ heap_offset,
false, bview);
- VkDescriptorType vk_type = dzn_descriptor_set_ptr_get_vk_type(set->layout, ptr);
- if (dzn_descriptor_type_depends_on_shader_usage(vk_type)) {
- heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, true);
- assert(heap_offset != ~0);
+ if (alt_heap_offset != ~0) {
dzn_descriptor_heap_write_buffer_view_desc(&set->pool->heaps[type],
- set->heap_offsets[type] + heap_offset,
+ set->heap_offsets[type] +
+ alt_heap_offset,
true, bview);
}
mtx_unlock(&set->pool->defragment_lock);
}
static void
-dzn_descriptor_set_ptr_write_buffer_desc(struct dzn_descriptor_set *set,
- const struct dzn_descriptor_set_ptr *ptr,
- const struct dzn_buffer_desc *bdesc)
+dzn_descriptor_set_ptr_write_buffer_view_desc(struct dzn_descriptor_set *set,
+ const struct dzn_descriptor_set_ptr *ptr,
+ const struct dzn_buffer_view *bview)
{
D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
uint32_t heap_offset =
dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, false);
+ uint32_t alt_heap_offset =
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, true);
+
+ dzn_descriptor_set_write_buffer_view_desc(set, heap_offset, alt_heap_offset, bview);
+}
+
+static void
+dzn_descriptor_set_write_buffer_desc(struct dzn_descriptor_set *set,
+ uint32_t heap_offset,
+ uint32_t alt_heap_offset,
+ const struct dzn_buffer_desc *bdesc)
+{
+ D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
if (heap_offset == ~0)
return;
@@ -1182,18 +1225,29 @@ dzn_descriptor_set_ptr_write_buffer_desc(struct dzn_descriptor_set *set,
set->heap_offsets[type] + heap_offset,
false, bdesc);
- VkDescriptorType vk_type = dzn_descriptor_set_ptr_get_vk_type(set->layout, ptr);
- if (dzn_descriptor_type_depends_on_shader_usage(vk_type)) {
- heap_offset =
- dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, true);
- assert(heap_offset != ~0);
+ if (alt_heap_offset != ~0) {
dzn_descriptor_heap_write_buffer_desc(&set->pool->heaps[type],
- set->heap_offsets[type] + heap_offset,
+ set->heap_offsets[type] +
+ alt_heap_offset,
true, bdesc);
}
mtx_unlock(&set->pool->defragment_lock);
}
+static void
+dzn_descriptor_set_ptr_write_buffer_desc(struct dzn_descriptor_set *set,
+ const struct dzn_descriptor_set_ptr *ptr,
+ const struct dzn_buffer_desc *bdesc)
+{
+ D3D12_DESCRIPTOR_HEAP_TYPE type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
+ uint32_t heap_offset =
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, false);
+ uint32_t alt_heap_offset =
+ dzn_descriptor_set_ptr_get_heap_offset(set->layout, type, ptr, true);
+
+ dzn_descriptor_set_write_buffer_desc(set, heap_offset, alt_heap_offset, bdesc);
+}
+
static void
dzn_descriptor_set_init(struct dzn_descriptor_set *set,
struct dzn_device *device,
More information about the mesa-commit
mailing list