feat(vk): enable Switch 2 AI upscaler on AMD RDNA 3/3.5/4 via fused 16x16x16 WMMA (+9-12% native FPS, sharper in-game upscaling) #2043
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
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2043
Loading…
Reference in a new issue
No description provided.
Delete branch "Jer9/Longshot:feat/wmma16-fused"
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?
Summary
On
main, the game's built-in Switch 2 AI upscaler ("In-game / Native",dlss=0) never ran properly on AMD GPUs:9dc98871), AMD fell back to a slow software matrix-multiply loop (4.98 msNN pass on Radeon 860M,155 sclean-cache shader compile with33 spipeline stalls).fd029a31) with a non-AI FXAA stand-in (taau_upscale.comp).66766196,f10782f9,72ba090c,0775215f) were skipped entirely (networks_left_out) and fell back to a blurry linear upscale.This PR implements fused
16×16×16WMMA (VK_KHR_cooperative_matrix) on supported AMD RDNA 3 / 3.5 / 4 GPUs and enables the real Switch 2 AI upscaler across all 6 in-game resolution scales where the networks fit:9dc98871): Pure performance win — +9.3% FPS (28.89 → 31.57 FPS) with exactK=8default (RX_VK_MMA_WMMA16_FAST=0) or +12.0% FPS (32.35 FPS,-63.6%NN GPU time) with fastK=16(RX_VK_MMA_WMMA16_FAST=1), and clean-cache shader compile time drops from155.5 s→71 s(max pipeline wait33.1 s → 1.3 s).75%,67%,58%,50%,33%): Restores the real Switch 2 AI neural upscaler instead of the blurry non-AI FXAA/linear workarounds. Because real AI reconstruction does more GPU work than a plain linear blit, FPS is ~1–3 FPS lower thanmain's non-AI linear/FXAA stand-in, in exchange for a massive jump in image quality (~5–8× higher fine-detail sharpness on foliage, grass, vines, and Link's tunic).36.45 FPS) strongly outperforms 75% FSR 3.1 (32.40 FPS) in fine-detail crispness while running +4.1 FPS (+12.5%) faster.RX_VK_MMA_WMMA16=0restores the old non-AI stand-ins across sub-native scales, orRX_VK_TAAU_KEYS=fd029a317a9a4b94restores the 75% stand-in.What this PR changes — and what it does NOT change
dlss=0)16×16×16WMMA across all 6 scales (100%–33%) on AMD RDNA 3 / 3.5 / 4 GPUs where cooperative matrices, full 32-lane compute subgroups and the startup probe pass, and the network fits.LLPCand LinuxRADV).gfx1033), which has no hardware16×16×16WMMA (VK_KHR_cooperative_matrix). This PR explicitly gates WMMA16 to `dev.facts.rdna3()16×8×16cooperative matrices).Visual Comparison (1:1 Native Pixel Crops — Kokiri Forest
1600×1000, RCAS Sharpness 80%)All 6 shots were captured at the exact same Kokiri Forest camera pose (
pos=[-125.7, 114.5, -38.4],facing=90°,cam=90°) with uniform post-processing (RX_VK_SHOT_FX=1,sharpness=80%, HUD hearts verified within ±2% across all 6; PR shots captured onK4b, withK4aandK4bvisually identical in playtesting):1600×1000)main(taau_upscaleFXAA)fd029a31)mainFXAA)main(linear fallback)66766196)9dc98871)main(28.89 FPS)Why & Relationship to Closed PR #1038
This PR builds directly on closed PR #1038 (
https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1038) byjcabarca(juliotec), preserving their 7 commits in the branch history, and resolves the blockers that held #1038 back:gfx11) startup probe bug fixed (gpu/vk/vk_coopmat.cpp): Raw #1038 failedtest_multiply_wmma16()on Radeon 860M (11/128elements differed by<= 2^-22f16subnormal residual on exact cancellation to0) and silently fell back to softwareLoop. Relaxing the probe tolerance to1e-4f, rejecting non-finite results and upgrading it to verify a full16×16N-pair (256elements) addresses the RDNA 3/3.5 probe failure while still catching tile-layout errors (>= 1.0on these inputs).[B0|B1]WMMA16 (DefineWmma16PairFunction,DontInlineinemit_spirv_warp.cpp): Pairs twoHMMA_nx2sharingAinto a single16×16×16[B0|B1]multiply, doubling N-utilization (25% → 50%exactK=8,100%fastK=16), halving barriers/A-loads/stores, avoidingamdvlk64.dll0xc0000005inlining crashes, and cutting clean-cache compile wall time in half (155 s → 71 s).dev.facts.rdna3() || dev.facts.rdna4()and!dev.policy.nan_bitsguards, plus full 32-lane compute subgroup and network fit checks (device_policy.h,vk_coopmat.cpp);translator_stamp()bits moved off colliding2048u/4096uto32768u/65536u/131072u(vk_shader.cpp); switches registered ingpu/vk/switches.def(RX_VK_MMA_WMMA16,RX_VK_MMA_WMMA16_FAST,RX_VK_MMA_WMMA16_FUSE).Key files for reviewers
gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_warp.cpp(Wmma16Fits,DefineWmma16MatrixFunction,DefineWmma16PairFunction,EmitMatrixMulAddF16)gpu/vk/vk_coopmat.cpp(wmma16_init,test_multiply_wmma16256-element paired probe)gpu/vk/device_policy.h(is_rdna3,is_rdna4)gpu/vk/vk_shader.cpp(translator_stamp,Wmma16Fitsnetwork gate)gpu/vk/switches.def(RX_VK_MMA_WMMA16,RX_VK_MMA_WMMA16_FAST,RX_VK_MMA_WMMA16_FUSE)tests/test_wmma16.py&tests/test_wmma16_spirv_val.pyTesting
Tested:
1002:1114, RDNA 3.5 iGPU), Adrenalin26.10.1(LLPC).RX_VK_TAAU_KEYS=-andRX_VK_NETWORK_KEEP=all):9dc98871,fd029a31,66766196,f10782f9,72ba090c,0775215f) passWmma16Fits = True(128×1×1,13,188–14,884 B / 65,536 Bshared memory) with exact SPIR-V fused-pair conservation (2*fused + singles == ir_mma_count).K4a(exactK=8),K4b(fastK=16),main(Loop), and75%modes: zero visual artifacts, glitches, or crashes.1600×1000Kokiri Forest screenshots (both pre-RCAS and post-RCASsharpness=80%), confirming crisp foliage/grass/tunic reconstruction and uniform native HUD.1280×800,1600×1000,1920×1080, and1920×1200(19cells, zero unseen gameplay NN keys).test_multiply_wmma16()pass) and safety E2E suite (5/5 PASS).5b3a1235(Windows 11, Radeon 860M1002:1114, Adrenalin26.10.1 LLPC):longshot_vk.dll(250/250renderer files,0failed, symbols checked) and bootedkokiri-startwith zero WMMA/TAAU/network env overrides (dlss=0).vk: native matrix multiplies on (WMMA 16x16x16 through workgroup tiles, fused, exact K=8).resolution=2,1728×1080 → 2304×1440),fd029a317a9a4b94dispatched automatically (34.4 FPSinKokiriForest_Child, zerotaau_upscalestand-in).resolution=3,1536×960 → 2304×1440),6676619641320ba7compiled cleanly on a worker in1,894 msand dispatched automatically (40.1 FPSinKokiriForest_Child).VK_ERROR, zero device lost, clean exit.0f38b3conAMD Radeon RX 7900 XTX RADV NAVI31andAMD Radeon 780M RADV PHOENIX): Both RDNA 3 Linux RADV testers activated WMMA16 (log_expected_missing: 1 → 0), had0crashes,0forbidden log lines, and rendered clean, artifact-free frames. (Thescreenshot.max_diffflag on0f38b3cwas caused by stalemain @ 89c3d21missing the teleport retry fixesd6ac4628/e9e2edc6, comparing Link's House against Kokiri Forest; rebased5b3a1235pulls both fixes in for a clean re-run.)5b3a1235(Windowsllvm-mingw):tests/test_wmma16.py,tests/test_device_policy.py(including#1839R9700 rows),tests/test_switch_table.py,tests/test_coopmat_probe_failures.py,tests/test_program_stamp_knobs.py,tests/test_translator_stamp_text.py,tests/test_shader_stamp_inputs.py,tests/test_shader_stamp_cache.py,tests/test_shader_profile_caps.py,tests/test_amd_subgroup_profiles.py,tests/test_subgroup_pin_limit.py,tests/test_rdna2_mesh_only.py,tests/test_vendor_fixes.py,tests/test_header_ext_deps.py,tests/test_doc_anchors.py,tests/test_utf8_paths.py,tests/test_check_pr_description.py,tests/byte_compile_tracked.py,scripts/check_third_party.py, and all 4 C++ unit tests undergpu/vk/tests/.tests/run_all.py --changed forge/main:88 passed, 11 failed, 14 skipped(14Linux/spirv-val/zstandardchecks skipped on Windows and checked by Linux CI; the11failures —test_recorder_sync,test_dev_ab,test_frame_overlap,test_dev_packs,test_build_long_paths,test_linux_pressure,test_pass_barrier,test_crash_dialog,test_present_queue_default,test_target_reuse_memory,test_vk_occlusion_queries— are pre-existing Windows/main failures unrelated to this PR's 15 files).Still to test:
LLPC) (e.g., RX 9070 / RX 9060 series): boot Kokiri Forest at100%,75%, and67%, expectingtest_multiply_wmma16()pass, clean visuals, and faster NN / compile times (@Beanstalk test on AMD RDNA 4 Windows).RADV) re-run on5b3a1235: re-run on the rebased head (which includesd6ac4628/e9e2edc6teleport retry fixes) to get a clean green A/B report (@Beanstalk test on AMD RDNA 3/4 Linux RADV).RADV): boot and confirm WMMA16 stays off (dev.facts.rdna3() || dev.facts.rdna4()is false) with zero regression (@Beanstalk test on Steam Deck).@Beanstalk/ CI).Measurements
Verdict: +9.3% to +12.0% native 100% FPS (-56% to -64% NN GPU time, -54% clean-cache compile time), and unlocks real Switch 2 AI upscaling at 75%–33% (~5–8× sharper foliage/grass/tunic at -1 to -3 FPS vs
main's blurry non-AI FXAA/linear fallback, while beating AMD FSR 3.1 by +8% to +15% FPS at every scale).RX_VK_MMA_WMMA16=1(on for AMD RDNA 3/3.5/4 where cooperative matrices and full 32-lane compute subgroups pass),RX_VK_MMA_WMMA16_FUSE=1(on — halves compile time and boosts FPS),RX_VK_MMA_WMMA16_FAST=0(off — exactK=8midpoint rounding matching AmpereHMMA.16816.F16as the safe default, with=1opt-in for an extra +0.5–0.8 FPS).Setup: Windows 11 (26200), AMD Radeon 860M (
1002:1114, Adrenalin26.10.1 LLPC), Kokiri Forest Child (1600×1000docked, 3×20 s interleaved runs per mode for100%/75%/67%, 1×12 s for58%/50%/33%), unprofiled FPS +RX_VK_PASS_TIMING=1GPU spans. (Measured onmain @ 89c3d21vs the identical WMMA16/shader code prior to the 2-line default-dispatch unlock in0f38b3c, usingRX_VK_TAAU_KEYS=-andRX_VK_NETWORK_KEEP=all. After rebasing ontomain @ 9dd41326(5b3a1235), the default-env smoke test confirmed WMMA16 activation and75%/67%AI dispatch. The measurements predate the final subgroup and probe guards.)1600×1000 Kokiri Forest (Interleaved Medians):
89c3d210f38b3c0f38b3c89c3d219dc98871AI)28.4 msGPU,4,975 µsNN)25.3 ms,2,172 µsNN, +9.3%)24.7 ms,1,809 µsNN, +12.0%)fd029a31) vsmainFXAA stand-in20.0 ms, non-AI FXAA) / 32.63 FPS (real AI Loop)21.4 ms,1,622 µsNN)21.0 ms,1,323 µsNN)23.6 ms)66766196) vsmainlinear fallback19.0 ms, non-AI linear)20.8 ms,1,589 µsNN)22.1 ms)f10782f9) vsmainlinear fallback18.4 ms, non-AI linear, 1×12s)19.4 ms,1,610 µsNN, 1×12s)21.2 ms)72ba090c) vsmainlinear fallback17.6 ms, non-AI linear, 1×12s)18.0 ms,1,603 µsNN, 1×12s)19.1 ms)0775215f) vsmainlinear fallback15.2 ms, non-AI linear, 1×12s)17.0 ms,1,457 µsNN, 1×12s)18.8 ms)100%)155.5 s(33.1 smax pipe wait)70.9 s(1.3 smax pipe wait)71.8 s(1.3 smax pipe wait)Resolution Scaling (
1280×800,1920×1080,1920×1200—RX_VK_MMA_WMMA16_FAST=1)89c3d210f38b3c89c3d211280×800100%3.12 msNN)1.16 msNN, +5.8%)1280×80075%0.84 msNN, parity w/ FXAA)1920×1080100%6.59 msNN)2.39 msNN, +17.1%)1920×1200100%7.26 msNN)2.70 msNN, +13.9%)1920×120075%1.95 msNN)1920×120050%1.81 msNN)Risks
main's non-AI workaround: Players on AMD RDNA 3/3.5/4 using75%(Auto) or67%–33%with the in-game upscaler will see ~1–3 FPS lower framerates thanmain's non-AI FXAA/linear stand-in, in exchange for dramatically sharper Switch 2 AI reconstruction. Players can choose Off on the Upscaler row and a smaller Render resolution for linear scaling, or restore the old non-AI stand-ins withRX_VK_MMA_WMMA16=0(orRX_VK_TAAU_KEYS=fd029a317a9a4b94for 75% only).LLPCand RDNA 3 LinuxRADVon earlier revisions; RDNA 4 WindowsLLPCand a LinuxRADVre-run remain to be tested. If a driver fails the startup 256-elementtest_multiply_wmma16()probe, it automatically falls back to the existing software path.translator_stamp()adds new flag bits (32768u/65536u/131072u), so RDNA 3/3.5/4 users will re-translate the AI upscaler shaders once on first launch after updating (much faster thanmain: ~1–2 s per upscaler pipeline). Saves andlongshot_options.iniare untouched.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11 (26200), AMD Radeon 860M (1002:1114, RDNA 3.5 iGPU), Adrenalin 26.10.1 (LLPC), Kokiri Forest Child (1600x1000, 1280x800, 1920x1080, 1920x1200): verified all 6 Switch 2 AI upscaler networks (100%-33%) via fused WMMA16 with 256-element startup probe passing, +9.3% to +12.0% native FPS, -54% clean-cache compile time, and crisp AI reconstruction with zero artifacts.
Possibly related, for context:
1:1 Native Pixel Crop Comparison (Kokiri Forest 1600x1000, RCAS Sharpness 80%)
Code looks good
@review
@beanstalk
Beanstalk test farm · an earlier run: commit
0f38b3c(the newer results are in a comment below)Commit
0f38b3c· approved by HumanBean (reviewed) · dashboard⚠️ Note: An AMD target may select a GPU or driver without the required cooperative-matrix support; a missing WMMA activation line is unjudged rather than a failure.
⚠️ Note: Sub-native images are intentionally different from main's fallback, so the screenshot threshold cannot establish sharpness or guarantee absence of every artifact.
⚠️ Note: The plan samples two render settings rather than all six scales and does not compare the optional fast or unfused WMMA paths.
Done (started 09:40 UTC, last report 10:34 UTC). Comment
@Beanstalkto run it again.linux+amdforest-driver-cold· frame time p99 (ms), main → PR at each levelresolution=0(reference)resolution=9linux+amdforest-driver-warm· frame time p99 (ms), main → PR at each levelresolution=0(reference)resolution=9linux+amdWhy it failed
linux+amd:forest-driver-cold · resolution=0screenshot.max_diff:limit 0.1linux+amd:forest-driver-warm · resolution=0screenshot.max_diff:limit 0.1What was tested
What will be tested · AI plan (
gpt-6.1-terra)On a Linux AMD PC, this plan compares main and the pull request in Kokiri Forest with cold and warm driver caches. It exercises two render-resolution settings because the changed neural upscaler depends on render scale, captures matched images, and measures frame times and shader preparation. Crashes, device loss, a large frame-time regression, or a substantial image difference fail the plan; expected sub-native image changes may need interpretation. The run takes roughly 21 minutes per tester.
0or9.kokiri-start(settings dlss=0, sharpness=80; each start with an empty driver shader cache, Linux only for now), then teleport to Kokiri Forest, take the picture forest-cold to compare with main, measure forest for 20 s (after 5 s warm-up); 1 run on each side for each of 2 cells (1 game start a run).kokiri-start(settings dlss=0, sharpness=80; each side's driver shader cache kept across its starts, filled first by an unmeasured start, Linux only for now), then teleport to Kokiri Forest, take the picture forest-warm to compare with main, measure forest for 20 s (after 5 s warm-up); 1 run on each side for each of 2 cells (1 game start a run).Measurements on `linux+amd`, for the PR description
Verdict: fail on linux+amd (2 reports):
forest-driver-cold screenshot.max_diff;forest-driver-warm screenshot.max_difffailed; 2 cells not compared (mismatch: what ran is not what the plan asked).Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAM; 2: linux+amd+radv+igpuAMD Radeon 780M Graphics (RADV PHOENIX), 26.1.99AMD Ryzen 7 7840HS w/ Radeon 780M Graphics, 24 GB RAMScene: forest-driver-cold, from the repository's save kokiri-start (dlss=0, sharpness=80); forest-driver-warm, from the repository's save kokiri-start (dlss=0, sharpness=80); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); forest-driver-cold: 1 game start a side, forest 20 s after 5 s warm-up; forest-driver-warm: 1 game start a side, forest 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)89c3d210f38b3cresolution=0· forest · frame time (p99) (ms)resolution=0· forbidden log linesresolution=0· expected log lines missingresolution=9· forest · frame time (p99) (ms)resolution=9· forbidden log linesresolution=9· expected log lines missingresolution=0· forest · frame time (p99) (ms)resolution=0· forbidden log linesresolution=0· expected log lines missingresolution=9· forest · frame time (p99) (ms)resolution=9· forbidden log linesresolution=9· expected log lines missingFlags and settings
resolution0,9As Markdown for the PR description:
The testers' hardware
linux+amdAMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMlinux+amdAMD Radeon 780M Graphics (RADV PHOENIX), 26.1.99AMD Ryzen 7 7840HS w/ Radeon 780M Graphics, 24 GB RAM0f38b3c0c25b3a123567Beanstalk test farm
Commit
f0de22e· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.WIP: feat(vk): enable Switch 2 AI upscaler on AMD RDNA 3/3.5/4 via fused 16x16x16 WMMA (+9-12% native FPS, sharper in-game upscaling)to feat(vk): enable Switch 2 AI upscaler on AMD RDNA 3/3.5/4 via fused 16x16x16 WMMA (+9-12% native FPS, sharper in-game upscaling)Thanks for the review and Beanstalk run! Updated and marked ready for review on
5b3a1235:main(9dd41326): Cleanly resolved thedevice_policy.h/switches.defmerge with#1839(is_rdna4PCI ID matching preserved;test_device_policy.pypasses including the new R9700 rows).linux+amdrun on0f38b3c(RX 7900 XTX RADV & Radeon 780M RADV): Both RDNA 3 Linux RADV machines activated WMMA16 (log_expected_missing: 1 -> 0), had 0 crashes, 0 forbidden log lines, and rendered clean, artifact-free frames. The0.71/0.72screenshot.max_diffwas solely because stalemain @ 89c3d21lacked the teleport retry fixes (d6ac4628/e9e2edc6), so one side stayed in Link's House while the other teleported to Kokiri Forest. Rebasing onto9dd41326pulls both teleport fixes in.5b3a1235: Rebuilt full game +longshot_vk.dll(250/250renderer files,0failed) and bootedkokiri-startwith zero WMMA/TAAU/network env overrides. Log confirmedvk: native matrix multiplies on (WMMA 16x16x16 through workgroup tiles, fused, exact K=8),75%(fd029a317a9a4b94,34.4 FPS) and67%(6676619641320ba7, compiled in1.89 s,40.1 FPS) both dispatched automatically with zeroVK_ERROR.5b3a1235: All PR-relevant tests (test_wmma16.py,test_device_policy.py,test_switch_table.py,test_coopmat_probe_failures.py,test_program_stamp_knobs.py,test_translator_stamp_text.py,test_shader_stamp_inputs.py,test_shader_stamp_cache.py,test_doc_anchors.py,test_utf8_paths.py,test_check_pr_description.py,scripts/check_third_party.py, and all 4gpu/vk/tests/C++ tests) pass locally.Ready for CI + a fresh Beanstalk approval on
5b3a1235(AMD RDNA 3/4 Linux RADV, RDNA 4 Windows LLPC, and Steam Deck RDNA 2 guard check).@review
Recommendation: Request changes. The WMMA path can run without the required 32-lane subgroup and can accept invalid probe results. It also enables the path on non-AMD devices despite the stated hardware scope; the sub-native image-quality versus frame-rate tradeoff needs a maintainer decision.
The change accelerates native-resolution neural upscaling on the tested Radeon 860M and enables neural reconstruction at lower scales. It adds a sizeable shader translation path and trades some sub-native frame rate for sharper output.
@fixwill do (5)gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_warp.cpp:660: The fit check assumes a multiple-of-32 X dimension guarantees 32-lane subgroups, but pin_subgroup declines to pin when total invocations exceed 32 times maxComputeWorkgroupSubgroups. (more on the line)gpu/vk/vk_coopmat.cpp:433: A NaN result passes this comparison because comparisons with NaN are false. (more on the line)gpu/vk/vk_coopmat.cpp:633: The vendor guard rejects unsupported AMD devices but allows every non-AMD device through. (more on the line)tests/test_wmma16_spirv_val.py:189: The SPIR-V fixture extracts only the single-multiply function, while fusion is enabled by default and emits a separate helper and planner. (more on the line)gpu/vk/vk_shader.cpp:1538: Preserve an explicit, accessible non-AI alternative while enabling the neural path.Before merging, for the author (2) (a run, a measurement or a decision; it doesn't hold the recommendation)
gpu/vk/vk_shader.cpp:1538: Enabling the neural networks changes the default at sub-native scales: the reported 75% result falls from 36.93 to 35.30 FPS and the 67% fast-mode result from 37.95 to 36.45 FPS, in exchange for sharper reconstruction. (more on the line)gpu/vk/switches.def:540: The default is enabled across RDNA 3, 3.5 and 4, but the reported A/B is from one Windows 860M; RDNA 4 and the rebased Linux runs remain outstanding. (more on the line)Checks: Still running:
CI / Conventional Commit title (pull_request),CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request),CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request),CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request),CI / Workflow lint (actionlint) (pull_request),CI / Website build and checks (pull_request),Guide screenshots / Guide images and local UI source review (pull_request),Third-party parts / As their notes say (pull_request),Third-party parts / The same as upstream (pull_request),Website / Website on Cloudflare (pull_request).More: does it help, other systems, switches, what was read
Does it help: Yes on the tested Radeon 860M at native resolution: the PR reports three interleaved runs with median FPS rising from 28.89 to 31.57 at the default, and neural-pass time falling from 4.975 to 2.172 ms. Those measurements use an earlier base and branch revision; the head received a smoke test, not a matching A/B. Default-mode results, frame-time tails and heavy-area results are missing for several scales.
Other systems: The path changes cooperative-matrix translation and network selection, not only one upscaler shader. RDNA 3 Linux had an earlier-head smoke run; RDNA 4 Windows and Linux, Steam Deck, NVIDIA and Intel head checks remain outstanding. Non-AMD devices exposing only the 16x16x16 shape can currently enter the new path. The PR reports no save or settings changes.
Switches: Adds RX_VK_MMA_WMMA16, default on for eligible devices; RX_VK_MMA_WMMA16_FUSE, default on; and RX_VK_MMA_WMMA16_FAST, default off. All have switch-table rows. The hardware defaults need the outstanding platform measurements; the implementation currently enables WMMA16 beyond the documented AMD scope.
Reviewed:
5b3a123567against9dd41326e7: Read the repository instructions, contribution rules, PR template, relevant standards, commit messages, diff, WMMA emitter and probe changes, new tests, and surrounding subgroup and network-selection code. Skimmed the other changed declarations, Sirit changes and policy test. The requested docs/review-checklist.md and adjacent Tooling checkout were absent. Did not read every changed code file in full.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no build, tests, scripts or game runs were executed. The supplied CI checks are still running.
Overlaps and merge order: The description identifies closed PR #1038 as the source of the earlier commits; no open overlapping pull requests were available to inspect.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -650,0 +657,4 @@// (only where every subgroup is full: the cooperative matrix operations and the subgroup barriers then run with all// 32 lanes, as the startup test checked them. Otherwise the software multiply)if (!mma_wmma16_full_subgroups || program.workgroup_size[0] == 0 || program.workgroup_size[0] % 32 != 0) return false;const u32 threads = std::max(1U, program.workgroup_size[0] * program.workgroup_size[1] * program.workgroup_size[2]);L1: The fit check assumes a multiple-of-32 X dimension guarantees 32-lane subgroups, but pin_subgroup declines to pin when total invocations exceed 32 times maxComputeWorkgroupSubgroups. Such a workgroup can therefore use a larger native subgroup while this code indexes tiles and lanes as 32-wide, producing incorrect results or out-of-bounds tile accesses. Gate WMMA on the same pinning limit and actual pipeline pin decision, and test a workgroup above that limit.
@ -537,6 +537,9 @@ SW(RX_VK_MMA_C_ORDER, diag, string, "the element order measured on the GPU at stSW(RX_VK_MMA_NO_COOP, attempt, bool, "off (cooperative matrices used when the device has them)", "1 pretends the device has no cooperative matrices, so the software multiplies are used.")SW(RX_VK_MMA_SOFTWARE, attempt, bool, "off (native cooperative matrices where the device has and passes them)", "1 forces the upscale networks' matrix multiplies into a software shader function, with no cooperative matrices.")SW(RX_VK_MMA_UNROLL, hw, bool, "on for Mesa RADV and AMD RDNA 4 on AMD's proprietary driver, off (the loop) elsewhere; only where matrix multiplies run in software", "0 keeps the looped software matrix multiply, 1 tries the unrolled forms on any GPU.")SW(RX_VK_MMA_WMMA16, attempt, bool, "on for AMD RDNA 3/3.5/4 where 16x16x16 cooperative matrices and full 32-lane compute subgroups pass", "0 disables the 16x16x16 WMMA workgroup-tile path and falls back to software matrix multiplies.")L6 (minor): The default is enabled across RDNA 3, 3.5 and 4, but the reported A/B is from one Windows 860M; RDNA 4 and the rebased Linux runs remain outstanding. Measure the default on the affected Tier 1 hardware and include frame-time tails and representative heavy scenes before settling the default.
@ -349,0 +430,4 @@const float got = from_half((uint16_t)(e & 1 ? w >> 16 : w & 0xffff));// (RDNA 3/3.5 gfx11 v_wmma_f16 can leave a <=2^-22 f16 subnormal residual on exact cancellation to 0;// any layout or tile bug is off by >= 1.0 on these integer inputs, so 1e-4 catches every wrong lane)if (std::fabs(got - want_d) > 1e-4f && bad++ < 4)L2: A NaN result passes this comparison because comparisons with NaN are false. A driver returning NaNs for some or all probe elements can consequently be marked supported and run broken neural shaders. Reject non-finite results explicitly and cover that failure in the probe test.
@ -537,0 +630,4 @@software_multiplies("RX_VK_MMA_WMMA16=0");return;}if (dev.props.vendorID == 0x1002 && (dev.policy.nan_bits || !(dev.facts.rdna3() || dev.facts.rdna4()))) {L3: The vendor guard rejects unsupported AMD devices but allows every non-AMD device through. An Intel or NVIDIA device that exposes 16x16x16 but not 16x8x16 can thus activate this unmeasured path and change network selection, contrary to the stated scope. Require AMD as well as RDNA 3 or 4 before enabling it, unless those other devices are deliberately supported and tested.
@ -1536,1 +1536,3 @@if ((!kept_one && (Shader::Backend::SPIRV::mma_software || dev.policy.networks_left_out)) || env_on("RX_VK_NO_F16") || !dev.vk12.shaderFloat16)// (device_policy.h networks_left_out: every vendor but NVIDIA; and where the multiplies run in software, whoever made the GPU;// kept where the WMMA 16x16x16 tiles run them: Wmma16Fits, or EmitSPIRV would compile the software multiply)if ((!kept_one && (Shader::Backend::SPIRV::mma_software || (dev.policy.networks_left_out && !(Shader::Backend::SPIRV::mma_wmma16 && Shader::Backend::SPIRV::Wmma16Fits(profile_pinned(), t->program))))) || env_on("RX_VK_NO_F16") || !dev.vk12.shaderFloat16)L5 (minor): Enabling the neural networks changes the default at sub-native scales: the reported 75% result falls from 36.93 to 35.30 FPS and the 67% fast-mode result from 37.95 to 36.45 FPS, in exchange for sharper reconstruction. A maintainer should decide whether that tradeoff is right for players who selected those scales for performance.
@ -0,0 +186,4 @@raise SystemExit("FAIL: emit_spirv_warp.cpp has no DefineWmma16MatrixFunction")if "bool Wmma16Fits(" not in warp:raise SystemExit("FAIL: emit_spirv_warp.cpp has no Wmma16Fits")fixture = FIXTURE.replace("@@FUNCTION@@", block(warp, "bool Wmma16Fits(") + "\n" + block(warp, marker))L4: The SPIR-V fixture extracts only the single-multiply function, while fusion is enabled by default and emits a separate helper and planner. Invalid SPIR-V or incorrect dependency handling in the default fused path can pass both new tests. Add a behavioral fixture that emits and validates fused pairs, including dependent and unpairable instructions.
@fix
5b3a123567d14c84687bRecommendation: Approve. The neural default trades sub-native performance for image quality, and a maintainer has not yet settled that tradeoff. Default-mode measurements on the affected hardware, including frame-time tails and heavy scenes, are also outstanding. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
d14c84687b. I rebased it ontomain(f8c130b143). I edited its description to match the change.Changed
Changed in part (the rest is for the author)
Nothing was built or run: the checks run again on the new head.
The change enables hardware-assisted neural upscaling on supported AMD GPUs. It improves native-resolution performance on the tested 860M and offers sharper sub-native reconstruction, at a reported sub-native FPS cost.
Before merging, for the author (2) (a run, a measurement or a decision; it doesn't hold the recommendation)
gpu/vk/vk_shader.cpp:1538: The documented Off option provides a linear alternative, but a maintainer still needs to decide whether making neural reconstruction the default at sub-native scales is the right tradeoff for players selecting those scales for performance.gpu/vk/switches.def:540: The default is enabled across RDNA 3, 3.5 and 4, but the reported A/B is from one Windows 860M; RDNA 4 and the rebased Linux runs remain outstanding. Measure the default on the affected Tier 1 hardware and include frame-time tails and representative heavy scenes before settling the default.Checks: they run again on this head; a failure shows on the pull request.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes on the tested Windows Radeon 860M: three interleaved runs reported 28.89 to 31.57 FPS at native resolution with the default, while 75% fell from 36.93 to 35.30 FPS. These measurements predate the final guards and do not establish frame-time tails or the default's cost on other affected hardware.
Other systems: The path is gated to supported AMD RDNA 3/3.5/4 devices with suitable cooperative matrices and full 32-lane compute subgroups. Earlier Linux RDNA 3 runs activated it without reported crashes; RDNA 4, the rebased Linux comparison, Steam Deck, NVIDIA and Intel checks remain outstanding.
Switches: RX_VK_MMA_WMMA16 defaults on for eligible devices; FUSE defaults on; FAST defaults off for midpoint rounding. All three have switch-table entries. The broad enabled default still awaits the hardware measurements and maintainer decision recorded in the ledger.
Reviewed:
d14c84687bagainstf8c130b143: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the latest fixture diff, and the relevant WMMA fit, probe, network gate, switch and player-documentation sections. The remaining changed files and full base diff were not read in full; the recorded runs were reviewed from the supplied description and comments. docs/review-checklist.md is absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports Windows 860M gameplay and source-test results, and earlier Linux RADV farm runs; CI has not run on this head.
Overlaps and merge order: The description identifies closed PR #1038 as prior work incorporated into this change; other overlaps were not checked.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@fix
d14c84687bf0de22eaa3Recommendation: Approve. The neural default trades some sub-native performance for image quality, and its suitability still needs a maintainer decision and measurements across affected hardware. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
f0de22eaa3. I rebased it ontomain(f836ca1d90).Conflicts resolved
tests/test_wmma16.pyNothing was built or run: the checks run again on the new head.
The change enables the game's neural upscaler on supported AMD RDNA 3, 3.5 and 4 GPUs. It improves native-scale performance in the reported 860M test, at the cost of lower FPS at several sub-native scales and added shader complexity.
Before merging, for the author (2) (a run, a measurement or a decision; it doesn't hold the recommendation)
gpu/vk/vk_shader.cpp:1538: The documented Off option provides a linear alternative, but a maintainer still needs to decide whether making neural reconstruction the default at sub-native scales is the right tradeoff for players selecting those scales for performance.gpu/vk/switches.def:540: The default is enabled across RDNA 3, 3.5 and 4, but the reported A/B is from one Windows 860M; RDNA 4 and the rebased Linux runs remain outstanding. Measure the default on the affected Tier 1 hardware and include frame-time tails and representative heavy scenes before settling the default.Checks: they run again on this head (
Guide screenshots / Guide images and local UI source review (pull_request)failed on the last one); a failure shows on the pull request.Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes on the reported Windows Radeon 860M test: native-scale median FPS rose from 28.89 to 31.57 with the default, and clean-cache compilation fell from 155.5 to 70.9 seconds. Those A/B measurements predate the final guards and rebase; default-mode frame-time tails, heavy scenes and other affected hardware remain unmeasured.
Other systems: The path is gated to supported AMD GPUs; the reported earlier Linux RDNA 3 runs activated it without crashes, but the rebased Linux run and RDNA 4 Windows test remain outstanding. Steam Deck, NVIDIA and Intel guard checks are also outstanding.
Switches: RX_VK_MMA_WMMA16 defaults on for qualifying AMD hardware; RX_VK_MMA_WMMA16_FUSE defaults on; RX_VK_MMA_WMMA16_FAST defaults off for exact midpoint rounding. The broader enabled default still needs the hardware measurements and decision recorded in L5 and L6.
Reviewed:
f0de22eaa3againstf836ca1d90: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the changed stamp and network-gate context, switch entries and relevant user documentation. Skimmed the rewritten range diff and test changes; the other changed code files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. The author reports Windows 860M playtesting and earlier Linux RDNA 3 runs; CI has not run on this head.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
Tested in game on Linux RDNA 4, after the merge too: AMD Radeon RX 9070 XT (RADV GFX1201, Mesa 26.2.7), Fedora 45 (kernel 7.3.4), Ryzen 5 5600X, 32 GB. Kokiri Forest (child), the game's own upscaler (
dlss=0). 0 device lost and no crash in any run below.1. The Test Farm's way: this PR's final head against its merge base, WMMA16 on and off. The Beanstalk agent's own run (
beanstalk-agent run --pr 2043, run on this PC, nothing sent to the farm), this PR @f0de22eaagainst main @f836ca1d, plusRX_VK_MMA_WMMA16=0and=1on the PR's side. 67 % render resolution (1707x960), the console's 60 fps cap, headless, 30 s after a 10 s warm-up, 2 starts a side, interleaved:f836ca1dRX_VK_MMA_WMMA16=0RX_VK_MMA_WMMA16=1RX_VK_PASS_TIMING)The farm's rule passes (
frametime_p99_ms, WMMA16 on against off on the PR: -7.6 %, limit +10 %), but at the 60 fps cap the frame times say little: every side's median sits at 16.5 ms and main's own p99 spans 18.6-20.3 ms. The clear difference is GPU time: with WMMA16 on, about 0.8 ms more a frame, in both runs, while WMMA16 off matches main.That 0.8 ms is the upscaler network running at all, not slower multiplies. A second Beanstalk run, the PR's own build against itself (
baseline.ref = "pr"), WMMA16 on (default) againstRX_VK_MMA_WMMA16=0, same scene and settings, 2 starts a side, with alog_matchon each start's log:RX_VK_MMA_WMMA16=0native matrix multiplies onloggednot translated: a network left out on this cardlinesWith WMMA16 off (and on main) the 67 % network is left out on this card and the game falls back to the linear upscale; with WMMA16 on it runs, for about 0.8-1.0 ms of GPU time a frame. At 100 % and 75 %, where main runs the network through the software multiplies, WMMA16 is no slower (below). The screenshot comparison can't tell the sides apart in this scene: two shots of the same side differ in 70-92 % of their pixels (the scene moves).
2. The switch on main after the merge (main @
971f77f5, with21050742), uncapped.dev.py ab,RX_VK_MMA_WMMA16unset against=0on the same build, a 2560x1440 window, V-Sync and frame generation off, 180 s each after a warm-up, 2 interleaved pairs:=0): fps100 %: within the spread (the 110.6 run is a one-off). 75 %: on is 0.5 % faster, every on run above every off run. This scene is CPU-bound on this PC (below), so GPU time hardly shows in fps.
3. Before the merge: this PR @
5b3a1235against main @9dd41326.dev.py ab, output resolution 2560x1440 in a 1440x2560 (portrait) window on both sides, uncapped, 180 s each, 3 interleaved pairs, the median:All within the spread. Every PR run logged
vk: native matrix multiplies on (WMMA 16x16x16 through workgroup tiles, fused, exact K=8); every main run loggedvk: matrix multiplies in software. The frame trace's mediangame_msis 9.7-10.1 ms of a 10.3 ms frame at 100 %, with about 0.3 ms GPU wait on both sides, so the scene is CPU-bound here. At 67 % the PR runs the network at the same frame rate as main's linear fallback.Not covered: a GPU-bound scene, image quality (no screenshot of the same frame),
spirv-val.