fix(vk): recognize RDNA 4 GPUs by PCI device ID #1839
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1839
Loading…
Reference in a new issue
No description provided.
Delete branch "gmourao/Longshot:fix/vk-rdna4-pci-id"
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
The renderer told an AMD RDNA 4 card only by its name ("RX 9" or "GFX12"), in three copies that could drift apart:
DeviceFacts::rdna4(),is_rdna4()invk_internal.h, and the check inauto_profile(). A card with another name, such as the Radeon AI PRO R9700, was not taken for RDNA 4. These are the follow-up suggestions from the #1590 review.This PR:
is_rdna4(vendor_id, device_id, device_name)ingpu/vk/device_policy.his used byDeviceFacts::rdna4(),choose_software_form()(vk_coopmat.cpp) andauto_profile()(vk_main.cpp). The copy invk_internal.his removed.0x1002)0x7550(Navi 48: RX 9070 / XT / GRE),0x7551(Navi 48: Radeon AI PRO R9700 / R9700S / R9600D) and0x7590(Navi 44: RX 9050 / 9060 / 9060 XT). The name match stays as the fallback for cards not in the list.VK_DRIVER_ID_AMD_PROPRIETARYis also what AMDGPU-PRO reports on Linux. The code has no_WIN32check, and this PR does not add one. So the comments and the looped-path log line say "AMD's proprietary driver" instead of "AMD's Windows driver". TheRX_VK_MMA_UNROLLrow inswitches.defnow lists the default as "on for Mesa RADV and AMD RDNA 4 on AMD's proprietary driver" (before, it said only "on for Mesa RADV"). Inauto_settings.h, the comment reads "an AMD RDNA 4 card, an RX 9000 or Radeon AI PRO: FSR 4". The player guide says "an AMD RDNA 4 card (RX 9000)".How to see it on
main: take an AMD RDNA 4 card whosedeviceNamehas neither "RX 9" nor "GFX12", for exampleAMD Radeon AI PRO R9700(1002:7551). On every driver, the device policy log block showsrdna4=0. On AMD's proprietary driver it also showsmma_unroll_try=0. RADV already tries the unrolled form, whatever the name.tests/test_device_policy.pywith this PR's two R9700 rows fails onmainfor exactly those two fields (see Measurements).Read first:
is_rdna4()andDeviceFacts::rdna4()ingpu/vk/device_policy.h,choose_software_form()ingpu/vk/vk_coopmat.cpp,auto_profile()ingpu/vk/vk_main.cpp. See #1590.Testing
Tested:
In the game, Windows 11, AMD Radeon RX 9060 XT (
1002:7590), AMD driver 26.11.2 (LLPC), driver id 1: I built the renderer from this PR's commit withpython -I scripts/dev.py vk: 246 files, 0 failed, symbols checked. I put thatlongshot_vk.dllinto a copy ofnightly-596-2692a6e3; the log readslongshot nightly-596-2692a6e3 (source 14be9eeb), the host's revision. It ran with its own empty caches and options. Both runs went through the job queue (dev.py queue run rdna4-pci-smoke --mode shared), withscripts/longshot_ctl.pybootingkokiri-startto play. Each run then stayed in Kokiri Forest (KokiriForest_Child) for 70 s with the game's own upscaler at 100%, and I read its status every 10 s. This build has no FSR 4.rdna4=1,mma_unroll_try=1, and the full linevk: 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). Frames 6642 → 10407, 50 to 60 fps, never stalled.RX_VK_MMA_UNROLL=0:rdna4=1,mma_unroll_try=1, andvk: software matrix multiplies looped (RX_VK_MMA_UNROLL=0). Frames 6547 → 10694, 60 fps, never stalled.VK_ERRORor device lost in the log.This card's name already matches "RX 9", so the run checks that nothing changed for it. The ID-only path is covered by the tests below.
Checks on Windows (
clang++, Vulkan-Headers 1.4.345):tests/test_device_policy.py: 21 PCs, 69 fields, 64 environments, 55 rule edges: ok. Withmain'sdevice_policy.hit fails on the two new R9700 rows (rdna4,mma_unroll_try).tests/test_mma_software.py:switch()(12is_rdna4cases: ID-only names, name fallback, null name, other AMD generations, NVIDIA with an RDNA 4 ID or an "RX 9" name),inputs()and the emitter/stamp wiring: pass, run on its own (python -I -B tests/test_mma_software.py --cxx clang++ --headers <SPIRV-Headers>).spirv()stops there because this PC has nospirv-val. The run below skips this whole file for the same reason. Theauto_profile()check now ignores comments; I confirmed it fails when the assignment is commented out with//or/* */.tests/test_auto_settings.py,tests/test_switch_table.py(712 switches),tests/test_doc_anchors.py,tests/test_vendor_fixes.py(16 devices): pass.python -I -B tests/run_all.py --changed origin/main(the 117 checks that read a changed file) on Windows:97 passed, 16 failed, 9 skippedhere. As a narrower comparison, I ran the same list'stests/checks onmain@068fb8eb, same PC:93 passed, 16 failed. The same 16 checks fail on both, so none is new with this PR. One of them,test_direct_buffer_writes, only hit its 60 s compile timeout because both runs were going at once; run alone, it passes on both (6.6 s here). I did not find the cause of every one of the other 15. Two examples:test_auto_handhelduses POSIXsetenv/unsetenv, and several report compile errors in their own fixtures againstmain's current names. They are:test_appimage_player_build,test_auto_handheld,test_crash_dialog,test_crt_options,test_dev_ab,test_frame_overlap,test_fsr_uniform_ownership,test_hud_layout_row,test_linux_pressure,test_prepare_cache_save,test_present_queue_default,test_present_thread,test_replay_write_order,test_vk_occlusion_queries,test_walk_key. The 9 skips needspirv-valor Linux.pre-commit(4.2.0, this repo's config) on the changed files: end-of-file, trailing-whitespace and gitleaks pass. The ruff hook stopped on a duplicate--force-excludefrom the hook wrapper, so I ran ruff 0.12.0 directly with--force-excludeon the two changed Python files: all checks passed.actionlintwas not run (no workflow changed).git diff --check: clean.mise run testandmise run lint. This PC is Windows withoutmise, and much of the suite needs Linux tools. This PR is open as WIP so CI can run them; a maintainer's OK to rely on CI for them is welcome, and I'll tick the boxes once CI passes.Still to test:
mise run test, includingtests/test_mma_software.pyspirv()withspirv-val, and the host build with clang/gcc, expecting no new failures (CI, or @Beanstalk Linux build and full test suite).rdna4=1and the selected MMA form. Record the PCI ID,deviceNameand Vulkan driver ID; on AMDGPU-PRO, check which ICD was loaded. Then, in a build with FSR 4 and a working FSR 4 runtime, with fresh options, record what Auto chooses and which upscaler is actually active (by hand, whoever has one).rdna4=1with the same MMA form as onmain(@Beanstalk).Measurements
Verdict: fixed. The two R9700 rows fail on
mainand pass here. Nothing changes on cards whose name already matched. This is not a perf change: the default for the unrolled software MMA on RDNA 4 + AMD's proprietary driver was measured in #1590 (RX 9060 XT).Setup: Windows 11,
clang++(llvm-mingw 23.1.5),python -I -B tests/test_device_policy.py --cxx clang++ --headers <Vulkan-Headers 1.4.345>, run withmain'sdevice_policy.hand then with this PR's. I ran it again aftermainwas merged into the branch: the result is the same as on068fb8eb. The one new commit onmain(08994a9e, #1815) touches none of this PR's files.08994a9e89369883Radeon AI PRO R9700, AMD's Windows driver (LLPC)(1002:7551)rdna4 is 0,mma_unroll_try is 0: FAILRadeon AI PRO R9700, AMD's proprietary driver on Linux (AMDGPU-PRO)rdna4 is 0,mma_unroll_try is 0: FAILIn the game, this PR on the RX 9060 XT shows
rdna4=1,mma_unroll_try=1and the unrolled form (Testing above). That is the same result #1590 recorded for this card.Risks
Who changes: only AMD cards with IDs
1002:7550,7551or7590whose name has neither "RX 9" nor "GFX12". In practice that is the Radeon AI PRO R9700 family, or a driver that reports a generic name. For them:rdna4=1on every driver.RX_VK_MMA_UNROLLunset, only cards onVK_DRIVER_ID_AMD_PROPRIETARYgain the unrolled software MMA trial, and the 8192-lane self-test still decides which form is used. RADV already tried it before this PR. AMDVLK keeps the loop.rdna4.LONGSHOT_SHADER_STAMPis unchanged. The runtimetranslator_stamp()includes the selected MMA form, so a card that moves from the loop to an unrolled form rebuilds its program, preparation and pipeline caches once.Everyone else: cards whose name already matched, RDNA 1-3, NVIDIA and Intel get the same policy as on
main. Their saves,longshot_options.iniand caches are untouched. NoMKWVK_API_VERSIONbump and no shader change.Turning it off:
RX_VK_MMA_UNROLL=0brings back the looped MMA (it does not affect the Auto choice). A revert restores the name-only check.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (Windows subset above; full suite on CI)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.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
RDNA 4 was told only by the device name ("RX 9" or "GFX12"), in three copies: DeviceFacts::rdna4(), is_rdna4() in vk_internal.h and auto_profile(). A card named otherwise, such as the Radeon AI PRO R9700, was not taken for RDNA 4. One is_rdna4(vendor, device ID, name) in device_policy.h now serves all three. It knows AMD's RDNA 4 PCI IDs 0x7550 and 0x7551 (Navi 48) and 0x7590 (Navi 44), with the name as a fallback. The software matrix multiply rule and its switch row say "AMD's proprietary driver", as the driver ID it tests is also AMDGPU-PRO's on Linux. See #1590. Assisted-by: Gemini (Antigravity), OpenAI Codex gpt-6.2 Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in game: Windows 11, AMD Radeon RX 9060 XT (1002:7590), AMD driver 26.11.2 (LLPC). Renderer built from this PR's commit (dev.py vk) on nightly-596-2692a6e3, run through the job queue with empty caches: kokiri-start to play, 70 s in Kokiri Forest per run at 50-60 fps with no stall. Default: rdna4=1, mma_unroll_try=1, unrolled form matching the loop over 8192 lanes. RX_VK_MMA_UNROLL=0: looped. No VK_ERROR or device lost in either run.
Possibly related, for context:
WIP: fix(vk): recognize RDNA 4 GPUs by PCI device IDto fix(vk): recognize RDNA 4 GPUs by PCI device IDRecommendation: Approve. It turns three copies of the RDNA 4 check into one and has it check the PCI ID first, so a Radeon AI PRO R9700 on AMD's proprietary driver gets the RDNA 4 policy the RX 9070 and 9060 cards already get. Cards whose name already matched see no change. Recommend approval; not approved on the forge.
For players: on an RDNA 4 card whose name has neither "RX 9" nor "GFX12" (in practice the Radeon AI PRO R9700 family on AMD's Windows driver or AMDGPU-PRO), Auto (this PC) can now pick FSR 4, and the software matrix multiplies try the unrolled form that #1590 measured, still gated by the 8192-lane self-test. The code is better for it: one definition (
is_rdna4indevice_policy.h) instead of three that could drift apart, and the comments now say "proprietary driver" because the rule never had a_WIN32check.Does it help: not a perf change. It is a fix, and the test shows it: the two R9700 rows in
test_device_policy.pyfail onmainforrdna4andmma_unroll_tryand pass here. The in-game run (RX 9060 XT, Windows, LLPC) checks that nothing changed for a card the name already matched. The ID-only path has not been run in the game.Other systems: on RADV, nothing changes: its names carry "GFX1201"/"GFX1200", so the name match already caught every RDNA 4 card. NVIDIA, Intel and RDNA 1-3 are untouched (the vendor check comes first, and the ID list has only RDNA 4 IDs, checked against
0x73DFand0x744Cin the test). On the affected cards,translator_stamp()includes the selected MMA form, so they rebuild their program caches once. A saved Auto setup keeps its choice because the fingerprint has nordna4. Both effects are stated in Risks. There is no API version bump and no shader change.Switches:
RX_VK_MMA_UNROLL: its behaviour is unchanged. The row now gives its real default ("on for Mesa RADV and AMD RDNA 4 on AMD's proprietary driver"), which the code already had since #1590. That default is right: it is what was measured, and the self-test decides. No switch is added or removed.Reviewed: head
9d3e0d8aagainst main3df5c13e(the merge ofmainthis review pushed; before that,89369883against08994a9e). Read in full:device_policy.h(is_rdna4, DeviceFacts::rdna4, the mma_unroll_try and rdna4 rules),vk_coopmat.cppsoftware_unroll_wanted/choose_software_form,vk_main.cppauto_profile and the DeviceFacts fill (pf.device_id = dev.props.deviceID),vk_internal.h,auto_settings.hchoose,switches.defrow, the user doc lines,test_device_policy.pyrows,test_mma_software.pyswitch(). Nothing run (a code review).Fixed in this review (pushed to
fix/vk-rdna4-pci-id, your commits kept):950e8714: mergedmainin. The one conflict wasvk_internal.h:mainaddedQueueMutexnext to the oldis_rdna4. I dropped the oldis_rdna4, as this PR does, and keptmain's code.9d3e0d8a: onmain,acquire_aheadis now on for every driver, and every row intest_device_policy.pylists it. Your two new R9700 rows did not, so they would have failed on the merged head. Both now list it, and nothing else in them changed (the RX 9070 XT row differs from the PR's copy only by that word).Checked and fine:
vk_main.cppandvk_coopmat.cppare both inmkwvkand includedevice_policy.hthroughvk_internal.h, so the old two-argumentis_rdna4has no callers left.p.vendorID == 0x1002is the same test as the oldhw.vendor == AMD.DeviceFacts::rdna4()keeps its oldamd()guard throughis_rdna4's vendor check.AMD Device 7550/7590and R9700 cases and both policy rows.auto_profilecheck strips comments first, so a commented-out assignment fails it.0x7550Navi 48 (RX 9070 / XT / GRE),0x7551Navi 48 (Radeon AI PRO R9700),0x7590Navi 44 (RX 9060 / XT). They do not include CDNA parts like MI350's0x75Ax, which is right.Suggestions (the author may take or leave)
gpu/vk/device_policy.h:51: an RDNA 4 part with another ID and a generic name (a mobile or OEM part, if one ships) would still fall through to the name match. That is fine as it stands; it is just one more line in the list when such a card turns up.Testing: in the game on an RX 9060 XT, Windows, AMD 26.11.2 (LLPC):
rdna4=1, unrolled, and withRX_VK_MMA_UNROLL=0, looped (the author's run and comment). Two runs are still wanted, and neither holds the merge in my view:CI on
9d3e0d8awas still running when I posted. "Guide screenshots" fails on review hashes for dozens of headers this PR does not touch, which comes frommain, not this PR. The description check fails on the two CI-reliant boxes.Overlaps and merge order:
f.rdna4(), so it gets this PR's ID-first detection with no change. Both orders merge without a textual overlap (different hunks indevice_policy.h,switches.defandtest_device_policy.py). Taking this one first is cleaner.is_rdna4rather than match names.@ -48,1 +48,4 @@// AMD RDNA 4 (GFX12): Navi 48 (0x7550 RX 9070 series, 0x7551 Radeon AI PRO R9700) and Navi 44 (0x7590 RX 9060 series),// with name matching as a fallback for future or uncatalogued GFX12 cards.inline bool is_rdna4(uint32_t vendor_id, uint32_t device_id, const char* device_name) {Suggestion: an RDNA 4 part with another ID and a generic name (a mobile or OEM part, if one ships) falls through to the name match. That is fine as it stands; add its ID here when one turns up. The three IDs match the RDNA 4 parts I know of (Navi 48 0x7550/0x7551, Navi 44 0x7590), and CDNA's 0x75Ax is rightly left out.