formats, texture: BC7 dictionary indices as BCPack.dll reads them; GPU copies reach views placed before them #67

Closed
github-bot wants to merge 2 commits from github-bot/gh-67 into main AGit
Owner

@⁠psychonaut0 on GitHub · 2026-12-01 12:35 UTC · original
psychonaut0:bc7-dictionary-placed-copied → main · +746 −7 · 5 files · 2 commits · closed without merging

Two fixes from our fork (a Strix Halo / Radeon 8060S tree, Proton Experimental, RADV 26.3.1) that this tree lacks. One commit each, so either can be taken alone.

1. BC7 dictionary indices as BCPack.dll reads them (VICTORY_BC7_DICTIONARY, on by default)

Cause

Each BC7 entry of the BCPack table file has two width bytes, then 32 words. BCPack.dll takes all 32 as the entry's indices, pixel 0 first. In entries 1–254 that first word repeats the widths, and Tables::parse took it for padding: it skipped it and read 31. So every index of those entries landed one pixel early, and so did every block predicted from them, directly or through the history. Entry 0 was already read with all 32.

Checked against BCPack.dll by trustno1-coder/VIctory-NVIDIA f9de61c5 and ubiquitarianism/leonida b589e0fe: 2,101,646 of the title's 2,866,176 BC7 blocks differed before, none after.

Change

crates/victory-formats/src/bcpack.rs: every entry reads 32 words. VICTORY_BC7_DICTIONARY=0 restores the old reading.

bc7_dictionary_indices_line_up asserted that a set with 0 index bits holds nothing. With 32 words, 233 of 254 entries put their last word in set 1's slot 0. No entry gives set 1 any bits, and that slot never reaches a block: the decoder skips 0-bit sets, and add_index drops 0-bit reference indices. The test now asserts that. Its anchor check is unchanged and passes.

2. A GPU copy into a texture also reaches the views placed over it before (VICTORY_PLACED_COPIED=1, off by default)

Cause

The decoration bake copies its result (make-up, stubble, tattoos, prints and numbers on clothes) into a block-compressed texture. The title then samples it through a view placed at the same address, often in another block format, e.g. a BC3 texture written and a BC7 view sampled. On the console those are the same bytes. Here the view gets its own texture (resource::texture_at), filled from title memory, which the host's copy never reaches. Where the bake's result belongs, the view shows zeros, or whatever was in that memory before, for as long as it lives. alias_of does not cover this case: it pairs views only with render/UAV targets of the same levels.

Change

With the switch:

  • Each CopyTextureRegion / CopyResource into a title texture is repeated, through a buffer, into the textures of the views placed over it that are laid out alike (resource::placed_twins: same dimension, size and layers, blocks of the same size, no more levels).
  • Such a view's texture then counts as written by the host. No upload from title memory goes over it, and its slots are made again after the copy.
  • Without the switch, placed_twins is empty and nothing changes.

Not covered:

  • A view placed after the last copy (VIctory-NVIDIA's seed_later).
  • The upload race that #47 closes for the written texture itself. If #47 lands, twin_copy should note its writes the same way (note_gpu_written).

Testing

  • victory-formats (native): 52 passed, 7 ignored, with and without VICTORY_BC7_DICTIONARY=0. New test bc7_dictionary_entries_read_as_bcpack_dll_reads_them parses the shipped table both ways.
  • victory-gpu --lib (diagnostics, Proton Experimental, Radeon 8060S): 309 passed, with VICTORY_PLACED_COPIED off and on. The same 11 failures, and the crash in descriptor::tests::views_die_with_their_resource, happen on 37bb30f unchanged.
  • New card test placed_copied_card (ignored, needs a GPU): a one-level BC7 sRGB view placed over a two-level BC7 texture before a title list copies into it. Read back, it prints placed copied: the view placed before the copy holds its blocks with the switch, not without.
  • Not run in-game on this tree. On our fork, one session's log showed 128 copies going into views placed before the copy, mostly 1024x1024 BC3 sRGB textures of 11 levels under 9-level views. The clothing prints, jersey numbers and lettering that had been missing in every earlier run came back in that run. Two other new switches came in with it (bake sources brought up to date before a bake, raw views on any dword), so this switch's share is not isolated. That is why it is off by default here.

Origin

  1. trustno1-coder/VIctory-NVIDIA f9de61c5, ubiquitarianism/leonida b589e0fe, as carried by BrayanOfficiel/VIctory-linux 8a79f3b5.
  2. A hand port of trustno1-coder/VIctory-NVIDIA e530c003 (the placed views' half; aventureroestelar-source) and of 523485ba's concern (the twin's own level, mikey), by way of our fork. There the copy goes straight into the view's texture; here it goes through a buffer, as alias does.

A third fix of ours, mesh records (n, 0, 0) run as (n, 1, 1) (VICTORY_MESH_ONE_DIM), is already open here as #45, so it is not repeated.

**@⁠psychonaut0** on GitHub · 2026-12-01 12:35 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/67) `psychonaut0:bc7-dictionary-placed-copied` → `main` · +746 −7 · 5 files · 2 commits · closed without merging Two fixes from our fork (a Strix Halo / Radeon 8060S tree, Proton Experimental, RADV 26.3.1) that this tree lacks. One commit each, so either can be taken alone. ## 1. BC7 dictionary indices as BCPack.dll reads them (`VICTORY_BC7_DICTIONARY`, on by default) ### Cause Each BC7 entry of the BCPack table file has two width bytes, then 32 words. BCPack.dll takes all 32 as the entry's indices, pixel 0 first. In entries 1–254 that first word repeats the widths, and `Tables::parse` took it for padding: it skipped it and read 31. So every index of those entries landed one pixel early, and so did every block predicted from them, directly or through the history. Entry 0 was already read with all 32. Checked against BCPack.dll by trustno1-coder/VIctory-NVIDIA f9de61c5 and ubiquitarianism/leonida b589e0fe: 2,101,646 of the title's 2,866,176 BC7 blocks differed before, none after. ### Change `crates/victory-formats/src/bcpack.rs`: every entry reads 32 words. `VICTORY_BC7_DICTIONARY=0` restores the old reading. `bc7_dictionary_indices_line_up` asserted that a set with 0 index bits holds nothing. With 32 words, 233 of 254 entries put their last word in set 1's slot 0. No entry gives set 1 any bits, and that slot never reaches a block: the decoder skips 0-bit sets, and `add_index` drops 0-bit reference indices. The test now asserts that. Its anchor check is unchanged and passes. ## 2. A GPU copy into a texture also reaches the views placed over it before (`VICTORY_PLACED_COPIED=1`, off by default) ### Cause The decoration bake copies its result (make-up, stubble, tattoos, prints and numbers on clothes) into a block-compressed texture. The title then samples it through a view placed at the same address, often in another block format, e.g. a BC3 texture written and a BC7 view sampled. On the console those are the same bytes. Here the view gets its own texture (`resource::texture_at`), filled from title memory, which the host's copy never reaches. Where the bake's result belongs, the view shows zeros, or whatever was in that memory before, for as long as it lives. `alias_of` does not cover this case: it pairs views only with render/UAV targets of the same levels. ### Change With the switch: - Each `CopyTextureRegion` / `CopyResource` into a title texture is repeated, through a buffer, into the textures of the views placed over it that are laid out alike (`resource::placed_twins`: same dimension, size and layers, blocks of the same size, no more levels). - Such a view's texture then counts as written by the host. No upload from title memory goes over it, and its slots are made again after the copy. - Without the switch, `placed_twins` is empty and nothing changes. Not covered: - A view placed after the last copy (VIctory-NVIDIA's `seed_later`). - The upload race that #47 closes for the written texture itself. If #47 lands, `twin_copy` should note its writes the same way (`note_gpu_written`). ## Testing - victory-formats (native): 52 passed, 7 ignored, with and without `VICTORY_BC7_DICTIONARY=0`. New test `bc7_dictionary_entries_read_as_bcpack_dll_reads_them` parses the shipped table both ways. - victory-gpu `--lib` (diagnostics, Proton Experimental, Radeon 8060S): 309 passed, with `VICTORY_PLACED_COPIED` off and on. The same 11 failures, and the crash in `descriptor::tests::views_die_with_their_resource`, happen on `37bb30f` unchanged. - New card test `placed_copied_card` (ignored, needs a GPU): a one-level BC7 sRGB view placed over a two-level BC7 texture before a title list copies into it. Read back, it prints `placed copied: the view placed before the copy holds its blocks with the switch, not without`. - **Not run in-game on this tree.** On our fork, one session's log showed 128 copies going into views placed before the copy, mostly 1024x1024 BC3 sRGB textures of 11 levels under 9-level views. The clothing prints, jersey numbers and lettering that had been missing in every earlier run came back in that run. Two other new switches came in with it (bake sources brought up to date before a bake, raw views on any dword), so this switch's share is not isolated. That is why it is off by default here. ## Origin 1. trustno1-coder/VIctory-NVIDIA f9de61c5, ubiquitarianism/leonida b589e0fe, as carried by BrayanOfficiel/VIctory-linux 8a79f3b5. 2. A hand port of trustno1-coder/VIctory-NVIDIA e530c003 (the placed views' half; aventureroestelar-source) and of 523485ba's concern (the twin's own level, mikey), by way of our fork. There the copy goes straight into the view's texture; here it goes through a buffer, as `alias` does. A third fix of ours, mesh records `(n, 0, 0)` run as `(n, 1, 1)` (`VICTORY_MESH_ONE_DIM`), is already open here as #45, so it is not repeated.
Each BC7 entry of the BCPack table file has two width bytes, then 32
words. BCPack.dll takes all 32 as the entry's indices, pixel 0 first. In
entries 1-254 that first word holds the widths again, and parse() took it
for a repeat: it skipped the word and read 31, so every index of those
entries landed one pixel early, and so did every block predicted from
them, directly or through the history. Entry 0, whose first word is not
the widths, was already read with all 32. Checked against BCPack.dll by
trustno1-coder/VIctory-NVIDIA f9de61c5 and ubiquitarianism/leonida
b589e0fe: 2,101,646 of the title's 2,866,176 BC7 blocks differed before,
none after. Every BC7 texture DirectStorage serves goes through this.

parse() now reads 32 words for every entry. On by default;
VICTORY_BC7_DICTIONARY=0 restores the old reading (read once).

Tests (victory-formats, native x86_64-unknown-linux-gnu): 52 passed,
7 ignored, with and without VICTORY_BC7_DICTIONARY=0. New
bc7_dictionary_entries_read_as_bcpack_dll_reads_them parses the shipped
table both ways: entry 0 unchanged (2, 1, 0, ...); in every other entry
pixel 0 holds the widths word, the old indices sit one pixel later, the
last of them in set 1's slot 0; endpoints and control words unchanged.

bc7_dictionary_indices_line_up asserted that a set with 0 index bits holds
nothing. With 32 words, 233 of the 254 entries put their last word in set
1's slot 0, and no entry gives set 1 any bits. That slot never reaches a
block: the decoder skips a set with 0 bits, and add_index drops a
reference index of 0 bits. The test now asserts that instead (slot 0
dropped by add_index, slots 1-15 empty); its anchor check is unchanged
and passes (pixel 0 is the widths, 3 or 4, inside the anchor range).
Not checked here against BCPack.dll: reference_chunks (ignored) does that
with VICTORY_BCPACK_TABLES and VICTORY_BCPACK_CASES.

Ported from BrayanOfficiel/VIctory-linux 8a79f3b5 (where the new reading
is the default and VICTORY_BC7_SKIP_WIDTHS=1 the old one), after
trustno1-coder/VIctory-NVIDIA f9de61c5.

Co-authored-by: BrayanOfficiel <[email protected]>
Co-Authored-By: Claude <[email protected]>
The title's decoration bake copies its result (a character's make-up,
stubble, tattoos, the prints and numbers on its clothes) into a
block-compressed texture and samples it through a view placed at the same
address, often in another block format: a BC3 texture written, a BC7 view
sampled. On the console those are the same bytes. Here the view gets a
texture of its own (resource::texture_at), filled from title memory, which
the host's copy never reaches: zeros, or whatever lay in that memory
before, where the bake's result belongs, for as long as the view lives.
alias_of does not cover it: it pairs views only with textures the host
renders to or writes with shaders, of the same levels.

With VICTORY_PLACED_COPIED=1:
- each copy into a title texture (CopyTextureRegion, CopyResource) is made
  into the textures of the views placed over it that are laid out alike
  (resource::placed_twins: the same dimension, size and layers, elements
  or blocks of the same size, no more levels; a 9-level BC7 view over an
  11-level BC3 texture is one). The level written goes through a buffer
  (texture::twin_copy), since the host copies between two block formats in
  no other way. The first time for a view, a whole copy, or when either
  host copy changed since, every level goes, the view's texture made whole
  first (want_level 0);
- such a view's texture then counts as written by the host
  (texture::host_written_view; not entered by address), so upload_from
  sends nothing from title memory over it, the idle sweep leaves it, and
  want_level does not make it again from title memory;
- the slots that show it are made again once the copy has run, when its
  host copy is a new one (levels_changed_after).
Without the switch nothing changes: placed_twins is empty.

Off by default because it has not run on this tree's own path. On ours
(a fork with unified-memory changes; Radeon 8060S, Proton Experimental,
RADV 26.3.1) the log showed 128 copies going into views placed before the
copy in one session, mostly 1024x1024 BC3 sRGB textures of 11 levels under
9-level views, and the clothing prints, jersey numbers and lettering that
had been missing in every run came back, together with two other new
switches, so not isolated to this one.

Not covered: a view placed after the last copy into the texture under it
still fills from title memory (VIctory-NVIDIA's seed_later; not ported).
An upload of the view asked for by a list recorded before the copy and
submitted after it can still land over it: the race PR #47 closes for the
written texture itself; with #47 in, twin_copy should note its writes the
same way (note_gpu_written).

Tests: resource::tests::a_view_is_a_twin_of_the_texture_under_it_where_they_are_laid_out_alike;
resource::tests::placed_copied_card (ignored; needs the card): a one-level
BC7 sRGB view placed over a two-level BC7 texture before a title list
copies into it; read back, the view holds the copied blocks with the
switch and not without. victory-gpu --lib (diagnostics, Proton
Experimental, Radeon 8060S): 309 passed with the switch off and on; the
11 failures and the crash in descriptor::tests::views_die_with_their_resource
are the same on 37bb30f96 unchanged.

A hand port of trustno1-coder/VIctory-NVIDIA e530c003 (the placed views'
half; aventureroestelar-source, from ScarlettPort, on by default there)
and of 523485ba's concern (the twin's own level), by way of our fork's
095c3b1b9. There the copy goes from the title's source straight into the
view's texture; here through a buffer, as alias does.

Co-authored-by: aventureroestelar-source <[email protected]>
Co-authored-by: mikey <[email protected]>
Co-Authored-By: Claude <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 12:38:36 +00:00
Author
Owner

@⁠BlueCatsz on GitHub · 2026-12-01 16:03 UTC · original

Tested #67 (VICTORY_BC7_DICTIONARY default on + VICTORY_PLACED_COPIED=1) on CachyOS + RX 9070 XT 16 GB as part of a combined local stack (main 37bb30f + #44 + #47 + #67 + #31 + #43 + opt-in VICTORY_AMBIENT_RT, with VICTORY_POOL_MOVE=1).

  • Environment: Ryzen 7 5800X3D, 32 GB DDR4, RX 9070 XT (RADV GFX1201, Mesa 26.3.1 + #44/#43 mesa.patch), CachyOS (kernel 7.3.6), proton-cachyos-slr + RB-tree wineserver, Series X (1706x960 -> 2560x1440, HW RT on, FG off).
  • Observed Result: Character skin/arm textures and environment textures rendered cleanly across the opening scenes into the open world — the rainbow/confetti arm corruption that reproduced reliably in the indoor corridor scenes on 37bb30f + #44 was gone (0 crashes, 0 device loss, 0 dropped draws). (Note: tested together with #47 rather than isolated.)
**@⁠BlueCatsz** on GitHub · 2026-12-01 16:03 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/67#issuecomment-7316966819) Tested #67 (`VICTORY_BC7_DICTIONARY` default on + `VICTORY_PLACED_COPIED=1`) on CachyOS + RX 9070 XT 16 GB as part of a combined local stack (`main` `37bb30f` + #44 + #47 + #67 + #31 + #43 + opt-in `VICTORY_AMBIENT_RT`, with `VICTORY_POOL_MOVE=1`). - **Environment:** Ryzen 7 5800X3D, 32 GB DDR4, RX 9070 XT (RADV GFX1201, Mesa `26.3.1` + #44/#43 `mesa.patch`), CachyOS (kernel `7.3.6`), `proton-cachyos-slr` + RB-tree `wineserver`, Series X (`1706x960 -> 2560x1440`, HW RT on, FG off). - **Observed Result:** Character skin/arm textures and environment textures rendered cleanly across the opening scenes into the open world — the rainbow/confetti arm corruption that reproduced reliably in the indoor corridor scenes on `37bb30f + #44` was gone (`0` crashes, `0` device loss, `0` dropped draws). *(Note: tested together with #47 rather than isolated.)*
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 12:03 UTC · original · edited 2026-12-05 11:24 UTC

As I read it, this is already in main: both halves are in main. 9268924 is patch-identical to main's b73c5c5, and 4c78099 was cherry-picked as 914276d — whose message still records (cherry picked from commit 4c78099…).

Main documents the result too: crates/victory-formats/src/bcpack.rs:88-92 explains VICTORY_BC7_DICTIONARY=0, with the test bc7_dictionary_entries_read_as_bcpack_dll_reads_them at bcpack.rs:1737, and VICTORY_PLACED_COPIED is in docs/SETTINGS.md and run.conf.default.

One hole main inherited and never closed, which is worth an issue of its own: VICTORY_BC7_DICTIONARY is documented only in code comments, not in docs/SETTINGS.md or run.conf.default — the same as VICTORY_ARROWS_DPAD, VICTORY_AMBIENT_MOST and VICTORY_PLANES. That is a main task, not something this branch can fix.

Whether it still has work of its own is the maintainer's call, not mine.

**@⁠Luxuride** on GitHub · 2026-12-04 12:03 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/67#issuecomment-7410914084) · edited 2026-12-05 11:24 UTC As I read it, this is already in `main`: both halves are in main. `9268924` is patch-identical to main's `b73c5c5`, and `4c78099` was cherry-picked as `914276d` — whose message still records `(cherry picked from commit 4c78099…)`. Main documents the result too: `crates/victory-formats/src/bcpack.rs:88-92` explains `VICTORY_BC7_DICTIONARY=0`, with the test `bc7_dictionary_entries_read_as_bcpack_dll_reads_them` at `bcpack.rs:1737`, and `VICTORY_PLACED_COPIED` is in `docs/SETTINGS.md` and `run.conf.default`. One hole main inherited and never closed, which is worth an issue of its own: `VICTORY_BC7_DICTIONARY` is documented only in code comments, not in `docs/SETTINGS.md` or `run.conf.default` — the same as `VICTORY_ARROWS_DPAD`, `VICTORY_AMBIENT_MOST` and `VICTORY_PLANES`. That is a main task, not something this branch can fix. Whether it still has work of its own is the maintainer's call, not mine.
github-bot closed this pull request 2026-12-05 17:31:49 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.