D3D12.X: a bias set by RSSetDepthBiasX is lost when the next pipeline is bound (dynamic depth bias) #3771
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 fromthemoonx on 2026-12-03T06:19:07Z.
A depth bias set with
RSSetDepthBiasXis lost when the title binds another pipeline afterwards. The next draws use the new pipeline's own bias. This happens on GPUs with dynamic depth bias (DynamicDepthBiasSupported); the patched-pipeline fallback keeps the bias.XCL means to keep it:
on_set_pipeline_state(list_x.rs) takess.depth_bias.unwrap_or(static_bias)as the bias after a bind.Cause
on_set_pipeline_stateruns after the nativeSetPipelineState. It sendsRSSetDepthBiasonly when the wanted bias differs fromnative_bias, the last one XCL sent. But the nativeSetPipelineStatehas just set the new pipeline's own bias, sonative_biasis out of date. The wanted bias equals it, and nothing is sent.Measured
I drew a triangle into a D16 depth buffer and read the depth back. The numbers are the offset from a draw without bias. All pipelines have
D3D12_PIPELINE_STATE_FLAG_DYNAMIC_DEPTH_BIAS. A and B have a bias of 0, C has 3.16c2fd08The plain D3D12 columns use no XCL code, so the reset comes from D3D12 itself.
A fix that worked here
In
on_set_pipeline_state, in theSome((true, static_bias))arm, before the comparison:depth_bias_native_path_exact_f32_and_list9_fallbackthen fails at its check after the bind ofpso_dyn_zero. It expects a call that sends 0, which is no longer needed because the bind already did that. The other threedepth_biastests pass. I did not run the whole suite with the line.static_bias.for_dsv(device_x::base_dsv_format(effective)).bind_pipeline_exact, for example at a draw when the pipeline was not ready before). From reading the code, those binds reset the bias too. I did not test them.Not known
I am not opening a PR now, because a runtime change needs a regression run on a retail title. Anyone who can make one is welcome to take this.
Windows 11 Pro 26300, RTX 3060 12 GB (610.88). Found while checking #2858. AI use: Claude Code, Claude Opus 5.5 (found it, wrote the test and this text).