[PR #767] OLD-2402: Runtime: D3D12 PSOs bind the --pc-tail-ubo set-1 block for 128-byte push-constant devices #806

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/767
Author: @whoalin1
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: pc-tail-runtime


📝 Commits (1)

  • a53ca73 Runtime: D3D12 PSOs bind the --pc-tail-ubo set-1 block for 128-byte push-constant devices

📊 Changes

12 files changed (+967 additions, -340 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+20 -12)
📝 runtime/CMakeLists.txt (+30 -3)
📝 runtime/shims/d3d12_com.h (+2 -2)
📝 runtime/shims/d3d12_vulkan_device.cpp (+191 -34)
📝 runtime/src/shader_library.h (+5 -0)
📝 runtime/src/vulkan_replay.h (+41 -23)
📝 runtime/test/d3d12_compute_test.cpp (+358 -208)
📝 runtime/test/d3d12_draw_test.cpp (+278 -53)
📝 runtime/test/glsl/cs_user_data.comp (+18 -2)
📝 runtime/test/glsl/ps_draw.frag (+15 -1)
📝 runtime/test/glsl/vs_draw.vert (+5 -1)
📝 runtime/test/shader_library_test.cpp (+4 -1)

📄 Description

Restores my open PR from the original repository (OLD-2402), rebased onto current main (2d73c242f).

Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7133003627

Summary

A Vulkan device whose maxPushConstantsSize is 128 bytes (AMD Windows driver on RDNA2 iGPUs, some Intel Arc drivers) cannot hold the 144-byte ShaderUserData push-constant block, so previously every D3D12 PSO was refused there with E_NOTIMPL.

With --pc-tail-ubo (already merged in main), translated shaders keep s0..s31 in 128 push-constant bytes and move the 16-byte tail (heap base, code base) to a uniform block at set 1, binding 0 when a stage reads it. This PR wires that path through the D3D12 → Vulkan layer:

  • runtime/src/shader_library.h: ShaderEntry parses pc_tail.bytes into pc_tail_bytes (covered by shader_library_test).
  • runtime/src/vulkan_replay.h: ComputePipeline and GraphicsPipeline carry push_bytes, tail_set, and tail_offset; detail::bind_user_data binds set 0 (if present), set 1 with dynamic offset (if present), and pushes push_bytes at all three push sites (ExecuteIndirect, Dispatch, Draw).
  • runtime/shims/d3d12_vulkan_device.cpp: DeviceState::pc_tail creates one UNIFORM_BUFFER_DYNAMIC descriptor over the arena (range 16) plus an empty set-0 layout once per device. PipelineState::user_data_layout sizes the push-constant range from each stage's push_constant_bytes / pc_tail_bytes (including VS+GS+PS), adds set 1 when any stage has pc_tail, writes the 16-byte tail once into the arena, and releases it on destruction. 144-byte shaders remain refused on <144-byte devices with a log pointing to --pc-tail-ubo.
  • runtime/test/d3d12_compute_test.cpp & runtime/test/d3d12_draw_test.cpp: verify 144-byte refusal and --pc-tail-ubo dispatch/draw (including VS without pc_tail + PS with set-1 tail) on both simulated 128-byte devices and real 128-byte GPUs, skipping the 144-byte passes on real 128-byte hardware.
  • docs/d3d12_vulkan.md & runtime/shims/d3d12_com.h: documentation updates.

Verification (rebased on 2d73c242f, LEONIDA_VK_VALIDATION=1)

  • CPU: shader_library_test — pass (rc=0)
  • NVIDIA GeForce RTX 4070 SUPER (Windows 11, driver 610.88, 256B push constants):
    • d3d12_compute_test (rc=0, 0 validation errors)
    • d3d12_draw_test (rc=0, 0 validation errors)
    • d3d12_bundle_test (rc=0, 0 validation errors)
    • d3d12_geometry_test (rc=0, 0 validation errors)
    • d3d12_mesh_test (LEONIDA_VK_VALIDATION=0, rc=0; VUID-07076 under validation is tracked separately in #506)
  • AMD Radeon(TM) Graphics (Ryzen 5 7600 RDNA2 iGPU, Windows 11, AMD driver 24.10.24, real 128B maxPushConstantsSize):
    • d3d12_compute_test (rc=0, 0 validation errors): --pc-tail-ubo 64/64 elements matched on simulated 128B device and real 128B GPU; 144B passes cleanly skipped
    • d3d12_draw_test (rc=0, 0 validation errors): --pc-tail-ubo VS+PS (VS without pc_tail, PS with set-1 tail) 4096/4096 pixels matched on simulated 128B device and real 128B GPU; 144B passes cleanly skipped

AI-assisted (Gemini 4 Neon).


🔄 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/767 **Author:** [@whoalin1](https://github.com/whoalin1) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pc-tail-runtime` --- ### 📝 Commits (1) - [`a53ca73`](https://github.com/ubiquitarianism/leonida/commit/a53ca73ca11bdc2b7b4bc48efdf3cfcb64eed120) Runtime: D3D12 PSOs bind the --pc-tail-ubo set-1 block for 128-byte push-constant devices ### 📊 Changes **12 files changed** (+967 additions, -340 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+20 -12) 📝 `runtime/CMakeLists.txt` (+30 -3) 📝 `runtime/shims/d3d12_com.h` (+2 -2) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+191 -34) 📝 `runtime/src/shader_library.h` (+5 -0) 📝 `runtime/src/vulkan_replay.h` (+41 -23) 📝 `runtime/test/d3d12_compute_test.cpp` (+358 -208) 📝 `runtime/test/d3d12_draw_test.cpp` (+278 -53) 📝 `runtime/test/glsl/cs_user_data.comp` (+18 -2) 📝 `runtime/test/glsl/ps_draw.frag` (+15 -1) 📝 `runtime/test/glsl/vs_draw.vert` (+5 -1) 📝 `runtime/test/shader_library_test.cpp` (+4 -1) </details> ### 📄 Description Restores my open PR from the original repository (OLD-2402), rebased onto current `main` (`2d73c242f`). Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7133003627 ### Summary A Vulkan device whose `maxPushConstantsSize` is 128 bytes (AMD Windows driver on RDNA2 iGPUs, some Intel Arc drivers) cannot hold the 144-byte `ShaderUserData` push-constant block, so previously every D3D12 PSO was refused there with `E_NOTIMPL`. With `--pc-tail-ubo` (already merged in `main`), translated shaders keep `s0..s31` in 128 push-constant bytes and move the 16-byte tail (heap base, code base) to a uniform block at set 1, binding 0 when a stage reads it. This PR wires that path through the D3D12 → Vulkan layer: - `runtime/src/shader_library.h`: `ShaderEntry` parses `pc_tail.bytes` into `pc_tail_bytes` (covered by `shader_library_test`). - `runtime/src/vulkan_replay.h`: `ComputePipeline` and `GraphicsPipeline` carry `push_bytes`, `tail_set`, and `tail_offset`; `detail::bind_user_data` binds set 0 (if present), set 1 with dynamic offset (if present), and pushes `push_bytes` at all three push sites (`ExecuteIndirect`, `Dispatch`, `Draw`). - `runtime/shims/d3d12_vulkan_device.cpp`: `DeviceState::pc_tail` creates one `UNIFORM_BUFFER_DYNAMIC` descriptor over the arena (range 16) plus an empty set-0 layout once per device. `PipelineState::user_data_layout` sizes the push-constant range from each stage's `push_constant_bytes` / `pc_tail_bytes` (including VS+GS+PS), adds set 1 when any stage has `pc_tail`, writes the 16-byte tail once into the arena, and releases it on destruction. 144-byte shaders remain refused on `<144`-byte devices with a log pointing to `--pc-tail-ubo`. - `runtime/test/d3d12_compute_test.cpp` & `runtime/test/d3d12_draw_test.cpp`: verify 144-byte refusal and `--pc-tail-ubo` dispatch/draw (including VS without `pc_tail` + PS with set-1 tail) on both simulated 128-byte devices and real 128-byte GPUs, skipping the 144-byte passes on real 128-byte hardware. - `docs/d3d12_vulkan.md` & `runtime/shims/d3d12_com.h`: documentation updates. ### Verification (rebased on `2d73c242f`, `LEONIDA_VK_VALIDATION=1`) - **CPU**: `shader_library_test` — pass (`rc=0`) - **NVIDIA GeForce RTX 4070 SUPER (Windows 11, driver 610.88, 256B push constants)**: - `d3d12_compute_test` (`rc=0`, 0 validation errors) - `d3d12_draw_test` (`rc=0`, 0 validation errors) - `d3d12_bundle_test` (`rc=0`, 0 validation errors) - `d3d12_geometry_test` (`rc=0`, 0 validation errors) - `d3d12_mesh_test` (`LEONIDA_VK_VALIDATION=0`, `rc=0`; `VUID-07076` under validation is tracked separately in #506) - **AMD Radeon(TM) Graphics (Ryzen 5 7600 RDNA2 iGPU, Windows 11, AMD driver 24.10.24, real 128B `maxPushConstantsSize`)**: - `d3d12_compute_test` (`rc=0`, 0 validation errors): `--pc-tail-ubo` 64/64 elements matched on simulated 128B device and real 128B GPU; 144B passes cleanly skipped - `d3d12_draw_test` (`rc=0`, 0 validation errors): `--pc-tail-ubo` VS+PS (VS without `pc_tail`, PS with set-1 tail) 4096/4096 pixels matched on simulated 128B device and real 128B GPU; 144B passes cleanly skipped AI-assisted (Gemini 4 Neon). --- <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#806
No description provided.