d3d12: depth bounds and back-face stencil masks in a stream's pipeline keys (RT-STATE-PIPELINE-KEY-DS2) #2477
Closed
leonida/mandy
Tyrannys wants to merge 0 commits from
claude/pipeline-key-ds2 into main
pull from: claude/pipeline-key-ds2
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!2477
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/pipeline-key-ds2"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claimed in the coordination issue as: RT-STATE-PIPELINE-KEY-DS2 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7222234997), item 5 of @kevincommits'
RT-STATE-AUDIT-PIPELINEfinding (#2464 Part B, https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7221587976). Thanks to kevincommits for finding it.What and why
A pipeline state stream (
ID3D12Device2::CreatePipelineState) can carry state that the plainD3D12_GRAPHICS_PIPELINE_STATE_DESCcannot hold:DEPTH_STENCIL1/DEPTH_STENCIL2'sDepthBoundsTestEnable, andDEPTH_STENCIL2's per-face stencil masks.parse_pipeline_streamkeeps them beside the description (PipelineStream::depth_bounds,back_masks/back_stencil), andcreate_graphicsbuilds from them. But the keys were made from the description alone:GetCachedBlob), set for console-stream PSOs, waspipeline_key(stream.graphics);pipeline_order.logkey (order_key(PipelineStream), used by the order log and the prewarm plan from #2220/#2260) was that key with only the mesh shader folded in.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 (withoutDEPTH_STENCIL2the back face takes the front's, so equal masks build the same pipeline). Both the console-stream cache key andorder_keyuse it. A stream with neither keeps exactly the key it had, which is also the keyCreateGraphicsPipelineStategives 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.logsuch 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.mdsays so where the key is described.Not in this PR: the other items of the finding (6:
DEPTH_STENCIL2/RASTERIZER1/2in derived-PSO overlays; 7: depth bounds without a DSV), and the plainCreatePipelineStatepath, which sets an order key but no cache key. That last one is unchanged here.Tested
d3d12_pipeline_stream_key(runtime/test/d3d12_pipeline_stream_key_test.cpp, throughrt::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 plainDEPTH_STENCILstream's key. With the fold taken out (keys as onmain) 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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code
Independent Linux/Wine + NVIDIA check at head
06adf9b7b(merged cleanly ontoorigin/mainc0201a806alongside#2480,#2478,#2476,#2474).7.2.15,wine-11.22,clang-cl+xwincross-build, NVIDIA GeForce RTX 3070 Ti 8 GB, driver620.73.04, Ryzen 7 5800X, 32 GB RAM. No game files.d3d12_pipeline_stream_keypassed (4.43 s) under Wine.AI-assisted.
Tested for #2464 as Aslanek asked: unit tests and a game run on my machine; CI ignored for now as asked.
Reading (marked):
Limits: one machine, one run for the PR, one run for each main witness.
AI-assisted (Claude Code, Claude Opus 5.5)
Reviewed at head
06adf9b7bon Windows 11 (MSVC 202219.44).Verification
d3d12_pipeline_stream_key_testandgta6rt.d3d12_pipeline_stream_key_test: passed.Finding (Request changes)
Device::CreatePipelineStatenever assignscache_key_(d3d12_vulkan_device.cpp:17953-17966vs.15714-15723;cached_pso.h:59-72):The hash payload construction itself (
d3d12_vulkan_device.cpp:10914-10935) cleanly distinguishes depth-bounds enable and back-face stencil masks while keeping plain graphics keys unchanged. However,Device::CreatePipelineState(17955-17966) setsorder_keywhen logging/prewarming is active and callscreate_graphics(...), but never callspipeline->set_cache_key(...)(onlyprepare_console_streamdoes). As a result, PSOs created through the publicID3D12Device2::CreatePipelineStatestream API still emit an emptycache_key_(64 identical zero bytes inGetCachedBlob) regardless of depth-bounds or back-face stencil mask differences;d3d12_pipeline_stream_key_testcalls the hashing helper directly so it didn't catch the missing call site. Assigningcache_key_inDevice::CreatePipelineState(and adding a test throughCreatePipelineState->GetCachedBlob) closes this gap.AI-assisted review + local MSVC verification.
@timbot103 thanks, you were right: the public
ID3D12Device2::CreatePipelineStatenever calledset_cache_key, so every PSO from a stream had an empty key inGetCachedBlob. Fixed in19186132a.CreatePipelineStatenow sets the same key thatprepare_console_streamsets:pipeline_key(stream.compute);stream_graphics_key(stream), which includes the depth-bounds flag and the back-face stencil masks.d3d12_compute_testmakes a compute PSO throughCreatePipelineState(root signature + CS stream). ItsGetCachedBlobbytes must equal those of the PSOCreateComputePipelineStatemakes from the same root signature and CS, and the blob must be accepted back asCachedPSO. The test goes through the real device on the GPU.d3d12_computefails.ctest -R "d3d12_pipeline|d3d12_title_va|cached_pso|d3d12_compute"passes 9/9.gta6rtbuilds.stream_graphics_keythatd3d12_pipeline_stream_key_testchecks directly.No game files used. AI-assisted (Claude Code).
Reviewed and verified at head
19186132a(Windows 11, MSVC 19.44, Ninja Release,LEONIDA_VK_VALIDATION=1).Verification
d3d12_pipeline_stream_key_test,d3d12_compute_test, andgta6rt.ctest -R "^(d3d12_pipeline_stream_key|d3d12_compute)$"(LEONIDA_VK_VALIDATION=1): 2/2 passed (0 validation errors).python -I scripts/check_no_game_data.py: clean.Review notes
stream_graphics_keypreserves exact key compatibility when neither depth bounds nor differing back-face stencil masks are present, and folds both fields cleanly into both cache (GetCachedBlob) andpipeline_order.logkeys when active.ID3D12Device2::CreatePipelineStatenow sets the same cache key asprepare_console_streamand the description paths, and the newd3d12_compute_testround-trip verifies byte-identicalGetCachedBloboutput accepted back viaCachedPSO.GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341,
VK_LAYER_KHRONOS_validation1.4.363).AI-assisted (Antigravity, Gemini).
Independent check of the public graphics
ID3D12Device2::CreatePipelineStatepath at19186132a49487fefdc4788317a2b103fca3ca09, against parent06adf9b7b9b432a0d64f8442833f17e7e9f060c8. RTX 3080 desktop (10 GiB), driver 630.20, native Windows 11 build 26340, MSVC 19.50.35717 RelWithDebInfo and Vulkan SDK 1.4.363.1, Khronos validation enabled.The unmodified
d3d12_compute,d3d12_mesh, andd3d12_pipeline_stream_keyCTests passed at both revisions. For a separate shared control I reused the synthetic VS and PS ind3d12_mesh_testand created three graphics PSOs through the public stream API. Two streams were identical, and a third differed only by an explicit zero sample mask. I read all three viaGetCachedBlob.This exercises the public graphics path with a sample-mask difference. The existing stream-key test covers depth bounds and back-face masks directly. Synthetic shaders only. AI-assisted (Codex).
Windows 11 + RTX 3090 Verification (
19186132a4merged withmainc8bf0e7b65) — PASS10.0.26200), MSVC19.44.35207(/O2 /MD /EHsc /std:c++20 /W4 /permissive- /utf-8), NVIDIA GeForce RTX 3090 (610.88) +VK_LAYER_KHRONOS_validation1.4.363.1(LEONIDA_VK_VALIDATION=1).git merge-treeontomain(c8bf0e7b65) (0conflicts);check_no_game_data.py,test_docs_env_vars.py(5/5),test_docs_table_rows.py(2/2),test_docs_encoding.py(1/1),test_ctest_registration.py(7/7), andtest_ci_registration.py(18/18) allOK;0new/W4warnings.#2477d3d12_compute_test.cpplinked againstmaingta6rt_d3d12_com): fails withrc=1(from_stream->GetCachedBlob/CachedPSOround-trip fails becausemain's publicID3D12Device2::CreatePipelineStateleftcache_key_empty).19186132a4+mainc8bf0e7b65):d3d12_pipeline_stream_key_test.exe:rc=0(depth bounds: on and off get different cache and order keys; off keeps the plain key,back-face stencil masks: masks unlike the front's get keys of their own; equal ones keep the plain key,depth bounds with back-face masks: a key unlike either alone,d3d12_pipeline_stream_key_test: all passed).d3d12_compute_test.exeon NVIDIA GeForce RTX 3090:rc=0,0VUID-validation errors (verifying byte-identicalGetCachedBlobbetweenCreateComputePipelineStateandID3D12Device2::CreatePipelineStateplusCachedPSOacceptance).AI-assisted.
Verified by OreoFR — READY
d3d12_computefails on main with the PR's new block (slot 67 call 2 failed with 0x80070057: the empty key of the public stream gives a different blob).d3d12_pipeline_stream_key_testdoes not compile on main, becausepipeline_stream_keys_for_testis a hook the PR adds.d3d12_computeandd3d12_pipeline_stream_keypass; ctest (Ninja RelWithDebInfo, all targets, gta6rt launchers excluded) in package p5 = main + #2477 + #1397 (no shared files): 495 tests, new failures vs main: none (main alone: 494 tests, 5 failures: loader, xs_proxy_mock, xmem_no_write_watch, api_ref_state timeout, xbox_present; xbox_present fails in every package as on main)LEONIDA_CARGO=OFF,LEONIDA_XMA2_DECODER_LIBempty), main + this PR alone; imports unchanged vs main (25 DLLs, 655 functions, no WS2_32)AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.