d3d12: validate CreateUnorderedAccessView descriptors for buffers and textures (OLD-5327) #578

Open
github-bot wants to merge 2 commits from github-bot/gh-578 into main AGit
Owner

@⁠Taffyyy-ops on GitHub · 2026-11-24 08:56 UTC · original
Taffyyy-ops:feat/d3d12-uav-validation → main · +724 −28 · 3 files · 2 commits · open

Claimed in the coordination issue as: OLD-5327 (#14)

What and why

Carried over from the closed upstream ItsNotRexed/Leonida PR #5327 and rebased cleanly onto ubiquitarianism/leonida main (0e888f03b, 5f82c7282).

Validates CreateUnorderedAccessView descriptors for buffers and textures in runtime/shims/d3d12_vulkan_device.cpp so malformed or unsupported views leave a null descriptor rather than crashing or aliasing invalid ranges/formats:

  • Buffer UAVs: reject unsupported D3D12_BUFFER_UAV_FLAGS, raw flag without DXGI_FORMAT_R32_TYPELESS, non-zero StructureByteStride on non-structured views, zero NumElements, overflow-safe element-range bounds (FirstElement / NumElements), and overflow-safe counter offset bounds (CounterOffsetInBytes).
  • Texture UAVs: reject multisampled textures, sRGB (is_srgb_format) / typeless / depth-stencil / block-compressed / 96-bit / B8G8R8X8 view formats, invalid dimensions and mip/plane/array slice bounds (including D3D12_UAV_DIMENSION_TEXTURE2DARRAY with ArraySize == UINT_MAX), and check storage layer bounds in write_image_descriptor (returning false and skipping note_shader_image when refused, including unregistered bindless storage images).
  • Coexists with main's mutable R9G9B9E5_SHAREDEXP, B5G5R5A1_UNORM, and 8-bit sRGB UAV resource backing (57d08d2fd, 0dc7f58e5).
  • Adds runtime/test/d3d12_uav_validation_test.cpp (d3d12_uav_validation in runtime/CMakeLists.txt).

Tested

Built cleanly with MSVC 19.44 / Ninja (cmake --build runtime/build, 0 new /W4 warnings on modified files) and tested on Windows 11 + NVIDIA GeForce RTX 5060 Laptop GPU (driver 621.24, validation off locally):

  • d3d12_uav_validation -> Passed (0.73 s)
  • d3d12_uav_clear -> Passed
  • d3d12_b5g5r5a1_uav -> Passed (0.55 s)
  • d3d12_srgb_uav -> Passed (0.71 s)
  • d3d12_r9g9b9e5_uav -> Passed
  • d3d12_descriptor -> Passed (0.47 s; sampling shader skipped: no glslangValidator)
  • d3d12_texture1d -> Passed (1.22 s)
  • python -I scripts/check_no_game_data.py -> exit 0
  • git diff --check upstream/main..HEAD -> exit 0

GPUs tested: NVIDIA GeForce RTX 5060 Laptop GPU (driver 621.24, Windows 11, validation layers not installed locally)

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.
**@⁠Taffyyy-ops** on GitHub · 2026-11-24 08:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/578) `Taffyyy-ops:feat/d3d12-uav-validation` → `main` · +724 −28 · 3 files · 2 commits · open Claimed in the coordination issue as: OLD-5327 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Carried over from the closed upstream `ItsNotRexed/Leonida` PR #5327 and rebased cleanly onto `ubiquitarianism/leonida` `main` (`0e888f03b`, `5f82c7282`). Validates `CreateUnorderedAccessView` descriptors for buffers and textures in `runtime/shims/d3d12_vulkan_device.cpp` so malformed or unsupported views leave a null descriptor rather than crashing or aliasing invalid ranges/formats: - Buffer UAVs: reject unsupported `D3D12_BUFFER_UAV_FLAGS`, raw flag without `DXGI_FORMAT_R32_TYPELESS`, non-zero `StructureByteStride` on non-structured views, zero `NumElements`, overflow-safe element-range bounds (`FirstElement` / `NumElements`), and overflow-safe counter offset bounds (`CounterOffsetInBytes`). - Texture UAVs: reject multisampled textures, sRGB (`is_srgb_format`) / typeless / depth-stencil / block-compressed / 96-bit / `B8G8R8X8` view formats, invalid dimensions and mip/plane/array slice bounds (including `D3D12_UAV_DIMENSION_TEXTURE2DARRAY` with `ArraySize == UINT_MAX`), and check storage layer bounds in `write_image_descriptor` (returning `false` and skipping `note_shader_image` when refused, including unregistered bindless storage images). - Coexists with `main`'s mutable `R9G9B9E5_SHAREDEXP`, `B5G5R5A1_UNORM`, and 8-bit sRGB UAV resource backing (`57d08d2fd`, `0dc7f58e5`). - Adds `runtime/test/d3d12_uav_validation_test.cpp` (`d3d12_uav_validation` in `runtime/CMakeLists.txt`). ### Tested Built cleanly with MSVC 19.44 / Ninja (`cmake --build runtime/build`, 0 new `/W4` warnings on modified files) and tested on Windows 11 + NVIDIA GeForce RTX 5060 Laptop GPU (driver 621.24, validation off locally): - `d3d12_uav_validation` -> Passed (0.73 s) - `d3d12_uav_clear` -> Passed - `d3d12_b5g5r5a1_uav` -> Passed (0.55 s) - `d3d12_srgb_uav` -> Passed (0.71 s) - `d3d12_r9g9b9e5_uav` -> Passed - `d3d12_descriptor` -> Passed (0.47 s; sampling shader skipped: no `glslangValidator`) - `d3d12_texture1d` -> Passed (1.22 s) - `python -I scripts/check_no_game_data.py` -> exit 0 - `git diff --check upstream/main..HEAD` -> exit 0 GPUs tested: NVIDIA GeForce RTX 5060 Laptop GPU (driver 621.24, Windows 11, validation layers not installed locally) 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:09:41 +00:00
Author
Owner

@⁠Taffyyy-ops on GitHub · 2026-11-24 20:09 UTC · original

Rebased onto upstream/main (6293c1c4f, 0 conflicts) to pick up #892 (SHADER-1266 TFE fixture expectations) and ce9bf43c5 (test_tool_stdout_encoding.py), which caused the prior stale-base failures in linux-gpu-tools, macos, macos-python, and stdlib-tests-linux (while check hit the 15m timeout and windows already passed).

Local verification after rebase (upstream/main @ 6293c1c4f, 100% synthetic tests)

  • Full runtime build (cmake --build runtime/build, MSVC 19.44 + Ninja): 403/403 steps succeeded, 0 errors, 0 warnings in runtime/shims/d3d12_vulkan_device.cpp or runtime/test/d3d12_uav_validation_test.cpp.
  • NVIDIA GeForce RTX 5060 Laptop GPU (driver 32.0.16.2124 / 621.24, Windows 11): 7/7 targeted CTests passed (16.65s) — d3d12_uav_validation, d3d12_uav_clear, d3d12_b5g5r5a1_uav, d3d12_srgb_uav, d3d12_r9g9b9e5_uav, d3d12_vulkan_device, crt_timed_wait.
  • Intel(R) RaptorLake-S Mobile Graphics Controller (driver 32.0.101.7026, Windows 11): 6/7 targeted CTests passed — d3d12_uav_validation, d3d12_uav_clear, d3d12_b5g5r5a1_uav, d3d12_r9g9b9e5_uav, d3d12_vulkan_device, and crt_timed_wait all passed; in d3d12_srgb_uav, both UAV clears matched WARP with 0 validation errors (the 2 RTV clears differed by 1 LSB on Intel 0xbb vs WARP 0xbc, a pre-existing Intel RTV sRGB rounding difference unrelated to CreateUnorderedAccessView).
  • Python & hygiene checks: python -I tests/test_ctest_registration.py (4/4 OK), python -I tests/test_tool_stdout_encoding.py (4/4 OK), python -I scripts/check_no_game_data.py (exit 0), git diff --check upstream/main..HEAD (exit 0).
**@⁠Taffyyy-ops** on GitHub · 2026-11-24 20:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/578#issuecomment-7143112814) Rebased onto `upstream/main` (`6293c1c4f`, 0 conflicts) to pick up `#892` (`SHADER-1266` TFE fixture expectations) and `ce9bf43c5` (`test_tool_stdout_encoding.py`), which caused the prior stale-base failures in `linux-gpu-tools`, `macos`, `macos-python`, and `stdlib-tests-linux` (while `check` hit the 15m timeout and `windows` already passed). ### Local verification after rebase (`upstream/main` @ `6293c1c4f`, 100% synthetic tests) - **Full runtime build (`cmake --build runtime/build`, MSVC 19.44 + Ninja):** `403/403` steps succeeded, `0` errors, `0` warnings in `runtime/shims/d3d12_vulkan_device.cpp` or `runtime/test/d3d12_uav_validation_test.cpp`. - **NVIDIA GeForce RTX 5060 Laptop GPU (driver `32.0.16.2124` / `621.24`, Windows 11):** `7/7` targeted CTests passed (`16.65s`) — `d3d12_uav_validation`, `d3d12_uav_clear`, `d3d12_b5g5r5a1_uav`, `d3d12_srgb_uav`, `d3d12_r9g9b9e5_uav`, `d3d12_vulkan_device`, `crt_timed_wait`. - **Intel(R) RaptorLake-S Mobile Graphics Controller (driver `32.0.101.7026`, Windows 11):** `6/7` targeted CTests passed — `d3d12_uav_validation`, `d3d12_uav_clear`, `d3d12_b5g5r5a1_uav`, `d3d12_r9g9b9e5_uav`, `d3d12_vulkan_device`, and `crt_timed_wait` all passed; in `d3d12_srgb_uav`, both UAV clears matched WARP with `0` validation errors (the 2 RTV clears differed by 1 LSB on Intel `0xbb` vs WARP `0xbc`, a pre-existing Intel RTV sRGB rounding difference unrelated to `CreateUnorderedAccessView`). - **Python & hygiene checks:** `python -I tests/test_ctest_registration.py` (`4/4` OK), `python -I tests/test_tool_stdout_encoding.py` (`4/4` OK), `python -I scripts/check_no_game_data.py` (`exit 0`), `git diff --check upstream/main..HEAD` (`exit 0`).
Author
Owner

@⁠Taffyyy-ops on GitHub · 2026-11-25 10:01 UTC · original

Rebased onto upstream/main (3de22a19047b168d28a7a11152bf05d18ed0062e) at ebc26f9cc (7dc12126f + ebc26f9cc), resolving the merge conflicts in runtime/shims/d3d12_vulkan_device.cpp and updating runtime/test/d3d12_uav_validation_test.cpp:

  • Buffer UAVs (write_buffer_uav / write_buffer_uav_at): Kept the split with write_buffer_uav_at (used by Xbox device slot 71) and applied the descriptor checks (D3D12_BUFFER_UAV_FLAG_RAW validation, non-structured StructureByteStride == 0, non-zero NumElements, overflow-safe bounds against width, and overflow-safe counter validation requiring structured non-RAW views).
  • Texture UAVs (CreateUnorderedAccessView / write_image_descriptor): Kept ImageViewUse (sampled, storage, depth_stencil_uav), D3D12_UAV_DIMENSION_TEXTURE1DARRAY, D3D12_UAV_DIMENSION_TEXTURE3D, and Xbox depth-stencil UAVs (depth_uav), applying multisampled/sRGB/typeless/compressed/96-bit/B8G8R8X8 rejections and TEXTURE1D/TEXTURE2D/TEXTURE2DARRAY bounds/plane checks on color textures while making write_image_descriptor return bool.
  • Tests (d3d12_uav_validation_test.cpp): Passed vk.robust_image_access / vk.sliced_3d_uav, updated default TEXTURE1DARRAY/TEXTURE3D checks to positive controls with out-of-range TEXTURE1DARRAY/TEXTURE3D rejections, and retained TEXTURE2DARRAY ArraySize == UINT_MAX rejection checks.

Local Verification (AI-assisted, Windows 11)

  • Build: MSVC 19.44 (vcvars64.bat + Ninja), 742/742 targets built (0 errors, 0 new /W4 warnings in PR files).
  • NVIDIA GeForce RTX 5060 Laptop GPU (driver 32.0.16.2124): 10/10 targeted CTests passed (d3d12_vulkan_device, d3d12_uav_clear, d3d12_uav_validation, d3d12_b5g5r5a1_uav, d3d12_srgb_uav, d3d12_r9g9b9e5_uav, d3d12_existing_heap, d3d12_texture_uav, xbox_depth_storage, crt_timed_wait; 27.26s).
  • Intel RaptorLake-S Mobile Graphics Controller (driver 32.0.101.7026): 8/10 targeted CTests passed (d3d12_uav_validation, d3d12_texture_uav, d3d12_uav_clear, d3d12_b5g5r5a1_uav, d3d12_r9g9b9e5_uav, xbox_depth_storage, d3d12_vulkan_device, crt_timed_wait). The 2 failures are pre-existing/unrelated (d3d12_srgb_uav 1-LSB Intel RTV clear rounding while UAV clears match WARP; d3d12_existing_heap slot-133 buffer 0x400/0x200 VK_ERROR_DEVICE_LOST while its placed texture UAV check passes).
  • Python & hygiene: test_ctest_registration.py (5/5 OK), test_vulkan_extension_guards.py (3/3 OK), check_no_game_data.py (exit 0), git diff --check upstream/main..HEAD (exit 0). (test_tool_stdout_encoding.py has 1 pre-existing failure on upstream/main's tools/compute_heap_layout_census.py from c8f7515e2.)
**@⁠Taffyyy-ops** on GitHub · 2026-11-25 10:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/578#issuecomment-7159124408) Rebased onto `upstream/main` (`3de22a19047b168d28a7a11152bf05d18ed0062e`) at `ebc26f9cc` (`7dc12126f` + `ebc26f9cc`), resolving the merge conflicts in `runtime/shims/d3d12_vulkan_device.cpp` and updating `runtime/test/d3d12_uav_validation_test.cpp`: - **Buffer UAVs (`write_buffer_uav` / `write_buffer_uav_at`):** Kept the split with `write_buffer_uav_at` (used by Xbox device slot 71) and applied the descriptor checks (`D3D12_BUFFER_UAV_FLAG_RAW` validation, non-structured `StructureByteStride == 0`, non-zero `NumElements`, overflow-safe bounds against `width`, and overflow-safe counter validation requiring structured non-RAW views). - **Texture UAVs (`CreateUnorderedAccessView` / `write_image_descriptor`):** Kept `ImageViewUse` (`sampled`, `storage`, `depth_stencil_uav`), `D3D12_UAV_DIMENSION_TEXTURE1DARRAY`, `D3D12_UAV_DIMENSION_TEXTURE3D`, and Xbox depth-stencil UAVs (`depth_uav`), applying multisampled/sRGB/typeless/compressed/96-bit/`B8G8R8X8` rejections and `TEXTURE1D`/`TEXTURE2D`/`TEXTURE2DARRAY` bounds/plane checks on color textures while making `write_image_descriptor` return `bool`. - **Tests (`d3d12_uav_validation_test.cpp`):** Passed `vk.robust_image_access` / `vk.sliced_3d_uav`, updated default `TEXTURE1DARRAY`/`TEXTURE3D` checks to positive controls with out-of-range `TEXTURE1DARRAY`/`TEXTURE3D` rejections, and retained `TEXTURE2DARRAY` `ArraySize == UINT_MAX` rejection checks. ### Local Verification (AI-assisted, Windows 11) - **Build:** MSVC 19.44 (`vcvars64.bat` + Ninja), `742/742` targets built (`0` errors, `0` new `/W4` warnings in PR files). - **NVIDIA GeForce RTX 5060 Laptop GPU (driver `32.0.16.2124`):** `10/10` targeted CTests passed (`d3d12_vulkan_device`, `d3d12_uav_clear`, `d3d12_uav_validation`, `d3d12_b5g5r5a1_uav`, `d3d12_srgb_uav`, `d3d12_r9g9b9e5_uav`, `d3d12_existing_heap`, `d3d12_texture_uav`, `xbox_depth_storage`, `crt_timed_wait`; `27.26s`). - **Intel RaptorLake-S Mobile Graphics Controller (driver `32.0.101.7026`):** `8/10` targeted CTests passed (`d3d12_uav_validation`, `d3d12_texture_uav`, `d3d12_uav_clear`, `d3d12_b5g5r5a1_uav`, `d3d12_r9g9b9e5_uav`, `xbox_depth_storage`, `d3d12_vulkan_device`, `crt_timed_wait`). The `2` failures are pre-existing/unrelated (`d3d12_srgb_uav` 1-LSB Intel RTV clear rounding while UAV clears match WARP; `d3d12_existing_heap` slot-133 buffer `0x400`/`0x200` `VK_ERROR_DEVICE_LOST` while its placed texture UAV check passes). - **Python & hygiene:** `test_ctest_registration.py` (`5/5` OK), `test_vulkan_extension_guards.py` (`3/3` OK), `check_no_game_data.py` (exit `0`), `git diff --check upstream/main..HEAD` (exit `0`). (`test_tool_stdout_encoding.py` has `1` pre-existing failure on `upstream/main`'s `tools/compute_heap_layout_census.py` from `c8f7515e2`.)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/578/head:github-bot/gh-578'
git switch 'github-bot/gh-578'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-578'
git switch 'github-bot/gh-578'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-578'
git switch 'github-bot/gh-578'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-578'
git switch 'main'
git merge --squash 'github-bot/gh-578'
git switch 'main'
git merge --ff-only 'github-bot/gh-578'
git switch 'main'
git merge 'github-bot/gh-578'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.