Skip to content

D3D12.X: strip console-only root-signature flags in D3D12SerializeRootSignature - #2447

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
Decodere:fix-d3d12-serialize-rs-flags
Nov 29, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
Decodere:fix-d3d12-serialize-rs-flags

Conversation

@Decodere

@Decodere Decodere commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What is in it
Strip Xbox console-only root-signature flags in D3D12SerializeRootSignature and share sanitization/error-blob handling with D3D12SerializeVersionedRootSignature in crates/xcl/src/hle/d3d12x/mod.rs (+105/-34 lines, single file):

  • D3D12SerializeVersionedRootSignature already stripped console-only bits above PC_FLAGS = 0xFFF (such as 0x3000000) and logged/cleaned up error blobs, whereas 1.0 D3D12SerializeRootSignature forwarded raw D3D12_ROOT_SIGNATURE_DESC directly to Windows d3d12.dll, which rejects unknown flag bits with E_INVALIDARG (0x80070057).
  • Extract a shared serialize_root_sig<const QWORDS: usize> helper with PC_FLAGS = 0xFFF: copies the descriptor into an 8-byte-aligned stack buffer (40 bytes / flags at +32 for D3D12SerializeRootSignature; 48 bytes / flags at +40 for D3D12SerializeVersionedRootSignature) only when !PC_FLAGS bits are set, drops unknown bits without mutating the caller's struct, zeroes caller-provided *err before forwarding, logs error-blob diagnostics on failure even when err is NULL, and releases temporary error blobs cleanly.
  • Add a WARP/CPU unit test (hle::d3d12x::tests::serialize_root_signature_strips_console_flags_and_preserves_pc_flags) verifying descriptor layout offsets, console-flag stripping and PC-flag preservation via D3D12CreateRootSignatureDeserializer for both 1.0 and versioned serializers, caller-struct immutability, Windows 10 in-box / Agility d3d12.dll failure handling without assuming non-empty runtime error text on unknown versions (guarding blob_release when err_out is null), and runtime-independent error-blob forwarding and own_err cleanup via a mock ID3DBlob vtable.

Part of #1452
Part of #1333

Tested

  • Failing-first on unmodified origin/main (569f0fc5): XCL_ADAPTER=warp cargo test -p xcl --lib hle::d3d12x::tests -- --test-threads=1 --nocapture failed 1 of 1 (D3D12SerializeRootSignature rejected console flags: 0x80070057).
  • Post-fix hle::d3d12x::tests (bd586636, rebased onto origin/main e1d84b7d):
    • Release WARP (XCL_ADAPTER=warp cargo test --release -p xcl --lib hle::d3d12x::tests -- --test-threads=1 --nocapture): 1 passed; 0 failed; 0 ignored (0.14 s).
    • Release default RTX 4060 (cargo test --release -p xcl --lib hle::d3d12x::tests -- --test-threads=1 --nocapture): 1 passed; 0 failed; 0 ignored (0.37 s).
  • Full release workspace (cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture, RTX 4060): 37 test binaries, 1424 passed; 0 failed; 46 ignored.
    • 29 pre-existing SKIPPED lines on this RTX 4060 host (21 no wave64, 3 per-lane wave32 refused, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in hle::d3d12x::tests).

Regression run
Paired 60 s RTX 4060 smoke (scripts/smoke.ps1 -Seconds 60) on base origin/main vs PR head (1566 vs 1550 frames = 101.0%, 60 60 60 steady pace, 0 device removals, 0 crashes):

Base (origin/main):

xcl-smoke v1
commit: 889ef3e8aa7f267323ab4879e735e65da6bcef10
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1550 (PresentX 1550)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13981 MB

PR head:

xcl-smoke v1
commit: bd58663616a18dd2dca7fb1850f0ab41d528a180
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14000 MB

Not tested

  • A live retail title calling 1.0 D3D12SerializeRootSignature with console-only flag bits (console-only flag stripping, PC-flag preservation via D3D12CreateRootSignatureDeserializer, and error-blob cleanup are covered by the unit test against real Windows d3d12.dll and mock ID3DBlob).
  • In-box Windows 10 d3d12.dll without Agility SDK (this host runs Windows 11 26200; the updated test removes the assumption that unknown-version failures emit non-empty "version" text and guards blob_release on null).
  • D3D12 debug layer (d3d12SDKLayers.dll not installed on this host).

AI use
Written and verified with Google Antigravity (Gemini 4 Neon). All changes were validated locally with failing-first WARP tests, full release workspace tests, and paired 60 s RTX 4060 smoke runs.

@SlopTart

Copy link
Copy Markdown

gpu_ suite (cold cache): 160 passed / 4 failed, no crashes. The four are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, depth-buffer state refusal, and gpu_promoted_uav_clear_values_pass_create_committed_resource (report); none caused by this PR.
(empty_stream_descriptors_do_not_change_the_key was not picked up by substring filter in the --lib target; suite covers the gpu-side changes.)

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…#2127, xcl-dev#2476, xcl-dev#2479, xcl-dev#2467, xcl-dev#2444, xcl-dev#2447, xcl-dev#2448

Integrates compositor RT tracking fix (xcl-dev#2480), split shader cache budget
(xcl-dev#2475), foreign-thread deferred release (xcl-dev#2474), Wine 4-thread DXC cap
(xcl-dev#2127), DXIL feature/reload fixes (xcl-dev#2476, xcl-dev#2479), DXC loader cleanup
(xcl-dev#2467), console xcl-dev#14 null ppv guard (xcl-dev#2444), root-sig flag stripping
(xcl-dev#2447), and two-pass stream canonicalization (xcl-dev#2448).

Assisted-by: Antigravity (Gemini 4 Neon)

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code-level blocker found. The shared helper preserves the caller descriptor, strips only console-only bits for both layouts, and current Windows CI is green. Nonblocking test gap: shared error-blob handling is covered only through the 1.0 serializer. A failing versioned-serializer case with NULL/non-NULL error output would validate ownership/reset in that path.

@xpatfussy69x

Copy link
Copy Markdown
Contributor

Test run on exact head 75c835d (75c835d425f8a614d346aceaf3402d23c0f1785d, on its base 2898511), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1364 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib serialize_root_signature: 1 passed, 0 failed
  • This PR's new tests in the workspace run:
    • serialize_root_signature_strips_console_flags_and_preserves_pc_flags: ok

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1091 (PresentX 1091)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

this PR:

xcl-smoke v1
commit: 75c835d425f8a614d346aceaf3402d23c0f1785d
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1137 (PresentX 1137)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14796 MB

No crash or device removal; frames 104 % of main's, peak commit 100 %.

Not tested

  • Whether the title serializes a root signature with console-only flags in this run: a regression check only
  • The PR merged into current main (tested on its own base; it merges into e1d84b7 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.

@HAL9000RELOADED

Copy link
Copy Markdown

Windows 10 data point for 75c835d: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045.6456), Rust 1.98.1 MSVC.

serialize_root_signature_strips_console_flags_and_preserves_pc_flags:

  • With the Agility SDK 1.620.2 (XCL_D3D12_DIR), on the card and with XCL_ADAPTER=warp: passes. Merged on 6d12f58 it also passes with the whole crate.
  • On the in-box Windows 10 runtime (no XCL_D3D12_DIR), card and WARP, merged on 889ef3e: fails with "caller error blob missing diagnostic". The flag checks before that pass; only the version-99 case differs. The in-box D3D12SerializeRootSignature fails as expected but its error blob has no text (I printed it: ""), so contains("version") is false.

So the stripping works on Windows 10 too. The last assertion depends on the runtime's error text, which the in-box runtime doesn't give. Checking only the failure code there would let the test pass on Windows 10 without Agility.

…tSignature

`D3D12SerializeVersionedRootSignature` already stripped Xbox console-only
flag bits above `PC_FLAGS = 0xFFF` (e.g. `0x3000000`) and logged/cleaned up
error blobs, whereas 1.0 `D3D12SerializeRootSignature` forwarded raw
`D3D12_ROOT_SIGNATURE_DESC` straight to Windows `d3d12.dll`, which rejects
unknown flag bits with `E_INVALIDARG`.

- Share `PC_FLAGS = 0xFFF`, aligned stack-copy flag sanitization (`+32` in
  40-byte `D3D12_ROOT_SIGNATURE_DESC`, `+40` in 48-byte
  `D3D12_VERSIONED_ROOT_SIGNATURE_DESC`), and error-blob logging/cleanup
  across both serializers via `serialize_root_sig`.
- Zero caller-supplied `*err` before forwarding so failed calls never leave
  or dereference uninitialized pointers.
- Add a WARP/CPU unit test verifying layout offsets, console-flag stripping
  with PC-flag preservation via `D3D12CreateRootSignatureDeserializer`,
  caller descriptor immutability, Windows 10 in-box / Agility error-blob
  handling, and runtime-independent error-blob forwarding and cleanup.

Part of xcl-dev#1452
Part of xcl-dev#1333

Assisted-by: Google Antigravity (Gemini 4 Neon)
@Decodere
Decodere force-pushed the fix-d3d12-serialize-rs-flags branch from 75c835d to bd58663 Compare November 25, 2026 23:05
@Decodere

Copy link
Copy Markdown
Contributor Author

@HAL9000RELOADED Thanks for the Windows 10 in-box d3d12.dll test point!

Updated in bd586636 (and rebased onto e1d84b7d): the version = 99 check now verifies the failure HRESULT and *err initialization without assuming non-empty "version" text on in-box Windows 10 runtimes (and guards blob_release when err_out is null), while a runtime-independent mock ID3DBlob check on serialize_root_sig deterministically covers caller error-blob forwarding and internal own_err cleanup. Re-verified hle::d3d12x::tests (1/0 on both WARP and RTX 4060), full release workspace (1424 passed, 0 failed), and paired 60 s smoke (1550 -> 1566, 0 crashes/removals).

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
@HAL9000RELOADED

Copy link
Copy Markdown

Re-run at bd58663 on the same Windows 10 22H2 (19045) machine, RX 7900 XTX (RDNA3), driver 32.0.32015.7029.

  • In-box runtime (no XCL_D3D12_DIR): serialize_root_signature_strips_console_flags_and_preserves_pc_flags passes, 3/3 runs.
  • With Agility 1.620.2 (XCL_D3D12_DIR): passes too.

At 75c835d the same test failed here on the in-box runtime, so the change covers it.

AI-assisted (Claude Code): tests run on my machine, text drafted with Claude.

@Kalmarv

Kalmarv commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: fa20459
head: bd58663
merge: clean (trial merge 8cae7feacb6be1bfd421a719e8d58eee091f2190, local, not pushed; mod.rs auto-merged; git diff --check clean)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> 2605 passed, 4 failed, 49 ignored; SKIPPED: 26, the usual set (21 no wave64 on this 32-lane GPU, 3 per-lane f16/f32 forms refused (#1426 semantics), 2 no heap windows). The new hle::d3d12x::tests::serialize_root_signature_strips_console_flags_and_preserves_pc_flags ran and passed. The 4 failures are one flake in code this PR doesn't touch: shaders::pipeline_library::tests::builder_deduplicates_names_and_atomically_replaces_output counted 4 library entries instead of 2 (finish counts a process-global builder that other tests can add pipelines to while it runs in parallel). Its panic poisoned the shared BUILD_TEST lock, which then failed graphics_pipeline_round_trips_through_serialized_library, mesh_pipeline_round_trips_through_serialized_library and warm_library::cold_publish_makes_an_unchanged_corpus_reusable with PoisonError. All 10 pipeline_library / warm_library tests passed when rerun alone on the same merge.
review: none blocking; whole diff read. D3D12SerializeRootSignature now strips console-only flag bits (anything outside 0xFFF; seen: 0x3000000 from XboxBvhBuilder.dll) the same way D3D12SerializeVersionedRootSignature already did. Both go through one serialize_root_sig, which copies the 40-byte 1.0 desc (flags at +32) or the 48-byte versioned desc (flags at +40) before changing it, so the caller's desc is untouched. The test checks those sizes and offsets with size_of / offset_of!, and the reads are unaligned-safe. Dispatch is the same as the old forward! macro: the system export on the Real backend, otherwise null::. The failure log now names the entry point and reads parameters / samplers / flags at the right offsets for each version. One behaviour change: a non-null err is set to null on entry, so a caller's error pointer is always initialized; that matches the runtime's contract and the test covers it. The error blob is released only when the caller passed no err.
performance: none to speak of (one 40/48-byte copy, only when console bits are set). Title run (release build of the merge, scratch/fast-world.py fast profile, about 85 s in world): exit 0, 0 crashes, 0 device removals, world entry 80.0 s, peak commit 31,227 MB, 68 WARN lines, failed_pipelines 0, no translation errors, no new WARN kinds against a main fa20459 run on the same harness (world entry 76.8 s, peak commit 33,027 MB, 86 WARN lines). This title only calls the versioned entry point: 17 "D3D12SerializeVersionedRootSignature: console flags 0x3000000 dropped" lines on both main and the merge, and no D3D12SerializeRootSignature call. So at run time the refactored versioned path behaves as before, and the new 1.0 stripping is covered only by the unit test. Both runs show 0 fps in the world because the cache doesn't match the translator identity.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, release build for the title run, DXC 1.9.2609 via XCL_DXC_DIR. Claude Code, Claude Opus 5.5: merge, build, suite, title run and full-diff review; this report.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 29, 2026
@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: bd58663

@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: fa20459
head: bd58663
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2609 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at fa20459: 2608 passed, 0 failed, 49 ignored.
review: no blocking finding. The flag stripping moves into one shared function and now also covers the 1.0 descriptor; offsets, copy sizes and the error-blob handling are right, and the caller's descriptor is not changed. One behaviour change: a caller's error pointer is now set to null before the call, as the null backend already did. Two notes on the test: it creates the process-wide real device inside a unit test (with the null backend configured it would fail on E_NOTIMPL), and it asserts what the system's d3d12.dll does with an unknown version and a null descriptor, which may differ between Windows builds. It passed here on Windows 11 26300.
performance: none expected (one small copy per serialize call); not measured.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Nov 29, 2026

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review of head bd58663 — no blocking finding in the change.

I checked the 40-byte and 48-byte descriptor copies, flag offsets, preservation of caller memory, forwarding of the error-blob pointer, and release of an internally captured error blob. The test covers both serializer exports and success/failure handling. I did not run the Windows/WARP suite here; the results in the PR description are author reported.

@raylitebull
raylitebull merged commit da421e0 into xcl-dev:main Nov 29, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants