Skip to content

d3d12: depth bounds and back-face stencil masks in a stream's pipeline keys (RT-STATE-PIPELINE-KEY-DS2) - #2477

Open
Tyrannys wants to merge 2 commits into
ProjectLeonida:mainfrom
Tyrannys:claude/pipeline-key-ds2
Open

Tyrannys wants to merge 2 commits into
ProjectLeonida:mainfrom
Tyrannys:claude/pipeline-key-ds2

Conversation

@Tyrannys

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-STATE-PIPELINE-KEY-DS2 (#1608 (comment)), item 5 of @kevincommits' RT-STATE-AUDIT-PIPELINE finding (#2464 Part B, #1608 (comment)). Thanks to kevincommits for finding it.

What and why

A pipeline state stream (ID3D12Device2::CreatePipelineState) can carry state that the plain D3D12_GRAPHICS_PIPELINE_STATE_DESC cannot hold: DEPTH_STENCIL1/DEPTH_STENCIL2's DepthBoundsTestEnable, and DEPTH_STENCIL2's per-face stencil masks. parse_pipeline_stream keeps them beside the description (PipelineStream::depth_bounds, back_masks/back_stencil), and create_graphics builds from them. But the keys were made from the description alone:

So two streams that differ only in the depth-bounds flag, or only in the back face's stencil masks, got the same key, and the order log and prewarm plan mixed the two pipelines up.

stream_graphics_key(stream) (runtime/shims/d3d12_vulkan_device.cpp) is now the graphics key of a stream. It folds in the depth-bounds flag, and the back face's masks when they differ from the front face's (without DEPTH_STENCIL2 the back face takes the front's, so equal masks build the same pipeline). Both the console-stream cache key and order_key use it. A stream with neither keeps exactly the key it had, which is also the key CreateGraphicsPipelineState gives the same description.

Old order logs: every key stays the same except for streams with depth bounds on, or with back-face masks unlike the front's. In an older pipeline_order.log such a pipeline is named by the plain key. That entry now simply finds nothing: the prewarm plan skips it and the pipeline is built on first use, as without a plan. Nothing misreads the log, and the next run's log has the new key. docs/d3d12_vulkan.md says so where the key is described.

Not in this PR: the other items of the finding (6: DEPTH_STENCIL2/RASTERIZER1/2 in derived-PSO overlays; 7: depth bounds without a DSV), and the plain CreatePipelineState path, which sets an order key but no cache key. That last one is unchanged here.

Tested

  • New d3d12_pipeline_stream_key (runtime/test/d3d12_pipeline_stream_key_test.cpp, through rt::d3d12::pipeline_stream_keys_for_test, parse only, no device). Synthetic streams: depth bounds on vs off; back-face masks unlike the front's (read or write) vs equal; and both at once. Each gets a cache and order key of its own. Off, or equal masks, gives the plain DEPTH_STENCIL stream's key. With the fold taken out (keys as on main) it fails with 7 failures; with it, it passes.
  • pipeline_order, pipeline_prewarm, replay_pipeline_order_hook: pass. tests/test_ci_registration.py: pass. Full runtime build (RelWithDebInfo, MSVC): clean.

GPUs tested: n/a (the new test only parses streams; the other tests are CPU-only). Build host: profile M (NVIDIA GeForce RTX 4070 SUPER, Windows 11).

AI-assisted: yes (Claude Code)

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. (No translator change.)

🤖 Generated with Claude Code

Tyrannys and others added 2 commits November 27, 2026 10:08
…e keys

A pipeline state stream carries DEPTH_STENCIL1/2's depth-bounds flag and
DEPTH_STENCIL2's back-face stencil masks beside the graphics description, and
create_graphics builds from them, but the console-stream cache key and
order_key (pipeline_order.log, the prewarm plan) hashed the description
alone. Two streams that differ only there shared a key.

stream_graphics_key folds them in where they change the pipeline (back masks
only when unlike the front's); a stream without them keeps its old key, so
older order logs only miss the changed entries. New
d3d12_pipeline_stream_key test.

RT-STATE-PIPELINE-KEY-DS2, item 5 of kevincommits' RT-STATE-AUDIT-PIPELINE
finding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@djrolfes

Copy link
Copy Markdown
Contributor

Independent Linux/Wine + NVIDIA check at head 06adf9b7b (merged cleanly onto origin/main c0201a806 alongside #2480, #2478, #2476, #2474).

  • Environment: Linux 7.2.15, wine-11.22, clang-cl + xwin cross-build, NVIDIA GeForce RTX 3070 Ti 8 GB, driver 620.73.04, Ryzen 7 5800X, 32 GB RAM. No game files.
  • CTest: d3d12_pipeline_stream_key passed (4.43 s) under Wine.

AI-assisted.

@MoonEyes

Copy link
Copy Markdown
Collaborator

Tested for #2464 as Aslanek asked: unit tests and a game run on my machine; CI ignored for now as asked.

RUN pr2477-court | 2026-11-27 | MoonEyes | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        main ec91d695c + PR #2477 (head 06adf9b7b), merged locally without conflict, nothing pushed | shaders: main's own translation
MACHINE:     RTX 4060 8 GB, desktop, only GPU, display attached | NVIDIA 610.88 | Windows 11 Pro 26300 | Ryzen 5 3600 | 32 GB | Windows GPU timeout at the default (2 s)
RECIPE:      short recipe: docs/running.md Windows NVIDIA recipe, pipeline cache warm, 330 s cap, scripted button presses from 60 s | build RelWithDebInfo, only the PR's targets built
TESTS:
  - d3d12_pipeline_stream_key_test (new, ctest d3d12_pipeline_stream_key): pass on the PR | fails on main: does not compile on main (it uses a new test hook that main lacks)
  - d3d12_title_va_test (14 ctest variants, touched by the PR): 14/14 pass on the PR | fails on main: no (14/14 also pass on main with the PR's test file, so this test does not discriminate)
GAME:        session=1 at 125 s | world entered at 175 s | last window >= 1 img/s ends at 251 s | 0 frames after world entry + 240 s | end: stopped by my local stall guard at 251 s (no new frame line for 180 s), not by the cap | device loss: no (no fault report) | private RAM max 17169 MB
COMPARED TO: w77 (main ec91d695c, same short recipe): session=1 at 145 s, world at 195 s, last window >= 1 img/s at 293 s, private RAM max 16043 MB, ended by the time limit (337 s)
             w79 (main, same short recipe): world at 200 s, last window >= 1 img/s at 286 s, private RAM max 16583 MB, ended by the time limit (350 s)
             one run each (n=1); on main the spread of world entry on this recipe is about 165 to 200 s, so no conclusion on timings
VERDICT:     new test passes and cannot compile on main; title_va test does not discriminate; game reached the world, stopped by the stall guard, no device loss; inconclusive for the game (n=1)

Reading (marked):

  • MEASURED: the display stops after the world is entered (76 s after world entry for the last window >= 1 img/s here; 98 s on w77, 86 s on w79). Present on main too, not caused by this PR (finding Coordinating who works on what (continued from #14) #1608 (comment)).
  • MEASURED: the run was ended by my local stall guard, not by a crash or a device loss. A stall guard end is not comparable with the time-limit end of the main runs; compare the last-window figure, not the end time. I do not attribute the stop to this PR.
  • The game logs of this run were deleted by a disk cleanup before this write-up; the figures above were extracted before that and cannot be re-checked from the logs now.

Limits: one machine, one run for the PR, one run for each main witness.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants