startup-runtime: gfx2hlsl does not support VOP2 SDWA #1134

Closed
opened 2026-11-24 01:45:29 +00:00 by denn0x · 4 comments
denn0x commented 2026-11-24 01:45:29 +00:00 (Migrated from github.com)
Contributor

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


Problem

tools/startup/gfx2hlsl.py stops on vop2_sdwa instructions (sub-dword addressing: byte/word selects,
sign extension, clamp). At least one pixel pipeline is left untranslated because of it.

Done when

SDWA source/destination selects are translated, with a gfx1013 assembly fixture that covers byte and word
selects and compares against the existing pixel AOT path.

Context: docs/startup-runtime.md (#1135). Do not attach game files, dumps or logs that contain addresses or names from an executable; describe results in terms of the component tested.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572713032 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1141). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-24T01:45:29Z. --- ## Problem `tools/startup/gfx2hlsl.py` stops on `vop2_sdwa` instructions (sub-dword addressing: byte/word selects, sign extension, clamp). At least one pixel pipeline is left untranslated because of it. ## Done when SDWA source/destination selects are translated, with a gfx1013 assembly fixture that covers byte and word selects and compares against the existing pixel AOT path. Context: `docs/startup-runtime.md` (#1135). Do not attach game files, dumps or logs that contain addresses or names from an executable; describe results in terms of the component tested. AI-assisted (Claude Code).
rasptum commented 2026-11-24 06:50:07 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-24T02:04:53Z.


Claiming this.

  • Scope: SDWA source and destination selects (byte and word, sign and zero extension, destination preserve or pad) for vop2_sdwa in tools/startup/gfx2hlsl.py.
  • Evidence: a gfx1013 assembly fixture with byte and word selects, compared against the existing pixel AOT path, plus a negative control for an unsupported select.
  • Out of scope: VOPC SDWA and anything in the stream-pipeline path (#1142).

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119735090 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1141#issuecomment-7119735090). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-24T02:04:53Z. --- Claiming this. - **Scope:** SDWA source and destination selects (byte and word, sign and zero extension, destination preserve or pad) for `vop2_sdwa` in `tools/startup/gfx2hlsl.py`. - **Evidence:** a gfx1013 assembly fixture with byte and word selects, compared against the existing pixel AOT path, plus a negative control for an unsupported select. - **Out of scope:** VOPC SDWA and anything in the stream-pipeline path (#1142). AI-assisted (Claude Code).
triggered02 commented 2026-11-24 06:50:27 +00:00 (Migrated from github.com)
Author
Contributor

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


Taking this. Plan: translate VOP2 SDWA source and destination selects in ools/startup/gfx2hlsl.py (byte/word selects, sign extension, destination select and unused lanes, clamp), and check the result against the existing ools/pixel_aot.py lowering for the same encodings with a source-built gfx1013 fixture.

Starting from the encodings the decoder already produces, so the fixture needs no assembler here (LLVM's MC tests supply the golden bytes).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123088486 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1141#issuecomment-7123088486). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T05:35:22Z. --- Taking this. Plan: translate VOP2 SDWA source and destination selects in ools/startup/gfx2hlsl.py (byte/word selects, sign extension, destination select and unused lanes, clamp), and check the result against the existing ools/pixel_aot.py lowering for the same encodings with a source-built gfx1013 fixture. Starting from the encodings the decoder already produces, so the fixture needs no assembler here (LLVM's MC tests supply the golden bytes).
triggered02 commented 2026-11-24 06:50:27 +00:00 (Migrated from github.com)
Author
Contributor

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


Implemented as PR #1256.

Scope: the byte and word selects of the 32-bit integer VOP1/VOP2 SDWA forms, with source zero-extension, \sext()\ sign extension, destination field placement, and \UNUSED_PAD\ / \UNUSED_PRESERVE. The selection helpers now match \ ools/pixel_aot.py\ exactly, and \startup_gfx2hlsl_sdwa\ enforces that parity mechanically for every selection with and without \sext(), and for both destination unused forms, then drives the translator on gfx1013 assembly.

Two real bugs the fixture caught: the operation's HLSL has to be grouped before the destination mask (\ _or_b32\ with \dst_sel:WORD_1\ otherwise emitted \ 7 | v8 & 0xffff, which keeps bits the hardware clears), and \sext()\ is a shift pair rather than a mask.

Not covered, and refused rather than translated inexactly: float SDWA forms and \dst_unused:UNUSED_SEXT. I did not run a full title startup from this branch, so I have not yet measured whether the pixel pipeline that stopped on SDWA now translates — I can run one and report the pipeline count if that is wanted before merge.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123148237 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1141#issuecomment-7123148237). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T05:39:13Z. --- Implemented as PR #1256. Scope: the byte and word selects of the 32-bit integer VOP1/VOP2 SDWA forms, with source zero-extension, \sext()\ sign extension, destination field placement, and \UNUSED_PAD\ / \UNUSED_PRESERVE\. The selection helpers now match \ ools/pixel_aot.py\ exactly, and \startup_gfx2hlsl_sdwa\ enforces that parity mechanically for every selection with and without \sext()\, and for both destination unused forms, then drives the translator on gfx1013 assembly. Two real bugs the fixture caught: the operation's HLSL has to be grouped before the destination mask (\ _or_b32\ with \dst_sel:WORD_1\ otherwise emitted \ 7 | v8 & 0xffff\, which keeps bits the hardware clears), and \sext()\ is a shift pair rather than a mask. Not covered, and refused rather than translated inexactly: float SDWA forms and \dst_unused:UNUSED_SEXT\. I did not run a full title startup from this branch, so I have not yet measured whether the pixel pipeline that stopped on SDWA now translates — I can run one and report the pipeline count if that is wanted before merge.
triggered02 commented 2026-11-24 06:50:28 +00:00 (Migrated from github.com)
Author
Contributor

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


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 `

(Full measurement is on PR #1256.)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7123350318 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1141#issuecomment-7123350318). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T05:52:07Z. --- 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 ` (Full measurement is on PR #1256.)
Sign in to join this conversation.
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#1134
No description provided.