[PR #1232] [MERGED] d3d12: graphics draws supply the directly indexed heaps after their root arguments (RT-DIRECT-HEAP-GRAPHICS) #1264

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1232
Author: @iFeyz
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: feat/direct-heap-graphics


📝 Commits (6)

  • 7c47fd9 d3d12: supply directly indexed heaps to compute dispatches (RT-DIRECT-HEAP-COMPUTE)
  • bfe8d5c Merge commit 'refs/pull/1064/head' of https://github.com/ubiquitarianism/leonida into feat/direct-heap-graphics
  • 9b8707c RT-DIRECT-HEAP-GRAPHICS: graphics draws supply the directly indexed heaps after their root arguments
  • c8f7515 d3d12: supply directly indexed heaps to compute dispatches (RT-DIRECT-HEAP-COMPUTE)
  • 5115f08 Merge main into RT-DIRECT-HEAP-COMPUTE (#1064)
  • 3ee0037 Merge main into RT-DIRECT-HEAP-GRAPHICS (#1232)

📊 Changes

6 files changed (+401 additions, -18 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+23 -5)
📝 runtime/shims/d3d12_com.cpp (+36 -5)
📝 runtime/test/d3d12_compute_test.cpp (+45 -6)
📝 runtime/test/d3d12_mesh_test.cpp (+65 -2)
➕ tests/test_compute_heap_layout_census.py (+64 -0)
➕ tools/compute_heap_layout_census.py (+168 -0)

📄 Description

Claimed in the coordination issue as: RT-DIRECT-HEAP-GRAPHICS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143274207)

Depends on: #974 (graphics root arguments in the console layout), #1064 (RT-DIRECT-HEAP-COMPUTE). This branch is #974 with #1064 merged in; its last commit is this pull request.

What and why

With CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED / SAMPLER_HEAP_DIRECTLY_INDEXED, a console program finds the descriptor heaps in the dwords right after its root arguments. @DadaCap measured on the retail library that this holds for every stage: from s4 in compute, s8 in VS/PS/GS and s16 in mesh shaders, the resource heap's address in the first dword after the root arguments and the sampler heap's in the next (issue #14, comment 7143020922, item 4). #1064 supplies them for compute. A graphics draw with a bound heap only got a note that its heap-base SGPR was not supplied, so a directly indexed VS/PS/MS read a zero heap base.

  • runtime/shims/d3d12_com.cpp: graphics_user_data(), the graphics side of #1064's compute_user_data(). Each DrawInstanced, DrawIndexedInstanced and DispatchMesh records the bound heaps' 32-bit addresses at graphics_arguments_end and the next dword.
    • An unbound heap contributes zero, and rebinding affects later draws.
    • A heap past s31 is reported once.
    • A mesh shader reads the same push dwords through #974's window, so the mesh case needs nothing of its own.
    • LEONIDA_GRAPHICS_DIRECT_HEAPS=0 restores the previous arguments.
  • runtime/shims/d3d12_vulkan_device.cpp / d3d12_com.h: RootArgumentLayout::graphics_arguments_end (from pack_stage's end_sgpr). It is not set for a signature with parameters in the argument block, or under LEONIDA_GRAPHICS_ROOT_LAYOUT=pc, because no slot is measured there; nothing is written then, with one note.
  • Docs: docs/d3d12_vulkan.md section 3.4, next to #1064's compute paragraph.

Tested

  • d3d12_mesh_test (RX 9070 XT), through rt::d3d12::recorded_commands:
    • 4 root constants: a vertex draw and a mesh draw record the constants at s8..s11, the resource heap at s12 and the sampler heap at s13, and the mesh draw's dwords are the vertex draw's.
    • Rebinding only the resource heap: the sampler dword goes to 0.
    • 23 constants: the resource heap takes s31 and the sampler heap has no room (noted).
    • 30 constants (spilled): nothing is written.
  • d3d12_compute_test (#1064's checks) and root_signature_test pass on the merge.
  • Runtime (Windows 11, MSVC 2022 Build Tools, RelWithDebInfo, full build): ctest 303 of 307 pass. The 4 failures are the same as on main here (d3d12_clear, d3d12_execute_indirect_validation, d3d12_texture_tiles, d3d12_pipeline_library_host, reported in #14).
  • tests/test_docs_env_vars.py, tests/test_docs_links.py, scripts/check_no_game_data.py on every changed file.

Not run here: the retail title. On main's own address path (no boot-prototype arena), a directly indexed draw now gets the same heap addresses a compute dispatch gets under #1064.

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/1232 **Author:** [@iFeyz](https://github.com/iFeyz) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `feat/direct-heap-graphics` --- ### 📝 Commits (6) - [`7c47fd9`](https://github.com/ubiquitarianism/leonida/commit/7c47fd946ba19461ed7ff0b12383b55e23bf79c7) d3d12: supply directly indexed heaps to compute dispatches (RT-DIRECT-HEAP-COMPUTE) - [`bfe8d5c`](https://github.com/ubiquitarianism/leonida/commit/bfe8d5c4d83f22570b604dbf70b80c226d3e91b0) Merge commit 'refs/pull/1064/head' of https://github.com/ubiquitarianism/leonida into feat/direct-heap-graphics - [`9b8707c`](https://github.com/ubiquitarianism/leonida/commit/9b8707c03dabb59ba2e29b9b0749d3c3eb1f3903) RT-DIRECT-HEAP-GRAPHICS: graphics draws supply the directly indexed heaps after their root arguments - [`c8f7515`](https://github.com/ubiquitarianism/leonida/commit/c8f7515e2e6fb2a2a61eb1e986ee8c6fd4431399) d3d12: supply directly indexed heaps to compute dispatches (RT-DIRECT-HEAP-COMPUTE) - [`5115f08`](https://github.com/ubiquitarianism/leonida/commit/5115f0887940595aa0f46fed7fc9db28b64151ff) Merge main into RT-DIRECT-HEAP-COMPUTE (#1064) - [`3ee0037`](https://github.com/ubiquitarianism/leonida/commit/3ee0037fd3accba459d0d5ecd8acad831174d4d7) Merge main into RT-DIRECT-HEAP-GRAPHICS (#1232) ### 📊 Changes **6 files changed** (+401 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+23 -5) 📝 `runtime/shims/d3d12_com.cpp` (+36 -5) 📝 `runtime/test/d3d12_compute_test.cpp` (+45 -6) 📝 `runtime/test/d3d12_mesh_test.cpp` (+65 -2) ➕ `tests/test_compute_heap_layout_census.py` (+64 -0) ➕ `tools/compute_heap_layout_census.py` (+168 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-DIRECT-HEAP-GRAPHICS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143274207) Depends on: #974 (graphics root arguments in the console layout), #1064 (RT-DIRECT-HEAP-COMPUTE). This branch is #974 with #1064 merged in; its last commit is this pull request. ### What and why With `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` / `SAMPLER_HEAP_DIRECTLY_INDEXED`, a console program finds the descriptor heaps in the dwords right after its root arguments. @DadaCap measured on the retail library that this holds for every stage: from s4 in compute, s8 in VS/PS/GS and s16 in mesh shaders, the resource heap's address in the first dword after the root arguments and the sampler heap's in the next (issue #14, comment 7143020922, item 4). #1064 supplies them for compute. A graphics draw with a bound heap only got a note that its heap-base SGPR was not supplied, so a directly indexed VS/PS/MS read a zero heap base. - **`runtime/shims/d3d12_com.cpp`**: `graphics_user_data()`, the graphics side of #1064's `compute_user_data()`. Each `DrawInstanced`, `DrawIndexedInstanced` and `DispatchMesh` records the bound heaps' 32-bit addresses at `graphics_arguments_end` and the next dword. - An unbound heap contributes zero, and rebinding affects later draws. - A heap past s31 is reported once. - A mesh shader reads the same push dwords through #974's window, so the mesh case needs nothing of its own. - `LEONIDA_GRAPHICS_DIRECT_HEAPS=0` restores the previous arguments. - **`runtime/shims/d3d12_vulkan_device.cpp` / `d3d12_com.h`**: `RootArgumentLayout::graphics_arguments_end` (from `pack_stage`'s `end_sgpr`). It is not set for a signature with parameters in the argument block, or under `LEONIDA_GRAPHICS_ROOT_LAYOUT=pc`, because no slot is measured there; nothing is written then, with one note. - **Docs**: `docs/d3d12_vulkan.md` section 3.4, next to #1064's compute paragraph. ### Tested - `d3d12_mesh_test` (RX 9070 XT), through `rt::d3d12::recorded_commands`: - **4 root constants:** a vertex draw and a mesh draw record the constants at s8..s11, the resource heap at s12 and the sampler heap at s13, and the mesh draw's dwords are the vertex draw's. - **Rebinding only the resource heap:** the sampler dword goes to 0. - **23 constants:** the resource heap takes s31 and the sampler heap has no room (noted). - **30 constants (spilled):** nothing is written. - `d3d12_compute_test` (#1064's checks) and `root_signature_test` pass on the merge. - Runtime (Windows 11, MSVC 2022 Build Tools, RelWithDebInfo, full build): `ctest` 303 of 307 pass. The 4 failures are the same as on `main` here (`d3d12_clear`, `d3d12_execute_indirect_validation`, `d3d12_texture_tiles`, `d3d12_pipeline_library_host`, reported in #14). - `tests/test_docs_env_vars.py`, `tests/test_docs_links.py`, `scripts/check_no_game_data.py` on every changed file. Not run here: the retail title. On `main`'s own address path (no `boot-prototype` arena), a directly indexed draw now gets the same heap addresses a compute dispatch gets under #1064. 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>
4ld0 2026-11-26 20:20:39 +01:00
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#1264
No description provided.