Textures: linear levels are detiled a row at a time #440

Closed
github-bot wants to merge 1 commit from gh-pr/440/head into gh-pr/440/base
Owner

@⁠emirduran707 on GitHub · 2026-11-24 00:21 UTC · original
emirduran707:linear-detile-rows → main · +46 −0 · 1 files · 1 commits · closed without merging

A retail title's intro video plays at 3.5 fps on an RX 9060 XT: every frame, the kept-in-step title textures upload its three linear R8 planes (3840x2160 and two 1920x1080), and Chain::detile_level computes the address of every element and copies it on its own – 8.3 M times for the large plane. A linear level keeps each row's elements contiguous, so its rows are now copied whole. The profiling and the idea are from the comments on #283 (gw1337x, CodeByCon); #334 did the same and was closed by its author.

What is in it

  • gpu/tiling.rs: detile_level copies the rows of a linear level (mode 0, no base swizzle, not in a mip tail) whole; which elements are copied when the source is cut short is unchanged. Swizzled modes, a base swizzle and mip-tail levels keep the element-by-element form.
  • Test linear_levels_detile_by_rows_as_by_elements: the same bytes by rows as by elements for every element size, padded rows, every mip, and a source cut short inside a row and inside an element.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.31044.16; Ryzen 5 5600, 32 GB; Windows 11 Pro 26300; rustc 1.100.0 x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.
  • cargo test --workspace -- --test-threads=4 at be722a7: 677 passed, 0 failed, 41 ignored; no SKIPPED lines.
  • detile_level alone (release, a local timing test, not committed): a 3840x2160 R8 plane 56.9 ms → 1.2 ms, 1920x1080 14.4 ms → 0.3 ms; about 85 ms → 2 ms for one video frame.
  • Retail title, A pressed by hand on the first menu, XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_FRAME_DUMP=60: on main 3516080 the video ran at 3.5 fps (7 presents per 2 s) for ~120 s and the world started loading at ~178 s; with this change it ran at 23–27 fps (900 frames presented, 27.2 fps over the last 300) for ~25 s, the world started loading at ~62 s, and the person watching saw it play smoothly.

Regression run

60 s, no input (the title stays at its first menu, so this run does not reach the video). The gpu: line names a virtual display adapter of this machine (what #281 / #282 / #285 fix); XCL's log names backend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM).

main:

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1382 (PresentX 1382)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14751 MB

PR:

xcl-smoke v1
commit: be722a7ab8306a1d952405abaeab67b2c941ae2f
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1425 (PresentX 1425)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14738 MB

Not tested

  • NVIDIA / RDNA2/3 (the change is CPU code; the timing depends on the CPU).
  • Other titles' linear textures.

AI use

  • Claude Code with Claude Opus 5.5: wrote the change, the test and this description; the runs above were made on my machine.
**@⁠emirduran707** on GitHub · 2026-11-24 00:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/440) `emirduran707:linear-detile-rows` → `main` · +46 −0 · 1 files · 1 commits · closed without merging A retail title's intro video plays at 3.5 fps on an RX 9060 XT: every frame, the kept-in-step title textures upload its three linear R8 planes (3840x2160 and two 1920x1080), and `Chain::detile_level` computes the address of every element and copies it on its own – 8.3 M times for the large plane. A linear level keeps each row's elements contiguous, so its rows are now copied whole. The profiling and the idea are from the comments on #283 (gw1337x, CodeByCon); #334 did the same and was closed by its author. **What is in it** - `gpu/tiling.rs`: `detile_level` copies the rows of a linear level (mode 0, no base swizzle, not in a mip tail) whole; which elements are copied when the source is cut short is unchanged. Swizzled modes, a base swizzle and mip-tail levels keep the element-by-element form. - Test `linear_levels_detile_by_rows_as_by_elements`: the same bytes by rows as by elements for every element size, padded rows, every mip, and a source cut short inside a row and inside an element. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.31044.16; Ryzen 5 5600, 32 GB; Windows 11 Pro 26300; rustc 1.100.0 `x86_64-pc-windows-msvc`; DXC 1.9.2602.17; debug for the suite, release for the runs. - `cargo test --workspace -- --test-threads=4` at be722a7: 677 passed, 0 failed, 41 ignored; no `SKIPPED` lines. - `detile_level` alone (release, a local timing test, not committed): a 3840x2160 R8 plane 56.9 ms → 1.2 ms, 1920x1080 14.4 ms → 0.3 ms; about 85 ms → 2 ms for one video frame. - Retail title, A pressed by hand on the first menu, `XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_FRAME_DUMP=60`: on `main` 3516080 the video ran at 3.5 fps (7 presents per 2 s) for ~120 s and the world started loading at ~178 s; with this change it ran at 23–27 fps (`900 frames presented, 27.2 fps over the last 300`) for ~25 s, the world started loading at ~62 s, and the person watching saw it play smoothly. **Regression run** 60 s, no input (the title stays at its first menu, so this run does not reach the video). The `gpu:` line names a virtual display adapter of this machine (what #281 / #282 / #285 fix); XCL's log names `backend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM)`. main: ``` xcl-smoke v1 commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1382 (PresentX 1382) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14751 MB ``` PR: ``` xcl-smoke v1 commit: be722a7ab8306a1d952405abaeab67b2c941ae2f gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1425 (PresentX 1425) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14738 MB ``` **Not tested** - NVIDIA / RDNA2/3 (the change is CPU code; the timing depends on the CPU). - Other titles' linear textures. **AI use** - Claude Code with Claude Opus 5.5: wrote the change, the test and this description; the runs above were made on my machine.
Chain::detile_level computed the address of every element and copied it
on its own. A linear level (mode 0) keeps each row's elements contiguous,
so its rows are now copied whole; which elements are copied when the
source is cut short is unchanged. Swizzled modes, a base swizzle and
levels in a mip tail keep the element-by-element form.

A retail title's intro video is three linear R8 planes per frame
(3840x2160 and two 1920x1080), uploaded on every frame through the
kept-in-step title textures: release, one plane 56.9 ms -> 1.2 ms and
14.4 ms -> 0.3 ms, about 85 ms -> 2 ms a frame. The video played at
3.5 fps on an RX 9060 XT with the element-by-element form.

Test: linear levels give the same bytes by rows as by elements, for
every element size, padded rows, every mip and a cut-short source.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:21:54 +00:00
github-bot closed this pull request 2026-11-26 04:21:54 +00:00
Author
Owner

@⁠mastrr9 on GitHub · 2026-11-24 00:30 UTC · original

Code audit + NVIDIA RTX 5080 test run on be722a7ab8306a1d952405abaeab67b2c941ae2f:

Review

Looks clean and mathematically equivalent to the element-by-element loop:

  • Guarding mode == 0 && base_xor == 0 && l.origin == (0, 0) ensures each linear row is contiguous at o..o + row.
  • src.len().saturating_sub(o).min(row) / e * e truncates down to whole elements, matching src.get(o..o + e) even when src ends mid-row or mid-element, with zero out-of-bounds risk on out[y * row..][..n].

Tested

  • Hardware / OS / toolchain: NVIDIA GeForce RTX 5080 (driver 617.42), AMD Ryzen 7 9800X3D, Windows 11 25H2 (build 26200.9711), rustc 1.100.0 (MSVC), debug build.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 677 passed, 0 failed, 41 ignored.
  • New test gpu::tiling::tests::linear_levels_detile_by_rows_as_by_elements: passed.
  • SKIPPED GPU tests (2, wave32-only adapter): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.

Not tested

  • Retail title / scripts/smoke.ps1 run (test suite only).
  • AMD / Intel GPUs.

AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.

**@⁠mastrr9** on GitHub · 2026-11-24 00:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/440#issuecomment-7118143858) Code audit + NVIDIA RTX 5080 test run on `be722a7ab8306a1d952405abaeab67b2c941ae2f`: ### Review Looks clean and mathematically equivalent to the element-by-element loop: - Guarding `mode == 0 && base_xor == 0 && l.origin == (0, 0)` ensures each linear row is contiguous at `o..o + row`. - `src.len().saturating_sub(o).min(row) / e * e` truncates down to whole elements, matching `src.get(o..o + e)` even when `src` ends mid-row or mid-element, with zero out-of-bounds risk on `out[y * row..][..n]`. ### Tested - Hardware / OS / toolchain: NVIDIA GeForce RTX 5080 (driver 617.42), AMD Ryzen 7 9800X3D, Windows 11 25H2 (build 26200.9711), `rustc 1.100.0` (MSVC), debug build. - `cargo build --workspace && cargo test --workspace -- --test-threads=4`: **677 passed, 0 failed, 41 ignored**. - New test `gpu::tiling::tests::linear_levels_detile_by_rows_as_by_elements`: **passed**. - `SKIPPED` GPU tests (2, wave32-only adapter): `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64`. ### Not tested - Retail title / `scripts/smoke.ps1` run (test suite only). - AMD / Intel GPUs. *AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.*
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-24 00:37 UTC · original

Thanks @⁠ethandepstein-del for the review and the RTX 5080 run.

For whoever merges: #451 (opened after this one) reworks the same function for every mode, so the two conflict, but they speed up different layouts – timings side by side in https://github.com/ivall/xcl/pull/451#issuecomment-7118264003. I'll rebase whichever lands second.

AI use: Claude Code with Claude Opus 5.5 wrote this note.

**@⁠emirduran707** on GitHub · 2026-11-24 00:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/440#issuecomment-7118265359) Thanks @⁠ethandepstein-del for the review and the RTX 5080 run. For whoever merges: #451 (opened after this one) reworks the same function for every mode, so the two conflict, but they speed up different layouts – timings side by side in https://github.com/ivall/xcl/pull/451#issuecomment-7118264003. I'll rebase whichever lands second. AI use: Claude Code with Claude Opus 5.5 wrote this note.
Author
Owner

@⁠alpz1000 on GitHub · 2026-11-24 01:05 UTC · original

Independent CPU-side detile benchmark on Intel Core i5-8400, Windows 11 Home 26200.9974, Rust 1.100.0 x86_64-pc-windows-msvc.

Tested: exact base a6f5f7a74cc620c1f88a9e3669a633d10c3c8212 and PR head be722a7ab8306a1d952405abaeab67b2c941ae2f, with the same temporary release-mode Cargo example calling Chain::detile_level on synthetic linear R8 planes. Each run checked the output against the original bytes before timing, then took the median of 31 calls including output allocation. Ran base → PR twice.

Plane Base medians (ms) PR medians (ms)
3840×2160 198.167 / 197.700 2.383 / 2.306
1920×1080 49.372 / 49.347 0.559 / 0.550

The PR's linear_levels_detile_by_rows_as_by_elements test also passed (1 passed, 0 failed, 0 ignored). The local timing example was removed after the run.

Not tested: retail playback or frame rate, GPU upload timing, and the full workspace suite.

AI use: OpenAI Codex (GPT-6) wrote the temporary benchmark, ran the local checks, and reported the measured results.

**@⁠alpz1000** on GitHub · 2026-11-24 01:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/440#issuecomment-7118751427) Independent CPU-side detile benchmark on Intel Core i5-8400, Windows 11 Home 26200.9974, Rust 1.100.0 x86_64-pc-windows-msvc. **Tested**: exact base `a6f5f7a74cc620c1f88a9e3669a633d10c3c8212` and PR head `be722a7ab8306a1d952405abaeab67b2c941ae2f`, with the same temporary release-mode Cargo example calling `Chain::detile_level` on synthetic linear R8 planes. Each run checked the output against the original bytes before timing, then took the median of 31 calls including output allocation. Ran base → PR twice. | Plane | Base medians (ms) | PR medians (ms) | | --- | ---: | ---: | | 3840×2160 | 198.167 / 197.700 | 2.383 / 2.306 | | 1920×1080 | 49.372 / 49.347 | 0.559 / 0.550 | The PR's `linear_levels_detile_by_rows_as_by_elements` test also passed (1 passed, 0 failed, 0 ignored). The local timing example was removed after the run. **Not tested**: retail playback or frame rate, GPU upload timing, and the full workspace suite. **AI use**: OpenAI Codex (GPT-6) wrote the temporary benchmark, ran the local checks, and reported the measured results.
Author
Owner

@⁠Chrysana on GitHub · 2026-11-24 01:08 UTC · original · edited 2026-11-24 01:11 UTC

Test report for #440 at be722a7 on an RX 9070 XT, with the video reached (the PR's own regression run stayed at the first menu).

Setup: AMD Radeon RX 9070 XT 16 GB, driver 32.0.32015.2008, Ryzen 7 9800X3D, 31 GB RAM, Windows 11 25H2 build 26200.9974, rustc 1.100.0 x86_64-pc-windows-msvc, DXC 1.9.2602.17. Retail title 1.0.2.1. Debug build for the tests, release build for the runs.

Tests: cargo test --workspace --no-fail-fast -- --test-threads=4 at be722a7: 679 passed, 0 failed, 41 ignored. SKIPPED: the two debug-layer tests (the D3D12 debug layer isn't installed here).

Title runs: scripts/smoke.ps1 -Game <folder> -Seconds 60 with XCL_PRESS_A_AT=14,17,21, which starts the video, two rounds each, interleaved with main, #451 and #458, same saved state:

build frames, round 1 / round 2 last 20 s
main a6f5f7a 489 / 497 ~5.5 fps
#440 be722a7 1261 / 1269 ~28 fps
#451 2cefc88 1489 / 1515 30 fps
#458 merged onto a6f5f7a 1418 / 1470 30 fps

No device removal or crash in any run. Peak commit was 15934 / 15783 MB (main: 15824 / 15815 MB).

Regression run (round 1, with the video):

main:

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 489 (PresentX 490)
presents per 2 s (last 3): 10 12 10
device removals: 0
crashes: 0
peak commit: 15824 MB

PR:

xcl-smoke v1
commit: be722a7ab8306a1d952405abaeab67b2c941ae2f
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1261 (PresentX 1262)
presents per 2 s (last 3): 56 58 57
device removals: 0
crashes: 0
peak commit: 15934 MB

Not tested: gameplay past the video; any title other than this one.

AI use: Claude Code with Claude Opus 5.5 built the commits, ran the tests and the title runs, and wrote this report. The runs were made on my machine.

**@⁠Chrysana** on GitHub · 2026-11-24 01:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/440#issuecomment-7118790925) · edited 2026-11-24 01:11 UTC Test report for #440 at `be722a7` on an RX 9070 XT, **with the video reached** (the PR's own regression run stayed at the first menu). **Setup:** AMD Radeon RX 9070 XT 16 GB, driver 32.0.32015.2008, Ryzen 7 9800X3D, 31 GB RAM, Windows 11 25H2 build 26200.9974, rustc 1.100.0 `x86_64-pc-windows-msvc`, DXC 1.9.2602.17. Retail title 1.0.2.1. Debug build for the tests, release build for the runs. **Tests:** `cargo test --workspace --no-fail-fast -- --test-threads=4` at `be722a7`: 679 passed, 0 failed, 41 ignored. `SKIPPED`: the two debug-layer tests (the D3D12 debug layer isn't installed here). **Title runs:** `scripts/smoke.ps1 -Game <folder> -Seconds 60` with `XCL_PRESS_A_AT=14,17,21`, which starts the video, two rounds each, interleaved with main, #451 and #458, same saved state: | build | frames, round 1 / round 2 | last 20 s | |---|---|---| | main `a6f5f7a` | 489 / 497 | ~5.5 fps | | **#440 `be722a7`** | **1261 / 1269** | **~28 fps** | | #451 `2cefc88` | 1489 / 1515 | 30 fps | | #458 merged onto `a6f5f7a` | 1418 / 1470 | 30 fps | No device removal or crash in any run. Peak commit was 15934 / 15783 MB (main: 15824 / 15815 MB). **Regression run** (round 1, with the video): main: ``` xcl-smoke v1 commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212 gpu: AMD Radeon RX 9070 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 489 (PresentX 490) presents per 2 s (last 3): 10 12 10 device removals: 0 crashes: 0 peak commit: 15824 MB ``` PR: ``` xcl-smoke v1 commit: be722a7ab8306a1d952405abaeab67b2c941ae2f gpu: AMD Radeon RX 9070 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1261 (PresentX 1262) presents per 2 s (last 3): 56 58 57 device removals: 0 crashes: 0 peak commit: 15934 MB ``` **Not tested:** gameplay past the video; any title other than this one. **AI use:** Claude Code with Claude Opus 5.5 built the commits, ran the tests and the title runs, and wrote this report. The runs were made on my machine.
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-24 01:12 UTC · original

Closing in favour of #451: its author folded this change into it unchanged as 1f282c7 (with its test), in front of their per-row loop for the swizzled modes – the combined head is faster than either alone (timings in https://github.com/ivall/xcl/pull/451#issuecomment-7118715303). Thanks @⁠1984742628, and @⁠ethandepstein-del, @⁠alpz1000 and @⁠Chrysana for the reviews and runs here.

AI use: Claude Code with Claude Opus 5.5 wrote this note.

**@⁠emirduran707** on GitHub · 2026-11-24 01:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/440#issuecomment-7118874484) Closing in favour of #451: its author folded this change into it unchanged as 1f282c7 (with its test), in front of their per-row loop for the swizzled modes – the combined head is faster than either alone (timings in https://github.com/ivall/xcl/pull/451#issuecomment-7118715303). Thanks @⁠1984742628, and @⁠ethandepstein-del, @⁠alpz1000 and @⁠Chrysana for the reviews and runs here. AI use: Claude Code with Claude Opus 5.5 wrote this note.
Author
Owner

@⁠Cattn on GitHub · 2026-11-24 01:16 UTC · original

Tested on Windows + NVIDIA: the retail title's intro video goes from about 5 fps to a steady 30 fps with this PR.

Setup: RTX 4070 12 GB (driver 617.42), Ryzen 7 7800X3D, 32 GB RAM, Windows 11 26200, release build, warm shader cache. scripts/smoke.ps1 (60 s, no input) reaches the intro video directly here, because the title's first-run settings are saved.

build frames shown presents per 2 s (last 3) removals / crashes peak commit
main 7ebf1b8, 3 runs 491 / 790 / 454 10 11 9 · (run 2, 3 similar) 0 / 0 15.0–15.1 GB
main 7ebf1b8 + this PR (be722a7), merge 105324d 1325 60 60 60 0 / 0 16.6 GB
xcl-smoke v1
commit: 105324dcb123935289527497d61769dc6e652b2e
gpu: NVIDIA GeForce RTX 4070
title: GTA6.Xbox.v1.0.2
seconds: 60
exit: 0x0
frames shown: 1325 (PresentX 1325)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16611 MB

Not tested: AMD; a longer run past the video.

(Report by Claude Code, Claude Opus 5.5; I ran the builds and the smoke runs on the hardware above.)

**@⁠Cattn** on GitHub · 2026-11-24 01:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/440#issuecomment-7118928736) Tested on Windows + NVIDIA: the retail title's intro video goes from about 5 fps to a steady 30 fps with this PR. **Setup:** RTX 4070 12 GB (driver 617.42), Ryzen 7 7800X3D, 32 GB RAM, Windows 11 26200, release build, warm shader cache. `scripts/smoke.ps1` (60 s, no input) reaches the intro video directly here, because the title's first-run settings are saved. | build | frames shown | presents per 2 s (last 3) | removals / crashes | peak commit | |---|---|---|---|---| | main `7ebf1b8`, 3 runs | 491 / 790 / 454 | 10 11 9 · (run 2, 3 similar) | 0 / 0 | 15.0–15.1 GB | | main `7ebf1b8` + this PR (`be722a7`), merge `105324d` | 1325 | 60 60 60 | 0 / 0 | 16.6 GB | ``` xcl-smoke v1 commit: 105324dcb123935289527497d61769dc6e652b2e gpu: NVIDIA GeForce RTX 4070 title: GTA6.Xbox.v1.0.2 seconds: 60 exit: 0x0 frames shown: 1325 (PresentX 1325) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16611 MB ``` Not tested: AMD; a longer run past the video. (Report by Claude Code, Claude Opus 5.5; I ran the builds and the smoke runs on the hardware above.)

Pull request closed

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