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

Open
opened 2026-11-26 20:20:24 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1160
Author: @iFeyz
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: feat/title-buffer-views


📝 Commits (2)

  • 99176da d3d12: resolve views of live placed textures (RT-TITLE-TEXTURE-VIEWS)
  • c4afec1 RT-TITLE-BUFFER-VIEWS: Xbox device slots 70/71 write buffer views from a buffer description and its address

📊 Changes

8 files changed (+453 additions, -113 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+14 -0)
📝 runtime/CMakeLists.txt (+2 -0)
📝 runtime/shims/d3d12_com_object.h (+4 -1)
📝 runtime/shims/d3d12_vulkan_device.cpp (+201 -75)
📝 runtime/shims/d3d12_xs_device.cpp (+46 -20)
📝 runtime/shims/d3d12_xs_device.h (+8 -4)
📝 runtime/test/d3d12_set0_compute_test.cpp (+163 -6)
📝 runtime/test/xs_proxy_mock_test.cpp (+15 -7)

📄 Description

Claimed in the coordination issue as: RT-TITLE-BUFFER-VIEWS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141517462)

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 #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 #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 #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 #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 #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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1160 **Author:** [@iFeyz](https://github.com/iFeyz) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/title-buffer-views` --- ### 📝 Commits (2) - [`99176da`](https://github.com/ubiquitarianism/leonida/commit/99176da104f8b49d3987cad24b300cd1a5f5f4c8) d3d12: resolve views of live placed textures (RT-TITLE-TEXTURE-VIEWS) - [`c4afec1`](https://github.com/ubiquitarianism/leonida/commit/c4afec17ec6feaa00400482c8b5e47c5a96240b4) RT-TITLE-BUFFER-VIEWS: Xbox device slots 70/71 write buffer views from a buffer description and its address ### 📊 Changes **8 files changed** (+453 additions, -113 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+14 -0) 📝 `runtime/CMakeLists.txt` (+2 -0) 📝 `runtime/shims/d3d12_com_object.h` (+4 -1) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+201 -75) 📝 `runtime/shims/d3d12_xs_device.cpp` (+46 -20) 📝 `runtime/shims/d3d12_xs_device.h` (+8 -4) 📝 `runtime/test/d3d12_set0_compute_test.cpp` (+163 -6) 📝 `runtime/test/xs_proxy_mock_test.cpp` (+15 -7) </details> ### 📄 Description Claimed in the coordination issue as: RT-TITLE-BUFFER-VIEWS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141517462) 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 #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 #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 #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 #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 #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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1193
No description provided.