Recompiler: deduplicate packed ISG1 vertex input struct fields (#105) #1361

Open
slopgobblercobbler wants to merge 1 commit from upstream-pr/1371 into main
slopgobblercobbler commented 2026-11-24 15:19:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by slopgobblercobbler on 2026-11-24T15:19:57Z.


Addresses #105 Item 4 (Packed ISG1 vertex input struct field deduplication):
When multiple packed ISG1 vertex attributes share an input register (e.g. UV0 and UV1 packing into 2-channel halves of a single register), Mode::Vertex previously emitted duplicate XclIn field names (a{e.register}), causing HLSL compilation errors under DXC.

What is in it

  • crates/xcl/src/gpu/recomp/mod.rs:
    • vs_input_names(inputs) generates deduplicated field names with _{dup} suffixes for shared registers.
    • vs_input_slot(vs, register, chan) routes channel indexing to the element declaring that component.
  • crates/xcl/src/gpu/recomp/emit.rs:
    • In Mode::Vertex, emits deduplicated XclIn struct members and indexes the corresponding field for each channel.
  • crates/xcl/src/gpu/recomp/tests.rs:
    • vs_packed_isg1_vertex_input_dedup verifies non-colliding fields (a0, a0_1, a1) and valid DXC vs_6_6 compilation.

Tested

  • cargo test -p xcl -- recomp (190 passed, 0 failed).
  • Full workspace test suite: cargo test --workspace (707 passed, 0 failed).
  • Windows 11 x64, MSVC toolchain, rebased onto upstream/main (930e8b4).

Not tested

  • Shaders with more than 16 packed vertex input attributes.

AI use

  • Developed with Antigravity swarm coordinator & dedicated author/verifier agents (author-recomp-isg1, verify-recomp-isg1). Verified and reviewed independently.
<!-- greyfinch-sync:ivall/xcl:issue:5475004462 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1371). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-11-24T15:19:57Z. --- Addresses #105 Item 4 (Packed ISG1 vertex input struct field deduplication): When multiple packed ISG1 vertex attributes share an input register (e.g. UV0 and UV1 packing into 2-channel halves of a single register), `Mode::Vertex` previously emitted duplicate `XclIn` field names (`a{e.register}`), causing HLSL compilation errors under DXC. **What is in it** - `crates/xcl/src/gpu/recomp/mod.rs`: - `vs_input_names(inputs)` generates deduplicated field names with `_{dup}` suffixes for shared registers. - `vs_input_slot(vs, register, chan)` routes channel indexing to the element declaring that component. - `crates/xcl/src/gpu/recomp/emit.rs`: - In `Mode::Vertex`, emits deduplicated `XclIn` struct members and indexes the corresponding field for each channel. - `crates/xcl/src/gpu/recomp/tests.rs`: - `vs_packed_isg1_vertex_input_dedup` verifies non-colliding fields (`a0`, `a0_1`, `a1`) and valid DXC `vs_6_6` compilation. **Tested** - `cargo test -p xcl -- recomp` (190 passed, 0 failed). - Full workspace test suite: `cargo test --workspace` (707 passed, 0 failed). - Windows 11 x64, MSVC toolchain, rebased onto `upstream/main` (`930e8b4`). **Not tested** - Shaders with more than 16 packed vertex input attributes. **AI use** - Developed with Antigravity swarm coordinator & dedicated author/verifier agents (`author-recomp-isg1`, `verify-recomp-isg1`). Verified and reviewed independently.
futurepro62 commented 2026-11-24 16:07:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:25:37Z.


Full-suite run, since this PR has no test report yet. Tested exact head d2e5c7b (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: vs_packed_isg1_vertex_input_dedup.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7136006955 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1371#issuecomment-7136006955). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T15:25:37Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `d2e5c7b` (on its base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `vs_packed_isg1_vertex_input_dedup`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
DavidM1911 commented 2026-11-24 17:06:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:41:50Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7138067430 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1371#issuecomment-7138067430). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T16:41:50Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
LocranKing commented 2026-11-24 17:06:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-24T16:55:21Z.


Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32), adding a 60 s retail regression smoke run on clean head d2e5c7b6e14d3f37dd547c7421c2f9b175c93888.

Tested

  • Commit: d2e5c7b6e14d3f37dd547c7421c2f9b175c93888 (clean tree, merge-base 930e8b4)
  • Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2101), rustc 1.100.0 (x86_64-pc-windows-msvc, MSVC 14.44.35207), DXC 1.9.2602.17 (SDK 10.0.26100.0), --release
  • cargo build --release --workspace: ok (exit 0)
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored, exit 0
    • SKIPPED (no wave64): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware

Regression run
main baseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1508 (PresentX 1508)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14730 MB

PR head (d2e5c7b6e14d3f37dd547c7421c2f9b175c93888):

xcl-smoke v1
commit: d2e5c7b6e14d3f37dd547c7421c2f9b175c93888
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1564 (PresentX 1564)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14713 MB

Not tested: debug build, XCL_SAMPLE_* tests on this branch, AMD / native wave64 hardware, shaders with more than 16 packed vertex attributes.

AI use: Antigravity (Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.

<!-- greyfinch-sync:ivall/xcl:comment:7138413886 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1371#issuecomment-7138413886). Originally posted by [LocranKing](https://github.com/LocranKing) on 2026-11-24T16:55:21Z. --- Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32), adding a 60 s retail regression smoke run on clean head `d2e5c7b6e14d3f37dd547c7421c2f9b175c93888`. **Tested** - Commit: `d2e5c7b6e14d3f37dd547c7421c2f9b175c93888` (clean tree, merge-base `930e8b4`) - Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (`8024 MiB VRAM`, driver `32.0.16.2101`), `rustc 1.100.0` (`x86_64-pc-windows-msvc`, MSVC `14.44.35207`), DXC `1.9.2602.17` (SDK `10.0.26100.0`), `--release` - `cargo build --release --workspace`: ok (`exit 0`) - `cargo test --workspace --release --no-fail-fast -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, exit `0` - `SKIPPED` (`no wave64`): `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` **Regression run** `main` baseline (`b7aa9f3bd212088e0d927439284dc5ed325ce3c7`): ``` xcl-smoke v1 commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1508 (PresentX 1508) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14730 MB ``` PR head (`d2e5c7b6e14d3f37dd547c7421c2f9b175c93888`): ``` xcl-smoke v1 commit: d2e5c7b6e14d3f37dd547c7421c2f9b175c93888 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1564 (PresentX 1564) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14713 MB ``` **Not tested:** debug build, `XCL_SAMPLE_*` tests on this branch, AMD / native wave64 hardware, shaders with more than 16 packed vertex attributes. **AI use:** Antigravity (`Gemini 4 Hydrogen`) ran the build, tests, and smoke runs and drafted this report from the command outputs.
KainanP commented 2026-11-24 19:07:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KainanP on 2026-11-24T18:27:28Z.


Read at d2e5c7b while doing the #1607 duplicate check for #105. I think the packed elements read the wrong channels.

In the new test, UV0 is declared at register 0 with mask 0xC (.zw), gets its own field float4 a0_1 : UV0, and is read as xi.a0_1[2] / xi.a0_1[3] (the asserts on v6/v7). On the PC, a0_1 is a separate semantic: the input assembler writes the element's components from .x up (an R32G32 UV0 lands in a0_1.xy), and .zw get the defaults 0 and 1. So once the element has its own field, the channel read from it has to be shifted down by the element's first component (chan - first_set_bit(mask)), here a0_1[0] / a0_1[1]. #297's draw test shows the data in .xy of the element's own member.

The test only checks the HLSL text, so it pins the unshifted index rather than catching it; a draw with distinct data in UV0 and UV1 would.

(Unrelated to #105: the PR also changes fmt_encode from saturate to clamp.)

AI use: Claude Code (Claude Opus 5.5) read the diff; not run on a GPU. Checked by the user before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7140672022 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1371#issuecomment-7140672022). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-24T18:27:28Z. --- Read at `d2e5c7b` while doing the #1607 duplicate check for #105. I think the packed elements read the wrong channels. In the new test, `UV0` is declared at register 0 with mask `0xC` (`.zw`), gets its own field `float4 a0_1 : UV0`, and is read as `xi.a0_1[2]` / `xi.a0_1[3]` (the asserts on `v6`/`v7`). On the PC, `a0_1` is a separate semantic: the input assembler writes the element's components from `.x` up (an `R32G32` UV0 lands in `a0_1.xy`), and `.zw` get the defaults 0 and 1. So once the element has its own field, the channel read from it has to be shifted down by the element's first component (`chan - first_set_bit(mask)`), here `a0_1[0]` / `a0_1[1]`. #297's draw test shows the data in `.xy` of the element's own member. The test only checks the HLSL text, so it pins the unshifted index rather than catching it; a draw with distinct data in UV0 and UV1 would. (Unrelated to #105: the PR also changes `fmt_encode` from `saturate` to `clamp`.) _AI use: Claude Code (Claude Opus 5.5) read the diff; not run on a GPU. Checked by the user before posting._
throny commented 2026-11-24 21:08:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-24T19:38:28Z.


Two contributors checked independently and found that #297 #313 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.

<!-- greyfinch-sync:ivall/xcl:comment:7142383919 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1371#issuecomment-7142383919). Originally posted by [throny](https://github.com/throny) on 2026-11-24T19:38:28Z. --- <!-- xcl-1607-hint:D20 --> Two contributors checked independently and found that #297 #313 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.
SergeAx commented 2026-11-25 20:08:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SergeAx on 2026-11-25T20:08:25Z.


Tested on RTX 5080 (Windows 10 22H2): with #297's gpu_vs_packed_isg1_inputs added to main + this PR (d2e5c7b), the draw gives [0.25, 0.5, 0.0, 1.0] where [0.25, 0.5, 0.75, 0.125] is expected. On PC the input layout feeds TEXCOORD1 (R32G32) into its own member's .xy, but v10/v11 read a1_1[2]/a1_1[3] (the register's channel), which hold the IA defaults 0/1. vs_packed_isg1_vertex_input_dedup asserts that read (v6 = asuint(xi.a0_1[2])), so it passes. The same test passes on #297 and on main + #313. (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ivall/xcl:comment:7173244002 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1371#issuecomment-7173244002). Originally posted by [SergeAx](https://github.com/SergeAx) on 2026-11-25T20:08:25Z. --- Tested on RTX 5080 (Windows 10 22H2): with #297's `gpu_vs_packed_isg1_inputs` added to `main` + this PR (`d2e5c7b`), the draw gives `[0.25, 0.5, 0.0, 1.0]` where `[0.25, 0.5, 0.75, 0.125]` is expected. On PC the input layout feeds TEXCOORD1 (R32G32) into its own member's `.xy`, but `v10`/`v11` read `a1_1[2]`/`a1_1[3]` (the register's channel), which hold the IA defaults 0/1. `vs_packed_isg1_vertex_input_dedup` asserts that read (`v6 = asuint(xi.a0_1[2])`), so it passes. The same test passes on #297 and on `main` + #313. (Claude Code, Claude Opus 5.5)
github-actions[bot] commented 2026-11-29 20:44:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:14Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262317577 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1371#issuecomment-7262317577). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:44:14Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:32:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:32:47Z.


Triage (#1607) – head d2e5c7b

#297 and #313 fix the same duplicate a{register} XclIn member (#105, group D20) and map the channels correctly.
In emit.rs (Mode::Vertex), each element gets a float4 member bound to its own semantic, but the fetch VGPRs read it at the register channel. In the test, UV0 sits in .zw of register 0 and is declared float4 a0_1 : UV0, so the IA puts UV0 in .xy of a0_1, while v6 = asuint(xi.a0_1[2]) reads .z (the default 0) and v7 reads w (1). The test asserts this wrong mapping.
The fmt_encode change from saturate to clamp is unrelated to vertex inputs.
Recommendation: close (bad: packed .zw elements read the IA default instead of their data).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301883702 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1371#issuecomment-7301883702). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:32:47Z. --- **Triage (#1607)** – head d2e5c7b #297 and #313 fix the same duplicate `a{register}` XclIn member (#105, group D20) and map the channels correctly. In `emit.rs` (Mode::Vertex), each element gets a float4 member bound to its own semantic, but the fetch VGPRs read it at the register channel. In the test, UV0 sits in .zw of register 0 and is declared `float4 a0_1 : UV0`, so the IA puts UV0 in .xy of `a0_1`, while `v6 = asuint(xi.a0_1[2])` reads .z (the default 0) and v7 reads w (1). The test asserts this wrong mapping. The `fmt_encode` change from `saturate` to `clamp` is unrelated to vertex inputs. Recommendation: close (bad: packed .zw elements read the IA default instead of their data). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1371:upstream-pr/1371'
git switch 'upstream-pr/1371'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1371'
git switch 'upstream-pr/1371'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1371'
git switch 'upstream-pr/1371'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1371'
git switch 'main'
git merge --squash 'upstream-pr/1371'
git switch 'main'
git merge --ff-only 'upstream-pr/1371'
git switch 'main'
git merge 'upstream-pr/1371'
git push origin 'main'
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
xcl-dev/xcl!1361
No description provided.