[PR #488] [MERGED] VK-HOST-AT-ALIASING: pass byte length to BufferVaIndex::find in host_at #538

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

📋 Pull Request Information

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

Base: main ← Head: fix/vulkan-host-at-aliasing


📝 Commits (1)

  • 5a67c51 vulkan_backend: pass byte length to BufferVaIndex::find in host_at

📊 Changes

3 files changed (+270 additions, -1 deletions)

View changed files

📝 runtime/CMakeLists.txt (+12 -0)
📝 runtime/src/vulkan_backend.h (+1 -1)
➕ runtime/test/vk_host_at_aliasing_test.cpp (+257 -0)

📄 Description

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).

🔄 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/488 **Author:** [@xroneyaa](https://github.com/xroneyaa) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `fix/vulkan-host-at-aliasing` --- ### 📝 Commits (1) - [`5a67c51`](https://github.com/ubiquitarianism/leonida/commit/5a67c51a49c512c8b87a28dd7dae988d4ad11da9) vulkan_backend: pass byte length to BufferVaIndex::find in host_at ### 📊 Changes **3 files changed** (+270 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+12 -0) 📝 `runtime/src/vulkan_backend.h` (+1 -1) ➕ `runtime/test/vk_host_at_aliasing_test.cpp` (+257 -0) </details> ### 📄 Description 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:13 +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#538
No description provided.