From fc5eb24a0941f9b53ceca35d9b36f4313c084ee9 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Thu, 21 Nov 2024 09:08:32 -0600 Subject: vulkaninfo: Call enumerate functions with scratch buffer This change makes calls using GetVectorInit() to start with an already created buffer of size 64, allowing for the Vulkan implementation to immediately fill in the buffer, rather than having to call the enumerate function twice. This change is primarily motivated to reduce the spam VK_LOADER_DEBUG=all produces when run with vulkaninfo. --- vulkaninfo/vulkaninfo.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vulkaninfo/vulkaninfo.h b/vulkaninfo/vulkaninfo.h index 116c0b0c..f3eb43e2 100644 --- a/vulkaninfo/vulkaninfo.h +++ b/vulkaninfo/vulkaninfo.h @@ -232,15 +232,14 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DbgCallback(VkDebugReportFlagsEXT msgFlags // Helper for robustly executing the two-call pattern template auto GetVectorInit(const char *func_name, F &&f, T init, Ts &&...ts) -> std::vector { - uint32_t count = 0; + uint32_t count = 32; // Preallocate enough so that most calls only happen once std::vector results; VkResult err; uint32_t iteration_count = 0; - uint32_t max_iterations = 3; + uint32_t max_iterations = 5; do { - err = f(ts..., &count, nullptr); - if (err) THROW_VK_ERR(func_name, err); - results.resize(count, init); + count *= 2; + results.resize(count); err = f(ts..., &count, results.data()); results.resize(count); iteration_count++; -- cgit v1.2.3