Skip to content

vk_subgroup_info: require bufferDeviceAddress; tests ignore the caller's LEONIDA_VK_DEVICE - #1762

Closed
Dom-in wants to merge 0 commit into
ItsNotRexed:mainfrom
Dom-in:subgroup-info-device
Closed

Dom-in wants to merge 0 commit into
ItsNotRexed:mainfrom
Dom-in:subgroup-info-device

Conversation

@Dom-in

@Dom-in Dom-in commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to @AwkGrep256's finding on #1548. The LEONIDA_VK_DEVICE filter landed separately (#1755, TEST-258); this PR is what was still missing. One commit on main:

  1. bufferDeviceAddress. d3d12_vulkan_device.cpp skips a device without it, and the tool didn't check it (VkPhysicalDeviceVulkan12Features index 38), so it could answer for a GPU the runtime passes over. FakeDevice gets buffer_device_address, and the rejection test gets a no_buffer_device_address case.
  2. Tests honour a tester's environment. On main, LEONIDA_VK_DEVICE=radeon python -m pytest tests/test_vk_subgroup_info.py gives 45 failed: QueryTest/MainCliTest expect the unfiltered pick but read the caller's variable, and docs/testing.md suggests setting it on a multi-GPU PC. setUp now clears it under mock.patch.dict; the filter tests still set it themselves.

The device ranking (native driver over Dozen, first-of-highest-rank) that an earlier revision had is removed, per @lucastayaralvarenga-ui's review: the probe must keep the runtime's rule ("last discrete wins") until the runtime changes with it. That change is #1799, and the tool can follow it once #1799 merges.

python -m pytest -q tests/test_vk_subgroup_info.py tests/test_make_game_wave64.py   68 passed
LEONIDA_VK_DEVICE=radeon python -m pytest -q ...                                     68 passed (main: 45 failed)

Disclosure: written with an AI assistant (Claude Code). I reviewed it and ran the commands above.

🤖 Generated with Claude Code

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Added a second commit: the tool now also requires bufferDeviceAddress (VkPhysicalDeviceVulkan12Features index 38), as d3d12_vulkan_device.cpp:5669 does, so the "not in scope" gap in the description is closed. FakeDevice has buffer_device_address, and the rejection test has a no_buffer_device_address case. 37 passed (65 together with test_make_game_wave64.py), with and without LEONIDA_VK_DEVICE set. The RX 9070 still answers native64: true.

@XFlawless1

Copy link
Copy Markdown
Contributor

Tested 13e66db on a PC with two GPUs, Windows 11 Pro 10.0.26300, Python 3.12.10: pass.

  • Ryzen 7 9800X3D iGPU (RDNA2, 0x13C0), AMD Windows 32.0.21042.62, subgroup 32..64

  • RTX 5080, NVIDIA 621.14, subgroup 32..32

  • compileall is clean. tests/test_vk_subgroup_info.py: 37 OK, also with LEONIDA_VK_DEVICE=radeon and =nvidia set. tests/test_make_game_wave64.py: OK.

  • Real tools/vk_subgroup_info.py:

LEONIDA_VK_DEVICE main c2967a5e this PR
unset RTX 5080, native64 false RTX 5080, native64 false
radeon / RADEON / amd RTX 5080 (wrong GPU) AMD Radeon(TM) Graphics, subgroup 64, native64 true
RTX 5080 / nvidia RTX 5080 RTX 5080
intel (no match) RTX 5080 {"error": "RuntimeError: LEONIDA_VK_DEVICE=intel: no Vulkan 1.3 GPU ..."}, exit 1

radeon now names the same device the shader tools pick. vk_compute_test reports AMD Radeon(TM) Graphics with the same filter.

  • Code read:
    • The filter matches runtime/src/vulkan_device_filter.h: lower-cased, substring match, empty takes every device.
    • The feature list matches the selection loop in d3d12_vulkan_device.cpp: Vulkan 1.3, the filter, then the five features. That includes bufferDeviceAddress.
    • 16 + 4 * 38 is bufferDeviceAddress in VkPhysicalDeviceVulkan12Features member order, right after hostQueryReset (36) and timelineSemaphore (37).

Together with #1697: a local merge of 0effeca onto this PR has one small conflict in the chosen = (...) tuple in query(). I kept both sides: #1697's vendor/device/driver fields and this PR's no-match raise. After that, test_vk_subgroup_info passes (39 OK), and so does test_make_game_wave64 (32 OK). On this PC, wave64_emulate('auto') gives:

  • unset or nvidia: emulation on (RTX 5080)
  • radeon: emulation off, logging the runtime's GPU (AMD Radeon(TM) Graphics) is RDNA2 on the AMD Windows driver ... (#857), with rdna2_amd_windows: true and device_id 5056
  • intel: the error above, so emulation stays on

So the combined pair handles the iGPU-plus-dGPU case raised on #1697. Whichever PR lands second needs that one-hunk rebase.

AI-assisted (Claude Code).

@freemanovec

Copy link
Copy Markdown
Contributor

Tested 13e66dbb on Intel(R) HD Graphics 530 (SKL GT2), Mesa 26.2.7-arch1.1 (ANV), Arch Linux, Python 3.14.10: pass. AI-only run.

  • python3 -m compileall -q tools/vk_subgroup_info.py tests/test_vk_subgroup_info.py: clean.
  • python3 -I tests/test_vk_subgroup_info.py -v: 37/37 OK.
  • Live Vulkan query (tools/vk_subgroup_info.py, both unset and LEONIDA_VK_DEVICE=Intel): returns Intel(R) HD Graphics 530 (SKL GT2), subgroup_size: 32, 8..32, native64: false.

No game files.

@Dom-in
Dom-in force-pushed the subgroup-info-device branch from d83accb to 1ba88e7 Compare November 22, 2026 14:20
@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 003e781 (kept #857's vendor/device/driver fields in the chosen tuple) and added two commits:

tests/test_vk_subgroup_info.py + tests/test_make_game_wave64.py: 72 passed, with and without LEONIDA_VK_DEVICE. The RX 9070 still answers native64: true.

@TheAirborneCoder

Copy link
Copy Markdown
Contributor

Tested 1ba88e7b on NVIDIA GeForce RTX 5090 (driver 32.0.16.1088) + AMD Radeon(TM) Graphics RDNA2 iGPU (driver 32.0.21042.62), Windows 11 (10.0.26200), Python 3.14.7: pass (AI-assisted).

  • python -m compileall -q make_game.py tools tests: clean
  • python -I tests/test_vk_subgroup_info.py -v: 39/39 OK (including with LEONIDA_VK_DEVICE=nonexistent-gpu-xyz in caller env)
  • python -I tests/test_make_game_wave64.py -v: 33/33 OK
  • Live dual-GPU CLI checks (python -I tools/vk_subgroup_info.py):
    • unset / "" / 5090 / nvidia / NVIDIA -> NVIDIA GeForce RTX 5090 (subgroup_size: 32, 32..32, native64: false, rdna2_amd_windows: false)
    • radeon / RADEON / amd -> AMD Radeon(TM) Graphics (subgroup_size: 64, 32..64, native64: true, vendor_id: 4098, device_id: 5056, driver_id: 1, rdna2_amd_windows: true)
    • nonexistent-gpu-xyz -> exit 1, error JSON (no fallback)

Code review: device_filter/device_wanted match vulkan_device_filter.h, device_rank matches vk_device_pick.h 1:1, and F12_BUFFER_DEVICE_ADDRESS = 168 is the exact VkPhysicalDeviceVulkan12Features::bufferDeviceAddress offset. Two tiny non-blocking nits: device_wanted assumes wanted is already lower-cased (wanted.lower() in name.lower() would match its docstring on direct calls), and chosen recomputes vendor instead of reusing the local variable.

@lucastayaralvarenga-ui lucastayaralvarenga-ui left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 39 subgroup tests pass on Windows with Python 3.12 at 1ba88e7b. The filter matches the intent, but the ranking changes which adapter the probe reports relative to the runtime on this base. runtime/shims/d3d12_vulkan_device.cpp:5860 still replaces the choice for every suitable discrete adapter. The Python probe keeps the first equal-rank discrete adapter, which the new first_discrete_wins_a_tie test explicitly expects. If both adapters match an empty or broad filter, make_game.py can still set wave64 options for the wrong GPU. Please retain the current runtime selection rule here, or make the new ranking depend on the runtime change and test the combined result. AI-assisted review.

Hardware retest. Tested 878aa29 on an NVIDIA GeForce RTX 4060 (Vulkan subgroup 32..32), driver 621.24, with an AMD Ryzen 5 5500 and Windows 11 Pro (build 26300.9974). Pass for the live Vulkan probe and targeted Python tests.

  • With the filter unset, RTX 4060, or nViDiA, tools/vk_subgroup_info.py selected the RTX 4060, reported native64: false, and exited 0. An unmatched filter returned a JSON error and exited 1.
  • Python 3.12.16: tests/test_vk_subgroup_info.py and tests/test_make_game_wave64.py passed (68 tests, 65 subtests). Hardware coverage was a single Vulkan GPU. AI-assisted.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Tested 1ba88e7 on AMD Radeon(TM) Graphics (Ryzen 9 9950X3D iGPU, RDNA2, subgroup 32..64), driver 26.10.1, and NVIDIA GeForce RTX 5080 (subgroup 32..32), driver 616.92, Windows 11 (26200): pass.

Machine with both GPUs installed and the RTX 5080 first in Vulkan's list. Detached worktree at the PR head (base 003e781); a second worktree at 003e781 for the red check.

  • python tools/vk_subgroup_info.py with VK_LOADER_LAYERS_DISABLE=~implicit~:
    • LEONIDA_VK_DEVICE=radeon: "device": "AMD Radeon(TM) Graphics", subgroup 64 (32..64), native64: true, exit 0.
    • LEONIDA_VK_DEVICE=5080: "device": "NVIDIA GeForce RTX 5080", subgroup 32, native64: false, exit 0.
    • Red on main (003e781), LEONIDA_VK_DEVICE=radeon: answers for the RTX 5080 (native64: false), which is the bug the PR describes. The PR head answers for the Radeon.
    • An unmatched value (LEONIDA_VK_DEVICE=nonexistentgpu) at the earlier head 13e66db: {"error": "RuntimeError: LEONIDA_VK_DEVICE=nonexistentgpu: ..."}, exit 1. Not rerun at 1ba88e7.
  • pytest tests/test_vk_subgroup_info.py tests/test_make_game_wave64.py: 72 passed, 62 subtests, with LEONIDA_VK_DEVICE=radeon and with =5080.

Not run: the full GPU test suite and the full semantic suite (the PR touches only the tool, its test and docs/testing.md).

AI-assisted.

@Dom-in
Dom-in force-pushed the subgroup-info-device branch from 1ba88e7 to 878aa29 Compare November 22, 2026 14:50
@Dom-in Dom-in changed the title vk_subgroup_info: honour LEONIDA_VK_DEVICE like the runtime vk_subgroup_info: require bufferDeviceAddress, rank like vk_device_pick.h; isolate LEONIDA_VK_DEVICE in tests Nov 22, 2026
@Dom-in
Dom-in force-pushed the subgroup-info-device branch from 2dbf004 to c505b62 Compare November 22, 2026 15:26
@Dom-in
Dom-in force-pushed the subgroup-info-device branch from c505b62 to 4c27573 Compare November 22, 2026 16:04
@Dom-in Dom-in changed the title vk_subgroup_info: require bufferDeviceAddress, rank like vk_device_pick.h; isolate LEONIDA_VK_DEVICE in tests vk_subgroup_info: require bufferDeviceAddress; tests ignore the caller's LEONIDA_VK_DEVICE Nov 22, 2026
@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@lucastayaralvarenga-ui thanks, you're right: on its own the ranking made the probe disagree with the runtime. I've removed it. The branch (4c27573) is now only the bufferDeviceAddress check and the test isolation, and the selection rule is unchanged (last_discrete_wins restored). The ranking goes with the runtime in #1799, and the probe can follow once that merges. 68 passed, with and without LEONIDA_VK_DEVICE set.

@UNYTIX

UNYTIX commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 4c27573e8e78. Command python -B -I tests/test_vk_subgroup_info.py -v.

35 passed. python -B -I tools/vk_subgroup_info.py also exited 0 on RX 7800 XT, AMD 26.11.2 (LLPC), reporting 32–64 subgroups, native64=true and per_vertex_inputs=true. Device query only, with no GPU workload.

Independent Windows 11 verification, Python 3.15.2. AI-assisted.

ItsNotRexed added a commit that referenced this pull request Nov 22, 2026
@Dom-in Dom-in closed this Nov 22, 2026
@Dom-in
Dom-in force-pushed the subgroup-info-device branch from 4c27573 to 4947579 Compare November 22, 2026 16:42
@Dom-in
Dom-in deleted the subgroup-info-device branch November 22, 2026 16:46
ItsNotRexed added a commit that referenced this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants