[PR #592] [CLOSED] fix(d3d12): fp16 fallback for R9G9B9E5 render targets (RT-RGB9E5-HALF) #634

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/592
Author: @derkoch1337
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: rt-rgb9e5-half


📝 Commits (3)

  • 62c1950 fix(d3d12): fp16 fallback for R9G9B9E5 render targets (RT-RGB9E5-HALF)
  • 07f7939 fix(d3d12): convert R9G9B9E5 fp16 copies at the logical footprint (RT-RGB9E5-HALF)
  • 06cddcf fix(d3d12): resolve RT-RGB9E5-HALF review holds

📊 Changes

12 files changed (+1021 additions, -303 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+20 -3)
📝 runtime/shims/d3d12_vulkan_device.cpp (+53 -6)
📝 runtime/src/depth24.h (+4 -1)
📝 runtime/src/depth24_convert.comp (+45 -1)
📝 runtime/src/depth24_convert.inc (+453 -261)
📝 runtime/src/queue_families.h (+7 -8)
📝 runtime/src/vulkan_depth24.h (+4 -1)
📝 runtime/src/vulkan_replay.h (+116 -11)
📝 runtime/src/vulkan_scratch.h (+2 -1)
📝 runtime/test/d3d12_clear_test.cpp (+10 -2)
📝 runtime/test/d3d12_r9g9b9e5_uav_test.cpp (+302 -3)
📝 runtime/test/vk_queue_test.cpp (+5 -5)

📄 Description

Item: RT-RGB9E5-HALF (claimed in #14). Credits lightelectriclife's finding.

Problem

On NVIDIA, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 has no COLOR_ATTACHMENT or STORAGE_IMAGE support, so the layer refused an ALLOW_RENDER_TARGET R9G9B9E5_SHAREDEXP texture with E_INVALIDARG. The Series S retail boot creates a 1920x1080 format-67 render target with ALLOW_RENDER_TARGET | ALLOW_UNORDERED_ACCESS and stops there.

What changes for the user

Such a render target is now backed by an R16G16B16A16_SFLOAT image instead of being refused. fp16 holds every shared-exponent value exactly, so the texture keeps its values (at twice the memory per texel); rendering, sampling and UAV access all work, and CheckFeatureSupport advertises RENDER_TARGET for the format. The resource is GPU-owned, so no CPU layout depends on the format. UAV-only textures keep the existing mutable R32_UINT emulation unchanged, and the request is still refused where fp16 cannot back it. This is the fp16 target fallback used in ivall/xcl #242.

Testing

AI-assisted. Built with VS 18 2026 (MSVC 14.51) and run on an NVIDIA GeForce RTX 5080, driver 610.88, with LEONIDA_VK_VALIDATION=1:

  • d3d12_r9g9b9e5_uav_test: the new render-target section creates the RT+UAV texture, clears it through the RTV and reads the fp16 texels back bit-exact; the existing UAV sections still match (6/6 WARP clears, 16/16 copies, 16/16 bindless round-trip). 0 validation errors.
  • Nearest gates d3d12_b5g5r5a1_uav_test, d3d12_srgb_uav_test, d3d12_uav_clear_test: all pass, 0 validation errors.

docs/d3d12_vulkan.md records the fallback.


🔄 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/592 **Author:** [@derkoch1337](https://github.com/derkoch1337) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `rt-rgb9e5-half` --- ### 📝 Commits (3) - [`62c1950`](https://github.com/ubiquitarianism/leonida/commit/62c1950c690a49491d72c73605ffabdea529ee3a) fix(d3d12): fp16 fallback for R9G9B9E5 render targets (RT-RGB9E5-HALF) - [`07f7939`](https://github.com/ubiquitarianism/leonida/commit/07f7939b9df3d6c3e435ec794f18731ed311d754) fix(d3d12): convert R9G9B9E5 fp16 copies at the logical footprint (RT-RGB9E5-HALF) - [`06cddcf`](https://github.com/ubiquitarianism/leonida/commit/06cddcf9fa7b13dd298f363d1c4bebf69f380d61) fix(d3d12): resolve RT-RGB9E5-HALF review holds ### 📊 Changes **12 files changed** (+1021 additions, -303 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+20 -3) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+53 -6) 📝 `runtime/src/depth24.h` (+4 -1) 📝 `runtime/src/depth24_convert.comp` (+45 -1) 📝 `runtime/src/depth24_convert.inc` (+453 -261) 📝 `runtime/src/queue_families.h` (+7 -8) 📝 `runtime/src/vulkan_depth24.h` (+4 -1) 📝 `runtime/src/vulkan_replay.h` (+116 -11) 📝 `runtime/src/vulkan_scratch.h` (+2 -1) 📝 `runtime/test/d3d12_clear_test.cpp` (+10 -2) 📝 `runtime/test/d3d12_r9g9b9e5_uav_test.cpp` (+302 -3) 📝 `runtime/test/vk_queue_test.cpp` (+5 -5) </details> ### 📄 Description Item: **RT-RGB9E5-HALF** (claimed in #14). Credits lightelectriclife's finding. ## Problem On NVIDIA, `VK_FORMAT_E5B9G9R9_UFLOAT_PACK32` has no `COLOR_ATTACHMENT` or `STORAGE_IMAGE` support, so the layer refused an `ALLOW_RENDER_TARGET` `R9G9B9E5_SHAREDEXP` texture with `E_INVALIDARG`. The Series S retail boot creates a 1920x1080 format-67 render target with `ALLOW_RENDER_TARGET | ALLOW_UNORDERED_ACCESS` and stops there. ## What changes for the user Such a render target is now backed by an `R16G16B16A16_SFLOAT` image instead of being refused. fp16 holds every shared-exponent value exactly, so the texture keeps its values (at twice the memory per texel); rendering, sampling and UAV access all work, and `CheckFeatureSupport` advertises `RENDER_TARGET` for the format. The resource is GPU-owned, so no CPU layout depends on the format. UAV-only textures keep the existing mutable `R32_UINT` emulation unchanged, and the request is still refused where fp16 cannot back it. This is the fp16 target fallback used in ivall/xcl #242. ## Testing AI-assisted. Built with VS 18 2026 (MSVC 14.51) and run on an NVIDIA GeForce RTX 5080, driver 610.88, with `LEONIDA_VK_VALIDATION=1`: - `d3d12_r9g9b9e5_uav_test`: the new render-target section creates the RT+UAV texture, clears it through the RTV and reads the fp16 texels back bit-exact; the existing UAV sections still match (6/6 WARP clears, 16/16 copies, 16/16 bindless round-trip). 0 validation errors. - Nearest gates `d3d12_b5g5r5a1_uav_test`, `d3d12_srgb_uav_test`, `d3d12_uav_clear_test`: all pass, 0 validation errors. `docs/d3d12_vulkan.md` records the fallback. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:32 +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#634
No description provided.