Textures: detile linear levels a row at a time, tiled ones with per-row and per-column parts #469

Closed
NiiRoZz wants to merge 1 commit from upstream-pr/474 into main
NiiRoZz commented 2026-11-24 00:49:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by NiiRoZz on 2026-11-24T00:49:02Z.


Kept-in-step title textures are detiled on the CPU at every upload, one element at a time (Chain::detile_level → element_at: three divisions, six table lookups and a bounds-checked copy per element). A retail title's intro movie is three linear R8 planes, 12.4 MB a frame, uploaded whenever the decoder writes them: on main the movie shows its picture (#283) but plays at 7 to 8 presented frames per 2 s, with ~1.75 s of every 2 s spent in the detile. Linear levels are now copied a row at a time, and tiled levels work out their address parts once per row and per column. The bytes are the same.

Overlap: three open PRs opened shortly before this one make the same linear-level change: #440 (linear levels a row at a time), #458 (levels a row at a time) and #451 (reused upload memory and faster detiling, which also covers the upload cost listed under Not tested). I had not seen them when this was written. This one differs in also covering tiled levels with per-row and per-column parts and in its equivalence test over every mode; close it if one of those is taken.

What is in it

  • gpu/tiling.rs: two fast paths in detile_level (linear: whole rows; other modes: the x parts once per level, the y and slice parts once per row), and the test detile_level_matches_element_at: against element_at byte for byte, for every mode (linear too), element sizes 1 to 16 B, three pipe configurations, mips in and out of the tail, two slices, a base swizzle and a source cut short. With either new path broken on purpose the test fails.

Tested

  • NVIDIA GeForce RTX 5090 (driver 621.35), AMD Ryzen 7 9800X3D, Windows 11 Pro 26300, Rust 1.100.0, release.
  • cargo test --release -p xcl --lib tiling: 12 passed.
  • cargo test --workspace -- --test-threads=4: 671 passed, 0 failed, 41 ignored (SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, no wave64). That run was on main 3516080 plus this change; since then the commit was only rebased onto 2997c9a without conflicts.
  • Synthetic release timing of the three planes: linear 107–113 ms → 1.4–2.0 ms; 64KB_R_X 112–116 ms → 22–33 ms.
  • A retail title, main 3516080 with and without this change, one run each with the machine to itself: presented frames per 2 s during the intro movie 7–8 → 34–46; read + detile ~1.75 s → ~0.33 s per 2 s; the movie (15.0 s long) took ~19 s, one 4 s stall included.

Regression run

Pending: the two 60 s scripts/smoke.ps1 runs (main, this PR's head), with scripted A presses so that the intro movie plays during the run, are queued on the test machine and will be added here.

Not tested

  • AMD GPUs, other titles.
  • The movie is still below its 30 fps after this: what remains is the upload itself (each plane goes up about three times per presented frame, through a new staging buffer and a blocking wait each time). Not in this PR.
  • The whole suite on this exact head (see above).

AI use

  • Claude Code with Claude Opus 5.5 measured, wrote the code and the test; Claude Fable 5.2 checked the diff, made the regression runs and wrote this description. The runs were made on the author's machine.
<!-- greyfinch-sync:ivall/xcl:issue:6572034003 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/474). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-24T00:49:02Z. --- Kept-in-step title textures are detiled on the CPU at every upload, one element at a time (`Chain::detile_level` → `element_at`: three divisions, six table lookups and a bounds-checked copy per element). A retail title's intro movie is three linear R8 planes, 12.4 MB a frame, uploaded whenever the decoder writes them: on main the movie shows its picture (#283) but plays at 7 to 8 presented frames per 2 s, with ~1.75 s of every 2 s spent in the detile. Linear levels are now copied a row at a time, and tiled levels work out their address parts once per row and per column. The bytes are the same. Overlap: three open PRs opened shortly before this one make the same linear-level change: #440 (linear levels a row at a time), #458 (levels a row at a time) and #451 (reused upload memory and faster detiling, which also covers the upload cost listed under Not tested). I had not seen them when this was written. This one differs in also covering tiled levels with per-row and per-column parts and in its equivalence test over every mode; close it if one of those is taken. **What is in it** - `gpu/tiling.rs`: two fast paths in `detile_level` (linear: whole rows; other modes: the x parts once per level, the y and slice parts once per row), and the test `detile_level_matches_element_at`: against `element_at` byte for byte, for every mode (linear too), element sizes 1 to 16 B, three pipe configurations, mips in and out of the tail, two slices, a base swizzle and a source cut short. With either new path broken on purpose the test fails. **Tested** - NVIDIA GeForce RTX 5090 (driver 621.35), AMD Ryzen 7 9800X3D, Windows 11 Pro 26300, Rust 1.100.0, release. - `cargo test --release -p xcl --lib tiling`: 12 passed. - `cargo test --workspace -- --test-threads=4`: 671 passed, 0 failed, 41 ignored (SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`, no wave64). That run was on main `3516080` plus this change; since then the commit was only rebased onto `2997c9a` without conflicts. - Synthetic release timing of the three planes: linear 107–113 ms → 1.4–2.0 ms; 64KB_R_X 112–116 ms → 22–33 ms. - A retail title, main `3516080` with and without this change, one run each with the machine to itself: presented frames per 2 s during the intro movie 7–8 → 34–46; read + detile ~1.75 s → ~0.33 s per 2 s; the movie (15.0 s long) took ~19 s, one 4 s stall included. **Regression run** Pending: the two 60 s `scripts/smoke.ps1` runs (main, this PR's head), with scripted A presses so that the intro movie plays during the run, are queued on the test machine and will be added here. **Not tested** - AMD GPUs, other titles. - The movie is still below its 30 fps after this: what remains is the upload itself (each plane goes up about three times per presented frame, through a new staging buffer and a blocking wait each time). Not in this PR. - The whole suite on this exact head (see above). **AI use** - Claude Code with Claude Opus 5.5 measured, wrote the code and the test; Claude Fable 5.2 checked the diff, made the regression runs and wrote this description. The runs were made on the author's machine.
upstream-sync closed this pull request 2026-11-24 06:58:31 +00:00
NiiRoZz commented 2026-11-24 07:05:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by NiiRoZz on 2026-11-24T00:53:54Z.


Closing as a duplicate: #440, #458 and #451 were opened before this and make the same linear-level change. The equivalence test here (new paths against element_at for every mode) is free to take.

AI-assisted.

<!-- greyfinch-sync:ivall/xcl:comment:7118548856 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/474#issuecomment-7118548856). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-24T00:53:54Z. --- Closing as a duplicate: #440, #458 and #451 were opened before this and make the same linear-level change. The equivalence test here (new paths against `element_at` for every mode) is free to take. AI-assisted.

Pull request closed

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!469
No description provided.