shader: a spilled descriptor's phi agrees when its spills have one origin (#400) #418

Merged
lautarocherro merged 1 commit from upstream-pr/418 into main 2026-11-28 00:28:25 +00:00
lautarocherro commented 2026-11-27 17:31:07 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by lautarocherro on 2026-11-27T17:31:07Z.


What this changes

Refs #400.

A descriptor spilled to VGPR lanes is followed back through v_writelane_b32 writes, and through phis of the VGPR when every edge spills the same value. The title's compiler restores a spilled descriptor inside a loop and spills it again, so the loop's edge spills the restored copy: another value with the same dwords. Tracer::spilled saw two values and refused the descriptor as "a descriptor neither loaded nor built".

The edges now agree when the values they spill have one origin in the copy propagation. That is the rule propagate_copies already applies to SGPR phis: a copy keeps every bit, so the values hold the same descriptor. restored now returns the origin itself, and "no origin yet" leaves the value for the next sweep, as before.

How it was tested

  • cargo test -p victory-shader: passes. The new test resource::tests::a_descriptor_spilled_again_in_a_loop_is_still_the_load fails without the change with "a descriptor neither loaded nor built".
  • cargo test -p victory-gpu -p xtask (arm64, with the Metal Shader Converter), Windows clippy on the workspace with -D warnings, and cargo xtask policy: all pass (victory-gpu 412 tests).
  • Corpus: examples/sweep on 21,556 shaders from one run, main b998bb65 against this branch, tools/corpus/compare.sh:
    • 8 newly translated, all vertex: 4 of this class, and 4 that were "a descriptor outside the heaps".
    • 0 regressions, 0 changed outputs.
    • The 305 compute programs of the class move on to the next refusal: 290 "a view address field the table gives as 0: a buffer's stride or swizzle", 14 "a descriptor's address or format read as data: an image's dwords", 1 "a register joining a lane mask and data, read as data".
    • 117 of the class's 309 shaders were bound in a world run here, 1 of the 8 gained.
  • Ran the game, or not needed: not needed. The change is in the resource tracer only, and no output of a shader that translated before changes.

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (none: it follows from the instructions)
  • New diagnostics are behind a VICTORY_* variable and documented (none)
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5530699994 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/418). Originally posted by [lautarocherro](https://github.com/lautarocherro) on 2026-11-27T17:31:07Z. --- ## What this changes Refs #400. A descriptor spilled to VGPR lanes is followed back through `v_writelane_b32` writes, and through phis of the VGPR when every edge spills the same value. The title's compiler restores a spilled descriptor inside a loop and spills it again, so the loop's edge spills the restored copy: another value with the same dwords. `Tracer::spilled` saw two values and refused the descriptor as "a descriptor neither loaded nor built". The edges now agree when the values they spill have one origin in the copy propagation. That is the rule `propagate_copies` already applies to SGPR phis: a copy keeps every bit, so the values hold the same descriptor. `restored` now returns the origin itself, and "no origin yet" leaves the value for the next sweep, as before. ## How it was tested - [x] `cargo test -p victory-shader`: passes. The new test `resource::tests::a_descriptor_spilled_again_in_a_loop_is_still_the_load` fails without the change with "a descriptor neither loaded nor built". - [x] `cargo test -p victory-gpu -p xtask` (arm64, with the Metal Shader Converter), Windows clippy on the workspace with `-D warnings`, and `cargo xtask policy`: all pass (victory-gpu 412 tests). - [x] Corpus: `examples/sweep` on 21,556 shaders from one run, main `b998bb65` against this branch, `tools/corpus/compare.sh`: - 8 newly translated, all vertex: 4 of this class, and 4 that were "a descriptor outside the heaps". - 0 regressions, 0 changed outputs. - The 305 compute programs of the class move on to the next refusal: 290 "a view address field the table gives as 0: a buffer's stride or swizzle", 14 "a descriptor's address or format read as data: an image's dwords", 1 "a register joining a lane mask and data, read as data". - 117 of the class's 309 shaders were bound in a world run here, 1 of the 8 gained. - [x] Ran the game, or not needed: not needed. The change is in the resource tracer only, and no output of a shader that translated before changes. ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (none: it follows from the instructions) - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none)
Olima34 commented 2026-11-28 02:00:40 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T02:00:40Z.


Thanks for this PR, now merged! For the record, an offline check on main 86cefd22 (world corpus, 21,600 shaders):

  • Newly translated: 8 vertex shaders.
  • Refused for another reason now: 305 compute shaders that were refused for "a descriptor neither loaded nor built" (123 at "an image's dwords 5 to 7", 114 at "a lane mask holding lanes elsewhere read as data: a program input", 65 at "a buffer's dword 1", 3 at others).
  • Regressions: 0.

So the passes those shaders cost are now held by the next refusal classes, which helps rank what comes next.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7232066473 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/418#issuecomment-7232066473). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T02:00:40Z. --- Thanks for this PR, now merged! For the record, an offline check on main 86cefd22 (world corpus, 21,600 shaders): - **Newly translated:** 8 vertex shaders. - **Refused for another reason now:** 305 compute shaders that were refused for "a descriptor neither loaded nor built" (123 at "an image's dwords 5 to 7", 114 at "a lane mask holding lanes elsewhere read as data: a program input", 65 at "a buffer's dword 1", 3 at others). - **Regressions:** 0. So the passes those shaders cost are now held by the next refusal classes, which helps rank what comes next.
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
LakshanSivakumar/Native-Victory-macOS!418
No description provided.