Module: Mesa
Branch: master
Commit: 492b5577f0037cb95f74f059c71b91c01349a0fa
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=492b5577f0037cb95f74f059c71b91c01349a0fa

Author: Jason Ekstrand <[email protected]>
Date:   Wed Mar 10 20:26:22 2021 -0600

vulkan/util: Add a type parameter to vk_multialloc_add

We also switch from using __alignof__ to alignof() in util/macros.h
which works on MSVC with the one unfortunate downside of requiring an
actual type and not a value.

Reviewed-by: Jesse Natalie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9511>

---

 src/intel/vulkan/anv_queue.c  |  5 +++--
 src/intel/vulkan/genX_query.c |  6 ++++--
 src/vulkan/util/vk_alloc.h    | 19 ++++++++++++-------
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
index 87afebfcfcd..a582de44735 100644
--- a/src/intel/vulkan/anv_queue.c
+++ b/src/intel/vulkan/anv_queue.c
@@ -2792,9 +2792,10 @@ VkResult anv_WaitSemaphores(
 
    VK_MULTIALLOC_DECL(&ma, uint64_t, values, pWaitInfo->semaphoreCount);
    if (device->has_thread_submit) {
-      vk_multialloc_add(&ma, &handles, pWaitInfo->semaphoreCount);
+      vk_multialloc_add(&ma, &handles, uint32_t, pWaitInfo->semaphoreCount);
    } else {
-      vk_multialloc_add(&ma, &timelines, pWaitInfo->semaphoreCount);
+      vk_multialloc_add(&ma, &timelines, struct anv_timeline *,
+                             pWaitInfo->semaphoreCount);
    }
 
    if (!vk_multialloc_alloc(&ma, &device->vk.alloc,
diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c
index 6520c39d568..32f97b75bae 100644
--- a/src/intel/vulkan/genX_query.c
+++ b/src/intel/vulkan/genX_query.c
@@ -141,8 +141,10 @@ VkResult genX(CreateQueryPool)(
                                        perf_query_info->pCounterIndices,
                                        perf_query_info->counterIndexCount,
                                        NULL);
-      vk_multialloc_add(&ma, &counter_pass, 
perf_query_info->counterIndexCount);
-      vk_multialloc_add(&ma, &pass_query, n_passes);
+      vk_multialloc_add(&ma, &counter_pass, struct gen_perf_counter_pass,
+                             perf_query_info->counterIndexCount);
+      vk_multialloc_add(&ma, &pass_query, struct gen_perf_query_info *,
+                             n_passes);
       uint64s_per_slot = 4 /* availability + small batch */;
       /* Align to the requirement of the layout */
       uint64s_per_slot = align_u32(uint64s_per_slot,
diff --git a/src/vulkan/util/vk_alloc.h b/src/vulkan/util/vk_alloc.h
index ef4067b4483..abf99197384 100644
--- a/src/vulkan/util/vk_alloc.h
+++ b/src/vulkan/util/vk_alloc.h
@@ -156,8 +156,8 @@ struct vk_multialloc {
    struct vk_multialloc _name = VK_MULTIALLOC_INIT
 
 static ALWAYS_INLINE void
-_vk_multialloc_add(struct vk_multialloc *ma,
-                   void **ptr, size_t size, size_t align)
+vk_multialloc_add_size_align(struct vk_multialloc *ma,
+                             void **ptr, size_t size, size_t align)
 {
    assert(util_is_power_of_two_nonzero(align));
    if (size == 0) {
@@ -176,15 +176,20 @@ _vk_multialloc_add(struct vk_multialloc *ma,
    ma->ptrs[ma->ptr_count++] = ptr;
 }
 
-#define vk_multialloc_add_size(_ma, _ptr, _size) \
-   _vk_multialloc_add((_ma), (void **)(_ptr), (_size), __alignof__(**(_ptr)))
+#define vk_multialloc_add_size(_ma, _ptr, _type, _size) \
+   do { \
+      _type **_tmp = (_ptr); \
+      (void)_tmp; \
+      vk_multialloc_add_size_align((_ma), (void **)(_ptr), \
+                                   (_size), alignof(_type)); \
+   } while(0)
 
-#define vk_multialloc_add(_ma, _ptr, _count) \
-   vk_multialloc_add_size(_ma, _ptr, (_count) * sizeof(**(_ptr)));
+#define vk_multialloc_add(_ma, _ptr, _type, _count) \
+   vk_multialloc_add_size(_ma, _ptr, _type, (_count) * sizeof(**(_ptr)));
 
 #define VK_MULTIALLOC_DECL_SIZE(_ma, _type, _name, _size) \
    _type *_name; \
-   vk_multialloc_add_size(_ma, &_name, _size);
+   vk_multialloc_add_size(_ma, &_name, _type, _size);
 
 #define VK_MULTIALLOC_DECL(_ma, _type, _name, _count) \
    VK_MULTIALLOC_DECL_SIZE(_ma, _type, _name, (_count) * sizeof(_type));

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to