startup: slot 70 structured buffer views at sub-allocated addresses take an exact-start upload copy #2833
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2841"
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 tedin7 on 2026-11-26T13:01:58Z.
Part of #870
Fixes #2839
What this unblocks: slot 70 buffer memory SRVs for structured views at sub-allocated addresses (an address that is not a whole number of elements past its 64 KiB page) publish instead of ending in
buffer_unavailable.What changed
unplaced_view_needs_exact_startinsrc/startup_stubs/memory_srv_buffer.h.unplaced_memory_bufferinsrc/startup_stubs/d3d12_memory_srv.inltakes the element size. When the 64 KiB page start cannot name the address as a whole number of elements, it backs the view with an upload copy that starts at the address (span = the view span), in its own cache entries, with no existing-heap wrap. The page-coverage and nearby-owner checks still run on the page.startup_memory_srv_buffer_check(new shapes,--mutate exact-startregistered in the CMake mutant list) andstartup_address_buffer_srv(an unplaced structured view with stride 12 at page offset 0x104 is read through slot 70).Why it is correct
A buffer SRV addresses whole elements from its base:
(address - base)must be a multiple of the element size to becomeFirstElement(D3D12D3D12_BUFFER_SRV, FirstElement / StructureByteStride). With the page start as base that fails for most sub-allocated addresses. Starting the copy at the address makes the offset 0.Source: Microsoft D3D12 documentation,
D3D12_BUFFER_SRV(FirstElement, StructureByteStride).What stays refused
Overlap with a known resource, pages the title does not own, views above the 256 MiB span limit, raw views not 16-byte aligned (unchanged).
Notes
The exact-start copy is a snapshot refreshed on every hit, like the existing upload fallback.
Verification
x86_64-w64-mingw32-g++ -std=c++17 -Isrc tests/startup_memory_srv_buffer_check.cppthen run under wine: pass;--mutate exact-start: fails (rc 1).tests/startup_address_srv.cpp: ok.Real-hardware testing: @Makto94 - thanks for the help.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T13:22:26Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
14edff2aa2ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:40:58Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:41:03Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T13:11:45Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
14edff2ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:40:48Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
da2a38f5788e8f0f9fd3351dfbf336a977a1cdd9:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer -- -j 2):42.77s(configure3.42s)ctest --preset dev -R 'startup_memory_srv_buffer|startup_address_buffer_srv|startup_address_srv' --parallel 3 --no-tests=error --output-on-failure): 13/13 passed (2.26s:startup_address_buffer_srv_warp1.02s,startup_address_buffer_srv_hardware1.02s,startup_memory_srv_buffer0.02s,startup_address_srv_warp1.06s,startup_memory_srv_buffer_height_control0.02s,startup_memory_srv_buffer_unplaced-heap-limit_control0.02s,startup_memory_srv_buffer_first-32_control0.02s,startup_memory_srv_buffer_unplaced-extent_control0.02s,startup_memory_srv_buffer_unplaced-covers_control0.02s,startup_memory_srv_buffer_exact-fit_control0.02s,startup_memory_srv_buffer_exact-start_control0.02s,startup_memory_srv_buffer_raw-exact_control0.02s,startup_address_srv_hardware0.98s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer -- -j 2):89.22s(configure2.76s)ctest --preset release -R 'startup_memory_srv_buffer|startup_address_buffer_srv|startup_address_srv' --parallel 3 --no-tests=error --output-on-failure): 13/13 passed (1.76s:startup_address_buffer_srv_warp0.83s,startup_address_buffer_srv_hardware0.83s,startup_memory_srv_buffer_height_control0.01s,startup_memory_srv_buffer0.01s,startup_memory_srv_buffer_exact-fit_control0.01s,startup_memory_srv_buffer_first-32_control0.01s,startup_memory_srv_buffer_unplaced-covers_control0.02s,startup_memory_srv_buffer_unplaced-heap-limit_control0.01s,startup_memory_srv_buffer_unplaced-extent_control0.01s,startup_memory_srv_buffer_exact-start_control0.01s,startup_address_srv_warp0.97s,startup_memory_srv_buffer_raw-exact_control0.01s,startup_address_srv_hardware0.75s)sccache: 148/171 hits; wall146.8sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T13:22:26Z.
Code review location:
src/startup_stubs/d3d12_memory_srv.inl; line 319For successive views into the same unplaced page, the shortened backing becomes an exclusive owner through
note_resource. For example, publish one stride-12 element atpage + 0x104, then request a 16-byte raw view atpage + 0x100:existing_memory_buffercannot cover the latter with the 12-byte copy, andaddress_resource_overlaprejects allocating another backing, leaving the previous descriptor in place. The previous page-sized backing allowed that raw view. Distinguish these synthetic copies from guest-owned resources in the overlap checks so overlapping or enlarged views can obtain compatible backings.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T13:22:26Z.
Code review location:
src/startup_stubs/d3d12_memory_srv.inl; line 316For an unplaced raw view at
page + 1withFirstElement == 0,elem_bytesis 4, so this enables the exact-start copy.resolve_buffer_srv_descthen sees offset zero and passes its raw 16-byte-alignment check, publishing a view that the previous page-based path rejected and overwriting the destination instead of leaving it unchanged. The existing unaligned fixture uses a placed buffer and does not exercise this path. Restrict rebasing to structured/typed views, or enforce the original raw alignment before changing the base.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:40:58Z.
Code review location:
src/startup_stubs/d3d12_memory_srv.inl; line 316Fixed in
da2a38f57. The exact-start copy is now limited to structured and typed views: a raw view keeps the page base, so its 16-byte alignment check still applies and a raw view atpage + 1is refused and keeps the previous descriptor. Test:startup_address_buffer_srv_warphas a new column for an unplaced raw view at page + 1 (expects 201 kept), plus a unit checkraw view keeps the page basewith theraw-exactmutation control instartup_memory_srv_buffer. Win2025 dev+release: 13/13 each (receipt comment on this PR).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:41:03Z.
Code review location:
src/startup_stubs/d3d12_memory_srv.inl; line 319Fixed in
da2a38f57. The upload copy made for an exact-start view is now marked as a synthetic backing:address_resource_overlapandexisting_memory_bufferskip it, so a later overlapping or larger view (for example a raw 16-byte view atpage + 0x100after a stride-12 view atpage + 0x104) gets its own compatible backing instead of being refused. Test:startup_address_buffer_srv_warppublishes that pair on a second page and expects the shader to read 55 (before the change the raw view was refused and the previous descriptor stayed). Win2025 dev+release: 13/13 each (receipt comment on this PR).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T16:07:01Z.
Hardware and WARP result for head
da2a38f5788e8f0f9fd3351dfbf336a977a1cdd9: all pass. Part of #870.Environment: Windows 11 25H2 (26200), MSVC 19.42,
devpreset, NVIDIA GeForce RTX 4070 Ti, driver 621.35 (32.0.16.2135). Tests run serially, one ctest process.Command
Result (measured): 36/36 passed, exit code 0.
startup_memory_srv_bufferand its 8 controls, including the newexact-startandraw-exact.startup_address_buffer_srv_warpandstartup_address_buffer_srv_hardware(the stride-12 view at page offset 0x104 that the PR adds).startup_stream_draw_warpandstartup_stream_draw_hardware(the PR editstests/startup_stream_draw.cpp).startup_address_srv,startup_memory_srv_diagandstartup_address_volume_srv(WARP and hardware),dxr_slot70_as(WARP and hardware),startup_memory_srv_{census,report,as,volume}with controls,startup_placed_buffer_rangewith controls.What this shows: the new stride-12 case and the changed stream-draw test pass on an NVIDIA adapter as well as WARP, and nothing else in the slot-70 group regressed.
What this does not show: I did not revert the fix to check that the hardware test fails without it. The description reports that mutant on WARP and hardware. I did not run a game or title.
AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T19:40:43Z.
Review: CHANGES_REQUESTED
Independently reviewed
da2a38f5integrated overmain0f3e8248(tree2b7779b9, clean merge).The PR's own suite passes. I built
startup_stream_consumer,d3d12_xs_shimandstartup_memory_srv_buffer_checkindev, then ran:ctest --test-dir out/build/dev --no-tests=error -j 1 -R '^(startup_memory_srv_buffer.*|startup_address_buffer_srv_(warp|hardware)|startup_address_srv_(warp|hardware))$'13/13 passed. That includes the new
exact-startandraw-exactcontrols, on WARP and hardware. Both earlier Codex threads are resolved, and their two cases behave as described.Finding: the exact-start copy is only used when it comes first on its page. The fixture publishes the structured view at page + 0x104 first and the raw view at page + 0x100 after it. With the two calls the other way round, the structured view is refused.
draw_address_buffer_srvs, add one line just before the existingstructured.view.Buffer.FirstElement = 0;of the page-offset case: Then runctest --test-dir out/build/dev --no-tests=error -j 1 --output-on-failure -R '^startup_address_buffer_srv_warp$'.As I read it:
exact_copy.existing_memory_bufferreturns that copy.resolve_buffer_srv_descthen fails on0x104 % 12, so the view is refused beforeunplaced_memory_bufferruns. If it did run,address_resource_overlapwould also count the page copy as an owner.The same happens after a raw view that is itself refused. I tested a raw view at page + 1 followed by a stride-16 view at page + 0x10C: the stride-16 view is refused. Without the raw view before it, it publishes from its own exact copy and reads the expected value.
This is not a regression against
main, where these views are refused in either order. But the outcome now depends on call order within a page. A title that touches a page through a raw or aligned view first gets the old refusal.Suggested direction (unconfirmed):
resolve_buffer_srv_descfails on such a copy, fall through tounplaced_memory_buffer, so the exact path can still run.Verdict: changes requested on
da2a38f5, for the order dependence only.Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; WARP 10.0.26100.9818; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; debug layer on.
CI:
Build and test on Windowspasses onda2a38f5. Both review threads are resolved.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T21:28:14Z.
Thanks for the repro. Pushed
c02f9dd45: when a cached page-base copy cannot resolve a slot 70 view, the path now retries with an exact-start copy, so the result no longer depends on which view came first on the page. Guest-owned resource checks still apply. The fixture gains the raw-view-first order (stride 12 reads 201) and the raw page+1 then stride-16 order (reads the same as without the raw view).Not yet run on Windows:
startup_address_buffer_srv_warp,startup_address_buffer_srv_hardware,startup_memory_srv_buffer*.Commands run locally:
git diff --check,python3 -B tests/docs_links_check.py,cmake -S . -B <tmp> -DDXC_EXECUTABLE=/bin/true,public_guard.py.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T21:47:19Z.
Verification: head
c02f9dd45after the main merge and the latest fixes.Environment: Windows Server 2025 (build 26100), MSVC 14.44, D3D12 WARP and the hardware adapter, dev and release legs in parallel.
Commands (the same selection in both legs):
Result: 11/11 passed in both legs.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:27:13Z.
Review: APPROVED
Re-reviewed
c02f9dd4merged over currentmainf6206217. The merge is clean andgit diff --cached --checkis clean.The finding from my review of
da2a38f5is fixed. The exact-start copy no longer depends on which view comes first on its page. Two changes do this:existing_memory_bufferreturns a synthetic backing (unplaced_srv_backing) thatresolve_buffer_srv_desccan't use,device_memory_srvnow asksunplaced_memory_bufferfor an exact-start copy.address_resource_overlapnow skips every synthetic backing, not only the exact ones. A page-base copy no longer counts as a guest-owned owner.The fixture has both orders I reported, on fresh pages:
What I ran. I built
d3d12_xs_device_obj,d3d12_xs_shim,startup_memory_srv_buffer_checkandstartup_stream_consumerindevandrelease, then ran12/12 and 3/3 pass in both presets, with no skips. The 12 include
startup_memory_srv_bufferwith all eight_controls.Mutants in
src/startup_stubs/d3d12_memory_srv.inl. For each, I rebuilt indevand ran the 12 non-hardware tests:if (!buffer), theda2a38f5behaviour)startup_address_buffer_srv_warp)address_resource_overlapskips onlyexact_copyagainstartup_address_buffer_srv_warp)unplaced_srv_backingset only on exact copiesstartup_address_buffer_srv_warp)!buffer || !resolved)Restored and rebuilt afterwards;
git diff --quietis clean.Non-blocking. The surviving mutant looks equivalent for guest-owned resources.
unplaced_memory_bufferbegins withaddress_resource_overlap, which counts such a resource and returnsnullptr, so the view is still refused. Theunplaced_srv_backingguard is a second layer that no test reaches on its own. That's fine to keep; a one-line comment saying so would help the next reader.Verdict: approve on
c02f9dd4.Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; D3D12 WARP; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on for the hardware runs.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass onc02f9dd4.This reply was AI-assisted.