Repository navigation
d3d12: LEONIDA_ASYNC_MIN_BYTES_GRAPHICS, a separate async threshold for graphics (RT-ASYNC-MIN-BYTES-GRAPHICS) - #2467
Conversation
…or graphics (RT-ASYNC-MIN-BYTES-GRAPHICS) With LEONIDA_ASYNC_PIPELINES=1, graphics and mesh pipelines (all their stages) now take LEONIDA_ASYNC_MIN_BYTES_GRAPHICS when it is set, and LEONIDA_ASYNC_MIN_BYTES otherwise, so nothing changes while it is unset. Compute keeps LEONIDA_ASYNC_MIN_BYTES. 0 makes every graphics pipeline asynchronous. One startup line states both thresholds; text that is not a number is ignored with a log line. Thread dumps from a retail run showed the draw thread building lazy graphics variants under the 1 MiB threshold in place, 2.5-11 s each, back to back, with no present for about 100 s. A skipped draw costs one draw. The image needs the small lighting and post compute programs, and those are still built in place. Tests: async_pipeline_size_test covers the per-kind decision and the unset fallback; d3d12_pipeline_workers_test --async-graphics-zero / --async-graphics-unset (new ctests) hold the compile worker with compute over its threshold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1c18cd2 to
d42c373
Compare
|
Updated onto main |
|
RUN gfx0 | 2026-11-27 | OreoFR | AI-assisted: Claude Code (Claude Opus 5.5) |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed and tested at d42c37335 (merged cleanly onto main ec91d695c).
Everything looks clean:
- Every graphics and mesh pipeline creation path (regular, stream PSO, and derived PSO) routes through
PipelineState::create_graphics()-->async_replay_compile(true, spirv_bytes), and compute routes throughasync_replay_compile(false, spirv_bytes). parse_thresholds()andasync_min_bytes()handle unset, empty,0,UINT64_MAX, overflow, malformed values, and over-length env strings consistently, preserving exact prior behaviour whenLEONIDA_ASYNC_MIN_BYTES_GRAPHICSis unset.- Note on the CI
checkfailure: the failed Python tests on that run were unrelated Windows runner temp-path failures (test_bink_names.py,test_world_names.py, etc.), not caused by this PR.
Verified locally on Windows 11 (MSVC 19.44.35230.0, Ninja Release, NVIDIA GeForce RTX 5070, driver 610.88, Vulkan 1.4.341; note VK_LAYER_KHRONOS_validation is not installed locally so Vulkan validation layers did not run):
async_pipeline_size(CPU): passedd3d12_pipeline_workers,d3d12_pipeline_workers_async_graphics_zero,d3d12_pipeline_workers_async_graphics_unset(GPU): 3/3 passedscripts/check_no_game_data.pyandgit diff --check: clean
No findings.
AI-assisted.
|
Independent Linux/Wine + NVIDIA RTX 3070 Ti check at head
AI-assisted. |
|
Game-run regression A/B requested for this PR. The two arms share the build recipe, shader pack, settings and caches; only this PR differs, with |
Claimed in the coordination issue as: RT-ASYNC-MIN-BYTES-GRAPHICS
Depends on: nothing (#2440 merged).
What and why
#2440 added
LEONIDA_ASYNC_MIN_BYTES=<n>. WithLEONIDA_ASYNC_PIPELINES=1, a pipeline under n bytes of SPIR-V is built where it is needed. Graphics and compute use the same threshold.@MoonEyes's thread dumps (RTX 4060, 1 MiB threshold) show what goes wrong with a shared threshold. The draw thread builds lazy graphics variants under 1 MiB in place (
PipelineState::variant->build->vkCreateGraphicsPipelines). Each takes 2.5-11 s, and they run back to back, so no present comes for about 100 s. The image only needs the small compute pipelines (lighting, post) to be built in place. A graphics pipeline that isn't built yet only costs a skipped draw.This adds
LEONIDA_ASYNC_MIN_BYTES_GRAPHICS=<n>:LEONIDA_ASYNC_MIN_BYTES.0: every graphics pipeline is asynchronous, asLEONIDA_ASYNC_PIPELINES=1was before d3d12: LEONIDA_ASYNC_MIN_BYTES, only large pipelines asynchronous (RT-ASYNC-LARGE-ONLY) #2440.LEONIDA_ASYNC_MIN_BYTES, so nothing changes. Text that isn't a decimal number is ignored the same way, with a log line.runtime/src/async_pipeline_size.h(pure stdlib):MinBytes,parse_thresholdsand a per-kindasynchronous.shims/d3d12_pipeline_compile.h: reads both variables once.d3d12_vulkan_device.cpp:graphics_.async_buildandpipeline_.async_buildsay which kind they are.Tested
async_pipeline_size_test: parsing of the graphics variable:0, set without the general one, above compute's;It also checks the per-kind decision. With graphics unset, both kinds decide exactly as d3d12: LEONIDA_ASYNC_MIN_BYTES, only large pipelines asynchronous (RT-ASYNC-LARGE-ONLY) #2440 for every tested size and threshold. With
1 MiB+ graphics0, every graphics pipeline is async, while compute under 1 MiB waits and compute at 1 MiB or more is async.d3d12_pipeline_workers_test --async-graphics-zero(new ctestd3d12_pipeline_workers_async_graphics_zero). Setup:LEONIDA_ASYNC_PIPELINES=1,LEONIDA_ASYNC_MIN_BYTES=1 GiB,LEONIDA_ASYNC_MIN_BYTES_GRAPHICS=0, every compile-worker job held by the job probe. The pipelines are 48 graphics (16 through a variant, 3 of them large) and 16 compute.--async-graphics-unset(ctestd3d12_pipeline_workers_async_graphics_unset): same setup with the graphics variable removed. The first submission draws everything in place and the worker gets no job, as onmain.d3d12_compile_teardown,d3d12_compile_pool,d3d12_m4_compute,d3d12_m4_compute_async_small_waits,d3d12_m4_compute --check-async-journalandd3d12_pipeline_workers, run with:GRAPHICS=0;MIN_BYTES=2097152+GRAPHICS=0;GRAPHICS=1073741824;GRAPHICS=abc.teardown,m4_computeand the journal check ran with and withoutLEONIDA_ASYNC_PIPELINES=1. All pass on the rebased branch.d3d12_m4_computewithLEONIDA_ASYNC_PIPELINES=1and no threshold failed 7 of 8 runs. d3d12: LEONIDA_ASYNC_MIN_BYTES, only large pipelines asynchronous (RT-ASYNC-LARGE-ONLY) #2440's build shows the same rate (all-async dispatch skip, see below).ctest(RelWithDebInfo, Ninja, MSVC,-j 4, before the rebase onto d3d12: a pool of compile workers for the pipeline compiler (RT-ASYNC-COMPILE-POOL) #2233): 492 of 495 pass.xbox_presentandd3d12_set_descriptor_heapsalso fail onmainon this machine (noted in d3d12: LEONIDA_ASYNC_MIN_BYTES, only large pipelines asynchronous (RT-ASYNC-LARGE-ONLY) #2440).dxgi_waitable_latencypassed 3 of 3 when rerun on its own (a timing test under-j 4).-std=c++20 -Wall -Wextra, Vulkan SDK include) onasync_pipeline_size_test.cppandd3d12_pipeline_workers_test.cpp: no diagnostics in user code. The 13tests/test_docs_*.pypass.scripts/check_no_game_data.pyis clean on every changed file.0vs unset on the same build follows in Coordinating who works on what (continued from #14) #1608.GPUs tested: NVIDIA GeForce RTX 4070 Laptop 8 GB (profile M, laptop), driver 621.40, Windows 11.
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: runtime only)🤖 Generated with Claude Code