d3d12: LEONIDA_LAZY_PSO=1 builds pipelines at their first draw or dispatch and keeps no unedited shader modules (RT-LAZY-PSO) #511
Closed
leonida/mandy
VibeClauding wants to merge 0 commits from
cont-lazy-pso into main
pull from: cont-lazy-pso
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!511
Loading…
Reference in a new issue
No description provided.
Delete branch "cont-lazy-pso"
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 #14 as
RT-LAZY-PSO.What and why
Opt-in
LEONIDA_LAZY_PSO=1(off by default, nothing changes without it):variant(0).prepare_drawtakes the base pipeline fromvariant(0)whenpipelineis null.ComputePipeline::build(both dispatch sites inprepare). The subgroup-size request is still decided, recorded (pipeline_subgroup_requests) and reported at creation in both modes.build()makes each from the library's words for the pipeline it creates and destroys it after (ModuleCleanup). Edited stages keep their module as today.The retail title creates some 50,000 PSOs before its first frame and draws with far fewer. On a 16 GB RAM + 8 GB pagefile Windows machine (RTX 3070, driver 610.88), building them all eagerly ran the process out of commit between 50 and 300 s into the boot: the driver's copy of every module plus every pipeline. With deferred pipelines and no kept modules, private memory stayed at 11-17 GB and the title's own loading continued instead of stalling behind the compiles. Those measurements were on a forge-based branch with this change and others; this pull request is the change alone, onto
main.Trade-off: a pipeline the driver refuses fails its draw or dispatch (
unresolved_resource, logged once) instead ofCreatePipelineState, and the first draw with a new PSO pays its compile. That is why it is a switch.Tests
d3d12_compute_lazy_pso,d3d12_draw_lazy_pso,d3d12_mesh_lazy_pso: the existing tests run with the switch on (CTestENVIRONMENT).cteston Windows 11, MSVC, RTX 3070: default mode and withLEONIDA_LAZY_PSO=1set for the whole run, 302/303 in both. The one failure,d3d12_execute_indirect_validation(5 count-buffer parity rows), fails the same way on unchangedmainon this machine.scripts/check_no_game_data.pyon the changed files: clean.Docs: a bullet in
docs/d3d12_vulkan.mdsection 3.6.AI-assisted (Claude Code); built and tested on the machine above.
Measured on the retail boot with an AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32029.2010), Windows 11 26300, MSVC 19.44 (CMake + Ninja), i7-14700K, own 1.0.2.1 copy,
--trace --trace-d3d12, the executable's network blocked in the firewall. Base: #321 ate0d4fd2b8with this PR's commit88658f1b3cherry-picked on top (two conflicts:CMakeLists.txtkept both test blocks; ind3d12_vulkan_device.cppI took this PR's compute creation and moved #321's startup pipeline-cache checkpoint intocompile_compute). Work folder frommain's shaders stage plus old #7529/#7746/#8858, withnative_hashes.txt. Counts only.On AMD's Windows driver the eager PSOs are what holds the boot back, so this switch matters there:
PresentXLEONIDA_LAZY_PSO=1GPU address arena full (raise LEONIDA_ARENA_MB), thenCreateCommittedResource3fails and the title assertsLEONIDA_LAZY_PSO=1,LEONIDA_ARENA_MB=2048GetResourceAllocationInfo format not supported yet: 118, then the title'sint3So the ~51,000 PSOs that took the whole 300 s now go by in about 14 s, and the boot reaches later stops: the 256 MB default arena first, then format 118 in
GetResourceAllocationInfo(the same kind of stop as format 65 / A8_UNORM in Tyrannys' run on #321).CreateLifetimeTrackerunsupportedgrows from 10,241 to 26,076, which is the title getting further, not new failures.One thing to watch when this meets a rectangle-list path (not a defect of this PR on
main, which has no such path yet): with the switch on, 242CreatePipelineStatecalls fail with... cannot be drawn as a rectangle list: the vertex shader is not a SPIR-V module; with it off, none fail. Increate_graphicsthe lazy branch clearsstage.words(// a lazy stage reads its words again at build time) before #321'srect_listblock readsvs_stage.wordsforrect_list_geometry, so that block gets an empty vector. Whichever lands second (this or the rect-list support) should read the VS words before they are cleared, or reload them there.Not run: this PR's three new
*_lazy_psoCTests (not built here), Intel (the UHD 770 stops at slot 41 before any of this on #321), and a memory curve.AI-assisted (Claude Code).
I used PortBridge to independently replay towade’s rectangle-list finding and the order already used in LloydNicholson’s integration. At rectangle PR #207 head
21dc3889280d, the standalonerect_list_geometryhelper produced 511 words from a 79-word synthetic vertex module. Releasing the words before the call reproducedthe vertex shader is not a SPIR-V module. Calling the helper before releasing them produced the same 511 words byte for byte. The input and both generated modules passedspirv-val --target-env vulkan1.1.The remaining integration check is
d3d12_rect_listwithLEONIDA_LAZY_PSO=0and1, including pixel readback. This replay covers the generator and word lifetime in isolation. AI-assisted with Codex.Native Windows pixel-readback follow-up to the standalone reproduction. I merged #207
21dc3889and #51188658f1bontomain21625bcalocally. Both merges were clean.LEONIDA_LAZY_PSO=0LEONIDA_LAZY_PSO=1CreateGraphicsPipelineStatefails withthe vertex shader is not a SPIR-V moduleI applied only the guard that keeps
vs_stage.wordsalive forrect_list_geometry. In both modes the fixture checked 4,096/4,096 pixels for the rectangle and each rotated right-angle case, 2,156 drawn pixels for the skewed triangle, and 4,096/4,096 exact pixels for the quad.d3d12_translated_drawandreplay_quad_listalso passed in both modes. No Vulkan validation errors in the two readback tests. The two hand-written test shaders passedspirv-val.Windows 11 build 26100, RTX 3060 Ti driver 610.88, MSVC 19.44, LLVM 23.1.5, Khronos validation 1.4.369 with
LEONIDA_VK_VALIDATION=1. AI-assisted synthetic tests, no game files.@towade Would you be willing to run the synthetic
d3d12_rect_listcheck on your Windows/Vulkan setup once there is a combined revision for #511 and #207? Running it withLEONIDA_LAZY_PSO=0and1on the same commit would show whether both paths return the expected pixels. PortBridge reproduced the word-lifetime failure you found and checked the corrected order in isolation. Shared test plan. Please note the exact combined commit and both outcomes if you have time.Retail check of
LEONIDA_LAZY_PSO=1on a second NVIDIA machine (Windows 11, RTX 5070, driver 617.14,LEONIDA_D3D12=vulkan, own 1.0.2.1 copy, 200 s limit). Base stack:main21625bca8 + #641 + #427 + #727 + #602 + #387 + #357 + #432, which reaches the frame loop without lazy PSOs (400,154PresentX ok).PresentX okLEONIDA_LAZY_PSO=1GetResourceAllocationInfo format not supported yet: 118(#588)GPU address arena full, then slot 133 failsLEONIDA_ARENA_MB=4095no emulation exists for wave64(4 ps, 3 vs)So on this machine the lazy path does what the description says and moves the first stop from the title's start-up to the depth format, then the arena, then wave64 graphics shaders; no device loss in any of the three runs, and no exception other than the title's own int3. I did not look at #207 together with this PR (DadaCap's report about the rectangle-list path); #207 alone on the base stack, without lazy PSOs, reached the loop (473,041
PresentX ok).AI-assisted: yes (Claude Code, Sonnet 5.5)
checked:
88658f1b3on currentmain(d0da7dade), Windows 11 26300, MSVC 19.44 (CMake + Ninja), on an AMD Radeon RX 9070 XT (RDNA4, 32.0.32029.2010) and an Intel UHD 770 (Xe-LP, 32.0.101.7092), picked withLEONIDA_VK_DEVICE.d3d12_compute_lazy_pso,d3d12_draw_lazy_psod3d12_mesh_lazy_psoVK_EXT_mesh_shader)ctest,LEONIDA_LAZY_PSO=1ctest, unsetThe failures are the same tests with and without the variable, so the lazy path adds none. On Intel they are sparse/tiled resources, DXR and some formats; on AMD they are
vk_queue_query_sync,d3d12_texture_tiles,d3d12_execute_indirect_validation,d3d12_clearandd3d12_pipeline_library_host.Retail, with this PR on
mainplus the open boot pull requests (ladder on #14), the lazy path gets the RX 9070 XT past the start-up compiles to 84,585 calls and 55,257 pipeline states, with no device loss.For the rectangle-list interaction, see my note on #682: the same
stage.words = {}ordering applies there.AI-assisted (Claude Code).
Independent eager/lazy A/B on Windows 10 22H2 (19045), RTX 5070 / NVIDIA 610.88, MSVC 19.51.36256, Vulkan with Khronos validation 1.4.369. Tested the same binaries in separate processes with
LEONIDA_LAZY_PSO=0and=1.88658f1b3, compute, raster draw, indirect dispatch count and pipeline library passed in both modes. The mesh test hitVUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076in both modes. Without validation the mesh test matched all 4,096 pixels in both modes.3bb46d65) to the same #511 head. All five tests passed with validation enabled in both modes, including all 4,096 pixels in the draw and mesh readbacks and eight WARP/Vulkan indirect dispatch comparisons per mode.Synthetic results only. This run did not measure retail startup or memory consumption. No game files. AI-assisted (Codex).
Independent check. Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, Vulkan SDK 1.4.363.0,
LEONIDA_VK_VALIDATION=1, merged ontomain82a2aabcc without conflicts, test targets rebuilt; RTX 5060 Ti (621.01) and a Ryzen 7 7700 iGPU (1002:164E, AMD 31.0.22044.1). On the iGPU the pipeline tests fail on plainmaintoo (128 push-constant bytes), so they say nothing there.RTX 5060 Ti, each without and with
LEONIDA_LAZY_PSO=1:d3d12_compute_test,d3d12_draw_testandd3d12_mesh_testall exit 0 with 0 VUID lines, as onmain.Synthetic tests only, no game files. AI-assisted (Claude Code): I read the diff and ran the tests on that machine.
PortBridge connected this PR to SceneGate VI's changing-color readback control. I applied that method to the offscreen Vulkan fixture at
88658f1b3fcdca2231358c18d09253a213dc8533.On RTX 4070 Ti SUPER, Windows 11 build 28000, driver 617.14, both
LEONIDA_LAZY_PSO=0and=1passed 3/3 runs. Every run checked 32 frames × 4,096 RGBA8 pixels. Omitting draw 8 returned 44 at frame 7, pixel (0,0), in 3/3 controls per mode. The fixture also passed both modes with the new check disabled. The local LLVM-MinGW build used an aggregate-return ABI adapter and an abort-on-use swapchain stub for the offscreen path.The test-only patch and reproduction guide use the existing
d3d12_draw_testtarget. An independent AMD run with the standard build would help confirm the result. Synthetic inputs. AI-assisted.Hi @VibeClauding, thanks for this pull request. It currently conflicts with
main(conflicting file(s):runtime/CMakeLists.txt,runtime/shims/d3d12_vulkan_device.cpp,runtime/src/vulkan_replay.h), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
Thanks for the contribution! This PR was reviewed by the maintainers and is being closed as part of a large batch of closures.
Reason: superseded by main.
If this looks like a mistake, mention @DadaCap here at any time and it will be looked at again.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.