zink: break out vk flag unrolling into util function

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23653>
This commit is contained in:
Mike Blumenkrantz 2023-06-13 10:45:38 -04:00 committed by Marge Bot
parent de60b463d7
commit 65fad783c7
2 changed files with 17 additions and 8 deletions

View file

@ -98,6 +98,22 @@ zink_screen_handle_vkresult(struct zink_screen *screen, VkResult ret)
return success;
}
typedef const char *(*zink_vkflags_func)(uint64_t);
static inline unsigned
zink_string_vkflags_unroll(char *buf, size_t bufsize, uint64_t flags, zink_vkflags_func func)
{
bool first = true;
unsigned idx = 0;
u_foreach_bit64(bit, flags) {
if (!first)
buf[idx++] = '|';
idx += snprintf(&buf[idx], bufsize - idx, "%s", func((1ul<<bit)));
first = false;
}
return idx;
}
VkSemaphore
zink_create_semaphore(struct zink_screen *screen);

View file

@ -591,14 +591,7 @@ zink_resource_buffer_barrier(struct zink_context *ctx, struct zink_resource *res
bool marker = false;
if (unlikely(zink_tracing)) {
char buf[4096];
bool first = true;
unsigned idx = 0;
u_foreach_bit64(bit, flags) {
if (!first)
buf[idx++] = '|';
idx += snprintf(&buf[idx], sizeof(buf) - idx, "%s", vk_AccessFlagBits_to_str((VkAccessFlagBits)(1ul<<bit)));
first = false;
}
zink_string_vkflags_unroll(buf, sizeof(buf), flags, (zink_vkflags_func)vk_AccessFlagBits_to_str);
marker = zink_cmd_debug_marker_begin(ctx, cmdbuf, "buffer_barrier(%s)", buf);
}