Repository navigation
d3d12: preserve offsets in sub-page host buffer imports (RT-HOST-IMPORT-PREFIX) - #1192
Conversation
|
Tested
AI-assisted: yes |
|
Recommendation: [WAIT] Reasoning: Draft: binds sub-page host buffer imports from the page start and keeps the prefix in Impact level: 4/10 |
|
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
This is a synthetic memory-coherence test. I did not run the game. AI-assisted testing and report. |
64f3898 to
5ea4870
Compare
|
Thanks for the independent A/B and Wine tests. The claim predates this PR and is linked at the top of the description: #14 (comment). 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. |
5ea4870 to
1e525c5
Compare
|
A second hardware point, where
So on Pascal it is not only the 16- and 32-byte offsets: a 64-byte offset into a page is refused on 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). |
|
Reviewed 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 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. |
|
Thanks for the reproducible +4 report. Fixed in 5e6d404 (code in 3df5d0c). 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. |
5e6d404 to
7e467c6
Compare
|
Rebased onto main 42537e7; new head 7e467c6. 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. |
7e467c6 to
4bee7a3
Compare
|
Rebased again onto main bcaa13d; head 4bee7a3. 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. |
4bee7a3 to
002c720
Compare
|
Rebased onto main 98c2f77; head 002c720. 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. |
On a driver that refuses importing a section view (RADV: amdgpu userptr takes anonymous memory only), the layer answers with a shadow at the same title VA, so the `may_refuse` early return never fires. The forward readback still passes through the shadow, but a shadow is never written back, so the new reverse-copy check failed on an AMD iGPU under Wine. Check the caller's pages only when the buffer is a real import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged. Thank you, @GGandCo, and thanks to @moffington for the +4 RGBA16 regression that the texture-copy staging now covers.
AI-assisted (Claude Code, Claude Opus 5.5). |
Claimed in the coordination issue as: RT-HOST-IMPORT-PREFIX
Claim: #14 (comment) (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 98c2f77 (current PR head 002c720). 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 02a2717 (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 (comment)). 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