Skip to content

Recompiler: handle packed ISG1 vertex inputs sharing a register (#105) - #313

Open
Michael-Glaser wants to merge 1 commit into
xcl-dev:mainfrom
Michael-Glaser:fix/recomp-vertex-packed-isg1
Open

Michael-Glaser wants to merge 1 commit into
xcl-dev:mainfrom
Michael-Glaser:fix/recomp-vertex-packed-isg1

Conversation

@Michael-Glaser

@Michael-Glaser Michael-Glaser commented Nov 23, 2026 •

Copy link
Copy Markdown

Part of #105. Mode::Vertex named XclIn fields a{e.register} and ignored e.mask, emitting duplicate field names and reading wrong channels when two ISG1 inputs share a register. Overlaps #297 (same packed-ISG1 issue, different approach).

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: name XclIn fields a{k} by index (matching Mode::Pixel) and map VGPR channels using e.mask.
  • crates/xcl/src/gpu/recomp/tests.rs: unit test vertex_packed_isg1_inputs_get_distinct_fields_and_components.

Tested

  • Cross-checked on macOS (aarch64-apple-darwin, Rust 1.100.0): cargo check --offline --target x86_64-pc-windows-msvc --workspace --tests (0 errors, 0 new warnings).

Not tested

  • Not built or executed on Windows; DXC, cargo test, GPU tests, and scripts/smoke.ps1 not run yet.

AI use

  • Antigravity with Gemini 4 Neon (audit, fix, unit test, description).

@regiumlepidi

Copy link
Copy Markdown

A Windows run for this draft, and a note that #297 (draft) fixes the same packed-ISG1 case in another way; the two conflict in emit.rs.

This PR: 18ca3b6 merged onto current main db1ddb2 (clean merge) builds and passes on both adapters: 667 passed, 0 failed, 41 ignored on an RTX 5070 Ti (driver 617.42) and on the Ryzen 7 9800X3D's RDNA2 iGPU (driver 32.0.21030.2001, XCL_ADAPTER=radeon); main alone is 666 / 0 / 41 on both. vertex_packed_isg1_inputs_get_distinct_fields_and_components fails with main's emit.rs and passes with this PR's. Windows 11 Pro 25H2, Ryzen 7 9800X3D, rustc 1.100.0 MSVC, DXC from Windows SDK 10.0.26100, debug, no XCL_SAMPLE_*.

Cross-check with #297 (a5b7825; #297 does not merge with main db1ddb2 any more, so each PR at its own head, on 9ab7d76). Each PR's tests appended to the other's tests.rs, both adapters, same result on each:

Fix #297's gpu_vs_packed_isg1_inputs (draws on the GPU) #297's vs_packed_isg1_inputs_are_members_of_their_own (HLSL text) #313's vertex_packed_isg1_inputs_get_distinct_fields_and_components (HLSL text)
main fails fails fails
#297 pass pass fails: its members are float2 a1_0 / float2 a1_2, not float4 a1 / a2
#313 pass fails: no a1_0 member pass

So on the one test that draws (packed TEXCOORD0 .xy / TEXCOORD1 .zw through an R32G32 input layout), both fixes give the expected pixels on NVIDIA and on RDNA2; the failing cross cases only assert the other PR's member names. Both read a component no element covers as 0u, and both keep an element alone in its register as float4 a…. The difference that is left: #313 declares every packed element as a 4-vector starting at component 0 and indexes by the bits of its mask, #297 declares each with its own width.

Not tested: scripts/smoke.ps1 on a real title (I have none); RDNA3 / RDNA4, Intel.

AI use: Claude Code with Claude Opus 5.5 ran the builds and the cross-check and wrote this comment; the numbers come from those runs.

@Michael-Glaser
Michael-Glaser force-pushed the fix/recomp-vertex-packed-isg1 branch from 18ca3b6 to 3875b45 Compare November 24, 2026 00:16
@upipibi upipibi mentioned this pull request Nov 24, 2026
…dev#105)

In Mode::Vertex, struct XclIn named fields a{e.register} and VGPR initialisation looked up the first element matching e.register while ignoring e.mask. When two ISG1 vertex inputs pack into one register (e.g. TEXCOORD0 .xy and TEXCOORD1 .zw in register 1), XclIn emitted duplicate field names (failing DXC compilation) and upper channels read from the first element instead of the packed element's components.

Name XclIn fields by element index (a{k}, matching Mode::Pixel) and match each VGPR channel against e.mask, indexing the packed element starting from component 0 while keeping the unmasked fallback for single elements that rely on IA defaults.

Assisted-by: Antigravity (Gemini 4 Neon)
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

This and #297 (opened 28 minutes earlier) both fix the packed ISG1 vertex inputs of #105: two elements in one register become two XclIn members instead of two members with one name. They differ in how a fetch-shader VGPR finds its member:

  • Recompiler: VS inputs packed into one ISG1 register are members of their own (#105) #297 names a packed member a{register}_{first} and declares only the components of its mask. It maps VGPR input_vgpr + c to component c - first. A component no element covers stays 0.
  • This PR numbers all members a{k}, each a full 4-vector. It maps by the popcount of the element's mask below the channel, and falls back to the first element whose register holds the VGPR.

Both have tests. They edit the same lines of emit.rs, so only one can land. Read from the diffs only; I have not run either.

AI-assisted (Claude Code).

@throny

throny commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #297 #1371 solves the same problem (for #105) in a different way: #1607, group D20. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 40f90f7b on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 40f90f7b09fcad72ebcc4822b77b8f521e3049a7
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

@JJAutoCompare

Copy link
Copy Markdown

Tested

Independent native Windows run for #313 at 40f90f7b09fcad72ebcc4822b77b8f521e3049a7, verified as the open PR head before the run. The assigned detached checkout was clean before and after testing. The PR discussion had a same-head AMD retail smoke run and an older-revision Windows suite run. It had no equivalent exact-head focused CPU result.

STOR-WINLAB, Windows 11 Enterprise Evaluation 25H2 x64 (build 26200.9974), AMD Ryzen 7 3800X, Rust and Cargo 1.100.0 (stable-x86_64-pc-windows-msvc, rustc 0ef1bc386). Cargo used the unoptimized test profile with debug info and incremental compilation disabled. XCL logged dxcompiler and dxil 1.9.2609.5.

cargo test --locked -p xcl --lib gpu::recomp::tests::vertex_packed_isg1_inputs_get_distinct_fields_and_components -- --exact --nocapture --test-threads=1

Exit 0. 1 passed, 0 failed, 0 ignored, 0 skipped, 719 filtered out. The synthetic fixture asserts complete HLSL translation, distinct float4 fields a0, a1, and a2 for POSITION0, TEXCOORD0, and TEXCOORD1, and VGPR reads v4/v7 from a0[0/3], v8/v9 from a1[0/1], and v10/v11 from a2[0/1], including the remap from the shared register's .zw. The run loaded DXC and successfully compiled main as vs_6_6 to DXIL with DXC's default validation. The build emitted one deprecation warning for fetch_update in xgameruntime.

Not tested

Separate DXIL validation, D3D12 pipeline creation, GPU execution, retail titles, the workspace suite, and comparison with #1371.

AI use

T3 Code / Codex (gpt-6.2-sol) inspected the fixture, ran the existing test, and wrote this report.

Raw evidence: L:/XclTooling/pr313/environment.log, L:/XclTooling/pr313/cargo-test.log, L:/XclTooling/pr313/pr-313.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants