From 2a44266d57de0fc7ae053503aab276d3443bc6fe Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 27 Feb 2025 17:28:49 -0500 Subject: [PATCH] vulkan: add helpers to work with executable statistics this is a lot of boilerplate in each driver. add helpers for it instead. the common framework will use these internally, but drivers that don't want the framework for whatever reason could use these themselves too. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Mary Guillemard Part-of: --- src/vulkan/util/vk_util.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/vulkan/util/vk_util.h b/src/vulkan/util/vk_util.h index e86d72ff379..7254871e455 100644 --- a/src/vulkan/util/vk_util.h +++ b/src/vulkan/util/vk_util.h @@ -412,6 +412,29 @@ vk_descriptor_type_is_dynamic(VkDescriptorType type) memset(field + len, 0, sizeof(field) - len); \ } while(0) +#define vk_add_exec_statistic(out, name_, description_, format_enum, \ + format_member, value_) \ + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &(out), stat) \ + { \ + VK_COPY_STR(stat->name, name_); \ + VK_COPY_STR(stat->description, description_); \ + stat->format = \ + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_##format_enum##_KHR; \ + stat->value.format_member = (value_); \ + } + +#define vk_add_exec_statistic_i64(out, name, description, value) \ + vk_add_exec_statistic(out, name, description, INT64, i64, value) + +#define vk_add_exec_statistic_u64(out, name, description, value) \ + vk_add_exec_statistic(out, name, description, UINT64, u64, value) + +#define vk_add_exec_statistic_f64(out, name, description, value) \ + vk_add_exec_statistic(out, name, description, FLOAT64, f64, value) + +#define vk_add_exec_statistic_bool(out, name, description, value) \ + vk_add_exec_statistic(out, name, description, BOOL32, b32, value) + #ifdef __cplusplus } #endif