Skip to content

Shaders: sizes of unused descriptors, paired f16 interpolation halves, 16-bit wave sums with lanes gone (+46 programs) - #203

Open
triippywhale wants to merge 1 commit into
fxceless:mainfrom
triippywhale:fix/shader-gaps
Open

triippywhale wants to merge 1 commit into
fxceless:mainfrom
triippywhale:fix/shader-gaps

Conversation

@triippywhale

Copy link
Copy Markdown

Summary

This PR fixes three translator gaps that were dropping world shaders. 46 programs of the retail shader pack now translate and validate, and none that translated before stop doing so. Seven of them are shaders the title actually binds in the prologue, which failed to translate in an in-game run before this change.

It is independent of #134 (the AMD view-heap clamp): this branch is upstream 2119b0e plus one commit. The in-game results below were taken with both applied.

Tested on Windows 11, AMD Radeon RX 7900 XT (RDNA3), Ryzen 7 7800X3D, 64 GB, Series X profile.

Changes (crates/victory-shader/src/emit/lower.rs)

1. Descriptors nothing uses as one, whose size the code still reads (36 programs)

descriptor_data rebuilt a descriptor's size dwords (width, height, levels; record count) only when it could find an instruction that uses the descriptor, either directly or through a "twin" load of the same address. Two patterns have no such use:

  • PS_PuddleDetect (34 pixel programs, 3 in game): at 0x1c5c the program does s_load_dwordx8 s[20:27], s[86:87], s12. That is an image descriptor taken from the heap at an index read from a constant buffer. The program then turns its width, height and base level into a texel size (s_lshr_b32 s12, s21, 30 / s_bfe_u32 s15, s22, 0x10000e / s_bfe_u32 s12, s23, 0x4000c / v_cvt_f32_u32), and never samples that texture there. Before this change it failed with "a descriptor read only as data".
  • ShallowWaterSim:CS_MinTimestepReduce (1 in game): it loads a 4-dword buffer descriptor only to run s_cmp_eq_u32 s2, 0 on its record count, to skip the pass when the buffer is empty. The address path filled dwords 0–1 and left dword 2 without a host value, so this failed with "a descriptor's address or format read as data".

The new unused_descriptor_kind gives such a load a kind:

  • 8 dwords: a 2D texture. This is a documented shortcut, since nothing in the program tells the dimension; for these programs the reads are texel sizes of 2D masks.
  • 4 dwords, where dword 2 is read: a raw buffer view.

The existing tail of descriptor_data then rebuilds the dwords from getDimensions on the host view, exactly as it does for used descriptors. For the buffer, the address comes from the host as the address-only path did. Lane-copied (waterfall) descriptors and samplers are checked first and keep their own handling. A first version of this change took them over and broke 283 mesh programs; the whole-pack comparison caught that.

2. f16 interpolation pairs whose first half's register is partly kept (8 programs, 2 in game)

PS_DeferredTextured_* (and mirror-reflection variants) do this:

v_interp_p1ll_f16 v10, v0, attr3.w high
v_interp_p2_f16   v10, v1, attr3.w, v10 high   ; writes the HIGH half of v10

The second half writes only the high half of its destination and keeps the low half, which is the first half's partial result. Nothing reads that low half; the console compiler just reused the register. But interp() refused any first half that belongs to a pair ("the first half of an interpolation"), so the export that eventually reads v10 had no value.

A first half that belongs to a pair now writes 0 to its register instead. Its real partial sum is never needed, because its second half interpolates the attribute directly.

3. 16-bit float wave sums where some lanes have left (2 programs, 1 in game)

compute_graph_ops:CS_TransposeVecMatMul* sums v_add_f16 products over the wave (DPP / v_permlanex16 / v_readlane tree), after threads past the matrix edge have already left through v_cmpx. half_sum reproduces the console's balanced tree bit for bit, but only when every lane is present ("a wave sum of 16-bit floats where not every lane runs").

On the console, the section runs in every lane, and a lane outside EXEC adds +0. So after step k, every lane of an aligned run of 2^k lanes holds that run's partial sum, including the lanes that left. The new half_sum_present (one host wave of 64, which is AMD) reads each partner run's sum from the first lane of that run that is still here, using a WaveActiveBallot, and uses +0 when no lane of that run is here. Lane 0's high half is handled the same way. Two host waves of 32 (NVIDIA) still refuse this case, because there the halves are exchanged through group-shared memory and that needs every lane.

Testing

  • Whole retail pack (victory translate shaders.rpf --validate --list, 26,503 containers), compared per program against the build before this commit:

    before after
    vertex + pixel emitted / validated 14,156 / 14,045 14,199 / 14,088
    compute emitted / validated 2,669 / 2,669 2,671 / 2,671 (this branch alone; 2,672 with AMD: clamp view heap indices on every host (fixes device removal on RDNA3); add v_cvt_f32_f64, v_permlane16/x16 #134's v_permlanex16)
    mesh emitted / validated 8,762 / 8,657 8,762 / 8,657 (unchanged)

    46 programs went from a failure to validated: 35 "descriptor read only as data", 8 "first half of an interpolation", 2 "wave sum of 16-bit floats where not every lane runs" and 1 "descriptor's address or format read as data". No program went the other way.

  • New GPU test a_sum_of_halves_where_lanes_have_left_is_the_consoles_tree_bit_for_bit (wave64_tests.rs): 64 lanes hold distinct f16 values whose sum depends on the order of the additions. Lanes at or past s0 leave through v_cmpx + s_cbranch_execz, and the rest run the console's sum sequence. With 64, 63, 40, 33, 32, 17, 5 and 1 lanes staying, the RX 7900 XT matches the console's tree bit for bit (lanes that left count as +0). The existing full-wave tree test still passes.

  • cargo test --workspace --locked: 23 suites, 497 tests, all pass. cargo clippy --workspace --all-targets --locked -- -D warnings: clean.

In game (RX 7900 XT, this commit + #134, VICTORY_RELAY=2 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024)

before after
Programs the title binds that do not translate 9 2
Now translate – 7d0f14ce44746d7e, 2fd01fca16993001, 6b6db9f1a526daeb (PuddleDetect), 78f3f2fc53a69531, 38bf0814e721a1b3 (DeferredTextured), b22a16a178976e1b (TransposeVecMatMulAligned), ceb5eb68cd99cb07 (MinTimestepReduce)
Device removed / errors / black frames 0 / 0 / 0 0 / 0 / 0
World frame rate ~5.9 fps ~5.9 fps (about 7½ minutes in the prologue)

What the screen still shows (prologue, after this PR)

From two screenshots of the opening interior scenes on the RX 7900 XT, with what the logs say about each:

  1. Walls and ceilings of the interior are missing. The room and corridor are open to the sky and haze, and ceiling slabs float. One character in the corridor is drawn as a head and forearms only, with no torso or clothing. The strongest lead is device methods 0x1c8 / 0x218 (DeserializePipelineStateX, per XCL's console device map). They return E_NOTIMPL, and the run logged them at 16,384+ calls (0x1c8) and 2,048+ (0x218), all during loading. device.rs notes that on failure "the title goes without this pipeline, silently". With thousands of pipelines missing, whole material passes (walls, clothing layers) are plausibly never drawn. This is not shown yet: the next step is to decode the serialized descriptions that are already logged (description= / first_points_at=) and build the pipelines from them. The README's known issue "The interior of the first gameplay room is sometimes not drawn" fits the same cause.
  2. Speckled, glittering surfaces on characters' clothing and skin, which look like unresolved per-pixel noise. This looks like dithered or stochastic material (hair, cloth, stochastic transparency) and noisy lighting that the console resolves with temporal accumulation or denoising. Candidates are a pass missing because of (1), or the ray-traced lighting that does not run yet. This needs a frame capture to confirm (VICTORY_CAPTURE + VICTORY_DUMP_TARGETS on the diagnostics build).
  3. Faces and the shadowed side of characters are near black. This is the known missing ray-traced bounce light and shadows ("anything the sun does not hit directly is black"). Its CS_TraceShadowRays_* programs (5) still fail with "a descriptor read only as data": they take a BVH address from a descriptor (s_lshr_b64 s[38:39], s[36:37], 8) and walk memory from it, which depends on the fork's ray-tracing work.
  4. Stray long lines from hair (strands stretching away from heads) and a long bright diagonal line across the floor. These are vertices at wrong positions: hair cards or skinned or blend-shape geometry. Not yet traced to a specific program.

Still failing in the pack

  • 5 water_shading:CS_TransmissionVolumetrics* (2 bound in the prologue): a wave-wide sum of doubles (v_add_f64 through the same DPP / permlane / readlane tree, WaveActiveSum(1.0) as a lane count), which the section simulator does not model. Fixing it needs double support in the emitter.
  • 5 shadowmask:CS_TraceShadowRays_* (ray tracing, see above), 195 GS_Voxelize* ("an address in an SGPR that is no root parameter"), 40 "a descriptor chosen by control flow", 10 "a hardware SGPR input", and 1 "an opaque lane mask".
  • One host mesh pipeline is still refused with E_INVALIDARG (mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35), which predates this PR.

Notes

  • XCL (GPL-2.0-only) was read only to identify the console device slots. No code from it is in this PR.
  • Workflow for the next person: VICTORY_TRANSLATE_ONLY=<hash,...> and VICTORY_DUMP_MATCH="<dir>;#<hash>|..." with translate, then shader-info <file> --disasm. Comparing --list outcomes per #hash against a baseline build is what caught the waterfall regression.

🤖 Generated with Claude Code

…16-bit wave sums with lanes gone

Three translator gaps that dropped world shaders (46 programs of the
retail pack; 0 that translated before stop now, by a whole-pack
`translate --validate --list` against the previous commit):

- A descriptor nothing uses as one, whose dwords the code reads all the
  same ("a descriptor read only as data", 35, and one "a descriptor's
  address or format read as data"): an 8-dword image picked from the heap
  by an index in a constant buffer, its width/height/base level turned
  into a texel size (PS_PuddleDetect, 34 pixel programs), or a 4-dword
  buffer tested for being empty by its record count
  (ShallowWaterSim:CS_MinTimestepReduce). New `unused_descriptor_kind`
  gives such loads a kind (image: a 2D texture, documented as a shortcut;
  buffer: a raw view) and `descriptor_data` rebuilds their size dwords from
  the host view as it does for used descriptors; the buffer's address
  dwords come from the host as before. Lane-copied descriptors and
  samplers keep their own handling (checked first).
- The first half of an f16 interpolation pair whose register an f16 second
  half then writes the high half of ("the first half of an
  interpolation", 8, PS_DeferredTextured and mirror-reflection variants):
  the second half keeps the low half of the register, which the first
  half wrote and nothing reads. The first half of a pair now writes 0.
- A 16-bit float wave sum where some lanes have left the program ("a wave
  sum of 16-bit floats where not every lane runs", 2,
  compute_graph_ops:CS_TransposeVecMatMul*): on a host wave of 64 lanes,
  `half_sum_present` follows the console's balanced tree, each lane
  reading its partner run's partial sum from the first lane of that run
  that is here (every lane of an aligned run holds the run's sum on the
  console, the ones outside EXEC included), +0 where none is. Two host
  waves of 32 still refuse it.

Tests: a GPU test of the 16-bit sum with 64, 63, 40, 33, 32, 17, 5 and 1
lanes staying, bit for bit against the console's tree (RX 7900 XT).
cargo test --workspace and clippy -D warnings pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Flyander Flyander left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-check on Windows D3D12 with an RTX 5070 Ti: cargo test --locked -p victory-shader --lib passes (211 passed, 2 ignored).

The new a_sum_of_halves_where_lanes_have_left_is_the_consoles_tree_bit_for_bit test cannot execute this wave64 program on this GPU: on_the_card reports “the hardware device does not take this program; not run”, then the test returns ok. So this run checks the rest of the shader suite on NVIDIA, while the RX 7900 XT run in the PR remains the hardware execution evidence for the new 64-lane path.

@m335671

m335671 commented Nov 24, 2026

Copy link
Copy Markdown

For whoever merges: part 2 here (f16 interpolation pairs, 8 programs) fixes the same 8 programs as #77, which has been open since earlier today, at a different place.

  • Shaders: v_fma_mixlo/mixhi over an f16 first interpolation half keeps zero (8 pixel programs) #77 keeps interp() as it is and fixes the consumer. The first half's VGPR stays without a value. The v_fma_mixlo_f16 / v_fma_mixhi_f16 arm that keeps the other half of that VGPR now treats a missing old value as 0, as write_half and low_half already do. That is 5 lines in lower.rs plus a test that fails without it.
  • Here, a first half that belongs to a pair writes 0 to its register. That covers any later reader of that register, not only the mixed FMA.

Same 8 hashes either way: 38bf0814e721a1b3, 78f3f2fc53a69531, 8445dcb2b63aa197, 007bb29b393d08c5, 15547db9d31b056b, 288c43f50bc7abee, 5ddcaa08d4a51215, 464ea474374b8ecd. #77 has in-game and offline confirmations on RTX 5070 Ti, RTX 5080, RTX 4080, RX 9070 and a Series S profile run (8 gained, 0 lost).

The two don't conflict in behaviour: with both, the mixed FMA reads the 0 this PR writes. Whichever lands first makes the other's part redundant for these programs. I have not tested this PR.

AI use: Claude Code (Claude Opus 5.5) compared the two changes and wrote this comment. I am the author of #77.

@pablogonz12

Copy link
Copy Markdown

Test report from AMD on Linux, for the 16-bit wave-sum part.

Setup: RX 9070 XT (RDNA4, GFX1201, native wave64), RADV Mesa 26.3.1, Arch, GE-Proton11-14 (Wine 11.0), vkd3d-proton master.

On this machine one world program was still refused for a 16-bit wave sum with lanes gone (the only remaining refusal of that kind in my dump of 751 world programs). With this PR built on the fork's main it translates, the DXIL validates and RADV creates the pipeline. I had written my own lowering for the same case (one widened f32 sum, rounded once); yours keeps the console's tree over the present lanes, which is the better choice, so I dropped mine.

Not tested: a game run with this PR alone, the descriptor-size and interpolation parts on their own. (AI-assisted; numbers from my own runs.)

@icecreammule277-dot

Copy link
Copy Markdown

Tested on an RX 9070 XT (Adrenalin 32.0.32029.2010).

Two compute programs that previously failed to translate now do:

  • b22a16a178976e1b — a 16-bit wave sum where not every lane runs. It had been dropped 14 dispatches a frame, every frame.
  • ceb5eb68cd99cb07 — a descriptor's dword 2 read as data (a buffer tested for being empty by its record count).

Both error strings match this PR's items one for one ("a wave sum of 16-bit floats where not every lane runs" and "a descriptor's address or format read as data").

For anyone cherry-picking onto an older base: the descriptor_data hunk conflicts. Resolving it by wrapping the existing if let/else in the unused-kind branch works and keeps the base's shape —

let unused = if use_at.is_none() {
    self.unused_descriptor_kind(inst, site, code, count)
} else {
    None
};
let (first, src, props, image, uav, used) = if let Some(kind) = unused {
    let (first, props, image, uav, used) = kind;
    (first, Source::Loaded { load: site, first }, props, image, uav, used)
} else if let Some((at, first)) = use_at {
    ...
} else {
    ...
};

— and the wave64_tests.rs hunks apply clean. 223 shader tests pass.

@arminkhaleghirod

Copy link
Copy Markdown

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

  • a descriptor read only as data: 40 → 5
  • a descriptor's address or format read as data: 1 → 0
  • a wave sum of 16-bit floats where not every lane runs: 2 → 0
  • the first half of an interpolation: 8 → 0
  • DXIL emitted: 14,168 → 14,211
  • No new failure reason. The newly emitted programs land in the blanket PSV mismatch on main, so their real validator result only shows with Shaders: write every PSV0 semantic name again, as DXC does (fixes #12) #61.

The descriptor and interpolation parts give the same counts as #81 and #77, so those overlap with this one.

@Arvi23

Arvi23 commented Nov 25, 2026

Copy link
Copy Markdown

Tested in game on AMD RDNA4 (RX 9070 XT, Windows 10): all 8 programs that did not translate in the prologue translate with this PR.

Setup: RX 9070 XT, driver 32.0.32029.2010, Windows 10 IoT Enterprise LTSC 21H2 (19044) with the Agility SDK runtime (#420), release build, Series X profile, no VICTORY_* switches.

Without this PR (31714de + #420's first commit + the #120 patch + #58), the run dropped these, first bound between frames 1112 and 1561:

program reason
2fd01fca16993001, 6b6db9f1a526daeb, abc6a80d46edc294, 8660e9822ebe4b62, c8df7216c69cecbd, 7d0f14ce44746d7e (pixel) a descriptor read only as data
ceb5eb68cd99cb07 (compute) a descriptor's address or format read as data
b22a16a178976e1b (compute) a wave sum of 16-bit floats where not every lane runs

With this PR (and #51) on the same tree, and again on a803c87 + #420: 0 programs untranslated in each run, no device removal, no compiler crash.

On the overlap with main: 3bff182 already maps the first half of an f16 interpolation pair onto its pair (VICTORY_FIRST_HALF). This PR's write-0 in interp() only runs for a site that is not in that map, so on current main it is a fallback behind 3bff182's version. The cherry-pick onto 31714de and a803c87 had no conflicts.

cargo test --workspace with this PR, #420 and #411 on a803c87: 509 passed, 0 failed.

AI use: Claude Code (Claude Opus 5.5) read the logs and the overlap and wrote this; the runs are on my machine.

@ryotdev

ryotdev commented Nov 25, 2026

Copy link
Copy Markdown

I tested commit 0e49a91 on Windows 11 with an RTX 5070 (driver 610.88), using the Series X profile. I cherry-picked this PR onto an older local play branch based on 4e17478, with #63 and a single-wave LDS fix, and used the same prison checkpoint as the control.

  • With the translator set to wave32, 2 of 8 selected programs passed DXIL validation on the control and 8 of 8 passed with this PR. The set included the seven programs named in the PR and one checkerboard-shadow control. The matrix program already passed on this base.
  • In the game, two previously refused puddle variants reached 8 and 3 indirect draw recordings in one sampled frame. The previously refused shallow-water timestep reached 8 direct dispatch recordings in another. An indirect recording does not tell us how many pixels it drew.
  • Both deferred-material variants validated offline. They did not appear in the sampled draw commands, so I could not attribute a change in character appearance to them. The run reached interactive 3D without a device loss.

AI-assisted test. These counts apply to the local base above.

gmankab pushed a commit to gmankab/fxceless-victory that referenced this pull request Nov 25, 2026
Use the wave-reduction change and its hardware test from Fxceless PR fxceless#203. This applies the balanced half-precision tree to live lanes, treating absent lanes as zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iGoldenNinja

iGoldenNinja commented Nov 25, 2026 •

Copy link
Copy Markdown

Independent RTX 5080 check of the descriptor-data part of 0e49a91, on PR 688 head 7e7bb18 with PR 51 d82acef already applied. Windows 11 Pro 25H2 build 26200.9974, NVIDIA 617.14, Ryzen 9 5900X, Rust 1.98.1 MSVC, DXIL 1.9.2609.5, Series X profile. The comparison kept the same relay, inline staging and input sequence.

7d0f14ce44746d7e and 6b6db9f1a526daeb both went from a descriptor read only as data to validated DXIL and a created offline D3D12 test pipeline. The live run also accepted both mesh/pixel pipelines, paired with a9184e594aae6932 and 4f23fd8d99482703, respectively. The five compute controls reproduced their previous results.

The same interior view after the first retreat still showed wall and ceiling gaps. Over five minutes of the prison replay, Presented FPS was 4.565 before and 4.543 after, and P99 was 435.139 and 435.072 ms. The patched run reached player control and ended deliberately after capture with no DRED device removal logged. This isolates only the descriptor change, with one live run per build.

Test method and counts

OpenAI Codex (GPT-6) ran the local checks and drafted this report.

gmankab pushed a commit to gmankab/fxceless-victory that referenced this pull request Nov 25, 2026
Use the wave-reduction change and its hardware test from Fxceless PR fxceless#203. This applies the balanced half-precision tree to live lanes, treating absent lanes as zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ArturoWolff

Copy link
Copy Markdown

Linux offline A/B on 8dd30ab versus the same main + only 0e49a91 (clean automatic merge). Of the seven prologue hashes in the PR, 3/7 validated on main and 7/7 with #203. Both builds called emit::translate directly on the same hash-checked inputs with set_host_max_wave(32); every emitted container was checked with dxv.

  • The three PuddleDetect variants and ceb5eb68cd99cb07 (shallow-water timestep) are the four gains. The latter reproduces issue shaders and light #599’s descriptor refusal at 0x38 on main. These are not four new wins on top of Shaders: a descriptor only read as data of eight dwords is a measured image #81: the three puddle variants overlap our earlier #81 replay.
  • The two deferred-material variants and the matrix compute b22a16a178976e1b already validated and were byte-identical across the builds. The matrix disassembly declares WaveSize=32 on this base. That is not a test of the PR’s wave64 arithmetic.
  • Two extra issue shaders and light #599 controls separate this from a black-frame fix: final-composite pixel 4f4ec7b16673362f was byte-identical; compute f133e35efed2a48a still refused at 0x1eb4 (lane mask exchanged where not every lane runs). The older local Proton run logged first binds for two of the newly translatable puddle variants at frame 2251; it did not log the shallow-water hash. No game or GPU pipeline ran in this A/B. The next useful runtime observation is whether those puddle draws actually write a target consumed by the final composite.

AI disclosure: Hermes Agent ran the Linux comparison, checked the validator output and prior bind log, and wrote this comment on ArturoWolff’s behalf.

Artking175 added a commit to Artking175/ztrx that referenced this pull request Nov 25, 2026
Use the 2D texture size path for full pixel SRV descriptors whose size word is read without an image operation. Leave existing sampler, lane-copy and buffer handling in place. Failure analysis and external comparison: fxceless/victory-fork#203.
Artking175 added a commit to Artking175/ztrx that referenced this pull request Nov 25, 2026
Retain the partial sum when an instruction reads it or an f16 interpolation keeps half of its destination. Use the usual half-register write so the destination follows op_sel. Failure analysis: fxceless/victory-fork#203.
gloger2003 pushed a commit to gloger2003/ztrx that referenced this pull request Nov 25, 2026
Retain the partial sum when an instruction reads it or an f16 interpolation keeps half of its destination. Use the usual half-register write so the destination follows op_sel. Failure analysis: fxceless/victory-fork#203.
gloger2003 pushed a commit to gloger2003/ztrx that referenced this pull request Nov 25, 2026
Use the 2D texture size path for full pixel SRV descriptors whose size word is read without an image operation. Leave existing sampler, lane-copy and buffer handling in place. Failure analysis and external comparison: fxceless/victory-fork#203.
sagouindupm pushed a commit to sagouindupm/Mandy that referenced this pull request Nov 25, 2026
Retain the partial sum when an instruction reads it or an f16 interpolation keeps half of its destination. Use the usual half-register write so the destination follows op_sel. Failure analysis: fxceless/victory-fork#203.

(cherry picked from commit 7b623a22aa5455af08c3539d2ddf607b7ca2823a)
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.

10 participants