mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:50:52 +01:00
[PR #1192] [MERGED] d3d12: preserve offsets in sub-page host buffer imports (RT-HOST-IMPORT-PREFIX) #1224
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1224
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1192
Author: @GGandCo
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:fix/host-import-prefix📝 Commits (7)
3f81c40d3d12: preserve logical offsets in sub-page host imports9de93fed3d12: retain fallback for byte-unaligned host buffers56846f6tests: isolate host-prefix coherence and preserve full heap coverageca68cb7fix: stage texel-misaligned imported host texture copies002c720docs: preserve original statistics comment encoding769634dMerge main into fix/host-import-prefix45219a6d3d12 test: skip the write-back check when a refused import is a shadow📊 Changes
5 files changed (+194 additions, -20 deletions)
View changed files
📝
runtime/CMakeLists.txt(+2 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+11 -12)📝
runtime/src/vulkan_replay.h(+8 -6)📝
runtime/test/d3d12_existing_heap_test.cpp(+128 -2)📝
runtime/test/replay_copy_offset_test.cpp(+45 -0)📄 Description
Claimed in the coordination issue as: RT-HOST-IMPORT-PREFIX
Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7142584768 (posted before this PR).
Depends on: none.
Overlaps: #1190 and #1100 touch the same existing-heap fixture/backend file. This PR only changes per-resource imported-buffer prefix alignment; it does not implement existing-heap placed resources or deferred image backing. I will rebase and preserve both sets of tests if either lands first.
What and why
A buffer 16 or 32 bytes into an importable host page can be valid for the logical resource while failing the Vulkan memory-binding alignment. Binding the logical VkBuffer at that prefix currently falls back to an unrelated allocation, so the caller's writes do not share its GPU memory.
Bind a VkBuffer covering the page prefix plus logical range at memory offset zero. Carry the logical prefix in ResourceBinding::buffer_offset and in a valid returned device address. Preserve logical VA, size, initial contents and the existing ordinary-buffer fallback for byte-unaligned addresses.
Extend the existing synthetic fixture with bidirectional copies and surrounding-byte sentinels. Add d3d12_host_prefix / --host-prefix-only so this behavior can be tested independently of OpenExistingHeapFromAddress. The full existing-heap suite remains enabled and includes the new cases.
Review regression fixed
The +4-byte host-prefix RGBA16 texture-copy regression reported in review is fixed with aligned transfer scratch, preserving the host alias. The isolated test now covers 0/4/8/16/32/64 prefixes, buffer copies and two-row RGBA16 texture copies in both directions, including every padding byte. Normal and Vulkan-validation runs pass locally; the unchanged previous head fails the new CPU replay fixture. Wine/Proton revalidation is pending.
Tested
Rebased onto main
98c2f7777(current PR head002c720f2). Conflict resolution keeps main's import-failure cleanup and page-pin release, BDA word padding, low-address import guards, shadow-fallback behavior and additional heap/placed-texture tests, plus this PR's logical prefix and aligned texture-copy staging. The RelWithDebInfo target build, isolated d3d12_host_prefix test normally and with Vulkan validation, and changed-file game-data/whitespace checks pass again on the rebased head. The negative control below was measured against main6293c1c4 / main58be9cdf8 before this rebase.Local Windows / Intel UHD Graphics (101.6314):
Independent reports on 02a2717b (before adding the isolated test):
Known limitation: the monolithic existing-heap executable on the local Intel machine still intermittently loses the device in its earlier aligned copy after the existing-heap checks, on both unchanged main and candidate. The isolated test above avoids those preceding operations; it does not remove their coverage. PR #1259 separately addresses that earlier-import lifetime issue: applied privately on top of this PR before the latest rebase, the full test passes normally, with validation and in three further repeats on this Intel machine (https://github.com/ubiquitarianism/leonida/pull/1259#issuecomment-7144543590). That fix is not included here. A private queue-barrier experiment was not reproducible and is not included. No game boot, gameplay or performance claim is made by this PR.
GPUs tested: Intel UHD Graphics / Windows, 101.6314 (local); NVIDIA RTX3060Ti / Windows,621.24 and Arch Linux+Wine11.22,595.58.03 (independent reports linked above).
AI-assisted: yes.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.