fix: read and write typed buffer views of integer formats as integers #333

Manually merged
github merged 2 commits from github-bot/gh-333 into main 2026-11-26 11:03:09 +00:00 AGit
Owner

@⁠Skyfrye on GitHub · 2026-11-26 03:59 UTC · original
Skyfrye:nep/face-typed-uint → main · +532 −136 · 8 files · 3 commits · merged 2026-11-26 10:53 UTC

Change

The translator lowered every typed buffer load and store (buffer_load_format_*, buffer_store_format_*, _d16_ included) through TypedBuffer<float4> with bufferLoad.f32 / bufferStore.f32, and for _d16_ converted with legacyF32ToF16 / legacyF16ToF32. GTA VI's facial animation graph (compute_graph_ops:*, then ped_standard_head_cs:*) keeps its tensors in typed buffer views of integer formats (R16G16B16A16_UINT): CS_AddOperation (#13c8daa0bad76f2a), for one, reads such a view with d16 loads and stores around f16 arithmetic. Through a float view and legacyF32ToF16, those loads gave 0 and the stores wrote garbage, so the graph that moves the faces computed nothing.

Now the format of a typed buffer view is known to the shader:

  • victory-gpu: the view heap's strides table carries two flags in its high bits for typed buffer views, SLOT_TYPED_UINT (bit 31) and SLOT_TYPED_SINT (bit 30) (descriptor/host.rs, view_stride, also for dynamic slots: make_at, make_null, raw_at); the table is bound to a new root view SLOT_TYPED (252) without the heap pass's scan (draw.rs heap_typed_table); every reader of the strides table masks the stride with SLOT_STRIDE_MASK.
  • victory-shader (emit/lower.rs): a typed load or store reads SLOT_TYPED[heap_index] and takes TypedBuffer<uint4> (bufferLoad.i32 / bufferStore.i32) for UINT views, TypedBuffer<int4> for SINT views, with d16 halves packed and unpacked as bits; float, UNORM and SNORM views keep the path they had.

Two changes on top of the first version of this work (found in review):

  • a d16 store to a SINT view now sign-extends each half (Shl 16 then AShr 16 for the low one, AShr 16 for the high one); zero-extended, -1 was 65,535, which the typed store clamps to 32,767;
  • a draw or dispatch whose shader reads SLOT_TYPED with no view heap set is dropped, as one that reads title memory by address without one is (State::bind); it ran with the root view unset before.

Linked issue: none.

Verification

Windows 11 26300, Rust 1.98.1 (MSVC), RTX 5080, on upstream main at c4c93bd, from third_party/victory:

cargo build --locked --release -p victory                      -> Finished, no new warning
VICTORY_WARP=1 cargo test --locked -p victory-shader --lib     -> 238 passed, 5 failed, 2 ignored
VICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --lib  -> 184 passed, 3 failed, 3 ignored
cargo xtask policy                                             -> asset policy: 199 files ok

The failures are those of main without this change, on the same adapter: 5 in victory-shader on WARP (ds_min_max_f32_order_floats_and_return_the_old_value, lds_subtractions_get_a_pipeline_and_stay_atomic, v_permlane16_and_x16_read_the_lanes_their_selectors_pick, whole_wave_f64_sum_and_cvt_f32_f64, a_lane_mask_joined_with_a_number_is_read_as_the_number_it_is) and the 3 known in victory-gpu (spans_say_the_next_start_and_the_lowest_level_viewed, warp_card_fetch_copies_flagged_pieces_to_their_slots, warp_card_patch_writes_the_masked_bytes_and_no_others).

New tests: descriptor::host::tests::typed_integer_buffer_views_carry_their_format_flag_in_the_strides_table and emit::descriptor_tests::typed_d16_buffer_load_and_store_use_slot_typed_and_validate (validated with dxil.dll); both fail without the change (the flags and the root view do not exist).

Translation of my copy's shaders.rpf on the CPU (victory translate --list --validate, before and after, also with VICTORY_HOST_MAX_WAVE=32): identical summaries, 0 of 26,503 outcome lines differ, all 73 programs of the face pipeline validate before and after (the change is in the code they emit, not in whether they translate).

In the world (launcher fast set; with VICTORY_INDIRECT_RAW=3, which on main clamps every indirect record): 3 runs of 300 s, no exception, no device lost, no draw dropped for want of SLOT_TYPED. The first run made 2,646 pipelines again (the root signatures of programs that use typed buffers changed) and ran at 5 fps; the next two at 10.5 fps median, against 10.4 fps for main at c4c93bd in the same run order (GPU 45 % against 46 % busy): no cost.

In the world, diagnostics builds of main (c4c93bd) and of this change, 600 s each, buffers dumped at 14 frames from the world's first frame on (a diagnostics-only dump patch of my own, not part of this PR):

  • The face graph's tensor that CS_GatherOperation writes (1,064,960 bytes, read by CS_BlendshapeTranslationsHSSGraphOutputExtract): on main all zeros in all 93 dumps; with this change 78,000 to 94,000 of its 266,240 words are non-zero, and 8.5 to 31 % of it changes between dumped frames.
  • The blendshape output that CS_PedStandardSkinning_11 reads: on main 97 to 100 % of the written words are the "no displacement" value and 0 of 20,048 change between frames; with this change 2,316 to 2,319 of 5,121 words of one region change from frame to frame.
  • The picture, the same shot of the opening cutscene: with this change a natural face (lips closed, a slight smile); on main the bind pose, eyes rolled up and the mouth smeared. (Screenshots kept locally, not attached: game imagery.)
  • No device lost, no panic or error, and no draw dropped for want of SLOT_TYPED in either run.

What this does not show: that the values equal the console's.

Oracle and test data

No game file in the tests. Program names and hashes come from the translator's listing of my copy's archive and from a frame capture of my own run; no game code, disassembly or address is in this PR.

Checklist

  • The PR covers a single reviewable behaviour (typed buffer views of integer formats are read and written as integers).
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above (the picture check is pending, said above).
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (Nothing unimplemented here.)
  • README: not touched.
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: program names, hashes and the formats of their views; no code.
  • Code taken from another project: none.

AI assistance: Google Antigravity (model gemini-4-neon-medium) found the root cause and wrote the change and its two tests. Claude Opus 5.5 (a subagent) reviewed it and ran the tests and the translation comparison; Claude Opus 5.5 (coordinating) fixed the signed d16 store and the unbound root view, ran the game, and wrote this description.

🤖 Generated with Claude Code

**@⁠Skyfrye** on GitHub · 2026-11-26 03:59 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/333) `Skyfrye:nep/face-typed-uint` → `main` · +532 −136 · 8 files · 3 commits · merged 2026-11-26 10:53 UTC ## Change The translator lowered every typed buffer load and store (`buffer_load_format_*`, `buffer_store_format_*`, `_d16_` included) through `TypedBuffer<float4>` with `bufferLoad.f32` / `bufferStore.f32`, and for `_d16_` converted with `legacyF32ToF16` / `legacyF16ToF32`. GTA VI's facial animation graph (`compute_graph_ops:*`, then `ped_standard_head_cs:*`) keeps its tensors in typed buffer views of integer formats (`R16G16B16A16_UINT`): `CS_AddOperation` (#13c8daa0bad76f2a), for one, reads such a view with d16 loads and stores around f16 arithmetic. Through a float view and `legacyF32ToF16`, those loads gave 0 and the stores wrote garbage, so the graph that moves the faces computed nothing. Now the format of a typed buffer view is known to the shader: - `victory-gpu`: the view heap's strides table carries two flags in its high bits for typed buffer views, `SLOT_TYPED_UINT` (bit 31) and `SLOT_TYPED_SINT` (bit 30) (`descriptor/host.rs`, `view_stride`, also for dynamic slots: `make_at`, `make_null`, `raw_at`); the table is bound to a new root view `SLOT_TYPED` (252) without the heap pass's scan (`draw.rs` `heap_typed_table`); every reader of the strides table masks the stride with `SLOT_STRIDE_MASK`. - `victory-shader` (`emit/lower.rs`): a typed load or store reads `SLOT_TYPED[heap_index]` and takes `TypedBuffer<uint4>` (`bufferLoad.i32` / `bufferStore.i32`) for UINT views, `TypedBuffer<int4>` for SINT views, with d16 halves packed and unpacked as bits; float, UNORM and SNORM views keep the path they had. Two changes on top of the first version of this work (found in review): - a d16 store to a SINT view now sign-extends each half (`Shl` 16 then `AShr` 16 for the low one, `AShr` 16 for the high one); zero-extended, -1 was 65,535, which the typed store clamps to 32,767; - a draw or dispatch whose shader reads `SLOT_TYPED` with no view heap set is dropped, as one that reads title memory by address without one is (`State::bind`); it ran with the root view unset before. Linked issue: none. ## Verification Windows 11 26300, Rust 1.98.1 (MSVC), RTX 5080, on upstream `main` at `c4c93bd`, from `third_party/victory`: ``` cargo build --locked --release -p victory -> Finished, no new warning VICTORY_WARP=1 cargo test --locked -p victory-shader --lib -> 238 passed, 5 failed, 2 ignored VICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --lib -> 184 passed, 3 failed, 3 ignored cargo xtask policy -> asset policy: 199 files ok ``` The failures are those of `main` without this change, on the same adapter: 5 in `victory-shader` on WARP (`ds_min_max_f32_order_floats_and_return_the_old_value`, `lds_subtractions_get_a_pipeline_and_stay_atomic`, `v_permlane16_and_x16_read_the_lanes_their_selectors_pick`, `whole_wave_f64_sum_and_cvt_f32_f64`, `a_lane_mask_joined_with_a_number_is_read_as_the_number_it_is`) and the 3 known in `victory-gpu` (`spans_say_the_next_start_and_the_lowest_level_viewed`, `warp_card_fetch_copies_flagged_pieces_to_their_slots`, `warp_card_patch_writes_the_masked_bytes_and_no_others`). New tests: `descriptor::host::tests::typed_integer_buffer_views_carry_their_format_flag_in_the_strides_table` and `emit::descriptor_tests::typed_d16_buffer_load_and_store_use_slot_typed_and_validate` (validated with `dxil.dll`); both fail without the change (the flags and the root view do not exist). Translation of my copy's `shaders.rpf` on the CPU (`victory translate --list --validate`, before and after, also with `VICTORY_HOST_MAX_WAVE=32`): identical summaries, 0 of 26,503 outcome lines differ, all 73 programs of the face pipeline validate before and after (the change is in the code they emit, not in whether they translate). In the world (launcher fast set; with `VICTORY_INDIRECT_RAW=3`, which on `main` clamps every indirect record): 3 runs of 300 s, no exception, no device lost, no draw dropped for want of `SLOT_TYPED`. The first run made 2,646 pipelines again (the root signatures of programs that use typed buffers changed) and ran at 5 fps; the next two at 10.5 fps median, against 10.4 fps for `main` at `c4c93bd` in the same run order (GPU 45 % against 46 % busy): no cost. In the world, diagnostics builds of `main` (`c4c93bd`) and of this change, 600 s each, buffers dumped at 14 frames from the world's first frame on (a diagnostics-only dump patch of my own, not part of this PR): - The face graph's tensor that `CS_GatherOperation` writes (1,064,960 bytes, read by `CS_BlendshapeTranslationsHSSGraphOutputExtract`): on `main` all zeros in all 93 dumps; with this change 78,000 to 94,000 of its 266,240 words are non-zero, and 8.5 to 31 % of it changes between dumped frames. - The blendshape output that `CS_PedStandardSkinning_11` reads: on `main` 97 to 100 % of the written words are the "no displacement" value and 0 of 20,048 change between frames; with this change 2,316 to 2,319 of 5,121 words of one region change from frame to frame. - The picture, the same shot of the opening cutscene: with this change a natural face (lips closed, a slight smile); on `main` the bind pose, eyes rolled up and the mouth smeared. (Screenshots kept locally, not attached: game imagery.) - No device lost, no panic or error, and no draw dropped for want of `SLOT_TYPED` in either run. What this does not show: that the values equal the console's. ## Oracle and test data No game file in the tests. Program names and hashes come from the translator's listing of my copy's archive and from a frame capture of my own run; no game code, disassembly or address is in this PR. ## Checklist - [x] The PR covers a single reviewable behaviour (typed buffer views of integer formats are read and written as integers). - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above (the picture check is pending, said above). - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (Nothing unimplemented here.) - [x] README: not touched. - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: program names, hashes and the formats of their views; no code. - [x] Code taken from another project: none. AI assistance: Google Antigravity (model `gemini-4-neon-medium`) found the root cause and wrote the change and its two tests. Claude Opus 5.5 (a subagent) reviewed it and ran the tests and the translation comparison; Claude Opus 5.5 (coordinating) fixed the signed d16 store and the unbound root view, ran the game, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The translator lowered every typed buffer load and store through a
float4 view, and d16 ones through legacyF32ToF16/legacyF16ToF32. GTA VI's
facial animation graph keeps its tensors in R16G16B16A16_UINT typed
views: its d16 loads gave 0 and its stores wrote garbage, so the faces
did not move.

The view heap's strides table now carries UINT/SINT flags in its high
bits for typed buffer views, bound as a root view of its own
(SLOT_TYPED), and typed loads and stores pick uint4/int4 views with i32
loads and stores for those, the d16 halves packed and unpacked as bits
(sign-extended for SINT stores). A draw whose shader reads SLOT_TYPED with
no view heap set is dropped.

Found and first written with Google Antigravity (gemini-4-neon-medium);
reviewed, the signed d16 store and the unbound root view fixed with
Claude Code.

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-26 05:43:23 +00:00
github manually merged commit 5c38af5133 into main 2026-11-26 11:03:09 +00:00
Author
Owner

@⁠KainanP on GitHub · 2026-11-26 10:55 UTC · original

Test report for #333 on three adapters.

Merges cleanly onto current main. Setup: current origin/main (afa30ce) merged with this PR, Windows 11, cargo test --locked in third_party/victory. Nothing under third_party/victory changed since c4c93bd, so the main column is c4c93bd's run. Adapters: RTX 4060 Laptop (DXGI 0), Intel UHD 8086:a78b (16-lane waves, no FP64), WARP. The hardware adapter is picked by name through a local, uncommitted test hook and confirmed in its log. For WARP, victory-gpu uses --features diagnostics + VICTORY_D3D12_WARP=1 and victory-shader uses VICTORY_WARP=1. victory-gpu runs with --test-threads=1.

victory-gpu --lib main main + #333
RTX 4060 Laptop 183 passed, main's 3 failed 184 passed, main's 3 failed
Intel UHD 183 passed, main's 3 failed 184 passed, main's 3 failed
WARP 196 passed, main's 3 failed 197 passed, main's 3 failed
victory-shader --lib main main + #333
RTX 4060 Laptop 242 passed 243 passed
Intel UHD 233 passed, 9 failed 234 passed, the same 9 failed
WARP 237 passed, 5 failed 238 passed, the same 5 failed (your list)

"main's 3" = descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed, indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots, indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others. The victory-shader failures on Intel have the same names as on main: FP64, permlane16, LDS float min/max and subtractions, and the four BVH node tests. Both new tests pass on all three adapters. No new failure, no new warning.

Notes from reading the diff:

  • typed_int_flag's DXGI numbers match the enum: UINT 3/7/12/17/25/30/36/42/50/57/62 and SINT 4/8/14/18/32/38/43/52/59/64. R10G10B10A2 has no SINT form, so the SINT list correctly has nothing for it.
  • typed_heap_index repeats handle()'s match arm for arm and skips the handles cache. A helper that returns (index, per_lane) for a Source, used by both, would keep them from drifting. Built sources still get "a typed root view" as before, so nothing that translated before stops translating.
  • Every typed access now loads SLOT_TYPED and branches two ways, even in programs whose views are all float. Your in-world numbers show no cost. If it ever does cost something, the flags could be loaded once per descriptor, keyed like self.strides.
  • make_at, make_null and raw_at now write the strides entry for dynamic slots, which main did not. That also changes what readers of SLOT_STRIDES get for those slots: a real stride where there was a stale or 0 entry before. That looks like an improvement, but it is a second behaviour change, worth a line in the description.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.

**@⁠KainanP** on GitHub · 2026-11-26 10:55 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/333#issuecomment-7190021422) Test report for #333 on three adapters. Merges cleanly onto current main. Setup: current `origin/main` (afa30ce) merged with this PR, Windows 11, `cargo test --locked` in `third_party/victory`. Nothing under `third_party/victory` changed since c4c93bd, so the main column is c4c93bd's run. Adapters: RTX 4060 Laptop (DXGI 0), Intel UHD 8086:a78b (16-lane waves, no FP64), WARP. The hardware adapter is picked by name through a local, uncommitted test hook and confirmed in its log. For WARP, victory-gpu uses `--features diagnostics` + `VICTORY_D3D12_WARP=1` and victory-shader uses `VICTORY_WARP=1`. victory-gpu runs with `--test-threads=1`. | `victory-gpu --lib` | main | main + #333 | |---|---|---| | RTX 4060 Laptop | 183 passed, main's 3 failed | 184 passed, main's 3 failed | | Intel UHD | 183 passed, main's 3 failed | 184 passed, main's 3 failed | | WARP | 196 passed, main's 3 failed | 197 passed, main's 3 failed | | `victory-shader --lib` | main | main + #333 | |---|---|---| | RTX 4060 Laptop | 242 passed | 243 passed | | Intel UHD | 233 passed, 9 failed | 234 passed, the same 9 failed | | WARP | 237 passed, 5 failed | 238 passed, the same 5 failed (your list) | "main's 3" = `descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed`, `indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots`, `indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others`. The victory-shader failures on Intel have the same names as on main: FP64, permlane16, LDS float min/max and subtractions, and the four BVH node tests. Both new tests pass on all three adapters. No new failure, no new warning. Notes from reading the diff: - `typed_int_flag`'s DXGI numbers match the enum: UINT 3/7/12/17/25/30/36/42/50/57/62 and SINT 4/8/14/18/32/38/43/52/59/64. R10G10B10A2 has no SINT form, so the SINT list correctly has nothing for it. - `typed_heap_index` repeats `handle()`'s match arm for arm and skips the `handles` cache. A helper that returns `(index, per_lane)` for a `Source`, used by both, would keep them from drifting. `Built` sources still get `"a typed root view"` as before, so nothing that translated before stops translating. - Every typed access now loads `SLOT_TYPED` and branches two ways, even in programs whose views are all float. Your in-world numbers show no cost. If it ever does cost something, the flags could be loaded once per descriptor, keyed like `self.strides`. - `make_at`, `make_null` and `raw_at` now write the strides entry for dynamic slots, which main did not. That also changes what readers of `SLOT_STRIDES` get for those slots: a real stride where there was a stale or 0 entry before. That looks like an improvement, but it is a second behaviour change, worth a line in the description. _AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this._
This discussion has been locked. Commenting is limited to contributors.
No description provided.