[PR #213] [MERGED] D3D-78: Support Texture1D, Texture1DArray and Texture3D UAVs #267

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

📋 Pull Request Information

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

Base: main ← Head: old-pr/9948


📝 Commits (4)

  • c0a5d66 feat(vulkan): support Texture1D, Texture1DArray and Texture3D UAVs
  • 1e63e09 test(vulkan): exercise D3D-78 texture UAVs in the GPU runner
  • 57cb669 fix(vulkan): require formatless reads for all D3D-78 UAVs
  • 33f4a5a Merge upstream main and preserve 1D UAV clear compatibility

📊 Changes

35 files changed (+2375 additions, -394 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+53 -26)
📝 docs/design.md (+3 -1)
📝 docs/testing.md (+23 -1)
📝 runtime/CMakeLists.txt (+8 -0)
📝 runtime/shims/d3d12_com.cpp (+8 -0)
📝 runtime/shims/d3d12_com.h (+4 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+257 -85)
📝 runtime/src/command_list.h (+1 -0)
📝 runtime/src/gfx10_descriptors.h (+20 -0)
📝 runtime/src/vulkan_bindless.h (+43 -23)
📝 runtime/src/vulkan_replay.h (+9 -2)
📝 runtime/test/bindless_sizing_test.cpp (+44 -4)
📝 runtime/test/d3d12_r9g9b9e5_uav_test.cpp (+76 -22)
📝 runtime/test/d3d12_texture1d_target_test.cpp (+4 -0)
📝 runtime/test/d3d12_texture1d_test.cpp (+8 -7)
➕ runtime/test/d3d12_texture_uav_oracle.h (+279 -0)
➕ runtime/test/d3d12_texture_uav_test.cpp (+620 -0)
📝 runtime/test/glsl/cs_r9g9b9e5_uav.comp (+18 -3)
📝 runtime/test/shaders/check.py (+27 -2)
📝 runtime/test/shaders/cs_imgatomic3d.asm (+2 -2)

...and 15 more files

📄 Description

Carried over from old PR 9948 by guimsolutions in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9948, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
This branch conflicts with the current main and needs a rebase.
guimsolutions: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Summary

D3D-78, assigned to @guimsolutions. Adds default and explicit Texture1D, Texture1DArray, and Texture3D UAVs to CreateUnorderedAccessView.

Rebased onto upstream main at f847748cc76bd3777f9c070c4034eb2fc1c04e64, retaining the two linear D3D-78 commits. D3D-63 is already in main (c7d5f8e8). The rebased translator keeps upstream A16 2D mip addresses and typed 3D mip loads and uses the existing W-slice guard only for tagged UAVs. The Vulkan harness keeps upstream geometry and push-constant-tail support. The descriptor refusal test now starts its read-only resource in COMMON to comply with upstream resource-state validation.

Implementation

  • Validate resource dimensions, formats, mips, and layer ranges. Texture1D uses storage bindings 17ÔÇô19; storage-only Texture1DArray uses 26ÔÇô28 (float, UINT, SINT). Default 1D-array UAVs cover the full array, but 1D-array SRVs remain unsupported. Upstream multisample SRV bindings 20ÔÇô25 are unchanged. Bindless sizing and the pipeline checker account for Vulkan descriptor limits, including update-after-bind limits.
  • Keep Vulkan array layers at {0, 1} for 3D UAVs. Partial W ranges require VkImageViewSlicedCreateInfoEXT, imageSlicedViewOf3D, and robustImageAccess; otherwise the runtime writes a null descriptor rather than exposing the entire mip. Tagged descriptors carry FirstWSlice and effective WSize. Storage coordinates use relative Z; float/UINT/SINT sampled loads rebase Z and return zero outside the range or at nonzero view-relative LOD. Untagged SRVs keep their original coordinates and LOD.
  • Preserve SHADER-151 typed sampled aliases and the separate coherent storage-load path. A tagged R32_UINT volume UAV whose descriptor SGPR group also feeds volume atomics uses the formatted storage view for load-after-atomic visibility in the same dispatch. Other sampled loads keep upstream visibility rules. 3D stores and atomics cannot write to the shared fallback on a lookup miss.
  • Check formatless writes for the actual view format and formatless reads for storage-only 1D arrays. The synthetic regression leaves the legacy shaderStorageImage{Read,Write}WithoutFormat device bits disabled to exercise Vulkan 1.3's per-format path. Emulated RGB9E5 retains its logical sampled format and R32_UINT backing; generic operations that would need unsupported repacking or unpacking take the safe fallback.
  • Keep compatible whole-mip CPU clears usable without bindless. Reject partial 3D clears and unsafe 1D/3D format reinterpretation; packed RGB9E5 clears retain bit-exact backing and existing upstream 2D typed attachment clears are unchanged.

Validation for 476ad95f

Windows: RTX 4090 (NVIDIA 621.01) and Intel UHD 770 (32.0.101.7088). GPU checks used the Khronos validation layer and synchronization validation.

Check Result
CMake/Ninja and CTest Build passed. RTX 4090: 134 passed, 8 skipped, 1 disabled. UHD 770: 131 passed, 9 skipped, 1 disabled, 2 baseline failures.
--filter cs_texture_uav Passed on both GPUs in standard and LEONIDA_PC_TAIL_UBO=1 modes: 14 cases (10 compared with WARP) on RTX 4090 and 10 cases (8 compared with WARP) on UHD 770. Intel lacks sliced 3D views; rejection of unsupported partial views was verified. No validation errors in the UAV readback test.
Full GPU runner (LEONIDA_W64_EMULATE=1) RTX 4090: 186 passed, 15 skipped, spirv-val 206/206. UHD 770: 168 passed, 33 skipped, spirv-val 205/205 translated. No failed GPU checks; each adapter adds two passing cases over exact upstream with unchanged skip counts.
Direct Vulkan regressions Packed RGB9E5 backing and #782 double-copy replay passed on both GPUs without validation errors; the synchronization self-test confirmed the layer was active. vk_pipeline_check compiled compute and geometry fixtures in both push-constant modes on both GPUs.
Python and CLI 806 passed, 10 skipped across the focused suites; 7,322 semantic tests run with one upstream expected failure (test_all_nan_keeps_src0) and no unexpected failures. compileall and make_game.py --help passed.

On exact upstream f847748c, UHD 770 reproduced the same CTest failures: d3d12_descriptor (lod_mismatches == 0, line 2659) and d3d12_subgroup (fragment_default, line 611). The Intel fallback still cannot translate ps_ij_computed without PerVertexKHR; every translated module passed validation. CTest skips reflect missing game-derived fixtures, unavailable adapter features, or opt-in validation (run separately); GameInput was disabled without SDL3. Other GPU skips reflect unsupported features or fixtures covered by separate tests. Python skips reflect missing synthetic DXBC fixtures or POSIX-only tests.

The requested scripts/run_gpu_tests.py integration is included: --filter cs_texture_uav dispatches the Windows differential test, and the full runner also exercises cs_imgload_mip. Runner unit tests cover pass, fail, missing executables, translation failure, and stale SPIR-V.

The regression creates and copies descriptors through the D3D12 shim, then dispatches a Vulkan compute pipeline with Leonida's real bindless set 0; this is not an end-to-end D3D12 Dispatch test. Coverage includes UINT/FLOAT and typeless views, nonzero mips, invalid descriptors, preservation of neighboring layers and slices, coexistence with a typed 3D SRV, dynamic image_load_mip, and active/inactive add and compare-and-swap with glc.

In a separate earlier native D3D12 probe, the RTX 4090 and UHD 770 clipped writes to the selected W range. WARP 10.0.26100.9818 rebased the view but wrote past a finite WSize under overdispatch. The oracle therefore compares in-range writes; Vulkan preservation of neighboring slices is checked independently.

Project compliance and AI disclosure

Only independently written synthetic fixtures were used. No proprietary game data, game shaders, keys, or protected content were used or included. AI-assisted implementation and review using OpenCode; validation is recorded above.

Previous contribution: #773


🔄 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/213 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `old-pr/9948` --- ### 📝 Commits (4) - [`c0a5d66`](https://github.com/ubiquitarianism/leonida/commit/c0a5d66fa60c7fd8e95700242c3f64ea23560fe5) feat(vulkan): support Texture1D, Texture1DArray and Texture3D UAVs - [`1e63e09`](https://github.com/ubiquitarianism/leonida/commit/1e63e096805a779a61f31715da5498d9864da116) test(vulkan): exercise D3D-78 texture UAVs in the GPU runner - [`57cb669`](https://github.com/ubiquitarianism/leonida/commit/57cb669f52ba6ca4bb58bf2e09492ffbe2b8ee60) fix(vulkan): require formatless reads for all D3D-78 UAVs - [`33f4a5a`](https://github.com/ubiquitarianism/leonida/commit/33f4a5aedeb48e27b004efe5d6ae306130d55cdd) Merge upstream main and preserve 1D UAV clear compatibility ### 📊 Changes **35 files changed** (+2375 additions, -394 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+53 -26) 📝 `docs/design.md` (+3 -1) 📝 `docs/testing.md` (+23 -1) 📝 `runtime/CMakeLists.txt` (+8 -0) 📝 `runtime/shims/d3d12_com.cpp` (+8 -0) 📝 `runtime/shims/d3d12_com.h` (+4 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+257 -85) 📝 `runtime/src/command_list.h` (+1 -0) 📝 `runtime/src/gfx10_descriptors.h` (+20 -0) 📝 `runtime/src/vulkan_bindless.h` (+43 -23) 📝 `runtime/src/vulkan_replay.h` (+9 -2) 📝 `runtime/test/bindless_sizing_test.cpp` (+44 -4) 📝 `runtime/test/d3d12_r9g9b9e5_uav_test.cpp` (+76 -22) 📝 `runtime/test/d3d12_texture1d_target_test.cpp` (+4 -0) 📝 `runtime/test/d3d12_texture1d_test.cpp` (+8 -7) ➕ `runtime/test/d3d12_texture_uav_oracle.h` (+279 -0) ➕ `runtime/test/d3d12_texture_uav_test.cpp` (+620 -0) 📝 `runtime/test/glsl/cs_r9g9b9e5_uav.comp` (+18 -3) 📝 `runtime/test/shaders/check.py` (+27 -2) 📝 `runtime/test/shaders/cs_imgatomic3d.asm` (+2 -2) _...and 15 more files_ </details> ### 📄 Description > Carried over from **old PR 9948** by `guimsolutions` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9948`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > This branch conflicts with the current `main` and needs a rebase. > `guimsolutions`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): ## Summary D3D-78, [assigned to `@guimsolutions`](https://github.com/ItsNotRexed/Leonida/issues/313#issuecomment-7072436551). Adds default and explicit `Texture1D`, `Texture1DArray`, and `Texture3D` UAVs to `CreateUnorderedAccessView`. Rebased onto upstream `main` at `f847748cc76bd3777f9c070c4034eb2fc1c04e64`, retaining the two linear D3D-78 commits. D3D-63 is already in `main` (`c7d5f8e8`). The rebased translator keeps upstream A16 2D mip addresses and typed 3D mip loads and uses the existing W-slice guard only for tagged UAVs. The Vulkan harness keeps upstream geometry and push-constant-tail support. The descriptor refusal test now starts its read-only resource in `COMMON` to comply with upstream resource-state validation. ## Implementation - Validate resource dimensions, formats, mips, and layer ranges. `Texture1D` uses storage bindings **17ÔÇô19**; storage-only `Texture1DArray` uses **26ÔÇô28** (float, UINT, SINT). Default 1D-array UAVs cover the full array, but 1D-array SRVs remain unsupported. Upstream multisample SRV bindings **20ÔÇô25** are unchanged. Bindless sizing and the pipeline checker account for Vulkan descriptor limits, including update-after-bind limits. - Keep Vulkan array layers at `{0, 1}` for 3D UAVs. Partial W ranges require `VkImageViewSlicedCreateInfoEXT`, `imageSlicedViewOf3D`, and `robustImageAccess`; otherwise the runtime writes a null descriptor rather than exposing the entire mip. Tagged descriptors carry `FirstWSlice` and effective `WSize`. Storage coordinates use relative Z; float/UINT/SINT sampled loads rebase Z and return zero outside the range or at nonzero view-relative LOD. Untagged SRVs keep their original coordinates and LOD. - Preserve SHADER-151 typed sampled aliases and the separate coherent storage-load path. A tagged `R32_UINT` volume UAV whose descriptor SGPR group also feeds volume atomics uses the formatted storage view for load-after-atomic visibility in the same dispatch. Other sampled loads keep upstream visibility rules. 3D stores and atomics cannot write to the shared fallback on a lookup miss. - Check formatless writes for the actual view format and formatless reads for storage-only 1D arrays. The synthetic regression leaves the legacy `shaderStorageImage{Read,Write}WithoutFormat` device bits disabled to exercise Vulkan 1.3's per-format path. Emulated RGB9E5 retains its logical sampled format and `R32_UINT` backing; generic operations that would need unsupported repacking or unpacking take the safe fallback. - Keep compatible whole-mip CPU clears usable without bindless. Reject partial 3D clears and unsafe 1D/3D format reinterpretation; packed RGB9E5 clears retain bit-exact backing and existing upstream 2D typed attachment clears are unchanged. ## Validation for `476ad95f` Windows: RTX 4090 (NVIDIA 621.01) and Intel UHD 770 (32.0.101.7088). GPU checks used the Khronos validation layer and synchronization validation. | Check | Result | | --- | --- | | CMake/Ninja and CTest | Build passed. RTX 4090: **134 passed, 8 skipped, 1 disabled**. UHD 770: **131 passed, 9 skipped, 1 disabled, 2 baseline failures**. | | `--filter cs_texture_uav` | Passed on both GPUs in standard and `LEONIDA_PC_TAIL_UBO=1` modes: **14** cases (**10** compared with WARP) on RTX 4090 and **10** cases (**8** compared with WARP) on UHD 770. Intel lacks sliced 3D views; rejection of unsupported partial views was verified. No validation errors in the UAV readback test. | | Full GPU runner (`LEONIDA_W64_EMULATE=1`) | RTX 4090: **186 passed, 15 skipped**, `spirv-val` **206/206**. UHD 770: **168 passed, 33 skipped**, `spirv-val` **205/205 translated**. No failed GPU checks; each adapter adds two passing cases over exact upstream with unchanged skip counts. | | Direct Vulkan regressions | Packed RGB9E5 backing and `#782` double-copy replay passed on both GPUs without validation errors; the synchronization self-test confirmed the layer was active. `vk_pipeline_check` compiled compute and geometry fixtures in both push-constant modes on both GPUs. | | Python and CLI | **806 passed, 10 skipped** across the focused suites; **7,322 semantic tests run** with one upstream expected failure (`test_all_nan_keeps_src0`) and no unexpected failures. `compileall` and `make_game.py --help` passed. | On exact upstream `f847748c`, UHD 770 reproduced the same CTest failures: `d3d12_descriptor` (`lod_mismatches == 0`, line 2659) and `d3d12_subgroup` (`fragment_default`, line 611). The Intel fallback still cannot translate `ps_ij_computed` without `PerVertexKHR`; every translated module passed validation. CTest skips reflect missing game-derived fixtures, unavailable adapter features, or opt-in validation (run separately); GameInput was disabled without SDL3. Other GPU skips reflect unsupported features or fixtures covered by separate tests. Python skips reflect missing synthetic DXBC fixtures or POSIX-only tests. The requested `scripts/run_gpu_tests.py` integration is included: `--filter cs_texture_uav` dispatches the Windows differential test, and the full runner also exercises `cs_imgload_mip`. Runner unit tests cover pass, fail, missing executables, translation failure, and stale SPIR-V. The regression creates and copies descriptors through the D3D12 shim, then dispatches a Vulkan compute pipeline with Leonida's real bindless set 0; this is not an end-to-end D3D12 `Dispatch` test. Coverage includes UINT/FLOAT and typeless views, nonzero mips, invalid descriptors, preservation of neighboring layers and slices, coexistence with a typed 3D SRV, dynamic `image_load_mip`, and active/inactive add and compare-and-swap with `glc`. In a separate earlier native D3D12 probe, the RTX 4090 and UHD 770 clipped writes to the selected W range. WARP `10.0.26100.9818` rebased the view but wrote past a finite `WSize` under overdispatch. The oracle therefore compares in-range writes; Vulkan preservation of neighboring slices is checked independently. ## Project compliance and AI disclosure Only independently written synthetic fixtures were used. No proprietary game data, game shaders, keys, or protected content were used or included. AI-assisted implementation and review using OpenCode; validation is recorded above. Previous contribution: `#773` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:19 +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#267
No description provided.