Shaders: zero missing typed-buffer components #1516
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1516
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@venglov on GitHub · 2026-11-24 18:40 UTC · original
venglov:fix/mtbuf-missing-channels→main· +72 −18 · 3 files · 2 commits · opentbuffer_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.
@marquezinii on GitHub · 2026-11-24 19:12 UTC · original
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.@sinan-cmyk on GitHub · 2026-11-24 19:33 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 01:30 UTC · original · edited 2026-11-25 16:06 UTC
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
@venglov on GitHub · 2026-11-25 14:21 UTC · original
@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.
@Lyrnc on GitHub · 2026-11-26 16:40 UTC · original
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.
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.