XG texture computer: tail mip positions, 3D tail offsets, and element offsets from the plane's start #3224

Open
opened 2026-11-29 20:51:46 +00:00 by github-bot · 2 comments
Owner

@⁠dyshay on GitHub · 2026-11-29 20:48 UTC · original

How this differs from #1659

#1659 (closed) made every tail mip report OffsetBytes 0. The change proposed here is narrower on that point and adds one new part:

  • Offset 0 only for 3D tail mips, thick or thin. 2D tail mips keep t.offset. As the review on #1659 showed, main's 2D offsets already point at the right bytes (the tail block is the first block of each slice), so they are left alone.
  • tail_position for every tail mip. Today only thick (3D) tail mips fill it; 2D and thin 3D tail mips leave it at 0, which puts each of them at element (0, 0) for a caller that reads the position.
  • New: element_offset (slot 0x30) counts from the plane's start, while mip_offset (slot 0x28) keeps adding the plane's offset. Today both add it.

Question for the maintainer: would you like this as one pull request, or split, with the element_offset part (which nothing open or closed touches) first and the tail-mip part after it?

What the texture computer answers

XGCreateTextureComputer returns an object the title asks about a texture's layout:

  • GetResourceLayout (slot 0x10) fills one MipOut per mip. For a mip in the tail (the small mips packed into one block of the surface's mode) it gives in_tail, offset and tail_position, the mip's element position in the tail block (x in bits 0-10, y in bits 11-21).
  • GetMipLevelOffsetBytes (slot 0x28): where a mip's first element is, from the texture's start.
  • Slot 0x30 (element_offset here): the byte offset of one element (plane, mip, x, y, z).

What was wrong

  1. Only thick 3D tail mips named their tail_position. A thin 3D mode placed its tail mips by byte offset, as 2D does, so a 3D tail mip could land in the wrong block: a 3D tail is one block per depth slab, and a mip in it is found by its position, not by an offset into the chain.
  2. element_offset added the plane's offset to every element. For a two-plane texture (depth then stencil), the stencil plane's elements came back shifted by the whole depth plane. mip_offset (slot 0x28) is where the texture-relative offset belongs, and it keeps it.

What the title does with it

The title reads texels of a 128x4 4KB_S texture on the CPU through element_offset (see the comment on element_offset in crates/victory-hle/src/modules/xg.rs). An offset that includes a plane offset it does not expect sends that read to the wrong bytes. A 3D tail mip placed by offset instead of by position is uploaded to, or read from, the wrong block.

How to check

  • cargo test -p victory-hle xg: three new CPU tests (no GPU, no game data):
    • three_d_tail_mips_are_placed_by_position: a 64x64x64 RGBA8 texture with a full chain in SW_4KB_S and SW_64KB_S (thick) and SW_64KB_Z_X and SW_64KB_R_X (thin): every tail mip has offset 0 and the layout's tail position.
    • two_d_tail_mips_name_their_position: a 256x256 BC7 texture in SW_64KB_D: each of its 8 tail mips keeps its byte offset and names its position.
    • element_offsets_count_from_the_plane: a D24S8 texture (depth, then stencil): the stencil plane's first element is at 0 from its plane, and mip_offset for that plane equals the plane's offset.
  • In the game: a 300 s run in the Series X house scene on an RTX 4090, compared with a run without the change (numbers in the pull request).

Please test on your cards

Our run is on one RTX 4090 in one scene. If you can, run a session with the branch on your own card, Series X or S, and say whether anything looks different (volume textures seen from far away, where their small mips are used, are the likeliest place) and whether the frame times change. Our run was unattended and measured frame times only, not pictures.

**@⁠dyshay** on GitHub · 2026-11-29 20:48 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3224) ## How this differs from #1659 #1659 (closed) made every tail mip report `OffsetBytes` 0. The change proposed here is narrower on that point and adds one new part: - **Offset 0 only for 3D tail mips, thick or thin.** 2D tail mips keep `t.offset`. As the review on #1659 showed, `main`'s 2D offsets already point at the right bytes (the tail block is the first block of each slice), so they are left alone. - **`tail_position` for every tail mip.** Today only thick (3D) tail mips fill it; 2D and thin 3D tail mips leave it at 0, which puts each of them at element (0, 0) for a caller that reads the position. - **New: `element_offset` (slot 0x30) counts from the plane's start**, while `mip_offset` (slot 0x28) keeps adding the plane's offset. Today both add it. **Question for the maintainer:** would you like this as one pull request, or split, with the `element_offset` part (which nothing open or closed touches) first and the tail-mip part after it? ## What the texture computer answers `XGCreateTextureComputer` returns an object the title asks about a texture's layout: - `GetResourceLayout` (slot 0x10) fills one `MipOut` per mip. For a mip in the tail (the small mips packed into one block of the surface's mode) it gives `in_tail`, `offset` and `tail_position`, the mip's element position in the tail block (x in bits 0-10, y in bits 11-21). - `GetMipLevelOffsetBytes` (slot 0x28): where a mip's first element is, from the texture's start. - Slot 0x30 (`element_offset` here): the byte offset of one element `(plane, mip, x, y, z)`. ## What was wrong 1. Only thick 3D tail mips named their `tail_position`. A thin 3D mode placed its tail mips by byte offset, as 2D does, so a 3D tail mip could land in the wrong block: a 3D tail is one block per depth slab, and a mip in it is found by its position, not by an offset into the chain. 2. `element_offset` added the plane's offset to every element. For a two-plane texture (depth then stencil), the stencil plane's elements came back shifted by the whole depth plane. `mip_offset` (slot 0x28) is where the texture-relative offset belongs, and it keeps it. ## What the title does with it The title reads texels of a 128x4 `4KB_S` texture on the CPU through `element_offset` (see the comment on `element_offset` in `crates/victory-hle/src/modules/xg.rs`). An offset that includes a plane offset it does not expect sends that read to the wrong bytes. A 3D tail mip placed by offset instead of by position is uploaded to, or read from, the wrong block. ## How to check - `cargo test -p victory-hle xg`: three new CPU tests (no GPU, no game data): - `three_d_tail_mips_are_placed_by_position`: a 64x64x64 RGBA8 texture with a full chain in `SW_4KB_S` and `SW_64KB_S` (thick) and `SW_64KB_Z_X` and `SW_64KB_R_X` (thin): every tail mip has offset 0 and the layout's tail position. - `two_d_tail_mips_name_their_position`: a 256x256 BC7 texture in `SW_64KB_D`: each of its 8 tail mips keeps its byte offset and names its position. - `element_offsets_count_from_the_plane`: a D24S8 texture (depth, then stencil): the stencil plane's first element is at 0 from its plane, and `mip_offset` for that plane equals the plane's offset. - In the game: a 300 s run in the Series X house scene on an RTX 4090, compared with a run without the change (numbers in the pull request). ## Please test on your cards Our run is on one RTX 4090 in one scene. If you can, run a session with the branch on your own card, Series X or S, and say whether anything looks different (volume textures seen from far away, where their small mips are used, are the likeliest place) and whether the frame times change. Our run was unattended and measured frame times only, not pictures.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 20:51:46 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-29 20:48 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-29 20:48 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3224#issuecomment-7262373749) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
Author
Owner

@⁠dyshay on GitHub · 2026-11-29 21:39 UTC · original

Not a crash report: this is a development issue (a code change and how to test it). The relevant log lines and the numbers from our runs are quoted in the issue body, and the pull request linked here has the tests.

**@⁠dyshay** on GitHub · 2026-11-29 21:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3224#issuecomment-7263045225) Not a crash report: this is a development issue (a code change and how to test it). The relevant log lines and the numbers from our runs are quoted in the issue body, and the pull request linked here has the tests.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA#3224
No description provided.