Repository navigation
d3d12: exact depth bias through VK_EXT_depth_bias_control (D3D-325) - #2718
UlteriorMotive00 wants to merge 4 commits into
Conversation
|
Independent Windows/MSVC 19.44 run of I expanded the local test to 39 cases with positive and negative slopes, constant and slope terms together, and PSOs declaring an RTV that is left unbound at draw time while the DSV stays bound. All 9,984 depth texels matched the D3D formula exactly with This exercised the layer on test-created Vulkan devices on one NVIDIA driver. It did not test the standalone device's feature negotiation, another ICD, or Vulkan validation layers. |
|
Independent Windows test of 6d98f33 on Intel integrated GPU 8086:7D41, driver 32.0.101.9150, Windows 11 build 26300. Built d3d12_depth_bias_test with x64 MSVC/Ninja (RelWithDebInfo), then ran ctest --test-dir review-build -R "^d3d12_depth_bias$" -V. The driver reported depthBiasExact unavailable. All 15 readback comparisons still matched the D3D reference on the fallback path, including native D16_UNORM, native D24_UNORM_S8_UINT and D32_FLOAT at biases 0, +1, +3, -5 and +1000. CTest passed 1/1 with zero fixture failures. This adds Intel fallback coverage alongside the RTX exact-path result above. AI-assisted testing and report. |
|
Thanks @duudiis, that's a much wider check than mine. On the gap you named (the standalone device's negotiation), I pushed Ran
That covers the standalone path's device creation, not draws through it. AI-assisted. |
|
Tested
AI-assisted. |
D3D's DepthBias is exactly one step of the depth format. Vulkan lets a fixed-point attachment's step be up to twice that unless the pipeline asks for depthBiasExact, and the RTX 5070 (617.42) uses twice: D24 +3 stored as +6, +1000 as +2000, and the same on D16. Where the GPU has VK_EXT_depth_bias_control with depthBiasExact, the standalone device (and the test device) enable it, VulkanDeviceInfo carries depth_bias_exact, and each PSO with a bias chains VkDepthBiasRepresentationInfoEXT (FORMAT representation, exact) from its recipe, so draw-time variants keep it. d3d12_depth_bias_test draws flat triangles with DepthBias 0, +1, +3, -5, +1000 into D16, D24S8 and D32F targets and compares stored depth with D3D's formula; without the extension it reports what the device does. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like the other optional features the standalone device negotiates, a GPU without VK_EXT_depth_bias_control's depthBiasExact is named once, since its fixed-point DepthBias then stays the driver's (up to 2x D3D's). AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ulkan_replay.h locals (C4459) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ef931e0 to
37ac244
Compare
ItsNotRexed#3797 (D3D-309) adds its own test/glsl/vs_depth.vert and a generated/vs_depth.spv rule; a second rule for the same output is a CMake error, so this test's shader gets its own name and its CMake block sits elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto
Thanks @duudiis, @yasaiiko and @gkissel for the runs on Turing, Intel and a second RTX 5070. Tested on
AI-assisted (Claude Code). |
D3D-325 (finding, listed). Depends on: none (based on
main49475796).What and why
D3D's
DepthBiasis exactly one step of the depth format:ris "the minimum representable value > 0 in the depth-buffer format", so 1 / (2^n - 1) for an n-bit UNORM, and 2^(exponent(z) - 23) forD32_FLOAT. Vulkan lets a fixed-point attachment'srbe anywhere up to twice that unless the pipeline setsVkDepthBiasRepresentationInfoEXT::depthBiasExact. The RTX 5070 uses twice. On nativeD24_UNORM_S8_UINTa flat draw stored +6 / -10 / +2000 steps forDepthBias+3 / -5 / +1000, andD16_UNORMbehaves the same way. Shadow-map and decal biases on D16/D24 targets would land at double what the game set.Changes
VulkanDeviceInfo::depth_bias_exact:VK_EXT_depth_bias_controlwithdepthBiasControlanddepthBiasExactis enabled on the device.leastRepresentableValueForceUnormRepresentationandfloatRepresentationstay off; they aren't needed).vktest::Devicedoes the same and reportsdepth_bias_exact.create_graphics: a PSO with a bias chainsVkDepthBiasRepresentationInfoEXT { LEAST_REPRESENTABLE_VALUE_FORMAT, depthBiasExact = VK_TRUE }into its rasterization state. The struct lives in the PSO'sRecipe, next to therasterit hangs from, so draw-time variants (build(unbound)) keep it. The recipe is only ever used by reference.docs/d3d12_vulkan.md: a "Exact depth bias" item next to the PSO feature list.Tests
New
d3d12_depth_bias_test(CTestd3d12_depth_bias, synthetic, no game files). A flat full-screen triangle (newtest/glsl/vs_depth.vert) at a depth on one of the format's steps (so no rounding tie decides the code) is drawn withDepthFuncALWAYS andDepthBias0, +1, +3, -5, +1000 intoD16_UNORM,D24_UNORM_S8_UINTandD32_FLOAT. Stored depth is read back through a footprint and compared with D3D's formula. WithoutdepthBiasExactthe test prints what the device does (INFO) instead of failing. D24 is skipped where the layer stores it as D32 (no D24 on the GPU), because that path's bias is D3D-309's.Tested on Windows 11 Home 26300, MSVC 14.44 (VS 2022 Build Tools), Ninja RelWithDebInfo via
scripts/build_runtime.ps1:depthBiasExactavailable), withLEONIDA_VK_VALIDATION=1: 15/15 exact. D16 and D24 +0/+1/+3/-5/+1000 steps; D32F 0.375 → 0.37500003 / 0.375000089 / 0.374999851 / 0.375029802 for +1/+3/-5/+1000.VK_EXT_depth_bias_control), with validation: D32F exact. D16 reportsINFO+2/+6/-10/+2000 steps (the driver's 2x, which this PR can't change there). D24 is skipped (stored as D32).ctest: 125/125 on both GPUs.Not covered
VK_EXT_depth_bias_controlhere, so its fixed-point bias stays at 2x on D16. A fallback would need the device'srmeasured once (a probe draw) and the constant factor halved; I can file that as a finding if it's wanted. AMD's D24 is stored as D32, so it falls under D3D-309, not this.r, so it isn't affected. Not separately tested here.AI-assisted: yes.
🤖 Generated with Claude Code