Report the correct padded depth for thin-tiled 3D mip chains #4180

Closed
github-bot wants to merge 1 commit from github-bot/gh-4179 into main AGit
Owner

@⁠RanoGames on GitHub · 2026-11-30 17:05 UTC · original
RanoGames:fix/thin-volume-mip-depth → main · +29 −10 · 1 files · 1 commits · closed without merging

What it changes

For a 256×256×8 RGBA8 texture with two mips in SW_64KB_R_X, XG reported a padded depth of 1 for mip 0. That gave it a size of 256 KiB. All eight slices occupy 2 MiB.

A thin-tiled 3D texture stores one mip chain per depth slice. The logical depth shrinks at each mip, while the padded depth uses the resource's slice count. This change reports that count for both standard mips and mips packed into the tail, following AMD addrlib's ComputeSurfaceInfoMacroTiled.

How it was tested

  • Added a regression test for two 8-slice textures. The 256×256 case exercises standard mips, and the 16×16 case exercises tail mips. Both report logical depths of 8 and 4 and a padded depth of 8 for each mip. The test reproduced the incorrect padded depth of 1 before the fix.
  • cargo test --locked -p victory-formats passed on Windows (86 passed, 7 ignored).
  • cargo clippy --locked -p victory-formats --all-targets -- -D warnings passed.

Checked for overlap

  • Searched existing PRs. #3225 addresses tail-mip placement and offsets. This fix covers the padded depth used by XG to report mip sizes.
**@⁠RanoGames** on GitHub · 2026-11-30 17:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4179) `RanoGames:fix/thin-volume-mip-depth` → `main` · +29 −10 · 1 files · 1 commits · closed without merging ## What it changes For a 256×256×8 RGBA8 texture with two mips in `SW_64KB_R_X`, XG reported a padded depth of 1 for mip 0. That gave it a size of 256 KiB. All eight slices occupy 2 MiB. A thin-tiled 3D texture stores one mip chain per depth slice. The logical depth shrinks at each mip, while the padded depth uses the resource's slice count. This change reports that count for both standard mips and mips packed into the tail, following AMD addrlib's `ComputeSurfaceInfoMacroTiled`. ## How it was tested - Added a regression test for two 8-slice textures. The 256×256 case exercises standard mips, and the 16×16 case exercises tail mips. Both report logical depths of 8 and 4 and a padded depth of 8 for each mip. The test reproduced the incorrect padded depth of 1 before the fix. - `cargo test --locked -p victory-formats` passed on Windows (86 passed, 7 ignored). - `cargo clippy --locked -p victory-formats --all-targets -- -D warnings` passed. ## Checked for overlap - [x] Searched existing PRs. #3225 addresses tail-mip placement and offsets. This fix covers the padded depth used by XG to report mip sizes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 17:09:59 +00:00
Author
Owner

@⁠babuakhil on GitHub · 2026-11-30 18:57 UTC · original

Checked on Windows 11 (Rust 1.98.1, pinned), applied on current main (e1251c31); cherry-picks cleanly. Clippy on victory-formats is clean with -D warnings, and cargo test -p victory-formats gives 86 passed, 0 failed, 7 ignored. Not tested in the game.

Only thin volumes change. Mip::depth_pitch is read in one place, XG's mip_out (xg.rs:293 for the padded depth, :305 for the mip size), so this only changes what XG reports to the title. A throwaway test (not part of this PR) built 636 layouts on main and on this PR: 2D and 3D; every S, D, S_X, D_X, R_X and Z_X mode (4 KB and 64 KB); 1, 4 and 16 bytes per element; four sizes; depths 1 to 64; full mip chains. It compared every mip's depth_pitch:

layouts count changed by this PR
2D 132 0
thick 3D (S, D) 360 0
thin 3D (R, Z) 144 120 (the other 24 have depth 1)

With this PR, every mip of every thin volume reports depth_pitch == slices, where main reported 1 for each. A mip's reported size (pitch × rows × bpe × depth_pitch) never exceeds the layout's total in any of the 636, on either branch. Your example: SW_64KB_R_X 256×256×8 RGBA8 mip 0 goes from 256 KiB to 2 MiB, of a 3 MiB surface.

That matches AMD's GFX10 addrlib as far as I could read it: Gfx10Lib::ComputeSurfaceInfoMacroTiled sets pMipInfo[i].depth = IsTex3d(pIn->resourceType) ? pOut->numSlices : 1 for mips in and out of the tail.

One question for later, not for this PR: those addrlib lines don't branch on thin or thick, while main (and this PR) still gives thick volumes a per-mip depth (padded_dim(d.depth, i, 1) rounded to the block). I only read part of that file, so I may have missed a thick-specific path. It may be worth checking whether thick mips should report numSlices too.

**@⁠babuakhil** on GitHub · 2026-11-30 18:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4179#issuecomment-7288624441) Checked on Windows 11 (Rust 1.98.1, pinned), applied on current `main` (`e1251c31`); cherry-picks cleanly. Clippy on `victory-formats` is clean with `-D warnings`, and `cargo test -p victory-formats` gives 86 passed, 0 failed, 7 ignored. Not tested in the game. **Only thin volumes change.** `Mip::depth_pitch` is read in one place, XG's `mip_out` (`xg.rs:293` for the padded depth, `:305` for the mip size), so this only changes what XG reports to the title. A throwaway test (not part of this PR) built 636 layouts on `main` and on this PR: 2D and 3D; every `S`, `D`, `S_X`, `D_X`, `R_X` and `Z_X` mode (4 KB and 64 KB); 1, 4 and 16 bytes per element; four sizes; depths 1 to 64; full mip chains. It compared every mip's `depth_pitch`: | layouts | count | changed by this PR | |---|---|---| | 2D | 132 | 0 | | thick 3D (`S`, `D`) | 360 | 0 | | thin 3D (`R`, `Z`) | 144 | 120 (the other 24 have depth 1) | With this PR, every mip of every thin volume reports `depth_pitch == slices`, where `main` reported 1 for each. A mip's reported size (`pitch × rows × bpe × depth_pitch`) never exceeds the layout's total in any of the 636, on either branch. Your example: `SW_64KB_R_X` 256×256×8 RGBA8 mip 0 goes from 256 KiB to 2 MiB, of a 3 MiB surface. That matches AMD's GFX10 addrlib as far as I could read it: `Gfx10Lib::ComputeSurfaceInfoMacroTiled` sets `pMipInfo[i].depth = IsTex3d(pIn->resourceType) ? pOut->numSlices : 1` for mips in and out of the tail. One question for later, not for this PR: those addrlib lines don't branch on thin or thick, while `main` (and this PR) still gives thick volumes a per-mip depth (`padded_dim(d.depth, i, 1)` rounded to the block). I only read part of that file, so I may have missed a thick-specific path. It may be worth checking whether thick mips should report `numSlices` too.
github-bot force-pushed github-bot/gh-4179 from 2b26d697b1 to c26aaf5fbb 2026-12-01 16:23:39 +00:00 Compare
github-bot closed this pull request 2026-12-01 18:50:36 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:46 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4179#issuecomment-7321506703) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!4180
No description provided.