[PR #927] [MERGED] vk: probe whole title-region host imports (RT-TITLE-HOST-REGION) #967

Closed
opened 2026-11-26 20:19:39 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/927
Author: @roanh47
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: pr/host-region-probe


📝 Commits (2)

  • e82ca07 vk: probe whole title-region host imports
  • ed1de62 vk: make the host-region probe skip where it cannot import

📊 Changes

2 files changed (+371 additions, -0 deletions)

View changed files

📝 runtime/CMakeLists.txt (+16 -0)
➕ runtime/test/vk_host_region_import_test.cpp (+355 -0)

📄 Description

Claimed in coordination issue #14 as RT-TITLE-HOST-REGION (probe portion).

What and why

The retail frame is black because the title writes vertices, descriptors and constants into memory that the Vulkan GPU-address arena does not read. The planned fix imports one committed title host region as the arena and rebases title addresses by subtraction.

This PR adds the capability gate for that path: one contiguous committed host allocation is imported as a buffer-device-addressable Vulkan buffer with VK_EXT_external_memory_host, then checked in both directions:

  • CPU writes are read by the GPU through a buffer copy;
  • GPU fills are visible to the CPU.

The default CTest case imports 185 MiB, the measured title placeholder size. A successful import must pass both coherence checks; a machine that cannot import reports a skip, not a pass and not a failure.

Exit codes

Code Meaning
0 The region imported and both directions matched.
77 (SKIP_RETURN_CODE) This machine cannot import: the driver reports the usage or the handle type as not importable, refuses the host pointer or the import (VK_ERROR_OUT_OF_DEVICE_MEMORY, VK_ERROR_OUT_OF_HOST_MEMORY, VK_ERROR_INVALID_EXTERNAL_HANDLE), has no commit room for the region, or there is no Vulkan 1.3 device with VK_EXT_external_memory_host and buffer device addresses. Each skip prints one SKIP vk_host_region_import: ... line that says which.
1 The probe contradicts itself: a coherence mismatch, VK_ERROR_DEVICE_LOST, any other failing VkResult, a broken driver answer, or a validation error.

Capability is checked before anything is allocated, with the Vulkan 1.1 vkGetPhysicalDeviceExternalBufferProperties query for the exact usage set and VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT. VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT is honoured with VkMemoryDedicatedAllocateInfo, so a device that requires a dedicated allocation is probed instead of skipped.

The copy whose destination the CPU compares ends with a TRANSFER → HOST memory barrier, as the fill path already did.

Tested

Windows 11, MSVC 19.44.35230 (14.44), NVIDIA GeForce RTX 3070, driver 610.88, Vulkan SDK 1.4.363.0.

ctest -R "^vk_host_region_import" --output-on-failure
1/2 Test #147: vk_host_region_import ..............   Passed    0.21 sec
2/2 Test #148: vk_host_region_import_validation ...   Passed    0.24 sec
100% tests passed out of 2

The validation variant runs the same binary with LEONIDA_VK_VALIDATION=1 and VK_VALIDATE_SYNC=1; it exits 77 (not 1) where VK_LAYER_KHRONOS_validation is not installed, so a machine without the SDK skips it instead of failing it.

Manual run of the 185 MiB default case, exit 0, zero validation errors:

device: NVIDIA GeForce RTX 3070
subgroup sizes: 32..32 (default 32), requirable in stages 0x3fff, subgroupSizeControl on, computeFullSubgroups on
host-region import: size=185 MiB result=imported alignment=64 requirements=193986560 memoryTypeBits=0x18 type=3 dedicated=no bda=0x6ff0000 handleTypes=0x80 import-features=0x6 cpu-gpu-coherence=ok

The same with LEONIDA_VK_VALIDATION=1 VK_VALIDATE_SYNC=1 prints device: NVIDIA GeForce RTX 3070 (validation on), the same import line, and exits 0 with no validation errors. vk_sync_validation reports its expected hazard on this machine, so the layer and synchronization validation were active.

Other sizes, same binary:

4096 MiB    imported, cpu-gpu-coherence=ok                       exit 0
65536 MiB   SKIP ... result=import-refused vkResult=-2           exit 77
65536 MiB   SKIP ... result=host-allocation-refused win32=1455   exit 77
0 MiB       host-region import: invalid region size              exit 1

python -I scripts/check_no_game_data.py runtime/test/vk_host_region_import_test.cpp runtime/CMakeLists.txt is clean.

Not covered

  • The result=not-importable branch is not exercised here: every device available to me reports the usage set importable. It is a three-field query (compatibleHandleTypes, externalMemoryFeatures) against the value the driver returns, and the skip it prints is identical in form to the one exercised by the allocation refusals above.
  • The VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT path is not exercised either: the RTX 3070 reports import-features=0x6 (importable, protected), so no dedicated allocation was requested.
  • Synchronization validation tracks device accesses only, so the missing host barrier of the previous revision could not have been reported by it; the barrier is added because the Vulkan memory model requires it for the CPU read that follows.
  • Only the 185 MiB region runs in CTest; larger sizes are a manual check.

No game data is included. The test needs only a Vulkan GPU with VK_EXT_external_memory_host and buffer device addresses.

AI-assisted (DeepSeek v4.1 Flash 1017).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/927 **Author:** [@roanh47](https://github.com/roanh47) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `pr/host-region-probe` --- ### 📝 Commits (2) - [`e82ca07`](https://github.com/ubiquitarianism/leonida/commit/e82ca07b790dac7dc083cabaabd74f3da78d619c) vk: probe whole title-region host imports - [`ed1de62`](https://github.com/ubiquitarianism/leonida/commit/ed1de62abbb56aeff5a292b7b353b7c5068915e1) vk: make the host-region probe skip where it cannot import ### 📊 Changes **2 files changed** (+371 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+16 -0) ➕ `runtime/test/vk_host_region_import_test.cpp` (+355 -0) </details> ### 📄 Description Claimed in coordination issue #14 as `RT-TITLE-HOST-REGION` (probe portion). ### What and why The retail frame is black because the title writes vertices, descriptors and constants into memory that the Vulkan GPU-address arena does not read. The planned fix imports one committed title host region as the arena and rebases title addresses by subtraction. This PR adds the capability gate for that path: one contiguous committed host allocation is imported as a buffer-device-addressable Vulkan buffer with `VK_EXT_external_memory_host`, then checked in both directions: - CPU writes are read by the GPU through a buffer copy; - GPU fills are visible to the CPU. The default CTest case imports 185 MiB, the measured title placeholder size. A successful import must pass both coherence checks; a machine that cannot import reports a skip, not a pass and not a failure. ### Exit codes | Code | Meaning | |---|---| | `0` | The region imported and both directions matched. | | `77` (`SKIP_RETURN_CODE`) | This machine cannot import: the driver reports the usage or the handle type as not importable, refuses the host pointer or the import (`VK_ERROR_OUT_OF_DEVICE_MEMORY`, `VK_ERROR_OUT_OF_HOST_MEMORY`, `VK_ERROR_INVALID_EXTERNAL_HANDLE`), has no commit room for the region, or there is no Vulkan 1.3 device with `VK_EXT_external_memory_host` and buffer device addresses. Each skip prints one `SKIP vk_host_region_import: ...` line that says which. | | `1` | The probe contradicts itself: a coherence mismatch, `VK_ERROR_DEVICE_LOST`, any other failing `VkResult`, a broken driver answer, or a validation error. | Capability is checked before anything is allocated, with the Vulkan 1.1 `vkGetPhysicalDeviceExternalBufferProperties` query for the exact usage set and `VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT`. `VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT` is honoured with `VkMemoryDedicatedAllocateInfo`, so a device that requires a dedicated allocation is probed instead of skipped. The copy whose destination the CPU compares ends with a `TRANSFER` → `HOST` memory barrier, as the fill path already did. ### Tested Windows 11, MSVC 19.44.35230 (14.44), NVIDIA GeForce RTX 3070, driver 610.88, Vulkan SDK 1.4.363.0. ```text ctest -R "^vk_host_region_import" --output-on-failure 1/2 Test #147: vk_host_region_import .............. Passed 0.21 sec 2/2 Test #148: vk_host_region_import_validation ... Passed 0.24 sec 100% tests passed out of 2 ``` The validation variant runs the same binary with `LEONIDA_VK_VALIDATION=1` and `VK_VALIDATE_SYNC=1`; it exits 77 (not 1) where `VK_LAYER_KHRONOS_validation` is not installed, so a machine without the SDK skips it instead of failing it. Manual run of the 185 MiB default case, exit `0`, zero validation errors: ```text device: NVIDIA GeForce RTX 3070 subgroup sizes: 32..32 (default 32), requirable in stages 0x3fff, subgroupSizeControl on, computeFullSubgroups on host-region import: size=185 MiB result=imported alignment=64 requirements=193986560 memoryTypeBits=0x18 type=3 dedicated=no bda=0x6ff0000 handleTypes=0x80 import-features=0x6 cpu-gpu-coherence=ok ``` The same with `LEONIDA_VK_VALIDATION=1 VK_VALIDATE_SYNC=1` prints `device: NVIDIA GeForce RTX 3070 (validation on)`, the same import line, and exits `0` with no validation errors. `vk_sync_validation` reports its expected hazard on this machine, so the layer and synchronization validation were active. Other sizes, same binary: ```text 4096 MiB imported, cpu-gpu-coherence=ok exit 0 65536 MiB SKIP ... result=import-refused vkResult=-2 exit 77 65536 MiB SKIP ... result=host-allocation-refused win32=1455 exit 77 0 MiB host-region import: invalid region size exit 1 ``` `python -I scripts/check_no_game_data.py runtime/test/vk_host_region_import_test.cpp runtime/CMakeLists.txt` is clean. ### Not covered - The `result=not-importable` branch is not exercised here: every device available to me reports the usage set importable. It is a three-field query (`compatibleHandleTypes`, `externalMemoryFeatures`) against the value the driver returns, and the skip it prints is identical in form to the one exercised by the allocation refusals above. - The `VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT` path is not exercised either: the RTX 3070 reports `import-features=0x6` (importable, protected), so no dedicated allocation was requested. - Synchronization validation tracks device accesses only, so the missing host barrier of the previous revision could not have been reported by it; the barrier is added because the Vulkan memory model requires it for the CPU read that follows. - Only the 185 MiB region runs in CTest; larger sizes are a manual check. No game data is included. The test needs only a Vulkan GPU with `VK_EXT_external_memory_host` and buffer device addresses. AI-assisted (DeepSeek v4.1 Flash 1017). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:39 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#967
No description provided.