D3D12.X: sanitize PATCH without HS and console topology types in graphics PSO fallbacks #3371
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3371"
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?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T10:54:58Z.
What is in it
Sanitize invalid or unsupported
PrimitiveTopologyTypevalues across all three graphics pipeline fallback and rewrite paths incrates/xcl/src/hle/d3d12x/real.rs(rebased ontomain3b6a91ed, preservingsanitize_integer_rt_blend(..., logic_op_supported())):fallback_streamnow handlesD3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY(subobject14), rewriting any topology type outsidePOINT/LINE/TRIANGLE(1..=3) — including consoleRECT_LIST_TYPE(19),UNDEFINED(0), andPATCH(4) afterfallback_streamstripsHS/DS— toD3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE(3).pc_topology_typenow checks whether the descriptor actually retains a non-empty Hull Shader (HS) and rewritesPATCH(4) withoutHS(for example afterstandin_graphicsorgraphics_psofallback stripsHS/DS) as well as console-only or undefined topology types toD3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE(3), keepingPATCHonly whenHSis present.rewrite_graphics_streamnow checkshas_hswhen validating subobject14(PRIMITIVE_TOPOLOGY), rewritingPATCHwithoutHSand any out-of-range/console topology type todefault_topo.hle::d3d12x::real::pso_topology_sanitize_testscoveringpc_topology_type,fallback_stream, andrewrite_graphics_streamwithPATCH(with and withoutHS), consoleRECT_LIST_TYPE(19), andUNDEFINED(0).Tested
hle::d3d12x::real::pso_topology_sanitize_testsfailed before the fix (PATCH without HS must become TRIANGLEand WARPCreateGraphicsPipelineStatereturningE_INVALIDARG(0x80070057) for aPATCHfallback desc) and passed after (2 passed, 0 failed).3b6a91ed:cargo test -p xcl --lib -- pso_blend_and_tsharp_tests::(8 passed, 0 failed, including logic-op tests from#2856).cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::with DXC 1.9 on NVIDIA GeForce RTX 5070 Ti, wave32):xcl --libpassed2575tests (including allpso_topology_sanitize_testsandpso_blend_and_tsharp_tests) and hit only the 4 pre-existingmain(3b6a91ed) geometry test failures (geometry_tests::msg_gs_done_emits_in_dxil,geometry_tests::gpu_geometry_msg_gs_done_records,lower_mem::stage_guard_tests::geometry_export_rejected,lower_geom::tests::gpu_epilogue_filters_oob_triangles_and_no_store_emits) fixed in#3411.Regression run
Not tested
CreatePipelineStatestreams withD3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCHor consoleRECT_LISTon AMD/Intel drivers (verified on WARP and RTX 5070 Ti only).test_title_runs_and_game_folder_is_untouchedanduma_driver::tests::were skipped in the workspace run; wave64 GPU tests were skipped on this wave32 RTX 5070 Ti.AI use
Assisted with locating the unsanitized topology type paths in
real.rs, drafting the fix and synthetic unit/WARP tests, rebasing ontomain, and running the test and smoke verification suite; all diffs and test results were reviewed directly.Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T12:57:17Z.
Ran the PSO topology sanitization tests at
c7705119on an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
Both tests pass on a real NVIDIA adapter:
PATCHwithout a hull shader and console-only/undefined topology types are rewritten to triangles in the three PSO fallback paths. The thread already reports a full suite on RTX 5070 Ti from the author; this adds an independent run on driver 32.0.16.2140 for the focused group. No title run was made.Not tested: a retail title, a paired smoke run, the full workspace suite here, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T14:21:06Z.
Re-ran the PSO topology sanitization tests at
8a21a4beafter the head moved fromc7705119; this is a new response in the same thread, not an edit of my earlier report: https://github.com/xcl-dev/xcl/pull/3371#issuecomment-7256182321Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
Both tests still pass at the new head:
PATCHwithout a hull shader and console-only/undefined topology types are rewritten to triangles. This adds the new head and driver 32.0.16.2140 as dimensions. No title run was made.Not tested: a retail title, a paired smoke run, the full workspace suite here, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:10:11Z.
merge-check
base:
d0832e614fhead:
8a21a4be2fmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (real.rs, +180/-4, mostly tests). It changes the default path: rect-list (19) and UNDEFINED (0) stream PSOs, refused as stand-ins on main and built during the title's call, now get stand-ins and build in the background; tessellation PSOs (HS + DS + PATCH), which failed to create on main, now give the title a dummy pipeline that draws nothing. Findings: (1) possible topology mismatch (from reading, not run).
ia_set_topology_xpasses patch-list topologies (33..=64) through unchanged, so the title's patch-list draws now run against a TRIANGLE-type dummy PSO, which D3D12 treats as invalid with undefined behaviour (~10137-10141, ~9939). The dummy VS emits one point, so the risk is driver behaviour rather than a visible picture. Remapping the IA topology for these draws, or saying how it was checked, would settle it. (2) The description doesn't mention the default-path change to rect-list / UNDEFINED PSOs. (3) AI use names no tool or model, no issue is linked, the commit area isd3d12x:(notD3D12.X:), and the test report skips two groups and has no ignored / SKIPPED counts. Fine: stripping HS/DS infallback_streammakes rewriting PATCH there correct, rect lists map to TRIANGLE asapply_topologymaps 17, and the tests fail on main and useskip_test.performance: 60 s smoke of a retail title, main
d0832e61vs this merge (245aa96c): 1516 -> 1679 frames shown (110 %; last presents per 2 s: 60 60 60), peak commit 18133 -> 17220 MB, 0 device removals, 0 crashes. The title doesn't show whether it draws with patch-list topologies or rect lists.verdict: safe to merge (finding 1 is worth settling: remap the IA topology for patch-list draws hitting the dummy TRIANGLE PSO, or say how it was checked)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T06:23:10Z.
merge-check claim
head:
8a21a4be2fImported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T06:39:50Z.
merge-check
base:
d0832e614fhead:
8a21a4be2fmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 2 failed, 51 ignored; 29 SKIPPED lines
failing: a_preparation_worker_keeps_a_split_programs_abi_whole
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: not yet: adds failing test(s): a_preparation_worker_keeps_a_split_programs_abi_whole
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 9939The stand-in and fallback PSOs now get TRIANGLE for a title's PATCH pipeline, but the draw-time IA topology isn't remapped.
apply_topologyin list_x.rs only maps RECT_LIST (17), so the title's N_CONTROL_POINT_PATCHLIST draws run on a TRIANGLE-type PSO. Before, a tessellation pipeline's stand-in failed to create. Now standin_stream, standin_graphics and the graphics_pso fallback (~8715) succeed, and the title's IASetPrimitiveTopology(PATCHLIST_3) + Draw no longer matches the PSO's PrimitiveTopologyType. That's invalid in D3D12: the debug layer reports it, and some drivers drop the draw or remove the device.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 10138Only half the HS<->PATCH rule is enforced.
pc_topology_typeleaves POINT/LINE/TRIANGLE unchanged when an HS is present, andrewrite_graphics_stream(~10710) has the same gap. A translated desc with HS+DS and PrimitiveTopologyType TRIANGLE (or a console type the PC enum maps into 1..=3) keeps TRIANGLE with an HS, and PC D3D12 rejects it with E_INVALIDARG. The PR describes this case ("keeping PATCH only when HS is present") as handled.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 10692In
rewrite_graphics_stream,has_hsusespayload_shader, which requires the HS bytes to be readable, but the HS subobject (type 4) still goes through the_ => out.rawarm unchanged. With an HS whose pointer is non-null but failsgpu::shader::readable(e.g. not yet mapped) and topology PATCH, has_hs is false and topology becomes TRIANGLE while the HS stays in the stream. The driver gets HS + TRIANGLE and rejects it, where before PATCH was kept and matched. The desc path (pc_topology_type) only checks pointer and length, so the two paths can disagree for the same HS. Usingshader_bytesin both would fix that.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 10137Not certain about this one:
pc_topology_typenow turns every PATCH without an HS into TRIANGLE, including VS + GS (patch input) pipelines with no tessellation, which D3D allows. Such a PSO built through the translated graphics_pso path (pc_topology_typeat ~8001, where GS is kept) used to keep PATCH. Now its GS input primitive no longer matches, and CreateGraphicsPipelineState fails for a pipeline that was valid.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:14:28Z.
Review: COMMENTED
Review of
8a21a4be: 4 finding(s). 4 are inline.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T17:52:12Z.
merge-check
base:
817eb1fc9fhead:
8a21a4be2fverdict: not yet: the workspace suite and retail smoke ended early on both builds. The changed fallback pipeline was verified on WARP and remains unverified on the AMD hardware.
Windows / AMD RDNA4 (native D3D12) — pipeline topology checks on
8a21a4bClean merge onto
mainat817eb1f(merge commit6b978c91197fc767eee3f2248e521778b2b2dfa2).git diff --checkwas clean.Setup
d3d12SDKLayers.dll, DXC 1.9.2609.5Tested
cargo build --workspacepassed.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputexited 101 on both builds.SKIPPEDnoticesmainCounts are partial because two test processes aborted on each build.
main— none observed in the comparable results.pso_topology_sanitize_tests::ran in isolation with--test-threads=1 --show-output: 2 passed, 0 failed, 0 ignored, 0 skip notices. This includes software WARP pipeline creation and descriptor normalization.uploads_start_from_each_subresources_statepassed on both builds.Shared failures and process aborts
fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_3, andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsreported failures on both builds.gpu_compute_e2etest processes exited with0xc0000409on both builds.Retail smoke
Ran
scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary>withXCL_UMA_DRIVER=mixedfor title hash2c508222.main0xc00004090xc0000409Diff review
The descriptor checks covered PATCH with and without hull shaders and normalization of RECT_LIST and UNDEFINED. The software pipeline check confirmed that WARP accepted the fallback descriptors.
Not tested
Remaining workspace tests after the aborts, retail frame performance, and creation and rendering of the changed fallback pipelines on the AMD hardware.
AI use
Codex (GPT-6) merged and built the PR, ran the tests, compared the results with
main, reviewed the diff, and drafted this report.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.