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

Open
slopgobblercobbler wants to merge 1 commit from upstream-pr/1432 into main
slopgobblercobbler commented 2026-11-24 15:54:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by slopgobblercobbler on 2026-11-24T15:54:14Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:5475613867 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1432). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-11-24T15:54:14Z. --- ## 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
CuteBooty commented 2026-11-24 17:06:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CuteBooty on 2026-11-24T16:21:13Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7137529083 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1432#issuecomment-7137529083). Originally posted by [CuteBooty](https://github.com/CuteBooty) on 2026-11-24T16:21:13Z. --- `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.
LocranKing commented 2026-11-24 17:06:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-24T16:55:24Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7138414922 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1432#issuecomment-7138414922). Originally posted by [LocranKing](https://github.com/LocranKing) on 2026-11-24T16:55:24Z. --- 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.
futurepro62 commented 2026-11-24 18:08:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T17:18:16Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7138992719 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1432#issuecomment-7138992719). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T17:18:16Z. --- 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.
gut0to commented 2026-11-24 18:58:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:58:52Z.

Review: COMMENTED


CONTRIBUTING.md requires paired real-title scripts/smoke.ps1 runs for changes under crates/xcl/src, with main and this head tested on the same title and for the same duration. The current description does not include those regression blocks. Please add both smoke results before merge; if the title does not reach the format-mapping path, document that under Not tested. AI-assisted review; I checked the diff scope and description against the guide.

<!-- greyfinch-sync:ivall/xcl:review:6045465537 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1432#pullrequestreview-6045465537). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-24T18:58:52Z. **Review:** COMMENTED --- CONTRIBUTING.md requires paired real-title `scripts/smoke.ps1` runs for changes under `crates/xcl/src`, with `main` and this head tested on the same title and for the same duration. The current description does not include those regression blocks. Please add both smoke results before merge; if the title does not reach the format-mapping path, document that under Not tested. AI-assisted review; I checked the diff scope and description against the guide.
gut0to commented 2026-11-24 19:01:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T19:01:21Z.

Review: COMMENTED


AI-assisted review; I traced format_bytes into the texture-size calculation.

<!-- greyfinch-sync:ivall/xcl:review:6045508722 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1432#pullrequestreview-6045508722). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-24T19:01:21Z. **Review:** COMMENTED --- AI-assisted review; I traced format_bytes into the texture-size calculation.
DavidM1911 commented 2026-11-24 19:07:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:22Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7141270280 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1432#issuecomment-7141270280). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:52:22Z. --- 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!
gut0to commented 2026-11-24 19:08:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T19:01:21Z.

Code review location: crates/xcl/src/gpu/desc.rs; line 740

@@ -656,17 +669,77 @@ mod view_tests {
         assert!(b[3] >> 28 < 8, "BVH descriptor must not look like a T# image to CopyDescriptors");
         assert_eq!(bvh_words(0x12_3456_789A_00, false)[1], 0x12);
     }
+
+    #[test]
+    fn gfx10_format_mappings_and_bit_depths_audit() {
+        // UNORM / SNORM channel order and bit depths
+        assert_eq!(dxgi_format(1), Some((DXGI_FORMAT_R8_UNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(2), Some((DXGI_FORMAT_R8_SNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(7), Some((DXGI_FORMAT_R16_UNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(8), Some((DXGI_FORMAT_R16_SNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(14), Some((DXGI_FORMAT_R8G8_UNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(15), Some((DXGI_FORMAT_R8G8_SNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(23), Some((DXGI_FORMAT_R16G16_UNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(24), Some((DXGI_FORMAT_R16G16_SNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(50), Some((DXGI_FORMAT_R10G10B10A2_UNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(56), Some((DXGI_FORMAT_R8G8B8A8_UNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(57), Some((DXGI_FORMAT_R8G8B8A8_SNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(65), Some((DXGI_FORMAT_R16G16B16A16_UNORM, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(66), Some((DXGI_FORMAT_R16G16B16A16_SNORM, [0, 1, 2, 3])));
+
+        // sRGB formats
+        assert_eq!(dxgi_format(130), Some((DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(170), Some((DXGI_FORMAT_BC1_UNORM_SRGB, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(172), Some((DXGI_FORMAT_BC2_UNORM_SRGB, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(174), Some((DXGI_FORMAT_BC3_UNORM_SRGB, [0, 1, 2, 3])));
+        assert_eq!(dxgi_format(182), Some((DXGI_FORMAT_BC7_UNORM_SRGB, [0, 1, 2, 3])));
+
+        // Reverse lookups via gfx10_format
+        assert_eq!(gfx10_format(DXGI_FORMAT_B5G5R5A1_UNORM), Some(134));
+        assert_eq!(gfx10_format(DXGI_FORMAT_B8G8R8A8_UNORM), Some(56));
+        assert_eq!(gfx10_format(DXGI_FORMAT_B8G8R8A8_UNORM_SRGB), Some(130));
+        assert_eq!(gfx10_format(DXGI_FORMAT_B8G8R8X8_UNORM), Some(56));
+        assert_eq!(gfx10_format(DXGI_FORMAT_B8G8R8X8_UNORM_SRGB), Some(130));
+        assert_eq!(gfx10_format(DXGI_FORMAT_D32_FLOAT), Some(22));
+        assert_eq!(gfx10_format(DXGI_FORMAT_D16_UNORM), Some(7));
+        assert_eq!(gfx10_format(DXGI_FORMAT_D24_UNORM_S8_UINT), Some(141));
+        assert_eq!(gfx10_format(DXGI_FORMAT_D32_FLOAT_S8X24_UINT), Some(146));
+
+        // Bit depths and block sizes in format_bytes
+        assert_eq!(format_bytes(1), 1);   // 8_UNORM
+        assert_eq!(format_bytes(128), 1); // 8_SRGB
+        assert_eq!(format_bytes(7), 2);   // 16_UNORM
+        assert_eq!(format_bytes(133), 2); // 5_6_5_UNORM
+        assert_eq!(format_bytes(134), 2); // 1_5_5_5_UNORM
+        assert_eq!(format_bytes(136), 2); // 4_4_4_4_UNORM
+        assert_eq!(format_bytes(56), 4);  // 8_8_8_8_UNORM
+        assert_eq!(format_bytes(130), 4); // 8_8_8_8_SRGB
+        assert_eq!(format_bytes(132), 4); // 5_9_9_9_FLOAT
+        assert_eq!(format_bytes(141), 4); // 8_24_UNORM
+        assert_eq!(format_bytes(146), 8); // X24_8_32_FLOAT
+        assert_eq!(format_bytes(169), 8); // BC1_UNORM
+        assert_eq!(format_bytes(170), 8); // BC1_SRGB
+        assert_eq!(format_bytes(175), 8); // BC4_UNORM
+        assert_eq!(format_bytes(176), 8); // BC4_SNORM
+        assert_eq!(format_bytes(171), 16); // BC2_UNORM
+        assert_eq!(format_bytes(173), 16); // BC3_UNORM
+        assert_eq!(format_bytes(177), 16); // BC5_UNORM
+        assert_eq!(format_bytes(179), 16); // BC6H_UF16
+        assert_eq!(format_bytes(181), 16); // BC7_UNORM
+        assert_eq!(format_bytes(182), 16); // BC7_SRGB
+    }
 }
 
-/// Bytes per element of a GFX10 buffer / image format (0–77: 8, 16, 32, 64, 96, 128 bits).
+/// Bytes per element of a GFX10 buffer / image format (0–77: 8, 16, 32, 64, 96, 128 bits,
+/// plus packed image and block-compressed formats 128+).
 pub fn format_bytes(f: u32) -> u32 {
     match f {
-        1..=6 => 1,
-        7..=19 => 2,
-        20..=61 => 4,
-        62..=71 => 8,
+        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,

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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4685058674 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1432#discussion_r4685058674). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-24T19:01:21Z. **Code review location:** `crates/xcl/src/gpu/desc.rs`; line 740 ~~~~diff @@ -656,17 +669,77 @@ mod view_tests { assert!(b[3] >> 28 < 8, "BVH descriptor must not look like a T# image to CopyDescriptors"); assert_eq!(bvh_words(0x12_3456_789A_00, false)[1], 0x12); } + + #[test] + fn gfx10_format_mappings_and_bit_depths_audit() { + // UNORM / SNORM channel order and bit depths + assert_eq!(dxgi_format(1), Some((DXGI_FORMAT_R8_UNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(2), Some((DXGI_FORMAT_R8_SNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(7), Some((DXGI_FORMAT_R16_UNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(8), Some((DXGI_FORMAT_R16_SNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(14), Some((DXGI_FORMAT_R8G8_UNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(15), Some((DXGI_FORMAT_R8G8_SNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(23), Some((DXGI_FORMAT_R16G16_UNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(24), Some((DXGI_FORMAT_R16G16_SNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(50), Some((DXGI_FORMAT_R10G10B10A2_UNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(56), Some((DXGI_FORMAT_R8G8B8A8_UNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(57), Some((DXGI_FORMAT_R8G8B8A8_SNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(65), Some((DXGI_FORMAT_R16G16B16A16_UNORM, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(66), Some((DXGI_FORMAT_R16G16B16A16_SNORM, [0, 1, 2, 3]))); + + // sRGB formats + assert_eq!(dxgi_format(130), Some((DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(170), Some((DXGI_FORMAT_BC1_UNORM_SRGB, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(172), Some((DXGI_FORMAT_BC2_UNORM_SRGB, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(174), Some((DXGI_FORMAT_BC3_UNORM_SRGB, [0, 1, 2, 3]))); + assert_eq!(dxgi_format(182), Some((DXGI_FORMAT_BC7_UNORM_SRGB, [0, 1, 2, 3]))); + + // Reverse lookups via gfx10_format + assert_eq!(gfx10_format(DXGI_FORMAT_B5G5R5A1_UNORM), Some(134)); + assert_eq!(gfx10_format(DXGI_FORMAT_B8G8R8A8_UNORM), Some(56)); + assert_eq!(gfx10_format(DXGI_FORMAT_B8G8R8A8_UNORM_SRGB), Some(130)); + assert_eq!(gfx10_format(DXGI_FORMAT_B8G8R8X8_UNORM), Some(56)); + assert_eq!(gfx10_format(DXGI_FORMAT_B8G8R8X8_UNORM_SRGB), Some(130)); + assert_eq!(gfx10_format(DXGI_FORMAT_D32_FLOAT), Some(22)); + assert_eq!(gfx10_format(DXGI_FORMAT_D16_UNORM), Some(7)); + assert_eq!(gfx10_format(DXGI_FORMAT_D24_UNORM_S8_UINT), Some(141)); + assert_eq!(gfx10_format(DXGI_FORMAT_D32_FLOAT_S8X24_UINT), Some(146)); + + // Bit depths and block sizes in format_bytes + assert_eq!(format_bytes(1), 1); // 8_UNORM + assert_eq!(format_bytes(128), 1); // 8_SRGB + assert_eq!(format_bytes(7), 2); // 16_UNORM + assert_eq!(format_bytes(133), 2); // 5_6_5_UNORM + assert_eq!(format_bytes(134), 2); // 1_5_5_5_UNORM + assert_eq!(format_bytes(136), 2); // 4_4_4_4_UNORM + assert_eq!(format_bytes(56), 4); // 8_8_8_8_UNORM + assert_eq!(format_bytes(130), 4); // 8_8_8_8_SRGB + assert_eq!(format_bytes(132), 4); // 5_9_9_9_FLOAT + assert_eq!(format_bytes(141), 4); // 8_24_UNORM + assert_eq!(format_bytes(146), 8); // X24_8_32_FLOAT + assert_eq!(format_bytes(169), 8); // BC1_UNORM + assert_eq!(format_bytes(170), 8); // BC1_SRGB + assert_eq!(format_bytes(175), 8); // BC4_UNORM + assert_eq!(format_bytes(176), 8); // BC4_SNORM + assert_eq!(format_bytes(171), 16); // BC2_UNORM + assert_eq!(format_bytes(173), 16); // BC3_UNORM + assert_eq!(format_bytes(177), 16); // BC5_UNORM + assert_eq!(format_bytes(179), 16); // BC6H_UF16 + assert_eq!(format_bytes(181), 16); // BC7_UNORM + assert_eq!(format_bytes(182), 16); // BC7_SRGB + } } -/// Bytes per element of a GFX10 buffer / image format (0–77: 8, 16, 32, 64, 96, 128 bits). +/// Bytes per element of a GFX10 buffer / image format (0–77: 8, 16, 32, 64, 96, 128 bits, +/// plus packed image and block-compressed formats 128+). pub fn format_bytes(f: u32) -> u32 { match f { - 1..=6 => 1, - 7..=19 => 2, - 20..=61 => 4, - 62..=71 => 8, + 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, ~~~~ --- 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.
github-actions[bot] commented 2026-11-27 21:26:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-27T21:26:29Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7228446253 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1432#issuecomment-7228446253). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T21:26:29Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:43:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:43:59Z.


Triage (#1607) – head d4381e2

The format_bytes change for the packed formats (133..=136 -> 2, 130/132 -> 4) is the same as #1165, which was opened first and does only that; this PR also adds 141/146 depth SRV formats in dxgi_format, explicit reverse mappings in gfx10_format (BGRA/BGRX -> 56/130, D32/D16/D24S8/D32S8) and sizes for the other 128+ formats.
format_bytes now returns 8/16 for BC1-BC7, i.e. bytes per 4x4 block, but real.rs (title_address of a texture) multiplies format_bytes by the texel count, so a BC7 texture is now reserved at 128 bits per texel (previously 32 through the default arm); an 8192x8192 BC7 texture goes over the 1 GiB cap there and no longer gets a title address. Either keep BC at the old value or make that caller block-aware.
gfx10_format(B8G8R8A8_UNORM) -> 56 gives a BGRA view the RGBA8 code in its T#; that is fine for the image class but worth a sentence in the description.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302078992 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1432#issuecomment-7302078992). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:43:59Z. --- **Triage (#1607)** – head d4381e2 The format_bytes change for the packed formats (133..=136 -> 2, 130/132 -> 4) is the same as #1165, which was opened first and does only that; this PR also adds 141/146 depth SRV formats in dxgi_format, explicit reverse mappings in gfx10_format (BGRA/BGRX -> 56/130, D32/D16/D24S8/D32S8) and sizes for the other 128+ formats. format_bytes now returns 8/16 for BC1-BC7, i.e. bytes per 4x4 block, but real.rs (title_address of a texture) multiplies format_bytes by the texel count, so a BC7 texture is now reserved at 128 bits per texel (previously 32 through the default arm); an 8192x8192 BC7 texture goes over the 1 GiB cap there and no longer gets a title address. Either keep BC at the old value or make that caller block-aware. gfx10_format(B8G8R8A8_UNORM) -> 56 gives a BGRA view the RGBA8 code in its T#; that is fine for the image class but worth a sentence in the description. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1432:upstream-pr/1432'
git switch 'upstream-pr/1432'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1432'
git switch 'upstream-pr/1432'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1432'
git switch 'upstream-pr/1432'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1432'
git switch 'main'
git merge --squash 'upstream-pr/1432'
git switch 'main'
git merge --ff-only 'upstream-pr/1432'
git switch 'main'
git merge 'upstream-pr/1432'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
xcl-dev/xcl!1422
No description provided.