Shaders: zero missing typed-buffer components #1515
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1516"
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?
Imported from Marvisak/VIctory. Originally posted by venglov on 2026-11-24T18:40:33Z.
tbuffer_load_format_xyzwcurrently returns 1 in W when the instruction's format has fewer than four components. The RDNA 2 MTBUF identity selection supplies zero for every missing component. This fixes the missing-channel behavior reported under VIC-BT-019 in #1242. RDNA 2 ISA §8.1.4, Table 31. Issue #1060 measured it on gfx1036 for all 77 buffer formats: every missing channel reads 0, the 4th included, and the typed loads ignore the descriptor'sdst_sel.The change zero-fills the missing channels after format conversion. It applies to GFX10 typed-format loads used for vertex fetch and compute.
format_load's doc comment now states this rule in place of the old(0, 0, 0, 1)one.The
typed loadscase indiff_tests.rsreads 16_16 SNORM through anR16G16_SNORMtyped view, which gives(x, y, 0, 1). Its PC side now takes.xyand zeroes the rest, as #1370 did. The other loads in that case have four channels, or their PC side already pads with 0.Verification
32_UINTand32_FLOATthrough synthetictbuffer_load_format_xyzwinstructions.940d32f. On Windows the workspace suite passed (703 passed, 10 ignored), and both Clippy configurations passed with warnings denied. The readback tests ran on WARP because the runner has no GPU. The verification branch adds only a CI workflow change on top of308d7dc. Windows CI runcargo xtask policypassed.translated_compute_matches_pcis not run: it needs the console compiler, which neither CI nor I have.In-game impact is unmeasured. OpenAI Codex assisted with the original change. Claude Code (Claude Opus 5.5) did the rebase and the differential-test update. The regression fixtures are synthetic.
Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T19:12:57Z.
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
63be4e0.cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 122 passed, 0 failed, 1 ignored.Two notes for review:
out.resize(channels, 0)informat_load. #1370 adds hardware readbacks over 25 formats (passed on an RTX 5090 and, in my run, on an RTX 5070). This one adds a portable lowering test and rewrites the doc comment.diff_tests.rsisn't updated here. Thetyped loadscase inCS_CASEScompares the translation against the PC reading the same bytes through anR16G16_SNORMtyped view, which returns(x, y, 0, 1). After this change the translation returns(x, y, 0, 0)for that format. #1370 changes the PC side touint4(asuint(snorm16x2[e].xy), 0, 0)for that reason. I couldn't run that test here (it needs the console compiler and skips without it), so this is from reading the code: on a machine that has the compiler, I'd expecttranslated_compute_matches_pcto fail with this branch alone.Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T19:33:52Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count changes against
main, and the tests pass on Ada.Offline. I merged head
63be4e0ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 on both, 0 gained, 0 lost. No program changes its failure reason either.This is the expected result for a correctness fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests. With the same merge,
cargo test --locked -p victory-shader --libpassed 122, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:30:03Z.
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (merge-candidate) was for an older state ofmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by venglov on 2026-11-25T14:21:44Z.
@marquezinii, thanks. You were right on the second point, and it is fixed in
308d7dc.b = raw.XB_TypedLoad4(4 * e, FMT(1, 5))is 16_16 SNORM. The translation now gives(x, y, 0, 0)there, and theR16G16_SNORMview gives(x, y, 0, 1).close()does not accept 1.0 against 0, sotranslated_compute_matches_pcwould have failed. The PC side now readsuint4(asuint(snorm16x2[e].xy), 0, 0), the same as #1370, and the case's comment no longer states(0, 0, 0, 1). The other seven loads in the case are unaffected. Their formats have four channels, or their PC side already pads with 0 (ff,gg). Like you, I cannot run that test: it needs the console compiler.On the first point, triage closed #1370 in favor of this PR, so this is now the only PR with the change. Its hardware coverage is in #1060, measured on gfx1036 across all 77 formats.
The PR is also rebased onto
940d32f, which resolves thevalu_tests.rsconflict that triage reported. Both tests are kept. The readback test now uses main'smtbuf()helper in place of hand-encoded words, and the encoding is the same.format_load's comment now cites the #1060 measurement. Windows CI passed at308d7dc: run. That covers 703 tests, both Clippy configurations, and the readback tests on WARP.Written with Claude Code.
Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-26T16:40:29Z.
Hardware check of this PR on current
main(63bcca4), against RDNA2 silicon. Result: 0 differences from the hardware on all 77 formats, on an AMD and an NVIDIA host.Setup.
tbuffer_load_format_xyzwwith each of the 77 GFX10 formats over 64 rows of edge patterns and random values.MTBUFwords throughbuild_valu_cs, run on two hosts:63bcca4.lower.rsconflicts withmain, so I resolved it by hand:out.resize(channels, 0);da82e44made that conversion exact;the_code_table_starts_after_the_instructionsfrommainnext to the new test.Lyrnc:rebase-1516-on-63bcca4, with the authorship kept. Feel free to take it.Results (77 formats × 64 rows × 4 channels):
main63bcca41/1.0where the hardware reads0), 49 formats × 64 rows63bcca4maindiffers from the hardware only in that missing 4th channel.da82e44already brought the norm conversions in line with the hardware, so no UNORM/SNORM value differs any more. With this PR on top, every value matches the hardware bit for bit on both hosts. NaN payloads aside, though none showed up in this run.The PR's own tests also pass on the rebased tree, on the 5080:
missing_typed_buffer_channels_are_zerotyped_buffer_loads_zero_missing_channelsnormalized_buffer_formats_*AI use: Claude Code (Claude Opus 5.5) ran the comparison and the tests on the GPUs above, resolved the conflict and drafted this comment. The numbers come from those runs.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T14:12:37Z.
I combined
308d7dcwith the exact D16 work from #1940/#2843 on current main63bcca4. Branch 7d17835 preserves the PR commits and resolves the overlap informat_loadand its tests.The new
tbuffer_load_format_d16_xyzwtest reads both packed dwords from R16_UNORM, R16_SNORM and R16_FLOAT. With exact rounding alone at8bcc0bf, R16_UNORM gets the right first dword but the second is0x3c000000, representing 1.0 in the missing W channel. The combination produces exact FP16 X and zeros for Y/Z/W in all six checks. A CPU lowering check also confirms the missing normalized channels no longer emit a legacy f32-to-f16 conversion.On app-local WARP 1.0.22 with DXIL validation, all 12 D16 tests passed. The #1516 typed-buffer readback and CPU missing-channel check passed too, as did strict shader Clippy and the asset check.
The merge resolution and regression are ready for the existing PR. Please retain Git authorship if taking them, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if squashed.AI-assisted with Codex. All readback data was synthetic.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.