Skip to content

D3D12.X: a placed view's padding does not make a second texture - #2764

Closed
GreemSC wants to merge 1 commit into
xcl-dev:amd-devfrom
GreemSC:amd-dev-placed-key-padding
Closed

GreemSC wants to merge 1 commit into
xcl-dev:amd-devfrom
GreemSC:amd-dev-placed-key-padding

Conversation

@GreemSC

@GreemSC GreemSC commented Nov 26, 2026 •

Copy link
Copy Markdown

format_alias::prepare_placed_srv_desc and prepare_placed_uav_desc key placed_srvs / placed_uavs by (address, the 0x38-byte console resource description) and clear only 0x34.. of it. Bytes 0x04..0x08 are the padding between Dimension and Alignment; the retail title leaves stack bytes there, so the same view at the same address made a second PC texture, with its own views, whenever that padding differed. Both now clear it too.

This is the amd-dev side of #2743; main's resource_at has the same key and is fixed by #2762 (joeypercia). Spotting the padding came from the VIctory project's notes (GPL-3.0, read only; no code taken).

What is in it

  • crates/xcl/src/hle/d3d12x/format_alias.rs: clear 0x04..0x08 in both prepares; test placed_descs_ignore_the_padding_after_dimension (fails without the change: the key keeps the padding bytes).

Tested

without with this change
placed_srvs entries at 150 s 59,112 41,194
at 190 s 60,925 41,965 (−31 %)
tracked textures at 190 s 64,473 45,531
title's anonymous memory at 190 s 11.85 GB 11.83 GB
crashes / device removals 0 / 0 0 / 0

Fewer objects; no memory difference measurable in a 200 s run (each entry is a few KB of host memory here).

Regression run

  • By @Anon64 on Windows (comment): RTX 3060 12 GB (NVIDIA 581.80), i9-14900KF, Windows 11 26200, scripts/smoke.ps1, 60 s, XCL_NETWORK=0, A every 4 s from 20 s. No device removal or crash on either side; 99 % of the base's frames. The base is 08db802 (on main and in amd-dev's history), not amd-dev's head. (Under Wine, amd-dev without the Wine stack stops at ~2.5 s, so a pair from my machine would cover nothing.)
xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1465 (PresentX 1465)
presents per 2 s (last 3): 27 5 0
device removals: 0
crashes: 0
peak commit: 21087 MB
xcl-smoke v1
commit: 24695174b1c1426a4be2c29502b29d2ed8ba6d30
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1452 (PresentX 1452)
presents per 2 s (last 3): 60 60 56
device removals: 0
crashes: 0
peak commit: 17421 MB

Not tested

  • AMD on Windows, a smoke pair on amd-dev's head, more than one run a side, the open world.

AI use

  • Claude Code (Claude Opus 5.5): wrote the change, the test and this description, ran the tests and the runs.

`prepare_placed_srv_desc` and `prepare_placed_uav_desc` key `placed_srvs` /
`placed_uavs` by (address, 0x38-byte console resource description) and
clear only 0x34.. of it. Bytes 0x04..0x08 are the padding between
`Dimension` and `Alignment`; the retail title leaves stack bytes there, so
the same view at the same address made a second PC texture (and its views)
whenever that padding differed. Both now clear it too.

Measured on the retail title (RX 7900 XT, RADV, Wine, amd-dev b5c0275 with
the Wine stack), one 200 s run each: `placed_srvs` held 60,925 entries at
190 s without the change and 41,965 with it (-31 %); the same share as
main's `resource_at` (xcl-dev#2743, fixed there by xcl-dev#2762).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Anon64

Anon64 commented Nov 26, 2026

Copy link
Copy Markdown

Regression run of 2469517 on a newer retail title: no device removal, no crash, frames and commit within the limits.

Setup: RTX 3060 12 GB (NVIDIA 581.80), i9-14900KF, Windows 11 26200, release builds of this PR's base 08db802 and of its exact head, scripts/smoke.ps1 -Game <title> for 60 s with XCL_NETWORK=0 and A pressed every 4 s from 20 s.

base:

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1465 (PresentX 1465)
presents per 2 s (last 3): 27 5 0
device removals: 0
crashes: 0
peak commit: 21087 MB

this PR:

xcl-smoke v1
commit: 24695174b1c1426a4be2c29502b29d2ed8ba6d30
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1452 (PresentX 1452)
presents per 2 s (last 3): 60 60 56
device removals: 0
crashes: 0
peak commit: 17421 MB

99 % of the base's frames, 83 % of its peak commit. One run each; the last-6-s rates and the commit vary between runs on this title, so they say nothing about this change by themselves.

Not tested: the suite on this head; whether the title creates placed views with padding in its first 60 s; AMD.

AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.

@GreemSC
GreemSC marked this pull request as ready for review November 26, 2026 12:08
@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent amd-win test report for head 24695174 (base amd-dev = merge-base b5c0275f), on real hardware.

Hardware / env: AMD Radeon RX 7800 XT, driver 32.0.31035.1003; Ryzen 7 5700X3D; Windows 11 Pro 10.0.26200; rustc 1.100.0; debug build. CARGO_TARGET_DIR=D:\xcl-2764-amdwin-target, -j 4 on every cargo command. Synthetic tests only.

Targeted (head)

  • cargo test -p xcl --lib -j 4 placed_: 5 passed, 0 failed, 0 ignored
  • ... placed_descs_ignore_the_padding: 1 passed (format_alias::tests::placed_descs_ignore_the_padding_after_dimension)
  • ... placed_title_textures_share_vram_and_preserve_pixels: 1 passed, ran on the GPU (no SKIPPED)
  • Fix reverted (only the two x[0x04..0x08].fill(0) lines removed): the new test fails (left keeps 216,126,63,1 in bytes 4..8, right has zeros). So the test does catch the bug. Working tree restored afterwards.

Full cargo test -p xcl --lib -j 4, head: the run aborted, no final test result line. The test process died with 0xc0000005 STATUS_ACCESS_VIOLATION after 1016 of 1572 results: 982 ok, 8 FAILED, 23 ignored, 4 SKIPPED (the f16 tests). The same command on base (b5c0275f) also aborts, with 0xc0000409 STATUS_STACK_BUFFER_OVERRUN, after 1563 results: 1515 ok, 12 FAILED, 27 ignored, 4 SKIPPED. The crash is on base too, so it is not from this PR. The two runs cut off at different points, so their counts are not comparable.

Failures on head, each rerun alone with -- --exact, then on base

test head alone base alone
gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole FAIL FAIL
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier FAIL FAIL
gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu FAIL FAIL
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (#2115) FAIL FAIL
hle::d3d12x::list_x::tests::bitset_runs_emit_exact_contiguous_page_ranges FAIL FAIL
hle::d3d12x::list_x::tests::a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget FAIL FAIL
hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap pass (failed in the full base run too)
hle::d3d12x::present::frame_dump_tests::compositor_releases_root_sig_and_rejects_invalid_planes pass (failed in the full base run too)

All six alone-failures also fail alone on base, so none come from this PR. The last two fail only inside the full run, on head and on base. That is cross-test interference on this adapter (or fallout from the crash), not a result of the PR.

Review: one file, +20 lines. The padding at 0x04..0x08 of the 0x38-byte resource desc (between Dimension and Alignment) is zeroed in both prepare_placed_srv_desc and prepare_placed_uav_desc, and the callers (placed_uav_resource / placed_srv_resource) build their cache key as (va, prepared), so the fix sits where the key is made. The offsets are right: Dimension u32 @0, Alignment u64 @8, Flags @0x30. I found no defects. Coverage gap: the unit test only checks the prepared descriptor bytes. No test drives placed_srv_resource / placed_uav_resource twice with different padding and checks that only one texture is made. The GPU test above has no garbage in the padding. I did not run a retail title (synthetic tests only), so there is no xcl-smoke regression run. The PR touches crates/xcl/src, so that block is still needed for the merge.

Not tested: NVIDIA, wave32-only GPUs, any retail title, a full-suite run that completes (the lib run aborts on this adapter, on base too).

AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5).

@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
@SlopTart

Copy link
Copy Markdown

Linux (Wine) dual-lane run at head 24695174 - PR itself is clean, but current amd-dev HEAD carries a lane-fatal failure this PR does not cause.

  • Rig: Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT (Mesa 26.2.5 RADV), Arch, wine-11.0 Proton build + vkd3d-proton
  • Boxb: i5-10600K, 16 GB DDR4, GTX 1070 (550.163.01), Debian 13, stock wine-10.0 + vkd3d-proton, xvfb

Suite: cargo test --release --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 --skip gpu::.

The PR's own change: format_alias::tests::placed_descs_ignore_the_padding_after_dimension ran green on both lanes at this head.

The branch-level finding (not caused by this PR): full-suite runs die before completion on BOTH lanes, at BOTH this PR head and bare amd-dev (c32c91a3). The killer is always the same test:

hle::d3d12x::list_x::tests::a_dispatch_with_a_pipeline_still_building_waits_at_the_submit

Solo repro on each machine (--exact), identical panic on both:

thread '...a_dispatch_with_a_pipeline_still_building_waits_at_the_submit' panicked at crates/xcl/src/hle/d3d12x/list_x.rs:8277:17:
dispatch 17 waited for the build (9.9574465s)   # rig
dispatch 17 waited for the build (9.9269916s)   # boxb

What we see leading up to it: the stand-in pipeline for shader 0x7e57d001 never completes its background build on either Wine lane. The dispatch-to-submit wait escalates in doubling retries (log shows #1, #2, #4, #8, #16), then the test's own budget assertion fires at ~10s. In full-suite context the process then dies hard instead of finishing the run: exit 5 on the rig, and on boxb an unhandled execute page fault with WineDbg attach (base run aborted with the PoisonError-style exit 9). Deterministic so far: 2/2 suite deaths + 1/1 solo on each machine.

Cross-branch contrast: the identically-named test exists and passes on main (8b957bec, measured today: rig 606/2, boxb 605/3) and on nvidia-dev (af2cecc4 today: rig 869/6, boxb 865/10). So this looks specific to whatever amd-dev currently does differently with that stand-in build under Wine, not to this PR and not to one vendor or one Wine stack.

Not tested: whether the same death occurs on native Windows amd-dev, we cannot run that.

AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

@GreemSC

GreemSC commented Nov 26, 2026

Copy link
Copy Markdown
Author

@SlopTart thanks for the two-lane run. Same here: on amd-dev c32c91a3 the lib run under Wine stops at the same place with and without #2842's changes, so it is the branch, not either PR (I'll name list_x::tests::a_dispatch_with_a_pipeline_still_building_waits_at_the_submit on #2842 too). The change of this PR is already in amd-dev as c093211e (cherry-picked by @raylitebull), so I'm closing this one.

AI use: Claude Code (Claude Opus 5.5) wrote this reply.

@SlopTart

Copy link
Copy Markdown

Follow-up: amd-dev rewound to b5c0275f - the Wine stand-in-build deadlock survives the rewind.

Context for anyone tracking this branch: amd-dev is now force-moved back to b5c0275f, which is an ancestor of c32c91a3 - the rb_queue rework (and everything #2842 stacks on) is off the branch. We re-ran both Wine lanes on the new tip today, same rigs and suite as our earlier rows (cargo test --release --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 --skip gpu::; rig = Ryzen 9 9900X / RX 7900 XT / wine-11.0 Proton, boxb = i5-10600K / GTX 1070 / wine-10.0 + xvfb).

AMD Wine lane (rig): still dies. Suite stops at 253 tests - hle::d3d12x::list_x::tests::a_dispatch_with_a_pipeline_still_building_waits_at_the_submit FAILED and the process dies. Solo repro identical signature at all three shas we have now:

c32c91a3: dispatch 17 waited for the build (9.957s rig / 9.927s boxb)
344ce7b5 (#2842 head): 9.972s / 9.922s
b5c0275f (current tip): 9.967s rig

So this is not an artifact of the dropped rework - the never-completing stand-in build for console shader 0x7e57d001 predates b5c0275f in the amd-dev lineage.

NVIDIA Wine lane (boxb): the suite completes but the branch is deeply red. wine-10 survives the failing test, and the full run gives 770 passed / 22 failed / 4 ignored (797 run). The 22 include clusters nowhere near our usual vendor noise: 4 in list_x (the killer test, a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget, bitset_runs_emit_exact_contiguous_page_ranges, write_buffer_immediate_on_open_existing_heap_visible_to_cpu), 6 in kernelx (4 alias, 1 sections, 1 physical-home), 3 in sparse (incl. flush_parked_does_not_free_or_reuse_tiles_while_unmap_is_in_flight), and one-offs in ambient sm5 compile, bind two-pass indirect, present compositor_releases_root_sig_and_rejects_invalid_planes, giant_driver_compiles_have_their_own_lane, class_for_rebuilds_when_heap_vtable_reused, title_bytes_are_used_in_place, serialize_root_signature, plus the two standing boxb reds (gpu_promoted_uav_clear_values, xma2_source_voice). Different branch, so this is the branch state, not a delta against our nvidia-dev numbers.

Net for anyone rebasing onto this tip: the Wine lane cannot currently finish the suite on an AMD stack, and completes with 22 red on a NVIDIA one.

AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants