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

Open
github-bot wants to merge 2 commits from github-bot/gh-333 into main AGit
Owner

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

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 · 2 commits · open ## 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
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/333/head:github-bot/gh-333'
git switch 'github-bot/gh-333'

Merge

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