runtime: add an opt-in resource write trace and a targeted draw dump #3822
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3822
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3820"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Leyukaka on GitHub · 2026-12-02 03:12 UTC · original
Leyukaka:scene-pr-dump→main· +1622 −44 · 13 files · 4 commits · openProblem
When a translated draw samples a resource with unexpected content, or leaves its targets unchanged, the existing diagnostics do not answer two questions directly:
Today, answering them means adding temporary logging around the draw path each time.
Change
Diagnostics only. Each part is off unless its environment variable is set. When the variables are unset, nothing is traced and no copy is scheduled.
runtime: trace writes to a selected D3D12 resource(d3d12_write_trace.inl)X2W_D3D12_WRITE_TRACE=srv-of:<hex pipeline key>:<SRV index>selects the resource that the given translated pipeline samples at that SRV slot. A plain hex address selects by address instead.x2w-write-tracelines with the operation, its outcome and the frame: translated draws, compute dispatches, buffer and texture copies, clears and discards. Writers recorded in the frame before the sampling draw are included.X2W_D3D12_WRITE_TRACE_DRAWS=<n>limits the number of matching draws (default 16, maximum 32).X2W_D3D12_WRITE_TRACE_COMPOSITE=<key>:<index>restricts an address filter to one draw.runtime: dump selected draw targets at one frame(d3d12_targeted_dump.inl)X2W_D3D12_DRAW_DUMP=<frame>:<key>[,<key>...]copies the render targets of the selected translated draws before and after each draw, plus their bound SRVs, in one recording frame.X2W_TRAP_LOGonce the submit fence completes, outside the submit lock. Textures are DX10 DDS files. Buffer SRV ranges are raw files with a small header.runtime: log the submitted state of targeted dump drawskind=stateline: draw arguments, topology, index buffer, viewports and scissors, the bound targets (and whether the dumped target is the bound one) and the fixed-function pipeline state the translated pipeline was built from.docs/startup-runtime.mdgains rows forX2W_D3D12_DRAW_DUMPand the threeX2W_D3D12_WRITE_TRACE*switches (syntax, what is logged, cost when off).This PR is about 1600 lines. If a smaller review unit is preferred, I can split it into a tracer PR followed by a dump PR. The dump includes from the tracer, so it would land second.
Related open work:
d3d12_draw.inlandd3d12_xs_device.cppfor an unrelated depth-view behaviour. A textual rebase may be needed depending on which lands first.d3d12_capture.inl. They report which descriptor was bound; this PR reports who wrote a resource and what one draw saw. They share no environment variable or log prefix with this PR.I found no open PR that adds a write trace or a per-draw target dump.
Validation
Windows, MSVC. GPU tests were run serially.
These tests pass on WARP and on a hardware adapter on this PR (the last commit only adds documentation rows).
tests/startup_resource_write_trace_check.pyis new. It is registered asstartup_resource_write_trace_<backend>and, indumpmode, asstartup_targeted_draw_dump_<backend>. It renders a writer pipeline into a target that a reader pipeline then samples.kind=statelines with the fixture's draw arguments, viewport, scissor, target format and pipeline state, and no budget or cap status.x2w-targeted-dumpline.startup_stream_drawis in the filter because its harness gains the writer fixture. The fixture shaders are written for this test.Checklist
X2W_D3D12_DRAW_DUMPand theX2W_D3D12_WRITE_TRACE*switches are added.@R0Y00 on GitHub · 2026-12-02 05:30 UTC · original · reviewed
Please take the split you proposed. Put resource writer tracing and its output-equivalence/negative controls in the first PR. Stack targeted before/after capture and draw-state logging on top, with its fence, file output and budget controls. That gives the tracer a review path independent of the new GPU copy and readback lifetime. Please keep the corresponding WARP/hardware commands and adapter receipts on each PR.
github-bot referenced this pull request2026-12-02 17:22:37 +00:00
fbc530150cto02fe20a8d1View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.