startup: accept output modifiers on float-result conversions #1700

Merged
triggered02 merged 2 commits from upstream-pr/1707 into main 2026-11-24 17:52:06 +00:00
triggered02 commented 2026-11-24 17:29:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T17:29:45Z.


Fixes #1705. Third group from the loading-screen refusal census (#870): 5 of 29 shaders.

Change

The float-result conversions sat in the uint-result table, whose dispatch refused every modifier before looking at the instruction, so v_cvt_f32_i32_e64 v1, v1 mul:2 did not translate even though set_vf() already implements those modifiers.

They are now their own table (VEC_U_TO_F) holding the float expression, dispatched through the float path:

v_cvt_f32_i32_e64 v1, v1          -> v1 = U(float(int(v1)));            (unchanged)
v_cvt_f32_i32_e64 v1, v1 mul:2    -> v1 = U((float(int(v1))) * 2.0);
v_cvt_f32_i32_e64 v1, v1 mul:4    -> U(... * 4.0)
v_cvt_f32_i32_e64 v1, v1 div:2    -> U(... * 0.5)
v_cvt_f32_i32_e64 v1, v1 clamp    -> U(saturate(float(int(v1))))

Boundaries kept: only clamp, mul:2, mul:4, div:2 are accepted — op_sel and source modifiers are refused rather than silently ignored (which would change the operand), and a uint-result conversion (v_cvt_f16_f32) keeps refusing output modifiers.

Test

startup_gfx2hlsl_vcvt_omod builds VOP1-as-VOP3 encodings from the checked-in decoder's layout (0b110101 prefix, opcode 0x180 + n, omod w1[28:27], clamp w0[15], neg w1[31:29]), decodes them, then translates — no game-derived bytes.

dev:     startup_gfx2hlsl_vcvt_omod Passed 0.14 s; all 7 startup_gfx2hlsl tests pass
release: startup_gfx2hlsl_vcvt_omod Passed 0.14 s

Fail-first: removing the VEC_U_TO_F dispatch fails the test with Unsupported: v_cvt_f32_i32.

Census A/B (local, aggregates only)

With the change, refusals grouped as v_cvt_f32_i32 go 16 → 0 in the annotated re-run, and the affected shaders now progress to the next refusal in their stream — export target mrtz, v_cvt_f32_u32_sdwa, negative operands, and the export off form that #1674 tracks. That is forward motion, not new failures: every group that appears after the change is one the shader previously never reached.

What this does not establish

  • That the loading screen gets further — needs a run that visibly reaches it; the counts above are local aggregates.
  • op_sel/abs/neg on conversions stay refused, and the SDWA variants of these conversions are their own slice.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6587638371 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1707). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T17:29:45Z. --- Fixes #1705. Third group from the loading-screen refusal census (#870): 5 of 29 shaders. ## Change The float-result conversions sat in the uint-result table, whose dispatch refused every modifier before looking at the instruction, so `v_cvt_f32_i32_e64 v1, v1 mul:2` did not translate even though `set_vf()` already implements those modifiers. They are now their own table (`VEC_U_TO_F`) holding the float expression, dispatched through the float path: ``` v_cvt_f32_i32_e64 v1, v1 -> v1 = U(float(int(v1))); (unchanged) v_cvt_f32_i32_e64 v1, v1 mul:2 -> v1 = U((float(int(v1))) * 2.0); v_cvt_f32_i32_e64 v1, v1 mul:4 -> U(... * 4.0) v_cvt_f32_i32_e64 v1, v1 div:2 -> U(... * 0.5) v_cvt_f32_i32_e64 v1, v1 clamp -> U(saturate(float(int(v1)))) ``` Boundaries kept: only `clamp`, `mul:2`, `mul:4`, `div:2` are accepted — `op_sel` and source modifiers are refused rather than silently ignored (which would change the operand), and a uint-result conversion (`v_cvt_f16_f32`) keeps refusing output modifiers. ## Test `startup_gfx2hlsl_vcvt_omod` builds VOP1-as-VOP3 encodings from the checked-in decoder's layout (`0b110101` prefix, opcode `0x180 + n`, omod `w1[28:27]`, clamp `w0[15]`, neg `w1[31:29]`), decodes them, then translates — no game-derived bytes. ``` dev: startup_gfx2hlsl_vcvt_omod Passed 0.14 s; all 7 startup_gfx2hlsl tests pass release: startup_gfx2hlsl_vcvt_omod Passed 0.14 s ``` Fail-first: removing the `VEC_U_TO_F` dispatch fails the test with `Unsupported: v_cvt_f32_i32`. ## Census A/B (local, aggregates only) With the change, refusals grouped as `v_cvt_f32_i32` go **16 → 0** in the annotated re-run, and the affected shaders now progress to the next refusal in their stream — `export target mrtz`, `v_cvt_f32_u32_sdwa`, negative operands, and the export `off` form that #1674 tracks. That is forward motion, not new failures: every group that appears after the change is one the shader previously never reached. ## What this does not establish - That the loading screen gets further — needs a run that visibly reaches it; the counts above are local aggregates. - `op_sel`/`abs`/`neg` on conversions stay refused, and the SDWA variants of these conversions are their own slice. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 18:02:41 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 18:02:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:33:42Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ceccbcaece

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044263376 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1707#pullrequestreview-6044263376). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T17:33:42Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `ceccbcaece` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-24 18:02:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:35:12Z.

Review: COMMENTED


Review of head ceccbcaece12b41f03938379d28b5e24906a7e5a. Verdict: 0 P1, 1 P2 (clamp together with an output modifier), plus test gaps.

Linux limits. Linux x86_64, llvm-mc-19, Python 3.14. No Windows, no DXC, no GPU. Python-level translation only; nothing was compiled to DXIL or drawn.

What I ran

  • python3 -B tests/startup_gfx2hlsl_vcvt_omod_check.py: PASS. git diff --check, docs_links_check, bidi_controls_check: clean.
  • llvm-mc-19 -mcpu=gfx1030 assembled v_cvt_f32_i32_e64 ... mul:2 / clamp / clamp mul:2, v_cvt_f32_u32_e64 mul:2, v_cvt_f32_f16_e64 mul:2, v_cvt_f32_ubyte1_e64 div:2, v_cvt_f16_f32_e64 mul:2. The opcodes (0x185, 0x186, 0x18b, 0x18a) and omod bits (mul:2 = 1, div:2 = 3) match the bytes the PR's encode_vop1_e64 builds, so the constructed fixtures are real encodings.
  • Mutations on tools/startup/gfx2hlsl.py (restored with git checkout -- .):
    • v_cvt_f32_f16 text f16tof32({0}) -> f16tof32({0} >> 16): FAILED, as intended.
    • v_cvt_f32_ubyte1 shift 8 -> 16: PASSED, not caught.
    • v_cvt_f32_ubyte3 shift 24 -> 16: PASSED, not caught.
    • the modifier whitelist if any(m not in (...)) replaced by if False: PASSED, not caught (an op_sel would then fall into set_vf, which silently ignores it).
    • v_cvt_f32_u32 lowered as float(int(x)) (signed): PASSED, not caught.

P2: clamp with an output modifier is applied in the wrong order. For v_cvt_f32_i32_e64 v1, v1 clamp mul:2 the translator emits v1 = U((saturate(float(int(v1)))) * 2.0); (and * 0.5 for div:2), i.e. clamp first, then scale. As I read the RDNA 2 ISA reference, the output modifier scales the result first and clamp saturates after it, so this should be saturate((float(int(v1))) * 2.0). For an input of 1 the hardware gives 1.0 and this lowering gives 2.0. The order comes from Stage.set_vf, which walks the modifiers in the order the decoder prints them (clamp mul:2); that is pre-existing for the VEC_F operations, but this PR is what makes the combination reachable for the seven conversions, and no case in the new test combines the two. Suggest applying omod first, then clamp, in set_vf, with a case for clamp mul:2 and clamp div:2.

Test gaps (not blocking)

  • v_cvt_f32_ubyte0..3 have no case, so a wrong shift or mask there is not detected; v_cvt_f32_u32 is checked only for the * 2.0 wrapper, not its text.
  • The whitelist is exercised only by the uint-result refusal and a source negation (which is refused earlier as Unsupported operand '-v1'); no case passes op_sel or another modifier to a float-result conversion, so dropping the guard goes unnoticed.
  • The docs say issue #1705, the test docstring says #1696; the test file ends without a final newline.

Not approving (comment only).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044284244 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1707#pullrequestreview-6044284244). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:35:12Z. **Review:** COMMENTED --- Review of head `ceccbcaece12b41f03938379d28b5e24906a7e5a`. **Verdict: 0 P1, 1 P2** (clamp together with an output modifier), plus test gaps. **Linux limits.** Linux x86_64, `llvm-mc-19`, Python 3.14. No Windows, no DXC, no GPU. Python-level translation only; nothing was compiled to DXIL or drawn. **What I ran** - `python3 -B tests/startup_gfx2hlsl_vcvt_omod_check.py`: PASS. `git diff --check`, `docs_links_check`, `bidi_controls_check`: clean. - `llvm-mc-19 -mcpu=gfx1030` assembled `v_cvt_f32_i32_e64 ... mul:2 / clamp / clamp mul:2`, `v_cvt_f32_u32_e64 mul:2`, `v_cvt_f32_f16_e64 mul:2`, `v_cvt_f32_ubyte1_e64 div:2`, `v_cvt_f16_f32_e64 mul:2`. The opcodes (0x185, 0x186, 0x18b, 0x18a) and omod bits (mul:2 = 1, div:2 = 3) match the bytes the PR's `encode_vop1_e64` builds, so the constructed fixtures are real encodings. - Mutations on `tools/startup/gfx2hlsl.py` (restored with `git checkout -- .`): - `v_cvt_f32_f16` text `f16tof32({0})` -> `f16tof32({0} >> 16)`: FAILED, as intended. - `v_cvt_f32_ubyte1` shift 8 -> 16: PASSED, not caught. - `v_cvt_f32_ubyte3` shift 24 -> 16: PASSED, not caught. - the modifier whitelist `if any(m not in (...))` replaced by `if False`: PASSED, not caught (an `op_sel` would then fall into `set_vf`, which silently ignores it). - `v_cvt_f32_u32` lowered as `float(int(x))` (signed): PASSED, not caught. **P2: `clamp` with an output modifier is applied in the wrong order.** For `v_cvt_f32_i32_e64 v1, v1 clamp mul:2` the translator emits `v1 = U((saturate(float(int(v1)))) * 2.0);` (and `* 0.5` for `div:2`), i.e. clamp first, then scale. As I read the RDNA 2 ISA reference, the output modifier scales the result first and clamp saturates after it, so this should be `saturate((float(int(v1))) * 2.0)`. For an input of 1 the hardware gives 1.0 and this lowering gives 2.0. The order comes from `Stage.set_vf`, which walks the modifiers in the order the decoder prints them (`clamp mul:2`); that is pre-existing for the `VEC_F` operations, but this PR is what makes the combination reachable for the seven conversions, and no case in the new test combines the two. Suggest applying omod first, then clamp, in `set_vf`, with a case for `clamp mul:2` and `clamp div:2`. **Test gaps (not blocking)** - `v_cvt_f32_ubyte0..3` have no case, so a wrong shift or mask there is not detected; `v_cvt_f32_u32` is checked only for the `* 2.0` wrapper, not its text. - The whitelist is exercised only by the uint-result refusal and a source negation (which is refused earlier as `Unsupported operand '-v1'`); no case passes `op_sel` or another modifier to a float-result conversion, so dropping the guard goes unnoticed. - The docs say issue #1705, the test docstring says #1696; the test file ends without a final newline. Not approving (comment only). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 18:02:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:50:32Z.

Review: COMMENTED


Review of head d7346d7e32 (comment only, not an approval).

Verdict: 1 P1, 1 P2. Update: the head moved from ceccbcae to d7346d7e ("apply the output modifier before the clamp") while I was reviewing. That commit changes only set_vf() (scale first, saturate last) and one test; both findings below still hold at the new head. sdwa() still has if base not in VEC_U: (line 401), the conversions are only in VEC_U_TO_F, and set_vf() still has elif m.startswith('op_sel'): pass. The two test files pass at the new head. The SDWA reproduction and the mutation list below were run at ceccbcae; I did not repeat them at the new head.

P1: the SDWA forms of the moved conversions stop translating (tools/startup/gfx2hlsl.py, sdwa() near line 392 and VEC_U_TO_F near line 1052)

  • On the base, v_cvt_f32_u32, v_cvt_f32_i32, v_cvt_f32_ubyte0..3 and v_cvt_f32_f16 are in VEC_U (base lines 1046-1050). This PR moves them to VEC_U_TO_F. sdwa() at line 392 only accepts names in VEC_U (if base not in VEC_U: raise Unsupported('SDWA form of ...')) and never looks at the new table.
  • Reproduction with a small stand-in stage, base versus head: v_cvt_f32_u32 with src0_sel:WORD_0, v_cvt_f32_i32 with src0_sel:BYTE_0, v_cvt_f32_f16 with src0_sel:WORD_0, v_cvt_f32_ubyte0 with src0_sel:BYTE_1. All four translate on the base (e.g. v1 = U(float(int(((v2 >> 0u) & 0xffu))));) and all four are refused at this head with Unsupported('SDWA form of v_cvt_f32_i32') and the matching messages.
  • No test catches it: startup_gfx2hlsl_sdwa_check only checks float SDWA is refused, and startup_gfx2hlsl_vcvt_omod_check has no SDWA case. Fix: let sdwa() also accept VEC_U_TO_F (wrapping in U(...)) and add a test that translates an SDWA conversion.

P2: the op_sel refusal is claimed but unguarded. The code comment and PR body say op_sel is refused; set_vf() ignores it silently, and the test covers only source negation (neg0=1), which is refused anyway because u() cannot parse -v1. Mutation D below confirms nothing guards it. Add refused() cases for op_sel:[1,0] and abs.

Run

  • python3 -B tests/startup_gfx2hlsl_vcvt_omod_check.py, startup_gfx2hlsl_sdwa_check.py, bit_alu, capture, smem_offset: pass. docs_links_check (17 files, 364 links) and bidi_controls_check: pass.
  • Mutations in gfx2hlsl.py (restored, green again): removing div:2 from the allowed tuple is caught; v_cvt_f32_i32 text changed to float({0}) is caught. NOT caught: v_cvt_f32_ubyte1 shift 8 -> 9, v_cvt_f32_ubyte3 shift 24 -> 23, v_cvt_f32_u32 -> float(int({0})), and replacing the modifier check with if False: (the P2).

Non-blocking

  • The test docstring says "issue #1696"; the issue is #1705 and #1696 is an unrelated PR.
  • The test never exercises v_cvt_f32_ubyte0..3, _e32 spellings, or clamp combined with mul, and builds words from the decoder's own layout.
  • tests/startup_gfx2hlsl_vcvt_omod_check.py has no trailing newline.
  • #1703, #1706 and #1708 touch VEC_U only in docs and tests; #1708's conversion draw test may need updating after this merges.

Not run: ctest, the DXC/FXC/D3D12 draw tests, the PR's release numbers and the census figures.

Linux limits: no Windows, MSVC, DXC or D3D12 device here; LLVM 19 only. Anything that needs them was not run.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044499254 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1707#pullrequestreview-6044499254). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:50:32Z. **Review:** COMMENTED --- Review of head d7346d7e32788a3a2053b11c647649d51e654141 (comment only, not an approval). Verdict: 1 P1, 1 P2. Update: the head moved from ceccbcae to d7346d7e ("apply the output modifier before the clamp") while I was reviewing. That commit changes only `set_vf()` (scale first, saturate last) and one test; both findings below still hold at the new head. `sdwa()` still has `if base not in VEC_U:` (line 401), the conversions are only in `VEC_U_TO_F`, and `set_vf()` still has `elif m.startswith('op_sel'): pass`. The two test files pass at the new head. The SDWA reproduction and the mutation list below were run at ceccbcae; I did not repeat them at the new head. P1: the SDWA forms of the moved conversions stop translating (tools/startup/gfx2hlsl.py, `sdwa()` near line 392 and `VEC_U_TO_F` near line 1052) - On the base, `v_cvt_f32_u32`, `v_cvt_f32_i32`, `v_cvt_f32_ubyte0..3` and `v_cvt_f32_f16` are in `VEC_U` (base lines 1046-1050). This PR moves them to `VEC_U_TO_F`. `sdwa()` at line 392 only accepts names in `VEC_U` (`if base not in VEC_U: raise Unsupported('SDWA form of ...')`) and never looks at the new table. - Reproduction with a small stand-in stage, base versus head: `v_cvt_f32_u32` with `src0_sel:WORD_0`, `v_cvt_f32_i32` with `src0_sel:BYTE_0`, `v_cvt_f32_f16` with `src0_sel:WORD_0`, `v_cvt_f32_ubyte0` with `src0_sel:BYTE_1`. All four translate on the base (e.g. `v1 = U(float(int(((v2 >> 0u) & 0xffu))));`) and all four are refused at this head with `Unsupported('SDWA form of v_cvt_f32_i32')` and the matching messages. - No test catches it: `startup_gfx2hlsl_sdwa_check` only checks float SDWA is refused, and `startup_gfx2hlsl_vcvt_omod_check` has no SDWA case. Fix: let `sdwa()` also accept `VEC_U_TO_F` (wrapping in `U(...)`) and add a test that translates an SDWA conversion. P2: the `op_sel` refusal is claimed but unguarded. The code comment and PR body say `op_sel` is refused; `set_vf()` ignores it silently, and the test covers only source negation (`neg0=1`), which is refused anyway because `u()` cannot parse `-v1`. Mutation D below confirms nothing guards it. Add `refused()` cases for `op_sel:[1,0]` and `abs`. Run - `python3 -B tests/startup_gfx2hlsl_vcvt_omod_check.py`, `startup_gfx2hlsl_sdwa_check.py`, `bit_alu`, `capture`, `smem_offset`: pass. docs_links_check (17 files, 364 links) and bidi_controls_check: pass. - Mutations in gfx2hlsl.py (restored, green again): removing `div:2` from the allowed tuple is caught; `v_cvt_f32_i32` text changed to `float({0})` is caught. NOT caught: `v_cvt_f32_ubyte1` shift 8 -> 9, `v_cvt_f32_ubyte3` shift 24 -> 23, `v_cvt_f32_u32` -> `float(int({0}))`, and replacing the modifier check with `if False:` (the P2). Non-blocking - The test docstring says "issue #1696"; the issue is #1705 and #1696 is an unrelated PR. - The test never exercises `v_cvt_f32_ubyte0..3`, `_e32` spellings, or `clamp` combined with `mul`, and builds words from the decoder's own layout. - tests/startup_gfx2hlsl_vcvt_omod_check.py has no trailing newline. - #1703, #1706 and #1708 touch `VEC_U` only in docs and tests; #1708's conversion draw test may need updating after this merges. Not run: ctest, the DXC/FXC/D3D12 draw tests, the PR's release numbers and the census figures. Linux limits: no Windows, MSVC, DXC or D3D12 device here; LLVM 19 only. Anything that needs them was not run. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 18:02:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:29:58Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T17:33:44.812955Z ceccbca PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139285536 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1707#issuecomment-7139285536). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T17:29:58Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"ceccbcaece12b41f03938379d28b5e24906a7e5a","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T17:33:44.812955Z">2026-11-24T17:33:44.812955Z</relative-time> | `ceccbca` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
triggered02 commented 2026-11-24 18:02:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T17:39:06Z.


Correct — fixed in d7346d7e.

The order was following the disassembler's text, which prints clamp before the omod, so set_vf() saturated and then multiplied. It now accumulates the scale, applies it, and saturates last:

v_cvt_f32_i32_e64 v1, v1 clamp mul:2   -> U(saturate((float(int(v1))) * 2.0))     (was: U(saturate(float(int(v1))) * 2.0))
v_cvt_f32_i32_e64 v1, v1 clamp div:2   -> U(saturate((float(int(v1))) * 0.5))

Single-modifier output is byte-identical to before (* 2.0, * 4.0, * 0.5), so this does not change the cases the PR already covered. The helper is shared by the other float operations, so a VOP3 float op carrying both modifiers was getting the same wrong order before this — that path is now correct too, not just conversions.

The test adds the two combined cases; swapping the blocks back fails it:

fail-first exit: 1 | clamp applies after the halving

All 7 startup_gfx2hlsl tests pass in dev and the new test passes in release. Thanks for catching it — the allow-list was the visible change but the operation order was the thing that would have silently disagreed with the hardware.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139506667 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1707#issuecomment-7139506667). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T17:39:06Z. --- Correct — fixed in `d7346d7e`. The order was following the disassembler's text, which prints `clamp` before the omod, so `set_vf()` saturated and then multiplied. It now accumulates the scale, applies it, and saturates last: ``` v_cvt_f32_i32_e64 v1, v1 clamp mul:2 -> U(saturate((float(int(v1))) * 2.0)) (was: U(saturate(float(int(v1))) * 2.0)) v_cvt_f32_i32_e64 v1, v1 clamp div:2 -> U(saturate((float(int(v1))) * 0.5)) ``` Single-modifier output is byte-identical to before (`* 2.0`, `* 4.0`, `* 0.5`), so this does not change the cases the PR already covered. The helper is shared by the other float operations, so a VOP3 float op carrying both modifiers was getting the same wrong order before this — that path is now correct too, not just conversions. The test adds the two combined cases; swapping the blocks back fails it: ``` fail-first exit: 1 | clamp applies after the halving ``` All 7 `startup_gfx2hlsl` tests pass in dev and the new test passes in release. Thanks for catching it — the allow-list was the visible change but the operation order was the thing that would have silently disagreed with the hardware. AI-assisted (Claude Code).
R0Y00 commented 2026-11-24 18:02:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T17:50:38Z.


Independently verified d7346d7e with a source-built flat-parameter pixel draw for v_cvt_f32_f16 clamp div:2. FXC and DXC both produced 3f800000,3f000000,00000000,3e000000 from half inputs 2, 1, -2, 0.25 on RTX 4060 Laptop (32.0.16.1656) and WARP (10.0.26100.9818). A clamp-before-scale mutation read 3f000000 in the first lane on all four runs and failed the comparison. The debug layer was enabled with zero errors and warnings. Please keep the #1708 draw coverage separate; its old blanket refusal for this float-result modifier will need to be adjusted once this lands.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139784744 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1707#issuecomment-7139784744). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T17:50:38Z. --- Independently verified d7346d7e with a source-built flat-parameter pixel draw for v_cvt_f32_f16 clamp div:2. FXC and DXC both produced 3f800000,3f000000,00000000,3e000000 from half inputs 2, 1, -2, 0.25 on RTX 4060 Laptop (32.0.16.1656) and WARP (10.0.26100.9818). A clamp-before-scale mutation read 3f000000 in the first lane on all four runs and failed the comparison. The debug layer was enabled with zero errors and warnings. Please keep the #1708 draw coverage separate; its old blanket refusal for this float-result modifier will need to be adjusted once this lands.
triggered02 commented 2026-11-24 18:03:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T17:54:45Z.


Thanks — the P1 is real and it is a regression I introduced, so it gets a follow-up rather than a note: #1730.

sdwa() now accepts VEC_U_TO_F as well, wrapping the float result in U(...) before the destination selection writes its bit pattern, so the four forms you reproduced translate again:

v_cvt_f32_u32_sdwa v0, v1 src0_sel:WORD_0 -> v0 = U(float(((v1 >> 0u) & 0xffffu)));
v_cvt_f32_i32_sdwa v0, v1 src0_sel:BYTE_0 -> v0 = U(float(int(((v1 >> 0u) & 0xffu))));

The test builds the SDWA encodings (SRC0 = 249 marks the form, control word in the next dword) and decodes them before translating, covers the destination selections and UNUSED_PRESERVE, keeps the uint-result conversion on the uint path, and fails if the new branch is removed. All 9 startup_gfx2hlsl tests pass in dev and the new one in release.

Your P2 (op_sel claimed refused but silently ignored by set_vf) is not bundled into that fix: making set_vf raise touches every float path that uses it, so it needs a sweep of the existing tests rather than a ride-along on a regression fix. It is queued as its own slice, along with the unexercised v_cvt_f32_ubyte* shifts you noted.

I should have run startup_gfx2hlsl_sdwa_check against the change rather than only the new test — the SDWA path was exactly the caller I did not check.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139883644 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1707#issuecomment-7139883644). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T17:54:45Z. --- Thanks — the P1 is real and it is a regression I introduced, so it gets a follow-up rather than a note: **#1730**. `sdwa()` now accepts `VEC_U_TO_F` as well, wrapping the float result in `U(...)` before the destination selection writes its bit pattern, so the four forms you reproduced translate again: ``` v_cvt_f32_u32_sdwa v0, v1 src0_sel:WORD_0 -> v0 = U(float(((v1 >> 0u) & 0xffffu))); v_cvt_f32_i32_sdwa v0, v1 src0_sel:BYTE_0 -> v0 = U(float(int(((v1 >> 0u) & 0xffu)))); ``` The test builds the SDWA encodings (`SRC0 = 249` marks the form, control word in the next dword) and decodes them before translating, covers the destination selections and `UNUSED_PRESERVE`, keeps the uint-result conversion on the uint path, and fails if the new branch is removed. All 9 `startup_gfx2hlsl` tests pass in dev and the new one in release. Your **P2** (`op_sel` claimed refused but silently ignored by `set_vf`) is not bundled into that fix: making `set_vf` raise touches every float path that uses it, so it needs a sweep of the existing tests rather than a ride-along on a regression fix. It is queued as its own slice, along with the unexercised `v_cvt_f32_ubyte*` shifts you noted. I should have run `startup_gfx2hlsl_sdwa_check` against the change rather than only the new test — the SDWA path was exactly the caller I did not check. AI-assisted (Claude Code).
chatgpt-codex-connector[bot commented 2026-11-24 18:03:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:33:42Z.

Code review location: tools/startup/gfx2hlsl.py; line 366

@@ -357,6 +357,16 @@ def one(self, name, asm):
             if base in ('v_fmac_f32', 'v_mac_f32'):
                 args.append(self.f(ops[0]))
             return self.set_vf(reg_range(ops[0])[1], text.format(*args), mods)
+        if base in VEC_U_TO_F:
+            arity, text_f = VEC_U_TO_F[base]
+            if len(ops) != arity + 1:
+                raise Unsupported('%s with %d operands, expected %d' % (base, len(ops), arity + 1))
+            # Only the output modifiers a conversion can carry; op_sel and the source modifiers are not
+            # accepted here, because ignoring them would silently change the operand.
+            if any(m not in ('clamp', 'mul:2', 'mul:4', 'div:2') for m in mods):

P2 Badge Apply output scaling before clamp

When a VOP3 conversion has both clamp and an OMOD, this allow-list accepts the pair and set_vf() applies the decoded clamp mul:2 order left-to-right, emitting 2 * saturate(result). RDNA applies the OMOD before the final clamp, so converting 1 with mul:2 clamp should yield 1 rather than 2; lower the pair in hardware order or reject combined modifiers.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4684010082 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1707#discussion_r4684010082). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T17:33:42Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 366 ~~~~diff @@ -357,6 +357,16 @@ def one(self, name, asm): if base in ('v_fmac_f32', 'v_mac_f32'): args.append(self.f(ops[0])) return self.set_vf(reg_range(ops[0])[1], text.format(*args), mods) + if base in VEC_U_TO_F: + arity, text_f = VEC_U_TO_F[base] + if len(ops) != arity + 1: + raise Unsupported('%s with %d operands, expected %d' % (base, len(ops), arity + 1)) + # Only the output modifiers a conversion can carry; op_sel and the source modifiers are not + # accepted here, because ignoring them would silently change the operand. + if any(m not in ('clamp', 'mul:2', 'mul:4', 'div:2') for m in mods): ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Apply output scaling before clamp** When a VOP3 conversion has both `clamp` and an OMOD, this allow-list accepts the pair and `set_vf()` applies the decoded `clamp mul:2` order left-to-right, emitting `2 * saturate(result)`. RDNA applies the OMOD before the final clamp, so converting `1` with `mul:2 clamp` should yield `1` rather than `2`; lower the pair in hardware order or reject combined modifiers. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
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!1700
No description provided.