Repository navigation
Translator: --pc-tail-ubo moves the push-constant tail to a uniform block (128-byte push-constant devices, 1/3) - #2046
Conversation
|
Tested
AI-assisted (Claude Code). |
Flyander
left a comment
There was a problem hiding this comment.
Reviewed the translator change and its contract/test coverage. The 128-byte tail layout is isolated behind the opt-in flag, preserves set 0, and the reported GPU/semantic checks cover the new rule. I found no blocking defect. I did not run tests; this approval covers step 1, with the separate Vulkan binding and D3D12 PSO integration still tracked as follow-ups.
|
Tested 6489f63 (as is, base 6a6704d) on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357), Arch Linux (kernel 6.18), llvm-mc 23.1.5, SPIRV-Tools v2026.4: pass. This device has more than 128 bytes of push constants, so it only checks that the default is unchanged and that the flag's output is valid; it cannot run the modules with the tail in a uniform block (that is #2048).
AI-assisted run (Claude). Counts only; nothing from the game leaves this machine. |
6489f63 to
8d89bfa
Compare
|
Tested the rebased head
Scope: I did not run the flag on the GPU. No game files. AI-assisted verification. |
…lock for 128-byte devices A device whose maxPushConstantsSize is 128, Vulkan's minimum (AMD's Windows driver on RDNA2 iGPUs, some Intel Arc drivers), can't take the 144-byte block (152 with --mesh-compute). With --pc-tail-ubo the push-constant block keeps s0..s31 (128 bytes), and the tail that follows them by default (heap base, code base, the --mesh-compute output address) becomes %pc_tail, a uniform block at set 1, binding 0, with the same members in the same order. It is declared only when the shader reads the tail; the index records "pc_tail" and 128 push-constant bytes, and "bindings" still lists set 0 only. Without the flag nothing changes. Step 1 of the uniform-buffer tail claimed in ItsNotRexed#1902; the GPU harnesses and the D3D12 layer that bind the block follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8d89bfa to
bf1c90e
Compare
…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>
|
Tested bf1c90e on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.
No game files. AI-assisted. |
|
Tested
No game files. AI-assisted (Claude Code). |
# Conflicts: # docs/design.md
…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>
…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>
Claimed in the coordination issue as: new item, the uniform-buffer tail for devices with 128 bytes of push constants (#1902 (comment)). This is step 1 of 3.
What and why
A device whose
maxPushConstantsSizeis 128, Vulkan's minimum, can't take the translator's 144-byte push-constant block (152 with--mesh-compute). AMD's Windows driver reports 128 on RDNA2 iGPUs (Radeon 680M on 22.40.84.06, 610M on 24.10.16.14, and the Ryzen 5 7600's iGPU on 24.10.24 here), and so do some Intel Arc drivers. Today the D3D12 layer refuses every PSO on such a device "until the uniform-buffer tail exists" (80e5caca), andvk_harnesscrashes or hangs there (#1873). This PR is the translator side of that tail.--pc-tail-ubo:--mesh-compute, the output address) becomes%pc_tail, a uniform block at set 1, binding 0, with the same members in the same order at offsets 0, 4, … (16 bytes, 24 with--mesh-compute). Set 1 is unused today, so set 0's update-after-bind table doesn't change.s_getpc_b64, or the--mesh-computeepilogue."pc_tail": {"set": 1, "binding": 0, "bytes": 16}(24 with--mesh-compute), and"push_constant_bytes"is 128 for every module."bindings"still lists set 0 only: the regex that builds it skips%pc_tail.mesh_compute_layout()reportspc_tail_address_dwords: [4, 5]in place ofaddress_dwords.pc_tail_chain(), so the flag changes the access chains and declarations and nothing else.Without the flag the output is unchanged (checked below).
docs/design.mdgets a contract row ("Push-constant tail as a uniform block"), and the "User data" and "Metadata index" rows mention it.Next steps, as claimed: (2)
vk_harness/vk_compute_testbind the block when the index asks for it, withLEONIDA_PC_TAIL_UBO=1for the runners, so a 128-byte device runs the tests that skip there today; (3) the D3D12 layer gives PSOs the set-1 layout and a per-PSO tail buffer instead ofE_NOTIMPLwhenpush_constants_need_fallbackis set.Tested
AI-assisted (Claude Code). Windows 11, Python 3.14.4, llvm-mc 21.1.8 (WSL Ubuntu 26.04), SPIRV-Tools v2026.4. No game files.
On GPUs, through step 2's test programs that bind the block (branch
whoalin1:pc-tail-gpu-compute, its PR follows),run_gpu_tests.py, whole suite:LEONIDA_PC_TAIL_UBOunsetLEONIDA_PC_TAIL_UBO=1maxPushConstantsSize128With the flag, 75 tests that skip on the 128-byte device run and pass, every compute, pixel, vertex, mesh and geometry test among them reading the heap base from the block. On NVIDIA the result is identical either way. The two AMD failures aren't from the block:
ms_clipstill crashes invk_harnesswith a valid 128-byte layout, so GPU tests: vk_harness skips a device with fewer push-constant bytes than it pushes #1873's push-constant range isn't the whole story (SHADER-167 tracksms_clipcrashing on this driver family).ps_gather_wrap(it never ran on this device before) gets zeros in exactly the cases whose wrap or mirror coordinate is negative going intoOpSMod. The address-mode arithmetic (Gen.gather_addr) isn't touched here, and NVIDIA passes the same module. I'm looking into it separately.tests/test_pc_tail_ubo.py(new, 8 tests): the default is unchanged; with the flag, the push-constant block is 128 bytes and every tail read goes through%pc_tailat set 1, binding 0, which is in the interface; the function body is otherwise identical to the default's;s_getpc_b64reads code base members 2/3; a shader with no tail read declares no block; the--mesh-computeoutput address is members 4/5 (24 bytes); and the metadata. Each module passesspirv-val.All 185 hand-written GPU test shaders (
runtime/test/shaders/build.py, with the flag added to its translator call): every one translates and passesspirv-val. Without the flag, all 185 report 144 push-constant bytes and none haspc_tail. With it, all 185 report 128, and 109 havepc_tail(16 bytes). The set-0bindingslists are identical in all 185.python -m pytest tests/test_mesh_compute.py tests/test_shader_index.py tests/test_translate.py: 510 passed, 2 skipped.python -m unittest discover -s tests/semantic: 1644 OK.python -m pytest tests --ignore=tests/semantic: 4422 passed, 66 skipped, 5 failed. All 5 fail onmain(6a6704d) too: twotest_cf_refsubtests (fixed by test_cf_ref: drop exec_hi from the Unsupported list now that cf_ref models it #1852) and threetest_world_namessubtests (world_names test: check the overwrite diagnostic for the path as printed #1848).Checklist
docs/design.md, with how it was confirmed.🤖 Generated with Claude Code