d3d12: forward ClearDepthStencilView on console command lists #2443
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2451"
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 R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T17:07:45Z.
Description
Implements
CommandListslot 51 (ClearDepthStencilView) on console command lists ind3d12_xs.dll.Details
tables[list_kind][51]andlist_typed[51], preserving x64 float parameter delivery (XMM3forDepth).view_target(handle, 21)).D3D12_DSV_FLAG_READ_ONLY_DEPTH, and stencil clears onD3D12_DSV_FLAG_READ_ONLY_STENCIL.D3D12_CLEAR_FLAG_STENCILif target format lacks a stencil plane.rect_countand bounds readability.D3D12_RESOURCE_STATE_DEPTH_WRITEon the desktop command list.render_clearsandrender_target_unresolveddiagnostic counters.Test Coverage
Added synthetic test
tests/startup_clear_depth_stencil.cpp:ClearDepthStencilViewon 1x1 depth surface with depth 0.25f.ClearDepthStencilViewon 2x2 depth surface with depth 0.75f and explicit rect.GetDeviceRemovedReason() == S_OKand 0 debug layer errors on both WARP and physical hardware.Evidence
Observed:
Release build:
Observed:
Environment:
Build commit
Head commit:
248f9151(d3d12: document why slot 51 is set in both table paths), based onb312f9da(d3d12: forward ClearDepthStencilView on console command lists). All test runs above were executed againstb312f9da; the comment-only commit does not change behavior.Reviewer notes
origin/main..248f9151contains only the ClearDepthStencilView change (d3d12_xs_device.cpp,tests/startup_clear_depth_stencil.cpp, its CMake entry). The slot 70 unplaced-buffer commits are onmainnow and are not part of this PR.tables[list_kind][51]is set directly unlike siblings 52-55; explained with a one-line comment inbuild_tables()(the fixture calls list vtable[51] directly viainvoke(), so the slot must be reachable through both paths).upstream-sync referenced this pull request2026-11-25 18:01:14 +00:00
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:22:58Z.
Review: COMMENTED
Review of head
b312f9da(comment only, no Windows run on my side).Issue 1 (scope): this branch carries other work.
git log origin/main..HEADshows 4 commits, and only the last one is the ClearDepthStencilView change:d97f04abd3d12: support unplaced buffer memory SRVs in device slot 700bc0b2b8Merge branch 'gpu/slot70-unplaced-buffer-backing'87a23b30d3d12: reject unplaced buffer memory SRVs overlapping live resourcesb312f9dad3d12: forward ClearDepthStencilView on console command listsThe first three are the content of open PR #2395. In the diff that is about 180 lines in
src/startup_stubs/d3d12_memory_srv.inl, the helpers inmemory_srv_buffer.h, theclear_unplaced_buffershook inrelease(), two mutation controls inCMakeLists.txt, and a docs section. None of it is in the title or body. Same shape as #2473 from the same author.Fix: rebase after #2395 merges, or drop those three commits so the diff is only slot 51 (
d3d12_xs_device.cpp,tests/startup_clear_depth_stencil.cpp, its CMake entry).Issue 2 (possible duplicate): list slot 51 was already proposed in #1806 ("startup: clear depth and stencil views (command-list slot 51)", closed, not merged). Main has no slot 51 handler today, so this is not a conflict with merged code. A maintainer should decide whether #1806 and this PR cover the same slice before either goes on.
Issue 3 (Windows results): the body has no head SHA and no build commit. The dev and release numbers in the body cannot be tied to
b312f9da. Please state the commit those runs used.What looks fine
list_clear_depth_stencilfollows the siblinglist_clear_target(slot 52): shadow-record view lookup viaresolve_view(desktop, 21), transition to DEPTH_WRITE,render_clearsandrender_target_unresolvedcounters.tables[list_kind][51]is also set directly, which the sibling slots 52 to 55 do not do. Harmless, but worth a one-line reason in the code if it is needed.docs/startup-runtime.mdchanges in this diff belong to the slot 70 commits only.Commands run locally (Linux)
python3 tests/docs_links_check.py-> passed (19 files, 464 links)python3 tests/bidi_controls_check.py-> passedgit diff --check origin/main...HEAD-> cleanAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:51:41Z.
Review: COMMENTED
Review of head
282bdaa6against current main (comment review, no approval).What I checked
list_clear_depth_stencil(slot 51) insrc/startup_stubs/d3d12_xs_device.cpp: it follows the siblinglist_clear_target(slot 52). The view is resolved from the shadow record, with the creation map fallback now enabled for slot 21 inresolve_view. Zero flags, read-only depth, read-only stencil and unreadable rect arrays are all refused before the call. The target is moved to DEPTH_WRITE before the clear.list_typed[51]andtables[list_kind][51]are both set, and the comment explains why. Thedepthfloat is a typed parameter, so x64 delivery stays correct.Non-blocking coverage gaps (also raised in the thread by ChazY11)
tests/startup_clear_depth_stencil.cppbuilds only a read-only-depth view (line 254). The read-only-stencil guard is never exercised, so removing it is not caught.if (!flags) return;that follows it are not pinned. A follow-up with one case each would close this.Linux commands run in a worktree of the head:
python3 tests/docs_links_check.pypasses.python3 tests/bidi_controls_check.pypasses.git diff --check origin/main...HEADis clean.Not run: Linux cannot build or run the D3D12 fixture, so I did not mutate the code myself. I rely on the Windows CI run and the contributor receipts in the thread.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T20:12:44Z.
Built and run here: 2/2 pass on WARP and a physical GPU; five mutations, two caught, three survivors — and one of my earlier runs was void, so here is the corrected set
First, a correction about my own method, because it produced three bogus results before I noticed: I tried
$s.Replace(old, new, 1)in PowerShell, which has no such overload, so the mutated text was never written, the buildfailed, and the harness dutifully reported "caught" for all three. Those rows are void. The set below was produced with a
single-occurrence substring splice and a build check on every iteration.
Five mutations of
list_clear_depth_stencil!(flags & (DEPTH | STENCIL))→false)READ_ONLY_DEPTHview acceptedREAD_ONLY_STENCILview acceptedSTENCILbit is no longer dropped when the format has no stencilif (!flags) return;→if (false) return;)The two catches are the important pair: both are cases where passing the call through would make the driver raise a
debug-layer error rather than return something wrong, and the fixture pins them.
The third one is the asymmetric survivor, and it is worth a look: depth-on-read-only is caught, stencil-on-read-only is
not. The two guards are written identically twenty lines apart
so a fixture that creates one read-only-depth view and one read-only-stencil view would cover both — or, if the intent
is that a read-only stencil view cannot exist without a read-only depth view, say so in a comment and the asymmetry is
explained rather than accidental.
The fourth and fifth are the "format has no stencil" normalisation: clearing stencil on an
R32_FLOATDSV drops the bitand then returns if nothing is left. Neither the drop nor the subsequent return is asserted, so the fixture never clears
stencil on a stencil-less format. One case each would pin them, and the pair matters together — dropping the bit without
the early return would issue a depth-only clear when the caller asked for both.
What I did not do
I did not read
tests/startup_clear_depth_stencil.cpp(331 lines) closely enough to say which rect-count anddsv_flagscombinations it builds; the survivors above are states the file demonstrably does not reach, not states Iread it to exclude. If a stencil-less-format case is already there and my mutation is inert for another reason, tell me
and I will re-check rather than leave the claim standing.
Environment
Windows 11 build 26300.9974; WARP and the installed physical GPU;
startup_clear_depth_stencilbuilt withcmake --build --preset dev --target …. Each mutation was built (build verified separately from the test result),run, reverted and rebuilt; final state 2/2 green.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-25T20:34:03Z.
Rebased onto current main (
99af3da0), dropping the three slot 70 backing commits (d97f04ab,0bc0b2b8,87a23b30) and resolving theCMakeLists.txtconflict with merged #2473.The branch now carries only the two topic commits (
76f7d8aeand282bdaa6).Commit
282bdaa6adds the comment explaining whytables[list_kind][51]is populated alongsidelist_typed[51](the test fixture exercises direct vtable slot invocation viainvoke()).Windows Verification
282bdaa6GetDeviceRemovedReason() == S_OK).Dev (
--preset dev):Release (
--preset release):Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-25T20:47:49Z.
Hardware run at head
282bdaa6(build exit code 0).Environment: NVIDIA GeForce RTX 3070 Ti, driver 32.0.16.2101 (NVIDIA 621.01) and Windows 11 Pro build 26300.9974 as reported by the system,
devpreset (MSVC). The runs were serial (-j1). The debug layer was enabled (x2w-d3d12 debug layer: 0x00000000 enabled).Command:
ctest --preset dev --no-tests=error -j1 -V -R '^startup_clear_depth_stencil'Result: 2/2 passed, 0 failed (
startup_clear_depth_stencil_warpandstartup_clear_depth_stencil_hardware). 0 capability skips (77).startup_clear_depth_stencil_hardware(test 302) printsadapter=NVIDIA GeForce RTX 3070 Ti:1 valid clear of A to 0.25: refused +0 (expected +0)2 valid clear of B with rect to 0.75: refused +0 (expected +0)3 read-only DSV clear refusal: refused +0 (expected +0)4 RTV handle passed as DSV (wrong kind): refused +1 (expected +1)5 empty descriptor handle: refused +1 (expected +1)6 zero clear flags: refused +0 (expected +0)7 A depth: 0.2500 (expected 0.2500)8 B[0]–B[3]: eachdepth: 0.7500 (expected 0.7500)device removed reason: 0x00000000, debug layer errors: 0The WARP run (test 301,
adapter=Microsoft Basic Render Driver) prints the same values for lines 1-8 and the same final line.For information: in both tests the debug layer prints 2 messages with
sev=2 id=821(ClearDepthStencilView: The clear values do not match those passed to resource creation). They do not count as errors in thedebug layer errors: 0line.This run covers NVIDIA and WARP only. Not covered: any test outside the filter above.