refactor(vk): add GPU architecture classifier (gpu_arch.h) and expose DeviceFacts::arch #2227
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!2227
Loading…
Reference in a new issue
No description provided.
Delete branch "madebyjordan/Longshot:feat/gpu-arch"
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
Adds a centralized, Vulkan-free GPU architecture classifier (
gpu/vk/gpu_arch.h) and exposes it onDeviceFactsingpu/vk/device_policy.hso driver workarounds and hardware policy rules can be gated by GPU generation (e.g. RDNA 2 vs RDNA 3/4, Alchemist vs Battlemage) instead of vendor-wide or ad-hoc device-ID helpers.What this changes:
gpu/vk/gpu_arch.hwithGpuArch(amd_gcn,amd_vega,amd_rdna1..amd_rdna4,intel_gen12,intel_alchemist,intel_meteor_arrow,intel_lunar,intel_battlemage,intel_panther,nvidia_pascal..nvidia_blackwell),gpu_arch_name(),classify_gpu_arch(), andis_rdna1..is_rdna4helpers.is_rdna3andis_rdna4fromgpu/vk/device_policy.hintogpu/vk/gpu_arch.h(no change to existing RDNA 3/4 classification) and addsDeviceFacts::arch(),arch_name(),rdna1()..rdna4(), andamd_win().(arch <name>)on the startupvk: policy: factsline so player logs immediately report the detected architecture.tests/test_gpu_arch.pycovering AMD (including Steam Deck Van Gogh0x163F, OLED Sephiroth0x1435, GCN 1–4, and Vega 12), Intel (including DG1), and NVIDIA (including RTX 50700x2F04, GP108 vs Volta, and Hopper exclusions) device IDs and name fallbacks, updatestests/test_device_policy.pywith end-to-endDeviceFacts::arch()/(arch <name>)log assertions, updatestests/test_mma_software.pyto readis_rdna4fromgpu/vk/gpu_arch.h, and documentsgpu_arch.hindocs/dev/reference/architecture.md.No default policy value changes on any GPU.
Read first:
gpu/vk/gpu_arch.h, thengpu/vk/device_policy.h(DeviceFacts).Testing
Tested: Windows 11, AMD Radeon RX 6700 XT (
1002:73df), AMD driver26.10.1(0x800161), headless in-game boot oncastle-gate(HyruleField_Child): startup log printsvk: policy: facts 1002:73df (arch amd_rdna2), driver id 1, version 0x800161 (26.10.1 (AMD proprietary shader compiler)), type 2, Windowswith all policy fields identical tomain.6d9b7c662with bothclang++andg++:test_gpu_arch.py,test_device_policy.py,test_mma_software.py(withspirv-val), andtest_doc_anchors.pyall pass (plus earlier full sweep one8915426;test_switch_table.pyfails only on the pre-existingmainsort order ofRX_VK_GRASS_DISTANCE/RX_VK_SIM_TURF_ADAPTIVE, tracked in #2197).dev.py vkbuildslongshot_vk.dllcleanly on Windows (llvm-mingw).Still to test:
gpu_arch.hand thatvk: policy: factslogs the expected(arch <name>)with unchanged policy fields (by hand — Beanstalk cannot validate GPU-specific arch values or diff policy fields againstmain).Measurements
Nothing to measure: pure header-only architecture classification and one startup log token (
(arch <name>)), with zero runtime behavior change on any GPU.Risks
Minimal:
classify_gpu_arch()is only logged onvk: policy: factsand existingis_rdna3/is_rdna4rules are unchanged. A revert cleanly removes it. Nothing changes in saves,longshot_options.ini, or caches.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
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.Tested in game: Windows 11, AMD Radeon RX 6700 XT (1002:73df), AMD driver 26.10.1 (0x800161), headless castle-gate (HyruleField_Child): startup log prints 'vk: policy: facts 1002:73df (arch amd_rdna2)' with all policy fields identical to main.
Possibly related, for context:
e8915426f3218a728d93The classifier's AMD GCN coverage is incomplete, and the uncatalogued fallback is only RADV's hint; on AMD's Windows driver many GCN IDs become
Unknown.The enum/docs claim GCN 1–4 (HD 7000/8000, R9 200/300, RX 400/500), but
classify_gpu_arch()maps only0x67DF/67EF/67FF/699F/7300.0x6798(HD 7970),0x6818/683D(Pitcairn/Cape Verde),0x6650(Bonaire) and0x67A0/67B0(Hawaii) are not mapped; the only uncatalogued GCN in the test (0x6798) passesradv_gcn=true, whichDeviceFactsgets only on RADV (!storage_io16). An AMD proprietary GCN — the platform #2228 targets — isUnknown, notAmdGcn. That is a safe no-rule fallback, but it means a futurearch()==AmdGcngate will not fire; add a real GCN Windows case withradv_gcn=falseand either map the family or state GCN is RADV-only.Also missing/misclassified: Vega 12 (
0x69A0–0x69AF) is not in the Vega ranges; Intel DG1 (0x4900) is notIntelGen12; NVIDIA Volta (0x1DB4and the0x1Dxxrange) falls in the Pascal range and is classified Pascal — a wrong family, notUnknown. These are future-rule gaps; current rules do not use them.Use sites do not change behaviour.
rdna3()/rdna4()still resolve through the sameis_rdna3/is_rdna4logic;p.batch_submits,p.mma_unroll_try,p.rdna4andauto_profile's directis_rdna4call are unchanged;(arch …)is a startup log token;amd_win()/rdna1()/rdna2()are new.test_device_policyandtest_mma_softwarepass, so this is a refactor plus log, not a policy change.Test:
test_gpu_arch.pyis new and fails on main becausegpu_arch.hdoes not exist there; it covers representative AMD/Intel/NVIDIA IDs, helper parity, cross-vendor isolation and unknown. It does not cover a proprietary GCN, Vega 12, DG1 or Volta, and it does not build aDeviceFactsend-to-end — only source strings forarch()/the log. Add those cases if the classifier is meant to be exhaustive.Not already solved on main: main has
is_rdna3/is_rdna4indevice_policy.hand #1839 only recognizes RDNA 4 by ID; there is nogpu_arch.horGpuArch, so this is new.No approval, no fix claim; the refactor is quiet on today's rules, and the gaps are about the breadth of the new classifier.
Thanks for the thorough review, @dazemc — all of those gaps are addressed in
5d80be2c2:radv_gcn_hint: Mapped the GCN 1–4 discrete PCI ID ranges ingpu/vk/gpu_arch.h(0x6600–0x667FOland/Bonaire/Hainan,0x6780–0x67FFTahiti/Hawaii/Polaris 10–11,0x6800–0x683FPitcairn/Cape Verde,0x6900–0x693FTopaz/Tonga,0x694C–0x694FPolaris 22/Vega M,0x6980–0x699FPolaris 12,0x6FDFRX 580 2048SP / 590 GME,0x7300Fiji) so AMD Windows proprietary GCN classifies asAmdGcndirectly, while excluding TeraScale (0x6700–0x677F,0x6840–0x685F,0x6880–0x68FF) and keepingradv_gcn_hintas the RADV fallback for uncatalogued GCN APUs.0x69A0–0x69AFtoAmdVega(with GCN PCI IDs checked before the"Vega"name fallback so GFX8 Vega M0x694C–0x694FstaysAmdGcn) and0x4900toIntelGen12.0x1Dxxat0x1D7Fso Pascal GP108 (0x1D00–0x1D7F, e.g. GT 1030 / MX150) remainsNvidiaPascalwhile Volta GV100 (0x1D80–0x1DFF, e.g. TITAN V0x1D81, V1000x1DB4) returnsUnknown. Also narrowedNvidiaAmpereto0x22xx/0x24xx/0x25xxso Hopper GH100 (0x23xx, e.g. H1000x2330) returnsUnknownrather thanNvidiaAmpere.tests/test_gpu_arch.pyfor all of the above (including Windows GCN withradv_gcn=false, TeraScale exclusion, Vega 12 by ID with null name, DG1, Pascal GP108 vs Volta, and Hopper) and end-to-endDeviceFacts::arch()/amd_win()/(arch <name>)log assertions intests/test_device_policy.py.Re-verified on
5d80be2c2:test_gpu_arch.py(clang++&g++),test_device_policy.py(clang++&g++),test_mma_software.py(withspirv-val), andtest_doc_anchors.pyall pass.@review
Recommendation: Request changes. The classifier can report a GCN GPU as RDNA 2 because a broad name match takes precedence over its known PCI ID. That makes the startup log misleading and makes the new architecture API unsafe for generation-specific rules.
The change centralizes GPU architecture detection and adds it to the startup policy log. Existing RDNA 3 and RDNA 4 policy predicates retain their prior behavior, but the new classifier needs more precise precedence for known devices.
@fixwill do (4)gpu/vk/gpu_arch.h:115: The "RX 6" fallback runs before the GCN PCI ID ranges, so a Polaris Radeon RX 640, for example, is classified as RDNA 2 even when its known GCN device ID is supplied. (more on the line)PR description / Description follows the template (pull_request_target)fails on this head and passes on the base branch: Failing after 9s.Guide screenshots / Guide images and local UI source review (pull_request)fails on this head and passes on the base branch: Failing after 10s.CI / Website build and checks (pull_request)fails on this head and passes on the base branch: Failing after 35s.Before merging: testing (1) (runs on the systems it can change; it doesn't hold the recommendation)
More: does it help, other systems, switches, what was read
Does it help: Unproven as a classifier across supported hardware. The supplied Windows RX 6700 XT run reports RDNA 2 and unchanged policy fields; the supplied game-free tests cover representative IDs. This is not a performance change.
Other systems: The existing RDNA 4 policy fields, auto profile and cooperative-matrix paths continue to use the same RDNA 3/4 predicates. The new classification also appears in logs on Linux, Windows, Steam Deck, NVIDIA and Intel systems; the supplied in-game run covers one Windows AMD GPU.
Switches: None added, changed or removed.
Reviewed:
5d80be2c2bagainsta2dc538590: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the full new classifier and test, the changed portions and relevant surrounding code in device_policy.h and the two existing tests, their callers, the diff and both commit messages. Skimmed the architecture reference and test runner. docs/review-checklist.md and the adjacent Tooling AGENTS.md were unavailable. No generated files or recorded runs were changed.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run code were executed, as requested. The supplied reports describe Windows in-game testing and game-free checks; Linux in-game testing remains outstanding. Three head-only CI failures are supplied separately and are not restated.
Overlaps and merge order: Not determined; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.
@ -0,0 +112,4 @@default:break;}return device_name && (std::strstr(device_name, "GFX103") || std::strstr(device_name, "NAVI2") ||L1: The "RX 6" fallback runs before the GCN PCI ID ranges, so a Polaris Radeon RX 640, for example, is classified as RDNA 2 even when its known GCN device ID is supplied. This produces an incorrect log and could enable an incompatible future RDNA 2 rule. Resolve known PCI IDs before name fallbacks, and add a test using an RX 640 name and its GCN ID.
Addressed BeanBot's review findings in
6d9b7c662and updated the PR description:6d9b7c662): Good catch on Polaris Radeon RX 640 (0x6987/0x699F).classify_gpu_arch()now resolves all catalogued AMD PCI device IDs viaclassify_amd_pci_id()before any device-name fallback,is_rdna1..3()delegate toclassify_gpu_arch()for consistent ID-first precedence (while keepingis_rdna4()self-contained fortests/test_mma_software.py), and the RDNA 2 name fallback now requires a 4-digitRX 6NNNmodel number (has_rx_4digit_series) so 3-digitRX 640cannot match RDNA 2 even by name alone. Added RX 640 regression tests intests/test_gpu_arch.py.Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.line fromWhen it applies(Linux build/run remains tracked underStill to test);scripts/check_pr_description.pynow passes on #2227.Guide screenshots) & L5 (CI / Website build and checks): Both are pre-existing failures on the base branchmain(a2dc53859018: runs48672/jobs/0and48671/jobs/5), not regressions from this PR (scripts/check_guide_screenshots.py --review-sourcesreports 10 pre-existing UI hash drifts onsettings-graphics.png;test_guide_screenshots.pyandtest_launcher_capture.pypass).Re-verified on
6d9b7c662:test_gpu_arch.py(clang++&g++),test_device_policy.py(clang++&g++),test_mma_software.py(withspirv-val),test_doc_anchors.py, andscripts/check_pr_description.pyall pass.@review
Recommendation: Request changes. The RX 640 classification is fixed, and the Windows run reports the expected architecture. A Linux in-game startup check remains outstanding. (It stands on L4: The check
Guide screenshots / Guide images and local UI source review (pull_request)fails on this head and passes on the base branch: Failing after 10s.)The change centralizes GPU architecture classification and adds the detected architecture to the startup log. Known AMD PCI IDs now take precedence over name fallbacks, at the cost of maintaining the classification table.
@fixwill do (2)Guide screenshots / Guide images and local UI source review (pull_request)fails on this head and passes on the base branch: Failing after 10s.CI / Website build and checks (pull_request)fails on this head and passes on the base branch: Failing after 35s.Before merging: testing (1) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
5d80be2c2b)Resolved: L1 (The "RX 6" fallback runs before the GCN PCI ID ranges, so a Polaris Radeon RX 640, for exa…); L3 (The check
PR description / Description follows the template (pull_request_target)fails…)Still open: L2 (A Linux in-game run remains outstanding. Check startup and the reported architecture on a…); L4 (The check
Guide screenshots / Guide images and local UI source review (pull_request)fai…); L5 (The checkCI / Website build and checks (pull_request)fails on this head and passes on…)Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven: the reported Windows RX 6700 XT run showed the expected RDNA 2 log and unchanged policy fields; the Linux integration has not yet been run in game. This is not a performance change.
Other systems: The classifier covers AMD, Intel and NVIDIA; the recorded in-game evidence is Windows on AMD only. RDNA 4 classification also feeds policy and other renderer paths; Linux startup remains unverified.
Switches: None.
Reviewed:
6d9b7c6621againsta2dc538590: Read AGENTS.md, CONTRIBUTING.md, the pull request template, gpu/vk/gpu_arch.h and tests/test_gpu_arch.py; reviewed the diff and searched RDNA helper callers. The other changed files and surrounding callers were skimmed, not read in full. No review-checklist.md was found.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The author reports game-free checks with clang++ and g++, a Windows build, and a Windows in-game startup; Linux in-game testing remains outstanding.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.