Repository navigation
Compute dispatches can be ordered by the memory they touch (DM_NVN_DISPATCH_DEPS=1, opt-in): Fire Emblem Fortune's Weave's 345 dispatches take 0.9 ms of GPU instead of 4.2 - #1076
Closed
parsifal295 wants to merge 3 commits into
Conversation
Contributor
|
the -[NvPkg heap] crash on DK. The cause is that dr_tex treats what tex_get returns as a texture. For a texture from the game’s files it returns the NvPkg holder, which the rest of the host unwraps first; I named the one-line fix. |
parsifal295
force-pushed
the
dispatch-deps
branch
from
November 3, 2026 23:54
de00432 to
b806779
Compare
Contributor
Author
|
Thanks @dpadr, that's exactly it: |
…SPATCH_DEPS=1): Fire Emblem Fortune's Weave's 345 dispatches a frame take 0.9 ms of GPU instead of 4.2
…les) is unwrapped before its Metal texture is asked for its heap (Donkey Kong Bananza crashed in -[NvPkg heap])
…ernel main added since, takes dispatch_enc's host-kernel path (NULL, 0)
parsifal295
force-pushed
the
dispatch-deps
branch
from
November 11, 2026 01:43
ebad9bf to
c4c26ac
Compare
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.
What and why
DM_NVN_GPUPROFon Fire Emblem Fortune's Weave's battle map shows one compute encoder with 345 dispatches taking 4.2 ms of GPU a frame. The dispatches are cube map faces and mip levels, then about 285 small particle dispatches. WithDM_NVN_BLIT_ORDER=0(the diagnostic that drops barriers) the same encoder takes 0.9 ms. The time goes todispatch_enc, which records every dispatch as having written all memory, so each dispatch waits for everything before it. That works out to about 9.7 µs per barrier on an M1 Pro.With
DM_NVN_DISPATCH_DEPS=1, a translated shader's dispatch is ordered by the memory its bindings touch, the same wayblit_bufalready orders copies:A dispatch takes a barrier only when these ranges meet what the encoder's operations wrote since the last barrier, or, for its writes, what they read.
Some bindings cannot be bounded: global memory, bindless or pool handles, buffer textures, a storage buffer in a sparse pool, or more than 48 ranges. Those dispatches keep the old rule, as do host kernels. With the variable unset, the code path is the same as before. The only change there is that the copy arrays grow to 256 entries, and copies still take a barrier at 64.
This is opt-in on purpose. It relies on the reflection naming every byte a shader touches, and I have checked only one game. If it looks right to you, it could become the default after
regress.pyon more games.The reference entry is Compute dispatches ordered by the memory they touch (opt-in). The switch is in
docs/env_switches.tsv.Checked
Tests:
make -C dm/gfx/tests GAME=04007EF01F8AE000 runpasses with and withoutDM_NVN_DISPATCH_DEPS=1.test_docsandtest_env_switchespass, anddocs_symptoms.pywas run.Game: Fire Emblem Fortune's Weave (
04007EF01F8AE000, v131072), battle map save, headless, docked,DM_NVN_GPUPROF=1500. Same binary, with and without the variable:Not checked:
Measured on: main 4129936's build. The PR branch is main aa9fa76 plus this change, built and tested; the chain has changed, so there is no game build at that revision here.
Devices and OS: MacBook Pro M1 Pro, macOS 27.2, Xcode 27.2.
regress.py: not run (it needs every local game rebuilt at main's chain).impactlists every NVN game with compute.Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)