From c51a2e85d87baf27f2fa1b9fec615e3bf178386e Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 3 Feb 2025 14:52:00 -0500 Subject: [PATCH] libcl/vk: add common query copy write routine every VK driver ends up wanting this. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Mary Guillemard Part-of: --- src/compiler/libcl/libcl_vk.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/compiler/libcl/libcl_vk.h b/src/compiler/libcl/libcl_vk.h index 9bfd65d1896..a6d1c58a378 100644 --- a/src/compiler/libcl/libcl_vk.h +++ b/src/compiler/libcl/libcl_vk.h @@ -42,6 +42,19 @@ typedef enum VkQueryResultFlagBits { VK_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkQueryResultFlagBits; +static inline void +vk_write_query(uintptr_t dst_addr, int32_t idx, VkQueryResultFlagBits flags, + uint64_t result) +{ + if (flags & VK_QUERY_RESULT_64_BIT) { + global uint64_t *out = (global uint64_t *)dst_addr; + out[idx] = result; + } else { + global uint32_t *out = (global uint32_t *)dst_addr; + out[idx] = result; + } +} + typedef enum VkIndexType { VK_INDEX_TYPE_UINT16 = 0, VK_INDEX_TYPE_UINT32 = 1,