vulkan/sync: Make the can_wait_many() check faster

In the common case where drivers only support one sync type, we can make
this check a lot faster.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36827>
This commit is contained in:
Faith Ekstrand 2025-08-21 09:56:44 -04:00 committed by Marge Bot
parent 1f6209ba09
commit 57368203a7

View file

@ -33,6 +33,7 @@
#include "vk_alloc.h"
#include "vk_device.h"
#include "vk_log.h"
#include "vk_physical_device.h"
static void
vk_sync_type_validate(const struct vk_sync_type *type)
@ -258,7 +259,8 @@ vk_sync_wait(struct vk_device *device,
}
static bool
can_wait_many(uint32_t wait_count,
can_wait_many(struct vk_device *device,
uint32_t wait_count,
const struct vk_sync_wait *waits,
enum vk_sync_wait_flags wait_flags)
{
@ -269,6 +271,12 @@ can_wait_many(uint32_t wait_count,
!(waits[0].sync->type->features & VK_SYNC_FEATURE_WAIT_ANY))
return false;
/* If we only have one sync type, there's no need to check everything */
if (device->physical->supported_sync_types[1] == NULL) {
assert(waits[0].sync->type == device->physical->supported_sync_types[0]);
return true;
}
for (uint32_t i = 0; i < wait_count; i++) {
assert_valid_wait(waits[i].sync, waits[i].wait_value, wait_flags);
if (waits[i].sync->type != waits[0].sync->type)
@ -293,7 +301,7 @@ __vk_sync_wait_many(struct vk_device *device,
wait_flags & ~VK_SYNC_WAIT_ANY, abs_timeout_ns);
}
if (can_wait_many(wait_count, waits, wait_flags)) {
if (can_wait_many(device, wait_count, waits, wait_flags)) {
return waits[0].sync->type->wait_many(device, wait_count, waits,
wait_flags, abs_timeout_ns);
} else if (wait_flags & VK_SYNC_WAIT_ANY) {