From 850c929967260fcec850fc349b34425ebf30397c Mon Sep 17 00:00:00 2001 From: Ahmad Sayed Alsayed Ebrahim Date: Sat, 10 Oct 2026 14:48:51 +0300 Subject: [PATCH] feat(vkbridge): VKBRIDGE_WSI_DUMP_EVERY=N dumps every Nth presented frame For watching a real game make progress through the bridge (frames are named by present count). Used to check The Witcher 3 (D3D12 / vkd3d-proton) on the host: legal screen and the 3D account-link screen render correctly. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01S1U9H1evGNjHRQ3wRUdv5V --- tools/vkbridge/client/wsi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/vkbridge/client/wsi.c b/tools/vkbridge/client/wsi.c index b97c4c3fe..066912895 100644 --- a/tools/vkbridge/client/wsi.c +++ b/tools/vkbridge/client/wsi.c @@ -714,7 +714,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkb_ep_vkAcquireNextImage2KHR(VkDevice device, co /* VKBRIDGE_WSI_DUMP=/path/prefix: writes presented frame 60 as a PPM (debugging aid). */ static void dump_frame(vkb_swapchain *sc, uint32_t index) { - if (sc->presents != 60) return; + /* The 60th present, or every VKBRIDGE_WSI_DUMP_EVERY-th (watching a game get somewhere). */ + static long every = -1; + if (every < 0) every = getenv("VKBRIDGE_WSI_DUMP_EVERY") ? atol(getenv("VKBRIDGE_WSI_DUMP_EVERY")) : 0; + if (every > 0 ? sc->presents % every != 0 : sc->presents != 60) return; uint32_t w = sc->info.imageExtent.width, h = sc->info.imageExtent.height, stride = w * 4; const uint8_t *px = NULL; void *map = NULL; @@ -730,7 +733,10 @@ static void dump_frame(vkb_swapchain *sc, uint32_t index) } if (!px) return; char path[512]; - snprintf(path, sizeof(path), "%s-%d.ppm", getenv("VKBRIDGE_WSI_DUMP"), (int)getpid()); + if (every > 0) + snprintf(path, sizeof(path), "%s-%d-%06u.ppm", getenv("VKBRIDGE_WSI_DUMP"), (int)getpid(), (unsigned)sc->presents); + else + snprintf(path, sizeof(path), "%s-%d.ppm", getenv("VKBRIDGE_WSI_DUMP"), (int)getpid()); FILE *f = fopen(path, "wb"); if (f) { int bgr = sc->info.imageFormat == VK_FORMAT_B8G8R8A8_UNORM || sc->info.imageFormat == VK_FORMAT_B8G8R8A8_SRGB;