shader: lower v_and_or_b32 and v_cvt_f16_f32 in the mesh frontend #3743

Merged
lambirou merged 1 commit from upstream-pr/3743 into main 2026-12-02 01:50:15 +00:00
lambirou commented 2026-12-01 14:03:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-01T14:03:04Z.


After the scalar bit operations, the forced slot 86 mesh path still refused
v_cvt_f16_f32 in 357 requests and v_and_or_b32 in 331, ahead of the
control-flow, heap-provenance and pixel blocks.

v_and_or_b32 (VOP3 0x371) joins the mesh vector list that already handles
v_or3_b32 and v_add3_u32, so it takes the three-source
alu_rules entry and lowers to (S0 & S1) | S2. The shared operand gate
still refuses abs, neg, clamp and omod. v_cvt_f16_f32 (VOP1 0x0A) joins
the same list and reuses the compute frontend's integer round-to-nearest-even
narrowing: the sign comes from bit 31, binary32 subnormals become signed
zeros, binary16 subnormals are kept, overflow including the 65520 tie gives
0x7c00, and a NaN keeps its quiet bit. The encoding goes into the low half
and the reaching destination value keeps the high half, so an unproven
destination still refuses and the merged word is not declared uniform.

Validation (Windows, Release; AMD Radeon RX 9060 XT for the hardware run):

  • cmake --build --preset release --target compile_dxil — 7/7 steps.
  • python -B tests/native_direct_mesh_check.py out\\build\\release\\compile_dxil.exe "<DXC dir>"
    — pass, including the v_and_or_b32 and v_cvt_f16_f32 programs and the
    unbound/unproven-source controls.
  • ctest --preset release --no-tests=error -R '^native_direct' — 2/2 pass.

Refs #3703

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5587295429 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3743). Originally posted by [lambirou](https://github.com/lambirou) on 2026-12-01T14:03:04Z. --- After the scalar bit operations, the forced slot 86 mesh path still refused `v_cvt_f16_f32` in 357 requests and `v_and_or_b32` in 331, ahead of the control-flow, heap-provenance and pixel blocks. `v_and_or_b32` (VOP3 0x371) joins the mesh vector list that already handles `v_or3_b32` and `v_add3_u32`, so it takes the three-source `alu_rules` entry and lowers to `(S0 & S1) | S2`. The shared operand gate still refuses abs, neg, clamp and omod. `v_cvt_f16_f32` (VOP1 0x0A) joins the same list and reuses the compute frontend's integer round-to-nearest-even narrowing: the sign comes from bit 31, binary32 subnormals become signed zeros, binary16 subnormals are kept, overflow including the 65520 tie gives `0x7c00`, and a NaN keeps its quiet bit. The encoding goes into the low half and the reaching destination value keeps the high half, so an unproven destination still refuses and the merged word is not declared uniform. Validation (Windows, Release; AMD Radeon RX 9060 XT for the hardware run): - `cmake --build --preset release --target compile_dxil` — 7/7 steps. - `python -B tests/native_direct_mesh_check.py out\\build\\release\\compile_dxil.exe "<DXC dir>"` — pass, including the `v_and_or_b32` and `v_cvt_f16_f32` programs and the unbound/unproven-source controls. - `ctest --preset release --no-tests=error -R '^native_direct'` — 2/2 pass. Refs #3703
lukaslw-lab commented 2026-12-01 20:13:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T20:13:12Z.

Review: APPROVED


Reviewed baa40780 by reading the diff; not built or run.

Verdict: approve. Both ops join the mesh VALU list and lower through the shared ALU, with uniformity handled correctly. No MUST.

  • Overlap with #3666. #3666 (Kawiu, open) also adds v_cvt_f16_f32 to this list. It goes through the same shared narrowing (gfx1013_direct_compute.inl:2102), so the behaviour is identical and only the list entry is duplicated. Whichever lands second can drop its entry on rebase. v_and_or_b32 here, and v_cvt_f32_f16 plus the two CMPX forms in #3666, are not duplicated. For context: on main + #3760, six slot 86 programs from our own capture now stop first at v_cvt_f16_f32, so either PR clears that wall for them.
  • Rebase. The branch is on e1161e43, and only tests/native_direct_mesh_check.py conflicts with main 158ef794, where both sides appended cases. The source hunk merges cleanly.
  • Checked, no finding:
    • Source counts. v_and_or_b32 has an alu_rules entry of arity 3, so a result is uniform only when all three sources are. v_cvt_f16_f32 has no rule and is not in the hard-coded arity lists, so sources is 0 and the merged word is never declared uniform. That matches the new comment, since the high half comes from the destination.
    • Modifiers. Abs, neg, clamp and omod still go through the shared operand gate, so they refuse as before.

Tests:

  • v-and-or-b32 traces (S0 & S1) | S2 to the export, and -unproven refuses an unbound source.
  • The v_cvt_f16_f32 cases match the NaN/infinity select chain of the narrowing and export the low half.
  • -unproven-source and -unproven-destination pin both refusals. The second covers the kept high half.

CI ran native_direct_mesh (pr preset filter) green at this head, on the old base.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6139258103 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3743#pullrequestreview-6139258103). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T20:13:12Z. **Review:** APPROVED --- Reviewed `baa40780` by reading the diff; not built or run. **Verdict: approve.** Both ops join the mesh VALU list and lower through the shared ALU, with uniformity handled correctly. No MUST. - **Overlap with #3666.** #3666 (Kawiu, open) also adds `v_cvt_f16_f32` to this list. It goes through the same shared narrowing (`gfx1013_direct_compute.inl:2102`), so the behaviour is identical and only the list entry is duplicated. Whichever lands second can drop its entry on rebase. `v_and_or_b32` here, and `v_cvt_f32_f16` plus the two CMPX forms in #3666, are not duplicated. For context: on `main` + #3760, six slot 86 programs from our own capture now stop first at `v_cvt_f16_f32`, so either PR clears that wall for them. - **Rebase.** The branch is on `e1161e43`, and only `tests/native_direct_mesh_check.py` conflicts with `main` `158ef794`, where both sides appended cases. The source hunk merges cleanly. - Checked, no finding: - **Source counts.** `v_and_or_b32` has an `alu_rules` entry of arity 3, so a result is uniform only when all three sources are. `v_cvt_f16_f32` has no rule and is not in the hard-coded arity lists, so `sources` is 0 and the merged word is never declared uniform. That matches the new comment, since the high half comes from the destination. - **Modifiers.** Abs, neg, clamp and omod still go through the shared operand gate, so they refuse as before. Tests: - `v-and-or-b32` traces `(S0 & S1) | S2` to the export, and `-unproven` refuses an unbound source. - The `v_cvt_f16_f32` cases match the NaN/infinity select chain of the narrowing and export the low half. - `-unproven-source` and `-unproven-destination` pin both refusals. The second covers the kept high half. CI ran `native_direct_mesh` (pr preset filter) green at this head, on the old base.
lambirou commented 2026-12-01 23:02:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-01T23:02:53Z.


Rebased onto origin/main 158ef794 after #3762, resolving the native_direct_mesh_check.py helper conflict by keeping both assert_export_column and the _sop2/_sopc/_sop1_literal helpers.

Head 816ab821. Validation:

  • cmake --build --preset release --target compile_dxil — 17/17.
  • python -B tests/native_direct_mesh_check.py ... — pass.
  • ctest --preset release --no-tests=error -R '^native_direct' — 2/2 passed.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7328710519 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3743#issuecomment-7328710519). Originally posted by [lambirou](https://github.com/lambirou) on 2026-12-01T23:02:53Z. --- Rebased onto `origin/main` `158ef794` after #3762, resolving the `native_direct_mesh_check.py` helper conflict by keeping both `assert_export_column` and the `_sop2`/`_sopc`/`_sop1_literal` helpers. Head `816ab821`. Validation: - `cmake --build --preset release --target compile_dxil` — 17/17. - `python -B tests/native_direct_mesh_check.py ...` — pass. - `ctest --preset release --no-tests=error -R '^native_direct'` — 2/2 passed. AI-assisted.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
R0Y00/Xbox2Windows!3743
No description provided.