Open
Conversation
Adds SaveDxTextureAsPNG() to the common D3D12 renderer library and wires it into all 48 D3D12 examples, matching the existing Metal screenshot behavior. - projects/common/dx_renderer.h/.cpp: Add SaveDxTextureAsPNG() which reads back the swapchain buffer via a READBACK heap, converts BGRA to RGBA, forces alpha=255, and saves via BitmapRGBA8u::Save() - All D3D12 example main loops: add frameIndex tracking, update auto-exit guard to respect --screenshot frame targeting, insert screenshot block after WaitForGpu (correctly scoped for nested swapchain-buffer blocks in raytracing/path-trace examples) - CMakeLists: add bitmap.h/bitmap.cpp and stb include path to projects that were missing them Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SaveDxTextureAsPNG()toprojects/common/dx_renderer.h/.cpp— reads back the swapchain buffer via a D3D12READBACKheap, converts BGRA→RGBA, forces alpha=255, and saves viaBitmapRGBA8u::Save(). Mirrors the existingSaveMetalTextureAsPNG()helper.--screenshot <path> [frameN]into all 48 D3D12 example main loops, matching the Metal behavior exactly:frameNomitted takes a screenshot on frame 0 and continues;frameNspecified waits for that frame then auto-exits.swapchainBufferis block-scoped).bitmap.h/bitmap.cppor thestbinclude path.Test plan
cmake --build build --config Release --parallel101_color_cube_d3d12.exe --screenshot out.png 0030_raytracing_path_trace_d3d12.exe --screenshot out.png 100🤖 Generated with Claude Code