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

Manually merged
github merged 1 commit from github-bot/gh-716 into main 2026-11-29 00:27:26 +00:00 AGit
Owner

@⁠adhd-speed on GitHub · 2026-11-28 04:17 UTC · original
adhd-speed:fix/gs-voxelize-table-pointer → main · +95 −6 · 1 files · 1 commits · merged 2026-11-29 00:24 UTC

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.

**@⁠adhd-speed** on GitHub · 2026-11-28 04:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/716) `adhd-speed:fix/gs-voxelize-table-pointer` → `main` · +95 −6 · 1 files · 1 commits · merged 2026-11-29 00:24 UTC ## 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.
HwStage::user_sgpr added 8 to every stage that can run merged, but a
standalone geometry shader's user data starts at s0; only stages that
run merged with their neighbours have the 8 system SGPRs first. With
the +8, the parameter lookup of GS_VoxelizeGeneric was shifted by eight
dwords, so s8/s9 matched no root parameter. Nothing in a GS's metadata
says which placement it uses and both occur in this title, so param_of
now tries s0 and then s8.

A table's base is a 32-bit address whose high half is zero, and an
offset added to it stays inside the 4 GiB, so an address into a table
is not checked for a high half. The failing shader reconstructs the
pointer with s_and_b32 s1, s9, 0xff; that high half is not a
descriptor's, and the old check rejected it.

On the 26,177-program corpus of the Xbox Series build, "an address in
an SGPR that is no root parameter" goes from 195 to 0. The 22 wave64
and 5 descriptor-read-as-data failures left are unrelated. translate
still lowers only Vs/Ps/Cs/Ms, so this fixes resource tracking and
preload; emitting geometry pipelines is separate.

Tests: the standalone (s8) and merged (s16) reads from
GS_VoxelizeGeneric, at 0xb8 and 0x920.

Refs #659
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 04:18:59 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-28 04:26 UTC · original · approved these changes

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

**@⁠Dukestar69** on GitHub · 2026-11-28 04:26 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/716#pullrequestreview-6095804587) · **approved these changes** 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).
param_of now returns the placement it matched, and address uses it to
find a root descriptor's high half. Without it, a merged ES-GS
descriptor at user data 8 read s9 instead of s17.

The new test fails before the fix with "a root descriptor without its
high half". The full victory-shader suite passes 296 tests.
github-bot force-pushed github-bot/gh-716 from 3e3b7e0792 to a1ba435d1c 2026-11-28 05:25:31 +00:00 Compare
github-bot changed title from Shaders: a geometry shader's user data starts at s0, or s8 when merged to Shaders: a merged geometry shader's raw user-data address is title memory 2026-11-28 05:34:54 +00:00
Author
Owner

@⁠jptorres96 on GitHub · 2026-11-28 09:16 UTC · original

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.

**@⁠jptorres96** on GitHub · 2026-11-28 09:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/716#issuecomment-7237132139) 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.
github-bot referenced this pull request from a commit 2026-11-29 00:27:22 +00:00
github manually merged commit 8b047e1d2b into main 2026-11-29 00:27:26 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/trustno1-coder--VIctory-NVIDIA!716
No description provided.