[PR #1728] d3d12: translate GPU-view V#s and guard untranslated title V#s (RT-UNTRANSLATED-VSHARP-GUARD) #1741

Open
opened 2026-11-26 21:18:48 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1728
Author: @TanmaySatyam
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/rt-untranslated-vsharp-guard


📝 Commits (1)

  • 4ebe446 d3d12: translate GPU-view V#s and guard untranslated title V#s (RT-UNTRANSLATED-VSHARP-GUARD)

📊 Changes

4 files changed (+253 additions, -21 deletions)

View changed files

📝 runtime/CMakeLists.txt (+3 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+71 -21)
➕ runtime/src/title_vsharp_guard.h (+43 -0)
➕ runtime/test/title_vsharp_guard_test.cpp (+136 -0)

📄 Description

Claimed in the coordination issue as: RT-UNTRANSLATED-VSHARP-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7158772853)

What and why

When resolve_title_memory or rebase_title_vsharp encounters a title-memory buffer V# in either an explicit descriptor table (scan_title_table) or the directly-indexed console resource heap (fix_console_slot), three gaps can leave an unrebased raw title virtual address in the live GPU descriptor heap, causing READ_INVALID / WRITE_INVALID (VK_ERROR_DEVICE_LOST):

  1. GPU-only title views not mapped in resolve_title_memory / rebase_title_vsharp: resolve_title_memory and rebase_title_vsharp checked aliases.title_memory(base) directly without mapping GPU-only views through leonida::title_gpu_views::to_cpu(base, span).
  2. Decoded title-memory V#s in console heap rebasing: when LEONIDA_GEOMETRY_MB is set (heap.scratch != nullptr), fix_console_slot passed make_window = false, so decoded title-memory V#s within kTitleWindowMax that geometry_va did not claim could not fall back to aliases.resolve(..., table_view).
  3. Unresolvable raw title V#s reaching the GPU: when rebase_title_vsharp returns false on a decoded title-memory V# (e.g. uncommitted page, over-cap window, or unmapped GPU-only address), copying the original words leaves a raw title VA in the GPU descriptor heap.

This adds a portable standalone helper runtime/src/title_vsharp_guard.h (leonida::title_vsharp_guard::redirect_untranslated_vsharp) with deterministic unit tests in runtime/test/title_vsharp_guard_test.cpp and hooks it into runtime/shims/d3d12_vulkan_device.cpp:

  • Maps GPU-only title views via leonida::title_gpu_views::to_cpu in resolve_title_memory and rebase_title_vsharp.
  • Allows decoded title-memory V#s within kTitleWindowMax in rebase_title_vsharp to request a title window via aliases.resolve.
  • Redirects any remaining unresolvable raw title-memory V# to a lazily allocated 64 KiB zeroed arena scratch range with num_records = 0 (w[2] = 0) so translated buffer loads return 0 and buffer stores drop OOB instead of faulting the GPU. Leaves null descriptors, image T#s, arena VAs, known GPU buffer VAs (host imports / geometry views), and non-V# data untouched.

Tested

  • ctest -R "^(title_vsharp_guard|title_va_alias|d3d12_existing_heap|d3d12_descriptor|d3d12_console_descriptor_heap)$" with LEONIDA_VK_VALIDATION=1 -> 5/5 passed (0 VUIDs)
  • title_vsharp_guard_test covers 8 deterministic cases (null, T#, arena VA, known GPU VA, non-title address, raw title V#, GPU-only view V#, unavailable scratch) with no GPU or game files
  • python -I scripts/check_no_game_data.py runtime/src/title_vsharp_guard.h runtime/test/title_vsharp_guard_test.cpp runtime/shims/d3d12_vulkan_device.cpp runtime/CMakeLists.txt -> exit 0

GPUs tested: NVIDIA GeForce RTX 5070 (Windows 11, MSVC RelWithDebInfo, Vulkan validation enabled, 0 VUIDs)

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)

🔄 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/1728 **Author:** [@TanmaySatyam](https://github.com/TanmaySatyam) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/rt-untranslated-vsharp-guard` --- ### 📝 Commits (1) - [`4ebe446`](https://github.com/ubiquitarianism/leonida/commit/4ebe446647965c71eb1e6adb405638a1335336b3) d3d12: translate GPU-view V#s and guard untranslated title V#s (RT-UNTRANSLATED-VSHARP-GUARD) ### 📊 Changes **4 files changed** (+253 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+3 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+71 -21) ➕ `runtime/src/title_vsharp_guard.h` (+43 -0) ➕ `runtime/test/title_vsharp_guard_test.cpp` (+136 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-UNTRANSLATED-VSHARP-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7158772853) ### What and why When `resolve_title_memory` or `rebase_title_vsharp` encounters a title-memory buffer V# in either an explicit descriptor table (`scan_title_table`) or the directly-indexed console resource heap (`fix_console_slot`), three gaps can leave an unrebased raw title virtual address in the live GPU descriptor heap, causing `READ_INVALID` / `WRITE_INVALID` (`VK_ERROR_DEVICE_LOST`): 1. **GPU-only title views not mapped in `resolve_title_memory` / `rebase_title_vsharp`:** `resolve_title_memory` and `rebase_title_vsharp` checked `aliases.title_memory(base)` directly without mapping GPU-only views through `leonida::title_gpu_views::to_cpu(base, span)`. 2. **Decoded title-memory V#s in console heap rebasing:** when `LEONIDA_GEOMETRY_MB` is set (`heap.scratch != nullptr`), `fix_console_slot` passed `make_window = false`, so decoded title-memory V#s within `kTitleWindowMax` that `geometry_va` did not claim could not fall back to `aliases.resolve(..., table_view)`. 3. **Unresolvable raw title V#s reaching the GPU:** when `rebase_title_vsharp` returns `false` on a decoded title-memory V# (e.g. uncommitted page, over-cap window, or unmapped GPU-only address), copying the original words leaves a raw title VA in the GPU descriptor heap. This adds a portable standalone helper `runtime/src/title_vsharp_guard.h` (`leonida::title_vsharp_guard::redirect_untranslated_vsharp`) with deterministic unit tests in `runtime/test/title_vsharp_guard_test.cpp` and hooks it into `runtime/shims/d3d12_vulkan_device.cpp`: - Maps GPU-only title views via `leonida::title_gpu_views::to_cpu` in `resolve_title_memory` and `rebase_title_vsharp`. - Allows decoded title-memory V#s within `kTitleWindowMax` in `rebase_title_vsharp` to request a title window via `aliases.resolve`. - Redirects any remaining unresolvable raw title-memory V# to a lazily allocated 64 KiB zeroed arena scratch range with `num_records = 0` (`w[2] = 0`) so translated buffer loads return 0 and buffer stores drop OOB instead of faulting the GPU. Leaves null descriptors, image T#s, arena VAs, known GPU buffer VAs (host imports / geometry views), and non-V# data untouched. ### Tested - `ctest -R "^(title_vsharp_guard|title_va_alias|d3d12_existing_heap|d3d12_descriptor|d3d12_console_descriptor_heap)$"` with `LEONIDA_VK_VALIDATION=1` -> **5/5 passed** (0 VUIDs) - `title_vsharp_guard_test` covers 8 deterministic cases (null, T#, arena VA, known GPU VA, non-title address, raw title V#, GPU-only view V#, unavailable scratch) with no GPU or game files - `python -I scripts/check_no_game_data.py runtime/src/title_vsharp_guard.h runtime/test/title_vsharp_guard_test.cpp runtime/shims/d3d12_vulkan_device.cpp runtime/CMakeLists.txt` -> exit 0 GPUs tested: NVIDIA GeForce RTX 5070 (Windows 11, MSVC RelWithDebInfo, Vulkan validation enabled, 0 VUIDs) 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1741
No description provided.