Skip to content

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

Closed
GamingRipperDoc wants to merge 1 commit into
fxceless:mainfrom
GamingRipperDoc:fix/typed-buffer-bits
Closed

GamingRipperDoc wants to merge 1 commit into
fxceless:mainfrom
GamingRipperDoc:fix/typed-buffer-bits

Conversation

@GamingRipperDoc

@GamingRipperDoc GamingRipperDoc commented Nov 25, 2026 •

Copy link
Copy Markdown

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

@avt0m4t48

Copy link
Copy Markdown

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.

@AaronMacArthur

Copy link
Copy Markdown

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

triippywhale pushed a commit to triippywhale/victory-fork that referenced this pull request Nov 25, 2026
Prepared with the help of Codex 6.2 Astra Max.

(cherry picked from commit 9576cc2)

fxceless#662. Conflict only in the tests: its test sits beside
fxceless#684's in descriptor/host.rs.
@tippythetaidum

Copy link
Copy Markdown

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).

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 <noreply@anthropic.com>
fxceless added a commit that referenced this pull request Nov 26, 2026
…e boat); legacy multiply-add as RDNA 2 runs it; 32-bit integer typed views move bits; removal and world-frame instruments; placed-slot census; skin-bake sources and reaper off by default

- At a device removal: the sixteen seconds before it, one row a second, and the
  pipelines first drawn with lately; the PC by the minute.
- Host objects let go can be dropped by a thread of their own (VICTORY_REAPER,
  off); the frame log counts the world's frames apart.
- Legacy multiply-add as RDNA 2 runs it: fused, sources flushed, zero-factor
  rule (pull request #1026).
- Typed buffer views of 32-bit integer formats are made in the float format of
  the same width (pull request #684).
- Placed texture slots counted by what they show every 5 s; textures with levels
  on demand that show no level; VICTORY_TILES_SMALL_WHEN_FULL_MB and
  VICTORY_RETIRE_LEAN (both off).
- Skin-bake draws' own textures: VICTORY_BAKE_SOURCES=count|1 (off; pull
  request #1264, hand-ported onto the texture worker).
- README: status and frame rate as measured.
KomanderDG88 added a commit to KomanderDG88/VIniVIdiVIci that referenced this pull request Nov 26, 2026
What comes from upstream (previous merge base 988aa41):
- VICTORY_HEAP_WORKER=1 (off): textures picked by index uploaded by a
  thread of their own (fork pull request fxceless#1007); needs VICTORY_LATE_WAIT
  (stage > 0, which the relay sets by default).
- VICTORY_TABLE_STAGES (off): a draw's stages share the tables they make
  afresh.
- VICTORY_HEAP_LOCKS (off): made slots found without the slots' lock
  (atomic made_now), kept resources in 64 locks.
- VICTORY_BAKE_SOURCES=count|1 (off): skin-bake draws' own textures
  (fxceless#1264 hand-ported onto the texture worker).
- VICTORY_REAPER (off): host objects let go dropped by a thread of their own.
- VICTORY_TILES_SMALL_WHEN_FULL_MB and VICTORY_RETIRE_LEAN (both off).
- Legacy multiply-add as RDNA 2 runs it (pull request fxceless#1026).
- Typed views of 32-bit integer formats made in the float format of the
  same width (pull request fxceless#684).
- Remapping time split in the frame log (unmap, map, commit, our notes).
- The corner box shows the machine's load beside the frame rate
  (VICTORY_FPS_COUNTER=fps: the rate alone; =0: off).
- A report at a device removal; placed-slot census; constant buffer view
  of no bytes stays one (fxceless#1260, one copy kept); diagnostics runs 301-309.

Conflicts:
- README.md: ours kept as is; upstream's added as README.upstream.md.
  .github/workflows/ci.yml unchanged from ours.
- crates/victory-gpu/src/descriptor/host.rs: both. Our SlotSet and slot
  flags beside upstream's KEPT_PIECES/heap_locks(); HostHeap::new takes
  the 64 kept pieces and kept_one, sized count + extra, with next/free
  sized by our per-heap dynamic count (extra), not DYNAMIC. The lock-free
  made_now lookup goes in mirror_inner, before the records' lock (our
  mirror_with_made is called with the lock held), returning (view, None);
  made_now stores added to our keep-views return and after our make/keep
  branches.
- crates/victory-gpu/src/draw.rs: upstream's bake-sources/worker pass
  setup, with our TEXTURE_SHORT short_room/since_short in front of it;
  our ShortOfRoom guard kept before upstream's List/Ahead view lookup.
- crates/victory-hle/src/modules/xmem.rs: our title_memory_view call
  (section.handle) plus upstream's RemapNotesUs timing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lynkes pushed a commit to Lynkes/victory-fork that referenced this pull request Nov 26, 2026
Upstream since 9c184b3: VICTORY_SETTLE_ROOM, VICTORY_PARALLEL_REFRESH,
VICTORY_DISPATCH_SPREAD, the lookup cache's race fix (fxceless#1245), dynamic
slots found across the search start, legacy multiply-add as RDNA 2 runs
it (fxceless#1026), 32-bit integer typed views (fxceless#684), BC7 rotation, the corner
box's load figures, VICTORY_HEAP_LOCKS / TABLE_STAGES / LIST_REUSE /
HEAP_PASS_MARKED / CARD_SYNC_BATCH (off), ABSENT_ONCE and LIGHT_REFRESH
(off), and its instruments.

Resolutions:
- watch.rs: upstream's file with fxceless#1067's BlockRuns kept (guard walk over
  the clean set's gaps, protected runs given back in one call) and
  upstream's noted-absent logic inside that walk; PUBLISHED bits cleared
  run by run. The local parking (VICTORY_VIEW_PARK, off) is dropped for
  upstream's ABSENT_ONCE / ABSENT_MS=told, which does the same.
- descriptor/host.rs: one lock-free array (made_fast, fxceless#1117's path, on
  whatever the switch); upstream's made_now writes go to it, including
  the kept-view store; VICTORY_HEAP_LOCKS keeps its split keep locks.
- indirect.rs: a record that can be spread across z is (upstream); one
  that cannot keeps the AMD wide x (VICTORY_INDIRECT_WIDE).
- host.rs: a closed gather still goes to run slots (fxceless#1171); a record
  refused by VICTORY_GATHER_BY_COPY gets a pass of its own.
- shadow.rs: fxceless#1245's order on our RwLock tables (fxceless#1068).
- xmem.rs: remap timing on our persistent/temporary views (fxceless#872) and the
  skipped recommit (fxceless#1103).
- policy: host.rs may be 640 KiB, as lower.rs (local).
@GamingRipperDoc

Copy link
Copy Markdown
Author

Closing this: f6a09d3 took the change into main by hand ("Typed buffer views of 32-bit integer formats are made in the float format of the same width (pull request #684)"), test included, and #927 covers the 16-bit case. Nothing here is still needed, and the branch now conflicts with main.

Thanks @AaronMacArthur for the RTX 4080 SUPER check and @tippythetaidum for the pointer to #927.

No game data in this comment.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants