tooling: translate VOP1/VOP2 sub-dword addressing in gfx2hlsl #1249

Merged
triggered02 merged 1 commit from upstream-pr/1256 into main 2026-11-24 05:58:02 +00:00
triggered02 commented 2026-11-24 05:39:07 +00:00 (Migrated from github.com)

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


Translates the SDWA forms this issue names. tools/startup/gfx2hlsl.py no longer stops on them: the byte and word selects of the 32-bit integer VOP1/VOP2 forms are lowered, with source zero-extension, sext() sign extension, destination field placement, and UNUSED_PAD / UNUSED_PRESERVE.

Parity with the pixel AOT path is checked mechanically, not by eye. startup_gfx2hlsl_sdwa compares the selection helpers against tools/pixel_aot.py for every selection (BYTE_0..3, WORD_0..1, DWORD) with and without sext(), and for the destination with both unused forms — the expressions must be identical. Then it drives the translator on gfx1013 assembly for:

case checked
byte destination + byte source + word source all three selects appear in the HLSL
sext(v5) with src0_sel:BYTE_0 emits asuint(asint(v5 << 24u) >> 24u)
dst_unused:UNUSED_PRESERVE keeps the destination's other bits
all-DWORD reduces to the plain operation (v9 = v10 ^ v11)
float SDWA, UNUSED_SEXT, missing src0_sel refused, not mistranslated

Two bugs this caught while writing it, both real:

  • Operator precedence. v_or_b32 with dst_sel:WORD_1 first emitted (v7 | v8 & 0xffff) << 16, which binds as v7 | (v8 & 0xffff) and keeps bits the hardware clears. The operation's HLSL is now grouped before the destination mask: (((v7 | v8) & 0xffffu) << 16u).
  • sext() is a shift pair, not a mask — a byte selection has to sign-extend through the whole word.

Still refused, and recorded in docs/startup-runtime.md: float SDWA forms and dst_unused:UNUSED_SEXT. Nothing is translated to something inexact.

Measured on the release preset: startup_gfx2hlsl_sdwa passes; docs_links_check.py passes. The startup_stream_* checks fail on this machine both before and after the change (missing external assembler, FileNotFoundError), so they are not a regression — I checked against a clean main checkout rather than assuming.

I did not run a full title startup from this branch, so I have not measured whether the pipeline that previously stopped on SDWA now translates; say the word and I will run one and report the pipeline count.

Closes #1141.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6575434959 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1256). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T05:39:07Z. --- Translates the SDWA forms this issue names. `tools/startup/gfx2hlsl.py` no longer stops on them: the byte and word selects of the 32-bit integer VOP1/VOP2 forms are lowered, with source zero-extension, `sext()` sign extension, destination field placement, and `UNUSED_PAD` / `UNUSED_PRESERVE`. **Parity with the pixel AOT path is checked mechanically, not by eye.** `startup_gfx2hlsl_sdwa` compares the selection helpers against `tools/pixel_aot.py` for every selection (`BYTE_0..3`, `WORD_0..1`, `DWORD`) with and without `sext()`, and for the destination with both unused forms — the expressions must be identical. Then it drives the translator on gfx1013 assembly for: | case | checked | |---|---| | byte destination + byte source + word source | all three selects appear in the HLSL | | `sext(v5)` with `src0_sel:BYTE_0` | emits `asuint(asint(v5 << 24u) >> 24u)` | | `dst_unused:UNUSED_PRESERVE` | keeps the destination's other bits | | all-DWORD | reduces to the plain operation (`v9 = v10 ^ v11`) | | float SDWA, `UNUSED_SEXT`, missing `src0_sel` | refused, not mistranslated | Two bugs this caught while writing it, both real: - **Operator precedence.** `v_or_b32` with `dst_sel:WORD_1` first emitted `(v7 | v8 & 0xffff) << 16`, which binds as `v7 | (v8 & 0xffff)` and keeps bits the hardware clears. The operation's HLSL is now grouped before the destination mask: `(((v7 | v8) & 0xffffu) << 16u)`. - **`sext()` is a shift pair, not a mask** — a byte selection has to sign-extend through the whole word. Still refused, and recorded in `docs/startup-runtime.md`: float SDWA forms and `dst_unused:UNUSED_SEXT`. Nothing is translated to something inexact. Measured on the `release` preset: `startup_gfx2hlsl_sdwa` passes; `docs_links_check.py` passes. The `startup_stream_*` checks fail on this machine both before and after the change (missing external assembler, `FileNotFoundError`), so they are not a regression — I checked against a clean `main` checkout rather than assuming. I did not run a full title startup from this branch, so I have not measured whether the pipeline that previously stopped on SDWA now translates; say the word and I will run one and report the pipeline count. Closes #1141.
upstream-sync closed this pull request 2026-11-24 06:47:21 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:50:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:39:16Z.


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-24T05:43:07.573602Z 83d4e18 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:7123149120 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1256#issuecomment-7123149120). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T05:39:16Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"83d4e18ec24e565bac61b6aa1312493b611f2442","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-24T05:43:07.573602Z">2026-11-24T05:43:07.573602Z</relative-time> | `83d4e18` | 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 06:50:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T05:52:05Z.


Measured impact, and it is weaker than the issue implies — reporting it rather than letting the PR look like a pipeline win.

I captured a fresh shader cache from an offline startup (-ShaderCache, run to the known null at 88 s, 1,869 frames) and translated the four pipelines with gfx2hlsl.py --pending:

translator result
this branch (SDWA + main) 4/4 ok, 0 .fail
origin/main (4182af8f, no SDWA) 4/4 ok, 0 .fail

So the two pipelines that used to fail were blocked by s_setprio, not by SDWA — #1241 is merged and that is what unblocked them. Since origin/main's translator raises Unsupported on any SDWA form, a 4/4 result there also proves none of these four pipelines contains an SDWA instruction. This change is therefore not exercised by the capture I can reach: the run stops at 88 s, before any pipeline that would need it is requested.

What that leaves:

  • The change removes a hard stop for pipelines that do use byte/word selects, and is tested against the pixel AOT lowering, so it is safe to carry.
  • But I have no evidence it converts a real missing pipeline, and the issue's premise ("at least one pixel pipeline is left untranslated because of it") is not confirmed by the capture available to me.

Your call, and I am fine either way: keep it as ahead-of-need coverage with the fixture, or close it and reopen when a capture actually hits a v_*_sdwa form — the fixture and the parity checks would be the thing to bring back. I would rather close it than have an unexercised translator path looking like a fix.

For completeness, the same run also re-confirms #1240's clamp against current main: the heap request of 1,245,184 descriptors is refused and clamped to the measured 1,000,000, and the run proceeds to 1,869 frames at 28.7 fps instead of stopping at ~2 s.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123349952 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1256#issuecomment-7123349952). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T05:52:05Z. --- Measured impact, and it is weaker than the issue implies — reporting it rather than letting the PR look like a pipeline win. I captured a fresh shader cache from an offline startup (`-ShaderCache`, run to the known null at 88 s, 1,869 frames) and translated the four pipelines with `gfx2hlsl.py --pending`: | translator | result | |---|---| | this branch (SDWA + main) | 4/4 ok, 0 `.fail` | | `origin/main` (`4182af8f`, no SDWA) | 4/4 ok, 0 `.fail` | So **the two pipelines that used to fail were blocked by `s_setprio`, not by SDWA** — #1241 is merged and that is what unblocked them. Since `origin/main`'s translator raises `Unsupported` on any SDWA form, a 4/4 result there also proves **none of these four pipelines contains an SDWA instruction**. This change is therefore not exercised by the capture I can reach: the run stops at 88 s, before any pipeline that would need it is requested. What that leaves: - The change removes a hard stop for pipelines that *do* use byte/word selects, and is tested against the pixel AOT lowering, so it is safe to carry. - But I have **no evidence it converts a real missing pipeline**, and the issue's premise ("at least one pixel pipeline is left untranslated because of it") is not confirmed by the capture available to me. Your call, and I am fine either way: keep it as ahead-of-need coverage with the fixture, or close it and reopen when a capture actually hits a `v_*_sdwa` form — the fixture and the parity checks would be the thing to bring back. I would rather close it than have an unexercised translator path looking like a fix. For completeness, the same run also re-confirms #1240's clamp against current `main`: the heap request of 1,245,184 descriptors is refused and clamped to the measured 1,000,000, and the run proceeds to 1,869 frames at 28.7 fps instead of stopping at ~2 s.
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!1249
No description provided.