Shaders, GPU: 16-bit buffer accesses through a table's views keep their bits (port of fxceless/victory-fork#927, which makes faces animate there) #578

Open
github-bot wants to merge 6 commits from github-bot/gh-578 into a-publier AGit
Owner

@⁠pr0vId3nce on GitHub · 2026-11-27 12:13 UTC · original
pr0vId3nce:halves-through-tables → a-publier · +1282 −41 · 19 files · 6 commits · open

This ports fxceless/victory-fork#927 by tippythetaidum, in the final form fxceless merged into victory-fork main as 58de9bf4c. The work and the findings are theirs; I brought it to a-publier and checked it on an RTX 4080.

#541 goes at the same gap another way: it makes the run-time integer-view check cover views in tables, and the host writes the view kind for a fresh table's slots. This PR decides per program at translation time and moves the bits as unsigned integers, so it does not depend on a float-typed load passing an integer view's bits, and it also covers plain format loads read as halves. The two merge without conflicts but overlap; whichever goes in first, the other should be rebased onto it.

What was wrong. The title keeps half floats, and 16-bit indices beside them, in buffers it views as R16G16B16A16_UINT and R16_UINT, and moves them with buffer_load_format_d16_* and buffer_store_format_d16_*. On the console each channel's 16 bits go through as they are. a-publier already keeps those bits for a view the program picks from the heap (integer_view, 9a6c829d6), but a view loaded from a fixed place in a descriptor table, which is how the face network reaches its buffers, still went by way of floats (bufferLoad.f32 then legacyF32ToF16, and the reverse for stores). A float access through an integer view is outside what D3D12 defines; on the fork PR author's RTX 5080 every value read came out 0. The GPU network that drives the faces works in such buffers, so its tensors and its output stayed zero and no character's mouth moved. The same symptom is reported on an RX 9070 XT (avatarmanz/VIctory-7900XTX#231) and an RTX 3080 (#346 here).

The fix.

  • victory-shader: a d16 typed buffer access through a descriptor loaded from a fixed place in a table moves each channel's 16 bits as an unsigned integer (bufferLoad.i32 / bufferStore.i32), packing and unpacking the halves as before. HostShader::half_views names those places (root parameter, dword), and the shader cache stores them.
  • A format load that is not d16 but whose every channel is read only as a half (v_cvt_f32_f16, or a v_fma_mix* source with its op_sel_hi bit, through phis) takes the same path (emit/halves.rs).
  • Both only where every access through that place moves halves and the program picks nothing from that table at run time; a whole float read through the same place keeps the float path.
  • The half place is the descriptor the program loads (the traced offset plus the first dword read), not the start of its range.
  • victory-gpu: a table with a 16-bit float or signed buffer view at one of those places is made afresh for the draw with that view in the unsigned format of the same layout (descriptor::host::half_view), and the fresh table reaches the half places past its range's start. The title's own heap slot keeps the title's format for other programs. A view in a format the integers do not carry exactly is logged once.
  • TRANSLATOR_VERSION 2 -> 3 (4 if my exec-entry-skip PR or #479, which also take 3, is merged first), shader cache entry format 2 -> 3.

Left out of 58de9bf4c: the SDWA sign extension (a separate fix), VICTORY_CLAMP_WINDOW, VICTORY_OCCLUSION and the offline tools.

Tests (the PR's, synthetic programs):

  • emit::valu_tests::halves_go_through_a_table_as_they_are_and_name_their_views
  • emit::valu_tests::half_places_are_the_descriptors_the_program_loads
  • emit::valu_tests::a_format_load_read_as_halves_loads_the_integer
  • descriptor::tests::a_fresh_table_holds_the_half_views_past_its_range_starts
  • descriptor::host::tests::only_16_bit_float_and_signed_buffer_views_get_an_unsigned_twin, views_whose_values_the_console_would_convert_are_named

On the RTX 4080: cargo test --release -p victory-shader --lib 306 passed, 0 failed (303 on a-publier); cargo test --release -p victory-gpu --lib 400 passed, 0 failed (396 on a-publier).

In the title's shader pack (fork census): 77 programs name half places, 65 of them the face network's.

Results on an RTX 4080 (NVIDIA, 32-lane waves; Ryzen 9 7900X, 32 GB, Windows 11; diagnostics build, the same checkpoint and scripted input, warm shader cache, Series S, 300 s runs, median of the frame lines from 200 to 295 s):

run 1 run 2
a-publier 226.7 ms 207.5 ms
this PR 195.8 ms 215.5 ms

No crash, the same picture in the scene timed, and the once-logged inexact-format warning did not appear. Frame time is within run-to-run noise. This PR's run 1 was the first with the new translations (they were done before the 200 s window). The camera is behind the player in that scene, so I did not see mouths here; the fork PR's author measured the network's buffers going from all-zero to changing on an RTX 5080.

AMD. Not gated: the old lowering relies on behaviour D3D12 leaves undefined, and the symptom is reported on RDNA 4 too. On every host, the programs that move halves through such views change translation (77 in the title's pack), the translator version bump makes every host translate once more, and a table with a 16-bit float or signed view at a half place is made afresh per draw (none for this title's own views, which are already unsigned). I have no AMD card to try it on.

🤖 Generated with Claude Code

**@⁠pr0vId3nce** on GitHub · 2026-11-27 12:13 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/578) `pr0vId3nce:halves-through-tables` → `a-publier` · +1282 −41 · 19 files · 6 commits · open This ports fxceless/victory-fork#927 by tippythetaidum, in the final form fxceless merged into victory-fork main as 58de9bf4c. The work and the findings are theirs; I brought it to a-publier and checked it on an RTX 4080. #541 goes at the same gap another way: it makes the run-time integer-view check cover views in tables, and the host writes the view kind for a fresh table's slots. This PR decides per program at translation time and moves the bits as unsigned integers, so it does not depend on a float-typed load passing an integer view's bits, and it also covers plain format loads read as halves. The two merge without conflicts but overlap; whichever goes in first, the other should be rebased onto it. **What was wrong.** The title keeps half floats, and 16-bit indices beside them, in buffers it views as `R16G16B16A16_UINT` and `R16_UINT`, and moves them with `buffer_load_format_d16_*` and `buffer_store_format_d16_*`. On the console each channel's 16 bits go through as they are. a-publier already keeps those bits for a view the program picks from the heap (`integer_view`, 9a6c829d6), but a view loaded from a fixed place in a descriptor table, which is how the face network reaches its buffers, still went by way of floats (`bufferLoad.f32` then `legacyF32ToF16`, and the reverse for stores). A float access through an integer view is outside what D3D12 defines; on the fork PR author's RTX 5080 every value read came out 0. The GPU network that drives the faces works in such buffers, so its tensors and its output stayed zero and no character's mouth moved. The same symptom is reported on an RX 9070 XT (avatarmanz/VIctory-7900XTX#231) and an RTX 3080 (#346 here). **The fix.** - victory-shader: a d16 typed buffer access through a descriptor loaded from a fixed place in a table moves each channel's 16 bits as an unsigned integer (`bufferLoad.i32` / `bufferStore.i32`), packing and unpacking the halves as before. `HostShader::half_views` names those places (root parameter, dword), and the shader cache stores them. - A format load that is not d16 but whose every channel is read only as a half (`v_cvt_f32_f16`, or a `v_fma_mix*` source with its `op_sel_hi` bit, through phis) takes the same path (`emit/halves.rs`). - Both only where every access through that place moves halves and the program picks nothing from that table at run time; a whole float read through the same place keeps the float path. - The half place is the descriptor the program loads (the traced offset plus the first dword read), not the start of its range. - victory-gpu: a table with a 16-bit float or signed buffer view at one of those places is made afresh for the draw with that view in the unsigned format of the same layout (`descriptor::host::half_view`), and the fresh table reaches the half places past its range's start. The title's own heap slot keeps the title's format for other programs. A view in a format the integers do not carry exactly is logged once. - `TRANSLATOR_VERSION` 2 -> 3 (4 if my exec-entry-skip PR or #479, which also take 3, is merged first), shader cache entry format 2 -> 3. Left out of 58de9bf4c: the SDWA sign extension (a separate fix), `VICTORY_CLAMP_WINDOW`, `VICTORY_OCCLUSION` and the offline tools. **Tests** (the PR's, synthetic programs): - `emit::valu_tests::halves_go_through_a_table_as_they_are_and_name_their_views` - `emit::valu_tests::half_places_are_the_descriptors_the_program_loads` - `emit::valu_tests::a_format_load_read_as_halves_loads_the_integer` - `descriptor::tests::a_fresh_table_holds_the_half_views_past_its_range_starts` - `descriptor::host::tests::only_16_bit_float_and_signed_buffer_views_get_an_unsigned_twin`, `views_whose_values_the_console_would_convert_are_named` On the RTX 4080: `cargo test --release -p victory-shader --lib` 306 passed, 0 failed (303 on a-publier); `cargo test --release -p victory-gpu --lib` 400 passed, 0 failed (396 on a-publier). In the title's shader pack (fork census): 77 programs name half places, 65 of them the face network's. **Results on an RTX 4080** (NVIDIA, 32-lane waves; Ryzen 9 7900X, 32 GB, Windows 11; diagnostics build, the same checkpoint and scripted input, warm shader cache, Series S, 300 s runs, median of the frame lines from 200 to 295 s): | | run 1 | run 2 | |---|---:|---:| | a-publier | 226.7 ms | 207.5 ms | | this PR | 195.8 ms | 215.5 ms | No crash, the same picture in the scene timed, and the once-logged inexact-format warning did not appear. Frame time is within run-to-run noise. This PR's run 1 was the first with the new translations (they were done before the 200 s window). The camera is behind the player in that scene, so I did not see mouths here; the fork PR's author measured the network's buffers going from all-zero to changing on an RTX 5080. **AMD.** Not gated: the old lowering relies on behaviour D3D12 leaves undefined, and the symptom is reported on RDNA 4 too. On every host, the programs that move halves through such views change translation (77 in the title's pack), the translator version bump makes every host translate once more, and a table with a 16-bit float or signed view at a half place is made afresh per draw (none for this title's own views, which are already unsigned). I have no AMD card to try it on. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The title keeps half floats, and indices beside them, in buffers it views
as R16G16B16A16_UINT and R16_UINT, and its programs move them with
buffer_load_format_d16_* and buffer_store_format_d16_*: on the console
each channel's 16 bits go as they are, whatever kind the view's format
is. The DXIL moved them by way of 32-bit floats (load as float,
legacyF32ToF16; legacyF16ToF32, store as float), which only a float view
carries. Through the integer view every value read came out 0.

The network that drives the faces (some 2,650 compute dispatches a
frame, then the head program that reads its output) works in such buffers: its
24 MB of tensors and its output were all zeros for whole runs, and no
character's mouth moved.

- victory-shader: such an access through a view of a table moves the 16
  bits as unsigned integers (bufferLoad.i32, bufferStore.i32), and
  HostShader::half_views names the table descriptors it is done through.
- victory-gpu: a table with a 16-bit float or signed buffer view at one
  of those places is made afresh for the draw, with that view in the
  unsigned format of the same layout (descriptor::host::half_view). The
  title's own slot keeps the title's format for other programs.

shortcut: through a view of wider, normalised or signed 8-bit channels,
whose values the console converts to and from halves, the integers are
read and written unconverted (logged once, with the format; the title's
are 16-bit unsigned). Views reached another way than through a table
keep the float path.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Original author: tippythetaidum, fxceless/victory-fork#927 (in victory-fork main as 58de9bf4c), commit 5dc9e63f0 (an earlier head of that PR).

(cherry picked from commit 5dc9e63f04cac3e508d8a5e9cb6edd72a23ca175)
Review on fxceless/victory-fork#927 (avt0m4t48): half_views took the
place from used_kind, whose entry gives where a range of descriptors
starts. With one entry for a range from dword 0 and the load at byte
0x20, the place was dword 0 and the host looked at the wrong slot for a
16-bit float view to show as its unsigned twin.

The place is now the load's own (the traced offset in dwords plus the
first dword read), for a descriptor loaded from a fixed place in a table.
A descriptor picked at run time names nothing and keeps the float path:
its slot, and so its format, is known only then.

The title's 65 programs with d16 typed buffer accesses load all 231 of
their descriptors from fixed places, each at the start of its own entry,
so what they name is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Original author: tippythetaidum, fxceless/victory-fork#927 (in victory-fork main as 58de9bf4c), commit befaf3b5a (an earlier head of that PR).

(cherry picked from commit befaf3b5aa91966d2569985eeba808d4d8017026)
Review on fxceless/victory-fork#927 (avt0m4t48): a table made afresh
because of a half view took its span from the used-resource entries'
starts and the slots picked by index. With one entry for a range from
dword 0 and the half view at dword 8, the table took one dynamic slot;
the next allocation got the slot the shader reads that view from.

The table's half places are added to the selected slots, as the slots
picked by index are: the table reaches them and they are made readable
like the others. The title's d16 programs name each of their descriptors
with its own entry, so their tables are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Original author: tippythetaidum, fxceless/victory-fork#927 (in victory-fork main as 58de9bf4c), commit b6bf65167 (an earlier head of that PR).

(cherry picked from commit b6bf65167f4407684bccfe201b30d084102d8862)
The head program reads the face network's output with
buffer_load_format_x (not d16) and uses only the low 16 bits of each
result, as a half (v_fma_mix_f32 with sel_lo): on the console that
view is 16-bit unsigned and the load gives the zero-extended integer.
Lowered as a float load through the title's R16_UINT view it read
garbage once the network's output was no longer all zero (specks on
some faces with this branch).

Such a load now loads the unsigned integer and names its place for the
host, as d16 accesses do, where every access through that place moves
halves (d16, or a format load read only as halves) and the program
picks nothing from that table at run time. A place also read as
numbers keeps the float path. Uses are operand reads: a later write of
the register under EXEC reads the value only to keep it in the lanes
it leaves alone, and a phi carries it on (the head program's loads are
behind a branch).

In the title's shader pack 77 programs name half places: the 65 network
programs, the head program and 11 lighting and water compute programs
that read those views as halves alone. Without the two conditions the
rule named 724, among them hundreds of pixel programs that read one
value of a view as a half and the rest as numbers.

The helpers are in emit/halves.rs, a child module of the emitter like
intersect.rs. Also puts used_kind's doc comment back above it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Original author: tippythetaidum, fxceless/victory-fork#927 (in victory-fork main as 58de9bf4c), commit b9c378134 (an earlier head of that PR).

(cherry picked from commit b9c378134968f93739a9f5864052f293ed67bf4c)
Brings the port of fxceless/victory-fork#927 (tippythetaidum) to its
final form in fxceless/victory-fork main 58de9bf4c ("Mouths move"):

- A d16 typed access moves raw 16 bits only where every access through
  that table place does (`halves_only`): a whole float read through the
  same place would otherwise see the unsigned twin. The two tests are
  the fork's.
- The shader cache's entry format is bumped (FORMAT 3: entries carry
  half_views), and the test-only HostShader initializers name the field.
  Merge fixes in two test modules.

Left out of 58de9bf4c: the SDWA sign extension (a separate problem),
VICTORY_CLAMP_WINDOW, VICTORY_OCCLUSION (off by default there) and the
offline tools.

Original author: tippythetaidum, fxceless/victory-fork#927 (in
victory-fork main as 58de9bf4c).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 12:22:30 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 15:56 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At 1a29b5c: victory-gpu 400 passed, 0 failed, 34 ignored; victory-shader 306 passed, 0 failed, 4 ignored.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 15:56 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/578#issuecomment-7222656984) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `1a29b5c`: `victory-gpu` 400 passed, 0 failed, 34 ignored; `victory-shader` 306 passed, 0 failed, 4 ignored. AI-assisted (Claude Code); no game data.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/578/head:github-bot/gh-578'
git switch 'github-bot/gh-578'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-578'
git switch 'github-bot/gh-578'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-578'
git switch 'github-bot/gh-578'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-578'
git switch 'a-publier'
git merge --squash 'github-bot/gh-578'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-578'
git switch 'a-publier'
git merge 'github-bot/gh-578'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.