startup: create translated graphics PSOs outside draw_lock #3530
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3530
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3528"
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?
@Leyukaka on GitHub · 2026-11-29 23:12 UTC · original
Leyukaka:startup-graphics-pso-off-draw-lock→main· +1737 −361 · 9 files · 16 commits · draftStacked on #3518; review the last six commits (f3793797..31be7fb2) — this stays a draft until #3518 merges.
Refs #3453
What changes
#3518 moves shader translation off
draw_lock. The first use of a translated PSO still created it with the lock held. This PR moves that creation out too (pipeline_forinsrc/startup_stubs/d3d12_draw.inl).draw_lockand recheck the cache and their own recording after each wake. Recipe replay is reserved once per key, and rect geometry once per translation.completeflag are written together. A failed driver create is cached as a null result. If the device or the recording changed during the unlock, the result is dropped, the entry stays incomplete, and a waiter can retry.draw_lockheld, including on unwind.pipeline_forthen returns null.draw_lock.824fb5cemakesremoval_deviceandinfo_queueatomics, since the device check can now run withoutdraw_lock.98ff231afixes the one remaining plain read, inview_slot.startup_graphics_pso_load_{unlock,concurrent}_{warp,hardware}, gated byX2W_TEST_GRAPHICS_PSO_*environment variables that are inert when unset. Docs:docs/experiments/startup-pso-recipe.md.Unrelated recordings and queue submissions can now take
draw_lockwhile a PSO is being created. The draw that started the creation, and draws waiting for the same state, still complete synchronously.Separate fix in
31be7fb2: texture uploads are published when their recording submitsThis bug exists on main and is independent of the PSO change. A texture upload copied from the shared upload ring was marked done when it was recorded, not when its list was submitted. Only uploads with a dedicated buffer were tracked per list. A second list could therefore treat the texture as already uploaded, skip its own copy, and sample the texture before the first list's copy had executed if it was submitted first.
31be7fb2records every texture copy per list (ring or dedicated). Other lists stage their own copy while one is pending, and the queue marks the upload done at submit, only if the recorded revision is still the current one. Records are dropped on Reset, failed Close and final list release.The concurrent fixture depends on this fix (it submits a list that reuses a texture staged by another list). I can split it into its own PR on request.
Evidence
Local build at
31be7fb2(fresh configure, full build,-DX2W_WITH_OPUS=OFF): exit 0.12/12 passed:
startup_graphics_pso_load_{unlock,concurrent}_{warp,hardware}(this PR) andstartup_graphics_published_load_{unlock,concurrent,native_backoff,precedence}_{warp,hardware}(#3518). The concurrent pair was rerun 5 more times: 5/5.Mutations, each a full rebuild followed by the same filter:
draw_lock(the unlock guard inpipeline_forreplaced by a no-op):pso_load_unlock_{warp,hardware}andpso_load_concurrent_{warp,hardware}fail on gate timeouts.31be7fb2):pso_load_concurrent_{warp,hardware}fail withpublication pixel (0,0) format 28: 00000000 expected ff00ff00;pso_load_unlock_*still pass.Restored source: 12/12.
Earlier failures on
98ff231aAn offline build and test job run before
31be7fb2failed four tests:startup_graphics_pso_load_concurrent_{warp,hardware}: the00000000 expected ff00ff00readback above. Cause: the upload bug, fixed in31be7fb2and reproduced by M2.startup_graphics_published_load_precedence_{warp,hardware}:FileNotFoundErrorwhen the check script started its child process. That job had not builtstartup_stream_consumer. With the executable built, both pass. Not a code failure.Not covered
!current()paths ofpipeline_for,draw_lockis retaken and then released and retaken again by the guard. Redundant, not incorrect.@lukaslw-lab on GitHub · 2026-11-30 07:41 UTC · original · approved these changes
Reviewed
31be7fb2(draft, stacked on #3518) by readingf3793797..31be7fb2; not built or run.Verdict: approve. The PSO handoff holds: reservations clear and wake under
draw_lockon every path, including unwind, and the caller rechecks the recording after each wait or unlock. No MUST.31be7fb2into its own PR, as you offered. It fixes a bug on main and has its own mutation evidence (M2). It also changes upload cost on its own: while list A has a texture pending, any other list that binds it stages its own copy (reusableneeds!pending_list || pending_list == list,src/startup_stubs/d3d12_draw.inl:2451). Titles that record several lists before the first submit now upload such textures once per list, and use more ring space. No counter tells these restages apart from content changes. One counter plus a title run would show whether ring stalls or dedicated pages go up.PsoTargetCache's comment says only rectangle geometry varies within a target signature. That holds becauseeffective_blend_stateanduse_depth_stencildepend only onbound,trandkey.targets(:1990-2000). Say so, so a later change that adds pass state to the PSO also adds it toPsoCacheKey.install_graphics_translationmakes a translation ready, and it setsready_device, so no ready path returns a null PSO.translated_rect_geometrynever waits on a PSO reservation, so there is no wait cycle.submit_texture_uploadstreats as not done.unordered_mapnodes stay put).info_queueswap is underdebug_lock.Tests:
pso_load_unlock_*proves creation runs withdraw_lockreleased (M1).pso_load_concurrent_*proves waiters, recipe replay and a mismatched recipe, and the upload ordering (M2). The_FAILand_ABANDON_ONCEvariants reach the null result and the unwind path. CI ran none of them (startup_graphics_*is not in the Windowsprfilter). The only results are the author's local 12/12 and mutation runs.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.