check_sparse_queue_family: skip CONCURRENT contract on single-family GPUs (OLD-7268) #618

Manually merged
github merged 2 commits from gh-pr/618/head into gh-pr/618/base 2026-11-26 09:12:05 +00:00
Owner

@⁠KarolKurzyna on GitHub · 2026-11-24 10:00 UTC · original
KarolKurzyna:fix/sparse-queue-family-single-family → main · +325 −3 · 2 files · 2 commits · merged 2026-11-24 16:39 UTC

Claimed in the coordination issue as: OLD-7268 (#14)

Carried over from upstream ItsNotRexed/Leonida PR #7268 (b75d669b0a, incorporating @wasonidas's review suggestions), where it received 5/5 independent PASS reviews (@claudetools-gh, @rideinstead, @garuspl, @airp1ane, @lines9686-rgb).

What was wrong

  1. On single-queue-family GPUs with sparse binding (such as Intel UHD Graphics 770 on Windows, which exposes 1 queue family with GRAPHICS | COMPUTE | TRANSFER | SPARSE_BINDING), VulkanDevice selects the same family for graphics, compute, and DMA, so only 1 distinct sparse-capable family exists and VK_SHARING_MODE_EXCLUSIVE is valid per the Vulkan specification. However, runtime/test/check_sparse_queue_family.py unconditionally failed when VK_SHARING_MODE_CONCURRENT was absent from vkCreateBuffer / vkCreateImage in the VK_LAYER_LUNARG_api_dump output.
  2. When multiple queue families were present in the dump, the script needed to mirror runtime/src/queue_families.h (pick_queue_families followed by sparse_capable_queue_families) in exact selection order and strictly validate vkGetPhysicalDeviceQueueFamilyProperties against pQueueFamilyPropertyCount.

What changed

  • Mirror runtime/src/queue_families.h (pick_queue_families -> sparse_capable_queue_families) in runtime/test/check_sparse_queue_family.py: pick the first non-graphics async compute and fine-grained (1x1x1) DMA transfer families first, fall back to the graphics family if the chosen family lacks VK_QUEUE_SPARSE_BINDING_BIT, and require VK_SHARING_MODE_CONCURRENT only when >= 2 distinct sparse-capable families are selected.
  • Strictly validate vkGetPhysicalDeviceQueueFamilyProperties dumps against pQueueFamilyPropertyCount and contiguous indices 0..count-1 so truncated or malformed dumps are never silently ignored.
  • Add synthetic unit tests in tests/test_check_sparse_queue_family.py covering single-family GPUs, non-sparse compute/DMA ahead of sparse families, and incomplete/malformed property dumps (29/29 pass).

Tested

  • python -I -m unittest tests/test_check_sparse_queue_family.py -v: 29/29 PASS.
  • NVIDIA GeForce RTX 3070 Ti (621.24, 3 sparse-capable queue families, Windows 11): ctest -R d3d12_sparse_queue_family PASS (verifies VK_SHARING_MODE_CONCURRENT across 3 families).
  • Intel(R) UHD Graphics 770 (101.6129, 1 sparse-capable queue family, Windows 11): ctest -R d3d12_sparse_queue_family PASS (was failing before fix).

AI-assisted.

**@⁠KarolKurzyna** on GitHub · 2026-11-24 10:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/618) `KarolKurzyna:fix/sparse-queue-family-single-family` → `main` · +325 −3 · 2 files · 2 commits · merged 2026-11-24 16:39 UTC Claimed in the coordination issue as: OLD-7268 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) Carried over from upstream `ItsNotRexed/Leonida` PR `#7268` (`b75d669b0a`, incorporating `@wasonidas`'s review suggestions), where it received **5/5 independent `PASS` reviews** (`@claudetools-gh`, `@rideinstead`, `@garuspl`, `@airp1ane`, `@lines9686-rgb`). ### What was wrong 1. On single-queue-family GPUs with sparse binding (such as Intel UHD Graphics 770 on Windows, which exposes 1 queue family with `GRAPHICS | COMPUTE | TRANSFER | SPARSE_BINDING`), `VulkanDevice` selects the same family for graphics, compute, and DMA, so only 1 distinct sparse-capable family exists and `VK_SHARING_MODE_EXCLUSIVE` is valid per the Vulkan specification. However, `runtime/test/check_sparse_queue_family.py` unconditionally failed when `VK_SHARING_MODE_CONCURRENT` was absent from `vkCreateBuffer` / `vkCreateImage` in the `VK_LAYER_LUNARG_api_dump` output. 2. When multiple queue families were present in the dump, the script needed to mirror `runtime/src/queue_families.h` (`pick_queue_families` followed by `sparse_capable_queue_families`) in exact selection order and strictly validate `vkGetPhysicalDeviceQueueFamilyProperties` against `pQueueFamilyPropertyCount`. ### What changed - Mirror `runtime/src/queue_families.h` (`pick_queue_families` -> `sparse_capable_queue_families`) in `runtime/test/check_sparse_queue_family.py`: pick the first non-graphics async compute and fine-grained (`1x1x1`) DMA transfer families first, fall back to the graphics family if the chosen family lacks `VK_QUEUE_SPARSE_BINDING_BIT`, and require `VK_SHARING_MODE_CONCURRENT` only when `>= 2` distinct sparse-capable families are selected. - Strictly validate `vkGetPhysicalDeviceQueueFamilyProperties` dumps against `pQueueFamilyPropertyCount` and contiguous indices `0..count-1` so truncated or malformed dumps are never silently ignored. - Add synthetic unit tests in `tests/test_check_sparse_queue_family.py` covering single-family GPUs, non-sparse compute/DMA ahead of sparse families, and incomplete/malformed property dumps (`29/29` pass). ### Tested - `python -I -m unittest tests/test_check_sparse_queue_family.py -v`: **29/29 PASS**. - **NVIDIA GeForce RTX 3070 Ti** (`621.24`, 3 sparse-capable queue families, Windows 11): `ctest -R d3d12_sparse_queue_family` **PASS** (verifies `VK_SHARING_MODE_CONCURRENT` across 3 families). - **Intel(R) UHD Graphics 770** (`101.6129`, 1 sparse-capable queue family, Windows 11): `ctest -R d3d12_sparse_queue_family` **PASS** (was failing before fix). AI-assisted.
DeviceState::share() (runtime/shims/d3d12_vulkan_device.cpp) only sets
VK_SHARING_MODE_CONCURRENT when the device has >= 2 queue families; Vulkan
VUID-VkBufferCreateInfo-sharingMode-00914 forbids CONCURRENT with <= 1
family. On GPUs that expose only one sparse-capable graphics/compute/transfer
queue family (such as Intel UHD Graphics 770 Xe-LP, whose second family is
VK_QUEUE_VIDEO_DECODE_BIT_KHR only), d3d12_sparse_queue_family_test passes
with valid EXCLUSIVE sparse buffers and zero Vulkan validation errors, but
check_sparse_queue_family.py failed expecting CONCURRENT with >= 2 families.

Inspect vkCreateDevice and the same physicalDevice's
vkGetPhysicalDeviceQueueFamilyProperties in the api_dump trace (mirroring
runtime/src/queue_families.h). When the physical device genuinely exposes
only one sparse-capable family and vkCreateDevice created one family, still
validate that every sparse VkBuffer uses EXCLUSIVE with count=0 and that the
Khronos validation pass reports zero errors, then exit 77 (CTest skip).
Multi-family physical devices remain strictly enforced even if vkCreateDevice
erroneously drops to one family.
Address review feedback on #7268:
- Mirror runtime/src/queue_families.h (pick_queue_families followed by
  sparse_capable_queue_families) in exact selection order: pick the first
  non-graphics async compute and fine-grained (1x1x1) DMA transfer families
  first, then fall back to the graphics family if the chosen family lacks
  VK_QUEUE_SPARSE_BINDING_BIT. Also read the graphics family index from
  vkCreateDevice's pQueueCreateInfos[0] when present.
- Validate vkGetPhysicalDeviceQueueFamilyProperties dumps strictly against
  pQueueFamilyPropertyCount and contiguous indices 0..count-1 so incomplete
  or truncated entries are never silently dropped.
- Add synthetic unit tests covering non-sparse compute/DMA ahead of sparse
  families and malformed/incomplete queue-family dumps (29/29 pass).

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:12:03 +00:00
github manually merged commit b75d669b0a into gh-pr/618/base 2026-11-26 09:12:05 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.