Skip to content

TEST-544: d3d12_ia_bounds runs on 128-byte push-constant devices (--pc-tail-ubo fixtures) - #3013

Open
whoalin1 wants to merge 3 commits into
ItsNotRexed:mainfrom
whoalin1:test-544-ia-bounds-pc-tail
Open

whoalin1 wants to merge 3 commits into
ItsNotRexed:mainfrom
whoalin1:test-544-ia-bounds-pc-tail

Conversation

@whoalin1

@whoalin1 whoalin1 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claim: TEST-544 in #2891

Depends on: #2676 — runtime/test/d3d12_ia_bounds_test.cpp only exists there.
Depends on: #2402 — the layer's --pc-tail-ubo set-1 path. This branch is stacked on #2402's head d2300403 with #2676 applied on top, so the diff shows both commits until they land; when they merge this rebases onto main unchanged.

Root cause

The test declares one 144-byte push-constant range for its two stages: the index entries for vs_ia_bounds and ps_ia_bounds say push_constant_bytes: 144. A device whose maxPushConstantsSize is the 128-byte Vulkan minimum — the AMD Windows driver reports 128 on RDNA2 iGPUs — cannot hold that range, so PipelineState::user_data_layout refuses the PSO with the limit in the log and CreateGraphicsPipelineState returns E_NOTIMPL at make_context (line 228). None of the nine input-assembler bounds cases ran there.

Reproduced on the tree this branch is stacked on, without the change (Ryzen 5 7600 iGPU, Radeon(TM) Graphics gfx1036, AMD Windows driver 24.10.24, Vulkan 1.3.280, 128 bytes):

[rt] d3d12: Vulkan device: AMD Radeon(TM) Graphics (maxPushConstantsSize: 128 bytes)
[rt] d3d12: pipelines need 144 bytes of push constants; translate the shaders with --pc-tail-ubo for this device, whose maxPushConstantsSize is 128
line 228: SUCCEEDED(c.device->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&c.pso.p)))

exit 1. The same binary on the RTX 4070 SUPER (256 bytes) passed, 9 of 9 cases.

Changes

  • test/glsl/vs_ia_bounds.vert, test/glsl/ps_ia_bounds.frag: declare the user-data block the translator emits (s0..s31, then heap base and code base: 144 bytes). Compiled with -DPC_TAIL they declare s0..s31 alone, 128 bytes, and no set 1 — neither stage reads a root argument. The modules differ by 112 bytes, so the two compiles are real.
  • runtime/CMakeLists.txt: build vs_ia_bounds_tail.spv and ps_ia_bounds_tail.spv with -DPC_TAIL and pass them as LEONIDA_TEST_{VS,PS}_TAIL_SPV, the shape TEST-465: give four D3D12 fixtures a --pc-tail-ubo variant #2752 used for four other fixtures.
  • test/d3d12_ia_bounds_test.cpp: a second shader library whose index declares 128 push-constant bytes per stage with no pc_tail. run_layer takes a Fixture (module folder plus the two program containers) and sets LEONIDA_SHADERS before creating its standalone device.
    • A device whose maxPushConstantsSize is below 144 skips the 144-byte pair and runs the twin alone; the table labels its rows layer (pc-tail).
    • A device with room for both runs both, and every case's two results must agree; its rows are layer (144 B) and layer (pc-tail). The original path keeps its full coverage there.
  • Case E (the partial vertex whose colour lies outside the view) becomes information only where the bounded and the unbounded layer pass draw the same pixels and the host draws others, i.e. where the GPU itself reads past the view and no layer setting decides the case. Every other case keeps its pass/fail condition; A16, A32 and C still fail on that device if the sized index bind regresses.
  • docs/d3d12_vulkan.md: the two variants, and the measured per-vertex-versus-per-element behaviour of the AMD driver.

Testing

Windows 11 build 26200, MSVC 19.44.35228.0, RelWithDebInfo, Ninja. Built with powershell -NoProfile -ExecutionPolicy Bypass -File scripts\build_runtime.ps1: 368 of 368 targets, 0 errors.

ctest --test-dir runtime/build -R "^d3d12_ia_bounds$" --output-on-failure, with VK_LOADER_DRIVERS_SELECT, LEONIDA_VK_DEVICE and VK_LOADER_LAYERS_DISABLE=~implicit~:

GPU driver Vulkan push constants before after
AMD Radeon(TM) Graphics, Ryzen 5 7600 iGPU (gfx1036, RDNA2) AMD Windows 24.10.24 1.3.280 128 exit 1, PSO refused at line 228 Passed, 1.85 s; direct run: 8 cases match the host, 1 informational
NVIDIA RTX 4070 SUPER 610.88 1.4.341 256 exit 0, 9 of 9 Passed, 2.80 s; direct run: 9 cases match the host, 0 informational, and the --pc-tail-ubo pair drew the same probes as the 144-byte one

The informational case on the AMD device is E: D3D12 keeps the vertex's position (inside the view) and zeroes its colour (outside); the layer there draws the colour from memory instead, with or without the bounds, so robustBufferAccess2 is not deciding it. B1 and B2 (vertices wholly past the view) do match, so that driver's bound holds per vertex, not per element. A16, A32 and C match the host there, so the sized index bind and robustBufferAccess2 work for indices, which is what #2676 is about.

Full ctest on the AMD iGPU (the device this PR is for): 116 of 122 passed, 6 failed — d3d12_typeless_families, d3d12_fspx_compute, d3d12_msaa_draw, d3d12_set0_compute, d3d12_pipeline_library, d3d12_bundle. All six print the same pipelines need 144 bytes of push constants line, i.e. they are the class TEST-544 was: four are #2752's fixtures (TEST-465, unmerged), and d3d12_typeless_families and d3d12_bundle are not covered by it — posted as a finding in #2891. d3d12_ia_bounds is not among them any more.

Full ctest on the RTX 4070 SUPER: 122 of 122 passed (114 run, 8 skipped), 259 s, exit 0.

Not run in this pass: an Intel Arc run (the third 128-byte family) and Wine.

AI-assisted. No game data, keys or decryption: the fixtures are hand-written GLSL/HLSL and synthetic FSSM programs.

🤖 Generated with Capy (DeepSeek V4.1 Flash)

whoalin1 and others added 3 commits November 22, 2026 20:17
…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>
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 814850f on Windows 11, RTX 5080 (driver 616.92) and AMD Radeon iGPU gfx1036 (driver 26.10.1): ctest -R "^d3d12_ia_bounds$" (MSVC, RelWithDebInfo, glslang available so both fixture pairs are built, LEONIDA_VK_DEVICE set per run, device confirmed by the "Vulkan device:" line) — pass on both, 1/1 each.

  • RTX 5080: "input-assembler bounds: 9 cases match the host, 0 informational"; the --pc-tail-ubo pair ran and drew the same probes as the 144-byte pair.
  • AMD Radeon (gfx1036): same, 9 cases match the host, 0 informational; the --pc-tail-ubo pair ran and matched.
    Caveat: both devices report maxPushConstantsSize 256 bytes, so the 128-byte fallback was exercised as the second pair, not as the only possible one (that needs a Ryzen 7000 iGPU, RX 580 or Intel Arc).

AI-assisted.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 814850f 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_compute, d3d12_draw, d3d12_ia_bounds and shader_library: pass 20 of 20 runs, and pass under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • One new MSVC warning: C4456 at runtime/test/d3d12_compute_test.cpp:496 (bytes hides an earlier local bytes). A full build of main has no C4456 in this file; renaming one of them clears it.

AI-assisted (Claude Code).

NiiRoZz added a commit to NiiRoZz/Leonida that referenced this pull request Nov 22, 2026
…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>
@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested 814850f (merged onto main 1628210) 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

This is the 256-byte push-constant side; the PR body covers the 128-byte AMD iGPU.

AI-assisted (Claude).

@zzEmmazz

Copy link
Copy Markdown
Contributor

Tested 814850ff, applied alone on main 16282101: passes here, with one finding in the test.
Windows 11 (26200), MSVC 14.50 (VS 2026), Ninja RelWithDebInfo. Two GPUs: Ryzen 7 9700X iGPU (RDNA2, AMD 32.0.21042.62) and RTX 3070 (NVIDIA 610.74), picked with LEONIDA_VK_DEVICE.

  • Full ctest -j 4, compared test by test with the same main: iGPU 123 passed, 7 skipped, 1 disabled of 131 (main: 122 / 7 / 1 of 130); RTX 3070 122 passed, 8 skipped, 1 disabled (main: 121 / 8 / 1). The only difference is the new d3d12_ia_bounds, which passes.
  • d3d12_ia_bounds on both GPUs (both report maxPushConstantsSize 256, so both layouts ran): "9 cases match the host, 0 informational (144-byte push constants)" and "the --pc-tail-ubo pair drew the same probes as the 144-byte one". Case E matches D3D12 on both.
  • d3d12_compute, d3d12_draw and shader_library pass on both; the first two also with LEONIDA_VK_VALIDATION=1.
  • Finding: the new "this GPU reads past the view itself" rule is not limited to case E. driver_reads_past (d3d12_ia_bounds_test.cpp:637) is computed for every case, so any case whose bounded pass equals the LEONIDA_NO_IA_BOUNDS=1 pass and differs from the host becomes information only. Measured: with the sized index bind switched off in vulkan_replay.h (the if (vk.bind_index_buffer2) branch never taken, nothing else changed) the test exits 0 on both GPUs with "6 cases match the host, 3 informational"; the three are A16, A32 and C. The same local change under TEST-544: let d3d12_ia_bounds run at 128 push-constant bytes #2981's version of the test (identical runtime files, no such rule) fails with "3 case(s) differ". The description says A16, A32 and C still fail if the sized index bind regresses; here they did not. Limiting the rule to case E (a flag on the case) would keep that.

Not checked: a device whose maxPushConstantsSize is 128 (neither GPU here), so the twin-alone path and the PSO refusal were not run. The test could not be run without the stacked runtime commits: it does not compile there (device_index_bounds_exact is missing on main).

@iurysf

iurysf commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Same heads-up as on #2402, since this branch carries its code: user_data_layout({stages[0].entry, stages[1].entry}, user)
is right with this branch's stages[2] = {vs, ps}, but main's stages[] is {vs, gs, ps} since #2109, and in a trial
merge with main f847748c that line merges without a conflict. After a rebase, a --pc-tail-ubo PS (what
d3d12_ia_bounds' twin uses) would lose set 1. #3106's 7813e905 is the fix; whichever of #2402/#3013 is rebased first
needs it.

Checked with git only (the file at 814850ff, main, and a trial merge); not rebuilt.

AI-assisted (Claude).

NiiRoZz added a commit to NiiRoZz/Leonida that referenced this pull request Nov 22, 2026
…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>
@mesterember104-cpu

Copy link
Copy Markdown

Tested 814850f on Tiger Lake (Xe-LP) iGPU 0x9a78, driver 32.0.101.7088, Windows 11, MSVC 14.44: pass

Full ctest -C RelWithDebInfo: 106/113 counted pass — the 2 failures are the known Intel-main pair (d3d12_buffer_tiles, d3d12_descriptor), failing the same way on main, untouched by this PR (skips: shader_library_corpus, vk_sync_validation, d3d12_queue_wait, d3d12_rgb9e5_rtv, d3d12_first_light; gameinput Disabled).

The PR's own area: d3d12_ia_bounds — 9 cases match the host, 0 informational (144-byte push constants), and the test additionally verified "the --pc-tail-ubo pair drew the same probes as the 144-byte one" — both layouts ran and agreed on Intel. Our adapter reports maxPushConstantsSize: 256 bytes, so the 144-byte fixtures ran directly and the twin comparison is layered on top; the below-144 branch (144-byte pair skipped, twin alone) is not exercisable on this hardware, but the equivalence check this PR adds is confirmed green.

AI-assisted (GLM, operated by the account owner).

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.

8 participants