Shaders: keep d16 bits of heap-picked integer views; nearest float for normalized buffer codes #240
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/gamingwithhomie--larp!240
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-240"
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?
@ambrosia-works on GitHub · 2026-12-05 22:00 UTC · original
ambrosia-works:fix/d16-integer-views-norm-codes→main· +1088 −42 · 12 files · 2 commits · merged 2026-12-05 23:34 UTCSummary
Two shader-translator correctness fixes, ported from the cool_fox fork (
9a6c829d6, after VIctory4243a96aandda82e444). Every shader is translated anew:lower.rsandshader.rsare hashed into the translation cache key.1. d16 data of integer typed views picked from the heap keeps its bits
The facial animation network keeps its tensors in
R16G16B16A16_UINT/R16_UINTtyped buffer views and reads and writes them as d16 data.halves.rsalready handles such views at fixed table places. For a view the program picks from the view heap at run time, the translator still took d16 data as f16 and converted it, which changes the integer bits. This is a candidate cause of the broken facial animation on AMD (only one eye blinks, mouths warp while talking). I have not verified that in-game yet.VIEW_INTEGER= bit 31,VIEW_SIGNED= bit 30;descriptor/host.rsview_kind).lower.rsinteger_viewreads the marks:halves.rs's unsigned-twin path is unchanged and still runs first.VIEW_STRIDE_BITS:slot_stride, and the four replacement shaders that readt255directly (3592426e3e9142d8,a74a0746279f960d,aeb93e0888250bd3,b58eb3ca6ee46427). Thet255row inshaders/replace/README.mddescribes the new bits.2. Normalized buffer codes give the nearest float
format_loaddivided UNORM/SNORM codes by2^n - 1, and the host's division is not exact. On the RX 7900 XT, 8-bit code 3 loads one ulp high, and 16-bit code 257, multiplied back by 65535 and truncated, comes out as 256. Titles truncatex * (2^n - 1)back to the code (for example a material index in a vertex colour's alpha), so a quotient one ulp low becomes the code below.norm_quotient/exact_norm, which give the float nearest the quotient.Verification
cargo test --release --locked -p larp-shader: 6 passed (5 new), run on an RX 7900 XT and WARP.cargo test --release --locked -p larp-gpu: 19 passed, 1 ignored (1 new: the marks in the table of strides).8-bit unsigned normalized 0x3 loads as 0x3c40c0c2, want 0x3c40c0c1stored: 0xffffffff, want 0xbeef1234cargo check --release --locked -p larp: no new warnings.Limits
@gamingwithhomie on GitHub · 2026-12-05 23:08 UTC · original
Queued for dedicated review (1,088 lines across shader/view handling - too large to fast-merge with the v1.1.4 batch). It touches heap-picked view semantics that interact with the AMD wide-heap work (#183/#227), so it will be reviewed together with those. Not lost - next review round.
@christopear on GitHub · 2026-12-06 02:45 UTC · original
NVIDIA follow-up on the d16 test
I reproduced a distinction between the stored bytes and the immediate raw read on upstream main
459db13. RTX 3090, NVIDIA 595.99.02, Proton Experimental, Windows MSVC release tests. The original PR called out missing NVIDIA coverage.I cross-built the test and ran the executable under Proton. The unchanged test failed on three fresh runs. The typed load cases passed. For each store, the raw load in the same dispatch returned zero. The two adapter labels resolve to the same NVIDIA device on this setup, so this is one hardware result.
I repeated two controls twice each:
beef1234 80017fff. FLOAT gave40003c00 3555c200.body.push(0xbf8a0000);betweenbody.extend(access)andbody.extend(out)in the synthetic program. With this barrier the original assertion passed.An earlier instrumented run on a custom build prefilled the destination with distinct markers. The immediate reads returned those previous markers. This points to visibility between the two views on this stack. It doesn't establish which layer is responsible or a gameplay regression.
I'd keep a separate assertion on the final stored bits so a visibility failure is distinguishable from conversion damage. A native Windows NVIDIA run of the unchanged test would help narrow this down. I would keep the barrier experiment confined to the test.
Diagnostic readback patch against
459db13, retaining the failing assertion