Repository navigation
Prepare compute texture bindings before opening the dispatch encoder - #1755
thehobbit85 wants to merge 1 commit into
Conversation
Related to seedds#1743. Resolve format-view upgrade copies before encoder selection and dependency barriers; cover direct and indirect cold/warm dispatches with synthetic Metal fixtures.
a33b39c to
ab2bfe2
Compare
|
Tested against Ocarina of Time on an M2 Pro (19-core GPU, 32 GB, macOS 27.2, the G14X driver). Here The tree is main
So in game, the change fixes this crash. The hang after it is the one tracked in #1326; this tree hangs there with shared encoders too (21 of 21 runs). |
…inding that upgrades its texture for a view of another format copies the pixels through the copy encoder, which opened a second encoder beside DM_NVN_DISPATCH_OWN's (Ocarina of Time crashed in AGX prepareForEnqueue at the Kokiri Forest load) and by default landed after the dispatch's barrier, so the shader could read the old pixels (PR #1755) Compute bindings only write the argument table, so encode_args needs no open encoder; any copy a binding issues now comes before the shared encoder's barrier, as image_prepare already does for image writes. t_dispatch_own checks pixels and driver group counts for direct and indirect dispatches, first and cached views, both encoder modes and both encoding threads; it fails without the change on an M6 (stale pixels shared, open-encoder abort separate). Ocarina of Time on an M2 Pro (Amost-): 5 of 5 runs crashed before, 3 of 3 loaded the forest after. Fixes #1743 Co-authored-by: Eliran Zach <4012041+thehobbit85@users.noreply.github.com>
|
Landed as 7b6506d, with you credited as co-author. Thank you, and thanks to @Amost- for confirming it in Ocarina of Time (5 of 5 crashes before, 3 of 3 clean after). The fix and the test are kept as written. Doc changes:
Checked on an M6: |
…inding that upgrades its texture for a view of another format copies the pixels through the copy encoder, which opened a second encoder beside DM_NVN_DISPATCH_OWN's (Ocarina of Time crashed in AGX prepareForEnqueue at the Kokiri Forest load) and by default landed after the dispatch's barrier, so the shader could read the old pixels (PR seedds#1755) Compute bindings only write the argument table, so encode_args needs no open encoder; any copy a binding issues now comes before the shared encoder's barrier, as image_prepare already does for image writes. t_dispatch_own checks pixels and driver group counts for direct and indirect dispatches, first and cached views, both encoder modes and both encoding threads; it fails without the change on an M6 (stale pixels shared, open-encoder abort separate). Ocarina of Time on an M2 Pro (Amost-): 5 of 5 runs crashed before, 3 of 3 loaded the forest after. Fixes seedds#1743 Co-authored-by: Eliran Zach <4012041+thehobbit85@users.noreply.github.com>
… and archived, the dynamic resolution that climbs on measured load and recycled render-target heaps, pipeline archive indexes, the -fwrapv, raw vector miss and mesh object fixes, the mist fix through frag_z_snap - Our frag_z (d78e724, PR seedds#1742) gives way to upstream's frag_z_snap for the same mist specks: dmsh_build.py, its tests and notes are upstream's - tex_mtl_: the GPU-only pool's heap (pool_heap_texture) first, then upstream's recycled heap of its own (rh_texture), then DM_NVN_RT_RECLAIM's free list, then a new texture - dispatch keeps our (dp, next) signature; upstream's seedds#1755 body is the same - The translator dlls, lock and chain header are upstream's here; they must be rebuilt from these sources (our ResolveRawRuns beside upstream's raw vector miss and follower-group fixes in GlobalToStorage.cs) before a build Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Aax1HnchwCweUDRNWjhHx9
…der) Upstream pull requests applied in this commit (their authors' work, brought onto this tree with a three-way merge; the description is in each PR): - seedds#1755 by thehobbit85 (closed): Prepare compute texture bindings before opening the dispatch encoder
What and why
Related to #1743. This fixes a reproducible host defect found while investigating that report; the issue stays open because the exact Ocarina of Time crash has not been confirmed against the game.
Resolving a compute shader's sampled texture can upgrade its allocation for a different-format view and copy the old pixels. Previously
dispatchopened its compute encoder before resolving arguments. WithDM_NVN_DISPATCH_OWN=1, the upgrade opened a second encoder on the same command buffer and crashed the Metal driver. With shared encoders, the upgrade copy came after the dispatch barrier and the shader could read stale pixels.Prepare the compute argument table before selecting/opening the encoder and placing its dependency barrier. Compute bindings only populate the argument table, so they need no open encoder. The change preserves the existing barriers, direct/indirect group counts, and encoder selection.
The regression builds an 8×8 texture and a tiny compute shader entirely from synthetic data. It checks preserved pixels and driver group counts for direct/indirect dispatches, first-use/cached views, shared/separate encoders, and immediate/threaded encoding.
Validation after conflict resolution — 2026-11-08 07:50 UTC
Tested head
ab2bfe2b6a5a324a8c8b6ec39feee9b219a1ed20rebasesa33b39c553d60af81b422c1e1b63228c9af446a2onto main62f6a52c4fa9b42b73e5c37ef9a88794c8d15ae5. Ocarina's findings list keeps both main's Pro Controller duplicate-device fix and this independent compute encoder finding. The seven feature paths have identical patch lines; all 18 upstream-only changed paths match main. The generated symptom index was refreshed.Fresh checks on this exact head, Apple M2 Max, macOS 26.6 / Xcode27.2 (27B52):
python3 -m unittest discover -s dm/tools/tests -p test_docs.py: all 11 tests pass.make -C dm/gfx/tests GAME=010015100B514000 check_t_dispatch_own: 21 checks in each of four shared/separate and immediate/threaded configurations pass with Metal validation.make -C dm/host GAME=010015100B514000 -j3andgit diff --check 62f6a52c..HEADpass.python3 dm/tools/lint_c.py compdbsucceeds;LLVM=<LLVM23.1.4> python3 dm/tools/lint_c.py tidy -j2 dm/gfx/nvn/nvn_mtl.m dm/gfx/tests/t_dispatch_own.mfinds zero fixture diagnostics and 62 renderer/header diagnostics. The ratchet remains failing with two file/check pairs above the baseline (BitwiseShift and ArrayBound). The exact main source gives the same diagnostic messages and counts, ignoring shifted line numbers. No suppression or baseline edit was made.The broader suite and baseline reproductions below remain historical at their named revision. No fresh gameplay, device test, full graphics run or remote-CI success is claimed; the exact Ocarina report and deferred-uniform/GPU-produced-count coverage remain open.
Earlier validation on
a33b39c5Apple M2 Max, arm64, macOS 26.6, Xcode 27.2 (27B52), base
555122a9069235441d5a88955105397ec6d53686.Command buffer already has an open command encoderin separate-encoder mode. Shared mode fails its preserved-pixel assertion. Without validation, the original synthetic reproduction faults inAGX::ComputeContext::endComputePassat address0x84; the report's M1 Max stack is inprepareForEnqueueat0x98, so these are not claimed to be an identical game reproduction.make -C dm/gfx/tests GAME=010015100B514000 check_t_dispatch_own: 21 checks × four configurations, zero failures, with Metal API validation. This was rerun after the base comparison restored the fix.make -C dm/host GAME=010015100B514000 -j3succeeds.t_present_cropcrashes;t_render_counter_overlapfailsCopyBuffer0(1/42);t_render_enable_queuefails 8/38. Both additional Python graphics checks pass. These same baseline failures are recorded in Fix CI fixtures and lint ratchets #1746. No test was weakened or skipped to obtain a green result.test_xcode_workflowhas six subcase errors for a missing syntheticRomFS.img, andtest_env_switcheshas stale table rows. Both reproduce in a separate source snapshot of the unchanged base and are already addressed by Fix CI fixtures and lint ratchets #1746.git diff --checkpasses.test_patches.pyhas existing baseline drift (376 findings against 371 listed, five new counts), also covered by Fix CI fixtures and lint ratchets #1746. No Python source is changed here.Game coverage and limits
No game files, extracted shaders, saves, keys, or device inputs were used. No gameplay, iPhone, or exact reported M1 Max crash validation is claimed. The fixture uses CPU-supplied indirect counts; it does not independently exercise GPU-generated counts or deferred uniform updates.
regress.py impact 555122a9..HEADreports three affected games with manifests (Breath of the Wild, Pokémon Scarlet, Tears of the Kingdom), one unaffected, and 149 unknown because they have no manifest. The five selected gameplay checks would be:0400486024DEC000)01002B00111A2000)01006BB00C6F0000)01007EF00011E000)0100F2C0115B6000)scripts/regress.py check --games 0400486024DEC000,01002B00111A2000,01006BB00C6F0000,01007EF00011E000,0100F2C0115B6000could not run: no game-build/harness paths are available. Its configuration check exits 2 before any game run. All five games and other titles remain unchecked; there is no passing gameplay report.Docs