Skip to content

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

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-d3d12-serialize-rs-flags
Open

Decodere wants to merge 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

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.

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.

6 participants