startup: direct indexed draws ignore index-buffer writes made before submission #2714
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#2714
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@chasegrindy on GitHub · 2026-11-26 03:13 UTC · original
Commit or build
546d881be2e14097fd086c52d711a3173d605471(main, x64 Release). Only the test fixture was patched; the runtime is unchanged.Reproduction
The fixture registers a 256-byte aliased buffer via slot 133, binds three R16 indices via slot 47, then records a direct indexed draw via slot 13. The vertex shader maps
0,1,2to a full-coverage triangle and3,4,5to a triangle wholly beyondx > w. The late cases rewrite those same six bytes after recording the draw but beforeExecuteCommandLists. Nothing is submitted while the CPU writes. A fence precedes the full 8×4 RGBA8 readback.Save the three source files below in the checkout root. Adjust
$sdkBinto the x64 binary directory of your installed SDK if needed. The runner uses WARP and explicitly selects the RX 7900 XTX for its hardware run.Expected behavior
For this sequence, the draw should read the final contents of the live index buffer. With the final indices
0,1,2, all 32 pixels should be red. With3,4,5, all 32 should retain the blue clear. Microsoft documents the pre-submit write ordering for CPU-accessible resources inID3D12Resource::Map.Observed behavior
The draw uses the indices present when it was recorded. The slot-133 log confirms an alias and the direct indexed draw still logs
drawn. Three fresh-process runs per case and adapter: all 12 unchanged-input controls match; all 12 late-write draws mismatch 32/32 pixels. No skips. The reproducer exits 1 for these pixel mismatches.The direct indexed branch takes a
frame_copyduring recording and binds the upload-ring slice instead of the live index resource. This can leave a target unchanged despite a recorded draw. Refs #870 for that symptom only: the public capture does not establish that its 2560×1440 producer used this index-write sequence.Environment
Windows 11 26300.9974, VS 2022 17.14 / MSVC 19.44.35229.0, Windows SDK 10.0.26100.0. RX 7900 XTX driver
32.0.32015.7029and Microsoft Basic Render Driver10.0.26100.9818. D3D12 debug layer enabled on both.Checklist
AI-assisted (Hermes Agent / OpenAI Codex). Measurements are from local GPU readbacks.
fixture.diff
index_probe_vs.hlsl
reproduce.py
@triggered02 on GitHub · 2026-11-26 03:38 UTC · original
This reproduces as a real semantics defect, not a fixture artifact: the direct indexed route snapshots the guest index bytes at recording time, while D3D12 reads the index buffer at execution. list_draw_indexed (src/startup_stubs/d3d12_draw.inl:2732) goes through draw_translated(...), and the translated index view resolves the guest BufferLocation into a desktop range when the draw is recorded � the indirect route shows the same resolution shape in d3d12_xs_device.cpp around the list_upload_range(self, view.BufferLocation, view.SizeInBytes) branch, where a guest-owned index range becomes a recording-time upload. A CPU write to those six bytes between DrawIndexedInstanced and ExecuteCommandLists is legal, and the upload is already stale by then.
The fix shape is to keep the guest address and range in the recording and resolve the index bytes at ExecuteCommandLists (or re-upload the range immediately before the recorded draw is executed), for both the direct and indirect translated routes. That is a recording/execute split in the translated draw path, not a one-line change, so I am not claiming a fix here.
What would make this landable: your fixture as a source-built CTest in ests/ (the ixture.diff + runner you pasted are the right shape) with the late-write case and the current early-read case as a negative control, so the failure is pinned before the path is changed. If you can attach the fixture diff as a file (not game data � it is synthetic), I will take it from there.
@R0Y00 on GitHub · 2026-11-26 03:51 UTC · original
I independently reproduced both late-write failures on WARP and RTX 4060 Laptop. PR #2724 integrates the source-built fixture and a narrow fix: retain an existing live placed alias when the drawn index interval is proven and the shader does not need sliced vertex streams. All five cases now match 32/32 pixels per backend. The snapshot-dependent path remains open under this issue. The actual executable's relevant index writer still needs tracing.