D3D12.X: keep untranslated console graphics and stream shaders out of the driver #303
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!303
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-303"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@pedrocalazans05 on GitHub · 2026-11-23 22:49 UTC · original
pedrocalazans05:fix/amd-nobc-pso-guard→main· +494 −5 · 1 files · 1 commits · openMirrors
dev_create_compute_pso's console-bytecode guard ingraphics_psoanddev_create_pipeline_stateso untranslated console DXIL (NOBC/XDAT) never reaches the PC shader compiler. On AMD GPUs (amdxc64.dll), passing stripped console DXIL directly toCreateGraphicsPipelineState/CreatePipelineStatetriggers a fail-fast crash (0xc0000409) instead of returningE_INVALIDARG.When
translated_graphics_psoreturns a failedHRESULT(for exampletranslated_gs_psoon a GPU without D3D12 mesh shaders),graphics_psonow falls through to the stand-in PSO instead of returning the failedHRESULTdirectly. Insidefallback_stream, console topology types (subobject 14— anything outside1..=3, includingUNDEFINED,PATCHsinceHS/DSare stripped, and consoleRECT_LIST_TYPE = 19), RTV formats (subobject 15), and DSV formats (subobject 16) are rewritten to PC-compatible values.What is in it
crates/xcl/src/hle/d3d12x/real.rs:graphics_has_console_shaderandstream_has_console_shaderguards before rawfinish_psoingraphics_psoanddev_create_pipeline_statetranslated_graphics_psoreturnshr < 014→TRIANGLE), RTV (15→pc_target_format), and DSV (16→pc_view_format) translation infallback_stream(aligned with #214'sfallback_streamsubobjects14/15/16)console_pso_guard_tests: predicate tests,fallback_streamrewrite test, plus an isolatedFakeAdoptedDeviceharness callinggraphics_psoanddev_create_pipeline_statedirectly to verify driver call counts, console shader blocking,translated_gs_psofailure fallthrough,fallback_streamrewriting, and PC-only passthroughTested
31.0.21925.1001), Intel Core i3-10100F, Windows 11 Build26300,rustc 1.100.0 (0ef1bc386 2026-11-09), debug (cargo test) & release (cargo build --release -p xcl)1193d2c(rebased cleanly ontoorigin/main7ebf1b8)cargo test -p xcl --lib console_pso_guard_tests -- --test-threads=4: 7 passed, 0 failed, 0 ignored (also 7 passed withXCL_ASYNC_PSO=0)1193d2c(temporarily removing each runtime change and runningconsole_pso_guard_tests):graphics_has_console_shaderguard: 2 behavioral tests fail (CreateGraphicsPipelineStatecalled twice with console bytecode first)if hr >= 0fallthrough ingraphics_pso:graphics_pso_falls_through_to_standin_when_translated_gs_pso_failsfails (E_INVALIDARGreturned, 0 driver calls)stream_has_console_shaderguard:dev_create_pipeline_state_blocks_console_stream_and_rewrites_fallbackfails (CreatePipelineStatecalled twice with console stream first)cargo test -p xcl --lib hle::d3d12x:: -- --test-threads=4: 95 passed, 0 failed, 1 ignored, 0 skippedcargo test -p xcl --test '*' -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched: 39 passed, 0 failed, 20 ignored, 1 filtered outcargo clippy -p xcl --lib --tests: 0 warnings on added/modified lines inreal.rsamdxc64.dll31.0.21925.1001), untranslated console shaders reachingCreateGraphicsPipelineState/CreatePipelineStatecausedamdxc64.dllfail-fast0xc0000409during extended runs before this guard; with this guard in place, extended runs and the 60 s smoke run below hit 0amdxc64.dllcrashes.Regression run
Not tested
gpu::recomp::tests::gpu_*suite on this RX 580 (Polaris lacks Wave32 / native f16 / SM 6.6;gpu_wave64_ps_whole_wave_reductionshits a pre-existing Polaris driver access violation, unrelated toreal.rs)80fb3be)test_title_runs_and_game_folder_is_untouched(noSystem32\xgameruntime.dll/ Gaming Services installed on this PC)XCL_SAMPLE_*game-data tests (variables unset)AI use
amdxc64.dll0xc0000409crash from logs, implemented the console-shader guards,fallback_streamsubobject14/15/16rewrites, andFakeAdoptedDevicebehavioral tests + negative controls, ran the local tests/smoke runs above, and performed an adversarial code review (APPROVE). Reviewed and verified by the author.@Fizzonaut on GitHub · 2026-11-23 23:42 UTC · original
Independent test run on commit
80fb3be6055be6d47a7389a35586978b6fffec7d(PR #303 head; clean merge ontoorigin/main4017f8fchecked viagit merge-tree) on AMD RDNA3 with mesh shaders,xgameruntime.dll, and the D3D12 debug layer: pass.Tested
32.0.31007.5012), AMD Ryzen 7 7800X3D, Windows 11 Pro 26H2 (build26300.9974),rustc 1.100.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5viaXCL_DXC_DIR,System32\xgameruntime.dll10.0.26100.9656, D3D12 debug layer active (D3D12SDKLayers.dll), debug build.powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4), noXCL_SAMPLE_*set:SKIPPEDGPU tests (exit 0)XCL_SPLIT_WAVE64=1: 654 passed, 0 failed, 40 ignored, 0SKIPPEDGPU tests (exit 0)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) andtest_title_runs_and_game_folder_is_untouched(e2e) ran and passed.Not tested
scripts/smoke.ps1(no unpacked Xbox title available),XCL_SAMPLE_*game-data tests, release build, NVIDIA / wave32-only GPUs.AI use
@Kalmarv on GitHub · 2026-11-24 00:10 UTC · original
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.graphics_psoanddev_create_pipeline_state, and a failedtranslated_graphics_psoreturned to the title again as on main, all three tests inconsole_pso_guard_testsstill pass (3 passed, 0 failed).finish_psoagain, or if a failed translation stops falling through to the stand-in. A test of that needs a device whoseCreateGraphicsPipelineState/CreatePipelineStatecalls can be counted, like the fake list vtable inbind::tests.fallback_stream_rewrites_console_rtv_and_dsv_formatsfails 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.fallback_stream. #214 also rewrites subobject 14 (a console topology type such as 19 becomes TRIANGLE); this PR leaves 14 as it is.c74b03a) and #267 (b5c9057).3.
scripts/pr_check.pyon 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_psoreturnsNonefor 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 tofinish_pso. With the PR those getE_INVALIDARGand then the dummy-shader stand-in.Tested
RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 26200, debug.
cargo build --workspace, thencargo test --workspace -- --test-threads=4on the merge 365c47f: 655 passed, 0 failed, 40 ignored. SKIPPED on this card:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).cargo test -p xcl --lib console_pso_guard_tests: merge 3 passed, 0 failed; main4017f8fwith the one test that compiles there 0 passed, 1 failed; merge with the three behaviour changes taken out 3 passed, 0 failed.git merge-treeof 80fb3be with main4017f8f, #187, #267 (clean) and #214 (conflict inreal.rs).Not tested
translated_gs_psofailure the fallthrough is for).🤖 Claude Fable 5.2
@pedrocalazans05 on GitHub · 2026-11-24 02:00 UTC · original
Thanks for the thorough review and negative-control check, @Kalmarv! Updated the PR on commit
1193d2c(rebased ontoorigin/main7ebf1b8) to address all three points:Behavioral tests (
console_pso_guard_tests): Added an isolatedFakeAdoptedDevicevtable harness callinggraphics_psoanddev_create_pipeline_statedirectly and counting driver calls:graphics_pso_blocks_untranslated_console_shaders_and_uses_standin— console VS+HS desc never reachesCreateGraphicsPipelineState; driver sees 1 call with dummy PC shaders (S_OK).graphics_pso_falls_through_to_standin_when_translated_gs_pso_fails— console VS+GS desc wheretranslated_gs_psoreturnsE_INVALIDARG(fake device reports no mesh shaders) falls through to the stand-in PSO (S_OK, 1 call with dummy PC shaders).dev_create_pipeline_state_blocks_console_stream_and_rewrites_fallback— console PS stream (StreamPipeline::Unknown) never reachesCreatePipelineState; driver sees 1 call with dummy PC PS and rewritten subobjects14/15/16.pc_only_graphics_and_stream_psos_pass_through_unmodified— cloned PC-only shaders pass directly to the driver unmodified.graphics_has_console_shaderguard,if hr >= 0fallthrough,stream_has_console_shaderguard).fallback_streamalignment with #214: Added subobject14(PrimitiveTopologyType) normalization alongside15and16. Becausefallback_streamunconditionally stripsHS/DS(3 | 4 | 5 | 24 => put(&mut buf, &[])), anything outside1..=3(includingUNDEFINED = 0,PATCH = 4, and consoleRECT_LIST_TYPE = 19) is rewritten toTRIANGLE (3). Since #214 is still open, rebasing ontomainkeeps this PR standalone and makes reconciling #214 straightforward if this lands first.Smoke regression run (
scripts/pr_check.py): Re-ranscripts/smoke.ps1(60 s) on bothorigin/main(7ebf1b8:1367frames,10019 MB) and1193d2c(1339frames — 98% ofmain,10046 MB,0crashes,0device removals) on the AMD RX 580 and updated the PR description accordingly.Also thank you @Fizzonaut and @jleybourne for the independent RDNA3 and NVIDIA test runs on
80fb3be!@MesshM on GitHub · 2026-11-24 05:08 UTC · original
Test run of
1193d2c5f504a3972788d4be71e86a0779ad01e6on AMD RDNA4. I merged it onto currentmaind5442d2locally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 711 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 670 passed, 0 failed, 21 ignoredSKIPPED; theconsole_pso_guard_testspass.Review: Untranslated console shaders are kept out of the driver and the stand-in is used, while PC-only graphics and stream PSOs pass through unmodified, as the tests check. At 499 lines I reviewed the structure, not every line.
Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@iggyvilla on GitHub · 2026-11-24 14:13 UTC · original
Test report and review for
1193d2c5f504a3972788d4be71e86a0779ad01e6(current head of #303; base7ebf1b8044bef8f0ef296eb36e85010cceb4633a, onecrates/xcl/src/hle/d3d12x/real.rschange) on an AMD RDNA2 card. The builds and runs were done by an agent (omp, DeepSeek V4.1 Flash) and I checked the numbers below against its saved smoke blocks and test log; the text is by Claude Code (Claude Sonnet 5.5).Tested
XCL_SAMPLE_*. Clean worktrees for head and base; debug for the tests, release for the smokes.cargo test --workspace --no-fail-fast -- --test-threads=4on the head: 681 passed, 3 failed, 41 ignored (16 test binaries; sums of the saved log). NoSKIPPEDlines; adapter-dependent tests are#[ignore]d here instead. The 3 failures are this card's known set:placed_title_textures_share_vram_and_preserve_pixels(3D 64x64x64 4 mips: subresource 2 mismatch, the #470 defect) and the twoPoisonErrorcascades it leaves (transitions_apply_when_their_list_is_submitted,d32s8_targets_take_their_own_size_of_video_memory). A first run before a workspace build failede2efor lack of the test-title binary; it is 3/3 once built.cargo test -p xcl --lib console_pso_guard_tests -- --test-threads=4: 7 passed, 0 failed. The head merged ontomainas of6efdabc(clean) gave the same 7/7; only these guard tests were run on that merge.XCL_NETWORK=0, retail title, 60 s, after one unmeasured 60 s warm-up of 1449 frames; head first, then base). Pasted fromscripts/smoke.ps1output:Head shows 99.9 % of base's frames and the same peak commit; no device removal or crash in either.
Review (diff read at
1193d2c; the points marked "hypothesis" were not run)graphics_psoshould not hide a real driver failure: the only negativeHRESULTtranslated_graphics_psoreturns comes fromtranslated_gs_pso, andfinish_two_passreports both driver failures there asE_INVALIDARG, so device-removed or out-of-memory results are not rewritten.dev_create_graphics_pso,CreateGraphicsPipelineStateX, the stream-to-desc route) funnels intographics_pso; compute already had its guard; the stream guard only matters forUnknownstreams.fallback_streamrewrites the primitive-topology subobject (14) only when it is outside 1..=3, but with a mesh stand-in the shader isdummy_mesh(), whose HLSL says[outputtopology("triangle")]. A console mesh stream declaring POINT (1) or LINE (2) keeps that, so the stand-in PSO declares a topology its mesh shader does not produce. Hypothesis: D3D12 requires these to match and the debug layer flags it; not run, and no doc is quoted. Using the already-computedmesh(if mesh || !(1..=3).contains(&topo)) would make the stand-in consistent. Not a regression:mainleaves the value alone too.stream_has_console_shaderstops at the first unknown subobject type, so a console shader behind one still reaches the driver (malformed or newer-SDK streams only).graphics PSO rejected by the driver (0x80070057) – fallback shaders used, although the driver was not called; a distinct message would keep the diagnosis honest. Cosmetic.graphics_pso_falls_through_to_standin_when_translated_gs_pso_failsgets itsE_INVALIDARGfromconsole_geometryon a synthetic blob, not from a missing mesh-shader capability as the name suggests, and nothing covers the mesh/topology arm in point 3.96e68a46, which GitHub reports as conflicting). #214 adds arms 14/15/16 in the samefallback_stream: its arm 14 uses(1..=4)and so keeps PATCH (4), where #303 turns PATCH into TRIANGLE because HS/DS are stripped; its arm 16 usespc_target_formatwhere #303 usespc_view_format(they differ only for B5G5R5A1/B4G4R4A4). Whichever lands second has to choose the semantics. My reading, not measured: keeping PATCH once HS/DS are stripped looks wrong.git merge-treeof #303 ontomainis clean.Not tested
0xc0000409or anamdxc64failure, so the guard is checked by tests, code reading and clean retail runs, not by watching it prevent a crash. (Context only, not this build: an earlier ~295 s menu run on another commit on this card ended0xc0000409inamdxc64.dllabout six seconds after a console VS/PS pair was logged.)main.AI use
Claude Code, Claude Sonnet 5.5: checked the numbers against the saved smoke blocks and test log, spot-checked the diff and the #214 diff, and wrote this text; it ran nothing. The builds, suite and smokes, and the first review pass, were done by omp with DeepSeek V4.1 Flash, which changed no code.
@DavidM1911 on GitHub · 2026-11-25 14:47 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1 real failure, deterministic (also fails--test-threads=1, 1104/1):The stand-in PSO path is creating the fallback pipeline twice instead of once. Needs a fix before merge.
— Devin
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.