D3D12.X: fix RSSetDepthBiasX x64 ABI (INT depth bias and DepthClipEnable) #3223
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3223"
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-28T22:26:33Z.
Fixes two bugs in the
RSSetDepthBiasXcommand-list hook (list_x::set_depth_bias_x):DepthBias):RSSetDepthBiasXtakesINT DepthBias(32-bit signed integer inEDX), followed byFLOAT DepthBiasClamp(XMM2),FLOAT SlopeScaledDepthBias(XMM3), andBOOL DepthClipEnable(5th stack parameter). Previouslyset_depth_bias_xdeclareddepth_bias: f32, which read whatever value happened to be inXMM1instead ofEDX(causing garbage or non-finite values to be clamped/injected as depth bias).DepthClipEnableparameter dropped:DepthClipEnablewas omitted from the hook signature and never tracked. Because PCID3D12GraphicsCommandList9::RSSetDepthBiasdoes not changeDepthClipEnable, overrides whoseDepthClipEnablematches the bound PSO continue to use the zero-derivation nativeRSSetDepthBiaspath, while overrides that changeDepthClipEnableroute through the patched-PSO fallback (DepthBias::patch_descnow patchesRasterizerState.DepthClipEnableat offset0x1DC).What is in it
crates/xcl/src/hle/d3d12x/device_x.rs: addRASTERIZER_DEPTH_CLIP_ENABLE, optionaldepth_clip: Option<bool>onDepthBias,with_clip/bias_only/is_zero_bias/clip_matches, and read/patchDepthClipEnableinfrom_desc/patch_desc.crates/xcl/src/hle/d3d12x/list_x.rs: fixset_depth_bias_xsignature to(this, depth_bias: i32, depth_bias_clamp: f32, slope_scaled_depth_bias: f32, depth_clip_enable: i32), routeDepthClipEnablemismatches to the fallback PSO path inset_depth_bias_x/on_set_pipeline_state/KickoffX, and update/extend unit tests.Tested
cargo test -p xcl --lib depth_bias -- --nocaptureon Windows 11 / RTX 5070 Ti: 4 passed, 0 failed (depth_bias_patches_rasterizer_fields,depth_bias_state_tracks_fallback_and_clear,depth_bias_native_path_int_abi_depth_clip_and_list9_fallback,depth_bias_native_list9_and_bundle_fallback).Regression run
scripts/smoke.ps1pair (a commit ofmainand this head,3b7143f376) still has to be made.Not tested
cargo test --workspace -- --test-threads=4).xcl-smokepair yet).AI use
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T22:34:59Z.
Native pixel comparison at head
3b7143f376db53aa55ac6f40c6bc5f9c0f7d4f4f, GeForce RTX 5070, driver 616.92. The dynamic hook matched a static integer-bias PSO in all 16 pixels for each of five paired draws.The test called the slot-94 handler through an x64
extern "system" fn(list, i32, f32, f32, i32)pointer on a real command list. The flat triangle had z=0.5, a D16_UNORM depth buffer, LESS comparison, zero slope and clamp, and clipping enabled on both the base and the override. Eight pixels were inside the scissor. Each draw was fenced before reading its color target.All eight pixels outside the scissor retained the clear color on every draw. The synthetic fixture registered the base PSO metadata with the stock test helper and exercised the real List9 path. This covers the stated integer calling convention and its rasterized sign/magnitude. The fixture calls the handler directly and leaves guest vtable lookup, clip-changing PSO derivation and retail behavior unmeasured.
AI use: OpenAI Codex wrote the test-only fixture, ran the paired native draws and drafted this report.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:09:57Z.
Review (head
3b7143f3, diff read, not a merge-check: thePR descriptioncheck fails (no xcl-smoke blocks yet), so not built or run here):kickoff_x(list_x.rs~5468-5481) andreset_pc_inner(~6288) weren't updated: they usedepth_bias.unwrap_or(static_bias)withoutclip_matches/bias_only, andis_zero()can no longer be true, so a DepthClipEnable override is dropped after KickoffX andnative_biasis stored with the clip value set (redundant RSSetDepthBias on later binds). The description says KickoffX was handled; onlysplit_recordingwas.Some(~5564, ~5599). On main, RSSetDepthBiasX(0, 0, 0) let the next SetPipelineState apply the PSO's static bias; now it doesn't, and the test that checked main's behaviour was changed to callon_clear_stateinstead (~8893). On the non-dynamic and bundle paths (~1959, ~1966), every PSO bound after any RSSetDepthBiasX call now gets a derived PSO, up to the 1024 cap.shaders::pipeline_library(untouched; a rerun on the current base should clear it).Fine: offset 0x1DC is checked against
offset_of!, the int bias matches howfrom_desc/patch_descstore it,clip_matchestreatsNonecorrectly, and clip mismatches go to the fallback path inset_depth_bias_x,on_set_pipeline_stateandsplit_recording.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T16:42:29Z.
Test report (not a merge-check:
PR descriptionred)base:
b2b1f109d2head:
3b7143f376merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2901 passed, 1 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: test_title_runs_and_game_folder_is_untouched
review: not repeated here; my review of this same head is at https://github.com/xcl-dev/xcl/pull/3223#issuecomment-7301486669, and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run.
assessment: the end-to-end test fails with this PR merged and passes on main: in
test_title_runs_and_game_folder_is_untouched, the test title's check "D3D12.X: dynamic depth bias via RSSetDepthBiasX (#94)" reads top-right [0, 0, 255, 255] where it expects green (RSSetDepthBiasX(-1000.5) passing the depth test). This PR changes exactly the RSSetDepthBiasX x64 ABI (INT depth bias, DepthClipEnable), so the new argument handling no longer gives the bias the test title's call sets. Either the title's call uses the old layout or the new decoding is wrong; the test title's source (tests/testtitle) shows which. The rest of the suite passes, and the findings in my review standhardware / 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 Kalmarv on 2026-12-02T19:38:15Z.
Closing: unsourced ABI change with a failing e2e test on
mainand incompletekickoff_x/reset_pc_innercoverage.Pull request closed