Skip to content

D3D12.X: keep untranslated console graphics and stream shaders out of the driver - #303

Open
pedrocalazans05 wants to merge 1 commit into
ivall:mainfrom
pedrocalazans05:fix/amd-nobc-pso-guard
Open

pedrocalazans05 wants to merge 1 commit into
ivall:mainfrom
pedrocalazans05:fix/amd-nobc-pso-guard

Conversation

@pedrocalazans05

Copy link
Copy Markdown

Mirrors dev_create_compute_pso's console-bytecode guard in graphics_pso and dev_create_pipeline_state so untranslated console DXIL (NOBC / XDAT) never reaches the PC shader compiler. On AMD GPUs (amdxc64.dll), passing stripped console DXIL directly to CreateGraphicsPipelineState / CreatePipelineState triggers a fail-fast crash (0xc0000409) instead of returning E_INVALIDARG.

When translated_graphics_pso returns a failed HRESULT (for example translated_gs_pso on a GPU without D3D12 mesh shaders), graphics_pso now falls through to the stand-in PSO instead of returning the failed HRESULT directly. Inside fallback_stream, console RTV (subobject 15) and DSV (subobject 16) formats are translated through pc_target_format / pc_view_format just like pc_topology_type already does for graphics PSOs.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs:
    • graphics_has_console_shader and stream_has_console_shader guards before raw finish_pso in graphics_pso and dev_create_pipeline_state
    • Fallthrough to the dummy stand-in when translated_graphics_pso returns hr < 0
    • Console RTV (15) / DSV (16) format translation in fallback_stream
    • Unit tests in console_pso_guard_tests covering console-shader detection across all graphics stages / stream subobjects and fallback_stream RTV/DSV format rewriting

Tested

  • Hardware / OS: AMD Radeon RX 580 2048SP (8170 MiB VRAM, driver 31.0.21925.1001), Intel Core i3-10100F, Windows 11 Build 26300, rustc 1.100.0 (0ef1bc386 2026-11-09), debug (cargo test) & release (cargo build --release --workspace)
  • Commit tested: 80fb3be (clean branch on 9ab7d76)
  • cargo test -p xcl --lib hle::d3d12x:: -- --test-threads=4: 81 passed, 0 failed, 1 ignored
  • cargo test -p xcl --test '*' -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched: 39 passed, 0 failed, 20 ignored, 1 filtered out
  • .\scripts\test.ps1 --skip gpu_wave64_ps_whole_wave_reductions (xcl --lib): 593 passed, 20 failed, 20 ignored, 2 GPU tests skipped (no mesh shaders). All 20 failures (gpu::recomp::tests::gpu_*, CreateComputePipelineState: 0x80070057 / wave32) and the skipped Polaris driver access violation (gpu_wave64_ps_whole_wave_reductions) are pre-existing Polaris/GCN4 hardware limitations unrelated to real.rs.

Regression run

xcl-smoke v1
commit: 9ab7d763197c7f420bff10cd9bf1310f07e2a9aa
gpu: AMD Radeon RX 580 2048SP
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 78 (PresentX 78)
presents per 2 s (last 3): 4 5 4
device removals: 0
crashes: 0
peak commit: 10122 MB
xcl-smoke v1
commit: 80fb3be6055be6d47a7389a35586978b6fffec7d
gpu: AMD Radeon RX 580 2048SP
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 47 (PresentX 47)
presents per 2 s (last 3): 3 2 2
device removals: 0
crashes: 0
peak commit: 9852 MB

Not tested

  • GPUs with D3D12 mesh shaders / Wave32 / native f16 (RDNA2+, NVIDIA RTX, Intel Arc)
  • test_title_runs_and_game_folder_is_untouched (no System32\xgameruntime.dll / Gaming Services installed on this PC)
  • XCL_SAMPLE_* game-data tests (variables unset)

AI use

  • Tool / model: Antigravity (Google DeepMind), Gemini 4 Hydrogen
  • What it did: diagnosed the amdxc64.dll 0xc0000409 crash from logs, drafted the guard + fallback_stream format translation + console_pso_guard_tests unit tests, ran the local test/smoke commands above, and performed an adversarial code review (reviewer subagent: APPROVE (LGTM)). Reviewed and verified by the author.

… the driver

Mirror dev_create_compute_pso's console-bytecode guard in graphics_pso and dev_create_pipeline_state so untranslated Xbox DXIL (NOBC/XDAT) never reaches the PC shader compiler (AMD's amdxc64.dll fails fast with 0xc0000409 instead of returning E_INVALIDARG).

Also fall through to the stand-in PSO when translated_graphics_pso returns a failed HRESULT (e.g. translated_gs_pso on GPUs without mesh shaders), and rewrite console RTV (subobject 15) and DSV (subobject 16) formats to PC formats inside fallback_stream, matching pc_topology_type.
@Fizzonaut

Copy link
Copy Markdown

Independent test run on commit 80fb3be6055be6d47a7389a35586978b6fffec7d (PR #303 head; clean merge onto origin/main 4017f8f checked via git merge-tree) on AMD RDNA3 with mesh shaders, xgameruntime.dll, and the D3D12 debug layer: pass.

Tested

  • Hardware / software: AMD Radeon RX 7900 XTX (24516 MiB VRAM, driver 32.0.31007.5012), AMD Ryzen 7 7800X3D, Windows 11 Pro 26H2 (build 26300.9974), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5 via XCL_DXC_DIR, System32\xgameruntime.dll 10.0.26100.9656, D3D12 debug layer active (D3D12SDKLayers.dll), debug build.
  • Command: powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4), no XCL_SAMPLE_* set:
    • Native (default): 654 passed, 0 failed, 40 ignored, 0 SKIPPED GPU tests (exit 0)
    • XCL_SPLIT_WAVE64=1: 654 passed, 0 failed, 40 ignored, 0 SKIPPED GPU tests (exit 0)
  • All 3 new console_pso_guard_tests (graphics_desc_detects_console_shader_in_any_stage, pipeline_stream_detects_console_shader_subobjects, fallback_stream_rewrites_console_rtv_and_dsv_formats) and test_title_runs_and_game_folder_is_untouched (e2e) ran and passed.

Not tested

  • Retail title / scripts/smoke.ps1 (no unpacked Xbox title available), XCL_SAMPLE_* game-data tests, release build, NVIDIA / wave32-only GPUs.
  • No manual code review performed.

AI use

  • Antigravity (Gemini 4 Neon) checked out the PR, ran both test runs, and drafted this test report from the actual output.

@jleybourne

Copy link
Copy Markdown

Ran this on the vendor it does not come from: your report is Polaris-only, which is where the guards matter, so a green NVIDIA run says the guard itself costs nothing on a healthy driver.

Tested

  • NVIDIA GeForce RTX 4070 Ti (11.7 GiB, driver 610.88, SM 6.8, WaveLaneCountMin/Max 32..32, mesh shader tier 1, raytracing 1.2), Intel Core i7-10700KF, Windows 11 build 26300, rustc 1.100.0 (x86_64-pc-windows-msvc), DXC 1.8.2502 (SDK 10.0.26100), system XGameRuntime 10.0.26100.9656.
  • Commit tested: 80fb3be (base 9ab7d76), no uncommitted changes, git status empty.
  • scripts\test.ps1 (debug), no XCL_SAMPLE_* set: 654 passed, 0 failed, 40 ignored (17 test binaries).
  • GPU tests skipped on this adapter: 2 (no wave64) — the same two as on main: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask and gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware.
  • The PR's own tests pass here: graphics_desc_detects_console_shader_in_any_stage, pipeline_stream_detects_console_shader_subobjects, fallback_stream_rewrites_console_rtv_and_dsv_formats.
  • e2e::test_title_runs_and_game_folder_is_untouched ran and passed with System32\xgameruntime.dll present, so the test title's D3D12.X pipeline creation goes through the changed real.rs path on this card.

Counts are lower than main's (666 passed / 41 ignored) because the base 9ab7d76 predates the last three commits on main, not because anything failed.

Not tested: the AMD fail-fast fix itself (needs one of those cards), any retail title — there is no game package on this machine, so PresentX/draw submission and the real CreateGraphicsPipelineState calls a title makes are not covered by this run.

AI use: real run on the machine above, turned into this comment by Hermes Agent with DeepSeek v4.1-flash. Numbers pasted from the test.ps1 log.

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Tested 80fb3be merged onto main 4017f8f (merge 365c47f, no conflicts). The change does what the description says; three things to settle.

1. The new tests cover the two predicates and fallback_stream, not the change in behaviour.

  • With both guards taken out of graphics_pso and dev_create_pipeline_state, and a failed translated_graphics_pso returned to the title again as on main, all three tests in console_pso_guard_tests still pass (3 passed, 0 failed).
  • So nothing fails if a console shader reaches finish_pso again, or if a failed translation stops falling through to the stand-in. A test of that needs a device whose CreateGraphicsPipelineState / CreatePipelineState calls can be counted, like the fake list vtable in bind::tests.
  • Negative control on main: fallback_stream_rewrites_console_rtv_and_dsv_formats fails there (formats stay [116, 117, 86, 115, 28, …]) and passes on the merge. The other two tests call the new predicates, so they do not compile on main.

2. It conflicts with #214 in real.rs (at f007d4a, and still at its current head 960162e), and both add the same rewrite.

3. scripts/pr_check.py on main refuses the description as it is: "the PR's run shows fewer frames than main's (47 against 78)". That is 60 %; the rule asks for 80 %.

From reading, where the graphics guard applies: translated_graphics_pso returns None for a console VS when the pipeline has an HS or DS, when a shader does not translate, and when the driver rejects the translated pipeline. In all three, main hands the original description with its console shaders to finish_pso. With the PR those get E_INVALIDARG and then the dummy-shader stand-in.

Tested

RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 26200, debug.

Not tested

  • AMD: the driver crash this PR is about does not happen on NVIDIA, so I could not show the guard preventing it.
  • A GPU without mesh shaders (the translated_gs_pso failure the fallthrough is for).
  • The retail game, and any pipeline that takes one of the three paths above.

🤖 Claude Fable 5.2

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