Desc: audit GFX10 to DXGI format mappings, depth SRVs, and byte sizing #1432

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

@⁠slopgobblercobbler on GitHub · 2026-11-24 15:54 UTC · original
slopgobblercobbler:fix/desc-format-audit → main · +84 −11 · 1 files · 1 commits · open

Summary

Audits and completes GFX10 resource descriptor format mappings, depth SRV views, and format byte sizing in crates/xcl/src/gpu/desc.rs:

  1. Depth SRV views (dxgi_format):
    • Added depth SRV format mappings for GFX10 format 141 (GFX10_FORMAT_8_24_UNORM -> DXGI_FORMAT_R24_UNORM_X8_TYPELESS) and 146 (GFX10_FORMAT_X24_8_32_FLOAT -> DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS).
  2. Reverse format mappings (gfx10_format):
    • Added fast path mappings for swapchain and render target formats DXGI_FORMAT_B8G8R8A8_UNORM / B8G8R8X8_UNORM -> 56 (8_8_8_8_UNORM) and B8G8R8A8_UNORM_SRGB / B8G8R8X8_UNORM_SRGB -> 130 (8_8_8_8_SRGB).
    • Added reverse lookups for depth formats (D32_FLOAT -> 22, D16_UNORM -> 7, D24_UNORM_S8_UINT -> 141, D32_FLOAT_S8X24_UINT -> 146).
  3. Format byte sizing (format_bytes):
    • Extended byte sizes for GFX10 formats >= 128 (e.g. 1B for 128, 137..=139; 2B for 129, 131, 133..=136; 4B for 130, 132, 140..=144, 147..=154; 8B for 145..=146, 169..=170, 175..=176; 16B for 171..=174, 177..=182), preventing fallback to default 4 bytes for BC and packed formats.
  4. Unit tests:
    • Added gfx10_format_mappings_and_bit_depths_audit and expanded packed_formats_reorder_channels.

Changes

  • crates/xcl/src/gpu/desc.rs:
    • dxgi_format: depth SRV typeless mappings.
    • gfx10_format: swapchain BGRA and depth reverse lookups.
    • format_bytes: comprehensive byte sizing for GFX10 formats >= 128.
    • Unit tests: validation of format mappings and bit depths.

Tested

  • Windows 11 x64, Rust 1.85+ stable (MSVC).
  • cargo test -p xcl -- desc: 21 passed, 0 failed (100% pass rate).
  • Full lib tests: 583 passed, 0 failed.
  • Clean diff: zero trailing whitespace, GPL-2.0-only compliant, zero game data/keys.

Not Tested

  • Retail title GPU execution (synthetic unit tests only).

AI Use

Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity

**@⁠slopgobblercobbler** on GitHub · 2026-11-24 15:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1432) `slopgobblercobbler:fix/desc-format-audit` → `main` · +84 −11 · 1 files · 1 commits · open ## Summary Audits and completes GFX10 resource descriptor format mappings, depth SRV views, and format byte sizing in `crates/xcl/src/gpu/desc.rs`: 1. **Depth SRV views (`dxgi_format`)**: - Added depth SRV format mappings for GFX10 format 141 (`GFX10_FORMAT_8_24_UNORM` -> `DXGI_FORMAT_R24_UNORM_X8_TYPELESS`) and 146 (`GFX10_FORMAT_X24_8_32_FLOAT` -> `DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS`). 2. **Reverse format mappings (`gfx10_format`)**: - Added fast path mappings for swapchain and render target formats `DXGI_FORMAT_B8G8R8A8_UNORM` / `B8G8R8X8_UNORM` -> 56 (`8_8_8_8_UNORM`) and `B8G8R8A8_UNORM_SRGB` / `B8G8R8X8_UNORM_SRGB` -> 130 (`8_8_8_8_SRGB`). - Added reverse lookups for depth formats (`D32_FLOAT` -> 22, `D16_UNORM` -> 7, `D24_UNORM_S8_UINT` -> 141, `D32_FLOAT_S8X24_UINT` -> 146). 3. **Format byte sizing (`format_bytes`)**: - Extended byte sizes for GFX10 formats >= 128 (e.g. 1B for 128, 137..=139; 2B for 129, 131, 133..=136; 4B for 130, 132, 140..=144, 147..=154; 8B for 145..=146, 169..=170, 175..=176; 16B for 171..=174, 177..=182), preventing fallback to default 4 bytes for BC and packed formats. 4. **Unit tests**: - Added `gfx10_format_mappings_and_bit_depths_audit` and expanded `packed_formats_reorder_channels`. ## Changes - `crates/xcl/src/gpu/desc.rs`: - `dxgi_format`: depth SRV typeless mappings. - `gfx10_format`: swapchain BGRA and depth reverse lookups. - `format_bytes`: comprehensive byte sizing for GFX10 formats >= 128. - Unit tests: validation of format mappings and bit depths. ## Tested - Windows 11 x64, Rust 1.85+ stable (MSVC). - `cargo test -p xcl -- desc`: 21 passed, 0 failed (100% pass rate). - Full lib tests: 583 passed, 0 failed. - Clean diff: zero trailing whitespace, GPL-2.0-only compliant, zero game data/keys. ## Not Tested - Retail title GPU execution (synthetic unit tests only). ## AI Use Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:42 +00:00
Author
Owner

@⁠CuteBooty on GitHub · 2026-11-24 16:21 UTC · original

d4381e2: with the new format_bytes, real::texture_memory finds no memory for some large BC textures, and their GetGPUVirtualAddress would be 0 again.

texture_memory takes format_bytes as bytes per texel (Width * Height * DepthOrArraySize * bits / 8 * 4 / 3). format_bytes now gives BC formats their bytes per 4x4 block, so a BC7 / BC2 / BC3 / BC5 / BC6H texture is counted 16 times too large (BC1 / BC4 too), where the base counted 4 bytes per texel. Past 1 GiB the function returns None.

Seen (one mip, texture_memory called directly on reserved textures of these shapes):

texture base 930e8b4 d4381e2
BC7 2048 x 2048, 16 slices address none
BC7 8192 x 8192 address none
BC7 4096 x 4096 address address
BC1 8192 x 8192 address address

It matters for a texture the title did not place itself and whose address XCL has not recorded (a committed one): the function's comment names a title that wrote at address 0 that way. The memory is only reserved, so the larger size costs address space until the cap is hit.

Possible fix: in texture_memory, divide by the block's 16 texels for the BC formats (169 to 182), with a test of the size. The other callers of format_bytes in real.rs (buffer_view, buffer_words_at) are for buffers.

Also, #1165 (open) changes the 133 to 136 rows of format_bytes.

Tested: one scratch test on both commits; RTX 3070, NVIDIA 621.24, Windows 11 Pro 26200, rustc 1.100.0 MSVC, debug.

Not tested: the call through GetGPUVirtualAddress, the whole suite, a retail title, whether any title asks for the address of a BC texture this large.

AI use: Claude Code (Claude Opus 5.5) found this, ran the test and wrote the comment; Codex (GPT-6.2 Astra) checked it by reading the code, without running anything.

**@⁠CuteBooty** on GitHub · 2026-11-24 16:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/1432#issuecomment-7137529083) `d4381e2`: with the new `format_bytes`, `real::texture_memory` finds no memory for some large BC textures, and their `GetGPUVirtualAddress` would be 0 again. `texture_memory` takes `format_bytes` as bytes per **texel** (`Width * Height * DepthOrArraySize * bits / 8 * 4 / 3`). `format_bytes` now gives BC formats their bytes per 4x4 **block**, so a BC7 / BC2 / BC3 / BC5 / BC6H texture is counted 16 times too large (BC1 / BC4 too), where the base counted 4 bytes per texel. Past 1 GiB the function returns `None`. **Seen** (one mip, `texture_memory` called directly on reserved textures of these shapes): | texture | base `930e8b4` | `d4381e2` | |---|---|---| | BC7 2048 x 2048, 16 slices | address | none | | BC7 8192 x 8192 | address | none | | BC7 4096 x 4096 | address | address | | BC1 8192 x 8192 | address | address | It matters for a texture the title did not place itself and whose address XCL has not recorded (a committed one): the function's comment names a title that wrote at address 0 that way. The memory is only reserved, so the larger size costs address space until the cap is hit. Possible fix: in `texture_memory`, divide by the block's 16 texels for the BC formats (169 to 182), with a test of the size. The other callers of `format_bytes` in `real.rs` (`buffer_view`, `buffer_words_at`) are for buffers. Also, #1165 (open) changes the 133 to 136 rows of `format_bytes`. **Tested:** one scratch test on both commits; RTX 3070, NVIDIA 621.24, Windows 11 Pro 26200, rustc 1.100.0 MSVC, debug. **Not tested:** the call through `GetGPUVirtualAddress`, the whole suite, a retail title, whether any title asks for the address of a BC texture this large. **AI use:** Claude Code (Claude Opus 5.5) found this, ran the test and wrote the comment; Codex (GPT-6.2 Astra) checked it by reading the code, without running anything.
Author
Owner

@⁠LocranKing on GitHub · 2026-11-24 16:55 UTC · original

Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32), including a 60 s retail regression smoke run on clean head d4381e2c0df5e6527851309b2e1d00ea7a91c1e1.

No crash or device removal occurred during the 60 s menu smoke run (matching @CuteBooty's note that oversized BC textures triggering the real::texture_memory format_bytes mismatch were not hit in this window).

Tested

  • Commit: d4381e2c0df5e6527851309b2e1d00ea7a91c1e1 (clean tree, merge-base 930e8b4)
  • Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2101), rustc 1.100.0 (x86_64-pc-windows-msvc, MSVC 14.44.35207), DXC 1.9.2602.17 (SDK 10.0.26100.0), --release
  • cargo build --release --workspace: ok (exit 0)
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored, exit 0
    • SKIPPED (no wave64): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware

Regression run
main baseline (b7aa9f3bd212088e0d927439284dc5ed325ce3c7):

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1508 (PresentX 1508)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14730 MB

PR head (d4381e2c0df5e6527851309b2e1d00ea7a91c1e1):

xcl-smoke v1
commit: d4381e2c0df5e6527851309b2e1d00ea7a91c1e1
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1604 (PresentX 1605)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14714 MB

Not tested: debug build, XCL_SAMPLE_* tests on this branch, AMD / wave64 hardware, interactive world loading with committed textures large enough to hit texture_memory's 1 GiB cap.

AI use: Antigravity (Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.

**@⁠LocranKing** on GitHub · 2026-11-24 16:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1432#issuecomment-7138414922) Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32), including a 60 s retail regression smoke run on clean head `d4381e2c0df5e6527851309b2e1d00ea7a91c1e1`. No crash or device removal occurred during the 60 s menu smoke run (matching `@CuteBooty`'s note that oversized BC textures triggering the `real::texture_memory` `format_bytes` mismatch were not hit in this window). **Tested** - Commit: `d4381e2c0df5e6527851309b2e1d00ea7a91c1e1` (clean tree, merge-base `930e8b4`) - Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (`8024 MiB VRAM`, driver `32.0.16.2101`), `rustc 1.100.0` (`x86_64-pc-windows-msvc`, MSVC `14.44.35207`), DXC `1.9.2602.17` (SDK `10.0.26100.0`), `--release` - `cargo build --release --workspace`: ok (`exit 0`) - `cargo test --workspace --release --no-fail-fast -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, exit `0` - `SKIPPED` (`no wave64`): `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` **Regression run** `main` baseline (`b7aa9f3bd212088e0d927439284dc5ed325ce3c7`): ``` xcl-smoke v1 commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1508 (PresentX 1508) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14730 MB ``` PR head (`d4381e2c0df5e6527851309b2e1d00ea7a91c1e1`): ``` xcl-smoke v1 commit: d4381e2c0df5e6527851309b2e1d00ea7a91c1e1 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1604 (PresentX 1605) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14714 MB ``` **Not tested:** debug build, `XCL_SAMPLE_*` tests on this branch, AMD / wave64 hardware, interactive world loading with committed textures large enough to hit `texture_memory`'s 1 GiB cap. **AI use:** Antigravity (`Gemini 4 Hydrogen`) ran the build, tests, and smoke runs and drafted this report from the command outputs.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 17:18 UTC · original

An AMD run to go with the reports above, which are NVIDIA. Tested exact head d4381e2 (on its base 930e8b4).

Tested

  • AMD Radeon iGPU of a Ryzen 7 9800X3D (RDNA2, native wave64), XCL_ADAPTER=radeon cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, nothing skipped. gfx10_format_mappings_and_bit_depths_audit ran and passed.
  • Same head on an RTX 5070 Ti (driver 616.64), XCL_REQUIRE_GPU=mesh: 752 passed, 0 failed (the usual two wave64-only skips).
  • The suite has no test for the large-BC texture_memory case @⁠CuteBooty describes above, so this run neither confirms nor rules it out.

Not tested

  • A release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 17:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/1432#issuecomment-7138992719) An AMD run to go with the reports above, which are NVIDIA. Tested exact head `d4381e2` (on its base `930e8b4`). **Tested** - AMD Radeon iGPU of a Ryzen 7 9800X3D (RDNA2, native wave64), `XCL_ADAPTER=radeon cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, nothing skipped. `gfx10_format_mappings_and_bit_depths_audit` ran and passed. - Same head on an RTX 5070 Ti (driver 616.64), `XCL_REQUIRE_GPU=mesh`: 752 passed, 0 failed (the usual two wave64-only skips). - The suite has no test for the large-BC `texture_memory` case @⁠CuteBooty describes above, so this run neither confirms nor rules it out. **Not tested** - A release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. I checked it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 18:52 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 18:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1432#issuecomment-7141270280) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
@ -668,0 +737,4 @@
1..=6 | 128 | 137..=139 => 1,
7..=19 | 129 | 131 | 133..=136 => 2,
20..=61 | 130 | 132 | 140..=144 | 147..=154 => 4,
62..=71 | 145..=146 | 169 | 170 | 175 | 176 => 8,
Author
Owner

@⁠gut0to on GitHub · 2026-11-24 19:01 UTC · original

These BC values are bytes per 4×4 block, not bytes per texel, but real.rs uses format_bytes() directly with width × height × depth to estimate texture bytes and has no block rounding. For BC1, 8 bytes/block is 0.5 bytes/texel; returning 8 overestimates by 16×. BC2–BC7 similarly return 16 where the texel average is 1 byte. Large valid compressed textures can therefore exceed the 1 GiB guard and be rejected. Could block dimensions be handled at the sizing call site so this helper keeps consistent units? AI-assisted review; I verified the caller and arithmetic.

**@⁠gut0to** on GitHub · 2026-11-24 19:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/1432#discussion_r4685058674) These BC values are bytes per 4×4 block, not bytes per texel, but real.rs uses format_bytes() directly with width × height × depth to estimate texture bytes and has no block rounding. For BC1, 8 bytes/block is 0.5 bytes/texel; returning 8 overestimates by 16×. BC2–BC7 similarly return 16 where the texel average is 1 byte. Large valid compressed textures can therefore exceed the 1 GiB guard and be rejected. Could block dimensions be handled at the sizing call site so this helper keeps consistent units? AI-assisted review; I verified the caller and arithmetic.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1432/head:github-bot/gh-1432'
git switch 'github-bot/gh-1432'

Merge

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