Skip to content

Commit 1228fba

Browse files
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.
1 parent df2ac1b commit 1228fba

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

vulkaninfo/vulkaninfo.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,14 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL DbgCallback(VkDebugReportFlagsEXT msgFlags
232232
// Helper for robustly executing the two-call pattern
233233
template <typename T, typename F, typename... Ts>
234234
auto GetVectorInit(const char *func_name, F &&f, T init, Ts &&...ts) -> std::vector<T> {
235-
uint32_t count = 0;
235+
uint32_t count = 32; // Preallocate enough so that most calls only happen once
236236
std::vector<T> results;
237237
VkResult err;
238238
uint32_t iteration_count = 0;
239-
uint32_t max_iterations = 3;
239+
uint32_t max_iterations = 5;
240240
do {
241-
err = f(ts..., &count, nullptr);
242-
if (err) THROW_VK_ERR(func_name, err);
243-
results.resize(count, init);
241+
count *= 2;
242+
results.resize(count);
244243
err = f(ts..., &count, results.data());
245244
results.resize(count);
246245
iteration_count++;

0 commit comments

Comments
 (0)