From e611c5b27d2230ebdd5a291c2d44c03a1d151eae Mon Sep 17 00:00:00 2001 From: PancakeTAS Date: Sun, 26 Apr 2026 01:10:19 +0200 Subject: [PATCH] feat(bindless): Split synchronization into another thread in debug tool I think RenderDoc attaches a fence or something, so the dispatch never returns. And ontop of this it looks like timeline semaphores can be signaled back to a lower value, when shared across processes --- lsfg-vk-cli/src/tools/benchmark.cpp | 2 +- lsfg-vk-cli/src/tools/debug.cpp | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lsfg-vk-cli/src/tools/benchmark.cpp b/lsfg-vk-cli/src/tools/benchmark.cpp index 88137e2..ebd826d 100644 --- a/lsfg-vk-cli/src/tools/benchmark.cpp +++ b/lsfg-vk-cli/src/tools/benchmark.cpp @@ -138,7 +138,7 @@ int benchmark::run(const Options& opts) { auto success = sync.wait(vk, idx++); if (!success) - throw ls::error("failed to wait for frame"); + throw ls::error("Failed to wait for frame"); total_frames++; generated_frames++; diff --git a/lsfg-vk-cli/src/tools/debug.cpp b/lsfg-vk-cli/src/tools/debug.cpp index b7b9c59..8c850f5 100644 --- a/lsfg-vk-cli/src/tools/debug.cpp +++ b/lsfg-vk-cli/src/tools/debug.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -185,6 +186,7 @@ int debug::run(const Options& opts) { // Render destination images const uint32_t total{static_cast(opts.multiplier) - 1U}; + size_t idx{1}; for (size_t j = 0; j < paths.size(); j++) { uploadDDS(vk, source, paths.at(j).string(), j % 2); @@ -192,19 +194,24 @@ int debug::run(const Options& opts) { rdoc_api->StartFrameCapture(rdoc_device, nullptr); } - const size_t idx{(j + 1) * total * 2}; - sync.signal(vk, idx - 1); + std::thread signal_thread{[&sync, &vk, &idx, total] { + for (size_t i = 0; i < total; i++) { + sync.signal(vk, idx++); + + auto success = sync.wait(vk, idx++); + if (!success) + throw ls::error("Failed to wait for frame"); + } + }}; lsfgvk_ctx.dispatch(total); - auto success = sync.wait(vk, idx); - if (!success) - throw ls::error("Failed to wait for frame"); - if (rdoc_api) { lsfgvk_ctx.idle(); rdoc_api->EndFrameCapture(rdoc_device, nullptr); } + + signal_thread.join(); } // Wait for idle