shader: lower v_pack_b32_f16 in the direct C++ DXIL path #2909

Closed
opened 2026-11-27 01:28:35 +00:00 by github-bot · 3 comments
Owner

@⁠R0Y00 on GitHub · 2026-11-26 19:00 UTC · original

Target branch cpp-migration. Open to contributors. Comment here to claim.

On 4036577020 the opcode table recognizes VOP3 0x311, but a source-built pixel shader stops at native compute +0x10: direct DXIL lowering for v_pack_b32_f16 in the pixel profile. Removing only the pack instruction produces DXIL.

Reproduce with patched_pixel from tests/native_direct_container_check.py. Supply the instruction words [0x7e0802ff, 0x11223344, 0x7e0a02ff, 0x55667788, 0xd7110004, 0x00020b04] and export (0xf800180f, 0x05040504). Run compile_dxil <sdk-dir> <empty-cache> gfx1013-container-ps input.cdxil output.cso. For the control remove the final two instruction words and adjust the length. The ordinary pack writes 0x77883344 to v4, which also supplies the first source.

Implementation references include the experimental lowering at a pinned revision and the existing Python reference and synthetic controls. Implement from the instruction semantics and existing public fixture. The experimental repository has a root MIT license and separately attributed third-party material. Preserve applicable notices for any reused source.

Acceptance follows each source's high/low selection, clears the half sign for abs, then toggles it for neg, and places source 0 low and source 1 high. Preserve bit patterns including signed zero and NaN payloads. Cover operand overlap, SGPR input and both wrong-result controls (swapped halves and neg before abs). Document unsupported modifier forms. Generate DXIL with the direct frontend and verify exact packed bits by GPU readback on a synthetic fixture, recording adapter, driver, build, and any capability skips. python -B tests/startup_gfx2hlsl_pack_b32_f16_check.py already passes 2304 reference cases. #1723 tracks the older translator census. #2906–#2908 cover separate branch and descriptor work.

**@⁠R0Y00** on GitHub · 2026-11-26 19:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/2909) Target branch `cpp-migration`. Open to contributors. Comment here to claim. On 40365770206d355160f364495cd9a72be2c7df8e the opcode table recognizes VOP3 0x311, but a source-built pixel shader stops at `native compute +0x10: direct DXIL lowering for v_pack_b32_f16` in the pixel profile. Removing only the pack instruction produces DXIL. **Reproduce** with `patched_pixel` from `tests/native_direct_container_check.py`. Supply the instruction words `[0x7e0802ff, 0x11223344, 0x7e0a02ff, 0x55667788, 0xd7110004, 0x00020b04]` and export `(0xf800180f, 0x05040504)`. Run `compile_dxil <sdk-dir> <empty-cache> gfx1013-container-ps input.cdxil output.cso`. For the control remove the final two instruction words and adjust the length. The ordinary pack writes 0x77883344 to v4, which also supplies the first source. **Implementation references** include [the experimental lowering at a pinned revision](https://github.com/denn0x/Xbox2Windows/blob/87a6003fcc38661683f6936a614acfa90e420c83/src/x2w_shader/emit/lower_valu.cpp#L878) and [the existing Python reference and synthetic controls](https://github.com/R0Y00/Xbox2Windows/blob/40365770206d355160f364495cd9a72be2c7df8e/tests/startup_gfx2hlsl_pack_b32_f16_check.py). Implement from the instruction semantics and existing public fixture. The experimental repository has a root MIT license and separately attributed third-party material. Preserve applicable notices for any reused source. **Acceptance** follows each source's high/low selection, clears the half sign for abs, then toggles it for neg, and places source 0 low and source 1 high. Preserve bit patterns including signed zero and NaN payloads. Cover operand overlap, SGPR input and both wrong-result controls (swapped halves and neg before abs). Document unsupported modifier forms. Generate DXIL with the direct frontend and verify exact packed bits by GPU readback on a synthetic fixture, recording adapter, driver, build, and any capability skips. `python -B tests/startup_gfx2hlsl_pack_b32_f16_check.py` already passes 2304 reference cases. #1723 tracks the older translator census. #2906–#2908 cover separate branch and descriptor work.
github-bot 2026-11-27 01:28:35 +00:00
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:28:35 +00:00
Author
Owner

@⁠Ybucaille on GitHub · 2026-11-26 19:42 UTC · original

I'd like to take this one. I'll implement the direct-path lowering on cpp-migration from the instruction semantics and the existing fixture, with the overlap, SGPR and wrong-result controls, plus a GPU readback on a synthetic fixture.

**@⁠Ybucaille** on GitHub · 2026-11-26 19:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/2909#issuecomment-7201869982) I'd like to take this one. I'll implement the direct-path lowering on `cpp-migration` from the instruction semantics and the existing fixture, with the overlap, SGPR and wrong-result controls, plus a GPU readback on a synthetic fixture.
Author
Owner

@⁠MasterDomino on GitHub · 2026-11-26 21:38 UTC · original

Closing: the fix landed on cpp-migration via #2917, squash-merged as 16099d7c. Fixes #2909 does not close issues automatically outside the default branch. Evidence on #2917: native_pack_b32_f16_ir passed on Windows, and on Linux (Ybucaille) and a GTX 1080 Ti (sydney-0o). The GPU readback native_pack_b32_f16_hardware passed 3/3 on an RTX 3080 (JB2WIN, 528 packed words bit-exact). The issue's words now compile with compile_dxil ... gfx1013-container-ps. The RX 9070 XT readback stays blocked by #2915.

AI-assisted.

**@⁠MasterDomino** on GitHub · 2026-11-26 21:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/2909#issuecomment-7203913846) Closing: the fix landed on `cpp-migration` via #2917, squash-merged as `16099d7c`. `Fixes #2909` does not close issues automatically outside the default branch. Evidence on #2917: `native_pack_b32_f16_ir` passed on Windows, and on Linux (Ybucaille) and a GTX 1080 Ti (sydney-0o). The GPU readback `native_pack_b32_f16_hardware` passed 3/3 on an RTX 3080 (JB2WIN, 528 packed words bit-exact). The issue's words now compile with `compile_dxil ... gfx1013-container-ps`. The RX 9070 XT readback stays blocked by #2915. AI-assisted.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 18:49 UTC · original

Rechecked this on main at 1e2b0d524, Windows 11 build 26300, MSVC Debug and NVIDIA GeForce RTX 4060 Laptop GPU (driver 32.0.16.1656). The fixture did not enable the D3D12 debug layer.

cmake --build --preset dev --target native_pixel_ir_dump native_store_replay and ctest --preset dev --no-tests=error -V -j 1 -R '^native_pack_b32_f16_(ir|hardware)$' passed (2/2). The hardware readback matched all 528 packed words bit for bit. In the IR fixture, all 269 results matched the reference. The no-pack control, overlapping and SGPR sources, constant cases and refusals passed. The swapped-half and neg-before-abs alternatives produced different bits, as expected.

**@⁠R0Y00** on GitHub · 2026-12-02 18:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/2909#issuecomment-7355216985) Rechecked this on `main` at `1e2b0d524`, Windows 11 build 26300, MSVC Debug and NVIDIA GeForce RTX 4060 Laptop GPU (driver `32.0.16.1656`). The fixture did not enable the D3D12 debug layer. `cmake --build --preset dev --target native_pixel_ir_dump native_store_replay` and `ctest --preset dev --no-tests=error -V -j 1 -R '^native_pack_b32_f16_(ir|hardware)$'` passed (2/2). The hardware readback matched all 528 packed words bit for bit. In the IR fixture, all 269 results matched the reference. The no-pack control, overlapping and SGPR sources, constant cases and refusals passed. The swapped-half and neg-before-abs alternatives produced different bits, as expected.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#2909
No description provided.