Skip to content

TEST-613: d3d12_bundle and d3d12_typeless_families run on 128-byte push-constant devices - #3106

Open
NiiRoZz wants to merge 5 commits into
ItsNotRexed:mainfrom
NiiRoZz:test-613-pc-tail-twins
Open

NiiRoZz wants to merge 5 commits into
ItsNotRexed:mainfrom
NiiRoZz:test-613-pc-tail-twins

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

TEST-613 (finding by @whoalin1 in #2891).

d3d12_bundle and d3d12_typeless_families declared 144 push-constant bytes in their shaders, so on a device whose maxPushConstantsSize is the 128-byte Vulkan minimum (AMD RDNA2 iGPUs on older drivers, RX 580, Intel Arc) their PSOs were refused and neither test reached its checks. This gives both a --pc-tail-ubo twin, as #3013 did for d3d12_ia_bounds.

  • d3d12_bundle: reuses d3d12_draw_test's -DPC_TAIL builds of vs_draw/ps_draw from a second library folder (VS 128 bytes, no set 1; PS 128 bytes with the heap base in the set-1 block). Every scenario and the layer-only checks run with the 144-byte shaders where the device has room, and with the twins on a layer device limited to 128 bytes. Both are held to the same expected grids.
  • d3d12_typeless_families: vs_fullscreen.vert leaves out heap_base/code_base under -DPC_TAIL (the pixel shaders declare no push constants). Each draw runs on both layouts and is compared with the host. The clears are unchanged.
  • A device below 144 bytes runs the twins alone.
  • docs/d3d12_vulkan.md: one sentence for each test.

Rebased on main aa2988c

The stack (#2402, #2981, #3013 and this PR) was rebased over 1,300 commits of main. #2402, #2981 and #3013 hadn't been rebased by their authors yet, so their conflicts were resolved here too:

The last commit (809612d3) fixes a bug in #2402 that the first rebase exposed. #2402 built the graphics user-data layout from {stages[0], stages[1]}, but since #2109 the stages are {vs, gs, ps}. That made stages[1] the empty GS slot, so a --pc-tail-ubo PS got no set 1 in its pipeline layout (VUID-07988) and drew nothing. The fix passes all three stages, the same slip 81ec7f7 fixed for the f16 link. #2402's author may want to fold it into #2402.

After the rebase, d3d12_draw_test, d3d12_bundle, d3d12_typeless_families, d3d12_ia_bounds, d3d12_compute (with main's SRV checks) and d3d12_conservative_raster all pass on both GPUs below, with zero validation errors.

Tested

With LEONIDA_VK_VALIDATION=1, Windows 11, MSVC 14.44, zero validation errors:

Test RTX 5090 (NVIDIA 621.35) AMD Radeon iGPU (AMD 26.5.2)
d3d12_bundle 10 scenarios with both layouts, 20 host comparisons, 0 failures same
d3d12_typeless_families 16 of 16 draws equal the host 16 of 16
d3d12_draw_test (shares vs_fullscreen.vert) pass pass

Both devices report 256 push-constant bytes, so the 128-byte case ran on the simulated limit (max_push_constants_size = 128, push_constants_need_fallback), the way d3d12_draw_test checks its own twin. A run on a real 128-byte device would be welcome.

Dependencies

Depends on: #3013
Depends on: #2402

This branch is stacked on #3013's head, so the diff against main includes #2402, #2981 and #3013's commits until they land. Only the last two commits are this PR (the TEST-613 twins and the stage fix). #2912 has merged and is included.

AI-assisted (Claude Code). No game data.

🤖 Generated with Claude Code

@Bj0rnis

Bj0rnis commented Nov 22, 2026

Copy link
Copy Markdown

Tested d20e9d6c on NVIDIA GeForce RTX 5070 Ti (Blackwell, NVIDIA 621.24, Vulkan 1.4.357) and AMD Radeon(TM) Graphics (RDNA2 iGPU, AMD 2026.04.17, Vulkan 1.4.315), Windows 11: pass

Built with MSVC 19.44 / Ninja / Windows SDK 10.0.26100.0 / Vulkan SDK 1.4.363.0 (scripts\build_runtime.ps1), run with LEONIDA_VK_VALIDATION=1 and DISABLE_VULKAN_OBS_CAPTURE=1:

  • RTX 5070 Ti: ctest -R "^(d3d12_bundle|d3d12_com|d3d12_compute|d3d12_descriptor|d3d12_draw|d3d12_ia_bounds|d3d12_multithread|d3d12_queue_wait|d3d12_typeless_families|d3d12_vulkan_device|shader_library)$" -V — 11/11 passed, 0 Vulkan validation errors (d3d12_typeless_families: 82/82 clears matched host; --pc-tail-ubo simulated 128-byte compute/graphics checks matched 64/64 elements and 4096/4096 pixels).
  • AMD Radeon iGPU (LEONIDA_VK_DEVICE=AMD): same 11 tests — 11/11 passed, 0 Vulkan validation errors (82/82 clears matched host).

(Note: both GPUs on this machine expose maxPushConstantsSize: 256, so this verifies the 256-byte path + simulated 128-byte checks rather than a native 128-byte device.)

AI-assisted (Antigravity / Gemini); no game files used.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested d20e9d6 merged onto main 1628210 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 131/131.
  • d3d12_bundle, d3d12_compute, d3d12_draw, d3d12_ia_bounds, d3d12_typeless_families and shader_library: pass 20 of 20 runs, and pass under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • Warnings: none new from this PR (the fopen C4996 in d3d12_bundle_test.cpp is already on main).

AI-assisted (Claude Code).

@NiiRoZz
NiiRoZz force-pushed the test-613-pc-tail-twins branch from d20e9d6 to 7813e90 Compare November 22, 2026 20:10
NiiRoZz added a commit to NiiRoZz/Leonida that referenced this pull request Nov 22, 2026
ItsNotRexed#2402's user_data_layout call took {stages[0], stages[1]}, written when a
graphics PSO's stages were {vs, ps}. Since ItsNotRexed#2109 they are {vs, gs, ps}, so on
main stages[1] is the (usually empty) GS slot: the PS's pc_tail never reached
the pipeline layout, set 1 was left out, and a --pc-tail-ubo PS failed
VUID-VkGraphicsPipelineCreateInfo-layout-07988 and drew nothing
(d3d12_draw_test line 358, d3d12_bundle's twin run). All three stages are
passed now; user_data_layout skips the absent ones. This is the same slip
81ec7f7 fixed for the f16 halves link.

Found rebasing ItsNotRexed#3106 onto main f847748. With it, d3d12_draw_test,
d3d12_bundle, d3d12_typeless_families, d3d12_ia_bounds and d3d12_compute pass
with LEONIDA_VK_VALIDATION=1 and no validation error on an RTX 5090 (NVIDIA
621.35) and an AMD Radeon iGPU (AMD 26.5.2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CLHelper

Copy link
Copy Markdown
Contributor

Tested d20e9d6c on a real 128-byte push-constant device: pass, and the parent commit fails there, so this PR's commit is what makes the two tests run.

  • AMD Radeon 610M (RDNA2 iGPU, gfx1036), AMD driver 24.10.16 (32.0.11016.14003), maxPushConstantsSize: 128 bytes
  • NVIDIA GeForce RTX 4060 Laptop GPU, driver 576.80, 256 bytes
  • Windows 11 (26200), MSVC (VS 2022 Build Tools) + Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.0 (glslangValidator found)
  • LEONIDA_VK_VALIDATION=1, LEONIDA_VK_DEVICE set per GPU (device confirmed by the device: / Vulkan device: lines), then ctest -R "^(d3d12_bundle|d3d12_typeless_families|d3d12_ia_bounds|d3d12_compute|d3d12_draw|shader_library)$" -V
Radeon 610M (128 B) RTX 4060 (256 B)
ctest, 6 tests 6/6 passed 6/6 passed
validation messages 0 0

Radeon 610M, the twins alone:

  • d3d12_bundle: "this device's maxPushConstantsSize is 128, below the 144 bytes the full shaders declare: the --pc-tail-ubo twins run alone", then "bundles: 10 scenarios on the layer with the --pc-tail-ubo twins alone, 20 host comparisons, 0 failures"
  • d3d12_typeless_families: 82 clears, 0 differ; "8 draws compared with AMD Radeon(TM) 610M (the --pc-tail-ubo VS alone), 0 differ"
  • d3d12_ia_bounds: "8 cases match the host, 1 informational (--pc-tail-ubo)". The informational one is case E: the layer draws (229,26,0,255) (149,106,0,255) (53,202,0,255) (181,74,0,255) with and without the bounds, where the host draws (229,0,0,229) (149,0,0,149) (53,0,0,53) (181,0,0,181). So 24.10.16 keeps the colour of the partial vertex too, as the doc already records for 24.10.24. A16, A32 and C match the host only with the bounds (the "no bounds" pass draws the extra triangle).
  • d3d12_compute: "a 128-byte device built the tail PSO and 64/64 elements matched"; d3d12_draw: tail VS+PS 4096/4096 pixels; both skip their 144-byte passes with the 128-byte reason.

RTX 4060, both layouts: d3d12_bundle "10 scenarios on the layer with 144-byte push constants and the --pc-tail-ubo twins, 20 host comparisons, 0 failures"; d3d12_typeless_families 16 draws, 0 differ; d3d12_ia_bounds 9 of 9 match the host and "the --pc-tail-ubo pair drew the same probes as the 144-byte one".

Before: the parent 814850ff (#3013's head), built the same way, on the 610M: d3d12_bundle and d3d12_typeless_families both FAIL with "pipelines need 144 bytes of push constants; translate the shaders with --pc-tail-ubo for this device, whose maxPushConstantsSize is 128" (bundle at make_pso, typeless at "typeless 9 view 12 draw: the layer failed").

Not tested: the new head 7813e905 (rebased onto a newer main, plus the stages[2] fix). In the tree of d20e9d6c a graphics PSO's stages are still {vs, ps}, so that bug is not in what I ran.

No game files. AI-assisted.

@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested 7813e90 on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass on a 256-byte device; conflicts with #2981, #3023 and #3013

The branch already contains main 1628210 through its own merge of main, so the tree tested is the PR head.

AI-assisted (Claude).

@iurysf

iurysf commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Code read of 7813e905 (this PR's own commits b6912c81 and 7813e905; the GPU runs are already in): the change looks
right, with one stacking problem to sort out before any of #2402/#3013/#3106 lands.

Read with git only (grep of #2402's and #3013's heads, merge-base --is-ancestor); not rebuilt.

AI-assisted code read (Claude).

@iurysf

iurysf commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Correction to my earlier read of 7813e905: I wrote that the current heads of #2402 (d2300403) and #3013 (814850ff) still have the {stages[0], stages[1]} bug. They don't: their base still has Stage stages[2] = {vs, ps}, so that line is right there. The risk is the rebase. On main the stages are {vs, gs, ps} since #2109, and in a trial merge (git merge-tree origin/main d2300403) the user_data_layout({stages[0].entry, stages[1].entry}, user) line merges without a conflict, so after a rebase it would quietly pass the empty GS slot instead of the PS. 7813e905 is the fix; whichever of #2402/#3013 is rebased first should fold it in. I've left the same note on both.

AI-assisted code read (Claude).

whoalin1 and others added 3 commits November 22, 2026 23:12
…ush-constant devices

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

With --pc-tail-ubo (PR ItsNotRexed#2046), 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 wires that path through the D3D12 -> Vulkan layer:

- runtime/src/shader_library.h: ShaderEntry parses pc_tail.bytes into pc_tail_bytes (tested in 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, Dispatch, Draw); the three unsupported checks cover tail_set.
- 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 (so a --pc-tail-ubo stage that reads neither heap nor code base still fits 128 bytes), 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.
- Tests: d3d12_compute_test and d3d12_draw_test 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 the host GPU, and skip the 144-byte passes when run on a real 128-byte device.
- Docs: docs/d3d12_vulkan.md (sections 3.2, 5.2, Q13) and d3d12_com.h comment updated.

Step 3 of the uniform-buffer tail claimed in ItsNotRexed#1902.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
…fines

The index buffer was bound without a size into the GPU address arena, so an
index past the view read whatever followed it there, and a draw with no
index buffer read past the zero page. D3D12 reads such an index as 0.

Where the device has VK_KHR_maintenance5 and robustBufferAccess2, the index
buffer is now bound with vkCmdBindIndexBuffer2 and the view's size (the zero
page with its own size when none is bound), and robustBufferAccess2 is
enabled at device creation. Both are needed for the read to be defined, so
with either missing the old unsized bind is kept, with a log line.

d3d12_ia_bounds compares nine cases with the PC runtime: indices past R16
and R32 views, vertices past a view, a view ending inside a vertex, no index
buffer with a count past the zero page, and in-range controls.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The test's two stages declared one 144-byte push-constant range, so a device
whose maxPushConstantsSize is the 128-byte Vulkan minimum refused the PSO
(E_NOTIMPL at make_context) and none of the nine input-assembler bounds cases
ran there; the AMD Windows driver reports 128 bytes on RDNA2 iGPUs.

The fixtures now also come as a --pc-tail-ubo twin: the same GLSL compiled
with -DPC_TAIL, whose stages declare s0..s31 alone (128 bytes) and no set-1
tail, since neither stage reads a root argument. A device with room for both
layouts runs both and their probes must agree; one whose maxPushConstantsSize
is below 144 runs the twin alone, which is where the cases were measured on
RDNA2 hardware.

Case E is information only where the bounded and the unbounded layer pass
draw alike and the host differs: AMD's driver reads a vertex attribute past
its view instead of zeroing it, so the case is not the layer's to decide
there. A16, A32 and C keep their pass/fail condition on that device.

Stacked on ItsNotRexed#2402's head (d230040) with ItsNotRexed#2676 applied, because the test and
the layer path it needs are not on main yet.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
NiiRoZz and others added 2 commits November 22, 2026 23:13
…sh-constant devices

Both tests' shaders declared 144 push-constant bytes, so a device whose
maxPushConstantsSize is the 128-byte Vulkan minimum refused their PSOs and
neither reached its checks (d3d12_bundle_test.cpp:130 via make_pso).

d3d12_bundle reuses d3d12_draw_test's --pc-tail-ubo twins (vs_draw/ps_draw
compiled with -DPC_TAIL) from a second library folder, and runs every
scenario and the layer-only checks on a layer device limited to 128 bytes as
well as with the 144-byte shaders. d3d12_typeless_families gets a -DPC_TAIL
build of vs_fullscreen.vert (its pixel shaders declare no push constants) and
draws each case on both. A device below 144 bytes runs the twins alone. Both
layouts are held to the same grids or host bytes.

Tested with LEONIDA_VK_VALIDATION=1 on an RTX 5090 (NVIDIA 621.35) and an AMD
Radeon iGPU (AMD 26.5.2): bundles 10 scenarios with both layouts, 20 host
comparisons, 0 failures; typeless draws 16 of 16 equal the host;
d3d12_draw_test still passes. Both devices report 256 bytes, so the 128-byte
limit is simulated; a real 128-byte device has not run it.

Stacked on ItsNotRexed#3013 (and ItsNotRexed#2402), which add the fallback the twins need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ItsNotRexed#2402's user_data_layout call took {stages[0], stages[1]}, written when a
graphics PSO's stages were {vs, ps}. Since ItsNotRexed#2109 they are {vs, gs, ps}, so on
main stages[1] is the (usually empty) GS slot: the PS's pc_tail never reached
the pipeline layout, set 1 was left out, and a --pc-tail-ubo PS failed
VUID-VkGraphicsPipelineCreateInfo-layout-07988 and drew nothing
(d3d12_draw_test line 358, d3d12_bundle's twin run). All three stages are
passed now; user_data_layout skips the absent ones. This is the same slip
81ec7f7 fixed for the f16 halves link.

Found rebasing ItsNotRexed#3106 onto main f847748. With it, d3d12_draw_test,
d3d12_bundle, d3d12_typeless_families, d3d12_ia_bounds and d3d12_compute pass
with LEONIDA_VK_VALIDATION=1 and no validation error on an RTX 5090 (NVIDIA
621.35) and an AMD Radeon iGPU (AMD 26.5.2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Vonsek

Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 809612d on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran ctest -R "^(d3d12_bundle|d3d12_compute|d3d12_draw|d3d12_ia_bounds|d3d12_typeless_families|shader_library)$" (the tests this PR changes): pass on both GPUs, 6/6 each. Both devices report maxPushConstantsSize 256, so the 128-byte push-constant limit case this PR targets was not reproduced here. No game files.

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.

9 participants