d3d12: advertise WriteBufferImmediate for addressable buffers #1208

Closed
PyZikYG wants to merge 1 commit from upstream-pr/1208 into main
PyZikYG commented 2026-11-24 20:17:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PyZikYG on 2026-11-24T20:17:22Z.


Claimed as D3D-WRITE-IMMEDIATE-CAPS.

OPTIONS3 always returned no WriteBufferImmediate support, even though the Vulkan runtime already executes these writes through vkCmdUpdateBuffer. Applications that check the feature flag before recording a write could not discover the implemented path.

Report direct, bundle, compute and copy list support when the console GPU-address arena and Vulkan update entry point are available. Leave the flags clear when either prerequisite is missing.

AI-assisted: yes.

Tested

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5479633399 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1208). Originally posted by [PyZikYG](https://github.com/PyZikYG) on 2026-11-24T20:17:22Z. --- Claimed as [D3D-WRITE-IMMEDIATE-CAPS](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143244652). OPTIONS3 always returned no WriteBufferImmediate support, even though the Vulkan runtime already executes these writes through vkCmdUpdateBuffer. Applications that check the feature flag before recording a write could not discover the implemented path. Report direct, bundle, compute and copy list support when the console GPU-address arena and Vulkan update entry point are available. Leave the flags clear when either prerequisite is missing. AI-assisted: yes. ### Tested - `d3d12_vulkan_device`: PASS - `replay_write_immediate_predication`: PASS - [Independent validation on Windows](https://github.com/ubiquitarianism/leonida/pull/1208#issuecomment-7145000136)
Snooozs commented 2026-11-24 21:29:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Snooozs on 2026-11-24T21:29:30Z.


Read the whole diff and tested 1c06b6024 merged on main 6261ca916 (clean): Windows 10 Pro 19045, VS 2022 RelWithDebInfo, LEONIDA_VK_VALIDATION=1, d3d12_vulkan_device_test.

RTX 5060 Ti (NVIDIA 621.01) exit VUID lines
main 0 0
this test, main's device code 1 0
this PR 0 0

The other OPTIONS3 checks in that file still hold here, including WriteBufferImmediateSupportFlags == NONE in the feature comparison and the subset check against the host. On the Ryzen 7 7700 iGPU (AMD 31.0.22044.1) the test exits 1 on main as well (it stops before this block), so there is no evidence either way from that GPU.

The description has no "Tested" section; the template asks for what was run and on which GPU and driver.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145000136 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1208#issuecomment-7145000136). Originally posted by [Snooozs](https://github.com/Snooozs) on 2026-11-24T21:29:30Z. --- Read the whole diff and tested `1c06b6024` merged on main `6261ca916` (clean): Windows 10 Pro 19045, VS 2022 RelWithDebInfo, `LEONIDA_VK_VALIDATION=1`, `d3d12_vulkan_device_test`. | RTX 5060 Ti (NVIDIA 621.01) | exit | VUID lines | |---|---|---| | main | 0 | 0 | | this test, main's device code | 1 | 0 | | this PR | 0 | 0 | The other `OPTIONS3` checks in that file still hold here, including `WriteBufferImmediateSupportFlags == NONE` in the feature comparison and the subset check against the host. On the Ryzen 7 7700 iGPU (AMD 31.0.22044.1) the test exits 1 on main as well (it stops before this block), so there is no evidence either way from that GPU. The description has no "Tested" section; the template asks for what was run and on which GPU and driver. AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-29 02:14:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T02:14:00Z.


Independently verified head c2fb5b68c6e4a084c3180e40199cd9aa8239af67 merged cleanly onto origin/main (59e65849b0927ee8c435baf1c74aecd08104fd60) on Windows 11 (10.0.26200), MSVC 19.44.35207 (RelWithDebInfo), NVIDIA GeForce RTX 3090 (driver 595.79), with VK_LAYER_KHRONOS_validation 1.4.363.1 (LEONIDA_VK_VALIDATION=1). No game files used.

Red -> Green Verification

  • Red (main's runtime/shims/d3d12_vulkan_device.cpp with PR's d3d12_vulkan_device_test.cpp):
    • ctest -C RelWithDebInfo -R "^d3d12_vulkan_device$": FAILED (rc=8) at line 7308: options.WriteBufferImmediateSupportFlags == expected_support (main always reports D3D12_COMMAND_LIST_SUPPORT_FLAG_NONE).
  • Green (#1208 merged with origin/main 59e65849b0, LEONIDA_VK_VALIDATION=1 on RTX 3090):
    • d3d12_vulkan_device: Passed (16.69 s, NONE on the un-addressable device at line 2430, full expected_support + markers == {1, 2, 3, 4} readback across DIRECT, BUNDLE, COMPUTE, and COPY lists on the addressable standalone device; 0 Khronos validation errors).
    • replay_write_immediate_predication: Passed (0.07 s).
    • scripts/check_no_game_data.py, tests/test_docs_encoding.py, tests/test_docs_repo_paths.py: Passed.

Non-Blocking D3D12 Spec Note (D3D12_COMMAND_LIST_SUPPORT_FLAG_BUNDLE)

  • The Vulkan replay layer handles WriteBufferImmediate inside ExecuteBundle cleanly (verified by the BUNDLE marker 2 readback above with 0 validation errors). Note, however, that in Microsoft's D3D12 specification ID3D12GraphicsCommandList2::WriteBufferImmediate is forbidden on bundles, so native Windows D3D12 drivers and WARP report 0xD (DIRECT | COMPUTE | COPY, without BUNDLE = 0x2). In d3d12_vulkan_device_test.cpp:2631, compare_host("OPTIONS3", ...) checks (ours & ~host) == 0 on a device without arena.buffer (0x0), which passes; if compare_host is ever extended to an arena-enabled device, advertising 0xF would exceed native D3D12's 0xD unless BUNDLE is omitted or masked there. Also consider state_.context && state_.context->vk.vkCmdUpdateBuffer alongside state_.arena.buffer purely for defensive null-safety.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249294930 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1208#issuecomment-7249294930). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T02:14:00Z. --- Independently verified head `c2fb5b68c6e4a084c3180e40199cd9aa8239af67` merged cleanly onto `origin/main` (`59e65849b0927ee8c435baf1c74aecd08104fd60`) on Windows 11 (`10.0.26200`), MSVC `19.44.35207` (`RelWithDebInfo`), **NVIDIA GeForce RTX 3090** (driver `595.79`), with `VK_LAYER_KHRONOS_validation` `1.4.363.1` (`LEONIDA_VK_VALIDATION=1`). No game files used. ### Red -> Green Verification - **Red (`main`'s `runtime/shims/d3d12_vulkan_device.cpp` with PR's `d3d12_vulkan_device_test.cpp`)**: - `ctest -C RelWithDebInfo -R "^d3d12_vulkan_device$"`: **FAILED (`rc=8`)** at `line 7308: options.WriteBufferImmediateSupportFlags == expected_support` (`main` always reports `D3D12_COMMAND_LIST_SUPPORT_FLAG_NONE`). - **Green (`#1208` merged with `origin/main` `59e65849b0`, `LEONIDA_VK_VALIDATION=1` on RTX 3090)**: - `d3d12_vulkan_device`: **Passed** (`16.69 s`, `NONE` on the un-addressable device at `line 2430`, full `expected_support` + `markers == {1, 2, 3, 4}` readback across `DIRECT`, `BUNDLE`, `COMPUTE`, and `COPY` lists on the addressable `standalone` device; `0` Khronos validation errors). - `replay_write_immediate_predication`: **Passed** (`0.07 s`). - `scripts/check_no_game_data.py`, `tests/test_docs_encoding.py`, `tests/test_docs_repo_paths.py`: **Passed**. ### Non-Blocking D3D12 Spec Note (`D3D12_COMMAND_LIST_SUPPORT_FLAG_BUNDLE`) - The Vulkan replay layer handles `WriteBufferImmediate` inside `ExecuteBundle` cleanly (verified by the `BUNDLE` marker `2` readback above with `0` validation errors). Note, however, that in Microsoft's D3D12 specification `ID3D12GraphicsCommandList2::WriteBufferImmediate` is forbidden on bundles, so native Windows D3D12 drivers and WARP report `0xD` (`DIRECT | COMPUTE | COPY`, without `BUNDLE = 0x2`). In `d3d12_vulkan_device_test.cpp:2631`, `compare_host("OPTIONS3", ...)` checks `(ours & ~host) == 0` on a device without `arena.buffer` (`0x0`), which passes; if `compare_host` is ever extended to an arena-enabled device, advertising `0xF` would exceed native D3D12's `0xD` unless `BUNDLE` is omitted or masked there. Also consider `state_.context && state_.context->vk.vkCmdUpdateBuffer` alongside `state_.arena.buffer` purely for defensive null-safety. AI-assisted: yes
enlight3d commented 2026-11-29 08:57:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T08:57:10Z.


Validation run of this PR on a Windows PC with a real GPU.

  • PR head: c2fb5b68c6
  • main: 54b2a81e95
  • Tested merged: yes, git merge --no-ff of the PR head into main was clean.

Commands (RelWithDebInfo, Ninja, LEONIDA_REQUIRE_VULKAN=ON):

git fetch origin pull/1208/head:pr-1208
git checkout --detach origin/main && git merge --no-edit --no-ff pr-1208
cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON
cmake --build runtime/build -j 8 --target d3d12_vulkan_device_test gta6rt
ctest -R "^d3d12_vulkan_device$" --output-on-failure -j1
  • Green: d3d12_vulkan_device passed (1/1), including the new WriteBufferImmediate checks (support flags and a write through a direct, bundle, compute and copy list).
  • Red (behavioural): the PR's test kept, runtime/shims/d3d12_vulkan_device.cpp reverted to main (the test still builds). The test exits 1 with line 7308: options.WriteBufferImmediateSupportFlags == expected_support.
  • Link: no new imports vs main (dumpbin /imports of gta6rt.exe, 703 DLL!symbol entries, identical to a main build).

Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7253438202 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1208#issuecomment-7253438202). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T08:57:10Z. --- Validation run of this PR on a Windows PC with a real GPU. - PR head: c2fb5b68c6e4a084c3180e40199cd9aa8239af67 - main: 54b2a81e95c470c953ddee6177fd6255cbaf041d - Tested merged: yes, `git merge --no-ff` of the PR head into main was clean. Commands (RelWithDebInfo, Ninja, `LEONIDA_REQUIRE_VULKAN=ON`): ``` git fetch origin pull/1208/head:pr-1208 git checkout --detach origin/main && git merge --no-edit --no-ff pr-1208 cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON cmake --build runtime/build -j 8 --target d3d12_vulkan_device_test gta6rt ctest -R "^d3d12_vulkan_device$" --output-on-failure -j1 ``` - Green: `d3d12_vulkan_device` passed (1/1), including the new WriteBufferImmediate checks (support flags and a write through a direct, bundle, compute and copy list). - Red (behavioural): the PR's test kept, `runtime/shims/d3d12_vulkan_device.cpp` reverted to main (the test still builds). The test exits 1 with `line 7308: options.WriteBufferImmediateSupportFlags == expected_support`. - Link: no new imports vs main (`dumpbin /imports` of `gta6rt.exe`, 703 DLL!symbol entries, identical to a main build). Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44.
fiestorra commented 2026-11-30 11:26:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-30T11:26:41Z.


Independent verification on this machine (Windows 11, RTX 4090, MSVC 19.44.35226), with a negative control that bites.

1. It applies and builds. merge-tree clean onto main d367675c7; one shim file changed (runtime/shims/d3d12_vulkan_device.cpp) plus its test.

2. With the branch:

ctest -R 'd3d12_vulkan_device'
100% tests passed, 0 tests failed out of 1

3. The control - revert only the shim, keep the test:

git checkout origin/main -- runtime/shims/d3d12_vulkan_device.cpp
cmake --build … --target d3d12_vulkan_device_test
ctest -R 'd3d12_vulkan_device' --output-on-failure
0% tests passed, 1 tests failed out of 1        (13.66 s on the failing side)
new formats: 11 of 11 created and copied both ways bit for bit (host compared on 11, host lacks 0), 9 render-target …
[rt] d3d12: ExecuteCommandLists failed: a list is not closed; nothing was submitted

The failing run gets through the format checks and then stops at ExecuteCommandLists with "a list is not closed" - so the part of the change that the test exercises is the command-list state around the new formats, not the format creation itself.

What I did not test: whether the "list is not closed" line is the assertion or a symptom of the missing shim behaviour - the test output does not say which assertion fired, and I did not read the test's source to attribute it. The control establishes that the test notices the absence of the change; the attribution is the author's.

Why I am commenting: I verify open pull requests that replay onto current main, build the binaries their tests name, run them, then revert only the source change. 28 controls so far: 23 bite.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7277032617 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1208#issuecomment-7277032617). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-30T11:26:41Z. --- Independent verification on this machine (Windows 11, RTX 4090, MSVC 19.44.35226), with a negative control that bites. **1. It applies and builds.** `merge-tree` clean onto `main` `d367675c7`; one shim file changed (`runtime/shims/d3d12_vulkan_device.cpp`) plus its test. **2. With the branch:** ``` ctest -R 'd3d12_vulkan_device' 100% tests passed, 0 tests failed out of 1 ``` **3. The control - revert only the shim, keep the test:** ``` git checkout origin/main -- runtime/shims/d3d12_vulkan_device.cpp cmake --build … --target d3d12_vulkan_device_test ctest -R 'd3d12_vulkan_device' --output-on-failure 0% tests passed, 1 tests failed out of 1 (13.66 s on the failing side) new formats: 11 of 11 created and copied both ways bit for bit (host compared on 11, host lacks 0), 9 render-target … [rt] d3d12: ExecuteCommandLists failed: a list is not closed; nothing was submitted ``` **The failing run gets through the format checks and then stops at `ExecuteCommandLists` with "a list is not closed"** - so the part of the change that the test exercises is the **command-list state around the new formats**, not the format creation itself. **What I did not test:** whether the "list is not closed" line is the assertion or a symptom of the missing shim behaviour - the test output does not say which assertion fired, and I did not read the test's source to attribute it. **The control establishes that the test notices the absence of the change; the attribution is the author's.** **Why I am commenting:** I verify open pull requests that replay onto current `main`, build the binaries their tests name, run them, then revert **only** the source change. **28 controls so far: 23 bite.** Written with an AI assistant.
aslan2142 commented 2026-12-01 16:33:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:33:58Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317817267 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1208#issuecomment-7317817267). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:33:58Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1208
No description provided.