D3D12.X: null ID3D12Heap::GetDesc returns the full 48-byte heap desc #2792

Open
oni-swr wants to merge 1 commit from upstream-pr/2802 into main
oni-swr commented 2026-11-26 13:51:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-26T13:51:02Z.


The null backend's ID3D12Heap::GetDesc zeroed only bytes 0-39 of the 48-byte D3D12_HEAP_DESC, so Flags (offset 40) kept whatever the caller's buffer held. The null heap now keeps the desc it was created with and GetDesc writes all 48 bytes.

Fixes #2783

What is in it

  • crates/xcl/src/hle/d3d12x/null.rs: CreateHeap / CreateHeap1 keep the desc (new_heap), Heap_GetDesc48 writes all 48 bytes in both calling orders, and the now unused Hidden_ZeroDesc40 is removed. The other null GetDesc slots (command queue 16 bytes, descriptor heap 16 bytes, resource 56 bytes) already match their structs. Test heap_get_desc_fills_all_48_bytes: sentinel-filled buffers, both orders, and a heap created without a desc reads back zeroed.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 Pro 10.0.26200, Rust 1.100.0, debug build (tests), release build (smoke)
  • cargo test -p xcl --lib -j 4 d3d12x::null: 7 passed, 0 failed, 0 ignored, 1330 filtered out
  • Whole suite on the exact head 00b0d9c4 (clean detached checkout, RX 7800 XT driver 32.0.31035.1003, no XCL_ADAPTER set, debug): cargo build --workspace -j 4, then cargo test --workspace -j 4 --no-fail-fast -- --test-threads=4: 1435 passed, 1 failed, 47 ignored over 37 test binaries (lib: 1309 passed, 1 failed, 27 ignored). 7 SKIPPED messages: six f16_programs_on_the_gpu / f32_programs_on_the_gpu cases the lowering refuses (V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32) and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows). heap_get_desc_fills_all_48_bytes passed.
  • The one failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 ("seed 722: res[30] = 0x1, CPU 0x7fffffff", #2115). It fails the same way, same seed, on main at e120925e, so it is not caused by this PR.
  • cargo clippy: nothing new on the changed lines

Regression run
Same title, 60 s each, same machine, one after the other (RX 7800 XT). Blocks pasted unedited from scripts/smoke.ps1.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1388 (PresentX 1388)
presents per 2 s (last 3): 60 58 60
device removals: 0
crashes: 0
peak commit: 15518 MB

PR:

xcl-smoke v1
commit: 00b0d9c4d58d9412f52367c55f6c3db48e974394
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1362 (PresentX 1362)
presents per 2 s (last 3): 59 56 59
device removals: 0
crashes: 0
peak commit: 15622 MB

Not tested

  • Other adapters (AMD RDNA4, NVIDIA, Intel): only the RX 7800 XT was used
  • The new test was not run against the old code, so I have not seen it fail there.
  • Whether the smoke title reaches the null backend: the run is a regression check only.

AI use

  • AI-assisted: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). It wrote the code, the tests and this description, and ran the commands and smoke runs above.
  • The whole-suite run on the exact head and the check of the seed-722 failure against main were made with Claude Code (Claude Sonnet 5.5), which also added them to this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5511248107 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2802). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T13:51:02Z. --- The null backend's `ID3D12Heap::GetDesc` zeroed only bytes 0-39 of the 48-byte `D3D12_HEAP_DESC`, so `Flags` (offset 40) kept whatever the caller's buffer held. The null heap now keeps the desc it was created with and `GetDesc` writes all 48 bytes. Fixes #2783 **What is in it** - `crates/xcl/src/hle/d3d12x/null.rs`: `CreateHeap` / `CreateHeap1` keep the desc (`new_heap`), `Heap_GetDesc48` writes all 48 bytes in both calling orders, and the now unused `Hidden_ZeroDesc40` is removed. The other null `GetDesc` slots (command queue 16 bytes, descriptor heap 16 bytes, resource 56 bytes) already match their structs. Test `heap_get_desc_fills_all_48_bytes`: sentinel-filled buffers, both orders, and a heap created without a desc reads back zeroed. **Tested** - AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 Pro 10.0.26200, Rust 1.100.0, debug build (tests), release build (smoke) - `cargo test -p xcl --lib -j 4 d3d12x::null`: 7 passed, 0 failed, 0 ignored, 1330 filtered out - Whole suite on the exact head `00b0d9c4` (clean detached checkout, RX 7800 XT driver 32.0.31035.1003, no `XCL_ADAPTER` set, debug): `cargo build --workspace -j 4`, then `cargo test --workspace -j 4 --no-fail-fast -- --test-threads=4`: 1435 passed, 1 failed, 47 ignored over 37 test binaries (lib: 1309 passed, 1 failed, 27 ignored). 7 SKIPPED messages: six `f16_programs_on_the_gpu` / `f32_programs_on_the_gpu` cases the lowering refuses (V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32) and `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). `heap_get_desc_fills_all_48_bytes` passed. - The one failure is `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` ("seed 722: res[30] = 0x1, CPU 0x7fffffff", #2115). It fails the same way, same seed, on `main` at `e120925e`, so it is not caused by this PR. - `cargo clippy`: nothing new on the changed lines **Regression run** Same title, 60 s each, same machine, one after the other (RX 7800 XT). Blocks pasted unedited from `scripts/smoke.ps1`. main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: AMD Radeon RX 7800 XT title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1388 (PresentX 1388) presents per 2 s (last 3): 60 58 60 device removals: 0 crashes: 0 peak commit: 15518 MB ``` PR: ``` xcl-smoke v1 commit: 00b0d9c4d58d9412f52367c55f6c3db48e974394 gpu: AMD Radeon RX 7800 XT title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1362 (PresentX 1362) presents per 2 s (last 3): 59 56 59 device removals: 0 crashes: 0 peak commit: 15622 MB ``` **Not tested** - Other adapters (AMD RDNA4, NVIDIA, Intel): only the RX 7800 XT was used - The new test was not run against the old code, so I have not seen it fail there. - Whether the smoke title reaches the null backend: the run is a regression check only. **AI use** - AI-assisted: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). It wrote the code, the tests and this description, and ran the commands and smoke runs above. - The whole-suite run on the exact head and the check of the seed-722 failure against `main` were made with Claude Code (Claude Sonnet 5.5), which also added them to this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ettehn commented 2026-11-26 15:03:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-26T14:10:44Z.


Independent Windows A/B of the null device’s CreateHeap1 (slot 54) followed by GetDesc (slot 8), using the same test on b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 and 00b0d9c4d58d9412f52367c55f6c3db48e974394. The output descriptor was prefilled with 0xA5 and had distinct guard bytes on both sides.

  • Main left Flags at 0xA5A5A5A5 with either argument order and failed the descriptor round-trip assertion.
  • The PR returned the original 48 bytes including Flags = 0x80, returned the caller’s output pointer in both argument orders, and preserved both adjacent guards.

Windows 11 build 26200, Ryzen 9 8945HX, Rust 1.97.1 MSVC debug. cargo test --locked --offline -p xcl --lib -j 2 -- hle::d3d12x::null::tests:: --test-threads=1 --nocapture on the PR plus the probe yielded 8 passed, 0 failed, 0 ignored, no reported skips. The main control ran just the probe and reproduced the expected failure. This check covers the null ABI path. No retail title or full workspace suite was run.

OpenAI Codex assisted with the test and verification. The exact model identifier was unavailable in this session.

<!-- greyfinch-sync:ivall/xcl:comment:7194386735 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2802#issuecomment-7194386735). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-26T14:10:44Z. --- Independent Windows A/B of the null device’s `CreateHeap1` (slot 54) followed by `GetDesc` (slot 8), using the same test on `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7` and `00b0d9c4d58d9412f52367c55f6c3db48e974394`. The output descriptor was prefilled with `0xA5` and had distinct guard bytes on both sides. - Main left `Flags` at `0xA5A5A5A5` with either argument order and failed the descriptor round-trip assertion. - The PR returned the original 48 bytes including `Flags = 0x80`, returned the caller’s output pointer in both argument orders, and preserved both adjacent guards. Windows 11 build 26200, Ryzen 9 8945HX, Rust 1.97.1 MSVC debug. `cargo test --locked --offline -p xcl --lib -j 2 -- hle::d3d12x::null::tests:: --test-threads=1 --nocapture` on the PR plus the probe yielded 8 passed, 0 failed, 0 ignored, no reported skips. The main control ran just the probe and reproduced the expected failure. This check covers the null ABI path. No retail title or full workspace suite was run. OpenAI Codex assisted with the test and verification. The exact model identifier was unavailable in this session.
SlopTart commented 2026-11-26 17:51:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-26T17:51:08Z.


Linux (Wine) dual-lane run at head 00b0d9c4

  • 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::.

Fresh main baseline measured today at 8b957bec for reference: rig 606/2 (reds: gpu_promoted_uav_clear_values_pass_create_committed_resource, xma2_source_voice_decodes_and_manages_lifetime), boxb 605/3 (those two plus write_buffer_immediate_on_open_existing_heap_visible_to_cpu). Note main's older third red on the AMD lane (sparse::a_tile_decommitted_and_committed_again_keeps_its_video_memory) is gone at current main — fixed upstream, we can confirm.

Results at 00b0d9c4: rig 597/3, boxb 597/3. The new null::tests::heap_get_desc_fills_all_48_bytes is green on both lanes. On the rig the third red is that stale sparse:: one — the head branches from an older main that still carried it; on boxb the red set is identical to current-main baseline (that test is green on Pascal there). No red anywhere is introduced by this PR.

Conclusion from two vendors: the null-device ID3D12Heap::GetDesc full-48-byte fill behaves as the test expects under both Wine stacks. A rebase onto current main would make the rig's third red disappear on contact.

Not tested: the real-device ID3D12Heap::GetDesc path (that is the standing real:: suite's job).

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

<!-- greyfinch-sync:ivall/xcl:comment:7199764749 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2802#issuecomment-7199764749). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-26T17:51:08Z. --- **Linux (Wine) dual-lane run at head `00b0d9c4`** - **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::`. **Fresh `main` baseline measured today at `8b957bec`** for reference: rig 606/2 (reds: `gpu_promoted_uav_clear_values_pass_create_committed_resource`, `xma2_source_voice_decodes_and_manages_lifetime`), boxb 605/3 (those two plus `write_buffer_immediate_on_open_existing_heap_visible_to_cpu`). Note main's older third red on the AMD lane (`sparse::a_tile_decommitted_and_committed_again_keeps_its_video_memory`) is gone at current main — fixed upstream, we can confirm. **Results at `00b0d9c4`:** rig 597/3, boxb 597/3. The new `null::tests::heap_get_desc_fills_all_48_bytes` is green on both lanes. On the rig the third red is that stale `sparse::` one — the head branches from an older main that still carried it; on boxb the red set is identical to current-main baseline (that test is green on Pascal there). No red anywhere is introduced by this PR. **Conclusion from two vendors:** the null-device `ID3D12Heap::GetDesc` full-48-byte fill behaves as the test expects under both Wine stacks. A rebase onto current main would make the rig's third red disappear on contact. **Not tested:** the real-device `ID3D12Heap::GetDesc` path (that is the standing `real::` suite's job). AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
Foniass commented 2026-12-01 09:00:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:00:02Z.


Triage (#1607) – head 00b0d9c

#2846 fixed the same bug (bytes 40-47 of D3D12_HEAP_DESC left untouched by the null heap's GetDesc) by zeroing 48 bytes; it is closed. This PR goes further: new_heap keeps the created desc and Heap_GetDesc48 returns it, with a test of both calling orders and the null-desc case. Main still writes only 40 bytes (Hidden_ZeroDesc40).
No problems found in the diff (NullObj::desc is 64 bytes, so the 48-byte copy fits).
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7306071445 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2802#issuecomment-7306071445). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:00:02Z. --- **Triage (#1607)** – head 00b0d9c #2846 fixed the same bug (bytes 40-47 of `D3D12_HEAP_DESC` left untouched by the null heap's `GetDesc`) by zeroing 48 bytes; it is closed. This PR goes further: `new_heap` keeps the created desc and `Heap_GetDesc48` returns it, with a test of both calling orders and the null-desc case. Main still writes only 40 bytes (`Hidden_ZeroDesc40`). No problems found in the diff (`NullObj::desc` is 64 bytes, so the 48-byte copy fits). Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2802:upstream-pr/2802'
git switch 'upstream-pr/2802'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2802'
git switch 'upstream-pr/2802'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2802'
git switch 'upstream-pr/2802'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2802'
git switch 'main'
git merge --squash 'upstream-pr/2802'
git switch 'main'
git merge --ff-only 'upstream-pr/2802'
git switch 'main'
git merge 'upstream-pr/2802'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
xcl-dev/xcl!2792
No description provided.