Repository navigation
Runtime: refuse a native wave64 compute PSO on a 32-lane GPU (E_NOTIMPL, use --wave64-emulate) instead of building one that computes wrong results - #5282
Conversation
…bgroups A compute shader translated for 64 lanes without --wave64-emulate was built on a device that cannot give it 64 lanes (NVIDIA: 32..32) and read lanes 32-63 that are not there: on an RTX 5080, cs_w64x_readlane gave 25 121 112 1 112 4 100 121 instead of 121 121 16 97 16 100 100 121, with S_OK and a log line. Compute has an exact translation for any size (--wave64-emulate, picked by make_game.py --wave64-emulate auto, ItsNotRexed#94), so CreateComputePipelineState now returns E_NOTIMPL with one line naming that build, before any Vulkan object is made. Vertex, geometry and pixel shaders have no emulation and are built as before. d3d12_subgroup_test expects the refusal on such a GPU, and on every GPU when the layer is told the device has 32-wide subgroups only; subgroup_size_test checks which pipelines are refused (no GPU).
…probe check follows the refusal rule Review fixes on the wave64 refusal: - report_subgroup_unavailable counted refused and built shaders of a stage together, so a refusal after an inexact wave32 compute shader could be silent. They are counted apart now. - d3d12_subgroup_test's compute probe expected a refusal only where maxSubgroupSize < 64; it now expects one exactly where the decision for the native wave64 probe is unavailable, and S_OK everywhere else. The native case prints BUILT when the layer builds it (main), refused otherwise.
|
Tested
AI-assisted (Claude Code). |
|
AI-assisted. Tested e720a87 on Windows 11 with Vulkan validation on. The RTX 4090 refuses the native wave64 compute pipeline with E_NOTIMPL (0x80004001). The emulated shader returns all eight expected words: I rebuilt main 3faac55 separately. On the same RTX 4090, main builds the native pipeline and returns On the AMD Radeon(TM) Graphics iGPU, the head selects a 64-wide subgroup for the native pipeline. Native and emulated runs both return all eight expected words. I built |
Kam471
left a comment
There was a problem hiding this comment.
Reviewed head e720a87cc (worktree detached from pr/5282, diff vs origin/main).
- Configured with
LLVM_MC='wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc', Ninja, RelWithDebInfo, BUILD_TESTING=ON, LEONIDA_BUILD_WINDOWS_RUNTIME=ON, Vulkan 1.4.363;cmake --build build-5282 --target subgroup_size_test d3d12_subgroup_test→ built. LEONIDA_VK_DEVICE='RTX 5070 Ti' ctest --test-dir build-5282 -R "^(subgroup_size|d3d12_subgroup)$"→ 2/2 passed.- GPU run on NVIDIA RTX 5070 Ti (sizes 32..32): native w64 cs PSO refused (
0x80004001), emulated exact, forced 32-only caps refused; 2 shaders judged exact. - Control with main's
d3d12_vulkan_device.cppandsubgroup_size.hplus this test:PSO BUILT (0x00000000), exit 1 atline 556: result.pso == E_NOTIMPL. git diff --checkclean;git merge-tree origin/main pr/5282clean.
Verdict: pass on NVIDIA; no blockers. AMD remains unverified, as the body says: the AMD-like CPU case and the forced-32 refusal check cover the decision logic, not a real AMD driver.
larpinguser
left a comment
There was a problem hiding this comment.
Summary: The runtime adds subgroup_refused in runtime/src/subgroup_size.h and refuses native wave64 compute PSOs on devices without 64-wide subgroups with E_NOTIMPL and a one-line --wave64-emulate hint. Refused pipelines are logged separately; docs and D3D12/subgroup tests cover real and forced-32 devices.
Why merge: It prevents silent wrong results from reading missing lanes while keeping report-only behavior for graphics stages without emulation.
Verdict: Approve
|
Summary: The runtime adds Why merge: It prevents silent wrong results from reading missing lanes while keeping report-only behavior for graphics stages without emulation. Verdict: Approve |
Claimed in #5256 (comment).
What
A compute PSO whose shader was translated for 64 lanes without
--wave64-emulateis now refused on a GPU that cannot give a compute stage 64 lanes (NVIDIA:minSubgroupSize = maxSubgroupSize = 32).CreateComputePipelineStatereturnsE_NOTIMPLand logs one line:The line is rate-limited like the existing one: the first shader of the stage, then again at 10, 100, 1000... Refused shaders are counted apart from the built-but-inexact ones, so the first refusal always prints its line.
Why
On main this PSO is built with
S_OK. It runs at 32 lanes and reads lanes 32-63 that do not exist, so the results are wrong. The only sign is a log line. Measured on an RTX 5080 (Linux, driver 580.65.06, Wine 11.0), withd3d12_subgroup_testat main3faac557:121 121 16 97 16 100 100 121S_OK)25 121 112 1 112 4 100 121--wave64-emulate121 121 16 97 16 100 100 121#94 settled how wave64 runs on 32-wide GPUs: compute and mesh are translated with
--wave64-emulate, which is exact at any subgroup size, andmake_game.py --wave64-emulate autopicks it for such a GPU. So a native wave64 compute module on such a GPU always comes from a build made for another GPU or with--wave64-emulate off. Refusing the PSO makes that build mistake visible at pipeline creation. Before, it only showed up as wrong data further down the frame.What does not change
wave64_halvestiers A and B are exact at 32. They are still built and logged as before.device_default) is also unchanged. Onlydecide_subgroup_size=unavailablewith wanted size 64 on a compute stage is refused (subgroup_refusedinruntime/src/subgroup_size.h).subgroup_refusedthe same way. It is left as compute-only here so the log line never says "refused" for a pipeline that was built.make_game.pytranslates each shader once, natively or emulated, so the layer has nothing to choose from.Tests
d3d12_subgroup_test(GPU):cs_w64x_readlanePSO must beE_NOTIMPL. On main the test let it pass with "not judged".subgroup_size_test(CPU): on NVIDIA-like properties, a native wave64csis refused.ps/vs/gswave64, wave32csand emulatedcsare not. On AMD-like properties, a native wave64csis not refused.Runs (RTX 5080, Linux driver 580.65.06, Wine 11.0, clang-cl + xwin build):
d3d12_subgroup_testwith this change: passes, and the native PSO is refused (0x80004001).d3d12_subgroup_testagainst main's layer fails at the refusal check, because the PSO is built.-R d3d12 -j4under Wine, with and without this change: the only difference isd3d12_subgroup. 7 tests fail the same way on main and here:d3d12_fence_timing,d3d12_private_data,d3d12_descriptor,d3d12_indirect_dispatch_count,d3d12_subresource_copy,d3d12_residency,d3d12_heap_properties. 13 tests skip on both.d3d12_xdxr_rttimed out once on each side and passed on the final run.subgroup_size_testpasses.No game data. AI-assisted.