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 <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9511>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user