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

Closed
opened 2026-11-26 22:44:26 +00:00 by github-bot · 4 comments
Owner

@⁠denn0x on GitHub · 2026-11-24 01:45 UTC · original

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).

**@⁠denn0x** on GitHub · 2026-11-24 01:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1141) ## 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).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:44:26 +00:00
Author
Owner

@⁠rasptum on GitHub · 2026-11-24 02:04 UTC · original

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).

**@⁠rasptum** on GitHub · 2026-11-24 02:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1141#issuecomment-7119735090) 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).
Author
Owner

@⁠triggered02 on GitHub · 2026-11-24 05:35 UTC · original

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** on GitHub · 2026-11-24 05:35 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1141#issuecomment-7123088486) 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).
Author
Owner

@⁠triggered02 on GitHub · 2026-11-24 05:39 UTC · original

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** on GitHub · 2026-11-24 05:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1141#issuecomment-7123148237) 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.
Author
Owner

@⁠triggered02 on GitHub · 2026-11-24 05:52 UTC · original

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.)

**@⁠triggered02** on GitHub · 2026-11-24 05:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1141#issuecomment-7123350318) 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.)
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#1141
No description provided.