Repository navigation
Conversation
added 2 commits
November 9, 2026 21:14
…ck-linear one: the video decoder's output pool (Tsukihime's movies) carries NVN_TEXTURE_FLAGS_LINEAR | NVN_TEXTURE_FLAGS_VIDEO_DECODE, and write_region_bl's geometry refuses a LINEAR layout, so the write fell to the swizzle fallback, which reinterprets the linear storage as block-linear (a whole 1920x1080 frame writes a few thousand misplaced bytes, hb being the GOB-row count) and the row-based upload shows the texture as empty: a black movie backdrop. Dispatching on the texture's flags is what the CopyTextureToTexture mirror already did
…yte sample, for the games whose movies draw black
seedds
added a commit
that referenced
this pull request
Nov 11, 2026
…e-texture movie into a LINEAR texture is no longer black: write_texels wrote every texture by block-linear address, nvn_deswizzle_geom refuses a LINEAR or LINEAR_RENDER_TARGET layout, so write_region_bl failed, and the whole-level fallback's nvn_swizzle refused it too with its result ignored: the storage kept what it held, with no log line for a whole-texture write. The host's native-texture movie output (nvn_host_write_texture) goes through it, so TSUKIHIME -A piece of blue glass moon- (01001DC01486A000, no profile in the repository) drew its title backdrop, a 1920x1080 RGBA8 LINEAR | VIDEO_DECODE movie texture, black. Now a linear texture is one 2D level of rows of its stride (tex_linear_row, the stride GetStorageSize counts, now shared by ReadTexels, the upload, gsb_geom and linear_fit), written as ReadTexels reads it; a region outside those rows, another target or level, or a block-compressed format is refused with a [RED] line, as is a block-linear write nvn_swizzle refuses. mtl_tex_linear_cpu_written leaves a texture viewed on its pool's buffer (linear_fit) as that view, which reads the storage itself (made CPU-written it would be uploaded whole at each write); any other is taken from its storage as tex_mtl_ takes one at first use. The diagnosis is PR #1983's (the probe showing each title-movie frame in the source and not in the storage, and the author's Mac run of the title, the opening movie, event movies and gallery CGs with the fix); changed here: the PR's write_region_mirror no longer exists on main (ab41d6a), LINEAR_RENDER_TARGET is covered too, the buffer view is no longer made CPU-written, the DM_MOVIE_DBG probe is left out for the [RED] lines. New reference entry (WriteTexels into a linear texture dropped the write); movies.md no longer says the output is always block-linear. Checked: t_nvn 311 checks with the new 6c2b (a 37x5 LINEAR | VIDEO_DECODE texture of stride 256 and a 16x16 LINEAR_RENDER_TARGET of stride 128, four regions each, some with a padded source stride: storage byte for byte with the row padding and the bytes after, a region past the last row refused, ReadTexels back, no CPU-written texture added for the buffer views; without the linear branch 3 fail, with mtl_tex_cpu_written in place of the view rule the last fails), t_linear_readback 61 cases, t_cpu_storage 135, t_cpu_tex 23, t_direct_upload 26,384, t_partial_upload 3,585, test_docs; lint_c.py tidy on the changed sources: nothing above main's own count (nvn_mtl.m's nullability pair is 18 on main as here). Not run: any game (Tsukihime is not here), the full Mac host build, iOS, regress.py (only linear textures change, which were not written before). Open: a LINEAR_RENDER_TARGET or IMAGE linear texture the GPU drew into as a private texture and the CPU then partly writes is uploaded from its storage, as a block-linear one is (PR #1983) Co-authored-by: Beeven <5119686+beeven@users.noreply.github.com>
Owner
|
Thanks: the diagnosis was right, and it landed on main as 9d60776, with you credited as co-author. It was rewritten rather than merged because
Not run here: Tsukihime itself, which isn't on this machine. A retest of the title screen, the opening movie and the gallery on current main would be welcome. |
kingbumi31
pushed a commit
to kingbumi31/no-lag-kart
that referenced
this pull request
Nov 15, 2026
…e-texture movie into a LINEAR texture is no longer black: write_texels wrote every texture by block-linear address, nvn_deswizzle_geom refuses a LINEAR or LINEAR_RENDER_TARGET layout, so write_region_bl failed, and the whole-level fallback's nvn_swizzle refused it too with its result ignored: the storage kept what it held, with no log line for a whole-texture write. The host's native-texture movie output (nvn_host_write_texture) goes through it, so TSUKIHIME -A piece of blue glass moon- (01001DC01486A000, no profile in the repository) drew its title backdrop, a 1920x1080 RGBA8 LINEAR | VIDEO_DECODE movie texture, black. Now a linear texture is one 2D level of rows of its stride (tex_linear_row, the stride GetStorageSize counts, now shared by ReadTexels, the upload, gsb_geom and linear_fit), written as ReadTexels reads it; a region outside those rows, another target or level, or a block-compressed format is refused with a [RED] line, as is a block-linear write nvn_swizzle refuses. mtl_tex_linear_cpu_written leaves a texture viewed on its pool's buffer (linear_fit) as that view, which reads the storage itself (made CPU-written it would be uploaded whole at each write); any other is taken from its storage as tex_mtl_ takes one at first use. The diagnosis is PR seedds#1983's (the probe showing each title-movie frame in the source and not in the storage, and the author's Mac run of the title, the opening movie, event movies and gallery CGs with the fix); changed here: the PR's write_region_mirror no longer exists on main (ab41d6a), LINEAR_RENDER_TARGET is covered too, the buffer view is no longer made CPU-written, the DM_MOVIE_DBG probe is left out for the [RED] lines. New reference entry (WriteTexels into a linear texture dropped the write); movies.md no longer says the output is always block-linear. Checked: t_nvn 311 checks with the new 6c2b (a 37x5 LINEAR | VIDEO_DECODE texture of stride 256 and a 16x16 LINEAR_RENDER_TARGET of stride 128, four regions each, some with a padded source stride: storage byte for byte with the row padding and the bytes after, a region past the last row refused, ReadTexels back, no CPU-written texture added for the buffer views; without the linear branch 3 fail, with mtl_tex_cpu_written in place of the view rule the last fails), t_linear_readback 61 cases, t_cpu_storage 135, t_cpu_tex 23, t_direct_upload 26,384, t_partial_upload 3,585, test_docs; lint_c.py tidy on the changed sources: nothing above main's own count (nvn_mtl.m's nullability pair is 18 on main as here). Not run: any game (Tsukihime is not here), the full Mac host build, iOS, regress.py (only linear textures change, which were not written before). Open: a LINEAR_RENDER_TARGET or IMAGE linear texture the GPU drew into as a private texture and the CPU then partly writes is uploaded from its storage, as a block-linear one is (PR seedds#1983) Co-authored-by: Beeven <5119686+beeven@users.noreply.github.com> (cherry picked from commit 9d60776)
kingbumi31
pushed a commit
to kingbumi31/no-lag-kart
that referenced
this pull request
Nov 15, 2026
…e-texture movie into a LINEAR texture is no longer black: write_texels wrote every texture by block-linear address, nvn_deswizzle_geom refuses a LINEAR or LINEAR_RENDER_TARGET layout, so write_region_bl failed, and the whole-level fallback's nvn_swizzle refused it too with its result ignored: the storage kept what it held, with no log line for a whole-texture write. The host's native-texture movie output (nvn_host_write_texture) goes through it, so TSUKIHIME -A piece of blue glass moon- (01001DC01486A000, no profile in the repository) drew its title backdrop, a 1920x1080 RGBA8 LINEAR | VIDEO_DECODE movie texture, black. Now a linear texture is one 2D level of rows of its stride (tex_linear_row, the stride GetStorageSize counts, now shared by ReadTexels, the upload, gsb_geom and linear_fit), written as ReadTexels reads it; a region outside those rows, another target or level, or a block-compressed format is refused with a [RED] line, as is a block-linear write nvn_swizzle refuses. mtl_tex_linear_cpu_written leaves a texture viewed on its pool's buffer (linear_fit) as that view, which reads the storage itself (made CPU-written it would be uploaded whole at each write); any other is taken from its storage as tex_mtl_ takes one at first use. The diagnosis is PR seedds#1983's (the probe showing each title-movie frame in the source and not in the storage, and the author's Mac run of the title, the opening movie, event movies and gallery CGs with the fix); changed here: the PR's write_region_mirror no longer exists on main (ab41d6a), LINEAR_RENDER_TARGET is covered too, the buffer view is no longer made CPU-written, the DM_MOVIE_DBG probe is left out for the [RED] lines. New reference entry (WriteTexels into a linear texture dropped the write); movies.md no longer says the output is always block-linear. Checked: t_nvn 311 checks with the new 6c2b (a 37x5 LINEAR | VIDEO_DECODE texture of stride 256 and a 16x16 LINEAR_RENDER_TARGET of stride 128, four regions each, some with a padded source stride: storage byte for byte with the row padding and the bytes after, a region past the last row refused, ReadTexels back, no CPU-written texture added for the buffer views; without the linear branch 3 fail, with mtl_tex_cpu_written in place of the view rule the last fails), t_linear_readback 61 cases, t_cpu_storage 135, t_cpu_tex 23, t_direct_upload 26,384, t_partial_upload 3,585, test_docs; lint_c.py tidy on the changed sources: nothing above main's own count (nvn_mtl.m's nullability pair is 18 on main as here). Not run: any game (Tsukihime is not here), the full Mac host build, iOS, regress.py (only linear textures change, which were not written before). Open: a LINEAR_RENDER_TARGET or IMAGE linear texture the GPU drew into as a private texture and the CPU then partly writes is uploaded from its storage, as a block-linear one is (PR seedds#1983) Co-authored-by: Beeven <5119686+beeven@users.noreply.github.com> (cherry picked from commit 9d60776)
kingbumi31
pushed a commit
to kingbumi31/no-lag-kart
that referenced
this pull request
Nov 15, 2026
…e-texture movie into a LINEAR texture is no longer black: write_texels wrote every texture by block-linear address, nvn_deswizzle_geom refuses a LINEAR or LINEAR_RENDER_TARGET layout, so write_region_bl failed, and the whole-level fallback's nvn_swizzle refused it too with its result ignored: the storage kept what it held, with no log line for a whole-texture write. The host's native-texture movie output (nvn_host_write_texture) goes through it, so TSUKIHIME -A piece of blue glass moon- (01001DC01486A000, no profile in the repository) drew its title backdrop, a 1920x1080 RGBA8 LINEAR | VIDEO_DECODE movie texture, black. Now a linear texture is one 2D level of rows of its stride (tex_linear_row, the stride GetStorageSize counts, now shared by ReadTexels, the upload, gsb_geom and linear_fit), written as ReadTexels reads it; a region outside those rows, another target or level, or a block-compressed format is refused with a [RED] line, as is a block-linear write nvn_swizzle refuses. mtl_tex_linear_cpu_written leaves a texture viewed on its pool's buffer (linear_fit) as that view, which reads the storage itself (made CPU-written it would be uploaded whole at each write); any other is taken from its storage as tex_mtl_ takes one at first use. The diagnosis is PR seedds#1983's (the probe showing each title-movie frame in the source and not in the storage, and the author's Mac run of the title, the opening movie, event movies and gallery CGs with the fix); changed here: the PR's write_region_mirror no longer exists on main (ab41d6a), LINEAR_RENDER_TARGET is covered too, the buffer view is no longer made CPU-written, the DM_MOVIE_DBG probe is left out for the [RED] lines. New reference entry (WriteTexels into a linear texture dropped the write); movies.md no longer says the output is always block-linear. Checked: t_nvn 311 checks with the new 6c2b (a 37x5 LINEAR | VIDEO_DECODE texture of stride 256 and a 16x16 LINEAR_RENDER_TARGET of stride 128, four regions each, some with a padded source stride: storage byte for byte with the row padding and the bytes after, a region past the last row refused, ReadTexels back, no CPU-written texture added for the buffer views; without the linear branch 3 fail, with mtl_tex_cpu_written in place of the view rule the last fails), t_linear_readback 61 cases, t_cpu_storage 135, t_cpu_tex 23, t_direct_upload 26,384, t_partial_upload 3,585, test_docs; lint_c.py tidy on the changed sources: nothing above main's own count (nvn_mtl.m's nullability pair is 18 on main as here). Not run: any game (Tsukihime is not here), the full Mac host build, iOS, regress.py (only linear textures change, which were not written before). Open: a LINEAR_RENDER_TARGET or IMAGE linear texture the GPU drew into as a private texture and the CPU then partly writes is uploaded from its storage, as a block-linear one is (PR seedds#1983) Co-authored-by: Beeven <5119686+beeven@users.noreply.github.com> (cherry picked from commit 9d60776)
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.
The symptom
Tsukihime (01001DC01486A000) renders its title screen with a black backdrop: the moon-and-clouds background is a fullscreen movie, and the game samples the texture the host gave the video decoder as if it were empty. Games whose movies deliver into a CPU buffer (the NV12 copy path) are unaffected: the decoder's native-texture output is the broken path.
The cause
The video decoder's output textures are NVN_TEXTURE_FLAGS_LINEAR | NVN_TEXTURE_FLAGS_VIDEO_DECODE (flags 0x12, RGBA8 1920x1080). write_texels (nvnTextureWriteTexels / Swizzled, what the decoder uses to deliver a frame) feeds every region to write_region_bl, whose geometry refuses a LINEAR layout (nvn_deswizzle_geom returns -1 for the linear flags), so the write falls to the swizzle fallback - which reinterprets the linear storage as block-linear: a whole-surface 1920x1080 region memcpys only hb = height/8 = 135 block-rows of misplaced bytes, then nvn_swizzle "swizzles" the linear storage over itself. The row-based upload of a LINEAR texture then shows a texture that stayed empty: the movie draws black.
write_region_linear and the flag dispatch already exist - write_region_mirror uses them for the CopyTextureToTexture mirror path since 3870fcc - but WriteTexels never took it. The first commit routes WriteTexels' region loop through write_region_mirror like the copy mirror does: block-linear textures take exactly the same path as before (the dispatch selects write_region_bl when the flag is clear), LINEAR textures get row-stride writes.
Evidence
With the second commit's DM_MOVIE_DBG probe, on the unpatched host each title-movie frame shows the write going in and not sticking: fmt=0x25 flags=0x12, swizzle-fallback, src_nz=129600 dst_nz=0 - the source holds the frame, the storage does not. Patched, the same writes report mirror: src_nz=129600 dst_nz=129600 - every frame of the title movie lands - and the title screen renders its backdrop:
The probe stays off unless DM_MOVIE_DBG is set (registered in docs/env_switches.tsv; one line per CPU texture write: which path wrote it, and a nonzero-byte sample of source vs storage), so a future "movie draws black" report can be triaged from one log line.
Tested on the mac host (M4 Pro, macOS 27.2): title screen, opening movie, in-game event movies and gallery CGs all render; the buffer-copy movie path never went through WriteTexels and is unchanged.