perf(vk): software matrix multiplies unrolled where the device gives the loop's words (RX_VK_MMA_UNROLL=0 keeps the loop) #1086
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1086
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:mma-unroll"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 ownsheep/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 bothcherry picked fromlines 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:run_shaderingpu/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'ssubmittedand its wait without a limit, and this PR'swhatin the log line. #912's fix then also covers this PR's self-test, whose three dispatches go throughrun_shader. Merged with this PR, #912's own checktests/test_coopmat_safe_free.pyneeds its marker forrun_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 doestests/test_mma_software.py.mma_layout.h(both add globals aftermma_software: keep both) and intranslator_stampinvk_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).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.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.
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.cppDefineSoftwareMatrixFunctioncalls it in the chosen form (the loop's SPIR-V unchanged);mma_layout.hholds the chosen form (mma_software_form,mma_software_quad).gpu/vk/vk_coopmat.cppchoose_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_shadertakes a group count.software_unroll_wanted:RX_VK_MMA_UNROLL=0the loop,=1tried on any GPU, unset tried on RADV. The log'svk: software matrix multiplies ...line says which form is used and why.gpu/vk/vk_shader.cpptranslator_stampholds the form (0 for the loop, as before).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/development.md(sheep); twelve files indocs/tested/for our Deck runs (ours).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.pycuts withtests/srccut.py; comments inmma_software.hsay 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 main9c9d69ed, the Deck's development base, plus this branch'sgpu/diff, applied with a three-way merge and no conflict. "Before" is that pack withRX_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.handvk_coopmat.cppare 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 between9c9d69edand this PR's base02903b04. What main changed since9c9d69edcan 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 withRX_VK_PRECOMPILE=0(the translator changed, so no warm cache is valid), 75 s warm-up then 45 s standing. Fps and present intervals fromHOS_PRESENT_TRACEin the 45 s sample (1% low: 1000 / the mean of the slowest 1% of present intervals), GPU time from the log'svk: GPU timelines, 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_ERRORor amdgpu kernel lineHow to reproduce: a child save; Kokiri Forest beside Saria, or teleport to Hyrule Field; options
output_res=1280x800,resolution=1(100%);RX_VK_PRECOMPILE=0and empty program caches;RX_VK_MMA_UNROLL=0against unset, alternating;RX_VK_PASS_TIMING=2for the network's rowRX_VK_MMA_UNROLL=0(the loop): packmmaun@ e2d3f793mmaun@ e2d3f7939dc98871eb7fc101, ms a frame (pass timing, the report periods after its compile)RX_VK_MMA_UNROLL=0)RX_VK_MMA_UNROLL=0(the loop): packmmaun@ e2d3f793mmaun@ e2d3f7939dc98871eb7fc101, ms a frame (pass timing, the one report period in the sample)RX_VK_MMA_UNROLL=0)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.
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.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.
RX_VK_MMA_UNROLL0the loop;1tried on any GPU0to roll backWhy 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=0as the way back. Other drivers keep the loop unless=1.Testing
Tested:
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_ERRORor amdgpu kernel line, and the pictures match.LONGSHOT_VULKAN_HEADERSandLONGSHOT_SPIRV_HEADERSset so the header checks run, on head 3e6ab7c9's code (the last rebase moved it over two main commits that touch onlynx2/make_game.pyand two tests;git range-diffshows both commits unchanged):tests/test_mma_software.pythroughrun_all.py --strict, withCXX=g++(13.3) andCXX=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_queriesandtest_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 main02903b04too, 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, andtest_fpx_stickyandtest_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_dialogpasses;test_failed_compile_keeps_objectsfails, as on mainf7922126.RX_VK_ONLY=1 RX_RELEASE=1 RX_TARGET=windows python -I nx2/build.py --standalone):longshot_vk.dllcompiled and linked, no warning; and for Linux with clang++ 23.1.5 (the same withoutRX_TARGET):longshot_vk.solinked.tests/test_mma_software.pypasses, and #912'stests/test_coopmat_safe_free.pypasses once its marker forrun_shader's first line is updated.Not tested:
1a75f5e6: read, not built or run before they were pushed; the forge's checks runtests/test_mma_software.pyon them. Wanted: one Polaris (RX 400/500) start showing thesoftware matrix multiplieslines (the f16 form not tried, then the integer form's result).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).RX_VK_TAAU_FULL_SIZE=1or #1053'sRX_VK_GPU_CLOCK=1.Must be tested:
RX_VK_MMA_UNROLL=0and once unset, expecting the log linevk: software matrix multiplies unrolled, ...: the loop's words for 8192 laneswhen 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)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)vk: software matrix multiplies loopedline (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:
RX_VK_MMA_UNROLL=0restores the loop.support_fp16_denorm_*unset, noted in vk_coopmat.cpp).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 clearingRX_VK_MMA_UNROLLthere translates again. Saves,longshot_options.iniand the vk ABI (MKWVK_API_VERSION,vk_api.huntouched) do not change.Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).tests/that reads changed source updated in this PR, not weakened.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.
Hi @sheep! Your unrolled software multiplies (BunnyHood
01f9b690d, from youre95c60a) are in this PR as you wrote them: your commit cherry-picked with your authorship and bothcherry picked fromlines 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 thev_fma_mixlo_f16write-up taught us something. Thank you.We ran it on a Steam Deck OLED, and it matches what you saw on your LCD:
(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.
@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=0and without it. Expecting the log linevk: 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.@zeldaootr only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it.This request was for3e6ab7c, and the PR has changed since (1a75f5e), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.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_f16fold. 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), andsoftware_multipliesnow routesRX_VK_MMA_SOFTWARE=1through 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.shaderFloat16is false, andvk_shader.cpphost_infoalready says f16 SPIR-V "drew Kokiri Forest as coloured noise on an RX 580".software_test_shaderalways declaresFloat16andOpTypeFloat 16.UnrolledF16emits realOpFConverts 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
MatrixMulAddF16settinguses_fp16. The fix is small:choose_software_form, skipUnrolledF16when!dev.vk12.shaderFloat16, so only the integerUnrolledis tried.Float16andOpTypeFloat 16in the test module only for the form that uses them.This doesn't change anything on the Deck.
Smaller things (inline):
software_forms_agreereturns false before it sets*differwhenrun_shaderfails.choose_software_formthen 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.quadis decided fromsupportedStages & COMPUTEonly. The translator then emitsOpGroupNonUniformQuadBroadcastin whatever stage the HMMA program has. Quad operations are guaranteed only in fragment and compute, unlessquadOperationsInAllStagesis set. The networks are compute, and RADV sets that flag, so this is about=1on other drivers. Either checkquadOperationsInAllStages, or use quads only whenctx.stageis compute or fragment.mma_software.hline 12 says "every lane index is a constant". A's lanes are constant, but B's shuffle lane is stillwarp_base + col_base + c. The comment could say "A's lane indices are constants".tests/test_mma_software.pybrings its ownblock/betweenwith a brace counter. AGENTS.md asks new checks to cut withtests/srccut.py, which gives one clear message when a marker is missing or appears twice.DefineSoftwareMmasets upcounterin two back-to-backif (!loop)/if (loop)blocks. Sincecountercomes first in both, one allocation before them gives the same SPIR-V.Not blocking, for the Risks section:
DenormFlushToZero/SignedZeroInfNanPreservefor 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 bymake_profileorchoose_software_formwould keep that tie visible.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):
run_shader, and its check's marker needs the new signature.🤖 Generated with 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 sameNit: 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)));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 onebool 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;When
run_shaderfails, this returns before*differis 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*differfirst 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);This checks only the compute stage, but the translator emits the quad broadcast in whatever stage
ctx.stageis. Quad operations outside fragment and compute needsg.quadOperationsInAllStages. Either check that flag here, or inDefineSoftwareMatrixFunctionuse quads only when the stage is compute or fragment. RADV sets the flag, so this matters for=1on other drivers.@ -342,0 +469,4 @@return;}size_t differ = 0;for (const SoftwareMmaForm form : {SoftwareMmaForm::UnrolledF16, SoftwareMmaForm::Unrolled}) {On RADV Polaris (GCN 4),
dev.vk12.shaderFloat16is false, andhost_infoalready avoids f16 SPIR-V there because of the RX 580 noise. Please skipUnrolledF16when!dev.vk12.shaderFloat16. Also havesoftware_test_shaderdeclareFloat16andOpTypeFloat 16only for that form. Without the feature, this is invalid Vulkan usage, and the self-test can't be relied on to catch it.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-v3with the play profile.Settings: Docked, output 1280x800, the game's own upscaler at 100%, frame generation 3x;
longshot_env.txtsetsRX_VK_READBACK_LATE=newest.vk: software matrix multiplies unrolled, f16 rounding by conversion, A through quad broadcasts: the loop's words for 8192 lanes.9dc98871eb7fc101withRX_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).tests/test_mma_software.pywas skipped in our Linux container (nospirv-val).This build is now the owner's Deck play build.