GPU: typed buffer views of 32-bit integer formats move their bits #684

Open
github-bot wants to merge 1 commit from github-bot/gh-684 into main AGit
Owner

@⁠GamingRipperDoc on GitHub · 2026-11-25 04:25 UTC · original
GamingRipperDoc:fix/typed-buffer-bits → main · +52 −0 · 1 files · 1 commits · open

Typed buffer views of 32-bit integer formats: make them in the float format of the same width, so the translated shaders' float loads and stores move the bits unchanged.

Why

The translator declares every typed buffer access as 32-bit float (victory_shader emit/lower.rs annotates typed buffers as 4×f32). The title's descriptors are passed on with their own format, so a buffer the title views as R32_UINT is read and written through a float declaration over an integer view. D3D12 GPU-based validation flags each such dispatch (UAV resource format channel class differs from that expected by shader … Expected: FLOAT/UNORM/SNORM, In Descriptor: UINT). The console moves the bits, so a value stored this way may not come back as the integer the title wrote. The meshlet culling programs, for example, append packed meshlet numbers to an R32_UINT list.

What

One function in crates/victory-gpu/src/descriptor/host.rs, bit_exact_format, maps R32{,G32,G32B32,G32B32A32}_{UINT,SINT} to the _FLOAT format of the same width; every other format is left as it is. buffer_srv and buffer_uav apply it before the element size is worked out (the width is the same, so offsets and counts don't change). It applies to buffer views only, where the format is the view's alone. Textures are untouched. A unit test covers the mapping and checks that element sizes match.

Not covered: narrower integer formats (R16_UINT, R8G8B8A8_UINT, …) have no float format that keeps their bits. Typed texture views can't be changed this way either, since a texture can only be viewed in formats its resource was created to allow. One texture case remains (below). It needs integer declarations in the translator instead.

Tested

Windows 10 22H2 (19045), AMD RX 9070 XT (Adrenalin 32.0.32015.7029), Rust 1.98.1.

  • On this branch (main 310c6eb + this commit): cargo test -p victory-gpu --lib --locked: 118 passed, 1 failed. The new test passed. The failure, pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws, fails the same way on main without this commit, on Windows 10 without the Agility SDK runtime staged. Clippy reports no warnings in the changed lines, and rustfmt finds nothing to change there.
  • Title runs with VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1 on my test stack (this change plus other open PRs and local diagnostics), diag build, fresh cache and data folders, same machine:
before (183 s) with this change (156 s)
UAV format-class warnings 4, in 3 compute programs (fc5e66f8f873d3bb, 1f32b2302bce7ce4, ce684a9201818f3f) 0
SRV format-class warnings 9 6

All the SRV warnings, before and after, come from one program (6c4160eab4a573bb). It reads a Texture2D<float4> that the title views with a UINT format, which is the texture case above, so this change doesn't reach it. Both runs ended on their own while GPU-based validation was on, as other validation runs on this machine did. Neither lost the device.

This doesn't fix the AMD page faults in #3 (the _Prev culling programs fault with or without it).

No game data used.

AI-assisted (Claude Code); I ran the checks above on my machine.

🤖 Generated with Claude Code

**@⁠GamingRipperDoc** on GitHub · 2026-11-25 04:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/684) `GamingRipperDoc:fix/typed-buffer-bits` → `main` · +52 −0 · 1 files · 1 commits · open Typed buffer views of 32-bit integer formats: make them in the float format of the same width, so the translated shaders' float loads and stores move the bits unchanged. ## Why The translator declares every typed buffer access as 32-bit float (`victory_shader` `emit/lower.rs` annotates typed buffers as 4×f32). The title's descriptors are passed on with their own format, so a buffer the title views as `R32_UINT` is read and written through a float declaration over an integer view. D3D12 GPU-based validation flags each such dispatch (`UAV resource format channel class differs from that expected by shader … Expected: FLOAT/UNORM/SNORM, In Descriptor: UINT`). The console moves the bits, so a value stored this way may not come back as the integer the title wrote. The meshlet culling programs, for example, append packed meshlet numbers to an `R32_UINT` list. ## What One function in `crates/victory-gpu/src/descriptor/host.rs`, `bit_exact_format`, maps `R32{,G32,G32B32,G32B32A32}_{UINT,SINT}` to the `_FLOAT` format of the same width; every other format is left as it is. `buffer_srv` and `buffer_uav` apply it before the element size is worked out (the width is the same, so offsets and counts don't change). It applies to buffer views only, where the format is the view's alone. Textures are untouched. A unit test covers the mapping and checks that element sizes match. Not covered: narrower integer formats (`R16_UINT`, `R8G8B8A8_UINT`, …) have no float format that keeps their bits. Typed *texture* views can't be changed this way either, since a texture can only be viewed in formats its resource was created to allow. One texture case remains (below). It needs integer declarations in the translator instead. ## Tested Windows 10 22H2 (19045), AMD RX 9070 XT (Adrenalin 32.0.32015.7029), Rust 1.98.1. - On this branch (`main` `310c6eb` + this commit): `cargo test -p victory-gpu --lib --locked`: 118 passed, 1 failed. The new test passed. The failure, `pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws`, fails the same way on `main` without this commit, on Windows 10 without the Agility SDK runtime staged. Clippy reports no warnings in the changed lines, and rustfmt finds nothing to change there. - Title runs with `VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1` on my test stack (this change plus other open PRs and local diagnostics), diag build, fresh cache and data folders, same machine: | | before (183 s) | with this change (156 s) | |---|---|---| | UAV format-class warnings | 4, in 3 compute programs (`fc5e66f8f873d3bb`, `1f32b2302bce7ce4`, `ce684a9201818f3f`) | **0** | | SRV format-class warnings | 9 | 6 | All the SRV warnings, before and after, come from one program (`6c4160eab4a573bb`). It reads a `Texture2D<float4>` that the title views with a UINT format, which is the texture case above, so this change doesn't reach it. Both runs ended on their own while GPU-based validation was on, as other validation runs on this machine did. Neither lost the device. This doesn't fix the AMD page faults in #3 (the `_Prev` culling programs fault with or without it). No game data used. AI-assisted (Claude Code); I ran the checks above on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Translated shaders declare every typed buffer load and store as 32-bit
float, so a view the title makes in R32_UINT (or another 32-bit integer
format) converted the value on the way: a store of an integer's bits as a
float wrote the integer the float rounds to. Make such views in the float
format of the same width, which moves the bits unchanged and matches what
the shader declares. GPU-based validation's UAV "format channel class"
warnings (four, in three compute programs) are gone with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:48:55 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 05:36 UTC · original

I independently checked the descriptor construction at base 310c6eb6c16822ab95076aad61fce19bba86bb98 and head 3467f1aeb3f4b2f665a46ff6c009237eee9308a5.

  • A CPU-only fixture compiled the SRV/UAV construction functions from each revision and captured the descriptors handed to a mock device. It exercised eight signed/unsigned format pairs (one through four 32-bit channels), both view kinds, and three buffer offsets. The base retained the integer format in all 48 cases. The head passed all 48 with the corresponding float format and identical first element, count, stride, flags, component mapping or counter offset. All 16 float, narrower-format, raw and structured controls passed at both revisions.
  • cargo check -p victory-gpu --tests --target x86_64-pc-windows-msvc --locked --features diagnostics,blake3/pure passed at both revisions from Linux using Rust 1.98.1. Both emitted the existing depth_written warning.

The 96-bit UAV cases in the fixture show what the code submits to the device. Microsoft’s FL 12.0 format table lists typed UAVs as unavailable for all three R32G32B32_{FLOAT,UINT,SINT} formats, so the three-component format was already limited to uses such as SRV loads at the base. Microsoft format table

Windows device execution and bitwise GPU readback remain unverified by this check. It used only synthetic descriptors.

**@⁠avt0m4t48** on GitHub · 2026-11-25 05:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/684#issuecomment-7153960361) I independently checked the descriptor construction at base `310c6eb6c16822ab95076aad61fce19bba86bb98` and head `3467f1aeb3f4b2f665a46ff6c009237eee9308a5`. - A CPU-only fixture compiled the SRV/UAV construction functions from each revision and captured the descriptors handed to a mock device. It exercised eight signed/unsigned format pairs (one through four 32-bit channels), both view kinds, and three buffer offsets. The base retained the integer format in all 48 cases. The head passed all 48 with the corresponding float format and identical first element, count, stride, flags, component mapping or counter offset. All 16 float, narrower-format, raw and structured controls passed at both revisions. - `cargo check -p victory-gpu --tests --target x86_64-pc-windows-msvc --locked --features diagnostics,blake3/pure` passed at both revisions from Linux using Rust 1.98.1. Both emitted the existing `depth_written` warning. The 96-bit UAV cases in the fixture show what the code submits to the device. Microsoft’s FL 12.0 format table lists typed UAVs as unavailable for all three `R32G32B32_{FLOAT,UINT,SINT}` formats, so the three-component format was already limited to uses such as SRV loads at the base. [Microsoft format table](https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/hardware-support-for-direct3d-12-0-formats#dxgi_format_r32g32b32_floatfcs-6) Windows device execution and bitwise GPU readback remain unverified by this check. It used only synthetic descriptors.
github-bot force-pushed github-bot/gh-684 from 3467f1aeb3 to ce1c419402 2026-11-26 06:45:49 +00:00 Compare
Author
Owner

@⁠AaronMacArthur on GitHub · 2026-11-25 08:49 UTC · original

We independently observed the typed-UAV format mismatch on an RTX 4080 SUPER in the Series S opening. In a scoped test of GamingRipperDoc’s change, all three compute outputs originally received R32_UINT. Switching those outputs to R32_FLOAT made the plaster and clothing seams easier to see. The uniform remained largely black and the bunk fabric showed bright speckles.

We adapted commit 3467f1aeb3f4b2f665a46ff6c009237eee9308a5 to a local guarded build. Our version creates a private view for the command list only for these scalar, shadow-backed output buffers. The upstream change also covers shader resource views and additional integer formats. We matched each observed pipeline to its shader’s first-bind record.

Shader hash Output Verified FLOAT view installations, at least
fc5e66f8f873d3bb u3 1,024
1f32b2302bce7ce4 u0 1,024
ce684a9201818f3f u1 512

Both runs used one binary and the same 3,100 starting save and cache files. We took a stationary screenshot 305 frames after the courtyard marker. Across two 64-interval windows per setting, pooled presentation went from 5.608 FPS off to 5.491 FPS on. The enabled run followed the control, so the 2.1% difference is a single-pair result.

After a scripted camera turn, the two indoor frames had different framing. We compared 179,544 screen positions with similar depth and normals. Nonzero base color rose from 38,273 to 41,906 of those positions, or 2.02 percentage points. Some surfaces lost color, and this screen-space comparison cannot identify the same mesh at every pixel. A repeat from an identical indoor camera pose would help establish which materials benefit.

These measurements come from a Codex-assisted local port and test harness. Upstream change

**@⁠AaronMacArthur** on GitHub · 2026-11-25 08:49 UTC · [original](https://github.com/fxceless/victory-fork/pull/684#issuecomment-7157525455) We independently observed the typed-UAV format mismatch on an RTX 4080 SUPER in the Series S opening. In a scoped test of GamingRipperDoc’s change, all three compute outputs originally received `R32_UINT`. Switching those outputs to `R32_FLOAT` made the plaster and clothing seams easier to see. The uniform remained largely black and the bunk fabric showed bright speckles. We adapted commit `3467f1aeb3f4b2f665a46ff6c009237eee9308a5` to a local guarded build. Our version creates a private view for the command list only for these scalar, shadow-backed output buffers. The upstream change also covers shader resource views and additional integer formats. We matched each observed pipeline to its shader’s first-bind record. | Shader hash | Output | Verified FLOAT view installations, at least | | --- | --- | ---: | | `fc5e66f8f873d3bb` | u3 | 1,024 | | `1f32b2302bce7ce4` | u0 | 1,024 | | `ce684a9201818f3f` | u1 | 512 | Both runs used one binary and the same 3,100 starting save and cache files. We took a stationary screenshot 305 frames after the courtyard marker. Across two 64-interval windows per setting, pooled presentation went from 5.608 FPS off to 5.491 FPS on. The enabled run followed the control, so the 2.1% difference is a single-pair result. After a scripted camera turn, the two indoor frames had different framing. We compared 179,544 screen positions with similar depth and normals. Nonzero base color rose from 38,273 to 41,906 of those positions, or 2.02 percentage points. Some surfaces lost color, and this screen-space comparison cannot identify the same mesh at every pixel. A repeat from an identical indoor camera pose would help establish which materials benefit. These measurements come from a Codex-assisted local port and test harness. [Upstream change](https://git.gtahub.st/github/fxceless--victory-fork/pulls/684)
Author
Owner

@⁠tippythetaidum on GitHub · 2026-11-25 13:15 UTC · original

On the 16-bit case this leaves out ("narrower integer formats ... need integer declarations in the translator"): #927 does that for the title's 16-bit accesses. They are buffer_load_format_d16_* and buffer_store_format_d16_*, all in the face network's compute_graph_ops programs, through R16G16B16A16_UINT and R16_UINT buffer views. The translator now moves those 16 bits as unsigned integers, and a 16-bit float or signed view at such a place is shown as its unsigned twin. Through the integer views every value had read as 0, so no character's mouth moved.

The two don't overlap: this changes 32-bit integer buffer views everywhere; #927 only acts at d16 accesses and only on 16-bit formats.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠tippythetaidum** on GitHub · 2026-11-25 13:15 UTC · [original](https://github.com/fxceless/victory-fork/pull/684#issuecomment-7163514048) On the 16-bit case this leaves out ("narrower integer formats ... need integer declarations in the translator"): #927 does that for the title's 16-bit accesses. They are `buffer_load_format_d16_*` and `buffer_store_format_d16_*`, all in the face network's `compute_graph_ops` programs, through `R16G16B16A16_UINT` and `R16_UINT` buffer views. The translator now moves those 16 bits as unsigned integers, and a 16-bit float or signed view at such a place is shown as its unsigned twin. Through the integer views every value had read as 0, so no character's mouth moved. The two don't overlap: this changes 32-bit integer buffer views everywhere; #927 only acts at d16 accesses and only on 16-bit formats. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
The changes on this branch are already on the target branch. This will be an empty commit.
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/684/head:github-bot/gh-684'
git switch 'github-bot/gh-684'

Merge

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