Shaders: sizes of unused descriptors, paired f16 interpolation halves, 16-bit wave sums with lanes gone (+46 programs) #203
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!203
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-203"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@triippywhale on GitHub · 2026-11-24 22:32 UTC · original
triippywhale:fix/shader-gaps→main· +236 −3 · 2 files · 1 commits · openSummary
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 fxceless/victory-fork#134 (the AMD view-heap clamp): this branch is upstream
2119b0eplus 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_datarebuilt 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): at0x1c5cthe program doess_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 runs_cmp_eq_u32 s2, 0on 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_kindgives such a load a kind:The existing tail of
descriptor_datathen rebuilds the dwords fromgetDimensionson 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: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 readsv10had 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*sumsv_add_f16products over the wave (DPP /v_permlanex16/v_readlanetree), after threads past the matrix edge have already left throughv_cmpx.half_sumreproduces 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 newhalf_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 aWaveActiveBallot, and uses+0when 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:v_permlanex16)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 pasts0leave throughv_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)7d0f14ce44746d7e,2fd01fca16993001,6b6db9f1a526daeb(PuddleDetect),78f3f2fc53a69531,38bf0814e721a1b3(DeferredTextured),b22a16a178976e1b(TransposeVecMatMulAligned),ceb5eb68cd99cb07(MinTimestepReduce)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:
0x1c8/0x218(DeserializePipelineStateX, per XCL's console device map). They returnE_NOTIMPL, and the run logged them at 16,384+ calls (0x1c8) and 2,048+ (0x218), all during loading.device.rsnotes 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.VICTORY_CAPTURE+VICTORY_DUMP_TARGETSon the diagnostics build).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.Still failing in the pack
water_shading:CS_TransmissionVolumetrics*(2 bound in the prologue): a wave-wide sum of doubles (v_add_f64through 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.shadowmask:CS_TraceShadowRays_*(ray tracing, see above), 195GS_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".E_INVALIDARG(mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35), which predates this PR.Notes
VICTORY_TRANSLATE_ONLY=<hash,...>andVICTORY_DUMP_MATCH="<dir>;#<hash>|..."withtranslate, thenshader-info <file> --disasm. Comparing--listoutcomes per#hashagainst a baseline build is what caught the waterfall regression.🤖 Generated with Claude Code
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 <[email protected]>@m335671 on GitHub · 2026-11-24 22:45 UTC · original
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.
interp()as it is and fixes the consumer. The first half's VGPR stays without a value. Thev_fma_mixlo_f16/v_fma_mixhi_f16arm that keeps the other half of that VGPR now treats a missing old value as 0, aswrite_halfandlow_halfalready do. That is 5 lines inlower.rsplus a test that fails without it.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 on GitHub · 2026-11-24 22:51 UTC · original
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 on GitHub · 2026-11-24 23:02 UTC · original
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_datahunk conflicts. Resolving it by wrapping the existingif let/elsein the unused-kind branch works and keeps the base's shape —— and the
wave64_tests.rshunks apply clean. 223 shader tests pass.@arminkhaleghirod on GitHub · 2026-11-24 23:38 UTC · original
Merged onto main
90228a7, ranvictory translate --validateover the full title (26,148 programs), Windows 11 / RTX 4080. Changes against main:a descriptor read only as data: 40 → 5a descriptor's address or format read as data: 1 → 0a wave sum of 16-bit floats where not every lane runs: 2 → 0the first half of an interpolation: 8 → 0The descriptor and interpolation parts give the same counts as #81 and #77, so those overlap with this one.
@Arvi23 on GitHub · 2026-11-25 01:10 UTC · original
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:2fd01fca16993001,6b6db9f1a526daeb,abc6a80d46edc294,8660e9822ebe4b62,c8df7216c69cecbd,7d0f14ce44746d7e(pixel)ceb5eb68cd99cb07(compute)b22a16a178976e1b(compute)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:3bff182already maps the first half of an f16 interpolation pair onto its pair (VICTORY_FIRST_HALF). This PR's write-0 ininterp()only runs for a site that is not in that map, so on currentmainit is a fallback behind3bff182's version. The cherry-pick onto31714deanda803c87had no conflicts.cargo test --workspacewith this PR, #420 and #411 ona803c87: 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 on GitHub · 2026-11-25 02:04 UTC · original
I tested commit
0e49a91on 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 on4e17478, with #63 and a single-wave LDS fix, and used the same prison checkpoint as the control.AI-assisted test. These counts apply to the local base above.
@iGoldenNinja on GitHub · 2026-11-25 06:03 UTC · original
Independent RTX 5080 check of the descriptor-data part of
0e49a91, on PR 688 head7e7bb18with PR 51d82acefalready 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.7d0f14ce44746d7eand6b6db9f1a526daebboth went froma descriptor read only as datato validated DXIL and a created offline D3D12 test pipeline. The live run also accepted both mesh/pixel pipelines, paired witha9184e594aae6932and4f23fd8d99482703, 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.
@ArturoWolff on GitHub · 2026-11-25 06:12 UTC · original
Linux offline A/B on
8dd30abversus the same main + only0e49a91(clean automatic merge). Of the seven prologue hashes in the PR, 3/7 validated on main and 7/7 with #203. Both builds calledemit::translatedirectly on the same hash-checked inputs withset_host_max_wave(32); every emitted container was checked withdxv.PuddleDetectvariants andceb5eb68cd99cb07(shallow-water timestep) are the four gains. The latter reproduces #599’s descriptor refusal at0x38on main. These are not four new wins on top of #81: the three puddle variants overlap our earlier #81 replay.b22a16a178976e1balready validated and were byte-identical across the builds. The matrix disassembly declaresWaveSize=32on this base. That is not a test of the PR’s wave64 arithmetic.4f4ec7b16673362fwas byte-identical; computef133e35efed2a48astill refused at0x1eb4(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.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.