WIP: perf(vk): block-linear textures' write-back swizzle and RGB widening in x86-64 assembly #2136

Draft
siantm wants to merge 27 commits from siantm/Longshot:perf/asm-texture into main
Contributor

Summary

Write-backs of block-linear textures are swizzled by suyu's C (SwizzleTexture in flush_finish), and 3-, 6- and
12-byte texels are widened to four channels with an alpha in a C loop (widen_rows), both in
gpu/vk/vk_texture.cpp.

This adds gpu/vk/asm/texture.S on the asm kit: lsasm_swizzle (suyu's at stride_alignment 0, with the Switch 2
GOB, a line copied 16-byte sector by sector, a sector being whole in both layouts) and lsasm_widen_rows (alpha 0xFF,
half 1.0 or float 1.0), AVX2 and SSE2 bodies. flush_finish's write-back swizzle calls lsasm_swizzle, and
widen_rows gives the three alphas the kernel writes to lsasm_widen_rows; every other widening (SNORM, UNORM16, the
integer ones) stays in its loop. The write-back swizzle was called with stride_alignment 1 and the kernel is 0's: the
same layout for every bytes per block a write-back has (1, 2, 4, 8, 16; flushable() keeps the widened formats out), as
the test shows. The result expected: the same texels, those write-backs and widenings faster.

The upload's unswizzle stays suyu's C. This pull request had a kernel for it too (lsasm_unswizzle, up to d6313013);
in play it was slower than the C on the game's shapes (Measurements), so it is dropped and unswizzle_upload is as on
main.

No switch: the kernels stand for suyu's C and the widening loop at those two calls, the same bytes.

From 971f8074 on exp/x86-asm-sync (its fix of the upload's own stride_alignment is main's already: #1603). Depends
on #1947 (the asm kit, which now carries the GPU-visible ranges' sort, lsasm_sort_ranges): its commits show in this
diff until #1947 merges.

Not the same change as #925 (jcabarca's, open): it sends sparse textures from the GPU unswizzle to the CPU path; this one
changes the CPU path's write-back swizzle and widening, and the two merge cleanly.

Read first: gpu/vk/asm/texture.S, then flush_finish and widen_rows in gpu/vk/vk_texture.cpp.

Testing

Tested: Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23 (CC/CXX, RX_CPM set); head a360ac98
on #1947's head 186fdb85 (the asm kit, on main 9dd41326). Through the PC's job queue (build job fb-2136n), each run in
a hidden console, tests/run_all.py --strict --exact: the change's own checks and the kit's (log 2136n-head-own):
test_asm_texture.py, test_texture_tile_upload.py, test_widen_alpha.py, test_asm_abi.py, test_asm_build.py,
test_asm_kit.py pass (6 of 6). test_texture_tile_upload.py at the test commit 3f5be891, before the fix, fails as it
should: Assertion failed: Tegra::Texture::fallback_calls == before + ... (log 2136n-tile-test). --changed 186fdb85
(log 2136n-head-changed): 74 checks, 64 pass, 2 skip, 8 fail, the same 8 that fail on #1947's head (at cffa2f46, logs
t-AsmCut5-base-kit-changed and t-AsmCut5-base-kit-more; 186fdb85 changes only tests/test_asm_build.py):
test_linux_pressure.py, test_low_vram_texture_mips.py, test_pass_barrier.py, test_readback_timeout_source.py,
test_staging_burst.py, test_target_reuse_memory.py, test_texel_buffer_ownership.py, test_ub_update_batch.py.

It has run in the game on this PC as the two arms of the like-for-like run in Measurements (held job fb-g2136-sw,
Hyrule Field, 16 runs and two warm-ups: this head's unswizzle is that run's C arm, its swizzle and widening its kernel
arm), and d6313013 in fb-g2136 (19 runs), with no FATAL, device lost or Vulkan error in any run.

Still to test:

  • A scene whose textures reach the widening: RGB8 UNORM, RGB16 float or RGB32 float textures widened with an alpha (the
    only ones lsasm_widen_rows takes). Hyrule Field has none; such a scene is not yet found (by hand)
  • Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: Kokiri Forest, then Hyrule Field, three minutes each, on
    #1947's head and on this PR, warmed and interleaved, expecting the same picture and frame times within the runs'
    spread or better on this PR (@Beanstalk linux+nvidia, linux+amd, windows+amd, windows+intel, steamdeck: Kokiri
    Forest and Hyrule Field three minutes each, #1947's head against this PR, warmed and interleaved, frame times and
    screenshots)
  • Linux: python3 -I -B tests/test_asm_texture.py --cxx g++ and --cxx clang++, expecting PASS (by hand)

Measurements

Verdict: the write-back swizzle kernel about 2 times faster in play, in the loads: 0.230 against 0.112 ms a MB
(p < 0.0001), about 1.4 ms over a run (Hyrule Field, one runtime, like for like, at an 800x600 desktop with the output
pinned at 2560x1440, below). The widening kernel was not reached in play so far: the textures that would call it are RGB8
UNORM, RGB16 float and RGB32 float ones widened with an alpha, and Hyrule Field has none. Nothing is shown in frame time.
No new game run is needed for this head: its unswizzle is the C arm and its swizzle the kernel arm of fb-g2136-sw
(below). The micro-benchmark (authored input) has the write-back swizzle 1.21-3.13× faster and the RGB widening 4.8-9.5×
in the SSE2 build and 6.5-28.6× in the AVX2 build.

The unswizzle kernel this pull request had up to d6313013 is dropped: in the same run it was slower than suyu's C where
the game uses it, by 14.5 % a MB in the loads (p = 0.037, matched work) and 64 % in steady play (p < 0.0001). A
micro-benchmark of it on play's sizes (the same script, its cases replaced: partial tiles of about 17 KB, 4 and 16 bytes a
block, a 16 KB 3D level, and 160-192 KB partial tiles and 3D levels; source bytes warm in the caches, run in the queue
beside builds on 2026-11-23) still had it 1.10-3.44× faster than suyu's C, so the loss in play is not the surfaces'
shapes alone; what it is (cold source bytes from guest memory, the upload's destination) is not known. Its rows stay in
the table below as measured.

Baseline: the C this PR replaces, as #1947's head has it (cffa2f46 for every run below; 186fdb85 now, the kit's code
the same: the asm kit on main 9dd41326, which this PR depends on), not main itself.

The micro-benchmark: suyu's UnswizzleTexture(..., 0) and SwizzleTexture(..., 1) (as unswizzle_upload and flush_finish call them at cffa2f46; suyu's decoders.cpp, the same at both commits, built at the arm's level) and widen_rows' loop cut from gpu/vk/vk_texture.cpp at cffa2f46, against lsasm_unswizzle and lsasm_swizzle called as d6313013 called them and its widen_rows (lsasm_widen_rows); 16 MB of authored texel bytes; the swizzle's destination filled with what is there first, untimed. A script on this PC, not in this PR (asm_texture_bench.py, PrTrials' trials/tools/bench), run alone in the PC's job queue on 2026-11-22: 3 rounds of 201 repetitions per case and arm, i7-9700, llvm-mingw clang 23.1.5 -O2 -ffp-contract=off, arms SSE2 (-march=x86-64) and AVX2 (-march=x86-64-v3, what the release builds the back end for). The arms take turns at going first; their outputs were compared at every repetition and were equal. Each cell: the median of the three rounds' medians, [lowest–highest round median], in ns per block or texel. Change: before ÷ after (above 1: this PR faster).

Surface or rows, arm Before: suyu's C, widen loop @ cffa2f46 After: this PR @ d6313013 (its head then) Change
unswizzle, 3D 64x64x16, 4 B a block, block height 3, depth 4, SSE2 0.227 [0.227–0.230] 0.168 [0.166–0.169] 1.35×
unswizzle, 3D 64x64x16, 4 B a block, block height 3, depth 4, AVX2 0.214 [0.212–0.224] 0.168 [0.166–0.171] 1.27×
unswizzle, 3D 32x32x32, 8 B, 2/5, SSE2 0.455 [0.455–0.461] 0.333 [0.333–0.336] 1.37×
unswizzle, 3D 32x32x32, 8 B, 2/5, AVX2 0.436 [0.427–0.464] 0.342 [0.336–0.345] 1.28×
unswizzle, partial tiles 100x75, 4 B, 4, SSE2 0.187 [0.187–0.200] 0.147 [0.147–0.147] 1.27×
unswizzle, partial tiles 100x75, 4 B, 4, AVX2 0.173 [0.173–0.173] 0.133 [0.133–0.133] 1.30×
unswizzle, partial tiles, BC 40x30 blocks, 16 B, 2 (4 a repetition), SSE2 0.729 [0.708–0.729] 0.479 [0.479–0.500] 1.52×
unswizzle, partial tiles, BC 40x30 blocks, 16 B, 2 (4 a repetition), AVX2 0.646 [0.646–0.646] 0.479 [0.479–0.479] 1.35×
unswizzle, 1024x1024, 4 B, 4 (whole tiles), SSE2 0.444 [0.425–0.456] 0.303 [0.298–0.305] 1.47×
unswizzle, 1024x1024, 4 B, 4 (whole tiles), AVX2 0.450 [0.435–0.455] 0.219 [0.219–0.222] 2.05×
unswizzle, a 4x4-block mip, 16 B, 0 (1,024), SSE2 1.82 [1.82–1.82] 0.897 [0.897–0.897] 2.03×
unswizzle, a 4x4-block mip, 16 B, 0 (1,024), AVX2 1.82 [1.82–1.85] 0.757 [0.757–0.757] 2.40×
swizzle (write-back), 256x256, 4 B, 4, SSE2 0.439 [0.439–0.441] 0.140 [0.140–0.143] 3.13×
swizzle (write-back), 256x256, 4 B, 4, AVX2 0.438 [0.435–0.438] 0.180 [0.171–0.182] 2.43×
swizzle, 1280x720, 8 B, 4, SSE2 1.43 [1.43–1.46] 0.742 [0.737–0.744] 1.93×
swizzle, 1280x720, 8 B, 4, AVX2 1.44 [1.42–1.44] 0.730 [0.720–0.731] 1.97×
swizzle, 100x60, 4 B, 3 (2), SSE2 0.200 [0.200–0.200] 0.125 [0.125–0.125] 1.60×
swizzle, 100x60, 4 B, 3 (2), AVX2 0.192 [0.183–0.192] 0.150 [0.150–0.150] 1.28×
swizzle, an 8x8 mip, 4 B, 0 (1,024), SSE2 0.580 [0.580–0.584] 0.412 [0.410–0.414] 1.41×
swizzle, an 8x8 mip, 4 B, 0 (1,024), AVX2 0.528 [0.528–0.533] 0.436 [0.436–0.439] 1.21×
widen 3 to 4 bytes (UNORM8), 65,536 texels, SSE2 3.24 [3.24–3.24] 0.342 [0.342–0.342] 9.48×
widen 3 to 4 bytes (UNORM8), 65,536 texels, AVX2 3.62 [3.62–3.63] 0.127 [0.125–0.127] 28.61×
widen 6 to 8 (half), 65,536, SSE2 3.24 [3.24–3.24] 0.673 [0.673–0.674] 4.82×
widen 6 to 8 (half), 65,536, AVX2 3.58 [3.57–3.58] 0.255 [0.250–0.259] 14.03×
widen 12 to 16 (float), 65,536, SSE2 3.25 [3.25–3.25] 0.601 [0.597–0.609] 5.40×
widen 12 to 16 (float), 65,536, AVX2 3.60 [3.58–3.64] 0.523 [0.514–0.539] 6.88×
widen 3 to 4, 16 texels (4,096), SSE2 3.65 [3.65–3.65] 0.511 [0.507–0.513] 7.15×
widen 3 to 4, 16 texels (4,096), AVX2 4.08 [4.08–4.08] 0.627 [0.627–0.629] 6.51×

In play (held job fb-g2136, 07:15 to 08:05 UTC on 2026-11-23): Hyrule Field, chosen because it has the most CPU
unswizzling of the scenes on disk. 60 s a run. The two builds are the head then, d6313013 (rt-atx-d6313013) and its parent,
the asm kit cffa2f46 (rt-kit-cffa2f46): a warm-up each, then kit and head interleaved (kit head head kit, four times),
every run loading at create. The output was pinned at 2560x1440, on a desktop at 800x600 at 30 Hz (the PC's only screen
then); the runs are alike among themselves. One kit run (base12) is held: in it the game's first uses waited 2,188 ms in
all for shader loads (the longest wait 585 ms), so it wrote the load marker into the kit's runtime. The marker was moved
out before the next run, and every later run logged loading at create. That leaves 7 kit runs against 8 head runs.

Reach, from a diagnostic build of d6313013 that is local and never pushed (one uncounted run in this scene, counters
beside the 120-frame unswizzle line): over about 12,840 frames, lsasm_unswizzle was called 19,895 times (528.6 MB),
lsasm_swizzle 570 times (12.4 MB) and lsasm_widen_rows never.

  • In the loads (the 9,240 frames before the measured stretch): unswizzle about 2 calls a frame (363.7 MB in all), and
    every one of the 570 swizzles.
  • In steady play (the last 3,600 frames): unswizzle 0.48 calls a frame (0.046 MB a frame), no swizzle.
  • The widening kernel was not reached in Hyrule Field (Still to test).

What the line counts: main's vk: a frame: X MB unswizzled on the CPU in Y ms times all of a frame's CPU unswizzling,
the unchanged tile fast path (texture_tiles.h) together with the fallback d6313013's kernel replaced. The kernel carries
about a third of those bytes in steady play and about 40 % in the loads. So the figures below are the whole stage, not
the kernel's own; they cannot be read as the kernel's speed.

a side: median (range) Before: the kit @ cffa2f46, 7 runs After: this PR @ d6313013 (its head then), 8 runs change of the means p (swap test)
CPU unswizzle, ns a KB, in the loads 301 (290 to 357) 362 (355 to 386) +17 % 0.0006
CPU unswizzle, ns a KB, steady play 242 (237 to 261) 351 (236 to 500) +46 % 0.0016
CPU unswizzle, ms a frame, steady play 0.041 0.058 about +0.016 ms -
calm-stretch game_ms 11.37 (11.11 to 12.40) 11.46 (10.86 to 11.91) -0.7 % 0.70
main_blocked_ms 9.12 (8.97 to 9.74) 9.18 (8.87 to 9.46) -0.6 % 0.67
frames a second 79.3 (69.8 to 81.9) 77.6 (72.1 to 81.9) -0.3 % 0.91
p99 frame time, ms 21.9 (18.6 to 44.3) 26.7 (19.5 to 33.9) +7.3 % 0.67
frames of 50 ms or more, all runs 31 32 - 0.84
a frame's replay time (ms): submit 7.56 (7.36 to 7.88) 7.48 (7.29 to 7.64) -1.5 % 0.15

Of the two causes this table left open (the kernel, or the build), the like-for-like run below settles it: it was the
kernel. With one build and only a switch between the arms, the unchanged fast path is level, and the fallback is slower
with the kernel.

Like for like (held job fb-g2136-sw, 09:3x to 10:33 UTC on 2026-11-23): one runtime, rt-atx-sw. It is d6313013
plus two commits of a diagnostic build, local and never pushed: one counts the three kernels' calls, the other adds a
switch, LONGSHOT_DIAG_TEX_C=1, that sends the three call sites back to the C they replaced (suyu's UnswizzleTexture
and SwizzleTexture, the widening loop) and times the fallback unswizzle and the swizzle on their own. Hyrule Field, 60 s
a run, a warm-up a side, then the C and the kernels interleaved, 8 runs a side, every run at create, the output pinned at
2560x1440 on a desktop at 800x600 at 30 Hz. Two short shader-load waits wrote strike files: the kernels' warm-up 578 ms and
its run on3 1,340 ms. Both were moved out, neither reached 2 s, and on3 is kept (both p values are given where it
matters). The figures are from the diagnostic line: the loads are everything before its last 30 lines, steady play the
last 30 (3,600 frames).

a side: median (range) C (LONGSHOT_DIAG_TEX_C=1), 8 runs the kernels (unset), 8 runs change of the means p (swap test)
fallback unswizzle, ms a MB, in the loads 0.450 (0.348 to 0.578) 0.505 (0.477 to 0.595) +14.5 % 0.037
its work in the loads: calls / MB / KB a call 18,140 / 299 / 16.9 18,150 / 291 / 16.8 - 0.84 / 0.69 / 0.72
fallback unswizzle, ms a MB, steady play 0.282 (0.236 to 0.305) 0.484 (0.336 to 0.695) +64 % < 0.0001
its work in steady play: MB / KB a call 258 / 155 361 / 210 - 0.13 / 0.22
write-back swizzle, ms a MB (570 calls, 12.4 MB a run, all in the loads) 0.230 (0.153 to 0.656) 0.112 (0.099 to 0.122) -60 % < 0.0001
the unchanged tile fast path, ms a MB, steady play / loads 0.238 / 0.359 0.239 / 0.347 -0.2 % / +2.9 % 0.95 / 0.54
calm-stretch game_ms 11.47 (11.24 to 12.04) 11.88 (11.48 to 12.38) +2.9 % 0.033 (0.066 without on3)
main_blocked_ms 9.12 (9.09 to 9.65) 9.41 (9.15 to 9.77) +1.9 % 0.11
frames a second 78.6 (72.0 to 79.4) 76.0 (69.7 to 78.3) -3.0 % 0.14
memory sync, ms a frame 0.64 (0.61 to 0.68) 0.66 (0.63 to 0.68) +3.3 % 0.063
p99 frame time, ms / frames of 50 ms or more 25.7 / 56 27.3 / 69 - 0.60 / 0.43

In steady play the kernel runs streamed more and in bigger calls, which a vector kernel should handle better, so the
work's difference does not explain the loss. The calm game time's +2.9 % is not explained and is not the unswizzle: the
kernel's extra unswizzle time in steady play is about 0.03 ms a frame, against 0.4 ms. Each run's calm game time does not
follow how much it streamed (r = 0.01 against the MB unswizzled in steady play, which ran from 229 to 917 MB a run). It
is one figure of 14 at p 0.033, and 0.066 without on3.

Risks

What could break: a texel put in the wrong place would show as a scrambled or shifted texture, in a write-back the
game reads back, or in a widened RGB texture; the test checks the swizzle against suyu's reference
built from its source for every bytes per block, sizes across and off a GOB, block heights 0-5 and 3D depths, ending
at a guard page. A revert is enough. Renderer
files: the runtime is rebuilt; nothing changes for players' saves, options or caches.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Screenshots of the same spot on main and here, for a change that shows on screen.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary Write-backs of block-linear textures are swizzled by suyu's C (`SwizzleTexture` in `flush_finish`), and 3-, 6- and 12-byte texels are widened to four channels with an alpha in a C loop (`widen_rows`), both in `gpu/vk/vk_texture.cpp`. This adds `gpu/vk/asm/texture.S` on the asm kit: `lsasm_swizzle` (suyu's at `stride_alignment` 0, with the Switch 2 GOB, a line copied 16-byte sector by sector, a sector being whole in both layouts) and `lsasm_widen_rows` (alpha 0xFF, half 1.0 or float 1.0), AVX2 and SSE2 bodies. `flush_finish`'s write-back swizzle calls `lsasm_swizzle`, and `widen_rows` gives the three alphas the kernel writes to `lsasm_widen_rows`; every other widening (SNORM, UNORM16, the integer ones) stays in its loop. The write-back swizzle was called with `stride_alignment` 1 and the kernel is 0's: the same layout for every bytes per block a write-back has (1, 2, 4, 8, 16; `flushable()` keeps the widened formats out), as the test shows. The result expected: the same texels, those write-backs and widenings faster. The upload's unswizzle stays suyu's C. This pull request had a kernel for it too (`lsasm_unswizzle`, up to d6313013); in play it was slower than the C on the game's shapes (Measurements), so it is dropped and `unswizzle_upload` is as on main. No switch: the kernels stand for suyu's C and the widening loop at those two calls, the same bytes. From 971f8074 on `exp/x86-asm-sync` (its fix of the upload's own `stride_alignment` is main's already: #1603). Depends on #1947 (the asm kit, which now carries the GPU-visible ranges' sort, `lsasm_sort_ranges`): its commits show in this diff until #1947 merges. Not the same change as #925 (jcabarca's, open): it sends sparse textures from the GPU unswizzle to the CPU path; this one changes the CPU path's write-back swizzle and widening, and the two merge cleanly. Read first: `gpu/vk/asm/texture.S`, then `flush_finish` and `widen_rows` in `gpu/vk/vk_texture.cpp`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23 (`CC`/`CXX`, `RX_CPM` set); head a360ac98 on #1947's head 186fdb85 (the asm kit, on main 9dd41326). Through the PC's job queue (build job `fb-2136n`), each run in a hidden console, `tests/run_all.py --strict --exact`: the change's own checks and the kit's (log `2136n-head-own`): `test_asm_texture.py`, `test_texture_tile_upload.py`, `test_widen_alpha.py`, `test_asm_abi.py`, `test_asm_build.py`, `test_asm_kit.py` pass (6 of 6). `test_texture_tile_upload.py` at the test commit 3f5be891, before the fix, fails as it should: `Assertion failed: Tegra::Texture::fallback_calls == before + ...` (log `2136n-tile-test`). `--changed 186fdb85` (log `2136n-head-changed`): 74 checks, 64 pass, 2 skip, 8 fail, the same 8 that fail on #1947's head (at cffa2f46, logs `t-AsmCut5-base-kit-changed` and `t-AsmCut5-base-kit-more`; 186fdb85 changes only `tests/test_asm_build.py`): `test_linux_pressure.py`, `test_low_vram_texture_mips.py`, `test_pass_barrier.py`, `test_readback_timeout_source.py`, `test_staging_burst.py`, `test_target_reuse_memory.py`, `test_texel_buffer_ownership.py`, `test_ub_update_batch.py`. It has run in the game on this PC as the two arms of the like-for-like run in Measurements (held job `fb-g2136-sw`, Hyrule Field, 16 runs and two warm-ups: this head's unswizzle is that run's C arm, its swizzle and widening its kernel arm), and d6313013 in `fb-g2136` (19 runs), with no FATAL, device lost or Vulkan error in any run. **Still to test:** - A scene whose textures reach the widening: RGB8 UNORM, RGB16 float or RGB32 float textures widened with an alpha (the only ones `lsasm_widen_rows` takes). Hyrule Field has none; such a scene is not yet found (by hand) - Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: Kokiri Forest, then Hyrule Field, three minutes each, on #1947's head and on this PR, warmed and interleaved, expecting the same picture and frame times within the runs' spread or better on this PR (@Beanstalk linux+nvidia, linux+amd, windows+amd, windows+intel, steamdeck: Kokiri Forest and Hyrule Field three minutes each, #1947's head against this PR, warmed and interleaved, frame times and screenshots) - Linux: `python3 -I -B tests/test_asm_texture.py --cxx g++` and `--cxx clang++`, expecting PASS (by hand) ## Measurements **Verdict:** the write-back swizzle kernel about 2 times faster in play, in the loads: 0.230 against 0.112 ms a MB (p < 0.0001), about 1.4 ms over a run (Hyrule Field, one runtime, like for like, at an 800x600 desktop with the output pinned at 2560x1440, below). The widening kernel was not reached in play so far: the textures that would call it are RGB8 UNORM, RGB16 float and RGB32 float ones widened with an alpha, and Hyrule Field has none. Nothing is shown in frame time. No new game run is needed for this head: its unswizzle is the C arm and its swizzle the kernel arm of `fb-g2136-sw` (below). The micro-benchmark (authored input) has the write-back swizzle 1.21-3.13× faster and the RGB widening 4.8-9.5× in the SSE2 build and 6.5-28.6× in the AVX2 build. The unswizzle kernel this pull request had up to d6313013 is dropped: in the same run it was slower than suyu's C where the game uses it, by 14.5 % a MB in the loads (p = 0.037, matched work) and 64 % in steady play (p < 0.0001). A micro-benchmark of it on play's sizes (the same script, its cases replaced: partial tiles of about 17 KB, 4 and 16 bytes a block, a 16 KB 3D level, and 160-192 KB partial tiles and 3D levels; source bytes warm in the caches, run in the queue beside builds on 2026-11-23) still had it 1.10-3.44× faster than suyu's C, so the loss in play is not the surfaces' shapes alone; what it is (cold source bytes from guest memory, the upload's destination) is not known. Its rows stay in the table below as measured. **Baseline:** the C this PR replaces, as #1947's head has it (cffa2f46 for every run below; 186fdb85 now, the kit's code the same: the asm kit on main 9dd41326, which this PR depends on), not main itself. The micro-benchmark: suyu's `UnswizzleTexture(..., 0)` and `SwizzleTexture(..., 1)` (as `unswizzle_upload` and `flush_finish` call them at cffa2f46; suyu's `decoders.cpp`, the same at both commits, built at the arm's level) and `widen_rows`' loop cut from `gpu/vk/vk_texture.cpp` at cffa2f46, against `lsasm_unswizzle` and `lsasm_swizzle` called as d6313013 called them and its `widen_rows` (`lsasm_widen_rows`); 16 MB of authored texel bytes; the swizzle's destination filled with what is there first, untimed. A script on this PC, not in this PR (`asm_texture_bench.py`, PrTrials' `trials/tools/bench`), run alone in the PC's job queue on 2026-11-22: 3 rounds of 201 repetitions per case and arm, i7-9700, llvm-mingw clang 23.1.5 `-O2 -ffp-contract=off`, arms SSE2 (`-march=x86-64`) and AVX2 (`-march=x86-64-v3`, what the release builds the back end for). The arms take turns at going first; their outputs were compared at every repetition and were equal. Each cell: the median of the three rounds' medians, [lowest–highest round median], in ns per block or texel. Change: before ÷ after (above 1: this PR faster). | Surface or rows, arm | Before: suyu's C, widen loop @ cffa2f46 | After: this PR @ d6313013 (its head then) | Change | |---|---|---|---| | unswizzle, 3D 64x64x16, 4 B a block, block height 3, depth 4, SSE2 | 0.227 [0.227–0.230] | 0.168 [0.166–0.169] | 1.35× | | unswizzle, 3D 64x64x16, 4 B a block, block height 3, depth 4, AVX2 | 0.214 [0.212–0.224] | 0.168 [0.166–0.171] | 1.27× | | unswizzle, 3D 32x32x32, 8 B, 2/5, SSE2 | 0.455 [0.455–0.461] | 0.333 [0.333–0.336] | 1.37× | | unswizzle, 3D 32x32x32, 8 B, 2/5, AVX2 | 0.436 [0.427–0.464] | 0.342 [0.336–0.345] | 1.28× | | unswizzle, partial tiles 100x75, 4 B, 4, SSE2 | 0.187 [0.187–0.200] | 0.147 [0.147–0.147] | 1.27× | | unswizzle, partial tiles 100x75, 4 B, 4, AVX2 | 0.173 [0.173–0.173] | 0.133 [0.133–0.133] | 1.30× | | unswizzle, partial tiles, BC 40x30 blocks, 16 B, 2 (4 a repetition), SSE2 | 0.729 [0.708–0.729] | 0.479 [0.479–0.500] | 1.52× | | unswizzle, partial tiles, BC 40x30 blocks, 16 B, 2 (4 a repetition), AVX2 | 0.646 [0.646–0.646] | 0.479 [0.479–0.479] | 1.35× | | unswizzle, 1024x1024, 4 B, 4 (whole tiles), SSE2 | 0.444 [0.425–0.456] | 0.303 [0.298–0.305] | 1.47× | | unswizzle, 1024x1024, 4 B, 4 (whole tiles), AVX2 | 0.450 [0.435–0.455] | 0.219 [0.219–0.222] | 2.05× | | unswizzle, a 4x4-block mip, 16 B, 0 (1,024), SSE2 | 1.82 [1.82–1.82] | 0.897 [0.897–0.897] | 2.03× | | unswizzle, a 4x4-block mip, 16 B, 0 (1,024), AVX2 | 1.82 [1.82–1.85] | 0.757 [0.757–0.757] | 2.40× | | swizzle (write-back), 256x256, 4 B, 4, SSE2 | 0.439 [0.439–0.441] | 0.140 [0.140–0.143] | 3.13× | | swizzle (write-back), 256x256, 4 B, 4, AVX2 | 0.438 [0.435–0.438] | 0.180 [0.171–0.182] | 2.43× | | swizzle, 1280x720, 8 B, 4, SSE2 | 1.43 [1.43–1.46] | 0.742 [0.737–0.744] | 1.93× | | swizzle, 1280x720, 8 B, 4, AVX2 | 1.44 [1.42–1.44] | 0.730 [0.720–0.731] | 1.97× | | swizzle, 100x60, 4 B, 3 (2), SSE2 | 0.200 [0.200–0.200] | 0.125 [0.125–0.125] | 1.60× | | swizzle, 100x60, 4 B, 3 (2), AVX2 | 0.192 [0.183–0.192] | 0.150 [0.150–0.150] | 1.28× | | swizzle, an 8x8 mip, 4 B, 0 (1,024), SSE2 | 0.580 [0.580–0.584] | 0.412 [0.410–0.414] | 1.41× | | swizzle, an 8x8 mip, 4 B, 0 (1,024), AVX2 | 0.528 [0.528–0.533] | 0.436 [0.436–0.439] | 1.21× | | widen 3 to 4 bytes (UNORM8), 65,536 texels, SSE2 | 3.24 [3.24–3.24] | 0.342 [0.342–0.342] | 9.48× | | widen 3 to 4 bytes (UNORM8), 65,536 texels, AVX2 | 3.62 [3.62–3.63] | 0.127 [0.125–0.127] | 28.61× | | widen 6 to 8 (half), 65,536, SSE2 | 3.24 [3.24–3.24] | 0.673 [0.673–0.674] | 4.82× | | widen 6 to 8 (half), 65,536, AVX2 | 3.58 [3.57–3.58] | 0.255 [0.250–0.259] | 14.03× | | widen 12 to 16 (float), 65,536, SSE2 | 3.25 [3.25–3.25] | 0.601 [0.597–0.609] | 5.40× | | widen 12 to 16 (float), 65,536, AVX2 | 3.60 [3.58–3.64] | 0.523 [0.514–0.539] | 6.88× | | widen 3 to 4, 16 texels (4,096), SSE2 | 3.65 [3.65–3.65] | 0.511 [0.507–0.513] | 7.15× | | widen 3 to 4, 16 texels (4,096), AVX2 | 4.08 [4.08–4.08] | 0.627 [0.627–0.629] | 6.51× | **In play** (held job `fb-g2136`, 07:15 to 08:05 UTC on 2026-11-23): Hyrule Field, chosen because it has the most CPU unswizzling of the scenes on disk. 60 s a run. The two builds are the head then, d6313013 (`rt-atx-d6313013`) and its parent, the asm kit cffa2f46 (`rt-kit-cffa2f46`): a warm-up each, then kit and head interleaved (kit head head kit, four times), every run loading at create. The output was pinned at 2560x1440, on a desktop at 800x600 at 30 Hz (the PC's only screen then); the runs are alike among themselves. One kit run (base12) is held: in it the game's first uses waited 2,188 ms in all for shader loads (the longest wait 585 ms), so it wrote the load marker into the kit's runtime. The marker was moved out before the next run, and every later run logged loading at create. That leaves 7 kit runs against 8 head runs. Reach, from a diagnostic build of d6313013 that is local and never pushed (one uncounted run in this scene, counters beside the 120-frame unswizzle line): over about 12,840 frames, `lsasm_unswizzle` was called 19,895 times (528.6 MB), `lsasm_swizzle` 570 times (12.4 MB) and `lsasm_widen_rows` never. - In the loads (the 9,240 frames before the measured stretch): unswizzle about 2 calls a frame (363.7 MB in all), and every one of the 570 swizzles. - In steady play (the last 3,600 frames): unswizzle 0.48 calls a frame (0.046 MB a frame), no swizzle. - The widening kernel was not reached in Hyrule Field (Still to test). What the line counts: main's `vk: a frame: X MB unswizzled on the CPU in Y ms` times all of a frame's CPU unswizzling, the unchanged tile fast path (`texture_tiles.h`) together with the fallback d6313013's kernel replaced. The kernel carries about a third of those bytes in steady play and about 40 % in the loads. So the figures below are the whole stage, not the kernel's own; they cannot be read as the kernel's speed. | a side: median (range) | Before: the kit @ cffa2f46, 7 runs | After: this PR @ d6313013 (its head then), 8 runs | change of the means | p (swap test) | |---|---|---|---|---| | CPU unswizzle, ns a KB, in the loads | 301 (290 to 357) | 362 (355 to 386) | +17 % | 0.0006 | | CPU unswizzle, ns a KB, steady play | 242 (237 to 261) | 351 (236 to 500) | +46 % | 0.0016 | | CPU unswizzle, ms a frame, steady play | 0.041 | 0.058 | about +0.016 ms | - | | calm-stretch game_ms | 11.37 (11.11 to 12.40) | 11.46 (10.86 to 11.91) | -0.7 % | 0.70 | | main_blocked_ms | 9.12 (8.97 to 9.74) | 9.18 (8.87 to 9.46) | -0.6 % | 0.67 | | frames a second | 79.3 (69.8 to 81.9) | 77.6 (72.1 to 81.9) | -0.3 % | 0.91 | | p99 frame time, ms | 21.9 (18.6 to 44.3) | 26.7 (19.5 to 33.9) | +7.3 % | 0.67 | | frames of 50 ms or more, all runs | 31 | 32 | - | 0.84 | | `a frame's replay time (ms)`: submit | 7.56 (7.36 to 7.88) | 7.48 (7.29 to 7.64) | -1.5 % | 0.15 | Of the two causes this table left open (the kernel, or the build), the like-for-like run below settles it: it was the kernel. With one build and only a switch between the arms, the unchanged fast path is level, and the fallback is slower with the kernel. **Like for like** (held job `fb-g2136-sw`, 09:3x to 10:33 UTC on 2026-11-23): one runtime, `rt-atx-sw`. It is d6313013 plus two commits of a diagnostic build, local and never pushed: one counts the three kernels' calls, the other adds a switch, `LONGSHOT_DIAG_TEX_C=1`, that sends the three call sites back to the C they replaced (suyu's `UnswizzleTexture` and `SwizzleTexture`, the widening loop) and times the fallback unswizzle and the swizzle on their own. Hyrule Field, 60 s a run, a warm-up a side, then the C and the kernels interleaved, 8 runs a side, every run at create, the output pinned at 2560x1440 on a desktop at 800x600 at 30 Hz. Two short shader-load waits wrote strike files: the kernels' warm-up 578 ms and its run on3 1,340 ms. Both were moved out, neither reached 2 s, and on3 is kept (both p values are given where it matters). The figures are from the diagnostic line: the loads are everything before its last 30 lines, steady play the last 30 (3,600 frames). | a side: median (range) | C (`LONGSHOT_DIAG_TEX_C=1`), 8 runs | the kernels (unset), 8 runs | change of the means | p (swap test) | |---|---|---|---|---| | fallback unswizzle, ms a MB, in the loads | 0.450 (0.348 to 0.578) | 0.505 (0.477 to 0.595) | +14.5 % | 0.037 | | its work in the loads: calls / MB / KB a call | 18,140 / 299 / 16.9 | 18,150 / 291 / 16.8 | - | 0.84 / 0.69 / 0.72 | | fallback unswizzle, ms a MB, steady play | 0.282 (0.236 to 0.305) | 0.484 (0.336 to 0.695) | +64 % | < 0.0001 | | its work in steady play: MB / KB a call | 258 / 155 | 361 / 210 | - | 0.13 / 0.22 | | write-back swizzle, ms a MB (570 calls, 12.4 MB a run, all in the loads) | 0.230 (0.153 to 0.656) | 0.112 (0.099 to 0.122) | -60 % | < 0.0001 | | the unchanged tile fast path, ms a MB, steady play / loads | 0.238 / 0.359 | 0.239 / 0.347 | -0.2 % / +2.9 % | 0.95 / 0.54 | | calm-stretch game_ms | 11.47 (11.24 to 12.04) | 11.88 (11.48 to 12.38) | +2.9 % | 0.033 (0.066 without on3) | | main_blocked_ms | 9.12 (9.09 to 9.65) | 9.41 (9.15 to 9.77) | +1.9 % | 0.11 | | frames a second | 78.6 (72.0 to 79.4) | 76.0 (69.7 to 78.3) | -3.0 % | 0.14 | | memory sync, ms a frame | 0.64 (0.61 to 0.68) | 0.66 (0.63 to 0.68) | +3.3 % | 0.063 | | p99 frame time, ms / frames of 50 ms or more | 25.7 / 56 | 27.3 / 69 | - | 0.60 / 0.43 | In steady play the kernel runs streamed more and in bigger calls, which a vector kernel should handle better, so the work's difference does not explain the loss. The calm game time's +2.9 % is not explained and is not the unswizzle: the kernel's extra unswizzle time in steady play is about 0.03 ms a frame, against 0.4 ms. Each run's calm game time does not follow how much it streamed (r = 0.01 against the MB unswizzled in steady play, which ran from 229 to 917 MB a run). It is one figure of 14 at p 0.033, and 0.066 without on3. ## Risks What could break: a texel put in the wrong place would show as a scrambled or shifted texture, in a write-back the game reads back, or in a widened RGB texture; the test checks the swizzle against suyu's reference built from its source for every bytes per block, sizes across and off a GOB, block heights 0-5 and 3D depths, ending at a guard page. A revert is enough. Renderer files: the runtime is rebuilt; nothing changes for players' saves, options or caches. ## Checklist ### Ready for review - [ ] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [ ] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Screenshots of the same spot on `main` and here, for a change that shows on screen. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
The ground the hand-written kernels stand on, without any kernel yet:

- gpu/asm/lsasm.h: a kernel is written once, in Intel syntax against the System V registers; the macros make the
  Win64 convention with its SEH unwind data on Windows (an epilogue laid out as Windows' unwinder recognises one:
  the vzeroupper and the frees before the pops) and the DWARF CFI on Linux, and LSASM_ABI for the declarations.
- tests/asm_kit.py: a kernel's check builds its fixture with the kernels at SSE2 and AVX2 (where the CPU has it),
  on Windows also the System V body through sysv_abi, and assembles every kernel with clang for ELF and COFF.
- tests/test_asm_abi.py with tests/asm_abi_probe.S: probes that use every part of the frame: six arguments arrive,
  every callee-saved register comes back, a fault inside one unwinds to the caller (Windows), and every single step
  of each probe is unwound by Windows' own unwinder to its caller.
- nx2/build.py asm_jobs: every .S of host/asm goes into the game, of gpu/vk/asm into the renderer, of gpu/asm into
  both, preprocessed with the build's CPU flags and keyed by the headers beside them and lsasm.h. No folder, no job.
- scripts/devtools/packs.py takes a .S as a source (it shows in its module's objects) and nx2/version.py counts it in
  the sources' fingerprint.
- tests/test_asm_build.py, tests/test_dev_packs.py: the jobs, their keys, the fingerprint and the packs' rules.

Assisted-by: Claude Code
tests/asm_abi_probe.S has three more probes that return rsp modulo 16 in their body: scratch alone, one push and
scratch, two pushes and the xmm saves, an even and an odd count of pushes in both conventions (Win64's LSASM_ARGS
pushes two). Win64 asks a function with a frame to keep rsp 16-byte aligned in its body, and LSASM_ALLOC's scratch
at [rsp] is aligned only so. On Windows each is stepped and unwound as the others are. tests/test_asm_abi.py also
assembles a kernel with LSASM_ALLOC 3072 (it must assemble) and 4096 (a page and a push: it must stop the assembly,
as the macros probe no stack page and its first store could skip Windows' guard page).

Both fail on this commit: lsasm.h leaves rsp at 8 modulo 16 with an even count of pushes, and takes any scratch size.

Assisted-by: Claude Code
Win64 asks a function with a frame to keep rsp 16-byte aligned in its body, and the macros did not: with an even
count of pushes (LSASM_ARGS's two included) the body ran at 8 modulo 16, so an aligned store to LSASM_ALLOC's
scratch could fault. The macros now count the pushes and take 8 bytes more below them where the count leaves rsp
misaligned, before the first xmm save or scratch (or at the prologue's end), in the SEH codes and the CFI alike; the
epilogue gives them back with its one add (Windows) or at the first pop (Linux). A push after the xmm saves or the
scratch stops the assembly, as the padding could not count it.

The macros probe no stack page, so a frame of more than a page could skip Windows' guard page with its first store:
LSASM_END_PROLOGUE stops the assembly of a frame (pushes, padding, xmm saves and scratch) over 4096 bytes.

The header also says what LSASM_ARGS maps: six integer or pointer arguments; a float argument is in another register
in each convention. The fifth and sixth stay loaded on every call: their slots lie inside the caller's own frame.

Assisted-by: Claude Code
tests/test_asm_build.py checks the kernels' object keys as compile_one names them: a header renamed with its contents or
removed changes the key (a clean compile of the kernel would fail), a .inc edit changes it, and a kernel whose depfile
exists is keyed by the headers it names (an edit to another header keeps it). A gpu/asm kernel's second job publishing
the same key after the first must leave the first job's object (the cache entry is a hard link to it) as it was. A
renderer file whose depfile names a gpu/asm declaration is keyed by it, through main()'s own vdeps_roots statement.

They fail on this commit: the key joins the folders' .h contents alone, cache_put copies over an entry that
os.link found there, and the renderer's roots leave gpu/asm out.

Assisted-by: Claude Code
asm_jobs keyed a kernel's object by the .h contents of its folder and gpu/asm joined: a header renamed with its
contents kept an object a clean compile no longer makes, and a .inc edit was not seen. A kernel is now compiled with
-MD and keyed as the host's and the back end's own files are (renderer_deps, DEPFILE_JOBS, rekey_depfiles): by the
names and contents of the headers its last compile read under its folder and gpu/asm, or by every header of the two
folders (tree_headers) before it has a depfile.

A gpu/asm kernel is compiled for each module with one key, and on a cold build both jobs could publish it: the second's
os.link failed on the first's entry, and its copyfile then wrote into that entry, a hard link to the first job's object.
cache_put leaves an entry it finds (FileExistsError), and a copy across volumes goes in whole by a rename.

The back end's own objects are keyed by gpu/asm's headers too (vdeps_roots), so a Vulkan caller of a shared kernel
compiles again when the kernel's declaration changes.

Assisted-by: Claude Code
tests/test_appimage_source_headers.py runs the AppImage script's copy block and checks that every file of gpu/asm
(lsasm.h, which every kernel includes) is carried and that every kernel's includes are, for host/asm, gpu/asm and
gpu/vk/asm (gpu/vk itself is copied whole after the block). tests/test_dev_packs.py routes the three kernel folders: a
host/asm kernel is the game's alone, so its pack builds the game without the renderer (renderer_untouched), a gpu/vk/asm
kernel builds the renderer alone, a gpu/asm kernel both.

They fail on this commit: the AppImage copies host/ and gpu/vk but not gpu/asm (a player's build with a host/asm kernel
stops listing it), and renderer_untouched takes only a host/ .c for the game's alone.

Assisted-by: Claude Code
scripts/linux/appimage.sh copied host/ and gpu/vk whole but not gpu/asm: a player's build with a host/asm kernel
stopped at asm_jobs listing the missing folder, and a gpu/asm kernel was left out of both modules. The source-copy
block now carries gpu/asm whole; tests/test_appimage_headers.py takes it for a host include of a kernel's declaration.

scripts/devtools/packs.py renderer_untouched took a host/ .c alone for the game's: a pack whose change was a host/asm
kernel, which only the game links, built and linked the renderer again. A host/asm .S is the game's alone now; a
header beside it, a gpu/asm kernel and a gpu/vk/asm kernel still build the renderer.

Assisted-by: Claude Code
tests/test_asm_kit.py records the commands tests/asm_kit.py would run, with no compiler: its CPU probe must read the
whole x86-64-v3 level (leaf 7, the extended leaf's LZCNT, the OS's ymm state through xgetbv) and a probe that crashed
must fail the check rather than read as a CPU without AVX2; two kernels of one name in two folders must be two
objects, natively and in the cross assembly, each linked once; a run with no clang found must fail instead of skipping
the cross assembly, an explicit clang must be the one used, and tests/test_asm_abi.py must take CXX without --cxx.

They fail on this commit: the probe reads AVX2, BMI2 and FMA alone and counts any exit but 0 as no AVX2, the objects
are named by the source's stem, a run without clang skips the cross assembly, and --cxx defaults to g++.

Assisted-by: Claude Code
tests/asm_kit.py ran the x86-64-v3 fixture where the CPU had AVX2, BMI2 and FMA, but a VM can mask MOVBE or LZCNT,
which the compiler emits at that level, and any exit of the probe but 0 read as no AVX2, a crash too. Its probe, built
for the baseline, now reads the whole level from CPUID (leaf 1, leaf 7, the extended leaf) and the OS's ymm state
(xgetbv), and an exit other than 0 or 1 fails the check.

The objects were named by the source's stem, so gpu/asm/hash.S and gpu/vk/asm/hash.S wrote one object and linked it
twice: each source's index is in its name now, natively and in the cross assembly.

Without clang on PATH the cross assembly (clang's assembler, the build's, for ELF and COFF) was skipped without a word,
and a CPU without AVX2 was then told its AVX2 bodies had been assembled. The clang is now the one given (--clang in
tests/test_asm_abi.py), else the one beside the compiler, else the one on PATH, and without one the check fails; its
PASS line names it. tests/test_asm_abi.py takes CXX when --cxx is not given. The unused os import is gone (Ruff F401).

Assisted-by: Claude Code
tests/test_asm_abi.py left the DWARF CFI unconsumed: removing the CFA adjustment after LSASM_ALLOC kept Linux green. A
Linux probe now stops in its body, with its scratch and padding in place, and calls the fixture, which unwinds from
there with the system's unwinder (_Unwind_Backtrace): the probe's frame must return to the harness's call, with rbx,
rbp and r12-r15 as the harness set them. A probe reads a table in LSASM_RODATA RIP-relative, so that macro is
assembled (ELF and COFF) and run.

On Windows each single step's unwind is now compared with the whole nonvolatile state of the entry: rsi, rdi and
xmm6-xmm15 as well in Win64, not the six other GPRs alone. A fault in a kernel is also taken by Windows' own dispatch
to a caller's __except, built with the game's -fms-extensions as guarded_copy is (clang; a gcc build says it skipped
this), besides the vectored handler that unwinds the one frame by hand.

Assisted-by: Claude Code
tests/asm_abi_probe.S calls a kernel of one argument on a stack that ends at its 32-byte home area, all a one-argument
Win64 call owes its callee, with the page above it left unreadable (tests/test_asm_abi.py, before any handler is set):
lsasm_probe_clobber and lsasm_probe_table must return their results there.

It fails on this commit: LSASM_ARGS reads the fifth and sixth slots on every call, so the first read lands in the
unreadable page.

Assisted-by: Claude Code
On Win64 LSASM_ARGS loaded the fifth and sixth arguments from the caller's stack on every call. A call of fewer owes
its callee the 32-byte home area alone, so the slots above it can lie past the stack's top. LSASM_ARGS now takes the
kernel's count of arguments (0 to 6; another count stops the assembly) and moves or loads only those: a one-argument
kernel reads no stack slot. The header says the mapping is for integer and pointer arguments; the probes give their
counts (6 for lsasm_probe_args, 1 for the others).

Assisted-by: Claude Code
tests/test_asm_build.py looked for asm_jobs' calls in main()'s text: it passed if a guard kept a call from running or
its jobs from a link list. main() now plans through plan_modules (nx2/build.py): the game's other jobs and the
renderer's in, the kernels joined (host/asm's and gpu/asm's to the game when it compiles the runtime, gpu/vk/asm's and
gpu/asm's to the renderer when it is built), RX_VK_ONLY's renderer-only jobs, and out the jobs and the two link lists
objs.rsp and vk_objs.rsp are written from. The build is the same as before; the kernels' jobs come after the game's
other jobs instead of after the runtime's files.

The test runs it on synthetic sources (two kernels in host/asm, one in gpu/asm, one of the same name in gpu/vk/asm)
and checks the compiled jobs and both modules' link inputs in full for a full build, a game-only build (no renderer
folder, as main() passes for RX_GAME_ONLY) and a renderer-only build (RX_VK_ONLY), and that main() plans and links
through it. tests/test_link_skip.py, test_renderer_depfiles.py and test_third_party_objects.py anchor on the planner's
line now, the lines they named being gone. docs/dev/reference/build.md names it.

Assisted-by: Claude Code
Importing nx2/build.py took the machine's build settings: RX_MARCH=native, or a CPU with x86-64-v3 and no RX_MARCH,
has clang say what -march=native is while the module loads, and RX_MARCH=native with no working clang stopped the
import before unittest started, in a check that says it runs no compiler. The test now imports it with the build's own
variables (RX_*, LONGSHOT_*, OOT_*) cleared and RX_MARCH=x86-64-v3, and with subprocess.Popen and os.system failing
while it loads: a process started by the import fails it instead of running. A test checks the CPU flags are the
fixed level's.

Assisted-by: Claude Code
hos_gpu_guest_ranges (host/nvdrv.c) sorts every GPU mapping's and native NVN pool's guest range by start before it
merges them, each time the mappings change: qsort with a comparison function call per compare. On x86-64 it now sorts
with host/asm/ranges.S's lsasm_sort_ranges, a hand-written merge sort on gpu/asm/lsasm.h: runs of 16 pairs by
insertion, then merges of runs twice as long a pass between the list and a second one (kept beside merged, grown with
it); two runs already in order (the mappings come mostly in address order) are copied, not merged, and the merge picks
its side with cmov, no branch. One body for both CPU levels: the pairs move in xmm registers. Other CPUs keep qsort
with cmp_range, under #if defined(__x86_64__). Both lists grow through hos_xrealloc (an allocation refused for 5 s
ends the run with the out-of-memory notice), where realloc's NULL was used as the list before.

It is stable where qsort is not: ranges that start together come out of qsort in any order, and the merge after the
sort makes the same ranges from any such order (one starts the merged range, the others only reach to their ends), so
the result is the same. No switch: the ranges merged are the same.

From 971f8074 on exp/x86-asm-sync, where the sort was collect.S's second kernel; here it is its own file. A
micro-benchmark there (i7-9700) found the kernel faster than qsort, more so in near order; not measured on this commit,
nor in play.

Test: tests/test_asm_ranges.py, through tests/asm_kit.py at SSE2 and AVX2, both conventions, clang ELF/COFF assembly:
the kernel against qsort with cmp_range (cut from the source) for 22 sizes around its runs and merges up to 10000 pairs
and 8 key patterns, between faulting pages: same order, stable, and hos_gpu_guest_ranges' merge makes the same ranges
from either order. The whole hos_gpu_guest_ranges, cut from the source, is compiled with its x86-64 test taken both
ways: the two give the same ranges for every case, one sorting with the kernel and the other with qsort, once a call.
scripts/profiling/cpu_functions.json describes lsasm_sort_ranges, and cmp_range as the other CPUs' comparison.

Assisted-by: Claude Code
The review asked for one shared kernel and one private kernel per module through a cold build, a cached rebuild after
an included file's rename, developer packs and the Linux AppImage's staging. tests/test_asm_end_to_end.py authors them
in a tree of its own (gpu/asm/e2e.S, host/asm/game.S, gpu/vk/asm/vk.S, each with an include, on the real lsasm.h) and
runs the build's own code on them with clang: plan_modules, plan_jobs with the hash record a build loads and saves,
compile_one on four threads (the shared kernel's two jobs at once), rekey_depfiles and main()'s own statements that
write the link lists. Each module's link list is linked with a caller and run, where this CPU runs x86-64-v3.

- a cold build compiles every kernel; a second build compiles nothing, nor does a new work folder made from its
  object cache (packs.link_objects), whose modules are the first's (module_changed);
- an include renamed while its kernel still names it compiles that kernel again and fails, as a clean build would; with
  the kernel naming the new file it compiles again, alone of the kernels;
- an include's edit compiles the kernels that read it, and its revert compiles nothing and links the cold build's
  objects, unchanged;
- packs one after another on one base (route, link_inputs_changed, renderer_untouched, link_objects, module_changed as
  cmd_pack runs them): a game kernel builds the game alone, a renderer kernel the renderer alone, a shared one both;
  each compiles the kernels that changed, and the base's objects and cache stay as they were;
- the AppImage's source-copy block, run with bash on the tree, carries the kernels and their includes, and a cold
  build of the staged tree compiles and links them.

nx2/build.py is imported as tests/test_asm_build.py imports it. The compiler is --cxx (CXX, else g++), clang beside it
(tests/asm_kit.py find_clang). The staging check needs bash: Git for Windows' on Windows, else it is skipped.

Assisted-by: Claude Code
compile_one hard-links each object into the object cache (cache_put), and links an object from the cache the same way;
a pack's work folder links the base's cache too (scripts/devtools/packs.py link_objects). clang's assembler, which
compiles the hand-written kernels (asm_jobs), writes its output in place (cc1as opens the -o path itself; clang's C and
C++ compiles write a temporary file and rename it over the object). A kernel compiled again therefore wrote through the
link: the cache's entry under the old key became the new object, and in a pack's work folder the base's cache entry and
its object did too. A build back at the old key (an edit reverted, a pack on that base) linked the edited kernel without
a word. compile_one now removes the object before it starts the compiler, so the compiler writes a new file and the
entries linked to the old one keep it. Every compile goes through it; for the C and C++ ones nothing changes, as their
compiler replaced the file anyway.

Test: tests/test_asm_end_to_end.py, which failed at the test commit: an include's edit and its revert linked the edited
kernel (the cache's entry under the cold build's key was the edited object), and a shared kernel's pack on a base wrote
into the base's objects and cache.

Assisted-by: Claude Code
The review: compile_one removes the old object but leaves its stamp (<object>.sha1) while clang's assembler writes the
new object in place. A build whose process tree is terminated during that write leaves part of an object under the old
stamp; once the edit is reverted the stamp matches the key again, and the first check (the object and its stamp) takes
the partial object before the object cache's valid entry is looked at.

tests/test_asm_end_to_end.py builds the kernels cold, edits the game kernel's include, and runs the next build with a
stand-in assembler for that kernel: a process that writes the first 64 bytes of the object at its own path and is
killed, and the build stops there (as its process tree terminated). The include is then reverted: the next build must
compile nothing and link the cold build's objects, unchanged, and the game's caller must give the cold build's values.

Assisted-by: Claude Code
The review: compile_one removed the object before it started the compiler but left its stamp (<object>.sha1). clang's
assembler, which compiles the hand-written kernels, writes its object in place, so a build whose process tree ended
during that write left part of an object under the old stamp. Once the edit was reverted the stamp matched the key
again, and the first check (the object and a stamp of its key) took the partial object before it looked in the object
cache, where the valid one is.

compile_one now removes the stamp as soon as it does not match: the object is replaced after that (linked from the
cache, or compiled), and only a finished one is stamped again. Without a stamp the next build links the cache's entry
or compiles again. The same holds for a link from the cache that stops before its stamp is written.

Test: tests/test_asm_end_to_end.py, test_a_stopped_replacement_and_its_revert, which failed at the test commit (the
revert linked the 64 bytes the stopped assembler had written).

Assisted-by: Claude Code
The review: main() sorts each compile's seconds into "renderer" or "host and game" by vk_job_objects, built from the
renderer's jobs before plan_modules joined the kernels to them (a new list), so a gpu/vk/asm or gpu/asm kernel of the
renderer was counted as host and game time.

tests/test_asm_build.py runs main()'s own statement (found in its syntax tree) on a plan of synthetic kernels: every
object the renderer links, its kernels included, is renderer time.

Assisted-by: Claude Code
vk_job_objects, by which main() counts each compile's seconds as renderer or host and game time, is now the set of the
renderer's link inputs plan_modules gives (vk_objs), its kernels included. It was built from the renderer's jobs before
the plan joined the kernels to them, so a renderer kernel was counted as host and game time.

Test: tests/test_asm_build.py, test_the_compile_time_breakdown_counts_the_renderer_kernels, which failed at the test
commit (vk_vk_draw.o alone was renderer time).

Assisted-by: Claude Code
The review: hos_gpu_guest_ranges grows the kernel's scratch list (one pair per range) through hos_xrealloc while it
holds the mapping lock. At the commit limit hos_xrealloc tries again for up to 5 s before the out-of-memory stop, and
every mapping change and lookup waits on the lock for as long.

tests/test_asm_ranges.py's fixture now holds a flag for the lock (LOCK, UNLOCK) and can refuse the scratch list: its
hos_xrealloc fails the check when asked for the sort's list while it is refused (the 5 s of tries), and the plain
realloc returns NULL. A call whose ranges outgrow every list the other cases grew, with the scratch refused, must sort
with qsort in place, not with the kernel, and leave the lock; the next call, with the scratch allowed, sorts with the
kernel, and both give the same ranges.

Assisted-by: Claude Code
fix(asm): a refused scratch list for the ranges' sort is not waited for with the mapping lock held
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 5s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
cffa2f46ba
hos_gpu_guest_ranges grew lsasm_sort_ranges' scratch list (one pair per range) through hos_xrealloc with the mapping
lock held: refused at the commit limit, hos_xrealloc tries again for up to 5 s before the out-of-memory stop, and every
mapping change and lookup waited on the lock as long. The list is only the sort's; the ranges can be sorted without it.

It now grows through plain realloc, with a capacity of its own. When it is refused the call sorts with qsort and
cmp_range in place (as other CPUs do), and the next change of the mappings asks for it again. The merged list still
grows through hos_xrealloc: the call cannot go on without it (on main its realloc's NULL was used as the list).

Test: tests/test_asm_ranges.py, which failed at the test commit (the refused scratch went through hos_xrealloc's tries
with the lock held).

Assisted-by: Claude Code
perf(vk): block-linear textures' unswizzle, swizzle and RGB widening in x86-64 assembly
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 4s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
d63130135d
- gpu/vk/asm/texture.S (texture.h): lsasm_unswizzle and lsasm_swizzle are suyu's UnswizzleTexture and SwizzleTexture
  (video_core/textures/decoders.cpp, with the Switch 2 GOB) at stride_alignment 0, a line copied 16-byte sector by
  sector (a sector is whole in both layouts); lsasm_widen_rows widens 3-, 6- and 12-byte texels with alpha 0xFF, half
  1.0 or float 1.0. AVX2 and SSE2 bodies.
- vk_texture.cpp: unswizzle_upload's fallback (what texture_tiles.h does not take: partial tiles, 3D levels) is
  lsasm_unswizzle; flush_finish's write-back swizzle is lsasm_swizzle; widen_rows gives the three alphas the kernel
  appends to lsasm_widen_rows, every other one (widen_alpha's SNORM, UNORM16 and integer ones) stays in its loop.
  RX_VK_UNSWIZZLE_CHECK still compares the upload with suyu's.
- The write-back swizzle was called with stride_alignment 1, the kernel is 0's: the same layout for every bytes per
  block a write-back has (1, 2, 4, 8, 16; flushable() keeps the widened formats out), as the test shows. The branch's
  fix of the upload's own 1 (971f8074) is main's already (#1603, 09a20cd6).
- Not measured on this port: the branch's micro-benchmarks against suyu's C timed the branch's code, the unswizzle's
  before #1603 (on main the kernel takes only what texture_tiles.h leaves); not measured in play.
- tests/test_asm_texture.py: the kernels against suyu's reference (built from its source) for every bytes per block,
  widths and heights across and off a GOB's, block heights 0-5 and 3D block depths, swizzled reads ending at a guard
  page; widen_rows and flush_finish's swizzle cut from vk_texture.cpp and run against the loop and the call they were.
  tests/test_texture_tile_upload.py and tests/test_widen_alpha.py assemble texture.S (the fallback's calls counted).
- No switch: the kernels stand for suyu's C at those three calls. Needs the hand-written kernels' kit (build(asm))
  first.

Assisted-by: Claude Code
Member

Possibly related, for context:

  • PR #2128 WIP: perf(vk): the capture's copies use hand-written x86-64 kernels (lsasm_copy, lsasm_copy_nt; RX_VK_CAPTURE_ASM) — Open assembly-kernel work sharing the asm-kit dependency; separate capture-copy code.
Possibly related, for context: - PR #2128 WIP: perf(vk): the capture's copies use hand-written x86-64 kernels (lsasm_copy, lsasm_copy_nt; RX_VK_CAPTURE_ASM) — Open assembly-kernel work sharing the asm-kit dependency; separate capture-copy code.
Author
Contributor

@Beanstalk This does the block-linear textures' CPU unswizzle fallback, their swizzle and RGB widening with hand-written x86-64 kernels (gpu/vk), when textures load. It sits on #1947 (cffa2f46, the asm kit), so its diff against its merge base includes that PR's commits; the farm cannot take it as the comparison, so please compare with main. No switch: a revert gives back main's code. Please start from the kokiri-start save and take the picture right after it loads and settles, before any input, with a main-against-itself picture on the same PC at that point; then, for frame times only, play Kokiri Forest for two minutes and go into Hyrule Field (one scene load) and play it for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; frame time p99 equal to main's or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. No garbled or black textures.

@Beanstalk This does the block-linear textures' CPU unswizzle fallback, their swizzle and RGB widening with hand-written x86-64 kernels (gpu/vk), when textures load. It sits on #1947 (cffa2f46, the asm kit), so its diff against its merge base includes that PR's commits; the farm cannot take it as the comparison, so please compare with main. No switch: a revert gives back main's code. Please start from the kokiri-start save and take the picture right after it loads and settles, before any input, with a main-against-itself picture on the same PC at that point; then, for frame times only, play Kokiri Forest for two minutes and go into Hyrule Field (one scene load) and play it for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; frame time p99 equal to main's or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. No garbled or black textures.
Member

@siantm only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for d631301, and the PR has changed since (a360ac9), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `d631301`, and the PR has changed since (`a360ac9`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Author
Contributor

Measurements: the micro-benchmark (trials script, run alone on this PC 2026-11-22, 3 rounds, SSE2 and AVX2): figures and Verdict

Measurements: the micro-benchmark (trials script, run alone on this PC 2026-11-22, 3 rounds, SSE2 and AVX2): figures and Verdict
Author
Contributor

@Beanstalk One correction to my request 69771 above, for its picture point: please take each picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between, and take the main-against-itself picture from the same point. A picture taken during the load's fade-in from black is not comparable: run 70269 on #2156 caught the fade in 3 of 4 starts.

@Beanstalk One correction to my request 69771 above, for its picture point: please take each picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between, and take the main-against-itself picture from the same point. A picture taken during the load's fade-in from black is not comparable: run 70269 on #2156 caught the fade in 3 of 4 starts.
Member

@siantm only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for d631301, and the PR has changed since (a360ac9), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `d631301`, and the PR has changed since (`a360ac9`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Author
Contributor

@Beanstalk This replaces my request 69771 on this head and the corrections under it, in a form the farm can run: it cannot time a picture from the first frame that is not a uniform colour (its answer on #2131), so each picture here follows a fixed wait after the map event. This does the block-linear textures' CPU unswizzle fallback, their swizzle and RGB widening with hand-written x86-64 kernels (gpu/vk), when textures load. It sits on #1947 (cffa2f46, the asm kit), so its diff against its merge base includes that PR's commits; the farm cannot take it as the comparison, so please compare with main. No switch: a revert gives back main's code. Please start from the kokiri-start save and take the picture 10 s (600 frames at 60 fps) after the map event that ends the load, a fixed wait with no input in between (the farm cannot time it from the first frame that is not a uniform colour), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest for two minutes and go into Hyrule Field (one scene load) and play it for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; frame time p99 equal to main's or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. No garbled or black textures.

@Beanstalk This replaces my request 69771 on this head and the corrections under it, in a form the farm can run: it cannot time a picture from the first frame that is not a uniform colour (its answer on #2131), so each picture here follows a fixed wait after the map event. This does the block-linear textures' CPU unswizzle fallback, their swizzle and RGB widening with hand-written x86-64 kernels (gpu/vk), when textures load. It sits on #1947 (cffa2f46, the asm kit), so its diff against its merge base includes that PR's commits; the farm cannot take it as the comparison, so please compare with main. No switch: a revert gives back main's code. Please start from the kokiri-start save and take the picture 10 s (600 frames at 60 fps) after the map event that ends the load, a fixed wait with no input in between (the farm cannot time it from the first frame that is not a uniform colour), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest for two minutes and go into Hyrule Field (one scene load) and play it for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; frame time p99 equal to main's or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. No garbled or black textures.
Member

@siantm only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for d631301, and the PR has changed since (a360ac9), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `d631301`, and the PR has changed since (`a360ac9`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
siantm force-pushed perf/asm-texture from d63130135d
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 4s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to a360ac981c
Some checks failed
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Failing after 1s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
2026-11-23 12:51:07 +00:00
Compare
siantm changed title from WIP: perf(vk): block-linear textures' unswizzle, swizzle and RGB widening in x86-64 assembly to WIP: perf(vk): block-linear textures' write-back swizzle and RGB widening in x86-64 assembly 2026-11-23 12:51:39 +00:00
Author
Contributor

@Beanstalk This replaces my request 74258, made for the earlier head d6313013; this head is narrower (the upload unswizzle is main's C again). It does the block-linear textures' write-back swizzle (when the renderer writes a texture back to guest memory) and the RGB8, RGB16F and RGB32F widening on upload with hand-written x86-64 kernels (gpu/vk); the swizzle runs only during loads, and the widening was not reached in Hyrule Field on the author's PC. It sits on #1947 (186fdb85, the asm kit), so its diff against its merge base includes that PR's commits; the farm cannot take it as the comparison, so please compare with main. No switch: a revert gives back main's code. Please start from the kokiri-start save, which already puts Link in Kokiri Forest (no teleport to Kokiri Forest is needed), and take the picture 10 s after the map event that ends the load, a fixed wait with no input in between, with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest for two minutes and go into Hyrule Field (one scene load: a teleport asked after about 80 frames of play, its arrival checked) and play it for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; frame time p99 equal to main's or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. No garbled or black textures.

@Beanstalk This replaces my request 74258, made for the earlier head d6313013; this head is narrower (the upload unswizzle is main's C again). It does the block-linear textures' write-back swizzle (when the renderer writes a texture back to guest memory) and the RGB8, RGB16F and RGB32F widening on upload with hand-written x86-64 kernels (gpu/vk); the swizzle runs only during loads, and the widening was not reached in Hyrule Field on the author's PC. It sits on #1947 (186fdb85, the asm kit), so its diff against its merge base includes that PR's commits; the farm cannot take it as the comparison, so please compare with main. No switch: a revert gives back main's code. Please start from the kokiri-start save, which already puts Link in Kokiri Forest (no teleport to Kokiri Forest is needed), and take the picture 10 s after the map event that ends the load, a fixed wait with no input in between, with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest for two minutes and go into Hyrule Field (one scene load: a teleport asked after about 80 frames of play, its arrival checked) and play it for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; frame time p99 equal to main's or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. No garbled or black textures.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Some checks failed
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Failing after 1s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
This pull request has changes conflicting with the target branch.
  • gpu/vk/vk_texture.cpp
  • nx2/build.py
Some workflows are waiting to be reviewed.
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/asm-texture:siantm-perf/asm-texture'
git switch 'siantm-perf/asm-texture'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot!2136
No description provided.