Repository navigation
Shaders: sizes of unused descriptors, paired f16 interpolation halves, 16-bit wave sums with lanes gone (+46 programs) - #203
Conversation
…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
left a comment
There was a problem hiding this comment.
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.
|
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.
Same 8 hashes either way: 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. |
|
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.) |
|
Tested on an RX 9070 XT (Adrenalin 32.0.32029.2010). Two compute programs that previously failed to translate now do:
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 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 |
|
Merged onto main 90228a7, ran
The descriptor and interpolation parts give the same counts as #81 and #77, so those overlap with this one. |
|
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 Without this PR (
With this PR (and #51) on the same tree, and again on On the overlap with
AI use: Claude Code (Claude Opus 5.5) read the logs and the overlap and wrote this; the runs are on my machine. |
|
I tested commit
AI-assisted test. These counts apply to the local base above. |
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>
|
Independent RTX 5080 check of the descriptor-data part of
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. OpenAI Codex (GPT-6) ran the local checks and drafted this report. |
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>
|
Linux offline A/B on
AI disclosure: Hermes Agent ran the Linux comparison, checked the validator output and prior bind log, and wrote this comment on ArturoWolff’s behalf. |
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.
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.
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.
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.
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)
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
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