Skip to content

startup: clear depth and stencil views (command-list slot 51) - #1806

Closed
tedin7 wants to merge 2 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-slot51-cleards
Closed

tedin7 wants to merge 2 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-slot51-cleards

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Refs #870.

Adds the missing command-list slot 51, ClearDepthStencilView. On main slot 51 has no handler, so it falls through to the x2w-noop stand-in: since #1701 a depth view is bound by slot 50, but nothing ever clears it on the desktop list, and a depth test then runs against whatever the new texture holds.

Slot 51 is DERIVED

Desktop ClearDepthStencilView is slot 47; the console list is shifted by four from slot 28 up. Slots 50 (OMSetRenderTargets, 46 + 4) and 52 (ClearRenderTargetView, 48 + 4) are observed at that offset, and 51 sits between them. It has not been seen in a title log; the first run past the menus will show whether it is called (x2w-render list slots per frame).

Change

  • src/startup_stubs/list_clear_depth.h (plain C++, no Windows types): which clears are forwarded. Unknown flag bits and the stencil bit of a format without a stencil plane are dropped; no plane left is "nothing to clear" (not counted); a depth that is not a number in [0, 1], a cleared plane that the view marks read-only, and unreadable rectangles are refused, because the desktop list would report an error for them.
  • list_clear_depth in d3d12_xs_device.cpp, modelled on list_clear_target: resolves the view through its shadow record (resolve_view(desktop, 21)), moves the resource to DEPTH_WRITE, calls the desktop ClearDepthStencilView, adds to clears in the totals line, logs the first four calls. A view that holds nothing adds to the unresolved count of x2w_d3d12_render_target_stats as in startup: bind single-range RTVs, clear copied views, count unresolved #1701; other refusals add to the new x2w_d3d12_depth_clear_stats(forwarded, refused).
  • The depth value is the fourth argument, so it arrives in xmm3; the generic noop_slot entry takes integer registers and would lose it. With X2W_D3D12_LIST_NOOP=1 in render mode the list table therefore points slot 51 at the handler itself (one line after the render_mode() block, not in the list_typed run). The handler keeps the per-slot call counts; a frame trace and a capture do not see slot 51.
  • Edits to the device file: one include, two counters, the export, the handler, one table line.

Tests (all source-built, no title data)

  • list_clear_depth_check: 24 cases of the decision, no device. --mutate keep-stencil and --mutate allow-read-only are registered with WILL_FAIL and fail as required.
  • startup_depth_clear_{warp,hardware}: a 4x4 D32_FLOAT_S8X24_UINT texture, a DSV heap with a writable view, a depth-read-only view, an empty slot and a stencil-read-only view. Each case is submitted and both planes are read back: both planes (0.75 / 0x11); depth only with a junk stencil argument (stencil unchanged); stencil only with a junk depth argument (depth unchanged); depth with one rectangle (only the rectangle changes); then depth 1.5, NaN, a read-only depth plane, a read-only stencil plane, unreadable rectangles and the empty view (nothing changes, 5 refusals and 1 unresolved counted), flags 0 (not counted), and a call on the closed list (ignored). Negative control: the planes are read once before any clear, and the test fails if they already hold what the first clear writes. The debug layer is on and must store no errors.
  • I chose a direct readback over a draw at 0.5 with LESS: it checks the cleared value itself and does not touch startup_stream_depth*, which startup: pass OMSetStencilRef (slot 24) to the desktop list #1787 also edits. A draw-based depth-reject case can follow.

Verified (Linux only)

Not run

  • Windows: d3d12_xs_device.cpp and startup_depth_clear were not compiled or run here. The Windows Server 2025 / WARP run of ctest -R "^(startup_depth_clear_|list_clear_depth)" is the remaining check.
  • No run with a title: whether slot 51 is called, with this argument order, is exactly what stays unknown.
  • Known limit (in the docs): a clear through a writable view of a resource that an earlier bind in the same recording holds as DEPTH_READ moves it to DEPTH_WRITE.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Closing this draft for now to help keep the open PR queue manageable; the branch stays preserved on the fork so it can be reopened once the queue clears.

@tedin7 tedin7 closed this Nov 24, 2026
@tedin7 tedin7 reopened this Nov 24, 2026
@tedin7
tedin7 marked this pull request as ready for review November 24, 2026 21:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T22:01:54.361312Z a3da298 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3da298921

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/startup_stubs/d3d12_xs_device.cpp Resolved
Comment thread src/startup_stubs/d3d12_xs_device.cpp Resolved
@tedin7
tedin7 force-pushed the x2w-frontier-slot51-cleards branch from 05efb49 to ab828ad Compare November 25, 2026 08:27
@Makto94

Makto94 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

First Windows build and run of this PR reported here, at head ab828adf (the body says it was not compiled or run on Windows).

Environment: NVIDIA GeForce RTX 3070 Ti (10de:2482), driver 32.0.16.2101, Windows 11 build 26300.9974, Debug build, x2w-d3d12 debug layer: 0x00000000 enabled, serial (-j1); the hardware run was on an idle machine; 0 capability skips (77).

Commands: ctest --preset dev --no-tests=error -j1 -R 'depth_clear|list_clear_depth' -E '_hardware$' -V (4/4 passed: startup_depth_clear_warp, list_clear_depth, and the two WILL_FAIL controls keep-stencil and allow-read-only, which fail as required) and ctest --preset dev --no-tests=error -j1 -R '^startup_depth_clear_hardware$' -V (passed).

startup_depth_clear_hardware on the RTX reads back both planes after each case:

  • 1 both planes: depth 0.750 at (0,0) and (3,3), stencil 11 (expected 0.750, 11)
  • 2 depth only: 0.250, stencil 11 unchanged
  • 3 stencil only: depth 0.250 unchanged, stencil 5a
  • 4 rectangle: (0,0) 0.500, (3,3) 0.250 untouched
  • 5 refusals: forwarded +0, refused +5, unresolved +1, planes unchanged
  • 0 and 6: nothing counted; before-clear control reads depth 0.000, stencil 00
  • device removed reason: 0x00000000, debug layer errors: 0

The startup_depth_clear_warp log is the same, with Microsoft Basic Render Driver. Each of the two logs (WARP and RTX) also shows four debug-layer id=821 warnings (severity 2, "clear values do not match those passed to resource creation"); they are not errors and the test counts 0 errors. The line ClearDepthStencilView skipped: view ... is not a known depth stencil view is the intended empty-view case (the test's case 5 lists "the empty view" and expects unresolved +1).

Slot 51 is still derived from the neighbouring slots, not observed in a captured log; this run does not change that.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you for the first Windows run.

Your run was at ab828adf, which is the current head, so the result applies to this PR as it stands.

  • The 4/4 WARP/list tests and startup_depth_clear_hardware on the RTX 3070 Ti all pass, with 0 capability skips, no device removal and 0 debug-layer errors.
  • The hardware readback matches the WARP readback case by case, so the clear behaviour is confirmed on a real GPU.
  • The id=821 warnings (clear value differs from the one given at resource creation) are warnings only. The test counts 0 errors, so no change is needed.
  • The ClearDepthStencilView skipped line is the intended empty-view case (case 5, unresolved +1).
  • Slot 51 is still derived from the neighbouring slots and not seen in a captured log. This run does not change that, and the PR text already says so.

No code change is needed.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is.

We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here.

AI-assisted; commands listed were executed locally.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants