GPU: bind large backed views in translated indirect draws #2469
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2477"
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-25T17:54:29Z.
Bind a translated indirect draw's full raw SRV over existing GPU storage when the range fits its backing and the D3D12 raw element count. The old 16 MiB guard rejected the descriptor before checking the resource. The change keeps the ownership, offset, resource state and copy provenance checks. It adds no upload or memory copy.
The source-built fixture writes two different colors 16 bytes apart, then reads the last DWORD through a nonzero-offset view. Shortening the view by one element leaves the sentinel in GPU memory and makes the shader read zero. This control detects a widened or misbased view.
Verified on
fe10936e, Windows 11 build 26200.9974, RTX 4060 Laptop (32.0.16.1656) and Microsoft WARP, D3D12 debug layer enabled on both.8 tests passed, 0 skips. On each backend the complete view produced 8/8 red pixels and the shortened view 0/8 non-clear pixels, with the argument guard words intact. On WARP the same fixture against the former 16 MiB limit returned black in all eight pixels of the positive case.
Refs #874.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:32:28Z.
Review: COMMENTED
Code review of head
fe10936e38ceaa3f648098ad866d76eb17ee55b5. Comment only; I did not run Windows or the game.Checked in the diff
src/startup_stubs/d3d12_draw.inl(indirect_table_buffer): the fixed 16 MiB cap is replaced bybytes / 4 > 2^D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP(2^27 raw elements, 512 MiB). Thebytes % 4and!byteschecks stay.bytesis built from a 14-bit stride times a 32-bit count inu64, so it cannot overflow.offset > desc.Width || bytes > desc.Width - offsetis refused), and the offset alignment, owner, device,initial_state,DENY_SHADER_RESOURCEand copied-range provenance checks are untouched. The upload-ring branch also still validates the range throughlist_upload_range. Nothing is copied.d3d12_draw.inlaround lines 2067 and 2071: the indexed vertex-stream case and the table-descriptor case) get the same relaxed limit. Both still go through the same backing check.16u << 20clamp near line 2121 is on a different path (descriptor binding forbuffer_view, not the indirect translated draw). It is not touched here, so a title that reads a large buffer through that path still gets the old clamp. Fine for this slice, but worth knowing.startup_indirect_translated_draw_*suite is extended (not a new suite). The fixture builds a buffer of 0x1000020 bytes, writes green at +0x100000c and red at +0x100001c, and reads the last DWORD. The full view must give red. A view one element short must hit the existinginsufficient_table_rangerefusal. This is a real D3D12 readback checked against an expected colour, with a negative control that catches a widened or misbased view. TheTableSampleenum change is a mechanical refactor of the helper's bool flag.docs/experiments.mddescribes the new behaviour and the control..github, launcher or hook changes.Commands run (Linux, in a worktree of the exact head)
git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: passed (19 files, 466 links)python3 tests/bidi_controls_check.py: passedWindows / CI results, with the SHA each one covers
fe10936e./O2job was skipped.Notes for @R0Y00
No blocking findings from the code and test review.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T19:01:33Z.
Reading-only review — I cannot build on this host (the full CMake build stops in DXC with
unable to create compilation: AccessDeniedon unrelated targets), so nothing below is a run result.The constant is the right one, and the arithmetic is safe
D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXPis 27, so the bound is 2^27 R32 elements. Theu64{1} << 27shift is well insideu64, andbytes / 4cannot overflow before the comparison, so the arithmetic is fine. Dividing by a literal 4 is correct because the view this guards is the raw R32 one —d3d12_draw.inl:1117setsDXGI_FORMAT_R32_TYPELESSwithD3D12_BUFFER_SRV_FLAG_RAW, andFirstElement = offset / 4, so bytes-per-element 4 is the same unit the view uses.Raise from 16 MiB to 512 MiB is the intended change and the check is now the API limit rather than an arbitrary ceiling. Good.
The part I would look at before merging
16 MiB is used in two other places in the same file and one in the capture code, and it is still applied unconditionally:
Line 2121 sits on the path that computes
bytesfor a hardware buffer descriptor before this function's new check sees it (thesrv.source == 0 && words[0] != view_token_magic && entryarm). So a view that this PR now admits at, say, 64 MiB can still arrive atbuffer_view()withNumElementscomputed from a range that was silently clamped to 16 MiB. The failure mode changes from "indirect_table_bufferreturns{}" to "a raw SRV whoseNumElementscovers a quarter of the resource" — which is a wrong result rather than a refusal.I am not claiming that is what happens for the fixture this PR adds: its buffer is presumably well under 16 MiB, so the clamp never bites and the test passes either way. The question is what the 512 MiB admission is for. If it exists to bind large backed views, the clamp at 2121 has to move with it, or the two constants will disagree wherever the clamp applies.
Worth checking whether line 2121's arm can even reach
indirect_table_buffer— if the token magic path is the only one that gets here, the clamp is off the path and this is a non-issue. That distinction is exactly what I cannot settle without building.What the test changes tell me
tests/startup_indirect_draw_indexed.cppgrows by 50 lines with 12 removed, so a case was reworked rather than just added. If the new case binds a buffer above 16 MiB and asserts the draw reads the right words, it would also demonstrate which of the two constants wins — that is the assertion I would look for, and if it is present, please say so and this concern is answered.Docs
docs/experiments.mdgains 6 lines describing the larger backing. If the 16 MiB clamp at 2121 stays, the doc should not read as "any size up to the API limit binds correctly".AI-assisted; reviewed by reading only, no build or run on this host.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T20:20:08Z.
Independent Windows Release run on
fe10936e: 17/17 selected indirect draw and refusal CTests passed, zero skips, on WARP and RTX 4060 Laptop. The >16 MiB draw returned 8/8 expected pixels through the complete nonzero-offset view and 0/8 after shortening the view, with guard words intact on both. The result covers the existing backed-view route inindirect_table_buffer; any subsequent use of the separate directbuffer_viewclamp remains outside this test. This is ready for an independent maintainer's merge review on the tested head. The #870 matched replay still has its own acceptance.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:17:23Z.
Conflict note for
fe10936e(270 commits behind main,CONFLICTING).The only textual conflict is the
TranslatedDrawFixtureconstructor intests/startup_indirect_draw_indexed.cpp. Main addedbool allow_rt = falseafterreplay. This PR addedUINT committed_bytes = 64. Resolution: keep both,..., bool replay = false, bool allow_rt = false, UINT committed_bytes = 64. Then the large-view call site must passfalseforallow_rt:TranslatedDrawFixture large(guest.Get(), 0, device.Get(), short_view, false, false, false, 0x1000020);. Without that edit the value0x1000020silently binds toallow_rt.I did not push to the branch (maintainer edits are off). Merged tree checked locally, nothing pushed:
x2w_pipe.py win2025 2477 --patch <merged-tree diff> --targets startup_indirect_draw_indexed --regex '^startup_indirect_'_hardwarecapability skips on the VM, reported as skips, not passes). The WARP large-view cases are in the passed set.Please merge main into the branch (or tell me to). After that the PR needs a fresh
merge_checkand review on the new head.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T07:24:38Z.
Updated the branch to
f1cf4b46after testing it against main atf1a8db63. It keeps the newer compute diagnostic and its 16 MiB limit, and keeps the cap on opening a new address alias. A translated draw with an existing GPU-backed range can now use the complete raw SRV.Windows Release, Windows 11 build 26200, serial WARP and RTX 4060 Laptop, debug layer enabled. All 20 indirect draw, provenance/refusal and compute input CTests passed, zero skips. On each adapter the nonzero-offset view beyond 16 MiB rendered 8/8 pixels. Shortening the view rendered 0/8. Guard words stayed intact. Command: ctest --preset release --no-tests=error -j 1 -R "^(startup_indirect_(translated_(draw|indexed|indexed_upload|indexed_rect|indexed_alias|indexed_alias_off|targets|refusal_census)|other_refusal_census)(warp|hardware)|startup_compute_dispatch_input(warp|hardware))$" -V.
This is a source-built draw result. The original-executable matched replay remains separate. Ready for independent review on this head.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T09:51:32Z.
Review: COMMENTED
Review of head
f1cf4b46(20 commits behind main, no conflicts).Code:
indirect_table_buffernow takes alimitargument. The translated draw path uses the D3D12 raw-view limit. The compute path passes16u << 20explicitly, so its behavior is unchanged. Address-alias opening stays capped at 16 MiB. The ownership, offset, state and copy provenance checks are untouched. The refusal text differs per limit.Test:
translated_buffer_tail_pixelreads the last DWORD of a view 16 bytes beyond 16 MiB. The shortened-view control must read zero, so a widened or misbased view fails it. The fixture ids and manifest choice stay separate per sample kind.Checked on Linux:
git diff --check,tests/docs_links_check.py,tests/bidi_controls_check.pyall pass. CI on the head is green. I did not run a code mutation myself (the fixture is Windows-only). The built-in shortened-view control is the negative control.This is a source-built draw result. It makes no startup claim, so I found no blocker.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
f1cf4b4665d4a8da2bdc18ea6b713b2444e1d962:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_indirect_draw_indexed -- -j 2):28.35s(configure1.84s)ctest --preset dev -R '^(startup_indirect_(translated_(draw|indexed|indexed_upload|indexed_rect|indexed_alias|indexed_alias_off|targets|refusal_census)|copy_provenance(_off)?|other_refusal_census)_warp|startup_compute_dispatch_input_warp)$' --parallel 6 --no-tests=error --output-on-failure): 12/12 passed (1.07s:startup_indirect_copy_provenance_off_warp0.20s,startup_indirect_translated_indexed_warp0.19s,startup_indirect_copy_provenance_warp0.20s,startup_indirect_translated_draw_warp0.23s,startup_indirect_translated_indexed_rect_warp0.20s,startup_indirect_translated_refusal_census_warp0.15s,startup_indirect_translated_targets_warp0.15s,startup_indirect_other_refusal_census_warp0.14s,startup_indirect_translated_indexed_alias_warp0.14s,startup_indirect_translated_indexed_upload_warp0.15s,startup_indirect_translated_indexed_alias_off_warp0.07s,startup_compute_dispatch_input_warp0.95s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_indirect_draw_indexed -- -j 2):54.67s(configure1.84s)ctest --preset release -R '^(startup_indirect_(translated_(draw|indexed|indexed_upload|indexed_rect|indexed_alias|indexed_alias_off|targets|refusal_census)|copy_provenance(_off)?|other_refusal_census)_warp|startup_compute_dispatch_input_warp)$' --parallel 6 --no-tests=error --output-on-failure): 12/12 passed (1.10s:startup_indirect_translated_indexed_warp0.18s,startup_indirect_translated_indexed_rect_warp0.19s,startup_indirect_translated_draw_warp0.21s,startup_indirect_copy_provenance_off_warp0.20s,startup_indirect_copy_provenance_warp0.23s,startup_indirect_translated_targets_warp0.11s,startup_indirect_translated_refusal_census_warp0.11s,startup_indirect_translated_indexed_alias_warp0.12s,startup_indirect_other_refusal_census_warp0.10s,startup_indirect_translated_indexed_upload_warp0.12s,startup_indirect_translated_indexed_alias_off_warp0.06s,startup_compute_dispatch_input_warp0.99s)sccache: 2/10 hits; wall93.2sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T09:51:32Z.
Review of head
f1cf4b46(20 commits behind main, no conflicts).Code:
indirect_table_buffernow takes alimitargument. The translated draw path uses the D3D12 raw-view limit. The compute path passes16u << 20explicitly, so its behavior is unchanged. Address-alias opening stays capped at 16 MiB. The ownership, offset, state and copy provenance checks are untouched. The refusal text differs per limit.Test:
translated_buffer_tail_pixelreads the last DWORD of a view 16 bytes beyond 16 MiB. The shortened-view control must read zero, so a widened or misbased view fails it. The fixture ids and manifest choice stay separate per sample kind.Checked on Linux:
git diff --check,tests/docs_links_check.py,tests/bidi_controls_check.pyall pass. CI on the head is green. I did not run a code mutation myself (the fixture is Windows-only). The built-in shortened-view control is the negative control.This is a source-built draw result. It makes no startup claim, so I found no blocker.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
f1cf4b4665d4a8da2bdc18ea6b713b2444e1d962:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_indirect_draw_indexed -- -j 2):28.35s(configure1.84s)ctest --preset dev -R '^(startup_indirect_(translated_(draw|indexed|indexed_upload|indexed_rect|indexed_alias|indexed_alias_off|targets|refusal_census)|copy_provenance(_off)?|other_refusal_census)_warp|startup_compute_dispatch_input_warp)$' --parallel 6 --no-tests=error --output-on-failure): 12/12 passed (1.07s:startup_indirect_copy_provenance_off_warp0.20s,startup_indirect_translated_indexed_warp0.19s,startup_indirect_copy_provenance_warp0.20s,startup_indirect_translated_draw_warp0.23s,startup_indirect_translated_indexed_rect_warp0.20s,startup_indirect_translated_refusal_census_warp0.15s,startup_indirect_translated_targets_warp0.15s,startup_indirect_other_refusal_census_warp0.14s,startup_indirect_translated_indexed_alias_warp0.14s,startup_indirect_translated_indexed_upload_warp0.15s,startup_indirect_translated_indexed_alias_off_warp0.07s,startup_compute_dispatch_input_warp0.95s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_indirect_draw_indexed -- -j 2):54.67s(configure1.84s)ctest --preset release -R '^(startup_indirect_(translated_(draw|indexed|indexed_upload|indexed_rect|indexed_alias|indexed_alias_off|targets|refusal_census)|copy_provenance(_off)?|other_refusal_census)_warp|startup_compute_dispatch_input_warp)$' --parallel 6 --no-tests=error --output-on-failure): 12/12 passed (1.10s:startup_indirect_translated_indexed_warp0.18s,startup_indirect_translated_indexed_rect_warp0.19s,startup_indirect_translated_draw_warp0.21s,startup_indirect_copy_provenance_off_warp0.20s,startup_indirect_copy_provenance_warp0.23s,startup_indirect_translated_targets_warp0.11s,startup_indirect_translated_refusal_census_warp0.11s,startup_indirect_translated_indexed_alias_warp0.12s,startup_indirect_other_refusal_census_warp0.10s,startup_indirect_translated_indexed_upload_warp0.12s,startup_indirect_translated_indexed_alias_off_warp0.06s,startup_compute_dispatch_input_warp0.99s)sccache: 2/10 hits; wall93.2sAI-assisted; commands listed were executed locally.