shader: lower v_pack_b32_f16 in the direct C++ DXIL path #2917
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2917"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ybucaille on 2026-11-26T19:54:56Z.
Fixes #2909
Change
src/gfx1013_direct_compute.inl:float_alulowers VOP3v_pack_b32_f16(0x311). It is shared by the computeand pixel profiles, so the pixel profile failure from the issue goes through the same code.
it. D[15:0] is source 0 and D[31:16] is source 1. Only
lshr/and/xor/shl/oron i32 are emitted, so signedzero and NaN payloads keep their exact bits. Sources are read before the destination is written, so a destination
overlapping a source is fine. VGPR and SGPR sources are supported.
constants and a literal source (same set as the Python path, plus omod). No approximation.
tests/native_pack_b32_f16_check.py(modesirandgpu), helpertests/native_pixel_ir_dump.cpp,registration in
tests/cmake/native_pack_b32_f16.cmake. The model isref()fromstartup_gfx2hlsl_pack_b32_f16_check.py.Verified on Linux (no Windows, no GPU)
python -B tests/startup_gfx2hlsl_pack_b32_f16_check.py: 2304 cases pass (unchanged).-fsyntax-onlyand object code;d3d12.hfrom the Wine headersand a stub
wrl/client.h, not part of the change). A small Linux build ofnative_pixel_ir_dumpfromgfx1013_compute_native.cpp,gfx1013_isa.cpp,gfx1013_compute_ir.cppandguest_shader_container.cppranpython -B tests/native_pack_b32_f16_check.py ir <dumper>: 261 results match the model (issue words give0x77883344in v4, the control without the pack gives0x11223344; 64 op_sel/abs/neg forms x 4 value pairs;overlap; SGPR sources; nine refusals).
applied before abs fails the check (first at op_sel 0, abs 1, neg 1).
Verified on Windows (review of this PR)
RX 9070 XT, driver 32.0.32029.2010, MSVC 19.44.35221,
releasepreset, SDK 10.0.26100 DXC, debug layer off.native_pack_b32_f16_irpassed (261 results match the model).compile_dxil ... gfx1013-container-ps(rc 0) anddxc -dumpbinreads the.cso.native_pack_b32_f16_hardwareis not verified:native_store_replay --directexits 0xC0000005 (#2915).Review fix
Workgroups were 64 words apart but each stores 66 words, so two results overlapped the next group. They are now
128 words apart (
s_lshlby 9), the offsets are asserted disjoint and inside the 2064-word buffer, andexpectedcompares every group's SGPR and overlap results without a write-order assumption(commit
076b950d). The unsupported forms and results are also indocs/experiments/pack-b32-f16-direct.md.Still open
The GPU readback has no run on any machine; it needs #2915 fixed or an adapter that does not crash.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T19:58:44Z.
Review: CHANGES_REQUESTED
Review of head
0850d32doncpp-migration40365770. This includes the Windows run you asked for.Environment: Windows 11 build 26300.9974, AMD Radeon RX 9070 XT, driver 32.0.32029.2010, MSVC 19.44.35221,
releasepreset, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled. The build is clean,native_pixel_ir_dumpincluded.Lowering: it matches the acceptance list in #2909.
op_selbits 11 and 12 pick each source's half.lshr/and/xor/shl/oron i32 are emitted.op_selbits 13 and 14, abs/neg on source 2, inline constants and a literal are refused with named diagnostics.vector_write, so overlap is safe.Results here
native_pack_b32_f16_ir261 results match the model; issue reproduction, control, overlap, SGPR and refusals pass; swapped-half and neg-before-abs variants differ from the emitted bitscompile_dxil ... gfx1013-container-psdxc -dumpbinreads the.cso(rc 0). The control without the pack also compilesnative_pack_b32_f16_hardwarenative_store_replay.exe ... pack-readback.bin --directexits0xC0000005with no output. This is the crash in #2915, where 5 of the base branch'snative_store_replay --directtests crash the same way on this adapter. It is not caused by this PR, but it means the readback still has no run on any machine.Bug in the GPU readback layout (please fix before a GPU run counts). In
run_gpu, each workgroup storeslen(want)= 66 words: 64op_sel/abs/neg forms, then the SGPR case and the overlap case. Each store is at byte offset4 * index, from a per-group base that is 64 words apart (v8 = group * 256 bytes). So group 0's last two stores land on group 1's first two words, at words 72 and 73 of the 2064-word buffer. The final value there depends on which workgroup writes last.expectedassigns group 0 and then group 1, so it assumes group 1 wins. On a GPU where group 0 finishes last, the test fails with a correct lowering. Either way, group 0's SGPR and overlap results are never compared. Splitting the cases across two dispatches, or adding a guard band at the edge, would fix it. So would writing at most 64 words per group, or using a wider stride if the root layout allows it.Minor
docs/experiments/<topic>.mdnote (seedocs/experiments/README.md) would also give the GPU result a place to live once someone has one.native_pack_b32_f16_hardwarehas no WARP variant, becausenative_store_replayalways takes the default adapter. That is consistent with the other replay tests, but this check stays unexercised until someone runs it on a GPU that does not crash in #2915.AI-assisted; the commands above were run locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Ybucaille on 2026-11-26T20:04:39Z.
Thank you for the review and for running it on Windows.
076b950d. Workgroups are now 128 words apart instead of 64, so the 66 results of a groupno longer reach the next one.
expectedis built from per-group offsets that are asserted disjoint and insidethe 2064-word buffer, so both groups' SGPR and overlap results are compared and nothing depends on write order.
docs/experiments/pack-b32-f16-direct.mdin21408d7ewith the semantics, the refused forms, the LinuxIR check and your Windows results.
The readback itself still has no run, since
native_store_replay --directcrashes on your adapter (#2915). Iwill leave it open until someone can run it on a GPU that does not hit that.
Imported from R0Y00/Xbox2Windows. Originally posted by sydney-0o on 2026-11-26T20:06:13Z.
Tested PR head
0850d32d7dfa0631591f214238bfc8e9665c88dbin a clean worktree on Windows 10 Pro 22H2 (build 19045.6456). The machine's physical adapter is an NVIDIA GeForce GTX 1080 Ti, driver32.0.15.8278(a Virtual Display Driver is also installed). The hardware fixture requests the default D3D12 adapter and does not print the selected adapter, so the adapter used by the capability check was not independently verified. The fixture does not explicitly enable the D3D12 debug layer; external debug-layer state was not verified.Configured with
cmake --preset dev -DINTAKE_PYTHON=<Python 3.12 environment>, then built the relevant targets withcmake --build --preset dev --target native_pixel_ir_dump native_store_replay compile_dxil -j 4(passed; MSVC 19.31.31105, DXC 1.8.2502.11). Ran serially:native_direct_container: passed.native_pack_b32_f16_ir: passed; 261 results matched the model, including the fixture's negative controls.native_scalar_lds_hardware: capability skip (77):requires shader model 6.6 with wave32.native_pack_b32_f16_hardware: capability skip (77):requires shader model 6.6 with wave32.CTest exited 0: 2 passed, 2 skipped, 0 failed. The hardware checks stopped at the combined capability gate before GPU readback; the diagnostic does not identify which requirement was missing. These results do not establish hardware correctness for the skipped fixtures.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T20:22:01Z.
Review: APPROVED
Follow-up on head
21408d7e. My requested change is addressed.076b950d): the shader moves the stride as well asexpected.scalar(0x1e, 7, 5, 137)iss_lshl_b32 s7, s5, 9, so each workgroup's base isgroup * 512bytes, and that matchesSTRIDE = 128words. Group 0 writes words 8–73 and group 1 writes 136–201, both inside the 2064-word buffer.group_offsetsasserts that the groups are disjoint and in range, andexpectedis built from the same offsets, so the result no longer depends on which group writes last. A small nit, not blocking: the shift137(inline 9) andSTRIDEare two separate constants. Deriving the shift fromSTRIDE, or asserting4 * STRIDE == 1 << 9, would keep them from drifting apart.21408d7e):docs/experiments/pack-b32-f16-direct.mdmatches the code and the runs. It reports the Windows results I posted, and it states that the GPU readback has produced no result anywhere.src/gfx1013_direct_compute.inl) and the IR path are unchanged since0850d32d, wherenative_pack_b32_f16_irpassed here, so I did not rebuild for this read.Still open, as the note says:
native_pack_b32_f16_hardwarehas no GPU result. It crashes in #2915 on the RX 9070 XT. On @sydney-0o's GTX 1080 Ti it skipped (77) at the SM 6.6 with wave32 gate. That needs an adapter with SM 6.6, wave32 and no #2915 crash, for example R0Y00's RTX 4060. That is a measurement still to make, not a defect in the PR.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-26T21:33:22Z.
GPU readback on an adapter that does not hit #2915:
native_pack_b32_f16_hardware: passed 3/3 —pack_b32_f16 GPU: 528 packed words matched the model bit for bitnative_pack_b32_f16_ir: passed —261 results match the modelSetup:
cpp-migrationee76dfa8+ #2912 (432db950) + this PR (74537dc6),devpreset, NVIDIA GeForce RTX 3080 driver 32.0.16.2124, Windows 11 build 26200, MSVC toolset 14.51.36231, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T21:37:02Z.
Review: APPROVED
Approving at
74537dc6and merging intocpp-migration.21408d7e, the only change is74537dc6, which ties the readback shift toSTRIDE(SHIFT = 9,assert 4 * STRIDE == 1 << SHIFT,128 + SHIFTin thes_lshl_b32). That settles my nit.src/is unchanged since0850d32d, wherenative_pack_b32_f16_irpassed here on Windows and the issue's words compiled withcompile_dxiland were read bydxc -dumpbin.dev) on this head givesnative_pack_b32_f16_hardware3/3, with528 packed words matched the model bit for bit, andnative_pack_b32_f16_irpasses too. @sydney-0o's GTX 1080 Ti skipped (77) at the SM 6.6 with wave32 gate, and the RX 9070 XT here still hits #2915, so this NVIDIA run is the readback evidence.cpp-migration(ee76dfa8)..github/workflows/windows.ymldoes not run for this base, so the runs above stand in for CI.AI-assisted.