Skip to content

D3D-78: Support Texture1D, Texture1DArray and Texture3D UAVs - #773

Open
guimsolutions wants to merge 3 commits into
ItsNotRexed:mainfrom
guimsolutions:feat/d3d78-texture-uavs
Open

guimsolutions wants to merge 3 commits into
ItsNotRexed:mainfrom
guimsolutions:feat/d3d78-texture-uavs

Conversation

@guimsolutions

@guimsolutions guimsolutions commented Nov 22, 2026 •

Copy link
Copy Markdown

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.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Verified two live singleton UAVs of the same 3D resource and mip on 6429d47. The independent case used an 11×9×11 R32_UINT volume. At mip 1 the buffer readback covers 5×4×5 texels. I created both views through CreateUnorderedAccessView (FirstWSlice 1 and 3, WSize 1 each) before submitting work. A single command buffer dispatched the translated source-built shader twice with the real set 0, switching only the T# and inserting a compute memory barrier. Both dispatches covered all five relative Z positions.

Adapter Texels matching the CPU expectation Physical W planes changed Negative control using the first T# twice
NVIDIA RTX 5080, 616.92 100/100 1 and 3, all 20 texels in each 40/100 mismatches
AMD Radeon(TM) Graphics, 26.10.1 100/100 1 and 3, all 20 texels in each 40/100 mismatches

I initialized each texel to 17 + 3 × its linear index and expected one increment of 1000 + x + 16y on the two selected planes. The first texels on W=1 and W=3 changed from 77 to 1077 and from 197 to 1197. Reusing the first key made them 2077 and 197. The 60 texels on W=0,2,4 retained their inputs in every run.

The unchanged fixture also passed separately on both drivers (13 GPU cases, 10 compared with WARP). Vulkan validation was on. This exercises device-created UAVs and the translated shader through the direct Vulkan dispatch used by the fixture.

@guimsolutions
guimsolutions marked this pull request as ready for review November 22, 2026 02:59
@ismailchaka1

Copy link
Copy Markdown
Contributor

Tested 6429d47 on an NVIDIA GeForce RTX 4070 SUPER, driver 32.0.16.1088, Windows 11, MSVC 2022 (Ninja, RelWithDebInfo), LEONIDA_VK_VALIDATION=1: pass.

One note: d3d12_texture_uav_test isn't registered with ctest (it needs the translated .spv), so CI and a plain ctest run skip it; only run_gpu_tests.py or a manual run covers it.

No game files. AI-assisted.

@guimsolutions

Copy link
Copy Markdown
Author

Thanks @Vonsek for the two-live-UAV negative control. I merged main at 8df277f in 3bd9853 without rewriting the branch. The merged test also creates a typed 3D SRV of the same mip and checks that the existing partial UAV still writes only its chosen W range. RTX 4090 and UHD 770 validation passed for the applicable UAV and SRV cases; Intel explicitly rejects sliced UAVs. GitHub reports no conflicts on #773. #561 remains an open dependency and was not modified.

@guimsolutions

Copy link
Copy Markdown
Author

Thanks again to @Vonsek and @ismailchaka1 for taking the time to test this PR on different hardware!

I really appreciate the independent validation, the additional test coverage, and the detailed feedback. It's great to see the implementation working across multiple gpu's!

Thanks for helping make this pr more robust 🙌

@quackottu quackottu 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.

Tested 8dc50af on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 97% tests passed, 1 tests failed out of 31
  • d3d12_texture_uav_test (changed here), run as the PR describes with build.py ... cs_texture_uav (1 translated, passes spirv-val): exit 0, 0 validation errors, "texture UAVs: 13 GPU cases (10 compared with WARP), format/range/refusal checks passed"
  • d3d12_vulkan_device_test (changed here): exit=1 validation=0 | 10 validation errors
  • 30 test programs in the build pass with 0 validation errors
  • d3d12_clear_test fails (format 28 case 0 byte 2: Vulkan 7f, WARP 80) exactly as on main 67204bf, so not from this PR: NVIDIA rounds a 0.5 UNORM clear to 0x7f, which #521 addresses
  • d3d12_vulkan_device_test reports 10 synchronization-validation WRITE_AFTER_WRITE hazards on back-to-back copies (so ctest's d3d12_vulkan_device fails). main 8df277f shows the same 10 here, so not from this PR: it's @guimsolutions's finding in #634, which #782 addresses

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

@quackottu quackottu 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.

Suggestion (from running this on an RTX 5070 earlier): d3d12_texture_uav_test isn't run by ctest, run_gpu_tests.py or CI, because it needs the translated cs_texture_uav.spv; only the description shows the manual build.py + run steps. Since run_gpu_tests.py already translates runtime/test/shaders/*.asm, a branch for cs_texture_uav that runs d3d12_texture_uav_test <spirv>/cs_texture_uav.spv (SKIP on exit 77 or when WARP is unavailable, as the other harness branches do) would keep it from rotting after merge. Happy to send it as a follow-up PR once this lands if you'd rather keep this one as is.

@guimsolutions

Copy link
Copy Markdown
Author

Thanks @quackottu for the testing and the suggestion!

I've integrated d3d12_texture_uav_test into run_gpu_tests.py in f356ca7. The runner now builds and translates cs_texture_uav, validates the generated SPIR-V, and runs the UAV test automatically.

Skip handling (exit code 77), missing executables, translation failures, and stale SPIR-V detection are covered by runner tests.

I also merged the latest upstream changes available at the time, preserved the #782 synchronization fix, and revalidated on RTX 4090 and Intel UHD 770.

Thanks again for helping improve the test coverage!

@guimsolutions

Copy link
Copy Markdown
Author

Hi maintainers,

I'd appreciate some feedback on #773 (D3D-78).

The implementation has been independently validated across multiple GPUs, the requested automated test integration is complete, and I've been keeping the branch updated with upstream changes.

However, the GitHub Actions workflows are still waiting for approval, and frequent upstream merges keep introducing new conflicts.

Could you let me know if there are any technical or architectural concerns preventing this PR from moving forward?

I'm happy to address any outstanding issues. I'd just like to understand what's needed for a final review.

Thanks!

@guimsolutions

Copy link
Copy Markdown
Author

How many times i have to merge conflicts before merge? hahaha

@guimsolutions

Copy link
Copy Markdown
Author

done: D3D-78 #773

Hi @ItsNotRexed,

Could I please get a clear update on the status of PR #773?

I've repeatedly rebased this PR onto the latest main, resolved conflicts introduced by subsequent merge rounds, and followed your request to keep the commit history clean.

The implementation has been extensively tested on multiple GPUs, including independent validation from other contributors. I've also addressed the review feedback received so far.

However, the PR still hasn't received a substantive maintainer review, and GitHub Actions remain blocked pending approval.

At this point, I'm spending more time keeping the branch synchronized with main than working on the actual implementation.

To put this into perspective, the time I've spent repeatedly resolving conflicts and rebasing this PR could have been spent fixing dozens of other issues in the project. I'd much rather use that time contributing new functionality and resolving outstanding problems than repeatedly maintaining a completed implementation without knowing whether it will be reviewed.

Could you please clarify:

  • Is there a technical or architectural concern preventing this PR from being merged?
  • Is D3D-78 still something you intend to integrate?
  • Should I continue maintaining and rebasing this branch, or would you prefer that I stop until a review is scheduled?

I'm happy to address concrete feedback, and I understand that maintainers have many contributions to review. However, I need some clarity on whether continuing to invest time in this PR makes sense.

I genuinely want to contribute to the project, but the current cycle of repeated rebases without a clear path toward review or merging is becoming increasingly frustrating.

Thanks for your time.

Comment thread runtime/shims/d3d12_vulkan_device.cpp Outdated
return;
}
if (new_uav && state_.info.robust_image_access) {
const bool storage_read = view.type == g::ImageType::image_1d_array;

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.

[P2] Check formatless read support for 1D and 3D UAVs too. new_uav admits 1D, 1D-array, and 3D images, but this predicate enables the STORAGE_READ_WITHOUT_FORMAT check only for 1D-array. The translator accepts image_load ... glc for the 1D/3D dimensions and emits OpImageRead on an Unknown-format storage image; Vulkan requires the format to advertise VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT for that read. Unsupported formats can therefore pass view creation and fail later at dispatch. Please validate every dimension whose shaders can issue glc reads (or reject that path). Vulkan format-feature requirements.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks @Flyander, good catch!

I've confirmed and fixed the issue in commit 57cb669f.

The formatless storage-read validation now covers Texture1D, Texture1DArray, and Texture3D UAVs, requiring both VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT and VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT on the actual Vulkan view format.

Unsupported formats are rejected before bindless registration, leaving a null descriptor. The existing packed RGB9E5 path remains unchanged.

I've also added regression tests covering all format-feature combinations, nonzero mip levels, sliced 3D views, and the packed-format exception. The new tests reproduce the original issue and pass with the fix.

Validation results:

  • RTX 4090: 14 UAV GPU cases passed, 0 Vulkan validation errors.
  • Intel UHD 770: 10 UAV GPU cases passed, 0 Vulkan validation errors.
  • CMake/Ninja build and SPIR-V validation passed.
  • 269 focused Python tests passed.
  • Full CTest passed on NVIDIA. Intel's two unrelated failures reproduce on upstream main.

The branch has also been successfully rebased onto the latest upstream main, and GitHub reports it as mergeable.

Could you please take another look and confirm whether this addresses your review?

Thanks again for the detailed feedback!

D3D-78: keep storage-only 1D-array bindings separate from upstream multisample SRVs. Validate typed views and W ranges; use sliced storage views with tagged coordinates, typed loads, stores and R32_UINT atomics. Keep clears safe and align the existing descriptor, RGB9E5 and shader regressions with the runtime contract.

Reconstructs bf9201c and the implementation portions of the original branch through a56b858. D3D-63 resource creation already comes from upstream c7d5f8e.
Register the descriptor smoke test with CTest and run synthetic dispatches against the real bindless set and WARP. Cover sliced-volume atomics, typed mip loads, and runner failure/skip handling; document the ABI, limits, and test procedure.

Reconstructs 6429d47, 8dc50af, and the test and documentation resolutions through a56b858.
Coherent 1D and 3D loads and all 1D-array loads can issue OpImageRead on Unknown-format storage views. Require both per-format access bits before registering the view or writing its descriptor, while preserving the formatted RGB9E5 exception.

AI-assisted. Verified the synthetic UAV readback and format refusals with Vulkan validation on RTX 4090 (621.01) and UHD 770 (101.7088).
@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 57cb669 on NVIDIA GeForce RTX 4080, driver 617.42, Windows 11 (clang-cl cross-build): d3d12_texture_uav_test --descriptors-only, d3d12_r9g9b9e5_uav_test and d3d12_texture1d_test all exit 0. d3d12_r9g9b9e5_uav_test reports "UAV clears: 6/6 cases matched WARP bit-for-bit" and "16/16 HDR RGB9E5 texels matched"; d3d12_texture1d_test prints "PASS: d3d12_texture1d_test (1D views, 1DArray UAV + CopyTextureRegion round-trip)". The validation layer was not loaded (the "0 validation errors" is the test's own count), and the cs_texture_uav dispatch was not run.

AI-assisted.

@editrice

Copy link
Copy Markdown

Tested exact head 57cb669 on Windows 11, NVIDIA RTX 5070, driver 621.01, with MSVC 19.44 and Vulkan SDK 1.4.363.1. The synthetic cs_texture_uav fixture assembled, translated, and passed spirv-val. With LEONIDA_VK_VALIDATION=1 and VK_LAYER_KHRONOS_validation, the full d3d12_texture_uav_test dispatch passed in both standard and LEONIDA_PC_TAIL_UBO=1 modes: each ran 14 GPU cases, 10 compared with WARP, and passed the format/range/refusal checks with no VUID or validation errors. Focused Python suites passed: test_image_load_typed 28 passed/2 skipped, test_run_gpu_tests 44 passed, test_shader_checks 80 passed. This covers the full shader dispatch and validation-layer gap left by the earlier current-head descriptor-only review. Synthetic inputs only; no game data. AI-assisted.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants