d3d12: preserve offsets in sub-page host buffer imports (RT-HOST-IMPORT-PREFIX) #1192
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1192
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1192/head"
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?
@GGandCo on GitHub · 2026-11-24 19:56 UTC · original
GGandCo:fix/host-import-prefix→main· +194 −20 · 5 files · 7 commits · merged 2026-11-25 14:49 UTCClaimed in the coordination issue as: RT-HOST-IMPORT-PREFIX
Claim: #14 (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 (#1259). 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
@madhyn on GitHub · 2026-11-24 20:08 UTC · original
Tested
02a2717b8on Arch Linux + Wine 11.22 + NVIDIA RTX 3060 Ti (595.58.03 / Vulkan):ctest --test-dir runtime/build/win -R "^d3d12_existing_heap$" --output-on-failure: Passed (5.49 s)AI-assisted: yes
@Deedlyy on GitHub · 2026-11-24 20:08 UTC · original
Recommendation: [WAIT]
Reasoning: Draft: binds sub-page host buffer imports from the page start and keeps the prefix in
buffer_offset, instead of falling back to an unrelated allocation when the offset is misaligned. The approach looks right and the existing-heap test is extended. But the PR is still marked draft, has no description template or claim, and overlaps #1190/#1100 in the same test file. Mark it ready, fill in the claim/testing sections, and coordinate merge order. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict withmain.Impact level: 4/10
@hubeton on GitHub · 2026-11-24 20:09 UTC · original
Independent A/B result on native Windows 11 build 26300.9974 with an Intel Core i9-13900K (24 cores, 32 threads), 64 GB RAM and an RTX 3060 Ti 8 GB (NVIDIA 621.24, Vulkan). Both executables were built with clang-cl/xwin in RelWithDebInfo.
I used the PR's identical
d3d12_existing_heap_test.cppin both builds. The control had the runtime from6293c1c4and the candidate had the runtime from02a2717b.This is a synthetic memory-coherence test. I did not run the game. AI-assisted testing and report.
@GGandCo on GitHub · 2026-11-24 20:32 UTC · original
Thanks for the independent A/B and Wine tests. The claim predates this PR and is linked at the top of the description: #14. I filled the repository template, rebased onto current main58be9cdf8, and added an isolated host-prefix CTest without removing the full existing-heap suite.
Our Intel A/B now reaches the behavior directly: unchanged backend fails only the 16/32-byte prefix cases; candidate passes normally and with Vulkan validation. The separate Intel failure after existing-heap operations is still disclosed. No experimental barrier change is included.
For merge order, #1190 owns existing-heap placed buffers and #1100 owns deferred attachments; this PR changes neither feature. They share files/test context, so I will rebase and retain their coverage if either merges first. CI workflow approval remains with maintainers.
@qhukz13 on GitHub · 2026-11-24 21:40 UTC · original
A second hardware point, where
mainfails without this PR: GeForce GTX 1050 Ti (Pascal, 4 GB), NVIDIA 582.66, Windows 10 Pro 19045, MSVC RelWithDebInfo.mainat6261ca916:d3d12_existing_heapfails. The case that breaks is the existing "64 bytes into a page" one (check_title_placed, test line 271): the layer logsa title-placed buffer (device slot 133) could not import its pages ... HRESULT -2147467263(E_NOTIMPL) and the check at line 196,GetGPUVirtualAddress() == pages, fails. The other slot-133 cases (VirtualAlloc range, section view, the two cache modifiers, the partly committed range) pass, and the 8OpenExistingHeapFromAddresscases match the host.5ea48706b, built the same way:d3d12_existing_heappasses.So on Pascal it is not only the 16- and 32-byte offsets: a 64-byte offset into a page is refused on
maintoo, presumably because this driver's memory-binding alignment for the imported buffer is larger than 64, which the oldoffset % requirements.alignmentcheck turned into the fallback. Binding at zero and carrying the offset fixes it here as well. That matters for the boot: slot 133 is how the title places its buffers on its own pages, and on this cardmainsilently gives such a buffer memory the title's writes never reach.The same failure is one of the five that #1217 lists as reproduced natively on a Pascal card.
No game files. AI-assisted (Claude Code).
@moffington on GitHub · 2026-11-24 22:04 UTC · original
Reviewed
1e525c53on Linux with an RTX 3060 (615.78.08), under Wine 11.20 and Proton Experimental.The isolated host-prefix fixture passes at 0, 16, 32 and 64 bytes, including bidirectional coherence and surrounding sentinels. Both the published base and merge base fail the +16/+32 VA checks as expected.
I found one regression with a +4-byte host prefix:
Both bases complete the copy through their ordinary-buffer fallback. HEAD successfully imports the buffer but returns ReplayResult::unsupported during texture-copy replay. The same test passes at +8 and +64 on HEAD, and ordinary buffer copies at +4 also pass.
The prefix added through
ResourceBinding::buffer_offsettriggers the 8-byte alignment guard invulkan_replay.h:1869.Reproduced under both runners, with and without validation. Could the existing aligned staging approach be extended to handle this case while preserving the host alias?
Native Xbox parity is unverified, but this is a reproducible regression relative to both base revisions.
@GGandCo on GitHub · 2026-11-24 22:43 UTC · original
Thanks for the reproducible +4 report. Fixed in 5e6d4048d (code in 3df5d0cb9).
The imported host alias is retained. Texture-copy replay now uses the existing aligned transfer scratch when a word-aligned host prefix violates the image's texel/block alignment, in both directions. Only occupied texels are copied; prefix, row padding and tail stay untouched. The direct path remains for already aligned copies, including byte-aligned R8; invalid logical offsets and overflowing spans remain rejected.
Tests on Windows 11 / Intel UHD Graphics 101.6314:
Could you repeat your Wine/Proton reproduction on this head? That environment has not been tested locally. No game boot or gameplay claim. AI-assisted.
@GGandCo on GitHub · 2026-11-25 05:46 UTC · original
Rebased onto main
42537e7b6; new head 7e467c6b5. The conflicts are resolved while preserving main's BDA word padding, low-address import guards, shadow fallback, additional placed-texture/shadow tests and texture-refresh test setup. This PR still adds only the host-prefix handling, isolated fixture and review regression fix.Rebuilt RelWithDebInfo on Windows / Intel UHD Graphics 101.6314. d3d12_host_prefix and replay_copy_offset pass; the isolated GPU test also passes with Vulkan validation. Coverage remains offsets 0/4/8/16/32/64, buffer and two-row RGBA16 transfers in both directions, prefix/padding/tail preservation and safe missing-scratch refusal. Changed-file data and whitespace checks pass. The full monolithic heap suite was not rerun for this rebase. AI-assisted. Wine/Proton retest of the +4 review case remains welcome.
@GGandCo on GitHub · 2026-11-25 10:56 UTC · original
Rebased again onto main
bcaa13dad; head 4bee7a33a. The new conflict was in create_host_buffer's import-refusal cleanup. Resolution retains main's decline() cleanup (including import memory and page-pin release) while keeping the prefix inside the VkBuffer and binding at zero.RelWithDebInfo build, d3d12_host_prefix and replay_copy_offset pass on Windows / Intel UHD Graphics 101.6314. The isolated buffer/texture-prefix fixture also passes with Vulkan validation. Changed-file game-data/whitespace checks pass. Full monolithic heap suite not rerun. AI-assisted.
@GGandCo on GitHub · 2026-11-25 13:07 UTC · original
Rebased onto main
98c2f7777; head002c720f2. The conflict was in imported-buffer ResourceBinding initialization: both main's indirect_arguments flag and this PR's logical buffer_offset are retained. RelWithDebInfo build, isolated d3d12_host_prefix/replay_copy_offset tests and the isolated GPU prefix fixture with Vulkan validation pass on Windows / Intel UHD Graphics 101.6314. Changed-file checks pass. Full heap suite not rerun. AI-assisted.@aslan2142 on GitHub · 2026-11-25 14:49 UTC · original
Merged. Thank you, @GGandCo, and thanks to @moffington for the +4 RGBA16 regression that the texture-copy staging now covers.
mainand one test fix, no force-push.may_refuseearly return never fired.title_shadow_buffersays the buffer is a real import.main+ this branch. Nothing goes from pass to fail. The newd3d12_host_prefixpasses on both devices, and so do the threed3d12_existing_heapvariants that failed on the iGPU before.create_host_bufferwithout the staging, so it will be closed as a duplicate.main446574e76+45219a640: it merges cleanly; the semantic suite passes (489 files, 6,288 tests, 0 files failed); the 14 docs and writer tests pass;check_no_game_data.pyis clean on the 5 changed files.AI-assisted (Claude Code, Claude Opus 5.5).