Repository navigation
A 1D array texture uploads one row per layer, not its layer count of rows - #2399
Open
computerguy526 wants to merge 1 commit into
Open
computerguy526 wants to merge 1 commit into
computerguy526 wants to merge 1 commit into
Conversation
…rows A 1D array (NVN target 3) is made as a one-row 2D array whose layer count is the NVN height (tex_desc), but the upload paths took that height as each layer's row count: every layer went up as `height` rows into a one-row slice. Metal's validation refuses the copy ((destinationOrigin.y + sourceSize.height) (64) must be <= height(1)); without it the GPU writes past each slice into the next layers. PRAGMATA's light-profile lookup table, a 512-wide R16F 1D array of 64 layers read by the deferred lighting, went up as 64 copies of 64 rows, and the junk rows flashed a light across a wall. tex_lh gives a level's rows as the Metal texture holds them (1 for 1D and 1D array textures); pkg_upload_'s byte count and both deswizzle loops, and the sparse texture's tile grid and tile uploads, use it. Other targets keep their row count. t_partial_upload: two 1D array cases (R16F 512 x 64 layers, and RGBA8 with levels), direct and CPU uploads. Under MTL_DEBUG_LAYER=1, main aborts on the copy above; with the change 4,551 checks pass. Co-authored-by: uncraftablexd <352372032+uncraftablexd@users.noreply.github.com>
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.
Related to the PRAGMATA bring-up, ccd834e (@seedds).
A 1D array (NVN target 3) is created as a one-row 2D array whose layer count is the NVN height (
tex_desc). The upload paths took that same NVN height as each layer's row count. So every layer went up asheightrows into a one-row slice. Metal's API validation refuses these copies (destinationOrigin.y + sourceSize.height must be <= height). Without validation the GPU writes past each slice, into the next layers.Found on PRAGMATA: its light-profile lookup table is a 512-wide R16F 1D array of 64 layers, read by the deferred lighting. It went up as 64 copies of 64 rows. The junk rows made a light flash across a wall when the camera crossed a distance band. That was one of two causes of the flicker on my branch. The other was a host experiment of mine that
maindoes not have. With both fixed, the flicker was gone by eye on the route where it showed (macOS 26, M4 Pro).What changes
tex_lhgives a level's row count as the Metal texture holds it: 1 for a 1D or 1D array texture, the NVN height otherwise.pkg_upload_'s byte count, its GPU deswizzle and CPU deswizzle loops, and the sparse texture's tile grid and tile uploads.Tests
t_partial_uploadgets two 1D array cases,R16F 1D array(512 x 64 layers, PRAGMATA's shape) andRGBA8 1D array with levels, with and without the direct (GPU) upload. Run underMTL_DEBUG_LAYER=1as before. Onmainthe first 1D array case aborts in validation:(destinationOrigin.y + sourceSize.height)(64) must be <= height(1). With the fix, all 4,551 checks pass.Regression
regress.py impactpicks The Legend of Zelda: Breath of the Wild, Pokémon Scarlet and The Legend of Zelda: Tears of the Kingdom (the profiles with a usage manifest, throughnvn_mtl.m). They were not run.