Skip to content

TEST-544: let d3d12_ia_bounds run at 128 push-constant bytes - #2981

Open
RipcuBAN wants to merge 5 commits into
ProjectLeonida:mainfrom
RipcuBAN:test-544-ia-tail
Open

RipcuBAN wants to merge 5 commits into
ProjectLeonida:mainfrom
RipcuBAN:test-544-ia-tail

Conversation

@RipcuBAN

Copy link
Copy Markdown
Contributor

Claimed as TEST-544 in #2891. This branch is stacked on #2676 (which adds d3d12_ia_bounds), #2402 (the runtime tail support), #2752 (TEST-465) and current main ec8ec4c9; those commits remain in the diff until they land.

Depends on: #2676
Depends on: #2402
Depends on: #2752

What and why

d3d12_ia_bounds previously built 144-byte shaders, so PSO creation failed on a device limited to Vulkan's 128-byte minimum and none of its IA-bounds cases ran. Both fixtures now have a PC_TAIL variant: 128-byte push constants and no set-1 block, because neither shader reads the heap or code base. The test's shader library copies those variants and declares push_constant_bytes: 128. The nine IA-bounds cases are unchanged; nothing is skipped or weakened.

No game data, keys or decryption.

Tested

AI-assisted. Windows 10 build 19045, VS 2026 Community (Visual Studio 18 2026, x64), MSVC 19.51.36260, CMake 4.5.0-rc3, MSYS2 glslangValidator. Fresh build, 0 errors. Full ctest -C RelWithDebInfo -j 6 --output-on-failure:

GPU this PR
AMD Radeon(TM) Graphics, Ryzen 5 7600X iGPU (gfx1036, RDNA2), driver 23.40.02, 128 B 107 passed / 6 failed of 113
NVIDIA GeForce RTX 3060, driver 621.14, 256 B 112 passed / 1 failed of 113

The RTX 3060 failure is the known d3d12_vulkan_device; d3d12_ia_bounds passes 9/9 cases, 0 informational.

On the 7600X iGPU the test now executes instead of failing at PSO creation. Eight cases match the host; case E (a view ending 8 bytes into a vertex) differs because this driver zeroes more of the partial vertex than D3D12's per-element rule. docs/d3d12_vulkan.md already records that Vulkan allows other vertex inputs of the binding to read as out of range and another driver may zero the whole vertex. I deliberately left the check strict and did not add a driver-specific tolerance: the divergence is a real measured result, not something to hide.

The other five AMD failures are the same pre-existing host/WARP and driver cases as on current main.

🤖 Generated with Claude Code

whoalin1 and others added 5 commits November 22, 2026 18:44
…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>
The fspx compute, MSAA draw, set-0 compute and pipeline-library tests used
144-byte push constants, so their PSOs were refused on devices limited to the
Vulkan minimum of 128 bytes. Reuse the tail GLSL variants from ItsNotRexed#2402 and add
one for cs_set0_sample, with index metadata declaring set 1 and a 16-byte
pc_tail where the shaders read the heap or code base.

On the Ryzen 5 7600X iGPU (gfx1036, 128 bytes) all four tests now pass; the
AMD suite goes from 101/107 on ItsNotRexed#2402 to 105/107. On RTX 3060 they also pass;
only the known d3d12_vulkan_device failure and the d3d12_depth_resolve
parallel flake remain. No game files.

Co-Authored-By: Claude <noreply@anthropic.com>
Resolve runtime/test/d3d12_compute_test.cpp by keeping both sides: ItsNotRexed#2402's
dispatch_once helper and 128-byte tail path, and main's CachedPSO helpers and
host comparison. The CachedPSO block is nested in the fallback else branch
with the right indentation.

Rebuilt from scratch on VS 2026 x64: AMD 107/112 (main 100/112), NVIDIA
110/112 with the known d3d12_depth_resolve parallel flake (main 111/112).
No game data.

Co-Authored-By: Claude <noreply@anthropic.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>
Give both IA-bounds shaders a --pc-tail-ubo variant (128-byte push block,
no set-1 tail because neither reads the heap or code base) and point the
test's shader library at them. The nine IA-bounds cases are unchanged.

On the Ryzen 5 7600X iGPU the test now executes instead of failing PSO
creation: eight cases match the host, and case E shows the documented driver
difference where robustBufferAccess2 zeroes the whole partial vertex rather
than only its colour. RTX 3060 remains 9/9. No game files.

Co-Authored-By: Claude <noreply@anthropic.com>
@evilclanker9000

Copy link
Copy Markdown
Contributor

Tested 6e0f2a8 on Windows 11, RTX 5080 (driver 616.92) and AMD Radeon iGPU gfx1036 (driver 26.10.1): ctest -R "d3d12_ia_bounds|^shader_library$" (MSVC, RelWithDebInfo, glslang available so the 128-byte variants are built, LEONIDA_VK_DEVICE set per run, device confirmed by the "Vulkan device:" line) — pass on both, 2/2 each.

  • RTX 5080: d3d12_ia_bounds: "input-assembler bounds: 9 cases match the host, 0 informational"; shader_library passed.
  • AMD Radeon (gfx1036): same, 9 cases match the host, 0 informational, shader_library passed. Case E on the layer matches the host here; only the "layer, no bounds" row differs from the RTX 5080's.
    Caveat: both devices report maxPushConstantsSize 256 bytes, so this ran the new 128-byte shader variants but not on a 128-byte device (that needs the Ryzen 7000 iGPU or similar).

AI-assisted.

@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested 6e0f2a8 (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

AI-assisted (Claude).

@zzEmmazz

Copy link
Copy Markdown
Contributor

Tested 6e0f2a88, applied alone on main 16282101: pass.
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; no other test changed status.
  • d3d12_ia_bounds: "9 cases match the host, 0 informational" on both GPUs. Both report maxPushConstantsSize 256; the test now always loads the -DPC_TAIL modules, so the 128-byte shaders are what ran here.
  • Case E matches D3D12 per element on both GPUs (on this iGPU driver too).
  • d3d12_compute and d3d12_draw (simulated 128-byte device: 64/64 elements, 4096/4096 pixels), d3d12_fspx_compute, d3d12_msaa_draw, d3d12_pipeline_library, d3d12_set0_compute and shader_library pass on both, also with LEONIDA_VK_VALIDATION=1.
  • The test still guards the sized index bind: with vkCmdBindIndexBuffer2KHR never used in vulkan_replay.h (a one-line local change), d3d12_ia_bounds fails on both GPUs with "3 case(s) differ" (A16, A32, C).
  • After this change vs_ia_bounds.spv / ps_ia_bounds.spv (144 bytes) are still built and required by the #error guard, but the test no longer loads them, so the 144-byte layout of these two shaders is not run on any device.

Not checked: a device whose maxPushConstantsSize is 128 (neither GPU here), so the PSO refusal this fixes was not reproduced. The test could not be run without the stacked runtime commits: it does not compile there (device_index_bounds_exact is missing on main).

@Rossrocha

Copy link
Copy Markdown

Tested on AMD Radeon RX 6600 (RDNA2, gfx1032), Windows 11, Adrenalin 26.11.2 (Vulkan driver 32.0.21045.29003).

PR head 6e0f2a88 (it conflicts with main aa2988cc, so I tested the head on its own), fresh MSVC build:

  • d3d12_ia_bounds_test plus the other touched tests (d3d12_compute, d3d12_draw, d3d12_fspx_compute, d3d12_msaa_draw, d3d12_pipeline_library, d3d12_set0_compute, shader_library): all PASS, with and without LEONIDA_VK_VALIDATION=1
  • ctest: 130/130 passed, and 130/130 with LEONIDA_VK_VALIDATION=1
  • run_gpu_tests.py: 174/189 passed, 15 skipped (expected), native and with LEONIDA_W64_EMULATE=1

No failures on this hardware.

@mesterember104-cpu

Copy link
Copy Markdown

Tested 6e0f2a8 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 (114 tests: 2 failures are the known Intel-main pair d3d12_buffer_tiles + d3d12_descriptor, failing on main the same way; skips: shader_library_corpus, vk_sync_validation, d3d12_queue_wait, d3d12_rgb9e5_rtv, d3d12_first_light; gameinput Disabled — no SDL3 in this build, the PR does not touch it).

The PR's own area, run directly with LEONIDA_VK_VALIDATION=1: d3d12_ia_bounds — 9 cases match the host, 0 informational, identical to the author's RTX 3060 result. Note our adapter reports maxPushConstantsSize: 256 bytes, so the 144-byte fixtures ran directly here (the PC_TAIL twins were built but not exercised); on a real 128-byte device the twin path is what this PR enables, and our data point confirms the 144-byte path is unchanged on a device with room.

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

@RipcuBAN

Copy link
Copy Markdown
Contributor Author

Tested 6e0f2a88e on the AMD Radeon(TM) Graphics iGPU of a Ryzen 5 7600X (Raphael, gfx1036 / RDNA2), Windows 10 22H2, AMD driver 23.40.02, maxPushConstantsSize = 128, MSVC (VS 2026). LEONIDA_VK_DEVICE=AMD.

The 128-byte path works: the device logs the 128 B warning, the --pc-tail-ubo PSOs build, and cases A–D2 match the default adapter and WARP pixel for pixel (layer and layer-no-bounds).

d3d12_ia_bounds still exits 1, only on case E (partial vertex: a view of 3 vertices + 8 bytes that uses vertex 3):

E ... default adapter    (229,0,0,229) (149,0,0,149) ( 53,0,0, 53) (181,0,0,181)
E ... WARP               (229,0,0,229) (149,0,0,149) ( 53,0,0, 53) (181,0,0,181)
E ... layer              (226,0,0,226) (137,0,0,137) ( 31,0,0, 31) (173,0,0,173)
E ... layer, no bounds   (226,0,0,226) (137,0,0,137) ( 31,0,0, 31) (173,0,0,173)

"layer" and "layer, no bounds" agree with each other, so this looks like how the AMD driver fetches a vertex that only partly lies inside the bound range (the in-range part of vertex 3 seems to come back different or zeroed), not the push-constant tail. On the RTX 3060 (621.14, 256 B) in the same build, case E matches WARP exactly (229/149/53/181) and the test passes.

Possible options: accept the robustness variant for E on devices where it differs, or skip E when the partial-vertex fetch isn't exact.

@ramenbellic

Copy link
Copy Markdown

Thanks for the 128-byte work and the run on the Ryzen 5 7600X iGPU. #3013 claims the same item (TEST-544) and changes the same six files; it is MERGEABLE today and runs both the 144-byte and the 128-byte fixtures, while this one conflicts with main since 2026-11-22. Could you compare with #3013 and close this one if you agree it covers yours?

(PR cleanup: #8919.) AI-assisted (Claude Code).

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