aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2024-11-21 09:08:32 -0600
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2024-11-21 08:54:55 -0700
commitfc5eb24a0941f9b53ceca35d9b36f4313c084ee9 (patch)
tree7784fc97baf0ee44324284b7d3bda99a75f56008
parentdf2ac1bb61f09a80db979d7108adf07b6fe55913 (diff)
downloadusermoji-fc5eb24a0941f9b53ceca35d9b36f4313c084ee9.tar.xz
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.
-rw-r--r--vulkaninfo/vulkaninfo.h9
1 files 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 <typename T, typename F, typename... Ts>
auto GetVectorInit(const char *func_name, F &&f, T init, Ts &&...ts) -> std::vector<T> {
- uint32_t count = 0;
+ uint32_t count = 32; // Preallocate enough so that most calls only happen once
std::vector<T> 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++;