startup: lower abs source modifiers on v_cndmask_b32_e64 #2431

Merged
triggered02 merged 2 commits from upstream-pr/2439 into main 2026-11-26 00:55:26 +00:00
triggered02 commented 2026-11-25 16:48:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T16:48:05Z.


Lowers abs (|src| and -|src|) on v_cndmask_b32_e64 register data sources in tools/startup/gfx2hlsl.py.

What changed

  • tools/startup/gfx2hlsl.py: Stage.u_src now handles |...| after split_neg(tok), applying (%s & 0x7fffffffu) first for abs and (%s ^ 0x80000000u) second for neg per RDNA2 VOP3A source-modifier order (so |v0| -> (v0 & 0x7fffffffu), -|v0| -> ((v0 & 0x7fffffffu) ^ 0x80000000u)). check_encoding() continues to refuse ABS on immediates, Stage.u() continues to refuse low16_only_v whole-word reads, and src2 mask modifiers stay refused.
  • tests/startup_gfx2hlsl_cndmask_abs_check.py, tests/startup_gfx2hlsl_cndmask_neg_check.py (removed the 3 superseded VGPR abs refusal checks while keeping immediate ABS/neg_mask and adding v_and_b32_e64 abs refusal), CMakeLists.txt, and docs/experiments.md.

Measured checks (30c2e6be on origin/main b442b57f)

  • tests/startup_gfx2hlsl_cndmask_abs_check.py (pure Python): PASS (31 checks: synthetic VOP3A decoding incl. v_cndmask_b32_e64 v0, v0, |v0|, s30, SGPR |s4|/-|s4|, 17 refusal controls, CPU evaluation across 22 combinations of 11 IEEE bit patterns incl. -0.0/qNaN/inf, and 22/22 mismatch checks for order-reversed & abs-dropped mutations).
  • tests/startup_gfx2hlsl_cndmask_abs_check.py draw <dxc> <offscreen_check> warp <fxc> (Microsoft Basic Render Driver 1414:008c, 10.0.26100.9818): PASS — 44/44 positive draws (22 FXC ps_5_1 + 22 DXC ps_6_0) matched bit-for-bit, and 8/8 mutated draws failed with exact wrong words.
  • 63/63 pure-Python startup_gfx2hlsl_*_check.py + startup_translator_check.py, docs_links_check.py (467 links), bidi_controls_check.py (1,726 files), git diff --check: all PASS.
  • 2 fail-first mutations on tools/startup/gfx2hlsl.py (dropping abs; reversing neg/abs order): both caught (exit 1).

Not established

  • AMD hardware was not exercised. The physical-GPU hardware draw has since been measured by @Makto94 on an NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.2101), Windows 11 build 26300.9974, MSVC 19.44.35230, dev preset, serial -j1 runs: startup_gfx2hlsl_cndmask_abs_hardware passed with debug_errors=0 debug_warnings=0, 0 capability skips, 22 cases through both the FXC and DXC paths (44 readbacks), and all four mutations reported fails as expected in both paths (report: https://github.com/R0Y00/Xbox2Windows/pull/2439#issuecomment-7170698898).

AI-assisted (Gemini).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6609286357 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2439). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-25T16:48:05Z. --- Lowers `abs` (`|src|` and `-|src|`) on `v_cndmask_b32_e64` register data sources in `tools/startup/gfx2hlsl.py`. ### What changed - **`tools/startup/gfx2hlsl.py`**: `Stage.u_src` now handles `|...|` after `split_neg(tok)`, applying `(%s & 0x7fffffffu)` first for `abs` and `(%s ^ 0x80000000u)` second for `neg` per RDNA2 VOP3A source-modifier order (so `|v0|` -> `(v0 & 0x7fffffffu)`, `-|v0|` -> `((v0 & 0x7fffffffu) ^ 0x80000000u)`). `check_encoding()` continues to refuse `ABS` on immediates, `Stage.u()` continues to refuse `low16_only_v` whole-word reads, and `src2` mask modifiers stay refused. - **`tests/startup_gfx2hlsl_cndmask_abs_check.py`**, **`tests/startup_gfx2hlsl_cndmask_neg_check.py`** (removed the 3 superseded VGPR `abs` refusal checks while keeping immediate `ABS`/`neg_mask` and adding `v_and_b32_e64` `abs` refusal), **`CMakeLists.txt`**, and **`docs/experiments.md`**. ### Measured checks (`30c2e6be` on `origin/main` `b442b57f`) - `tests/startup_gfx2hlsl_cndmask_abs_check.py` (pure Python): PASS (31 checks: synthetic VOP3A decoding incl. `v_cndmask_b32_e64 v0, v0, |v0|, s30`, SGPR `|s4|`/`-|s4|`, 17 refusal controls, CPU evaluation across 22 combinations of 11 IEEE bit patterns incl. `-0.0`/`qNaN`/`inf`, and 22/22 mismatch checks for order-reversed & `abs`-dropped mutations). - `tests/startup_gfx2hlsl_cndmask_abs_check.py draw <dxc> <offscreen_check> warp <fxc>` (Microsoft Basic Render Driver `1414:008c`, `10.0.26100.9818`): PASS — 44/44 positive draws (22 FXC `ps_5_1` + 22 DXC `ps_6_0`) matched bit-for-bit, and 8/8 mutated draws failed with exact wrong words. - 63/63 pure-Python `startup_gfx2hlsl_*_check.py` + `startup_translator_check.py`, `docs_links_check.py` (467 links), `bidi_controls_check.py` (1,726 files), `git diff --check`: all PASS. - 2 fail-first mutations on `tools/startup/gfx2hlsl.py` (dropping `abs`; reversing `neg`/`abs` order): both caught (exit 1). ### Not established - AMD hardware was not exercised. The physical-GPU `hardware` draw has since been measured by @Makto94 on an NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.2101), Windows 11 build 26300.9974, MSVC 19.44.35230, `dev` preset, serial `-j1` runs: `startup_gfx2hlsl_cndmask_abs_hardware` passed with `debug_errors=0 debug_warnings=0`, 0 capability skips, 22 cases through both the FXC and DXC paths (44 readbacks), and all four mutations reported `fails as expected` in both paths (report: https://github.com/R0Y00/Xbox2Windows/pull/2439#issuecomment-7170698898). AI-assisted (Gemini).
chatgpt-codex-connector[bot commented 2026-11-25 17:01:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T16:48:21Z.


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-25T16:50:12.026323Z 30c2e6b 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:7168559031 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2439#issuecomment-7168559031). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T16:48:21Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"30c2e6be1a44b2c55a883e6da184dd94fa7c1265","has_any_findings":false,"has_unresolved_findings":false,"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-25T16:50:12.026323Z">2026-11-25T16:50:12.026323Z</relative-time> | `30c2e6b` | 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>
tedin7 commented 2026-11-25 19:03:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:24:13Z.

Review: COMMENTED


Review of head 30c2e6be (comment only, no Windows run from me).

Checked:

  • Stage.u_src (gfx2hlsl.py): abs is applied first (& 0x7fffffffu), then neg (^ 0x80000000u). That is the VOP3 modifier order, so -|x| forces bit 31 to 1. Its only caller is the v_cndmask_b32_e64 data sources (line ~4063). Other integer ops still go through u() and keep refusing |..|.
  • Refusals stay in place: abs on an immediate, abs on the mask operand, and abs on another integer op. The old "abs is refused" checks in startup_gfx2hlsl_cndmask_neg_check.py are replaced by one that still pins the refusal on AND_B32.
  • Tests guard the behavior: the new check compares the emitted HLSL against an ISA reference on 11 bit patterns x 2 mask states, and the desktop draw runs on WARP and hardware with FXC and DXC. This is a real readback, not a string check.
  • Sibling wiring: CMake adds controls, warp and hardware tests next to bit_alu; the docs section is added.
  • Author's Windows results: the hardware comment (RTX 3070 Ti, 3/3 abs tests and the neg test passed) names head 30c2e6be, which is the current head. I did not re-run them.
  • Possible overlap: open #2449 ("support |x| abs modifier on v_cndmask_b32_e64 operands") appears to cover the same slice. This PR was opened first, so the authors may want to settle which one goes in.

Commands run (Linux):

  • python3 -B tests/startup_gfx2hlsl_cndmask_abs_check.py: PASS
  • python3 -B tests/startup_gfx2hlsl_cndmask_neg_check.py: PASS
  • python3 tests/docs_links_check.py: pass
  • python3 tests/bidi_controls_check.py: pass
  • git diff --check origin/main...HEAD: clean
  • Mutation 1: drop the abs mask in u_src. The abs check fails.
  • Mutation 2: drop the neg flip in u_src. The abs check fails.
  • Both mutations reverted with git checkout -- ..

No blocking findings. The branch is 23 commits behind main; I did not update it, so the author's test results stay tied to this head.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6062832409 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2439#pullrequestreview-6062832409). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T18:24:13Z. **Review:** COMMENTED --- Review of head `30c2e6be` (comment only, no Windows run from me). Checked: - `Stage.u_src` (gfx2hlsl.py): abs is applied first (`& 0x7fffffffu`), then neg (`^ 0x80000000u`). That is the VOP3 modifier order, so `-|x|` forces bit 31 to 1. Its only caller is the `v_cndmask_b32_e64` data sources (line ~4063). Other integer ops still go through `u()` and keep refusing `|..|`. - Refusals stay in place: abs on an immediate, abs on the mask operand, and abs on another integer op. The old "abs is refused" checks in `startup_gfx2hlsl_cndmask_neg_check.py` are replaced by one that still pins the refusal on `AND_B32`. - Tests guard the behavior: the new check compares the emitted HLSL against an ISA reference on 11 bit patterns x 2 mask states, and the desktop draw runs on WARP and hardware with FXC and DXC. This is a real readback, not a string check. - Sibling wiring: CMake adds `controls`, `warp` and `hardware` tests next to `bit_alu`; the docs section is added. - Author's Windows results: the hardware comment (RTX 3070 Ti, 3/3 abs tests and the `neg` test passed) names head `30c2e6be`, which is the current head. I did not re-run them. - Possible overlap: open #2449 ("support |x| abs modifier on v_cndmask_b32_e64 operands") appears to cover the same slice. This PR was opened first, so the authors may want to settle which one goes in. Commands run (Linux): - `python3 -B tests/startup_gfx2hlsl_cndmask_abs_check.py`: PASS - `python3 -B tests/startup_gfx2hlsl_cndmask_neg_check.py`: PASS - `python3 tests/docs_links_check.py`: pass - `python3 tests/bidi_controls_check.py`: pass - `git diff --check origin/main...HEAD`: clean - Mutation 1: drop the abs mask in `u_src`. The abs check fails. - Mutation 2: drop the neg flip in `u_src`. The abs check fails. - Both mutations reverted with `git checkout -- .`. No blocking findings. The branch is 23 commits behind main; I did not update it, so the author's test results stay tied to this head. AI-assisted; commands listed were executed locally.
Makto94 commented 2026-11-25 19:04:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-25T18:17:09Z.


Hardware run and Windows 11 MSVC build at head 30c2e6be.

Environment: Windows 11 Pro build 26300.9974, Debug (dev preset), MSVC toolset 14.44.35207 (cl 19.44.35230.0), driver 32.0.16.2101. The hardware test prints adapter=NVIDIA GeForce RTX 3070 Ti vendor=10de device=2482 and backend=hardware debug_layer=enabled, with debug_errors=0 debug_warnings=0. The runs were serial (-j1).

Build: cmake --build --preset dev exited 0. This PR changes no C++ source.

Tests:

  • ctest --preset dev --no-tests=error -j1 -R 'startup_gfx2hlsl_cndmask_abs' -E 'hardware' -V: 2/2 passed (startup_gfx2hlsl_cndmask_abs_controls, _warp).
  • ctest --preset dev --no-tests=error -j1 -R 'startup_gfx2hlsl_cndmask_abs_hardware' -V: 1/1 passed. 0 capability skips (77).
  • ctest --preset dev --no-tests=error -j1 -R '^startup_gfx2hlsl_cndmask_neg$': 1/1 passed (CPU-only check, also changed by this PR).

The hardware test checks 22 cases through both the fxc and the dxc path (44 readbacks) and prints PASS. The 4 mutations (rev_neg_one_m1, drop_neg_one_m1, rev_neg_zero_m0, drop_neg_zero_m0) each print fails as expected in both paths, so the check can fail.

The PR body lists as not established: "Physical GPU hardware draw was not run locally (WARP only)." This run adds that measurement.

Not covered by this run: AMD hardware; only these 22 cases were run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7170698898 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2439#issuecomment-7170698898). Originally posted by [Makto94](https://github.com/Makto94) on 2026-11-25T18:17:09Z. --- Hardware run and Windows 11 MSVC build at head `30c2e6be`. Environment: Windows 11 Pro build 26300.9974, Debug (`dev` preset), MSVC toolset 14.44.35207 (cl 19.44.35230.0), driver 32.0.16.2101. The hardware test prints `adapter=NVIDIA GeForce RTX 3070 Ti vendor=10de device=2482` and `backend=hardware debug_layer=enabled`, with `debug_errors=0 debug_warnings=0`. The runs were serial (`-j1`). Build: `cmake --build --preset dev` exited 0. This PR changes no C++ source. Tests: - `ctest --preset dev --no-tests=error -j1 -R 'startup_gfx2hlsl_cndmask_abs' -E 'hardware' -V`: 2/2 passed (`startup_gfx2hlsl_cndmask_abs_controls`, `_warp`). - `ctest --preset dev --no-tests=error -j1 -R 'startup_gfx2hlsl_cndmask_abs_hardware' -V`: 1/1 passed. 0 capability skips (77). - `ctest --preset dev --no-tests=error -j1 -R '^startup_gfx2hlsl_cndmask_neg$'`: 1/1 passed (CPU-only check, also changed by this PR). The hardware test checks 22 cases through both the fxc and the dxc path (44 readbacks) and prints `PASS`. The 4 mutations (`rev_neg_one_m1`, `drop_neg_one_m1`, `rev_neg_zero_m0`, `drop_neg_zero_m0`) each print `fails as expected` in both paths, so the check can fail. The PR body lists as not established: "Physical GPU `hardware` draw was not run locally (WARP only)." This run adds that measurement. Not covered by this run: AMD hardware; only these 22 cases were run.
triggered02 commented 2026-11-25 19:04:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T18:45:43Z.


Thanks � recorded in the PR description: the physical-GPU hardware draw is no longer listed as not established. The body now cites your RTX 3070 Ti run (driver 32.0.16.2101, Windows build 26300.9974, MSVC 19.44.35230, dev preset, debug_errors=0 debug_warnings=0, 0 skips), the 22 cases through both the FXC and DXC paths, and that all four mutations reported \ ails as expected, with a link to your comment. AMD hardware stays listed as unexercised, and this PR's head is unchanged at 30c2e6be, so your measurement is of the current head � nothing to re-run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7171360251 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2439#issuecomment-7171360251). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-25T18:45:43Z. --- Thanks � recorded in the PR description: the physical-GPU hardware draw is no longer listed as not established. The body now cites your RTX 3070 Ti run (driver 32.0.16.2101, Windows build 26300.9974, MSVC 19.44.35230, dev preset, debug_errors=0 debug_warnings=0, 0 skips), the 22 cases through both the FXC and DXC paths, and that all four mutations reported \ ails as expected\, with a link to your comment. AMD hardware stays listed as unexercised, and this PR's head is unchanged at 30c2e6be, so your measurement is of the current head � nothing to re-run.
tedin7 commented 2026-11-25 21:00:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:07:26Z.

Review: COMMENTED


Review of head 8246b007 (comment review, no merge from this side).

Checked:

  • Stage.u_src in tools/startup/gfx2hlsl.py: abs applied first (& 0x7fffffffu), neg second (^ 0x80000000u), matching the VOP3 modifier order. The only callsite is the v_cndmask_b32_e64 data sources; other integer handlers still use u() and keep refusing modifiers.
  • tests/startup_gfx2hlsl_cndmask_abs_check.py and the updated tests/startup_gfx2hlsl_cndmask_neg_check.py: PASS. The abs test has a CPU reference plus a D3D12 WARP readback mode (draw).
  • Mutation: dropping the abs mask makes startup_gfx2hlsl_cndmask_abs_check.py fail (exit 1).
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: clean.

Finding (overlap, design question): #2449 (startup/cndmask-abs-operand) lowers the same |x| modifier on v_cndmask_b32_e64 operands in gfx2hlsl. Two PRs for the same slice will conflict in Stage.u_src / the cndmask tests. The code here looks sound, so the question is only which one lands. Leaving the choice to @R0Y00; I am not merging while both are open.

I did not run Win2025 and did not verify any game startup.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064225915 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2439#pullrequestreview-6064225915). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:07:26Z. **Review:** COMMENTED --- Review of head 8246b007 (comment review, no merge from this side). Checked: - `Stage.u_src` in `tools/startup/gfx2hlsl.py`: abs applied first (`& 0x7fffffffu`), neg second (`^ 0x80000000u`), matching the VOP3 modifier order. The only callsite is the `v_cndmask_b32_e64` data sources; other integer handlers still use `u()` and keep refusing modifiers. - `tests/startup_gfx2hlsl_cndmask_abs_check.py` and the updated `tests/startup_gfx2hlsl_cndmask_neg_check.py`: PASS. The abs test has a CPU reference plus a D3D12 WARP readback mode (`draw`). - Mutation: dropping the abs mask makes `startup_gfx2hlsl_cndmask_abs_check.py` fail (exit 1). - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: clean. Finding (overlap, design question): #2449 (`startup/cndmask-abs-operand`) lowers the same `|x|` modifier on `v_cndmask_b32_e64` operands in `gfx2hlsl`. Two PRs for the same slice will conflict in `Stage.u_src` / the cndmask tests. The code here looks sound, so the question is only which one lands. Leaving the choice to @R0Y00; I am not merging while both are open. I did not run Win2025 and did not verify any game startup. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 01:01:49 +00:00
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!2431
No description provided.