Skip to content

d3d12: Xbox device slots 70/71 write buffer views from a buffer description and its address (RT-TITLE-BUFFER-VIEWS) - #1160

Open
iFeyz wants to merge 2 commits into
ProjectLeonida:mainfrom
iFeyz:feat/title-buffer-views
Open

iFeyz wants to merge 2 commits into
ProjectLeonida:mainfrom
iFeyz:feat/title-buffer-views

Conversation

@iFeyz

@iFeyz iFeyz commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-TITLE-BUFFER-VIEWS (#14 (comment))

Depends on: #1079 (this branch is built on it; its last commit is this pull request)

What and why

@DadaCap measured that Xbox device slots 70 (SRV) and 71 (UAV) also make buffer views, and that the missing ones are a cause of the world-phase GPU fault: with the null descriptor, the instance-culling dispatches read leftover memory as a V# and the device is lost (issue #14, comment 7140195321). #1079 resolves the texture half of the same two slots; this is the buffer half, on top of it.

  • runtime/shims/d3d12_xs_device.cpp: a buffer description now reaches the placed-view handler too, not only TEXTURE1D..3D.
  • runtime/shims/d3d12_vulkan_device.cpp, write_placed_view: a buffer description writes the V# of a buffer view of the description's Width bytes at the address (dwords 10–11 of the view words). The address is taken as a GPU address, as CreateConstantBufferView takes BufferLocation. The V# is built by the same code as CreateShaderResourceView / CreateUnorderedAccessView for a buffer resource, factored out as write_buffer_srv_at / write_buffer_uav_at (address and size in, no resource object), so raw, structured and typed views and their bounds checks are the PC methods' and are not copied.
    • A view those refuse gives the caller's null descriptor, as before.
    • So does a UAV with a counter offset, since the slot names no counter resource.
    • The retail title's flags word (0x20004) needs no masking: only ALLOW_UNORDERED_ACCESS (0x4) is read.
  • Docs: docs/d3d12_vulkan.md, next to d3d12: resolve views of live placed textures (RT-TITLE-TEXTURE-VIEWS) #1079's paragraph on slots 70/71.

Not measured here: whether the title's addresses for these buffers are ones the layer can read on every stack. They are used the way a CBV's address already is.

When stacked with DadaCap's boot-prototype (or anything that adds arena_va()): the slot's address belongs to the same family as a CBV's or a vertex view's there, so translate it with arena_va() once in write_placed_view before the two helpers are called. Taking write_buffer_srv_at whole from this PR drops that call (DesertGamer's review, which re-ran with it kept).

Retail result so far (DesertGamer, RTX 5070, with arena_va() kept): the instance-culling device loss is still there at 83.4 s, so the null buffer views were at most one of its causes.

Tested

  • d3d12_set0_compute_test (RX 9070 XT): through the real slot 70/71 entry points, with a buffer description carrying the retail flags 0x20004, six views give exactly the descriptor the PC method writes for the same buffer: typed R32_UINT, structured stride 16 and 32 (UAVs); raw, structured, typed (SRVs). Three controls give the null descriptor: past the buffer's end, a counter offset, and a UAV of a description without ALLOW_UNORDERED_ACCESS.
  • Rebased on d3d12: resolve views of live placed textures (RT-TITLE-TEXTURE-VIEWS) #1079's current head (99176da10): xs_proxy_mock* (6), d3d12_set0_compute, d3d12_placed_texture_uav_off: 8 of 8 pass, xs_proxy_mock_env_slots_invalid included now that d3d12: resolve views of live placed textures (RT-TITLE-TEXTURE-VIEWS) #1079 routes its example away from slot 71.
  • Runtime (Windows 11, MSVC 2022 Build Tools, RelWithDebInfo, full build): ctest 303 of 308 pass. The 5 failures fail the same way without this commit: xs_proxy_mock_env_slots_invalid on d3d12: resolve views of live placed textures (RT-TITLE-TEXTURE-VIEWS) #1079's previous head (passes on the current one, above), and the 4 already on main here (d3d12_clear, d3d12_execute_indirect_validation, d3d12_texture_tiles, d3d12_pipeline_library_host, reported in Coordinating who works on what #14).
  • tests/test_docs_links.py, scripts/check_no_game_data.py on every changed file.

GPUs tested: AMD Radeon RX 9070 XT, AMD Adrenalin 26.11.2 (Vulkan 1.4.359), Windows 11

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified. Vital breakthrough for title instance culling and crash resolution (RT-TITLE-BUFFER-VIEWS, Issue #14). Extends Xbox device slots 70 (SRV) and 71 (UAV) to construct raw, structured, and typed buffer views from a buffer description Width and GPU address via write_buffer_srv_at / write_buffer_uav_at. Prevents device-loss crash on instance-culling dispatches. Verified in runtime/test/d3d12_set0_compute_test.cpp and xs_proxy_mock_test.cpp. 100% clean-room.

@madhyn

madhyn commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Tested d04e78e2b on Arch Linux + Wine 11.22 + NVIDIA RTX 3060 Ti (clang-cl + xwin cross-build):

ctest --test-dir runtime/build/win -R "^(xs_proxy_mock.*|d3d12_set0_compute|d3d12_placed_texture_uav_off|d3d12_title_buffer.*)$" --output-on-failure:

  • d3d12_set0_compute: Passed (5.53 s)
  • d3d12_placed_texture_uav_off: Passed (5.57 s)
  • xs_proxy_mock, _no_reserve, _no_protect, _no_handler, _env_slots: Passed (5/5)
  • xs_proxy_mock_env_slots_invalid: Failed (5.35 s) — [rt] d3d12_xs: device slot 71 routed to placed view UAV -> xs_proxy_mock line 1073: hr_of(raw(device, 71)) == S_OK && mock->calls[71] == 1 (same slot 71 failure seen on current main)

7 passed, 1 failed (88%).

AI-assisted: yes

@DesertGamer

Copy link
Copy Markdown
Contributor

measurement on the retail boot, #1160 on top of #1079 + #980 + #1028 (+ #1021 translated shaders, DadaCap prototype + #968): RTX 5070, Windows 11, NVIDIA 617.14

AI-assisted: yes (Claude Code, Sonnet 5.5)

@DesertGamer

Copy link
Copy Markdown
Contributor

correction, please disregard the measurement above as a statement about #1160: my stack was wrong, not the PR.

On my stack the buffer views go through arena_va() (a buffer's GPU address is turned into its arena address); #1160 was written on a base without that, so its factored write_buffer_srv_at writes base_va + byte_off as is. When I merged #1160 onto my stack I took its function whole and lost the arena_va() call in the three buffer cases, so the invalid addresses in the fault reports (0x21bcc41f000 here, 0x3233d5e0000 without #1160) and the earlier loss at 29 s say nothing about #1160 itself. The "reading" in my comment (a null descriptor became a real V# with a non-GPU address) was a guess made before I had looked at that line.

I am re-running with the arena_va() kept in write_buffer_srv_at and will post that result here. Whoever lands #1160 together with the change that introduced arena_va() in the buffer SRV path will hit the same textual conflict in that function, so it is worth knowing before both are merged.

AI-assisted: yes (Claude Code, Sonnet 5.5)

A raw shader-resource view of a live image used to return a null
descriptor. Match the placement and resource description for SRVs and
UAVs, retain the chosen image while creating its view, and remove its
entry on final release. The placement ABI is also documented by VIctory.

The default and rollback GPU tests each sampled 64 expected texels from
a placed view. The default accepted two writable views and rejected two
controls. The rollback returned four null UAVs.

xs_proxy_mock's invalid environment-slot case used slot 71 as its
forwarded PC slot. Slot 71 is routed now, so the case probes slot 72.
All six CTest forms of the proxy test pass.

AI-assisted (Codex and Claude Code agents).

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@DesertGamer

Copy link
Copy Markdown
Contributor

result with arena_va() kept in write_buffer_srv_at (the correction above), same stack as before: #1160 on #1079 + #980 + #1028, #1021 translated shaders, DadaCap prototype + #968, RTX 5070, Windows 11, NVIDIA 617.14, retail boot.

The checkpoint output comes from LEONIDA_CHECKPOINTS=1 (RT-VK-CHECKPOINTS, claimed above); I can post the marker lines for the last few commands if useful.

AI-assisted: yes (Claude Code, Sonnet 5.5)

@madhyn

madhyn commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Also tested d04e78e2b (which carries #1079) stacked with #1028 (RT-DEVICE-FAULT-INFO) and #974 (00fc23b9a) on origin/main (6293c1c4f, Arch Linux + Wine 11.22 + NVIDIA RTX 3060 Ti, retail 1.0.2.1):

  • device slot 70 is hit and routed to placed view SRV (args 0xbb8764f810 0xbb8764f7d0 0xbbb4fe0220 0x0 0x0).
  • 0 VK_ERROR_DEVICE_LOST / VK_EXT_device_fault lines.
  • On this clean main base (without our separate exp/stack-385 frame-loop stack), the boot stops earlier at 0x14247af2d: int3 right after device slot 127 (dimension=3) and device slot 20.

AI-assisted: yes

@iFeyz

iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@madhyn @DesertGamer thank you both, that is exactly the check this needed.

arena_va(): it exists on DadaCap's boot-prototype (d3d12_com.h, used for root views and vertex/index views there), not on main. This pull request is written against main, where a constant-buffer view's BufferLocation is used as is, so write_buffer_srv_at / write_buffer_uav_at take the slot's address the same way. On a stack that has arena_va(), the slot's address belongs to the same family as a CBV's or a vertex view's. Translating it once in write_placed_view before the two calls (or inside both helpers, as DesertGamer did) is the right merge. I will say so in the description so whoever stacks the two does not lose it.

The culling loss: DesertGamer's run says #1160 alone does not remove it on that stack (lost at 83.4 s in an instance-culling dispatch, read of 0xf042c31e8000). So the null buffer views were at most one cause. That address does not look like an arena address. Whether it comes from a buffer view these slots write or from somewhere else is what the checkpoint markers (RT-VK-CHECKPOINTS) could show. If you post the last markers' bindings, I can check them against what #1160 writes.

…m a buffer description and its address

DadaCap measured that slots 70 (SRV) and 71 (UAV) also make buffer views, and that the null descriptor
they got left the instance-culling dispatches reading leftover memory as a V# until the device was
lost (issue ProjectLeonida#14 comment 7140195321). A buffer description now reaches ProjectLeonida#1079's placed-view handler,
which writes the V# of a view of Width bytes at the address (taken as a GPU address, as a CBV's
BufferLocation is). The V# comes from the code CreateShaderResourceView / CreateUnorderedAccessView
use for a buffer resource, factored out as write_buffer_srv_at / write_buffer_uav_at, so the view
kinds and bounds are the PC methods'. A refused view or a UAV counter offset keeps the null view.
d3d12_set0_compute_test compares six views with the PC methods' and checks three null controls.
@iFeyz
iFeyz force-pushed the feat/title-buffer-views branch from d04e78e to c4afec1 Compare November 24, 2026 19:53
@Deedlyy

Deedlyy commented Nov 24, 2026

Copy link
Copy Markdown

Recommendation: [WAIT]

Reasoning: Xbox device slots 70/71 now write buffer SRV/UAV views from a buffer description and address. This targets a world-phase device-loss cause, a significant runtime change (+453/-113). The branch is built on #1079, which must land first. The retail-boot measurements from DesertGamer and madhyn depend on DadaCap's out-of-tree arena_va() stack, which isn't on main. Merge after #1079, once someone shows the device-loss improvement on main's own address path. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main.

Impact level: 7/10

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 24, 2026
@azsekazvamdimitar

Copy link
Copy Markdown
Contributor

Ran this on Linux under Wine and Proton, as part of VERIFY-WINE-PROTON-GPU in #14. Your branch at c4afec1 as is, against its base #1079 at 99176da: both now conflict with main (d3d12_xs_device.h/.cpp slot 70/74, xs_proxy_mock_test.cpp main), so I did not merge into main.

tests #1079 this PR #1079 + only this PR's tests
d3d12_set0_compute pass pass fail: line 159: expected != Words{} && got == expected, line 176: same(uav, true) == 0, line 325: check_placed_buffer_views(device.p) == 0
d3d12_placed_texture_uav_off pass pass fail: the same three lines
xs_proxy_mock and its five variants pass pass pass

The same results on each host: WineHQ 11.22 (winewayland) and GE-Proton11-14 (winex11, with d3d12, d3d12core and dxgi set to native) on an RTX 3090 (NVIDIA 590.48.01), and GE-Proton on the Radeon iGPU of a Ryzen 5 7600 (RADV, Mesa 26.0.8) for the two d3d12_set0_compute registrations. So the new buffer-view checks fail without your change and pass with it.

These tests are Windows-only, so nothing ran natively. Built with clang-cl and xwin in a container; not run on Windows or with the retail game. It will need a rebase onto main after #1079's.

AI-assisted (Claude).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants