Repository navigation
Same-pass feedback: a read-only image load of a colour attachment takes the snapshot too (#1009) - #1035
Closed
Haseenesss wants to merge 2 commits into
Closed
Same-pass feedback: a read-only image load of a colour attachment takes the snapshot too (#1009)#1035Haseenesss wants to merge 2 commits into
Haseenesss wants to merge 2 commits into
Conversation
…es the snapshot too (seedds#1009) Xenoblade Chronicles 3's lighting-zone shader 15816d836842bfb5 (shd_lgt.wishp) reads its own R32Uint colour attachment through a read-only image between the game's barriers, to skip zones it has already marked. On Apple's tiled GPUs the attachment stays in tile memory until the pass ends, so the image load read the previous frame's stored content instead of this pass's clear and draws; each zone bit inverted every frame and rendered cutscenes flickered. fb_prepare took the same-pass feedback snapshot only for sampled textures. A read-only, non-atomic fragment image whose binding is one level and layer of a colour attachment now takes the same path, and encode_args binds the snapshot for that draw, declared read-only. Both sides compare the object img_binding returns; a slot whose pixel class needs a reinterpreting view is left as is. The translated slot has no access qualifier (access::sample), so the shader-read snapshot is a legal binding. t_feedback gains an image case for modes 0, 1 and 2 under the Metal debug layer. On an M2, Events Theater chapter 1's second scene alternated every frame before (sign-flip fraction 0.83-1.00 in 8 of 10 bursts) and holds one level after (at most 0.28); GPU p50 50.4 -> 53.0 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thank you. #1025 and this PR fixed #1009 the same way. #1025 landed (f5d5327) because it was built on current main, where the tile-read path ( |
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.
A fragment shader that reads its own colour attachment through a read-only image now gets the same-pass feedback snapshot that a sampled texture already got.
Closes #1009.
Cause
Xenoblade Chronicles 3's lighting-zone shader
15816d836842bfb5(shd_lgt.wishp) reads its own R32Uint colour attachment through image slot 0 between the game's barriers, to skip zones it has already marked. On Apple's tiled GPUs the attachment stays in tile memory until the pass ends, so the image load read the previous frame's stored content instead of this pass's clear and earlier draws. Each zone bit inverted every frame, and rendered cutscenes alternated brightness with blocky light/shadow bands.fb_preparehandled this forNVN_RB_TEXslots only; read-onlyNVN_RB_IMGslots read the attachment directly.Change
fb_prepare(nvn_mtl.m): a read-only, non-atomic fragment image (reg < 32) whose binding is one level and layer of a colour attachment takes the same snapshot as a texture sample, including the direct-read mask (a later writer then starts a new pass).encode_args,NVN_RB_IMGbranch: binds the snapshot for that draw, declaredMTLResourceUsageRead.img_bindingreturns. ARegisterImageview already names one level and layer, and a swizzle-only binding isimg_fit's identity view of the same range. A slot whose pixel class needs a reinterpreting view is left as is.texture2d<uint>with no access qualifier (access::sample; reflectionrw= 0), so the shader-read snapshot is a legal binding. The chain is unchanged.docs/reference/rendering.md), the symptom index, and the finding in Xenoblade Chronicles 3's note.This builds on the patch attached to the issue; the image is resolved through
img_bindingon both sides so level/layer views match.Checks
Apple M2 (8 GB), macOS 27.2, Xcode 27.2.
make -C dm/gfx/tests GAME=010074F013262000 run: exit 0.check_t_feedbackgains an image case underMTL_DEBUG_LAYER=1: default 102 checks,DM_NVN_FB_SNAP=all --image23,DM_NVN_FB_SNAP=0 --image17, 0 failed. It covers a level-1 view of a two-level R32UI against the level-1 attachment (and not level 0), a SINT class on R32Uint left as is, the value after a clear and an earlier draw (0x33, not the pre-pass 0x11), and an image read of an unwritten attachment making a later writer end the pass.make -C dm/host GAME=010074F013262000builds.lint_c.py tidy(LLVM 23.1.4) onnvn_mtl.m: 0 file/check pairs above the baseline.test_docs.pyOK.5474c6f, the chain of the shader libraries built for the game), Events Theater chapter 1, second scene (the battle with Colony Sigma), 48 consecutive distinct presents per burst, crop luminance:[RED]lines.regress.py
regress.py impact origin/main..HEAD: 3 games use what the change touches (Breath of the Wild, Pokémon Scarlet, Tears of the Kingdom, throughfb_prepare/encode_args→nvnQueueSubmitCommands), 128 profiles have no usage manifest. None of those three is on this machine, and no local game has an NSP folder with a--platform macbuild in the layoutcheckneeds, socheck --gameswas not run. The change does not touch the chain, sochainhas nothing to compare. The Xenoblade Chronicles 3 A/B above is the runtime check; games that sample their own attachments through textures (BotW's decals, agl's post effects) take an unchanged path, since only read-onlyNVN_RB_IMGslots are added.🤖 Generated with Claude Code