Shaders: a merged geometry shader's raw user-data address is title memory #716

Merged
adhd-speed merged 1 commit from upstream-pr/716 into main 2026-11-29 00:24:47 +00:00
adhd-speed commented 2026-11-28 04:17:37 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by adhd-speed on 2026-11-28T04:17:37Z.


Problem

victory translate --list with VICTORY_HOST_MAX_WAVE=32 reports 195
GS_VoxelizeGeneric failures, all at the same load:

000030: s_and_b32 s1, s9, 0xff
000038: s_mov_b32 s0, s8
000044: s_load_dword s0, s[0:1], 0xb8

with:

resources: an address in an SGPR that is no root parameter

Root cause

The earlier diagnosis treated this as a table read at
table_offset_dwords: 184. That comparison was a unit error: 0xb8 is 184
bytes (46 dwords), while 184 dwords is 0x2e0.

The program's only UsedResource table is at 584 dwords = 0x920,
user_data 8, and it is read through s16:

000078: s_mov_b32 s17, 0
000084: s_load_dwordx4 s[8:11], s[16:17], 0x920

In a merged ES-GS, user data starts at s8; user_data 8 is s16. The
program is therefore merged. The 0xb8 load goes through s8, which is
user_data 0 in that placement. The layout has no user_data 0 parameter,
and the UsedResource table has no entry at 46 dwords. It is a raw address,
not a table root.

Change

  • Keep the merged +8 placement for Gs; HwStage::user_sgpr is unchanged
    in the net diff.
  • Let an address that traces to no root parameter fall back to title memory
    for Gs, as compute programs already do. The 0x920 load stays a table;
    0xb8 becomes MEMORY.
  • Tests:
    • the table at s16 / 0x920 / 584 dwords;
    • the raw 0xb8 and the table 0x920 in the same program, expecting
      (MEMORY, 0) and (0, 0x920);
    • a merged root descriptor's high half at s17.

Verification

  • cargo test -p victory-shader: 296 passed, 5 ignored.
  • cargo build --release --locked -p victory succeeds.
  • translate --list on the Xbox Series 1.0.2.1 corpus:
    • before: 195 an address in an SGPR that is no root parameter;
    • after: 0;
    • remaining: 22 no wave32 lowering for this wave64 program and 5
      a descriptor read only as data, unchanged.
  • The extracted shader 8cf49c6770ae0810: 1 of 1 tracked, 2 scalar
    accesses, one raw (MEMORY) and one table (0x920).

Scope

This fixes resource tracking and preload, not geometry pipeline emission.
translate still lowers only Vs/Ps/Cs/Ms, so the 195 still produce
no host geometry pipelines; that remains a separate change. #659 stays open
for the emitter.

Standalone geometry shaders

The evidence in this title is a merged ES-GS. This change does not claim a
standalone Gs placement; if one appears, its placement must come from
pipeline metadata rather than trying both offsets.

Refs #659.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5536582036 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/716). Originally posted by [adhd-speed](https://github.com/adhd-speed) on 2026-11-28T04:17:37Z. --- ## Problem `victory translate --list` with `VICTORY_HOST_MAX_WAVE=32` reports **195** `GS_VoxelizeGeneric` failures, all at the same load: ``` 000030: s_and_b32 s1, s9, 0xff 000038: s_mov_b32 s0, s8 000044: s_load_dword s0, s[0:1], 0xb8 ``` with: ``` resources: an address in an SGPR that is no root parameter ``` ## Root cause The earlier diagnosis treated this as a table read at `table_offset_dwords: 184`. That comparison was a unit error: `0xb8` is 184 **bytes** (46 dwords), while 184 dwords is `0x2e0`. The program's only `UsedResource` table is at **584 dwords = 0x920**, `user_data 8`, and it is read through `s16`: ``` 000078: s_mov_b32 s17, 0 000084: s_load_dwordx4 s[8:11], s[16:17], 0x920 ``` In a merged ES-GS, user data starts at `s8`; `user_data 8` is `s16`. The program is therefore merged. The `0xb8` load goes through `s8`, which is `user_data 0` in that placement. The layout has no `user_data 0` parameter, and the `UsedResource` table has no entry at 46 dwords. It is a raw address, not a table root. ## Change - Keep the merged `+8` placement for `Gs`; `HwStage::user_sgpr` is unchanged in the net diff. - Let an address that traces to no root parameter fall back to title memory for `Gs`, as compute programs already do. The `0x920` load stays a table; `0xb8` becomes `MEMORY`. - Tests: - the table at `s16` / `0x920` / 584 dwords; - the raw `0xb8` and the table `0x920` in the same program, expecting `(MEMORY, 0)` and `(0, 0x920)`; - a merged root descriptor's high half at `s17`. ## Verification - `cargo test -p victory-shader`: 296 passed, 5 ignored. - `cargo build --release --locked -p victory` succeeds. - `translate --list` on the Xbox Series `1.0.2.1` corpus: - before: 195 `an address in an SGPR that is no root parameter`; - after: 0; - remaining: 22 `no wave32 lowering for this wave64 program` and 5 `a descriptor read only as data`, unchanged. - The extracted shader `8cf49c6770ae0810`: `1 of 1 tracked`, 2 scalar accesses, one raw (`MEMORY`) and one table (`0x920`). ## Scope This fixes resource tracking and preload, not geometry pipeline emission. `translate` still lowers only `Vs`/`Ps`/`Cs`/`Ms`, so the 195 still produce no host geometry pipelines; that remains a separate change. #659 stays open for the emitter. ## Standalone geometry shaders The evidence in this title is a merged ES-GS. This change does not claim a standalone `Gs` placement; if one appears, its placement must come from pipeline metadata rather than trying both offsets. Refs #659.
Dukestar69 commented 2026-11-28 04:26:39 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T04:26:39Z.

Review: APPROVED


LGTM — verified on Windows:

  • cargo test -p victory-shader --lib native:: (12/12) and resource:: (40/40, including a_standalone_geometry_shaders_table_pointer_is_at_s0 and a_merged_geometry_shaders_table_pointer_is_at_s16) passed
  • 0 new clippy warnings in touched files (native.rs, resource.rs)
  • cargo xtask policy passed (294 files ok)

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6095804587 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/716#pullrequestreview-6095804587). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T04:26:39Z. **Review:** APPROVED --- LGTM — verified on Windows: - `cargo test -p victory-shader --lib native::` (12/12) and `resource::` (40/40, including `a_standalone_geometry_shaders_table_pointer_is_at_s0` and `a_merged_geometry_shaders_table_pointer_is_at_s16`) passed - 0 new clippy warnings in touched files (`native.rs`, `resource.rs`) - `cargo xtask policy` passed (`294 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
jptorres96 commented 2026-11-28 09:16:30 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by jptorres96 on 2026-11-28T09:16:30Z.


Tested on top of main: cargo test -p victory-shader --lib → 296 passed, 0 failed, 5 ignored. No regressions.

Env: RTX 4080 SUPER (driver 621.01), Ryzen 5 5600X, Windows build 26300, rustc 1.98.1, DXC 1.9.2609.5 (VICTORY_DXIL), --test-threads=1. VICTORY_INDIRECT_REST=1 set to sidestep main's two indirect budget-test failures (fixed in #67), unrelated to this PR.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7237132139 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/716#issuecomment-7237132139). Originally posted by [jptorres96](https://github.com/jptorres96) on 2026-11-28T09:16:30Z. --- Tested on top of main: `cargo test -p victory-shader --lib` → 296 passed, 0 failed, 5 ignored. No regressions. Env: RTX 4080 SUPER (driver 621.01), Ryzen 5 5600X, Windows build 26300, rustc 1.98.1, DXC 1.9.2609.5 (`VICTORY_DXIL`), `--test-threads=1`. `VICTORY_INDIRECT_REST=1` set to sidestep main's two indirect budget-test failures (fixed in #67), unrelated to this PR.
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
trustno1-coder/VIctory-NVIDIA!716
No description provided.