Skip to content

D3D12.X: a stage the PC cannot run goes to the fallback without the driver - #750

Open
Lucasyudi wants to merge 1 commit into
xcl-dev:mainfrom
Lucasyudi:d3d12x/non-pc-stage-fallback
Open

Lucasyudi wants to merge 1 commit into
xcl-dev:mainfrom
Lucasyudi:d3d12x/non-pc-stage-fallback

Conversation

@Lucasyudi

@Lucasyudi Lucasyudi commented Nov 24, 2026 •

Copy link
Copy Markdown

A graphics pipeline whose shaders XCL does not translate is handed to the driver as it came; the stand-in shaders are used when the driver refuses it. Windows drivers refuse a stage that is neither DXIL nor SM5 byte code, but Apple's D3DMetal (macOS under CrossOver) dereferences null parsing a container it does not know, and the process dies. Part of #258.

What is in it

  • gpu/shader.rs: runs_on_pc(blob), from the existing classify: DXIL or DXBC with SM5 byte code; a unit test for it.
  • hle/d3d12x/real.rs: graphics_pso skips the driver call when a stage fails runs_on_pc and goes to the fallback with E_INVALIDARG, the result a Windows driver gives. On Windows the outcome is the same pipeline (the stand-ins), one driver call fewer.

Tested

  • Apple M4 Pro (24 GB), macOS 27.2.1, CrossOver 26.3 with D3DMetal, Rosetta 2. xcl.exe cross-built with mingw-w64 (GCC 16.2.0), Rust 1.100.0, debug. DXC 1.9.2609.
  • Without XCL: a 60-line D3D12 program (mingw, D3D12CreateDevice + CreateGraphicsPipelineState) on the same host gets S_OK for a vs_5_0 / ps_5_0 pipeline and dies (write to 0 in ntdll, after a read at null+0x18 in D3DMetal) for the same pipeline with a 56-byte DXBC container holding only an XBOX part, which is what the test title's console_container() builds.
  • cargo test -p xcl --lib gpu::shader::: only_pc_shaders_run_on_pc fails before the change (stub) and passes after. readable_answers_from_the_working_set_without_touching_pages fails on this host, on main (91f9a5e) as well.
  • cargo test --test e2e (the test title): on main the title dies in "shaders captured; console shader gets a fallback PSO" (31 PASS before it). With this commit that check and the retail-format one pass (32 PASS); the title then dies later in render_triangle, calling past the end of a D3DMetal vtable. That is what @Ahmet-Dedeler's mac-on-main-wip handles: his branch (db065d8) alone dies at the same fallback PSO check; with this commit on top, the title runs to its end, 47 PASS, 3 FAIL (no GPU timestamp; window not cloaked; XMA2 GetState ctx=0).
  • Head 6569928, rebased onto main 64b3f35: the unit test and the e2e counts above are the same.
  • Runs by others on this head against 64b3f35 (on the PR): @juliptree, native Windows, RTX 5060 Ti, MSVC: gpu::shader:: 4 passed on base, 5 on the PR; both e2e tests pass on each (50/50 title checks, the fallback PSO and the triangle readback included). @us3r40456 (M5 Pro, cargo-xwin MSVC) and @shortside (M5 Pro, clang-cl / xwin): on base the title dies at the console shader, on the head both fallback pipelines are made and it dies later at the D3DMetal vtable crash, as above.
  • The hle::d3d12x unit tests stop at the first test that creates a device on this host, on main and with this commit alike.

Regression run

Run by @Anon64 on a retail title, 60 s each, scripts/smoke.ps1, release, clean tree at each commit (NVIDIA GeForce RTX 3060 12 GB, driver 581.80, Windows 11 25H2), pasted unedited from #750 (comment):

main:

xcl-smoke v1
commit: 64b3f35599bb7102f55d640e1a791e7d6dd3b175
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1649 (PresentX 1649)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16734 MB

this PR:

xcl-smoke v1
commit: 6569928c24d157bc0c03a8a6de655e2a94378c81
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1647 (PresentX 1647)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16740 MB

Not tested

AI use

  • Claude Code with Claude Opus 5.5 (claude-opus-5-5): found the cause, wrote the change, the test and the probe, ran the tests above.

…river

A graphics pipeline whose shaders XCL does not translate was handed to the
driver as it came, and the stand-in shaders were used when the driver refused
it. Windows drivers refuse a stage that is neither DXIL nor SM5 byte code, but
Apple's D3DMetal (macOS, CrossOver) dereferences null parsing a container it
does not know and the process dies: the e2e test title's "console shader gets a
fallback PSO" check crashed there.

Such a stage (`shader::runs_on_pc`, from the existing `classify`) now skips the
driver call and takes the fallback with E_INVALIDARG, the result a Windows
driver gives. On Windows the outcome is the same pipeline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Lucasyudi
Lucasyudi force-pushed the d3d12x/non-pc-stage-fallback branch from 4ce3355 to 6569928 Compare November 24, 2026 04:44
@Lucasyudi

Copy link
Copy Markdown
Author

@Kalmarv if your offer on #258 covers this one too: it touches the shared PSO path, so it needs a Windows pair. Head 6569928 on main 64b3f35. I have no retail title here. Thanks!

AI-assisted (Claude Code, Claude Opus 5.5).

@juliptree

Copy link
Copy Markdown

Independent native Windows validation of base 64b3f35 and PR head 6569928 using Rust 1.100.0 MSVC. XCL’s runtime logs confirmed the RTX 5060 Ti on NVIDIA driver 616.92 as the D3D12 adapter for both runs.

  • gpu::shader:: library tests passed: 4 on base, 5 on the PR.
  • Both synthetic e2e tests executed and passed on each revision, with 50/50 synthetic title checks. The console shader fallback PSO and the normal triangle render and readback both ran and passed.
  • The D3D12 debug-layer case explicitly skipped on both revisions because d3d12SDKLayers.dll was unavailable. Cargo counted that early return as a third e2e pass. No other explicit skips.
    Synthetic fixtures only. No retail smoke run. AI-assisted validation and write-up by Codex.

@Anon64

Anon64 commented Nov 24, 2026

Copy link
Copy Markdown

Regression runs for this PR's head 6569928 and for its base main 64b3f35, on a retail title (same title, 60 s each), made with scripts/smoke.ps1 (release, clean tree at each commit) and pasted unedited, for Regression run.

main:

xcl-smoke v1
commit: 64b3f35599bb7102f55d640e1a791e7d6dd3b175
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1649 (PresentX 1649)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16734 MB

this PR:

xcl-smoke v1
commit: 6569928c24d157bc0c03a8a6de655e2a94378c81
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1647 (PresentX 1647)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16740 MB

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 581.80, wave32), Intel Core i9-14900KF, Windows 11 25H2 26200.9974 (native Windows), Rust 1.90.0

Not tested

  • the unit tests on this machine
  • whether the title reaches the changed code; this is a regression check only

Report written with Claude Code (Claude Opus 5.5) from runs on this machine.

@us3r40456

Copy link
Copy Markdown

Tested on an Apple Silicon Mac. I compared the head 6569928 with its base 64b3f35, both on main (no Mac port branch).

Tested

  • MacBook Pro, Apple M5 Pro (20-core GPU), 24 GB, macOS 27.2.1, Rosetta 2. CrossOver 26.3.0.39832 with D3DMetal 3.0. MSVC debug build, cross-built with cargo-xwin 0.24.1 (Rust 1.100.0, clang-cl / lld 23.1.6). DXC 1.9.2609 (XCL_DXC_DIR). Builds with no new warning.
  • tests/e2e.rs, test_title_runs_and_game_folder_is_untouched:
    • On the base, the test title gets 29 [PASS]. It then dies right after capturing its console pixel shader (the [XBOX] container), on a write to address 0: the D3DMetal null dereference described in macOS (Apple Silicon, CrossOver + D3DMetal): the newer retail game reaches its first-run menus at 30 fps #258.
    • With this PR, it gets 33 [PASS], among them D3D12.X: shaders captured; console shader gets a fallback PSO and D3D12.X: retail-format console shader (XDAT/XBCH/FSSM) captured + fallback PSO. It then dies further on, executing at 0x1b84800000af0, right after the title-texture setup (ID3D12Resource2 – 17 PC methods …).
    • With Ahmet-Dedeler's pr/native-host-vtables (ddf3be7) merged on top locally, it gets 32 [PASS] and dies inside D3DMetal, in D3D12GraphicsCommandList::IASetIndexBuffer (+0x129, a read at 0xa8).
    • So the step this PR targets passes on this host. On main, the test title needs more of the Mac port to reach its end.
    • The two storage checks (pls dir S:\, create S:/Users/xcl/games) failed on the base run and passed on the PR run. The e2e test reuses its data folder between runs, so I don't count that difference.
  • gpu::shader::: 3 passed and 1 failed on the base, 4 passed and 1 failed with this PR. The new test passes. The failure on both is readable_answers_from_the_working_set_without_touching_pages.
  • hle::d3d12x::real::: 18 passed on both.

Not tested

  • Windows, the rest of the suite, and mac-on-main-wip.

AI use

  • Claude Code, Claude Opus 5.5 ran these tests on this machine and wrote this report.

@shortside

Copy link
Copy Markdown

Test report from a second Mac, head 6569928 against its merge base 64b3f35.

Tested

  • MacBook Pro M5 Pro, macOS 27.2.1, Rosetta 2; CrossOver 26.3 (Wine 11.0), Windows 10 bottle, D3DMetal; DXC 1.9.2609. Cross-built for x86_64-pc-windows-msvc with clang-cl / lld-link 23.1.6 and an xwin SDK 10.0.26100, Rust 1.100.0, debug. The lib test binary run under Wine, one test per process (--exact --nocapture, 60 s cap).
  • gpu::shader:: lib tests: base 3 passed, 1 failed; head 4 passed (only_pc_shaders_run_on_pc is new), 1 failed. The failure is readable_answers_from_the_working_set_without_touching_pages on both, as your description says.
  • The test title (tests/e2e.rs, fresh data folder): on base it dies right after "D3D12.X: queue + fence signal on the GPU", 2 of 2 runs (31 PASS before it). On head, 1 run: xcl.log shows both fallback pipelines made ("graphics PSO rejected by the driver (0x80070057) – fallback shaders used" Implement XSystemGetDeviceType/PLS thunks and Opus audio carrier parsing #1 and #2), and the title dies later with a page fault on execute access, which matches the D3DMetal vtable crash your description names. Wine's debugger then held the process past my 400 s cap, so I have no PASS count for the head run.

Not tested

AI use

  • Claude Code with Claude Fable 5.2 built both commits, ran the tests and wrote this report.

@Lucasyudi

Copy link
Copy Markdown
Author

@Anon64 @juliptree @us3r40456 @shortside thanks for the runs. The smoke pair is now under Regression run in the description (scripts/pr_check.py --local on it: "description ok"), and the other reports are summarised under Tested.

AI-assisted (Claude Code, Claude Opus 5.5).

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (6569928)

Tested xcl-dev/xcl PR #750 at 6569928c24d157bc0c03a8a6de655e2a94378c81 in a clean checkout.

Hardware / environment

  • Windows x64, build 10.0.26200.0. CPU reported as AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD. The focused fixture used no GPU.
  • rustc 1.100.0 (0ef1bc386 2026-11-09) (x86_64-pc-windows-msvc). DXC reported dxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47).
  • The Cargo test profile was unoptimized, with debug info and incremental compilation disabled.

Commands and results

  • cargo test --workspace --no-run exited 0 and built the workspace test executables. Cargo emitted a deprecation warning for AtomicU32::fetch_update in hle/xgameruntime/mod.rs.
  • cargo test -p xcl --lib gpu::shader::tests::only_pc_shaders_run_on_pc -- --exact exited 0 with XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. It ran outside the Arc runner.
  • Focused log totals were 1 passed, 0 failed, 0 ignored, 0 skipped (681 filtered out). The skip count comes from case-sensitive SKIPPED markers.

Observed behavior

The CPU-only fixture confirmed that runs_on_pc accepted synthetic DXIL and SM5 (SHEX) containers. It rejected a DXBC container carrying an XBOX part with RDNA2 code, the raw RDNA2 bytes, and an ELF-prefixed blob. The assertions passed in a single library test.

Not tested

The full GPU workspace suite and game smoke runs were omitted. This run did not create a D3D12 graphics pipeline or verify that the runtime bypassed the driver and created a fallback pipeline. CrossOver and D3DMetal were outside this Windows test run.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr750-focused.log and published.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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.

7 participants