Repository navigation
draw_barriers game works again with image family heaps; fragment-only barriers keep the overlap - #2334
Closed
LiamPalmqvist wants to merge 3 commits into
Closed
draw_barriers game works again with image family heaps; fragment-only barriers keep the overlap#2334LiamPalmqvist wants to merge 3 commits into
LiamPalmqvist wants to merge 3 commits into
Conversation
…ent-only game barrier no longer forces the full one: since 7f50222 the relaxed draw-pass barriers were off whenever image family heaps existed (to keep the alias flush off end barriers, about 100 KB of command allocator per encoder), which Ocarina of Time's dynamic resolution always has, and any nonzero nvnCommandBufferBarrier forced the full consumer barrier although NVN orders later vertex or indirect fetch only for ORDER_PRIMITIVES and ORDER_INDIRECT_DATA (the game's most common barrier is 0x12, ORDER_FRAGMENTS | INVALIDATE_TEXTURE). The relaxed end barrier now flushes to the device only and, when aliases exist, the alias flush is a start barrier of the next pass before its fragments (no allocator cost, vertex work still overlaps); g_game_barrier_all marks the barriers that force the full one. Ocarina of Time on an M1 Max, gameplay, frame hold off, two runs each: frame 23.2-23.6 to 21.6-21.9 ms, GPU 22.0-22.3 to 20.2-20.4 ms, about 68 of 103 entry barriers a frame saved, same-buffer render-pass gaps 141 to 72 a frame; picture unchanged
# Conflicts: # dm/games/0400486024DEC000/README.md # dm/games/README.md
# Conflicts: # dm/games/0400486024DEC000/README.md
Contributor
|
A user log on main from an M1 Pro (discussion #1789, @brucewrks; our read of it) shows the same thing in the wild: A second device data point: on an M2 Air, the equivalent fix in #1970 saved ~75 % of entry barriers but didn't move GPU span, so the gain looks device-dependent. |
Owner
|
Landed as e775054 on main, with you as co-author. Your code is kept: the guard is gone, the alias flush is a start barrier before the fragments, and only ORDER_PRIMITIVES / ORDER_INDIRECT_DATA force the full barrier. Added on top:
|
This was referenced Nov 12, 2026
Closed
Kayyluhh
added a commit
to Kayyluhh/nxnative
that referenced
this pull request
Nov 14, 2026
…closed, superseded by seedds#2334, on main as e775054; its two env_switches rows (39aa802) go with it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
draw_barriers gamelets a draw pass's vertex work overlap the previous pass's fragments, ordered by the game's own barriers. On Ocarina of Time it had been doing nothing since 7f50222: every draw pass got the full barrier (draw-pass entry barriers full 31025 / saved 0per 300 frames).Cause
Two things in
enc_r_begin_pass/enc_r_end_pass(dm/gfx/nvn/nvn_mtl.m):&& !g_image_heap_n), to keep the alias flush off end barriers, where it costs a command allocator about 100 KB per encoder. Ocarina of Time's dynamic resolution always has family heaps.nvnCommandBufferBarrierforced the full consumer barrier. In NVN onlyORDER_PRIMITIVESandORDER_INDIRECT_DATAorder earlier work before later vertex or indirect fetch. Ocarina of Time's most common barrier,0x12(ORDER_FRAGMENTS | INVALIDATE_TEXTURE, pass dump of frame 1400), asks only for fragment-to-fragment order, which the relaxed end barrier (vertex, mesh and fragment before fragment, dispatch and blit) already gives.Fix (about 7 lines)
m4_end. When aliases exist, the alias flush is a start barrier of the next pass before its fragments (barrierAfterQueueStages:All beforeStages:Fragment visibilityOptions:resource_vis()), following the file's rule that alias flushes go on start barriers (no allocator memory), and vertex work still overlaps.g_game_barrier_all: only a barrier withORDER_PRIMITIVESorORDER_INDIRECT_DATAforces the full consumer barrier.g_game_barrierkeeps its meaning for the slice-merge check.docs/reference/frame-rate.mdentry, thedraw_barriersrow indm/games/README.md, the Ocarina of Time note (profile row and "Found on this game"), the symptom index.Measured
Ocarina of Time (
0400486024DEC000), M1 Max on AC,kokiri-deckgameplay (t 36-52 s), frame hold off, two runs each, every screenshot in Kokiri Forest:Bench p50: fps 42.5 → 45.8, frame 23.52 → 21.84 ms, GPU 22.88 → 20.91 ms, frames over budget 88 → 23. Entry barriers saved 0 → about 68 of 103 a frame. In a Metal System Trace, render-to-render idle gaps in one command buffer went from 141 to 72 a frame (2.34 → 1.15 ms). The picture is unchanged: the screenshots match as closely as two base runs match each other (PSNR base vs base 19.8 dB, base vs fix 20.0-20.6 dB, the differences in Navi, particles and leaves); no
[RED]lines.Checked
make -C dm/host GAME=0400486024DEC000builds;make -C dm/gfx/tests GAME=0400486024DEC000 runpasses, includingt_image_alias,t_rt_range*andt_copy_alias.test_docs.pypasses afterdocs_symptoms.py.regress.py checkcould not run: the only game built on this Mac is Ocarina of Time, which has no smoke route. The other games withdraw_barriers game(Breath of the Wild and others) now also skip the full barrier after fragment-only barriers, as NVN allows, and were not run on this change.Open
About 37 full entry barriers a frame remain on Ocarina of Time (
ORDER_PRIMITIVESbarriers, compute in between), and about 1.3 ms a frame of gaps at command-buffer boundaries (segment cuts and the CPU commit).