Repository navigation
Port upstream #169: tbuffer d16 loads pack two channels, normalized ends load as exactly ±1.0 - #28
Merged
DesertGamer merged 2 commits intoNov 25, 2026
Conversation
6 of 7 tasks
The d16 forms of the typed buffer loads return each channel as 16 bits, two per VGPR, low half first; the decoder already sizes their data that way. The lowering only treated `buffer_` names as d16, so a tbuffer_load_format_d16_* went through the 32-bit path: the first VGPR got channel x as a 32-bit value (the f32 bits of 1.0 instead of the f16 pair (1.0, 2.0)) and the other channels were dropped. The format path now packs its channels for d16: integer formats keep their low 16 bits, the other formats become f16 (as the MUBUF d16 path converts them). (cherry picked from commit c430b1d)
Buffer format loads divide a UNORM or SNORM field by its largest value. A host may divide through a reciprocal and land just below 1.0: on an RX 9070 (RDNA 4), 16_16_UNORM's 65535 loaded through the d16 path as the half 0x3BFF instead of 0x3C00. The largest value now selects 1.0, and an SNORM field's two lowest values select -1.0, as the formats define them. (cherry picked from commit 645391b)
lcg007xd-c
force-pushed
the
port/upstream-169-tbuffer-d16-norm-ends
branch
from
November 25, 2026 21:45
14b76d5 to
317c470
Compare
2 of 23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
This ports Marvisak/VIctory#169 by Dufftwt: both of its commits, cherry-picked with
-x, so they keep their authorship. The upstream merge is in VIPort's history, but neither change is in the tree. Inemit/lower.rsonmain:tbuffer_load_format_d16_*are loaded as 32-bit. The d16 test isname.starts_with("buffer_") && name.contains("_format_d16_"), so the typed (tbuffer_) d16 loads take the 32-bit path. The first VGPR gets channel x as an f32 (the bits of 1.0, not the f16 pair (1.0, 2.0)), and the other channels are dropped. The decoder already sizes their data as d16, two channels per VGPR. The first commit packs the format path's channels for d16: integer formats keep their low 16 bits, the others become f16, as the MUBUF d16 path does. It addstbuffer_d16_loads_pack_two_channels_per_dword.16_16_UNORM's 65535 loading as the half0x3BFFinstead of0x3C00on an RX 9070. The second commit selects exactly 1.0 for the largest value, and exactly -1.0 for an SNORM field's two lowest values, as the formats define them. It addsnormalized_buffer_formats_load_their_ends_exactly.The second commit's test uses helpers from the first, so they come together, as they did upstream. The cherry-picks did not follow the rename for
valu_tests.rs, so I applied that file's hunks tocrates/viport-shader/src/emit/valu_tests.rsby hand. They applied cleanly.lower.rsapplied as is.Checked
docs/asset-policy.mdbuild.rs, git hook,.cargoconfig, CI change or script (or an issue explains why)cargo test --workspacepasses (onlyviport-shader --libon Linux, see below)cargo clippy --workspace --all-targets --locked -- -D warningspasses (forviport-shader, with CI: clear the clippy errors that keep main red since a3e7f17 #21 merged in locally)rustfmt; I did not reformat lines I did not changeWhat I ran
On Linux, Rust 1.98.1:
cargo test -p viport-shader --lib --locked: 190 passed, 0 failed, 3 ignored. This covers decoding and lowering, but not the new tests, which run on D3D12.cargo clippy -p viport-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: clean with CI: clear the clippy errors that keep main red since a3e7f17 #21 merged in, so the new Windows tests type-check.Not run: the two new tests in
valu_tests.rs. They dispatch on the host GPU and WARP, and I have no Windows machine. The Windows CI test step should run them on WARP. Upstream ran them there and on an RX 9070 for #169.Overlaps
#22 (
v_dot8_i32_i4) and #21 (CI clippy) also editemit/lower.rs, in other functions. I merged #21 into this branch locally with no conflict.🤖 Generated with Claude Code