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

Open
opened 2026-11-26 20:18:29 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/578
Author: @Taffyyy-ops
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: feat/d3d12-uav-validation


📝 Commits (2)

  • 7dc1212 d3d12: validate CreateUnorderedAccessView descriptors for buffers and textures
  • ebc26f9 d3d12: reject TEXTURE2DARRAY UAV ArraySize == UINT_MAX

📊 Changes

3 files changed (+724 additions, -28 deletions)

View changed files

📝 runtime/CMakeLists.txt (+9 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+88 -28)
➕ runtime/test/d3d12_uav_validation_test.cpp (+627 -0)

📄 Description

Claimed in the coordination issue as: OLD-5327 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7126487215)

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.

🔄 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/578 **Author:** [@Taffyyy-ops](https://github.com/Taffyyy-ops) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/d3d12-uav-validation` --- ### 📝 Commits (2) - [`7dc1212`](https://github.com/ubiquitarianism/leonida/commit/7dc12126f5a8b84afc280b0bb5ecca5f3943b713) d3d12: validate CreateUnorderedAccessView descriptors for buffers and textures - [`ebc26f9`](https://github.com/ubiquitarianism/leonida/commit/ebc26f9cc38f0e903bea2ad75f4279574a65e4a2) d3d12: reject TEXTURE2DARRAY UAV ArraySize == UINT_MAX ### 📊 Changes **3 files changed** (+724 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+9 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+88 -28) ➕ `runtime/test/d3d12_uav_validation_test.cpp` (+627 -0) </details> ### 📄 Description Claimed in the coordination issue as: OLD-5327 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7126487215) ### 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#621
No description provided.