Skip to content

d3d12: preserve float DepthBias in RASTERIZER1 and RASTERIZER2 streams - #806

Open
kotekompotek wants to merge 1 commit into
ProjectLeonida:mainfrom
kotekompotek:work/d3d12-rasterizer-float-depth-bias
Open

kotekompotek wants to merge 1 commit into
ProjectLeonida:mainfrom
kotekompotek:work/d3d12-rasterizer-float-depth-bias

Conversation

@kotekompotek

@kotekompotek kotekompotek commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D-RASTERIZER-FLOAT-BIAS (#14 (comment))

What and why

  • Rebased onto current main.
  • Preserved FLOAT DepthBias in RASTERIZER1 and RASTERIZER2 pipeline streams (runtime/shims/d3d12_vulkan_device.cpp and runtime/src/depth24_fragment.h).
  • Updated runtime/test/d3d12_bundle_test.cpp (Vertex input layout order/formats, SubTopology triangle topology, CullMode = D3D12_CULL_MODE_NONE, 64x64 DXGI_FORMAT_D24_UNORM_S8_UINT depth buffer + GREATER depth test comparing 1.5f vs 0.0f for RASTERIZER1/RASTERIZER2), added depth24_bias_constant unit assertions in runtime/test/d3d12_d24_support_test.cpp, and synced docs/d3d12_vulkan.md.

Tested

  • Built d3d12_com_test and d3d12_d24_support_test and ran d3d12_com & d3d12_d24_support (2/2 Passed on NVIDIA GeForce GTX 1050).
  • Ran tests/test_ctest_registration.py (4/4 OK).
  • Note: d3d12_bundle_test was not compiled locally because glslangValidator is absent in this environment.

GPUs tested: NVIDIA GeForce GTX 1050 (driver 582.28, Windows)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

@KernelSmoker KernelSmoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux review of the stream-to-rasterizer path only. The parser retains the original float for RASTERIZER1/2, and create_graphics uses it for both the D24 fragment-bias conversion and Vulkan rasterizer bias; legacy/base rasterizer descriptions still use their integer field. I found no issue in those paths by inspection.

I could not run d3d12_bundle_test on this Bazzite host: CMake builds that target only for Windows, and the local Vulkan device creation currently fails. The Windows hosted check is still queued, so this is not a test-pass report.

@kotekompotek
kotekompotek force-pushed the work/d3d12-rasterizer-float-depth-bias branch from e8b8ca5 to 278cc0f Compare November 24, 2026 15:13
@moffington

Copy link
Copy Markdown
Contributor

I was able to run d3d12_bundle_test on RTX 3060 / Linux / Wine with Vulkan validation enabled at 278cc0fa.

The new RASTERIZER2 test fails at line 802 because the pipeline stream omits D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY (primitive topology type not supported: 0). The merge-base test passes.

Additionally, the new test has no depth target or depth-bias assertion, so it wouldn't catch a regression to integer truncation even after fixing pipeline creation.

Independent depth-buffer readback probes confirmed that fractional and negative biases (+0.5, -0.5, -2.5) are preserved across D16_UNORM, D24_UNORM_S8_UINT and D32_FLOAT on HEAD, whereas baseline truncates them. No new Vulkan validation errors observed.

The runtime implementation looks good. Could the regression test include the topology subobject and verify biased depth readback or depth-test behavior?

@Timon360SB

Copy link
Copy Markdown
Contributor

Independent testing results

Reproduced the RASTERIZER2 pipeline creation failure
reported previously by @moffington, this time on two
native Windows 11 systems with different NVIDIA GPU
architectures.

Tested revisions

  • BASE: f3e26be7c661e97eb4c70464e675a3b32dc149e3
  • HEAD: 278cc0fa6c010cd52ba6919adac90fb3ad165c23

Test environments

Component System 1 System 2
CPU AMD Ryzen 7 7800X3D AMD Ryzen 5 3600X
GPU NVIDIA GeForce RTX 5070 NVIDIA GeForce RTX 2060 SUPER
Architecture Blackwell Turing
VRAM 12227 MiB 8192 MiB
RAM (reported) 31.11 GiB 15.93 GiB
GPU driver 621.14 621.14
OS Windows 11 Pro (26200) Windows 11 Pro (28000)
Windows SDK 10.0.26100.0 10.0.28000.0
Vulkan SDK 1.4.363.0 1.4.363.0
MSVC 19.44.35230 19.44.35230
Resizable BAR Enabled Disabled

Test configuration

  • Build configuration: RelWithDebInfo
  • Build generator: Ninja Multi-Config
  • Build scope: selected targets
  • Vulkan validation: enabled
  • GPU-assisted validation: enabled
  • Synchronization validation: enabled
  • Repetitions: 3 per revision on each system
  • Total queue attempts: 3
  • Synthetic fixtures only

Both revisions compiled successfully on both systems.

CTest results

Initial attempt:

Test RTX 5070 BASE RTX 5070 HEAD RTX 2060 SUPER BASE RTX 2060 SUPER HEAD
d3d12_bundle 3/3 0/3 3/3 0/3
d3d12_com 3/3 3/3 3/3 3/3
d3d12_d24_support 3/3 3/3 3/3 3/3
d3d12_state_sweep 3/3 3/3 3/3 3/3
vk_sync_validation 3/3 3/3 3/3 3/3
Total PASS 15/15 12/15 15/15 12/15

Failure reproducibility

Two additional attempts were performed on both systems.

Successful BASE checkpoints were reused, while HEAD
tests were executed again. Reused BASE results are
not counted as independent executions.

Test RTX 5070 HEAD RTX 2060 SUPER HEAD
d3d12_bundle 0/9 0/9
d3d12_com 9/9 9/9
d3d12_d24_support 9/9 9/9
d3d12_state_sweep 9/9 9/9
vk_sync_validation 9/9 9/9
Total PASS 36/45 36/45

Actual executions, excluding reused checkpoints:

  • BASE: 30/30 PASS
  • HEAD: 72/90 PASS
  • Combined: 102/120 PASS
  • FAIL: 18
  • SKIP: 0

The d3d12_bundle failure reproduced in all 18 HEAD
executions across both hardware configurations.

RASTERIZER2 pipeline creation failure

All failing executions reported the same diagnostic:

@aslan2142 aslan2142 added the missing claim Needs a claim in #14 label Nov 24, 2026
@kotekompotek
kotekompotek force-pushed the work/d3d12-rasterizer-float-depth-bias branch from 278cc0f to dbc475a Compare November 24, 2026 17:28
@kotekompotek

Copy link
Copy Markdown
Contributor Author

@Timon360SB @moffington Thanks for the detailed testing and catches — updated in dbc475a4f:

  • Updated runtime/test/d3d12_bundle_test.cpp: fixed the Vertex input layout order/formats, added SubTopology triangle topology, set CullMode = D3D12_CULL_MODE_NONE, and added a 64x64 DXGI_FORMAT_D24_UNORM_S8_UINT depth buffer + GREATER depth test comparing 1.5f vs 0.0f for both RASTERIZER1 and RASTERIZER2.
  • Added depth24_bias_constant unit assertions in runtime/test/d3d12_d24_support_test.cpp.
  • Claimed D3D-RASTERIZER-FLOAT-BIAS in coordination issue #14: Coordinating who works on what #14 (comment)

Locally verified:

  • d3d12_com & d3d12_d24_support: 2/2 Passed on NVIDIA GeForce GTX 1050
  • test_ctest_registration.py: 4/4 OK
  • Note: d3d12_bundle_test was not compiled locally because glslangValidator is absent in this environment.

@aslan2142 aslan2142 removed the missing claim Needs a claim in #14 label Nov 24, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@kotekompotek
kotekompotek force-pushed the work/d3d12-rasterizer-float-depth-bias branch from dbc475a to ab87f83 Compare November 25, 2026 06:39
@kotekompotek

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (42537e7b6) as ab87f836f. The stream parser and create_graphics now carry both StencilFaceMasks (per-face stencil, from main) and this PR's GraphicsStreamExtras (has_float_depth_bias/depth_bias), and Depth24Bias keeps the float constant together with main's levels field (packed16 fallback keeps its 65535.0f level count).

Verified locally on Windows / MSVC Debug (GTX 1050, driver 582.28): pso_stream, d3d12_com, d3d12_d24_support pass; d3d12_vulkan_device and d3d12_close_parity build clean and show only the two pre-existing main failures on this machine (the CreateHeap invalid-argument column and the three CopyTextureRegion WARP-annotation rows — unrelated to this change). d3d12_bundle_test is not built here (no glslangValidator/llvm-mc).

AI-assisted.

@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@kotekompotek

Copy link
Copy Markdown
Contributor Author

Note on the red jobs at this head: both failures are baseline, not this diff — linux-gpu-tools cs_imgatomic_ext (6/64 sint words, llvmpipe) and windows vk_xdxr_postbuild_readback (prints "skipped" but exits nonzero) fail identically on every PR rebased after ~15:00 UTC, including merged #808's own checks. Reported in #1608. Locally (GTX 1050, MSVC Debug) the tests this change touches pass.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 26, 2026
@Tauwni

Tauwni commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

@kotekompotek heads-up from RT-STATE-AUDIT-PIPELINE (issue #2464, part B): this PR is listed there for the fractional RASTERIZER1/2 depth bias (d3d12_vulkan_device.cpp still does r.DepthBias = INT(bias) on main 2859d0c9b), but it carries needs rebase and conflicts with main. Once it's updated, I can run it on a Mac (Apple M3, MoltenVK, KosmicKrisp and llvmpipe, and the d3d12 tests under Wine) and report here.

AI-assisted (Claude Code, Claude Opus 5.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants