runtime: validate translated indexed indirect draws on the GPU #2244
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2252"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T07:56:06Z.
Refs #1759. Builds on the native indexed path in #1891 and the translated resource binding work in #2232 and #2236.
Route one translated
DrawIndexedrecord through slot 61 whenX2W_TRANSLATED_INDIRECT_DRAW=1. Start with the existing index-view and argument allocation checks. Keep the guest root, target and graphics-state checks and require complete GPU-backed input ranges. A small compute step validates the argument and index bytes on the recording, then supplies the translated base-vertex constant alongside the indexed argument. A rejected argument produces a zero draw count.The profile accepts a complete vertex stream at slot zero, a single instance starting at zero, and at most 4,096 indices in a triangle list. It refuses a live guest compute binding and shader inputs outside the verified translation profile. Allocator lifetime tracking holds the scratch buffer through execution and reuse. Microsoft HLSL extended command information
Verification
Windows build 26200, Release MSVC 19.51.36244.0, D3D12 debug layer. WARP 10.0.26100.9818 and RTX 4060 Laptop GPU 32.0.16.1656. All 10 selected tests passed.
The source-built shader manually fetches a vertex value from the bound stream. R16/base zero and R32/base three at different argument and index-view offsets paint opposite halves. The check reads all eight pixels and the original GPU argument words and guards. Bad index/vertex ranges, an invalid adjusted index, a short argument record and an omitted writer leave the target clear. With the previous shim, both adapters left pixel (0,0) black (
0xff000000) when red (0xff0000ff) was expected.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:57:40Z.
Review: COMMENTED
Review of head
0b6a07a613(comment only, not an approval).Commands executed locally (Linux):
git diff --stat origin/main...HEAD: 6 files, +385/-48.python3 tests/docs_links_check.py: pass (18 files, 428 links).python3 tests/bidi_controls_check.py: pass.git diff --check origin/main...HEAD: clean.gh pr checks 2252: Linux Python checks pass; the Windows build and the gfx1013 job were still pending when I looked.Not run: the changed tests are Windows/D3D12 only (
startup_indirect_draw_indexed), so I did not build them or mutate the guard on Linux. Please rely on the Windows jobs and the verification block for GPU results. Title is neutral, the diff has no clean-room concerns, and the PR is mergeable.Read-through of
indexed_indirect_guard.handd3d12_draw.inl:args.xlimited to 3..4096 and divisible by 3, start-instance zero, one instance, and the index range inside the view.verticesis also right.P1: none found.
P2:
d3d12_draw.inl(validate_indexed_arguments): if the argument buffer was tracked as COMMON before validation, it is not transitioned back (argument_previous != COMMONguard). It stays in NON_PIXEL_SHADER_RESOURCE for later guest use. Please confirm the pass state tracker handles this, or restore it to COMMON. A test that reuses the same buffer for a later copy or write would show it.indexed_verticesstaysUINT_MAXwhen the translation has no slot-zero vertex-stream SRV. The guard then does not bound adjusted indices by any vertex extent. It is safe only if such a translation cannot fetch vertices. Please state that invariant or require a stream whenever the base-vertex entry is present.Nits:
docs/experiments.mdctest regex liststranslated_indexed|translated_draw|draw_indexed. The PR body also includescopy_provenance(_off)?, so the two commands differ.compute.device != device). A one-line comment on that would help readers.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T08:30:53Z.
Review: COMMENTED
Re-review of head
ab83bffd4a(comment only, not an approval). Previous review was on0b6a07a6.Commands executed locally (Linux):
git diff --stat origin/main...HEAD: 6 files, +385/-48.python3 tests/docs_links_check.py: pass (18 files, 428 links).python3 tests/bidi_controls_check.py: pass (1541 files).git diff --check origin/main...HEAD: clean.gh pr checks 2252: Linux Python checks and gfx1013 fixtures pass; "Build and test on Windows" was still pending, the /O2 job skipped.Not run: the changed test (
startup_indirect_draw_indexed) and the guard (HLSL inindexed_indirect_guard.h) only run on Windows/D3D12, so I did not mutate the guard on Linux. Please rely on the Windows job for GPU results. Title is neutral, no clean-room concerns, PR is mergeable.Previous P2 items:
require_statestill records it inpass.states, andrelease_targets(d3d12_xs_device.cpp, around line 2188) transitions every tracked resource back to COMMON at list end. So theargument_previous != COMMONguard ind3d12_draw.inl:1573is correct: nothing is left behind.indexed_verticesstayingUINT_MAX: PARTLY OPEN. With a source-1 SRV, a missing slot-zero stream now refuses the draw (d3d12_draw.inl:1879), and otherwise the extent isSizeInBytes / StrideInBytes(line 1874). The only remaining unbounded path is a translation with no source-1 SRV, which cannot fetch vertices, so I think it is safe. No comment states that invariant yet. See nit.P1: none found.
P2: none new.
Nits:
d3d12_draw.inl:1751sayingUINT_MAXis used only when the translation has no vertex-stream SRV.compute.device != devicereturns null at line 1508, which becomes a refusal). A one-line comment would help readers.docs/experiments.mdmatches the one in the PR body (copy_provenance(_off)?was missing earlier); I did not re-diff it.AI-assisted; commands listed were executed locally.