perf(vk): software matrix multiplies unrolled where the device gives the loop's words (RX_VK_MMA_UNROLL=0 keeps the loop) #1086

Merged
HumanBean merged 3 commits from zeldaootr/Longshot:mma-unroll into main 2026-11-16 09:50:09 +00:00
Contributor

Type: perf · Risk: low · Tested on: Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel); Linux x86-64 game-free checks; Windows renderer built with llvm-mingw · Needs: Linux, other AMD GPUs on RADV without 16x8x16 cooperative matrices (RDNA 1 and 2, RDNA 3 and 4); Windows, any GPU (the loop, unchanged)

Why

On GPUs without hardware for matrix maths (the Steam Deck, AMD cards before RDNA 3, GTX 10 and 16, Intel's integrated GPUs), the game's upscale networks multiply through a shader function, and on the Deck at its own resolution that function is most of the anti-aliasing network's 9 ms a frame. Writing its steps out instead of looping over them takes that network to about 4 ms a frame on a Deck, and Hyrule Field from 14.8 to 16.1 fps, with a self-test at start making sure the faster form gives exactly the loop's results on the player's own GPU before it is used.

The idea, the code and the first measurements are sheep's. They built it in their fork, https://git.magicbean.dev/sheep/BunnyHood (GPL-3.0), commit sheep/BunnyHood@01f9b690d5 (their cherry-pick of their own sheep/BunnyHood@e95c60a642), on Lichii's loop, which stays the reference form. They measured it on a Deck LCD: the network 8.61 -> 3.82 ms a frame, Kokiri Forest 11.7 -> 12.4 fps at 1280x800 (their numbers, labelled as theirs, are below ours). Their commit is here as they wrote it (cherry-pick -x, their authorship and both cherry picked from lines kept), with a [port: ...] line for the fork's names mapped to Longshot's. The one commit of ours adds the files for our Deck runs. sheep is welcome to take this PR over, send commits to it, or leave it with us.

The tracker was searched (MMA_UNROLL, "unrolled", "matrix multiplies", "software matrix"): no issue or pull request does this. Related:

  • #912 (mooki, WIP: the cooperative matrix test waits for its dispatch before destroying what it uses) edits run_shader in gpu/vk/vk_coopmat.cpp, which this PR also changes. They conflict in the lines of the submit and the "did not complete" log line; the merge keeps both: #912's submitted and its wait without a limit, and this PR's what in the log line. #912's fix then also covers this PR's self-test, whose three dispatches go through run_shader. Merged with this PR, #912's own check tests/test_coopmat_safe_free.py needs its marker for run_shader's first line set to the new signature (it cuts the function out by that line); with that change it passes on the merge, and so does tests/test_mma_software.py.
  • #1038 (jcabarca: matrix multiplies through WMMA 16x16x16 tiles on AMD RDNA 3 and 4) conflicts in mma_layout.h (both add globals after mma_software: keep both) and in translator_stamp in vk_shader.cpp, where both use flag bits 256 and 512: this PR's form only when the multiplies run in software, #1038's only when they run on its tiles. Whichever lands second should move its bits up so the stamp stays unambiguous. Until #1038 lands, RDNA 3 and 4 on RADV multiply in software, so this PR's default applies to them too (not measured, under Not tested).
  • #687 (ours: FXAA in place of the full-size network where the GPU multiplies in software, RX_VK_TAAU_FULL_SIZE=1, off by default) replaces the same network on these GPUs. With #687's switch on, the network does not run and this PR has nothing to speed up there; with this PR the network costs about 4 ms a frame where it cost 9, so #687's trade (a softer picture for the network's time) buys about half as much. Not measured together.
  • #1053 (ours: the Deck's GPU clock held at its peak power state, RX_VK_GPU_CLOCK=1, off by default; also sheep's idea) is independent: it raises the clock, this PR cuts the work. Our runs here are at the stock automatic clock; the two together were not measured.

What changed

Where the GPU multiplies in software, the multiply function now comes in two forms built from one header: Lichii's loop, word for word as before, and an unrolled form that takes one operand through quad broadcasts and rounds to f16 with the GPU's own conversion. At start a self-test runs both forms on the device over 8,192 lanes of chosen inputs and uses the unrolled one only where every word is the loop's; on RADV it is tried by default, elsewhere only when asked.

  • vk, the forms (sheep): gpu/vk/eden/shader_recompiler/backend/spirv/mma_software.h (new) DefineSoftwareMma, built the same way by the translator and by the self-test; emit_spirv_warp.cpp DefineSoftwareMatrixFunction calls it in the chosen form (the loop's SPIR-V unchanged); mma_layout.h holds the chosen form (mma_software_form, mma_software_quad).
  • vk, the self-test (sheep): gpu/vk/vk_coopmat.cpp choose_software_form, software_test_shader, software_test_input (f16 values of every kind, and warps built so a K group's sum lands on an f16 tie, which catches a driver that folds the conversion into the FMA before it), software_forms_agree; run_shader takes a group count. software_unroll_wanted: RX_VK_MMA_UNROLL=0 the loop, =1 tried on any GPU, unset tried on RADV. The log's vk: software matrix multiplies ... line says which form is used and why.
  • vk, the cache (sheep): gpu/vk/vk_shader.cpp translator_stamp holds the form (0 for the loop, as before).
  • tests (sheep): tests/test_mma_software.py (new): every form through spirv-val with its shape, the self-test's inputs against CPU models of the loop and of a folding driver, the switch, the emitter's use of the form and the stamp.
  • docs: the switch's row in docs/development.md (sheep); twelve files in docs/tested/ for our Deck runs (ours).
  • vk, review fixes (HumanBean, 1a75f5e6): the unrolled form with the f16 conversion is tried only where the GPU has f16 shaders (shaderFloat16); elsewhere (RADV Polaris, RX 400/500) only the integer unrolled form is, and the self-test's module declares Float16 only for the f16 form. A form whose test did not run is logged as such, not as a word count. A goes through quad broadcasts only where the device has quad operations in every stage (quadOperationsInAllStages; RADV has them). tests/test_mma_software.py cuts with tests/srccut.py; comments in mma_software.h say only A's lane indices are constants and that the xor-0 barrier holds only while the driver keeps it.

Measurements

Verdict: helps on the Steam Deck at native resolution. The full-size network takes 4.05-4.30 ms a frame instead of 9.27-9.51 in Hyrule Field (-56%) and 5.77 instead of 9.48 in Kokiri Forest (-39%); median fps +8.3% in the Field (14.83 -> 16.06) and +6.6% in Kokiri (9.16 -> 9.77); GPU time -5.4 and -4.9 ms a frame. The self-test chose the unrolled form on RADV VANGOGH in every run, and the pictures match. The 1% low is better in Kokiri (6.07 -> 6.32 fps) and mixed in the Field (12.90 -> 12.41: one unrolled run had three isolated long frames, the other was the best of the four).

Baseline: both columns are one renderer pack, mmaun (local tree e2d3f793): Longshot main 9c9d69ed, the Deck's development base, plus this branch's gpu/ diff, applied with a three-way merge and no conflict. "Before" is that pack with RX_VK_MMA_UNROLL=0 (the loop, main's form), "After" with the switch unset (the default). A renderer pack fits only the base it was built on, and main's translator differs from the pack's in its stamp and files, so the loop is measured inside the same pack rather than as main. The numbers hold for this branch: emit_spirv_warp.cpp, mma_layout.h, mma_software.h and vk_coopmat.cpp are byte-identical between the pack's tree and this PR's head, vk_shader.cpp's stamp hunk is the same lines, and none of those files changed on main between 9c9d69ed and this PR's base 02903b04. What main changed since 9c9d69ed can move the absolute fps, not what this PR changes, which is the network's own shader.
Hardware: Steam Deck OLED, SteamOS 3.9.5 (20261023.100, kernel 7.2.7-valve2), AMD Custom GPU 0932 (RADV VANGOGH), Mesa 26.2.0-devel (git-5c65d4fc31), Zen 2 4 cores / 8 threads, 16 GB shared; plugged in, stock automatic GPU clock, headless
Scene: Hyrule Field (child, teleported from the Kokiri save) and Kokiri Forest (the save's spot outside Link's house beside Saria, sheep's scene); 1280x800 output, render resolution 100%, the game's own upscaler, frame generation off, no frame rate cap
Method: one session, 2026-11-16 04:54-05:46 UTC. Per scene four timed runs interleaved loop, unrolled, unrolled, loop, then a pass-timing run of each (RX_VK_PASS_TIMING=2, for the network's GPU ms). Every run from empty program and pipeline caches in a fresh private game folder with RX_VK_PRECOMPILE=0 (the translator changed, so no warm cache is valid), 75 s warm-up then 45 s standing. Fps and present intervals from HOS_PRESENT_TRACE in the 45 s sample (1% low: 1000 / the mean of the slowest 1% of present intervals), GPU time from the log's vk: GPU time lines, GPU clock, busy and power from sysfs at 10 Hz; the median of the two runs per arm. All 12 runs exit 0, with no device loss, VK_ERROR or amdgpu kernel line
How to reproduce: a child save; Kokiri Forest beside Saria, or teleport to Hyrule Field; options output_res=1280x800, resolution=1 (100%); RX_VK_PRECOMPILE=0 and empty program caches; RX_VK_MMA_UNROLL=0 against unset, alternating; RX_VK_PASS_TIMING=2 for the network's row

Hyrule Field, 1280x800, 100% (median of 2) Before, RX_VK_MMA_UNROLL=0 (the loop): pack mmaun @ e2d3f793 After, unset (unrolled): pack mmaun @ e2d3f793 Δ
fps 14.83 (14.89, 14.76) 16.06 (16.12, 16.00) +8.3%
1% low, fps 12.90 (12.98, 12.81) 12.41 (13.12, 11.70) -3.8%
present interval p50 / p95 / p99, ms 67.2 / 72.4 / 75.8 61.9 / 66.9 / 71.0 -7.8% / -7.6% / -6.4%
frames over 100 ms in 45 s 0, 0 1, 2
GPU time, ms a frame 45.45 (45.4, 45.5) 40.05 (39.9, 40.2) -5.4 ms
full-size network 9dc98871eb7fc101, ms a frame (pass timing, the report periods after its compile) 9.51, 9.27 4.30, 4.05 -56%
the form the self-test chose looped (RX_VK_MMA_UNROLL=0) unrolled, f16 rounding by conversion, A through quad broadcasts
Kokiri Forest, 1280x800, 100%, about 2,200 draws (median of 2) Before, RX_VK_MMA_UNROLL=0 (the loop): pack mmaun @ e2d3f793 After, unset (unrolled): pack mmaun @ e2d3f793 Δ
fps 9.16 (9.12, 9.20) 9.77 (9.86, 9.67) +6.6%
1% low, fps 6.07 (5.89, 6.24) 6.32 (6.57, 6.07) +4.2%
present interval p50 / p95 / p99, ms 102.6 / 148.9 / 156.7 97.7 / 137.6 / 153.5 -4.8% / -7.6% / -2.0%
frames over 100 ms in 45 s 244 (247, 240) 184 (175, 193) -24%
GPU time, ms a frame 75.85 (79.1, 72.6) 71.0 (69.35, 72.65) -4.9 ms
full-size network 9dc98871eb7fc101, ms a frame (pass timing, the one report period in the sample) 9.48 5.77 -39%
the form the self-test chose looped (RX_VK_MMA_UNROLL=0) unrolled, f16 rounding by conversion, A through quad broadcasts

Kokiri Forest at handheld settings (1280x720 output, render 50%): pending. The runs are queued on the same Deck (loop, unrolled, unrolled, loop, and one pass-timing run that will also show whether the full-size network runs there at all); the numbers will follow in a comment and here.

The Field's 1% low: the unrolled runs' long frames (114 ms in U-fN-1; 113, 112 and 93 ms in U-fN-2) were spent in the game's thread before the present (the renderer's own part 0.1-2.3 ms), with no program or pipeline built during either sample; the loop's runs had none over 83 ms. Two runs a side cannot tell that from noise, and Kokiri's 1% low went the other way.

The pictures: the end-of-sample shot of each run (sample_end, kokiri_stand_end, 1280x800), loop against unrolled, looked at side by side at full size and as 2x crops around Link and Navi in the Field and the house and its fence in Kokiri: the same edges and their smoothing, the same foliage, hair, cloth and texture detail, the same HUD, no banding, noise or black. What differs is what moves: fireflies, Navi, falling leaves, Saria's pose. Pixel identity can't be shown from stills of an animated scene, so the per-pixel difference across arms was set beside the one between two runs of the same arm (mean of the largest channel difference, 0-255): loop against unrolled 6.8 and 5.6 in the Field, 15.1 and 13.0 in Kokiri; loop against loop 5.4 and unrolled against unrolled 6.6 in the Field, 14.1 and 14.0 in Kokiri. Across arms is within the spread within an arm. That the multiply's results are the same is the self-test's job: every unrolled run logged that the unrolled form gave the loop's words for all 8,192 lanes on this device.

Cost: the full-size network's pipeline took longer to compile, once, on a worker: 12.0 and 12.2 s with the loop, 15.3 and 15.7 s unrolled (its dispatch is left out while it compiles, as before). Start to the first present: 7.1-7.4 s with the loop, 7.3-7.7 s unrolled (the self-test included), within the runs' spread.

vk: matrix multiplies in software (no cooperative matrices)
vk: software matrix multiplies looped (RX_VK_MMA_UNROLL=0)                               (every loop run)
vk: software matrix multiplies unrolled, f16 rounding by conversion, A through quad broadcasts: the loop's words for 8192 lanes (RX_VK_MMA_UNROLL=0: looped)   (every unrolled run)

Field, pass timing, loop (mu-pt-L-fN):
vk: compute pipeline of 9dc98871eb7fc101: SLOW compile, 12036 ms (on a worker)
vk:   m   9.511 ms     0.9 x  10528.3 us       0.9 items    0.00 MB  dispatch  prog 9dc98871eb7fc101
vk:   m   9.270 ms     1.0 x   9269.7 us       1.0 items    0.00 MB  dispatch  prog 9dc98871eb7fc101
Field, pass timing, unrolled (mu-pt-U-fN):
vk: compute pipeline of 9dc98871eb7fc101: SLOW compile, 15288 ms (on a worker)
vk:   m   4.296 ms     1.0 x   4295.8 us       1.0 items    0.00 MB  dispatch  prog 9dc98871eb7fc101
vk:   m   4.048 ms     1.0 x   4048.1 us       1.0 items    0.00 MB  dispatch  prog 9dc98871eb7fc101
Kokiri, pass timing, loop (mu-pt-L-kN):
vk:   m   9.485 ms     1.0 x   9484.9 us       1.0 items    0.00 MB  dispatch  prog 9dc98871eb7fc101
Kokiri, pass timing, unrolled (mu-pt-U-kN):
vk:   m   5.771 ms     1.0 x   5770.5 us       1.0 items    0.00 MB  dispatch  prog 9dc98871eb7fc101

sheep's numbers, from BunnyHood (their commit message), not from this branch: Steam Deck LCD, RADV (Mesa 26.2.7), Kokiri Forest, 1280x800 at Resolution 100%, interleaved with the loop (RX_VK_MMA_UNROLL=0) on the same build.

Steam Deck LCD, Kokiri Forest, 1280x800 100% (sheep's, in BunnyHood) Loop Unrolled, f16 rounding by conversion
the network, ms a frame (pass timing) 8.61 3.82
fps 11.7 12.4 / 12.5
GPU time, ms a frame 57.4 52.3

Flags and settings

One switch is added. Its default tries the unrolled form on RADV, as the author ships it, and keeps it only where the self-test finds the loop's words; everywhere else nothing changes unless it is set.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_MMA_UNROLL The software matrix multiplies' form, where the GPU has no cooperative matrices with 16x8x16 f16 absent (the loop) unset: the unrolled form tried on RADV, kept only where the self-test finds every word the loop's; 0 the loop; 1 tried on any GPU The upscale networks' multiplies cost less; the picture is the same Helps the Steam Deck: the OLED here (the network -56% in the Field, -39% in Kokiri; fps +8.3% and +6.6% at native), the LCD in sheep's runs (8.61 -> 3.82 ms, +6% fps); untested on other RADV GPUs (RDNA 1, 2, 3 and 4, Polaris and older); idle with cooperative matrices As shipped: tried on RADV by default; 0 to roll back

Why the default stays on for RADV: CONTRIBUTING.md asks a switch to ship at its recommended value, on when that is what we recommend and the measurements back it. They do on the GPU the project puts first: two Decks (sheep's LCD, our OLED), two scenes, interleaved runs, the network 39-56% faster and no picture change. The default cannot change a picture by design: the unrolled form is used only on a device where it gave all 16,384 words of the self-test exactly as the loop did, otherwise the loop runs as before, and the self-test's inputs include the f16 ties that catch the driver folding seen so far. What it costs where it wasn't measured: on other RADV GPUs without cooperative matrices the speed is unknown (the same work written out, on the same Mesa compiler, but with other register files and wave sizes), the network's first compile is about 3 s longer on a worker, and the self-test's three small dispatches run at start. Opt-in would leave every Deck player on the slow form for a gain already shown on both Deck models, so the cost elsewhere goes to testers instead (Must be tested), with RX_VK_MMA_UNROLL=0 as the way back. Other drivers keep the loop unless =1.

Testing

Tested:

  • In the game, Steam Deck OLED, SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel: 12 runs in Hyrule Field and Kokiri Forest at 1280x800, 100% (Measurements), on a renderer pack of this branch's gpu/ change; every unrolled run logged the self-test choosing the unrolled form with conversion rounding, every run exited 0 with no device loss, VK_ERROR or amdgpu kernel line, and the pictures match.
  • Game-free, Linux x86-64, with LONGSHOT_VULKAN_HEADERS and LONGSHOT_SPIRV_HEADERS set so the header checks run, on head 3e6ab7c9's code (the last rebase moved it over two main commits that touch only nx2/make_game.py and two tests; git range-diff shows both commits unchanged):
    • tests/test_mma_software.py through run_all.py --strict, with CXX=g++ (13.3) and CXX=clang++ (23.1.5), spirv-val on every form: pass.
    • python -I -B tests/run_all.py --changed forge/main (70 checks that read the changed files), with each compiler: 67 passed, 3 failed. The three, test_walk_key, test_vk_occlusion_queries and test_nonuniform_image_arrays, fail on main too.
    • python -I -B tests/run_all.py, the whole run: 619 passed, 20 failed, 26 skipped (Windows-only checks, a game build or dump, zstandard, PIL). 17 fail on main 02903b04 too, by name: test_bug_report_defaults, test_crt_options, test_fsr_uniform_ownership, test_guest_imported, test_import_reach, test_linux_preflight, test_linux_update, test_make_game_cache, test_missing_nup, test_mods_size_table, test_nonuniform_image_arrays, test_parallel_init_order, test_pending_guest_import, test_replay_write_order, test_run_all_changed, test_vk_occlusion_queries, test_walk_key. The other three (test_pipeline_cache_save, and test_fpx_sticky and test_recorder_sync, which timed out at 600 s under the full run's load) pass run alone on this branch. Main's two newest commits' checks on this head: test_crash_dialog passes; test_failed_compile_keeps_objects fails, as on main f7922126.
    • The renderer built for Windows with llvm-mingw 20261104 (RX_VK_ONLY=1 RX_RELEASE=1 RX_TARGET=windows python -I nx2/build.py --standalone): longshot_vk.dll compiled and linked, no warning; and for Linux with clang++ 23.1.5 (the same without RX_TARGET): longshot_vk.so linked.
    • Merged with #912 (the conflict resolved as under Why): tests/test_mma_software.py passes, and #912's tests/test_coopmat_safe_free.py passes once its marker for run_shader's first line is updated.

Not tested:

  • The review fixes in 1a75f5e6: read, not built or run before they were pushed; the forge's checks run tests/test_mma_software.py on them. Wanted: one Polaris (RX 400/500) start showing the software matrix multiplies lines (the f16 form not tried, then the integer form's result).
  • Kokiri Forest at the Deck's handheld settings (1280x720, render 50%): runs queued, numbers to follow.
  • Other RADV GPUs, where the unrolled form is tried by default: RDNA 1 and 2 desktop and laptop GPUs, RDNA 3 and 4 (in software until #1038), Polaris and older GCN. The self-test keeps the picture the same there; the speed is not measured.
  • Intel and NVIDIA GTX 10 and 16 in the game (the loop stays unless RX_VK_MMA_UNROLL=1), and Windows in the game (the default tries only RADV, a Linux driver, so Windows players keep the loop; the Windows renderer was built, not run).
  • Together with #687's RX_VK_TAAU_FULL_SIZE=1 or #1053's RX_VK_GPU_CLOCK=1.

Must be tested:

  • linux, amd, radv, an RDNA 1 or 2 GPU (no cooperative matrices): Hyrule Field at render resolution 100% from empty program caches, once with RX_VK_MMA_UNROLL=0 and once unset, expecting the log line vk: software matrix multiplies unrolled, ...: the loop's words for 8192 lanes when unset, a frame rate no lower than with the loop and the same picture (Test Farm: @Beanstalk linux amd radv, Hyrule Field at 100% render with RX_VK_MMA_UNROLL=0 and unset, compare the frame rate and screenshots and post the "software matrix multiplies" log line)
  • linux, amd, radv, an RDNA 3 or 4 GPU: the same steps, expecting vk: matrix multiplies in software (the cooperative matrices lack 16x8x16 f16) and then the unrolled line, a frame rate no lower and the same picture (Test Farm: @Beanstalk linux amd radv rdna3, Hyrule Field at 100% render with RX_VK_MMA_UNROLL=0 and unset, compare the frame rate and screenshots and post the "software matrix multiplies" log line)
  • windows, any GPU: one start into Hyrule Field, expecting a vk: software matrix multiplies looped line (or native multiplies) and no unrolled line, at main's frame rate (Test Farm: @Beanstalk windows, one start in Hyrule Field, post the "matrix multiplies" log lines)

Risks

What could break:

  • A driver whose unrolled results differ only for inputs the self-test does not have: it would show as a slightly different upscaled picture. The inputs cover f16 values of every kind and the ties that catch a folded conversion; RX_VK_MMA_UNROLL=0 restores the loop.
  • Speed on RADV GPUs other than the Deck's: measured on the Deck only; where it is slower, the switch is the way back.
  • Start: the self-test makes three small compute pipelines and dispatches at start on software-multiply GPUs where it is tried (RADV by default); on the Deck, start to the first present moved within the runs' spread.
  • The full-size network's first compile, once per cache: about 3 s longer on the Deck (12 -> 15 s, on a worker, the pass left out meanwhile as before).
  • The self-test runs the function in a 32-lane test module; in the game Mesa inlines it into the network, and the game programs carry float-control modes the test module doesn't. These match while the 16-bit denormal modes are not emitted (support_fp16_denorm_* unset, noted in vk_coopmat.cpp).
  • The xor-0 shuffle that keeps the f16 conversion out of the FMA holds only while the driver keeps it: a Mesa that folds it away falls back to the loop through the tie inputs, slower, said only in the log.
  • If the self-test's result changes between starts (a dispatch that did not complete), the stamp changes and the program cache is translated again.

Turning it off: RX_VK_MMA_UNROLL=0, or revert the commit.

Compatibility: this PR changes the shader translator's files (gpu/vk/eden/shader_recompiler/backend/spirv/), so after updating every player on every GPU translates their programs again, once, at the first start (the build's shader stamp hashes those files). On GPUs that multiply in software the chosen form is also in the program cache's stamp, so setting or clearing RX_VK_MMA_UNROLL there translates again. Saves, longshot_options.ini and the vk ABI (MKWVK_API_VERSION, vk_api.h untouched) do not change.

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
**Type:** perf · **Risk:** low · **Tested on:** Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel); Linux x86-64 game-free checks; Windows renderer built with llvm-mingw · **Needs:** Linux, other AMD GPUs on RADV without 16x8x16 cooperative matrices (RDNA 1 and 2, RDNA 3 and 4); Windows, any GPU (the loop, unchanged) ## Why On GPUs without hardware for matrix maths (the Steam Deck, AMD cards before RDNA 3, GTX 10 and 16, Intel's integrated GPUs), the game's upscale networks multiply through a shader function, and on the Deck at its own resolution that function is most of the anti-aliasing network's 9 ms a frame. Writing its steps out instead of looping over them takes that network to about 4 ms a frame on a Deck, and Hyrule Field from 14.8 to 16.1 fps, with a self-test at start making sure the faster form gives exactly the loop's results on the player's own GPU before it is used. **The idea, the code and the first measurements are sheep's.** They built it in their fork, https://git.magicbean.dev/sheep/BunnyHood (GPL-3.0), commit https://git.magicbean.dev/sheep/BunnyHood/commit/01f9b690d5ef058cae970c8b6ce3ca2970d562f3 (their cherry-pick of their own https://git.magicbean.dev/sheep/BunnyHood/commit/e95c60a64224fc35eeb1deab07ccf0a0ca8b8ad9), on Lichii's loop, which stays the reference form. They measured it on a Deck LCD: the network 8.61 -> 3.82 ms a frame, Kokiri Forest 11.7 -> 12.4 fps at 1280x800 (their numbers, labelled as theirs, are below ours). Their commit is here as they wrote it (`cherry-pick -x`, their authorship and both `cherry picked from` lines kept), with a `[port: ...]` line for the fork's names mapped to Longshot's. The one commit of ours adds the files for our Deck runs. sheep is welcome to take this PR over, send commits to it, or leave it with us. The tracker was searched (`MMA_UNROLL`, "unrolled", "matrix multiplies", "software matrix"): no issue or pull request does this. Related: - #912 (mooki, WIP: the cooperative matrix test waits for its dispatch before destroying what it uses) edits `run_shader` in `gpu/vk/vk_coopmat.cpp`, which this PR also changes. They conflict in the lines of the submit and the "did not complete" log line; the merge keeps both: #912's `submitted` and its wait without a limit, and this PR's `what` in the log line. #912's fix then also covers this PR's self-test, whose three dispatches go through `run_shader`. Merged with this PR, #912's own check `tests/test_coopmat_safe_free.py` needs its marker for `run_shader`'s first line set to the new signature (it cuts the function out by that line); with that change it passes on the merge, and so does `tests/test_mma_software.py`. - #1038 (jcabarca: matrix multiplies through WMMA 16x16x16 tiles on AMD RDNA 3 and 4) conflicts in `mma_layout.h` (both add globals after `mma_software`: keep both) and in `translator_stamp` in `vk_shader.cpp`, where both use flag bits 256 and 512: this PR's form only when the multiplies run in software, #1038's only when they run on its tiles. Whichever lands second should move its bits up so the stamp stays unambiguous. Until #1038 lands, RDNA 3 and 4 on RADV multiply in software, so this PR's default applies to them too (not measured, under Not tested). - #687 (ours: FXAA in place of the full-size network where the GPU multiplies in software, `RX_VK_TAAU_FULL_SIZE=1`, off by default) replaces the same network on these GPUs. With #687's switch on, the network does not run and this PR has nothing to speed up there; with this PR the network costs about 4 ms a frame where it cost 9, so #687's trade (a softer picture for the network's time) buys about half as much. Not measured together. - #1053 (ours: the Deck's GPU clock held at its peak power state, `RX_VK_GPU_CLOCK=1`, off by default; also sheep's idea) is independent: it raises the clock, this PR cuts the work. Our runs here are at the stock automatic clock; the two together were not measured. ## What changed Where the GPU multiplies in software, the multiply function now comes in two forms built from one header: Lichii's loop, word for word as before, and an unrolled form that takes one operand through quad broadcasts and rounds to f16 with the GPU's own conversion. At start a self-test runs both forms on the device over 8,192 lanes of chosen inputs and uses the unrolled one only where every word is the loop's; on RADV it is tried by default, elsewhere only when asked. - vk, the forms (sheep): `gpu/vk/eden/shader_recompiler/backend/spirv/mma_software.h` (new) `DefineSoftwareMma`, built the same way by the translator and by the self-test; `emit_spirv_warp.cpp` `DefineSoftwareMatrixFunction` calls it in the chosen form (the loop's SPIR-V unchanged); `mma_layout.h` holds the chosen form (`mma_software_form`, `mma_software_quad`). - vk, the self-test (sheep): `gpu/vk/vk_coopmat.cpp` `choose_software_form`, `software_test_shader`, `software_test_input` (f16 values of every kind, and warps built so a K group's sum lands on an f16 tie, which catches a driver that folds the conversion into the FMA before it), `software_forms_agree`; `run_shader` takes a group count. `software_unroll_wanted`: `RX_VK_MMA_UNROLL=0` the loop, `=1` tried on any GPU, unset tried on RADV. The log's `vk: software matrix multiplies ...` line says which form is used and why. - vk, the cache (sheep): `gpu/vk/vk_shader.cpp` `translator_stamp` holds the form (0 for the loop, as before). - tests (sheep): `tests/test_mma_software.py` (new): every form through spirv-val with its shape, the self-test's inputs against CPU models of the loop and of a folding driver, the switch, the emitter's use of the form and the stamp. - docs: the switch's row in `docs/development.md` (sheep); twelve files in `docs/tested/` for our Deck runs (ours). - vk, review fixes (HumanBean, `1a75f5e6`): the unrolled form with the f16 conversion is tried only where the GPU has f16 shaders (`shaderFloat16`); elsewhere (RADV Polaris, RX 400/500) only the integer unrolled form is, and the self-test's module declares Float16 only for the f16 form. A form whose test did not run is logged as such, not as a word count. A goes through quad broadcasts only where the device has quad operations in every stage (`quadOperationsInAllStages`; RADV has them). `tests/test_mma_software.py` cuts with `tests/srccut.py`; comments in `mma_software.h` say only A's lane indices are constants and that the xor-0 barrier holds only while the driver keeps it. ## Measurements **Verdict:** helps on the Steam Deck at native resolution. The full-size network takes 4.05-4.30 ms a frame instead of 9.27-9.51 in Hyrule Field (-56%) and 5.77 instead of 9.48 in Kokiri Forest (-39%); median fps +8.3% in the Field (14.83 -> 16.06) and +6.6% in Kokiri (9.16 -> 9.77); GPU time -5.4 and -4.9 ms a frame. The self-test chose the unrolled form on RADV VANGOGH in every run, and the pictures match. The 1% low is better in Kokiri (6.07 -> 6.32 fps) and mixed in the Field (12.90 -> 12.41: one unrolled run had three isolated long frames, the other was the best of the four). Baseline: both columns are one renderer pack, `mmaun` (local tree e2d3f793): Longshot main 9c9d69ed, the Deck's development base, plus this branch's `gpu/` diff, applied with a three-way merge and no conflict. "Before" is that pack with `RX_VK_MMA_UNROLL=0` (the loop, main's form), "After" with the switch unset (the default). A renderer pack fits only the base it was built on, and main's translator differs from the pack's in its stamp and files, so the loop is measured inside the same pack rather than as main. The numbers hold for this branch: `emit_spirv_warp.cpp`, `mma_layout.h`, `mma_software.h` and `vk_coopmat.cpp` are byte-identical between the pack's tree and this PR's head, `vk_shader.cpp`'s stamp hunk is the same lines, and none of those files changed on main between 9c9d69ed and this PR's base 02903b04. What main changed since 9c9d69ed can move the absolute fps, not what this PR changes, which is the network's own shader. Hardware: Steam Deck OLED, SteamOS 3.9.5 (20261023.100, kernel 7.2.7-valve2), AMD Custom GPU 0932 (RADV VANGOGH), Mesa 26.2.0-devel (git-5c65d4fc31), Zen 2 4 cores / 8 threads, 16 GB shared; plugged in, stock automatic GPU clock, headless Scene: Hyrule Field (child, teleported from the Kokiri save) and Kokiri Forest (the save's spot outside Link's house beside Saria, sheep's scene); 1280x800 output, render resolution 100%, the game's own upscaler, frame generation off, no frame rate cap Method: one session, 2026-11-16 04:54-05:46 UTC. Per scene four timed runs interleaved loop, unrolled, unrolled, loop, then a pass-timing run of each (`RX_VK_PASS_TIMING=2`, for the network's GPU ms). Every run from empty program and pipeline caches in a fresh private game folder with `RX_VK_PRECOMPILE=0` (the translator changed, so no warm cache is valid), 75 s warm-up then 45 s standing. Fps and present intervals from `HOS_PRESENT_TRACE` in the 45 s sample (1% low: 1000 / the mean of the slowest 1% of present intervals), GPU time from the log's `vk: GPU time` lines, GPU clock, busy and power from sysfs at 10 Hz; the median of the two runs per arm. All 12 runs exit 0, with no device loss, `VK_ERROR` or amdgpu kernel line How to reproduce: a child save; Kokiri Forest beside Saria, or teleport to Hyrule Field; options `output_res=1280x800`, `resolution=1` (100%); `RX_VK_PRECOMPILE=0` and empty program caches; `RX_VK_MMA_UNROLL=0` against unset, alternating; `RX_VK_PASS_TIMING=2` for the network's row | Hyrule Field, 1280x800, 100% (median of 2) | Before, `RX_VK_MMA_UNROLL=0` (the loop): pack `mmaun` @ e2d3f793 | After, unset (unrolled): pack `mmaun` @ e2d3f793 | Δ | |---|---|---|---| | fps | 14.83 (14.89, 14.76) | 16.06 (16.12, 16.00) | +8.3% | | 1% low, fps | 12.90 (12.98, 12.81) | 12.41 (13.12, 11.70) | -3.8% | | present interval p50 / p95 / p99, ms | 67.2 / 72.4 / 75.8 | 61.9 / 66.9 / 71.0 | -7.8% / -7.6% / -6.4% | | frames over 100 ms in 45 s | 0, 0 | 1, 2 | | | GPU time, ms a frame | 45.45 (45.4, 45.5) | 40.05 (39.9, 40.2) | -5.4 ms | | full-size network `9dc98871eb7fc101`, ms a frame (pass timing, the report periods after its compile) | 9.51, 9.27 | 4.30, 4.05 | -56% | | the form the self-test chose | looped (`RX_VK_MMA_UNROLL=0`) | unrolled, f16 rounding by conversion, A through quad broadcasts | | | Kokiri Forest, 1280x800, 100%, about 2,200 draws (median of 2) | Before, `RX_VK_MMA_UNROLL=0` (the loop): pack `mmaun` @ e2d3f793 | After, unset (unrolled): pack `mmaun` @ e2d3f793 | Δ | |---|---|---|---| | fps | 9.16 (9.12, 9.20) | 9.77 (9.86, 9.67) | +6.6% | | 1% low, fps | 6.07 (5.89, 6.24) | 6.32 (6.57, 6.07) | +4.2% | | present interval p50 / p95 / p99, ms | 102.6 / 148.9 / 156.7 | 97.7 / 137.6 / 153.5 | -4.8% / -7.6% / -2.0% | | frames over 100 ms in 45 s | 244 (247, 240) | 184 (175, 193) | -24% | | GPU time, ms a frame | 75.85 (79.1, 72.6) | 71.0 (69.35, 72.65) | -4.9 ms | | full-size network `9dc98871eb7fc101`, ms a frame (pass timing, the one report period in the sample) | 9.48 | 5.77 | -39% | | the form the self-test chose | looped (`RX_VK_MMA_UNROLL=0`) | unrolled, f16 rounding by conversion, A through quad broadcasts | | Kokiri Forest at handheld settings (1280x720 output, render 50%): pending. The runs are queued on the same Deck (loop, unrolled, unrolled, loop, and one pass-timing run that will also show whether the full-size network runs there at all); the numbers will follow in a comment and here. The Field's 1% low: the unrolled runs' long frames (114 ms in U-fN-1; 113, 112 and 93 ms in U-fN-2) were spent in the game's thread before the present (the renderer's own part 0.1-2.3 ms), with no program or pipeline built during either sample; the loop's runs had none over 83 ms. Two runs a side cannot tell that from noise, and Kokiri's 1% low went the other way. The pictures: the end-of-sample shot of each run (`sample_end`, `kokiri_stand_end`, 1280x800), loop against unrolled, looked at side by side at full size and as 2x crops around Link and Navi in the Field and the house and its fence in Kokiri: the same edges and their smoothing, the same foliage, hair, cloth and texture detail, the same HUD, no banding, noise or black. What differs is what moves: fireflies, Navi, falling leaves, Saria's pose. Pixel identity can't be shown from stills of an animated scene, so the per-pixel difference across arms was set beside the one between two runs of the same arm (mean of the largest channel difference, 0-255): loop against unrolled 6.8 and 5.6 in the Field, 15.1 and 13.0 in Kokiri; loop against loop 5.4 and unrolled against unrolled 6.6 in the Field, 14.1 and 14.0 in Kokiri. Across arms is within the spread within an arm. That the multiply's results are the same is the self-test's job: every unrolled run logged that the unrolled form gave the loop's words for all 8,192 lanes on this device. Cost: the full-size network's pipeline took longer to compile, once, on a worker: 12.0 and 12.2 s with the loop, 15.3 and 15.7 s unrolled (its dispatch is left out while it compiles, as before). Start to the first present: 7.1-7.4 s with the loop, 7.3-7.7 s unrolled (the self-test included), within the runs' spread. ``` vk: matrix multiplies in software (no cooperative matrices) vk: software matrix multiplies looped (RX_VK_MMA_UNROLL=0) (every loop run) vk: software matrix multiplies unrolled, f16 rounding by conversion, A through quad broadcasts: the loop's words for 8192 lanes (RX_VK_MMA_UNROLL=0: looped) (every unrolled run) Field, pass timing, loop (mu-pt-L-fN): vk: compute pipeline of 9dc98871eb7fc101: SLOW compile, 12036 ms (on a worker) vk: m 9.511 ms 0.9 x 10528.3 us 0.9 items 0.00 MB dispatch prog 9dc98871eb7fc101 vk: m 9.270 ms 1.0 x 9269.7 us 1.0 items 0.00 MB dispatch prog 9dc98871eb7fc101 Field, pass timing, unrolled (mu-pt-U-fN): vk: compute pipeline of 9dc98871eb7fc101: SLOW compile, 15288 ms (on a worker) vk: m 4.296 ms 1.0 x 4295.8 us 1.0 items 0.00 MB dispatch prog 9dc98871eb7fc101 vk: m 4.048 ms 1.0 x 4048.1 us 1.0 items 0.00 MB dispatch prog 9dc98871eb7fc101 Kokiri, pass timing, loop (mu-pt-L-kN): vk: m 9.485 ms 1.0 x 9484.9 us 1.0 items 0.00 MB dispatch prog 9dc98871eb7fc101 Kokiri, pass timing, unrolled (mu-pt-U-kN): vk: m 5.771 ms 1.0 x 5770.5 us 1.0 items 0.00 MB dispatch prog 9dc98871eb7fc101 ``` sheep's numbers, from BunnyHood (their commit message), not from this branch: Steam Deck LCD, RADV (Mesa 26.2.7), Kokiri Forest, 1280x800 at Resolution 100%, interleaved with the loop (`RX_VK_MMA_UNROLL=0`) on the same build. | Steam Deck LCD, Kokiri Forest, 1280x800 100% (sheep's, in BunnyHood) | Loop | Unrolled, f16 rounding by conversion | |---|---|---| | the network, ms a frame (pass timing) | 8.61 | 3.82 | | fps | 11.7 | 12.4 / 12.5 | | GPU time, ms a frame | 57.4 | 52.3 | ### Flags and settings One switch is added. Its default tries the unrolled form on RADV, as the author ships it, and keeps it only where the self-test finds the loop's words; everywhere else nothing changes unless it is set. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_MMA_UNROLL` | The software matrix multiplies' form, where the GPU has no cooperative matrices with 16x8x16 f16 | absent (the loop) | unset: the unrolled form tried on RADV, kept only where the self-test finds every word the loop's; `0` the loop; `1` tried on any GPU | The upscale networks' multiplies cost less; the picture is the same | Helps the Steam Deck: the OLED here (the network -56% in the Field, -39% in Kokiri; fps +8.3% and +6.6% at native), the LCD in sheep's runs (8.61 -> 3.82 ms, +6% fps); untested on other RADV GPUs (RDNA 1, 2, 3 and 4, Polaris and older); idle with cooperative matrices | As shipped: tried on RADV by default; `0` to roll back | Why the default stays on for RADV: CONTRIBUTING.md asks a switch to ship at its recommended value, on when that is what we recommend and the measurements back it. They do on the GPU the project puts first: two Decks (sheep's LCD, our OLED), two scenes, interleaved runs, the network 39-56% faster and no picture change. The default cannot change a picture by design: the unrolled form is used only on a device where it gave all 16,384 words of the self-test exactly as the loop did, otherwise the loop runs as before, and the self-test's inputs include the f16 ties that catch the driver folding seen so far. What it costs where it wasn't measured: on other RADV GPUs without cooperative matrices the speed is unknown (the same work written out, on the same Mesa compiler, but with other register files and wave sizes), the network's first compile is about 3 s longer on a worker, and the self-test's three small dispatches run at start. Opt-in would leave every Deck player on the slow form for a gain already shown on both Deck models, so the cost elsewhere goes to testers instead (Must be tested), with `RX_VK_MMA_UNROLL=0` as the way back. Other drivers keep the loop unless `=1`. ## Testing **Tested:** - In the game, Steam Deck OLED, SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel: 12 runs in Hyrule Field and Kokiri Forest at 1280x800, 100% (Measurements), on a renderer pack of this branch's `gpu/` change; every unrolled run logged the self-test choosing the unrolled form with conversion rounding, every run exited 0 with no device loss, `VK_ERROR` or amdgpu kernel line, and the pictures match. - Game-free, Linux x86-64, with `LONGSHOT_VULKAN_HEADERS` and `LONGSHOT_SPIRV_HEADERS` set so the header checks run, on head 3e6ab7c9's code (the last rebase moved it over two main commits that touch only `nx2/make_game.py` and two tests; `git range-diff` shows both commits unchanged): - `tests/test_mma_software.py` through `run_all.py --strict`, with `CXX=g++` (13.3) and `CXX=clang++` (23.1.5), spirv-val on every form: pass. - `python -I -B tests/run_all.py --changed forge/main` (70 checks that read the changed files), with each compiler: 67 passed, 3 failed. The three, `test_walk_key`, `test_vk_occlusion_queries` and `test_nonuniform_image_arrays`, fail on main too. - `python -I -B tests/run_all.py`, the whole run: 619 passed, 20 failed, 26 skipped (Windows-only checks, a game build or dump, `zstandard`, `PIL`). 17 fail on main 02903b04 too, by name: `test_bug_report_defaults`, `test_crt_options`, `test_fsr_uniform_ownership`, `test_guest_imported`, `test_import_reach`, `test_linux_preflight`, `test_linux_update`, `test_make_game_cache`, `test_missing_nup`, `test_mods_size_table`, `test_nonuniform_image_arrays`, `test_parallel_init_order`, `test_pending_guest_import`, `test_replay_write_order`, `test_run_all_changed`, `test_vk_occlusion_queries`, `test_walk_key`. The other three (`test_pipeline_cache_save`, and `test_fpx_sticky` and `test_recorder_sync`, which timed out at 600 s under the full run's load) pass run alone on this branch. Main's two newest commits' checks on this head: `test_crash_dialog` passes; `test_failed_compile_keeps_objects` fails, as on main f7922126. - The renderer built for Windows with llvm-mingw 20261104 (`RX_VK_ONLY=1 RX_RELEASE=1 RX_TARGET=windows python -I nx2/build.py --standalone`): `longshot_vk.dll` compiled and linked, no warning; and for Linux with clang++ 23.1.5 (the same without `RX_TARGET`): `longshot_vk.so` linked. - Merged with #912 (the conflict resolved as under Why): `tests/test_mma_software.py` passes, and #912's `tests/test_coopmat_safe_free.py` passes once its marker for `run_shader`'s first line is updated. **Not tested:** - The review fixes in `1a75f5e6`: read, not built or run before they were pushed; the forge's checks run `tests/test_mma_software.py` on them. Wanted: one Polaris (RX 400/500) start showing the `software matrix multiplies` lines (the f16 form not tried, then the integer form's result). - Kokiri Forest at the Deck's handheld settings (1280x720, render 50%): runs queued, numbers to follow. - Other RADV GPUs, where the unrolled form is tried by default: RDNA 1 and 2 desktop and laptop GPUs, RDNA 3 and 4 (in software until #1038), Polaris and older GCN. The self-test keeps the picture the same there; the speed is not measured. - Intel and NVIDIA GTX 10 and 16 in the game (the loop stays unless `RX_VK_MMA_UNROLL=1`), and Windows in the game (the default tries only RADV, a Linux driver, so Windows players keep the loop; the Windows renderer was built, not run). - Together with #687's `RX_VK_TAAU_FULL_SIZE=1` or #1053's `RX_VK_GPU_CLOCK=1`. **Must be tested:** - linux, amd, radv, an RDNA 1 or 2 GPU (no cooperative matrices): Hyrule Field at render resolution 100% from empty program caches, once with `RX_VK_MMA_UNROLL=0` and once unset, expecting the log line `vk: software matrix multiplies unrolled, ...: the loop's words for 8192 lanes` when unset, a frame rate no lower than with the loop and the same picture (Test Farm: @Beanstalk linux amd radv, Hyrule Field at 100% render with RX_VK_MMA_UNROLL=0 and unset, compare the frame rate and screenshots and post the "software matrix multiplies" log line) - linux, amd, radv, an RDNA 3 or 4 GPU: the same steps, expecting `vk: matrix multiplies in software (the cooperative matrices lack 16x8x16 f16)` and then the unrolled line, a frame rate no lower and the same picture (Test Farm: @Beanstalk linux amd radv rdna3, Hyrule Field at 100% render with RX_VK_MMA_UNROLL=0 and unset, compare the frame rate and screenshots and post the "software matrix multiplies" log line) - windows, any GPU: one start into Hyrule Field, expecting a `vk: software matrix multiplies looped` line (or native multiplies) and no unrolled line, at main's frame rate (Test Farm: @Beanstalk windows, one start in Hyrule Field, post the "matrix multiplies" log lines) ## Risks **What could break:** - A driver whose unrolled results differ only for inputs the self-test does not have: it would show as a slightly different upscaled picture. The inputs cover f16 values of every kind and the ties that catch a folded conversion; `RX_VK_MMA_UNROLL=0` restores the loop. - Speed on RADV GPUs other than the Deck's: measured on the Deck only; where it is slower, the switch is the way back. - Start: the self-test makes three small compute pipelines and dispatches at start on software-multiply GPUs where it is tried (RADV by default); on the Deck, start to the first present moved within the runs' spread. - The full-size network's first compile, once per cache: about 3 s longer on the Deck (12 -> 15 s, on a worker, the pass left out meanwhile as before). - The self-test runs the function in a 32-lane test module; in the game Mesa inlines it into the network, and the game programs carry float-control modes the test module doesn't. These match while the 16-bit denormal modes are not emitted (`support_fp16_denorm_*` unset, noted in vk_coopmat.cpp). - The xor-0 shuffle that keeps the f16 conversion out of the FMA holds only while the driver keeps it: a Mesa that folds it away falls back to the loop through the tie inputs, slower, said only in the log. - If the self-test's result changes between starts (a dispatch that did not complete), the stamp changes and the program cache is translated again. **Turning it off:** `RX_VK_MMA_UNROLL=0`, or revert the commit. **Compatibility:** this PR changes the shader translator's files (`gpu/vk/eden/shader_recompiler/backend/spirv/`), so after updating every player on every GPU translates their programs again, once, at the first start (the build's shader stamp hashes those files). On GPUs that multiply in software the chosen form is also in the program cache's stamp, so setting or clearing `RX_VK_MMA_UNROLL` there translates again. Saves, `longshot_options.ini` and the vk ABI (`MKWVK_API_VERSION`, `vk_api.h` untouched) do not change. ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated.
On GPUs without cooperative matrices (the Steam Deck and other AMD GPUs
before RDNA 3, GTX 10 and 16, Intel's integrated GPUs) the game's upscale
networks run HMMA.16816.F16 as a shader function. On the Deck that
function is most of the gameplay network's 8.6 ms a frame: each multiply
takes 32 shuffles through the LDS crossbar, rounds to f16 with about 15
integer operations a value, and runs as a loop of 8 steps.

The function moves to mma_software.h, built the same way by the
translator and by a self-test, in two forms:

- Loop: Lichii's, as before (the SPIR-V is the same word for word).
- Unrolled: the steps written out, in a loop that runs once. A comes
  through quad broadcasts (a lane's rows of A are in its own quad: DPP
  on AMD), every lane index is a constant, and the f16 rounding is the
  GPU's own f32 -> f16 -> f32 conversion. The value goes through a
  shuffle with lane xor 0 first: RADV otherwise folds the conversion into
  the FMA before it (v_fma_mixlo_f16), which rounds the exact sum once
  instead of to f32 first, and 1 word in about 17,000 of random data
  comes out one f16 step away. RADV folds the shuffle into the
  conversion as a DPP identity, at no cost. Without the one-trip loop,
  Mesa's CSE shares the shuffles of an operand several multiplies take
  and holds them: the network took 256 VGPRs (4 waves a SIMD, not 8) and
  the 3/4 one spilled 181 to scratch.

At start (vk_coopmat.cpp choose_software_form) both forms multiply the
same 8,192 lanes' fragments on the device: f16 values of every kind, and
warps built so that a K group's sum lands on an f16 tie after its f32
rounding, which catches a driver that folds the conversion. The unrolled
form is used only where every word is the loop's, with the conversion,
else with the integer rounding, else not. RX_VK_MMA_UNROLL=0 keeps the
loop, =1 tries the unrolled form on any GPU; by default it is tried on
RADV, where it was measured. The form is in the program cache's stamp
(0 for the loop, so other GPUs' caches are as before).

Steam Deck LCD, RADV (Mesa 26.2.7), Kokiri Forest, Resolution 100%,
1280x800: the network 8.61 -> 3.82 ms a frame (pass timing), 11.7 ->
12.4 / 12.5 fps, GPU 57.4 -> 52.3 ms a frame, interleaved with the loop
(RX_VK_MMA_UNROLL=0) on the same build.

tests/test_mma_software.py: every form through spirv-val with its shape,
the self-test's inputs against CPU models of the loop and of a folding
driver, the switch, the emitter's form and the stamp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e95c60a64224fc35eeb1deab07ccf0a0ca8b8ad9)
(cherry picked from commit 01f9b690d5ef058cae970c8b6ce3ca2970d562f3)
[port: the fork's names as Longshot's (tests/test_mma_software.py: compat/bunnyhood_env.h as compat/longshot_env.h; docs/development.md keeps main's rows beside the new one); its rename-only hunks ((hookshot) comment tags as (longshot)) in the fork's GPU clock files and two vk_main.cpp comments (system_ram_mb's, the GPU clock call's), none of which Longshot has, left out: Longshot's side taken]
docs(tested): the software matrix multiplies unrolled and looped on a Steam Deck OLED at native 1280x800
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 3s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
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
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
3e6ab7c9fb
Twelve runs in one session: Hyrule Field and Kokiri Forest, timed loop,
unrolled, unrolled, loop and pass timing loop, unrolled, each from empty
caches on a renderer pack of this branch's `gpu/` change.

Assisted-by: Claude
Author
Contributor

Tested in game: Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel), this branch's gpu/ change as a renderer pack on an older main: Hyrule Field and Kokiri Forest at 1280x800, the loop (RX_VK_MMA_UNROLL=0) against the default, interleaved. The self-test chose the unrolled form; the full-size network went from about 9.4 to 4.2 ms a frame and the Field from 14.83 to 16.06 fps; the pictures of the two arms match within the scene's own animation.

Tested in game: Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel), this branch's gpu/ change as a renderer pack on an older main: Hyrule Field and Kokiri Forest at 1280x800, the loop (RX_VK_MMA_UNROLL=0) against the default, interleaved. The self-test chose the unrolled form; the full-size network went from about 9.4 to 4.2 ms a frame and the Field from 14.83 to 16.06 fps; the pictures of the two arms match within the scene's own animation.
Author
Contributor

Hi @sheep! Your unrolled software multiplies (BunnyHood 01f9b690d, from your e95c60a) are in this PR as you wrote them: your commit cherry-picked with your authorship and both cherry picked from lines kept, with only a [port: ...] line for the fork's names. The self-test that takes the unrolled form only where it gives the loop's exact words is a lovely way to make a faster default safe, and the v_fma_mixlo_f16 write-up taught us something. Thank you.

We ran it on a Steam Deck OLED, and it matches what you saw on your LCD:

Loop Unrolled
yours: Deck LCD, Kokiri Forest, 1280x800 100% network 8.61 ms, 11.7 fps network 3.82 ms, 12.4 fps
ours: Deck OLED, Kokiri Forest, 1280x800 100% network 9.48 ms, 9.16 fps network 5.77 ms, 9.77 fps
ours: Deck OLED, Hyrule Field, 1280x800 100% network 9.27-9.51 ms, 14.83 fps network 4.05-4.30 ms, 16.06 fps

(Ours: the median of two interleaved runs a side from empty caches, the network's time from pass timing; the self-test chose "f16 rounding by conversion, A through quad broadcasts" on RADV VANGOGH every time, and the pictures match.) We kept your default, tried on RADV, and the PR says why.

This PR is yours as much as ours: you're welcome to take it over, send commits to it, or leave it with us, whichever suits you.

Hi @sheep! Your unrolled software multiplies (BunnyHood `01f9b690d`, from your `e95c60a`) are in this PR as you wrote them: your commit cherry-picked with your authorship and both `cherry picked from` lines kept, with only a `[port: ...]` line for the fork's names. The self-test that takes the unrolled form only where it gives the loop's exact words is a lovely way to make a faster default safe, and the `v_fma_mixlo_f16` write-up taught us something. Thank you. We ran it on a Steam Deck OLED, and it matches what you saw on your LCD: | | Loop | Unrolled | |---|---|---| | yours: Deck LCD, Kokiri Forest, 1280x800 100% | network 8.61 ms, 11.7 fps | network 3.82 ms, 12.4 fps | | ours: Deck OLED, Kokiri Forest, 1280x800 100% | network 9.48 ms, 9.16 fps | network 5.77 ms, 9.77 fps | | ours: Deck OLED, Hyrule Field, 1280x800 100% | network 9.27-9.51 ms, 14.83 fps | network 4.05-4.30 ms, 16.06 fps | (Ours: the median of two interleaved runs a side from empty caches, the network's time from pass timing; the self-test chose "f16 rounding by conversion, A through quad broadcasts" on RADV VANGOGH every time, and the pictures match.) We kept your default, tried on RADV, and the PR says why. This PR is yours as much as ours: you're welcome to take it over, send commits to it, or leave it with us, whichever suits you.
Author
Contributor

@Beanstalk linux amd radv (any card without cooperative matrices; an RDNA 3 or 4 card too if one is free): Hyrule Field and Kokiri Forest at the display's own resolution, a few minutes each, with RX_VK_MMA_UNROLL=0 and without it. Expecting the log line vk: software matrix multiplies unrolled ... by default, the same picture, and GPU time equal or lower than with the loop. The first start after the change translates the programs again once.

@Beanstalk linux amd radv (any card without cooperative matrices; an RDNA 3 or 4 card too if one is free): Hyrule Field and Kokiri Forest at the display's own resolution, a few minutes each, with `RX_VK_MMA_UNROLL=0` and without it. Expecting the log line `vk: software matrix multiplies unrolled ...` by default, the same picture, and GPU time equal or lower than with the loop. The first start after the change translates the programs again once.
Member

@zeldaootr only members of BigBeans can start the farm.

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

@zeldaootr only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it.~~ This request was for `3e6ab7c`, and the PR has changed since (`1a75f5e`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
HumanBean left a comment

Code review only. I didn't run any tests or builds.

This is a clear, well-argued change. Building both forms from one header, so the self-test compiles the same function the translator emits, is the right way to make a faster default safe. The tie inputs at K 7 and 15 are a good catch for the v_fma_mixlo_f16 fold. The loop's SPIR-V is still word for word the same, the stamp keeps the loop at 0 (so the caches of GPUs that keep the loop stay valid), and software_multiplies now routes RX_VK_MMA_SOFTWARE=1 through the same choice. The Deck numbers are interleaved, taken from empty caches, and include sheep's LCD runs. That is good evidence for the Deck.

One change before merge. The rest are small.

Blocking: f16 on RADV GPUs that have no shaderFloat16 (Polaris, RX 400/500). The default tries the unrolled forms on every RADV device, including GCN 4. There, dev.vk12.shaderFloat16 is false, and vk_shader.cpp host_info already says f16 SPIR-V "drew Kokiri Forest as coloured noise on an RX 580".

  • software_test_shader always declares Float16 and OpTypeFloat 16.
  • UnrolledF16 emits real OpFConverts to f16, in the test and in the game.

Using f16 types without the feature is invalid Vulkan usage. The self-test only helps if the driver gives wrong words. Worse outcomes are a pipeline that fails or crashes, or one that passes the test and then behaves differently inside a network. The loop itself never converts to f16; the Float16 capability network programs already carry comes from MatrixMulAddF16 setting uses_fp16. The fix is small:

  • In choose_software_form, skip UnrolledF16 when !dev.vk12.shaderFloat16, so only the integer Unrolled is tried.
  • Declare Float16 and OpTypeFloat 16 in the test module only for the form that uses them.

This doesn't change anything on the Deck.

Smaller things (inline):

  • software_forms_agree returns false before it sets *differ when run_shader fails. choose_software_form then logs "gave N of 16384 words other than the loop's" with N left at 0 or at the previous form's count, when the form never ran. Please give that case its own log line.
  • quad is decided from supportedStages & COMPUTE only. The translator then emits OpGroupNonUniformQuadBroadcast in whatever stage the HMMA program has. Quad operations are guaranteed only in fragment and compute, unless quadOperationsInAllStages is set. The networks are compute, and RADV sets that flag, so this is about =1 on other drivers. Either check quadOperationsInAllStages, or use quads only when ctx.stage is compute or fragment.
  • mma_software.h line 12 says "every lane index is a constant". A's lanes are constant, but B's shuffle lane is still warp_base + col_base + c. The comment could say "A's lane indices are constants".
  • tests/test_mma_software.py brings its own block/between with a brace counter. AGENTS.md asks new checks to cut with tests/srccut.py, which gives one clear message when a marker is missing or appears twice.
  • Nit, optional: DefineSoftwareMma sets up counter in two back-to-back if (!loop) / if (loop) blocks. Since counter comes first in both, one allocation before them gives the same SPIR-V.

Not blocking, for the Risks section:

  • The self-test certifies the function compiled inside a 32-lane test module. In the game, Mesa inlines it into the network and optimises across the call. The test module also has none of the game programs' float-control execution modes (DenormFlushToZero/SignedZeroInfNanPreserve for 32-bit). The 16-bit modes are not emitted today (support_fp16_denorm_* is unset), so the conversion's f16 subnormal behaviour matches. If those profile bits are ever turned on, the test stops standing for the game. A one-line comment by make_profile or choose_software_form would keep that tie visible.
  • The shuffle-xor-0 barrier relies on NIR keeping it. If a future Mesa folds it away, the tie inputs should catch the fused rounding, and the loop is kept. That is the design working, but it is worth one line in the header comment.
  • If the self-test's result changes between starts (for example a dispatch that didn't complete), the stamp changes and the whole program cache is translated again. This is rare and self-correcting; I mention it only so it's known.

Testing: There are 12 in-game runs on a Deck OLED plus sheep's LCD runs. Still missing are the description's own Must be tested runs: RDNA 1/2, RDNA 3/4 (in software until #1038), and the Windows start. The Test Farm request is waiting on a BigBean's approval. With the Float16 gate added, one Polaris start that shows the "software matrix multiplies" line would also be worth having, since GCN 4 gets the new default.

Overlaps (as the description says):

  • #912 conflicts in run_shader, and its check's marker needs the new signature.
  • #1038 also uses stamp bits 256/512, so whichever PR lands second must move its bits.
  • #687 and #1053 are independent.

🤖 Generated with Claude Code

Code review only. I didn't run any tests or builds. This is a clear, well-argued change. Building both forms from one header, so the self-test compiles the same function the translator emits, is the right way to make a faster default safe. The tie inputs at K 7 and 15 are a good catch for the `v_fma_mixlo_f16` fold. The loop's SPIR-V is still word for word the same, the stamp keeps the loop at 0 (so the caches of GPUs that keep the loop stay valid), and `software_multiplies` now routes `RX_VK_MMA_SOFTWARE=1` through the same choice. The Deck numbers are interleaved, taken from empty caches, and include sheep's LCD runs. That is good evidence for the Deck. One change before merge. The rest are small. **Blocking: f16 on RADV GPUs that have no `shaderFloat16` (Polaris, RX 400/500).** The default tries the unrolled forms on every RADV device, including GCN 4. There, `dev.vk12.shaderFloat16` is false, and `vk_shader.cpp` `host_info` already says f16 SPIR-V "drew Kokiri Forest as coloured noise on an RX 580". - `software_test_shader` always declares `Float16` and `OpTypeFloat 16`. - `UnrolledF16` emits real `OpFConvert`s to f16, in the test and in the game. Using f16 types without the feature is invalid Vulkan usage. The self-test only helps if the driver gives wrong words. Worse outcomes are a pipeline that fails or crashes, or one that passes the test and then behaves differently inside a network. The loop itself never converts to f16; the Float16 capability network programs already carry comes from `MatrixMulAddF16` setting `uses_fp16`. The fix is small: - In `choose_software_form`, skip `UnrolledF16` when `!dev.vk12.shaderFloat16`, so only the integer `Unrolled` is tried. - Declare `Float16` and `OpTypeFloat 16` in the test module only for the form that uses them. This doesn't change anything on the Deck. **Smaller things (inline):** - `software_forms_agree` returns false before it sets `*differ` when `run_shader` fails. `choose_software_form` then logs "gave N of 16384 words other than the loop's" with N left at 0 or at the previous form's count, when the form never ran. Please give that case its own log line. - `quad` is decided from `supportedStages & COMPUTE` only. The translator then emits `OpGroupNonUniformQuadBroadcast` in whatever stage the HMMA program has. Quad operations are guaranteed only in fragment and compute, unless `quadOperationsInAllStages` is set. The networks are compute, and RADV sets that flag, so this is about `=1` on other drivers. Either check `quadOperationsInAllStages`, or use quads only when `ctx.stage` is compute or fragment. - `mma_software.h` line 12 says "every lane index is a constant". A's lanes are constant, but B's shuffle lane is still `warp_base + col_base + c`. The comment could say "A's lane indices are constants". - `tests/test_mma_software.py` brings its own `block`/`between` with a brace counter. AGENTS.md asks new checks to cut with `tests/srccut.py`, which gives one clear message when a marker is missing or appears twice. - Nit, optional: `DefineSoftwareMma` sets up `counter` in two back-to-back `if (!loop)` / `if (loop)` blocks. Since `counter` comes first in both, one allocation before them gives the same SPIR-V. **Not blocking, for the Risks section:** - The self-test certifies the function compiled inside a 32-lane test module. In the game, Mesa inlines it into the network and optimises across the call. The test module also has none of the game programs' float-control execution modes (`DenormFlushToZero`/`SignedZeroInfNanPreserve` for 32-bit). The 16-bit modes are not emitted today (`support_fp16_denorm_*` is unset), so the conversion's f16 subnormal behaviour matches. If those profile bits are ever turned on, the test stops standing for the game. A one-line comment by `make_profile` or `choose_software_form` would keep that tie visible. - The shuffle-xor-0 barrier relies on NIR keeping it. If a future Mesa folds it away, the tie inputs should catch the fused rounding, and the loop is kept. That is the design working, but it is worth one line in the header comment. - If the self-test's result changes between starts (for example a dispatch that didn't complete), the stamp changes and the whole program cache is translated again. This is rare and self-correcting; I mention it only so it's known. **Testing:** There are 12 in-game runs on a Deck OLED plus sheep's LCD runs. Still missing are the description's own *Must be tested* runs: RDNA 1/2, RDNA 3/4 (in software until [#1038](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1038)), and the Windows start. The Test Farm request is waiting on a BigBean's approval. With the Float16 gate added, one Polaris start that shows the "software matrix multiplies" line would also be worth having, since GCN 4 gets the new default. **Overlaps** (as the description says): - [#912](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/912) conflicts in `run_shader`, and its check's marker needs the new signature. - [#1038](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1038) also uses stamp bits 256/512, so whichever PR lands second must move its bits. - [#687](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/687) and [#1053](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053) are independent. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
@ -0,0 +9,4 @@
// - Loop: Lichii's (zortos293/Lichii, emit_spirv_tensor.cpp, GPL-3.0). The 8 steps (4 K-pairs in each half of K) in a loop the
// driver is asked not to unroll; A and B from other lanes through shuffles, the f16 rounding in integer operations.
// - Unrolled: the steps written out (in a loop that runs once: see below). A lane's rows of A are in its own quad (lanes 4g..4g+3), so A comes through quad broadcasts
// (DPP on AMD, not the LDS crossbar a shuffle takes), and every lane index is a constant. The rounding to f16 is either the same
Owner

Nit: only A's lane indices are constants. B's shuffle lane is still warp_base + col_base + c.

Nit: only A's lane indices are constants. B's shuffle lane is still `warp_base + col_base + c`.
@ -0,0 +67,4 @@
};
const auto round_half_f16 = [&](Id value) {
// (through the same lane first: the conversion is then not folded into the FMA that made the value, see above)
const Id same = m.OpBitcast(f32ty, m.OpGroupNonUniformShuffleXor(u32ty, imm(3), m.OpBitcast(u32ty, value), imm(0)));
Owner

Worth one more line in the header comment: this barrier holds only while NIR keeps a shuffle-xor by 0. If a later Mesa folds it away, the fold comes back and the tie inputs make the self-test fall back to the loop. That is fine, but the slowdown would be silent.

Worth one more line in the header comment: this barrier holds only while NIR keeps a shuffle-xor by 0. If a later Mesa folds it away, the fold comes back and the tie inputs make the self-test fall back to the loop. That is fine, but the slowdown would be silent.
@ -342,0 +433,4 @@
/// The two forms' words the same (any NaN is a NaN), false when the device could not run one
bool software_forms_agree(Shader::Backend::SPIRV::SoftwareMmaForm form, bool quad, const std::vector<uint32_t>& loop, size_t* differ) {
std::vector<uint32_t> data = software_test_input();
if (!run_shader(software_test_shader(form, quad), data, kSoftwareTestLanes / 32, "software matrix test")) return false;
Owner

When run_shader fails, this returns before *differ is set. The caller then logs "gave N of 16384 words other than the loop's" with a stale N (0, or the previous form's count) for a form that never ran. Please set *differ first and log the did-not-run case separately.

When `run_shader` fails, this returns before `*differ` is set. The caller then logs "gave N of 16384 words other than the loop's" with a stale N (0, or the previous form's count) for a form that never ran. Please set `*differ` first and log the did-not-run case separately.
@ -342,0 +462,4 @@
VkPhysicalDeviceProperties2 p2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2};
p2.pNext = &sg;
vkGetPhysicalDeviceProperties2(dev.physical, &p2);
const bool quad = (sg.supportedOperations & VK_SUBGROUP_FEATURE_QUAD_BIT) && (sg.supportedStages & VK_SHADER_STAGE_COMPUTE_BIT);
Owner

This checks only the compute stage, but the translator emits the quad broadcast in whatever stage ctx.stage is. Quad operations outside fragment and compute need sg.quadOperationsInAllStages. Either check that flag here, or in DefineSoftwareMatrixFunction use quads only when the stage is compute or fragment. RADV sets the flag, so this matters for =1 on other drivers.

This checks only the compute stage, but the translator emits the quad broadcast in whatever stage `ctx.stage` is. Quad operations outside fragment and compute need `sg.quadOperationsInAllStages`. Either check that flag here, or in `DefineSoftwareMatrixFunction` use quads only when the stage is compute or fragment. RADV sets the flag, so this matters for `=1` on other drivers.
@ -342,0 +469,4 @@
return;
}
size_t differ = 0;
for (const SoftwareMmaForm form : {SoftwareMmaForm::UnrolledF16, SoftwareMmaForm::Unrolled}) {
Owner

On RADV Polaris (GCN 4), dev.vk12.shaderFloat16 is false, and host_info already avoids f16 SPIR-V there because of the RX 580 noise. Please skip UnrolledF16 when !dev.vk12.shaderFloat16. Also have software_test_shader declare Float16 and OpTypeFloat 16 only for that form. Without the feature, this is invalid Vulkan usage, and the self-test can't be relied on to catch it.

On RADV Polaris (GCN 4), `dev.vk12.shaderFloat16` is false, and `host_info` already avoids f16 SPIR-V there because of the RX 580 noise. Please skip `UnrolledF16` when `!dev.vk12.shaderFloat16`. Also have `software_test_shader` declare `Float16` and `OpTypeFloat 16` only for that form. Without the feature, this is invalid Vulkan usage, and the self-test can't be relied on to catch it.
fix(vk): the unrolled f16 form only where the device has shaderFloat16; review points
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 11s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 17s
CI / Workflow lint (actionlint) (pull_request) Successful in 19s
PR description / Description follows the template (pull_request_target) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 29s
beanstalk/approval changed since the request: ask again
1a75f5e6a0
Review of #1086:
- choose_software_form skips the unrolled f16 form on a GPU without f16 shaders (RADV
  Polaris, RX 400/500): only the integer unrolled form is tried there. The self-test's
  module declares Float16 and OpTypeFloat 16 only for the f16 form; the loop and the
  integer form need neither. The translator takes the form only from the self-test, so
  no other path gives f16 to such a GPU (and its networks are left out anyway).
- software_forms_agree sets *differ to kSoftwareFormDidNotRun before the dispatch, and
  choose_software_form logs a form whose test did not run as such, not a stale count.
- Quad broadcasts only where the device has quad operations in every stage
  (quadOperationsInAllStages): the translator may emit the function in any stage with
  subgroup operations, and the self-test then tests the same function. RADV sets it.
- mma_software.h: only A's lane indices are constants; the xor-0 shuffle barrier holds
  only while the driver keeps it. vk_coopmat.cpp: the test stands for the game programs
  while their f16 denormal modes are unset.
- DefineSoftwareMma makes the counter once, first in either form: the same SPIR-V, word
  for word, in both forms.
- tests/test_mma_software.py cuts with tests/srccut.py (every marker is unique in its
  source).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean deleted branch mma-unroll 2026-11-16 09:50:09 +00:00
Contributor

Deck OLED: in a Deck play build, at native 1280x800

Hardware: Steam Deck OLED (AMD Custom GPU 0932, RADV VANGOGH, Mesa 26.2.0-devel), SteamOS 3.9.5, docked, in Game Mode through Steam.
Build: a Deck play build, v3.0.0-rc.5 + #225 + #227 + #222 + #977 (off) + #1086 + #1053 + #906 + #790 + #391 + #568 (for #1086, #391 and #568 their own commits, since they sit on newer mains). Linux, the release toolchain (LLVM 23.1.5), x86-64-v3 with the play profile.
Settings: Docked, output 1280x800, the game's own upscaler at 100%, frame generation 3x; longshot_env.txt sets RX_VK_READBACK_LATE=newest.

  • Engaged in every run of the build: vk: software matrix multiplies unrolled, f16 rounding by conversion, A through quad broadcasts: the loop's words for 8192 lanes.
  • The full-size network 9dc98871eb7fc101 with RX_VK_PASS_TIMING=2, one run each on our moving Kokiri route: 9.01-9.16 ms a frame without (the loop), 3.92-3.95 ms with (-56%; the full report periods).
  • fps at stock clocks, the build against the same stack without the six PRs (so not this PR alone): game fps 13.4 / 12.7 against 12.6 / 12.7, shown (3x) 37.7 / 36.0 against 34.2 / 33.2, p95 62 / 62 ms against 104 / 111, frames over 100 ms 77 / 92 against 151 / 165.
  • Pictures: 15 shots a run along the route. I saw no noise, blocks or colour shifts in the anti-aliased edges, foliage or HUD, compared with the runs without it. The shots are not at the same frames (the camera turns on a clock), so I didn't compare them pixel by pixel.
  • tests/test_mma_software.py was skipped in our Linux container (no spirv-val).

This build is now the owner's Deck play build.

**Deck OLED: in a Deck play build, at native 1280x800** Hardware: Steam Deck OLED (AMD Custom GPU 0932, RADV VANGOGH, Mesa 26.2.0-devel), SteamOS 3.9.5, docked, in Game Mode through Steam. Build: a Deck play build, v3.0.0-rc.5 + #225 + #227 + #222 + #977 (off) + #1086 + #1053 + #906 + #790 + #391 + #568 (for #1086, #391 and #568 their own commits, since they sit on newer mains). Linux, the release toolchain (LLVM 23.1.5), `x86-64-v3` with the play profile. Settings: Docked, output 1280x800, the game's own upscaler at 100%, frame generation 3x; `longshot_env.txt` sets `RX_VK_READBACK_LATE=newest`. - Engaged in every run of the build: `vk: software matrix multiplies unrolled, f16 rounding by conversion, A through quad broadcasts: the loop's words for 8192 lanes`. - The full-size network `9dc98871eb7fc101` with `RX_VK_PASS_TIMING=2`, one run each on our moving Kokiri route: **9.01-9.16 ms a frame** without (the loop), **3.92-3.95 ms** with (-56%; the full report periods). - fps at stock clocks, the build against the same stack without the six PRs (so not this PR alone): game fps 13.4 / 12.7 against 12.6 / 12.7, shown (3x) 37.7 / 36.0 against 34.2 / 33.2, p95 62 / 62 ms against 104 / 111, frames over 100 ms 77 / 92 against 151 / 165. - Pictures: 15 shots a run along the route. I saw no noise, blocks or colour shifts in the anti-aliased edges, foliage or HUD, compared with the runs without it. The shots are not at the same frames (the camera turns on a clock), so I didn't compare them pixel by pixel. - `tests/test_mma_software.py` was skipped in our Linux container (no `spirv-val`). This build is now the owner's Deck play build.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!1086
No description provided.