Shaders: dword 0 of root constants is no address base #93

Closed
github-bot wants to merge 0 commits from github-bot/gh-93 into main AGit
Owner

@⁠murillojndem on GitHub · 2026-12-01 10:52 UTC · original
amd/root-constant-dword0-is-no-base → main · +221 −4 · 2 files · 1 commits · closed without merging

What

Tracer::sum took dword 0 of every root parameter that a user SGPR holds as an address base. That is right for a table, a root descriptor or a heap, whose dword 0 is the address, but a root constant is a number, so dword 0 of root constants behaved unlike its other dwords:

  • used as an SMEM soffset or as a global load's VGPR offset, the program was refused with "an offset from a root parameter";
  • added to a table base (s_add_u32 s6, s2, s0), the sum had two bases, so the address lost the table and no root-indexed view was made. In a compute program a data load there read title memory at the sum; from reading the code, a descriptor loaded there was refused ("a descriptor outside the heaps").

Change

resource.rs:

  • sum() takes dword 0 as a base only when the parameter is not RootType::Constants, as upstream does.
  • address() returns "an address from a root parameter that is no address" first for a pointer in root constants (any of their dwords). In a compute program an SMEM load through such a pointer with a computed soffset then reads title memory through by_address, instead of stopping at "an address with two computed terms". This part is mine; upstream changed only the sum() arm.

TRANSLATOR_VERSION goes from 4 to 5: a compute program that added dword 0 to a table base and read the dwords there as data translated before, reading title memory at the sum, and now reads through the table.

Ported from Marvisak/VIctory@88daba4 (upstream PR 2154, by Fuzeofficial, co-author on the commit).

Tests

New tests in resource::tests:

  • root_constant_dword_0_offsets_tables_and_root_descriptors: dword 0 as an SMEM soffset, added to a table base, as an offset to a root descriptor (s_load_dword and global_load_dword), and a 64-bit pointer in the constants.
  • root_constant_dword_0_offsets_translate: such a program lowers, reads dword 0 as user data, uses no title memory and passes the DXIL validator.

On main 5d91fde both fail with "an offset from a root parameter"; with this branch both pass. They run on the CPU (no device).

Also run:

  • victory-shader --lib on WARP: 311 passed, 4 failed, 4 ignored (main: 309, 4, 4). The four failures are the same on main: three fail PSV0 validation with the SDK 10.0.22621 dxil.dll on this PC, and a_lane_mask_joined_with_a_number_is_read_as_the_number_it_is is a hardware-only test that VICTORY_WARP=1 sends to WARP.
  • victory-shader --lib on the RX 7900 XT (and WARP, through the same harness): 312 passed, 3 failed, 4 ignored (main: 310, 3, 4). The three failures are the PSV0 ones.
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings, with and without --all-features: clean.
  • cargo test -p xtask: repository_passes_policy passes. documented_switches_are_read fails, the same way as on main (VICTORY_NAME in README.md).

Limits

  • Not covered by the tests: the refusal outside compute, pointers at dwords 1 and up, and table plus dword 0 in a graphics stage. The pointer sub-cases check that the early return keeps the old result, not new behaviour. The validator check is skipped where dxil.dll does not load.
  • I built and tested victory-shader only. My checkout leaves out crates/victory-formats/src/bcpack-tables.bin, so I did not build -p victory or run the workspace clippy.
  • No in-game run and no fps numbers.
  • No environment switch: it is a translation fix. I can put it behind a switch if you prefer.
  • Other translator PRs bump the version too (#72 goes to 6, #90, #91 and #92 to 5). Whichever lands later needs the next number.

The same change is open as DexNom/VIctory#209.

Generated with Claude Code

**@⁠murillojndem** on GitHub · 2026-12-01 10:52 UTC · [original](https://github.com/eikkapine/victory-amd/pull/93) `amd/root-constant-dword0-is-no-base` → `main` · +221 −4 · 2 files · 1 commits · closed without merging ## What `Tracer::sum` took dword 0 of every root parameter that a user SGPR holds as an address base. That is right for a table, a root descriptor or a heap, whose dword 0 is the address, but a root constant is a number, so dword 0 of root constants behaved unlike its other dwords: - used as an SMEM soffset or as a global load's VGPR offset, the program was refused with "an offset from a root parameter"; - added to a table base (`s_add_u32 s6, s2, s0`), the sum had two bases, so the address lost the table and no root-indexed view was made. In a compute program a data load there read title memory at the sum; from reading the code, a descriptor loaded there was refused ("a descriptor outside the heaps"). ## Change `resource.rs`: - `sum()` takes dword 0 as a base only when the parameter is not `RootType::Constants`, as upstream does. - `address()` returns "an address from a root parameter that is no address" first for a pointer in root constants (any of their dwords). In a compute program an SMEM load through such a pointer with a computed soffset then reads title memory through `by_address`, instead of stopping at "an address with two computed terms". This part is mine; upstream changed only the `sum()` arm. `TRANSLATOR_VERSION` goes from 4 to 5: a compute program that added dword 0 to a table base and read the dwords there as data translated before, reading title memory at the sum, and now reads through the table. Ported from Marvisak/VIctory@88daba4 (upstream PR 2154, by Fuzeofficial, co-author on the commit). ## Tests New tests in `resource::tests`: - `root_constant_dword_0_offsets_tables_and_root_descriptors`: dword 0 as an SMEM soffset, added to a table base, as an offset to a root descriptor (`s_load_dword` and `global_load_dword`), and a 64-bit pointer in the constants. - `root_constant_dword_0_offsets_translate`: such a program lowers, reads dword 0 as user data, uses no title memory and passes the DXIL validator. On main 5d91fde both fail with "an offset from a root parameter"; with this branch both pass. They run on the CPU (no device). Also run: - `victory-shader --lib` on WARP: 311 passed, 4 failed, 4 ignored (main: 309, 4, 4). The four failures are the same on main: three fail PSV0 validation with the SDK 10.0.22621 `dxil.dll` on this PC, and `a_lane_mask_joined_with_a_number_is_read_as_the_number_it_is` is a hardware-only test that `VICTORY_WARP=1` sends to WARP. - `victory-shader --lib` on the RX 7900 XT (and WARP, through the same harness): 312 passed, 3 failed, 4 ignored (main: 310, 3, 4). The three failures are the PSV0 ones. - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. - `cargo test -p xtask`: `repository_passes_policy` passes. `documented_switches_are_read` fails, the same way as on main (`VICTORY_NAME` in README.md). ## Limits - Not covered by the tests: the refusal outside compute, pointers at dwords 1 and up, and table plus dword 0 in a graphics stage. The pointer sub-cases check that the early return keeps the old result, not new behaviour. The validator check is skipped where `dxil.dll` does not load. - I built and tested `victory-shader` only. My checkout leaves out `crates/victory-formats/src/bcpack-tables.bin`, so I did not build `-p victory` or run the workspace clippy. - No in-game run and no fps numbers. - No environment switch: it is a translation fix. I can put it behind a switch if you prefer. - Other translator PRs bump the version too (#72 goes to 6, #90, #91 and #92 to 5). Whichever lands later needs the next number. The same change is open as DexNom/VIctory#209. Generated with [Claude Code](https://claude.com/claude-code)
Tracer::sum took dword 0 of every root parameter that a user SGPR holds
as an address base. That is right for a table, a root descriptor or a
heap, whose dword 0 is the address, but a root constant is a number, so
dword 0 of root constants behaved unlike its other dwords:
- used as an SMEM soffset or as a global load's VGPR offset, the program
  was refused with "an offset from a root parameter";
- added to a table base (s_add_u32 s6, s2, s0), the sum had two bases,
  so the address lost the table, and no root-indexed view was made.
RootType::Constants is now excluded, as upstream does.

address() now returns "an address from a root parameter that is no
address" first for a pointer in root constants, any of their dwords. In
a compute program an SMEM load through such a pointer with a computed
soffset then reads title memory (by_address) instead of stopping at "an
address with two computed terms". This early return is this port's own;
upstream changed only the sum() arm.

Tests root_constant_dword_0_offsets_tables_and_root_descriptors (the
tracer: soffset, table offset, root descriptor offset, a pointer in the
constants) and root_constant_dword_0_offsets_translate (the program
lowers, reads dword 0 as user data and passes the DXIL validator). Both
fail without the change with "an offset from a root parameter".

Ported from Marvisak/VIctory 88daba4 (upstream PR 2154).

TRANSLATOR_VERSION 4 -> 5: a compute program that added dword 0 to a
table base and read the dwords there as data translated before, reading
title memory at the sum, and now reads through the table.

Co-authored-by: Fuzeofficial <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 10:54:50 +00:00
github-bot closed this pull request 2026-12-01 18:59:36 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.