d3d12: choose sparse-capable queues for sparse textures (D3D-SPARSE-IMAGE-QUEUE-FAMILY) #1164

Merged
lixonik merged 1 commit from upstream-pr/1164 into main 2026-11-29 19:00:19 +00:00
lixonik commented 2026-11-24 19:28:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-24T19:28:14Z.


Claimed in the coordination issue as D3D-SPARSE-IMAGE-QUEUE-FAMILY.

What and why

Queue selection used sparse buffer residency as its gate, while the device can expose sparse 2D textures independently. With sparse textures and no sparse buffers, a D3D12 COPY or COMPUTE queue could keep a dedicated Vulkan queue without VK_QUEUE_SPARSE_BINDING_BIT. Tile mapping on that queue would then pass an invalid queue to vkQueueBindSparse.

Use the same sparse aliasing prerequisites for device initialization and queue selection. Apply the fallback when either sparse buffer or sparse 2D image residency is available, retaining dedicated queues that support sparse binding. Add a synthetic image-only case to the queue-family picker tests.

Tested

  • With the former buffer-only gate restored, the new image-only assertion fails. With the fix, the synthetic picker passes all seven layouts on Windows with MSVC and on Ubuntu with GCC.
  • Compiled the modified Windows runtime translation unit and vk_queue_test.cpp with MSVC.
  • The Ubuntu vk_queue_test also passed the CPU queue-slot checks. Its GPU portion reported skip because the local Ubuntu environment has no Vulkan loader.
  • Full translator semantic suite passed (470 files, 6,141 tests). Python compile checks and make_game.py --help passed.
  • git diff --check and scripts/check_no_game_data.py passed.

GPUs tested: n/a (CPU-only synthetic checks).

AI-assisted.

Checklist

  • Based on current main.
  • One topic.
  • No game data, keys or decryption.
  • No new translator rule.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478885538 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1164). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-24T19:28:14Z. --- Claimed in the coordination issue as [D3D-SPARSE-IMAGE-QUEUE-FAMILY](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7142010267). ### What and why Queue selection used sparse buffer residency as its gate, while the device can expose sparse 2D textures independently. With sparse textures and no sparse buffers, a D3D12 COPY or COMPUTE queue could keep a dedicated Vulkan queue without `VK_QUEUE_SPARSE_BINDING_BIT`. Tile mapping on that queue would then pass an invalid queue to `vkQueueBindSparse`. Use the same sparse aliasing prerequisites for device initialization and queue selection. Apply the fallback when either sparse buffer or sparse 2D image residency is available, retaining dedicated queues that support sparse binding. Add a synthetic image-only case to the queue-family picker tests. ### Tested - With the former buffer-only gate restored, the new image-only assertion fails. With the fix, the synthetic picker passes all seven layouts on Windows with MSVC and on Ubuntu with GCC. - Compiled the modified Windows runtime translation unit and `vk_queue_test.cpp` with MSVC. - The Ubuntu `vk_queue_test` also passed the CPU queue-slot checks. Its GPU portion reported skip because the local Ubuntu environment has no Vulkan loader. - Full translator semantic suite passed (470 files, 6,141 tests). Python compile checks and `make_game.py --help` passed. - `git diff --check` and `scripts/check_no_game_data.py` passed. GPUs tested: n/a (CPU-only synthetic checks). AI-assisted. ### Checklist - [x] Based on current `main`. - [x] One topic. - [x] No game data, keys or decryption. - [x] No new translator rule.
madhyn commented 2026-11-24 19:29:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T19:29:50Z.


Tested fb50e0b14 on Arch Linux + Wine 11.22 + NVIDIA RTX 3060 Ti (595.58.03 / Vulkan):

  • vk_queue (Linux): Passed (0.56 s)
  • d3d12_vulkan_device (Wine): Passed (7.65 s)

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142180935 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1164#issuecomment-7142180935). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-24T19:29:50Z. --- Tested `fb50e0b14` on Arch Linux + Wine 11.22 + NVIDIA RTX 3060 Ti (595.58.03 / Vulkan): - `vk_queue` (Linux): **Passed** (0.56 s) - `d3d12_vulkan_device` (Wine): **Passed** (7.65 s) AI-assisted: yes
abnalstlll-byte commented 2026-11-24 19:32:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T19:32:52Z.

Review: APPROVED


Reviewed and verified. Fixes Vulkan queue selection in runtime/shims/d3d12_vulkan_device.cpp to verify sparse binding capability when either sparse buffers OR sparse 2D textures are supported, ensuring COPY and COMPUTE queues passed to vkQueueBindSparse carry VK_QUEUE_SPARSE_BINDING_BIT. Verified via synthetic queue tests in vk_queue_test.cpp. 100% clean-room.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045990595 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1164#pullrequestreview-6045990595). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T19:32:52Z. **Review:** APPROVED --- Reviewed and verified. Fixes Vulkan queue selection in `runtime/shims/d3d12_vulkan_device.cpp` to verify sparse binding capability when either sparse buffers OR sparse 2D textures are supported, ensuring COPY and COMPUTE queues passed to `vkQueueBindSparse` carry `VK_QUEUE_SPARSE_BINDING_BIT`. Verified via synthetic queue tests in `vk_queue_test.cpp`. 100% clean-room.
Deedlyy commented 2026-11-24 20:11:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:11:29Z.


Recommendation: [MERGE]

Reasoning: Queue selection now gates on the same sparse prerequisites as device init (sparse buffers or sparse images), so a sparse-texture-only device no longer gets a COPY/COMPUTE queue without SPARSE_BINDING. Small fix with a queue test. Verified on Linux/Wine + RTX 3060 Ti by madhyn. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 4/10

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143168231 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1164#issuecomment-7143168231). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:11:29Z. --- **Recommendation:** [MERGE] **Reasoning:** Queue selection now gates on the same sparse prerequisites as device init (sparse buffers or sparse images), so a sparse-texture-only device no longer gets a COPY/COMPUTE queue without `SPARSE_BINDING`. Small fix with a queue test. Verified on Linux/Wine + RTX 3060 Ti by madhyn. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 4/10
zmasi commented 2026-11-28 23:57:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:57:22Z.


#1164 | head fb50e0b14f (merged cleanly with main ba8b77b390 — no conflicts on current main) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(vk_queue|d3d12_buffer_tiles|d3d12_texture_tiles|d3d12_sparse_queue_family_contract)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red proof: restoring the buffer-only !features.sparseResidencyBuffer gate in runtime/src/queue_families.h fails vk_queue at line 150: image_only.direct == 0 && image_only.compute == 0 && image_only.copy == 0 | green on PR+main: 4/4 CTests (vk_queue — 7 layouts ok + validation errors: 0, d3d12_buffer_tiles — 12 full tiles matched vs native D3D12 Tier 4, d3d12_texture_tiles — all 4 gated remap/COPY-to-DIRECT handoff cases matched native D3D12, d3d12_sparse_queue_family_contract — 3 COPY/COMPUTE sparse queue cases + VK API CONTRACT PASS) pass in 7.04 s on RTX 3090 with 0 Khronos validation errors; check_no_game_data.py 0 violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247773795 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1164#issuecomment-7247773795). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T23:57:22Z. --- #1164 | head fb50e0b14f7c9bd0d56abcdb01841fc1226a17b6 (merged cleanly with main ba8b77b390b278cfb05510a4fc2922fb0fb9a11c — no conflicts on current `main`) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^(vk_queue|d3d12_buffer_tiles|d3d12_texture_tiles|d3d12_sparse_queue_family_contract)$" --output-on-failure` (`LEONIDA_VK_VALIDATION=1`) | red proof: restoring the buffer-only `!features.sparseResidencyBuffer` gate in `runtime/src/queue_families.h` fails `vk_queue` at `line 150: image_only.direct == 0 && image_only.compute == 0 && image_only.copy == 0` | green on PR+main: `4/4` CTests (`vk_queue` — `7 layouts ok` + `validation errors: 0`, `d3d12_buffer_tiles` — `12 full tiles matched` vs native D3D12 Tier 4, `d3d12_texture_tiles` — all `4` gated remap/COPY-to-DIRECT handoff cases matched native D3D12, `d3d12_sparse_queue_family_contract` — `3 COPY/COMPUTE sparse queue cases` + `VK API CONTRACT PASS`) pass in `7.04 s` on RTX 3090 with `0` Khronos validation errors; `check_no_game_data.py` `0` violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes
enlight3d commented 2026-11-29 08:58:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T08:58:47Z.


Validation run of this pull request.

  • PR head: fb50e0b14f. main: 54b2a81e95. Merged cleanly (git merge --no-edit --no-ff pr-1164, no conflicts); tested at the merge commit.
  • Commands:
    • cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON
    • cmake --build runtime/build --target gta6rt vk_queue_test d3d12_vulkan_device_test d3d12_sparse_queue_family_test -j 8
    • ctest -R "^(vk_queue|d3d12_vulkan_device|d3d12_sparse_queue_family|d3d12_sparse_queue_family_contract)$" --output-on-failure -j1
  • Green (merged): 4 of 4 passed, none skipped. vk_queue prints queue family picker: 7 layouts ok. The last three are the tests that exercise the touched d3d12_vulkan_device.cpp and queue_families.h.
  • Red, first kind (build): queue_families.h and d3d12_vulkan_device.cpp taken back from main, the test kept: vk_queue_test does not build (sparse_capable_queue_families takes no 4 arguments). The signature changes, so this is only a build failure.
  • Red, second kind (a mutation made for this run): new signature kept, the gate set back to the buffer-only form (!(features.sparseResidencyBuffer || features.sparseResidencyImage2D) replaced by !features.sparseResidencyBuffer). vk_queue fails: line 150: image_only.direct == 0 && image_only.compute == 0 && image_only.copy == 0, the new image-only case. This is the reason the PR gives.
  • Link: no new imports vs main (gta6rt.exe, 714 imports on both).
  • Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7253455436 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1164#issuecomment-7253455436). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T08:58:47Z. --- Validation run of this pull request. - PR head: fb50e0b14f7c9bd0d56abcdb01841fc1226a17b6. main: 54b2a81e95c470c953ddee6177fd6255cbaf041d. Merged cleanly (`git merge --no-edit --no-ff pr-1164`, no conflicts); tested at the merge commit. - Commands: - `cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON` - `cmake --build runtime/build --target gta6rt vk_queue_test d3d12_vulkan_device_test d3d12_sparse_queue_family_test -j 8` - `ctest -R "^(vk_queue|d3d12_vulkan_device|d3d12_sparse_queue_family|d3d12_sparse_queue_family_contract)$" --output-on-failure -j1` - Green (merged): 4 of 4 passed, none skipped. `vk_queue` prints `queue family picker: 7 layouts ok`. The last three are the tests that exercise the touched `d3d12_vulkan_device.cpp` and `queue_families.h`. - Red, first kind (build): `queue_families.h` and `d3d12_vulkan_device.cpp` taken back from main, the test kept: `vk_queue_test` does not build (`sparse_capable_queue_families` takes no 4 arguments). The signature changes, so this is only a build failure. - Red, second kind (a mutation made for this run): new signature kept, the gate set back to the buffer-only form (`!(features.sparseResidencyBuffer || features.sparseResidencyImage2D)` replaced by `!features.sparseResidencyBuffer`). `vk_queue` fails: `line 150: image_only.direct == 0 && image_only.compute == 0 && image_only.copy == 0`, the new image-only case. This is the reason the PR gives. - Link: no new imports vs main (gta6rt.exe, 714 imports on both). - Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44.
enlight3d commented 2026-11-29 18:22:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T18:22:34Z.


RUN #1164 | head fb50e0b14f, merged cleanly with main 4364a4fa61 (local merge, not pushed)

Commands (repository root, temporary worktree):

git fetch origin pull/1164/head:pr-1164
git checkout --detach origin/main && git merge --no-edit --no-ff pr-1164
cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON
cmake --build runtime/build -j 6 --target gta6rt vk_queue_test d3d12_vulkan_device_test d3d12_sparse_queue_family_test
ctest -C RelWithDebInfo -R "^(vk_queue|d3d12_vulkan_device|d3d12_sparse_queue_family|d3d12_sparse_queue_family_contract)$" --output-on-failure -j1

Green (merged): 4 of 4 passed, none skipped (vk_queue, d3d12_vulkan_device, d3d12_sparse_queue_family, d3d12_sparse_queue_family_contract).

Red, build kind: queue_families.h and d3d12_vulkan_device.cpp taken back from main, the test kept: vk_queue_test does not build (sparse_capable_queue_families does not take 4 arguments). The signature changes, so this alone is only a build failure.
Red, behavioural kind (a mutation made for this run): new signature kept, the gate !(features.sparseResidencyBuffer || features.sparseResidencyImage2D) replaced by !features.sparseResidencyBuffer. vk_queue then fails at the new image-only case: line 150: image_only.direct == 0 && image_only.compute == 0 && image_only.copy == 0.

Link: no new imports vs main (gta6rt.exe, 723 DLL!symbol entries on both, dumpbin /imports).

#2566: no conflict with #2566 (merge-tree of the two heads is clean).

Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44, Vulkan SDK 1.4.363.1.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260432231 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1164#issuecomment-7260432231). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T18:22:34Z. --- RUN #1164 | head fb50e0b14f7c9bd0d56abcdb01841fc1226a17b6, merged cleanly with main 4364a4fa61f6bc42eefc94452c3a565fc530dd34 (local merge, not pushed) Commands (repository root, temporary worktree): ``` git fetch origin pull/1164/head:pr-1164 git checkout --detach origin/main && git merge --no-edit --no-ff pr-1164 cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON cmake --build runtime/build -j 6 --target gta6rt vk_queue_test d3d12_vulkan_device_test d3d12_sparse_queue_family_test ctest -C RelWithDebInfo -R "^(vk_queue|d3d12_vulkan_device|d3d12_sparse_queue_family|d3d12_sparse_queue_family_contract)$" --output-on-failure -j1 ``` Green (merged): 4 of 4 passed, none skipped (`vk_queue`, `d3d12_vulkan_device`, `d3d12_sparse_queue_family`, `d3d12_sparse_queue_family_contract`). Red, build kind: `queue_families.h` and `d3d12_vulkan_device.cpp` taken back from main, the test kept: `vk_queue_test` does not build (`sparse_capable_queue_families` does not take 4 arguments). The signature changes, so this alone is only a build failure. Red, behavioural kind (a mutation made for this run): new signature kept, the gate `!(features.sparseResidencyBuffer || features.sparseResidencyImage2D)` replaced by `!features.sparseResidencyBuffer`. `vk_queue` then fails at the new image-only case: `line 150: image_only.direct == 0 && image_only.compute == 0 && image_only.copy == 0`. Link: no new imports vs main (gta6rt.exe, 723 DLL!symbol entries on both, dumpbin /imports). #2566: no conflict with #2566 (merge-tree of the two heads is clean). Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44, Vulkan SDK 1.4.363.1.
MoonEyes commented 2026-11-29 19:00:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T19:00:16Z.


Merging. Head fb50e0b14 has red/green verdicts from reviewers other than the author (above), merges cleanly with main f7a4e75bf, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-tests mesh, semantic-tests f16) are pre-existing. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260928566 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1164#issuecomment-7260928566). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T19:00:16Z. --- Merging. Head `fb50e0b14` has red/green verdicts from reviewers other than the author (above), merges cleanly with `main` `f7a4e75bf`, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (`translator-tests` mesh, `semantic-tests` f16) are pre-existing. Merged by MoonEyes. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1164
No description provided.