Skip to content

Shaders: retain live interpolation first halves - #52

Open
jaschinski97-ops wants to merge 3 commits into
fxceless:mainfrom
jaschinski97-ops:fix/standalone-interpolation
Open

jaschinski97-ops wants to merge 3 commits into
fxceless:mainfrom
jaschinski97-ops:fix/standalone-interpolation

Conversation

@jaschinski97-ops

@jaschinski97-ops jaschinski97-ops commented Nov 24, 2026 •

Copy link
Copy Markdown

A synthetic pixel shader exporting v_interp_p1_f32 without its second half fails with the first half of an interpolation. The same happens when the partial result is copied for another calculation before an otherwise ordinary loaded-i/j pair completes. That failure message is also reported in #7; the reported title shader itself was not available for validation.

I/O raising now records first halves whose SSA values are consumed outside a folded complete interpolation, including values reaching a consumer through phis. They use the existing weighted interpolation lowering (P0 + i * (P1 - P0)). Normal loaded-i/j pairs retain their current single host interpolation and do not gain barycentrics or per-vertex attribute reads. Computed-weight pairs retain their existing handling.

Validation on Windows 11 / NVIDIA RTX 3080, driver 32.0.16.2140, Rust 1.98.1 / Windows GNU:

  • Two synthetic emission regressions failed before the change and now pass: a standalone first half and a live partial result beside a complete pair. DXIL validation passes.
  • A synthetic full-screen triangle renders both cases on the RTX 3080 and WARP. All 1,024 returned channel values match the expected partial/full interpolation expressions within 1e-5.
  • Additional I/O tests cover first halves through a phi and registration of a standalone v_interp_p1ll_f16 (the f16 form was not executed on the GPU).
  • Existing interpolation_alone_declares_no_barycentrics and computed-weight tests pass, preserving the ordinary-pair optimization.
  • cargo test --locked -p victory-shader --lib -- --test-threads=1: 215 passed, 0 failed, 2 existing ignored tests (90.94 seconds).
  • Clippy for victory-shader, all targets, diagnostics,host, with -D warnings: clean. Asset policy: 169 files OK.
  • Local integration with Shaders: lower row permutations on wave32 hosts #40: 217 shader tests passed, 0 failed, 2 existing ignored; combined Clippy with diagnostics,host and -D warnings and the asset policy pass. The changes combine without conflicts.

No gameplay or shader-corpus result is claimed. No title data, dumps or extracted code are included. Synthetic programs and tests are our own. Instruction semantics: AMD RDNA 2 ISA section 12.11, https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture

AI-assisted contribution with Codex; code and hardware/software rendering tests run locally.

Additional review corrections in c194f64: demand-based first-half tracking avoids unnecessary barycentrics for a dead value overwritten by a full move, preserves masked-move dependencies, and retains the old destination High16 of a folded f16 P2. The dead-overwrite test fails before the fix. The extended render test checks 1,536 channel results on RTX 3080 and WARP, including exact old-High16/new-f16-Low16 bits. Final branch shader suite: 218 passed, 2 pre-existing ignored; Clippy and asset policy pass. All fixtures remain synthetic.

@adriaespii

Copy link
Copy Markdown

Independent test run on commit 81a8e2e (AMD RDNA4):

  • Hardware: AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (x86_64-pc-windows-msvc)
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo test --workspace: 501 passed, 0 failed, 7 ignored (victory-shader: 215 passed, 0 failed, 2 ignored; victory-gpu: 110 passed, 0 failed, 1 ignored)
  • Not tested: live game run (no game files on this machine)

AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.

@rocobalt1

Copy link
Copy Markdown

Offline coverage of this PR on the retail pack, measured on its own (not stacked with the other first-half PRs, because #52 and #77 both edit emit/mod.rs and conflict).

Method: worktree at 4e17478 (this PR's base), cargo build --release -p victory, then victory.exe translate <shaders.rpf> --validate --list --jobs 20 with the same Windows SDK validator, compared program by program by the program hash printed in the --list line against the same command on 4e17478 alone.

programs validated
4e17478 26 531 25 370
+ this PR 26 531 25 218

+8 gained, -160 lost.

The 8 gained are the ones this PR is after, and they are real:

PS_DeferredTextured_9e3a1555   PS_DeferredTextured_c5fd36bb
PS_MirrorReflectionDeferredTextured_862306ef / f0a15084 / d3b47178
PS_MirrorReflectionDeferredDecalTextured_38f9dc3e / e3251b40

PS_DeferredTextured_9e3a1555 is refused in the title on my machine (GFX10 code at 0x1464: the first half of an interpolation is not supported), so these 8 are worth having.

The 160 lost are all pixel programs, and they cluster on peds and fire:

 51  PS_PedTextured_Eight_Decals
 51  PS_MirrorPedTextured_Eight
 28  PS_PedTexturedCutOutTint_Zero
 10  PS_PedAlphaPrepass_Fire
 10  PS_PedAlphaTransmission_Fire
 10  PS_PedTextured_Eight_Fire

For comparison, #77 on the same base gains the same 8 and loses 0, so the 8 do not need this PR, while the 160 do come from it.

Is that expected - are the ped/fire programs meant to be refused until something else lands? I did not look at the diff for a reason, only at what the translator does, so this may be a known trade. On my side it is the difference between "worth trying in the title" and "not": PS_PedAlphaPrepass_Fire/PS_PedTextured_*_Fire are exactly the programs a burning character needs, so I would not run this build to look at one.

No game data; counts and program names only.

@arminkhaleghirod

Copy link
Copy Markdown

Merged onto main 90228a7 and ran victory translate --validate over the full title (26,148 programs) on Windows 11 / RTX 4080. Changes against main, by failure reason:

  • the first half of an interpolation: 8 → 0 (DXIL emitted 14,168 → 14,176)
  • New: 160 programs now fail the validator with signature element TEXCOORD at location (0,2) size (1,2) has interpolation mode that differs from another element packed into the same row. On main they only had the common PSV mismatch.

For comparison, #77 clears the same 8 with no new failure reason.

@KaliemSB

Copy link
Copy Markdown

Tested on the title's own shaders: all 8 "first half of an interpolation" programs now translate, validate and get a pipeline on an RTX 4060, with no regressions in the rest of the archive.

Setup

  • CPU / RAM: Intel Core i5-12400F, 32 GB
  • GPU: NVIDIA GeForce RTX 4060 8 GB (32-lane waves), driver 621.24
  • OS: Windows 11 Pro 24H2 (build 26100)
  • Toolchain: rustc / cargo 1.98.1, cargo build --release -p victory
  • Validator: dxil.dll 1.9.2609.5 (VICTORY_DXIL)
  • Trees: base 4e17478 (fork main) against this PR's head 81a8e2e, which is main plus this PR. Nothing else merged.
  • Translation settings: VICTORY_HOST_WAVE=32 VICTORY_VIEW_LIMIT=999999, the same forms the runtime picks on this card (32-lane waves, view heap capped at 1,000,000)

Whole archive (victory translate <dump> --list, 26,599 containers, 26,148 programs):

base 4e17478 PR 81a8e2e
vertex/pixel DXIL emitted 14,168 of 14,259 14,176 of 14,259
the first half of an interpolation 8 0
programs that newly fail – 0
programs whose failure reason changed – 0

The 8 programs, each extracted and run on its own with --validate and then with --pipelines:

program hash base PR
PS_DeferredTextured 78f3f2fc53a69531 first half validated, pipeline created
PS_DeferredTextured 38bf0814e721a1b3 first half validated, pipeline created
PS_DeferredTextured 8445dcb2b63aa197 first half validated, pipeline created
PS_MirrorReflectionDeferredDecalTextured 5ddcaa08d4a51215 first half validated, pipeline created
PS_MirrorReflectionDeferredDecalTextured 464ea474374b8ecd first half validated, pipeline created
PS_MirrorReflectionDeferredTextured 288c43f50bc7abee first half validated, pipeline created
PS_MirrorReflectionDeferredTextured 15547db9d31b056b first half validated, pipeline created
PS_MirrorReflectionDeferredTextured 007bb29b393d08c5 first half validated, pipeline created

Two of these (78f3f2fc…, 38bf0814…) were also logged as shader does not translate in a 31-minute game run on this machine at 1684989.

Tests, cargo test -p victory-shader:

  • With the default validator, 81a8e2e gives 212 passed and 3 failed. 4e17478 alone gives 208 passed and 2 failed.
  • The 2 rect::tests failures already happen on main.
  • The third failure is this PR's new first_half_values_render_on_hardware_and_warp. It fails with the same error: Container part 'Pipeline State Validation' does not match expected for module.
  • With no VICTORY_DXIL, the tests pick the newest Windows SDK dxil.dll, here 10.0.22621.0 (1.6.2112). Using dxil.dll 1.9.2609.5, or merging Shaders: write every PSV0 semantic name again, as DXC does (fixes #12) #61 on top, makes all 7 related tests pass: the 5 new ones and the 2 rect ones.
  • So the failure comes from the validator's PSV check, which Shaders: write every PSV0 semantic name again, as DXC does (fixes #12) #61 addresses, and not from this change.

I didn't do a game run with this PR, so I haven't seen these draws on screen.

AI use: Claude Code (Claude Opus 5.5) built the trees, ran the translations and tests, and drafted this; the machine is mine. No game files or extracted shaders attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants