shader: pass the bits of 16-bit typed accesses through integer table views #65

Manually merged
github merged 1 commit from github-bot/gh-65 into gh-pr/65/base 2026-12-06 00:43:36 +00:00 AGit
Owner

@⁠Kal0s-design on GitHub · 2026-12-05 19:54 UTC · original
Kal0s-design:pr/d16-integer-table-views → main · +150 −35 · 7 files · 1 commits · merged 2026-12-05 22:28 UTC

A real translation bug, also present upstream. A d16 load or store (16-bit typed access) through a table view of a UINT or SINT format read and wrote zeros on hosts whose shader compiler doesn't happen to fuse two instructions, which includes WARP and NVIDIA cards.

The translation keeps a float handle for typed buffer views and picks the integer path by the view's format kind, which it reads from the host's table by heap slot (VIEW_INTEGER). It did that only for views a program picks from the heap. For a view in a table it went the float way, where the integer's bits read as a float are a denormal and the f32-to-f16 conversion gives 0. Recent AMD compilers join the float load and the conversion into one d16 load and pass the bits anyway, which is why it looked fine there. The repo's own tests show it. d16_accesses_of_an_integer_table_view_move_integers_on_warp was marked ignored as known to fail, and the hardware variant fails on NVIDIA. A comment in typed_half_tests.rs ties these views to the face network's halves and tables, but I can only show the test results, not an in-game difference.

What changes. The translation now reads the kind of a view in a table the same way, by its heap slot, the table's place plus the entry, exactly as sizes of views in tables are already read. Strides of views in tables still come from their used-resource entries, so only the kind lookup reaches tables. On the GPU side the title's slots already entered the kind together with the stride, but the dynamic slots most tables are made in entered only their size, so size_is now also enters the kind there, with a mirror per slot like the one for sizes so unchanged slots skip the write. Before writing it I checked the mechanism by forcing the integer path for table views, and both integer tests passed on WARP and on NVIDIA.

Two costs to be aware of. A shader with such an access now reads the table of strides, so the host readies the heap's buffer views once per list for it, as it already does for shaders that read the size of a view in a table. And the translation of those shaders changes, so TRANSLATOR_VERSION goes from 19 to 20 and everyone retranslates once. #38 and #78 also changed translations without a bump, so this bump covers those too.

Tests. The typed-half harness now binds the table when a shader reads it, the WARP integer test is no longer ignored, and both integer tests pass on WARP and on one NVIDIA desktop card, where they read 0 before. victory-gpu gets dynamic_slots_enter_their_views_format_kind, which checks that a dynamic slot enters its view's kind and clears it, and that a title slot is left alone. The float-view d16 test still fails on NVIDIA because the card drops the sign of a 16-bit NaN, which is a separate matter. On top of main as of #37, victory-shader and victory-gpu pass apart from the hardware cases explained in #48. Rebased on current main, clippy -D warnings reports nothing in either of the Lint workflow's two runs.

AI-assisted: yes

🤖 Generated with Claude Code

**@⁠Kal0s-design** on GitHub · 2026-12-05 19:54 UTC · [original](https://github.com/VGLALALA/ReVictory-RDNA3/pull/65) `Kal0s-design:pr/d16-integer-table-views` → `main` · +150 −35 · 7 files · 1 commits · merged 2026-12-05 22:28 UTC A real translation bug, also present upstream. A d16 load or store (16-bit typed access) through a table view of a UINT or SINT format read and wrote zeros on hosts whose shader compiler doesn't happen to fuse two instructions, which includes WARP and NVIDIA cards. The translation keeps a float handle for typed buffer views and picks the integer path by the view's format kind, which it reads from the host's table by heap slot (VIEW_INTEGER). It did that only for views a program picks from the heap. For a view in a table it went the float way, where the integer's bits read as a float are a denormal and the f32-to-f16 conversion gives 0. Recent AMD compilers join the float load and the conversion into one d16 load and pass the bits anyway, which is why it looked fine there. The repo's own tests show it. d16_accesses_of_an_integer_table_view_move_integers_on_warp was marked ignored as known to fail, and the hardware variant fails on NVIDIA. A comment in typed_half_tests.rs ties these views to the face network's halves and tables, but I can only show the test results, not an in-game difference. What changes. The translation now reads the kind of a view in a table the same way, by its heap slot, the table's place plus the entry, exactly as sizes of views in tables are already read. Strides of views in tables still come from their used-resource entries, so only the kind lookup reaches tables. On the GPU side the title's slots already entered the kind together with the stride, but the dynamic slots most tables are made in entered only their size, so size_is now also enters the kind there, with a mirror per slot like the one for sizes so unchanged slots skip the write. Before writing it I checked the mechanism by forcing the integer path for table views, and both integer tests passed on WARP and on NVIDIA. Two costs to be aware of. A shader with such an access now reads the table of strides, so the host readies the heap's buffer views once per list for it, as it already does for shaders that read the size of a view in a table. And the translation of those shaders changes, so TRANSLATOR_VERSION goes from 19 to 20 and everyone retranslates once. #38 and #78 also changed translations without a bump, so this bump covers those too. Tests. The typed-half harness now binds the table when a shader reads it, the WARP integer test is no longer ignored, and both integer tests pass on WARP and on one NVIDIA desktop card, where they read 0 before. victory-gpu gets dynamic_slots_enter_their_views_format_kind, which checks that a dynamic slot enters its view's kind and clears it, and that a title slot is left alone. The float-view d16 test still fails on NVIDIA because the card drops the sign of a 16-bit NaN, which is a separate matter. On top of main as of #37, victory-shader and victory-gpu pass apart from the hardware cases explained in #48. Rebased on current main, clippy -D warnings reports nothing in either of the Lint workflow's two runs. AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A d16 load or store through a typed buffer view of a UINT or SINT format
has to move the integer's bits. The translation keeps a float handle and
picks the integer path by the view's format kind, which it read from the
host's table by heap slot (VIEW_INTEGER) only for views a program picks
from the heap. For a view in a table it went the float way: the
integer's bits read as a float are a denormal, and the f32-to-f16
conversion gives 0. Hosts whose compiler joins the load and the
conversion into one d16 load pass the bits anyway, which is why this
went unseen on recent AMD cards. On WARP and on an NVIDIA card those
accesses read and wrote zeros; the existing tests say so, one of them
was marked as known to fail on WARP, and the hardware one failed on
NVIDIA.

The translation now reads the kind of a view in a table the same way,
by its heap slot (the table's place plus the entry, as sizes already
are). Strides of views in tables still come from their used-resource
entries; only the kind lookup reaches tables. On the GPU side the title's
slots already entered the kind with the stride, but the dynamic slots
most tables are made in only entered their size, so size_is now enters
the kind there too (a mirror per slot, as for sizes, so unchanged slots
skip the write).

A shader with such an access now reads the table of strides, so the
host readies the heap's buffer views once per list for it, as it does
for shaders that read the size of a view in a table. The translation of
those shaders changes, so TRANSLATOR_VERSION goes from 19 to 20.

Tests: the typed-half harness binds the table when a shader reads it,
the WARP variant of the integer test is no longer ignored, and both
integer tests pass on WARP and on one NVIDIA desktop card, where they
read 0 before. victory-gpu gets a test that a dynamic slot enters its
view's kind and clears it. The float-view test still differs on NVIDIA
in the sign of a 16-bit NaN, which is a separate matter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 19:56:58 +00:00
github-bot changed target branch from main to gh-pr/65/base 2026-12-05 22:32:31 +00:00
github manually merged commit 0694d7a859 into gh-pr/65/base 2026-12-06 00:43:36 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.