VK-HOST-AT-ALIASING: pass byte length to BufferVaIndex::find in host_at #488

Manually merged
github merged 1 commit from gh-pr/488/head into gh-pr/488/base 2026-11-26 09:03:49 +00:00
Owner

@⁠xroneyaa on GitHub · 2026-11-24 06:13 UTC · original
xroneyaa:fix/vulkan-host-at-aliasing → main · +270 −1 · 3 files · 1 commits · merged 2026-11-24 16:25 UTC

Claimed in the coordination issue as: VK-HOST-AT-ALIASING

What and why

In runtime/src/vulkan_backend.h, VulkanContext's replay_.buffer_at calls buffer_vas_.find(va, hit, size) so placed buffers aliasing the same virtual address resolve to a buffer that holds the entire requested range [va, va + size). Its companion replay_.host_at omitted the bytes argument (buffer_vas_.find(va, hit), defaulting bytes = 1). When a smaller placed buffer aliases a larger CPU-mapped buffer at or inside that VA, find picks the closest smaller range and host_at then fails the bytes > b->size - offset check with HostReadStatus::absent.

This passes bytes to buffer_vas_.find(va, hit, bytes) inside replay_.host_at and adds the CPU-only mock-Vulkan test runtime/test/vk_host_at_aliasing_test.cpp (registered as vk_host_at_aliasing) exercising tied-start aliasing, offset aliasing, oversized reads, and GPU-only (host == nullptr) refusals through KHR TLAS array-of-pointers staging.

Tested

  • Rebuilt vk_host_at_aliasing_test, vk_buffer_registration_oom_test, and buffer_va_index_test with MSVC 19.50 / Ninja (0 warnings under /W4)
  • ctest --test-dir runtime/build --output-on-failure -R "^(vk_host_at_aliasing|vk_buffer_registration_oom|buffer_va_index)$" -> 3/3 Passed (buffer_va_index 0.50 s, vk_buffer_registration_oom 0.02 s, vk_host_at_aliasing 0.02 s)
  • python -I scripts/check_no_game_data.py runtime/src/vulkan_backend.h runtime/test/vk_host_at_aliasing_test.cpp runtime/CMakeLists.txt -> exit 0

GPUs tested: n/a (vk_host_at_aliasing runs CPU-only with a mock Vulkan dispatch table)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed (n/a — no translator rule added).
**@⁠xroneyaa** on GitHub · 2026-11-24 06:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/488) `xroneyaa:fix/vulkan-host-at-aliasing` → `main` · +270 −1 · 3 files · 1 commits · merged 2026-11-24 16:25 UTC Claimed in the coordination issue as: VK-HOST-AT-ALIASING ### What and why In `runtime/src/vulkan_backend.h`, `VulkanContext`'s `replay_.buffer_at` calls `buffer_vas_.find(va, hit, size)` so placed buffers aliasing the same virtual address resolve to a buffer that holds the entire requested range `[va, va + size)`. Its companion `replay_.host_at` omitted the `bytes` argument (`buffer_vas_.find(va, hit)`, defaulting `bytes = 1`). When a smaller placed buffer aliases a larger CPU-mapped buffer at or inside that VA, `find` picks the closest smaller range and `host_at` then fails the `bytes > b->size - offset` check with `HostReadStatus::absent`. This passes `bytes` to `buffer_vas_.find(va, hit, bytes)` inside `replay_.host_at` and adds the CPU-only mock-Vulkan test `runtime/test/vk_host_at_aliasing_test.cpp` (registered as `vk_host_at_aliasing`) exercising tied-start aliasing, offset aliasing, oversized reads, and GPU-only (`host == nullptr`) refusals through KHR TLAS array-of-pointers staging. ### Tested - Rebuilt `vk_host_at_aliasing_test`, `vk_buffer_registration_oom_test`, and `buffer_va_index_test` with MSVC 19.50 / Ninja (0 warnings under `/W4`) - `ctest --test-dir runtime/build --output-on-failure -R "^(vk_host_at_aliasing|vk_buffer_registration_oom|buffer_va_index)$"` -> 3/3 Passed (`buffer_va_index` 0.50 s, `vk_buffer_registration_oom` 0.02 s, `vk_host_at_aliasing` 0.02 s) - `python -I scripts/check_no_game_data.py runtime/src/vulkan_backend.h runtime/test/vk_host_at_aliasing_test.cpp runtime/CMakeLists.txt` -> exit 0 GPUs tested: n/a (`vk_host_at_aliasing` runs CPU-only with a mock Vulkan dispatch table) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed (n/a — no translator rule added).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:03:47 +00:00
github manually merged commit 5a67c51a49 into gh-pr/488/base 2026-11-26 09:03:49 +00:00
Author
Owner

@⁠moffington on GitHub · 2026-11-24 06:22 UTC · original

Tested 5a67c51a on Linux. vk_host_at_aliasing, buffer_va_index, and vk_buffer_registration_oom all passed.

The same aliasing test failed on the merge base (8f481cf1) in both the tied-start and offset cases. With the fix, both cases staged the expected instance addresses. This was a CPU-only run with mocked Vulkan calls.

**@⁠moffington** on GitHub · 2026-11-24 06:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/488#issuecomment-7123865543) Tested 5a67c51a on Linux. vk_host_at_aliasing, buffer_va_index, and vk_buffer_registration_oom all passed. The same aliasing test failed on the merge base (8f481cf1) in both the tied-start and offset cases. With the fix, both cases staged the expected instance addresses. This was a CPU-only run with mocked Vulkan calls.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 16:25 UTC · original

Merging.

Why merged: host_at passes the byte length to BufferVaIndex::find, so aliasing placed buffers resolve over the full range rather than at the start address only. The CMake change only adds the new test target.

Why it's good: vk_host_at_aliasing, buffer_va_index and vk_buffer_registration_oom all pass both plain and under validation.

Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Alone on main, its tests passed both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #388, #418, #421, #434, #470, #484, #485, #486 and #488 merged onto main 1504c1af6 (a225e593e). There the repo-consistency set gives 566 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 306/308. The 2 failures are the same pre-existing ones as main (d3d12_execute_indirect_validation, d3d12_depth_resolve), with the same skip set. git merge-tree against current main 98a977b4b: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 16:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/488#issuecomment-7137650931) Merging. **Why merged:** host_at passes the byte length to BufferVaIndex::find, so aliasing placed buffers resolve over the full range rather than at the start address only. The CMake change only adds the new test target. **Why it's good:** vk_host_at_aliasing, buffer_va_index and vk_buffer_registration_oom all pass both plain and under validation. Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Alone on main, its tests passed both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #388, #418, #421, #434, #470, #484, #485, #486 and #488 merged onto main 1504c1af6 (a225e593e). There the repo-consistency set gives 566 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 306/308. The 2 failures are the same pre-existing ones as main (d3d12_execute_indirect_validation, d3d12_depth_resolve), with the same skip set. git merge-tree against current main 98a977b4b: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.