Repository navigation
nvn: pre-pass indirect draw conversion and indirect dispatch/mesh clamp - #1729
ksolenk38ze wants to merge 1 commit into
Conversation
Batch indirect-count multi-draw masking (mdx_run) before opening a render pass so indirect draws inside the pass do not split the active MTL4RenderCommandEncoder mid-pass. Check OP_UPDATE_UB byte ranges during the lookahead scan in ixc_run, wide_run, and mdx_run so inline uniform updates to unrelated buffer regions do not prematurely stop batching, and flush deferred inline buffer writes (ubd_land_compute) before opening the conversion compute pass. Also clamp GPU-written indirect compute dispatch counts (DM_NVN_DISPATCH_CLAMP, 65,535 per dimension and 4,194,304 total threadgroups) and DrawMeshTasksIndirect workgroup counts so uninitialized or race-written indirect records cannot hang the GPU. Verified in The Legend of Zelda: Ocarina of Time (0400486024DEC000) in Kakariko Village and Hyrule Field on Apple M-series (macOS).
1d059e4 to
c5fa499
Compare
…h reads them (each dimension to 65535, at most 2^22 threadgroups): a count from bad data runs on the GPU for ever (from upstream PR seedds#1729, that part only)
|
Data on Ocarina of Time's (0400486024DEC000 v131072) indirect task/mesh draws, since this PR touches their conversion and clamps the copied count. Kokiri Forest, Docked 1536x864, main colour pass (RG11B10 + D32F, ~800 draws, EQUAL after the depth prepass), from
Two questions: have you seen this pass on your Macs, and does the pre-pass conversion here change the grass's task counts or timing in your runs? I can run a build of this PR on the iPad if a particular measurement would help. |
|
Thanks @aksmith-git for the
|
|
A data point on the indirect dispatch clamp's cost (the same |
What and why
When an indirect draw (
DrawArraysIndirect,DrawElementsIndirect,MultiDrawArraysIndirectCount,MultiDrawElementsIndirectCount) required vertex conversion (vconv), index conversion (8-bit or primitive-restart index rewrite), or geometry shader emulation inside an already-open render pass,draw_()ended the current render pass (rp_end()), dispatched the compute conversion, and reopened the pass withMTLLoadActionLoad, splitting the pass and losing tile memory state. In addition, indirect compute dispatches (DispatchComputeIndirect) and mesh draws (DrawMeshTasksIndirect) could read uninitialized or out-of-bounds workgroup dimensions when the guest indirect buffer had not yet been populated, and background task/mesh pipeline compilation inmtk_psowaited behindpp_bg_queue()'s serial utility backlog.This change:
ixc_run,mdx_run) beforerp_begin(), keeping the render pass intact.ixc_clamp) and mesh task counts (mdx_clamp) on the GPU before indirect dispatch/draw calls (DM_NVN_IND_CLAMP).mtk_psoonQOS_CLASS_USER_INITIATEDso mesh draws without a pulling stand-in do not stall behind utility-priority background compiles.docs/reference/rendering.md(### Pre-pass indirect draw conversion and indirect dispatch clamping) and updatesdocs/agents/symptoms.md.Related
DrawMeshTasks/DrawMeshTasksIndirectand mesh pipeline handling).Checked
make -C dm/gfx/tests GAME=0400486024DEC000 run,python3 dm/tools/docs_symptoms.py0400486024DEC000, v131072, SDK 22.2.8), played through Kokiri Forest, Lost Woods, Hyrule Field, and Zora's Domain at 60 fps with foliage and indirect draws intact.Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)