Skip to content

Ocarina of Time (Switch 2): vertices streak to the origin and models flicker or drop out with the uniform read bound on (26062f9e) #2218

Closed

Description

@Know-It-All-Brother

Symptom

Since main's uniform read bound (26062f9e, from #1860), Ocarina of Time draws long white streaks from the horses at Lon Lon Ranch and from Link's slingshot. Parts of the slingshot and of the ReDeads' faces also flicker, dropping out for a frame and coming back. With the bound off, all of it is gone.

on main
Image

Image Image

with #2219

CleanShot.2026-11-10.at.10.26.15.mp4

How it can look

There's no [RED] line. The quickest check is a build from before 26062f9e, or with #2219.

In the host, this is main's uniform read bound for constant buffers: the zero padding of short bindings (ub_padded) and the size table at bank 25 (DMSH_CBSIZE_BANK) for reads at computed offsets. The Switch 2's NVN (NVN2) doesn't seem to stop a read at the size passed to nvnCommandBufferBindUniformBuffer.

Setup

  • MacBook Pro M5 Max, macOS 27.0, 0400486024DEC000 v131072.
  • My own branch: main from this morning plus some changes of my own. The bound code is main's, unchanged.

What we tested

We ran three variants of the bound in the same places:

Bound Stretching Flicker
main's, the size the game binds yes yes
the size taken as 4-byte words, at most 64 KB gone still on the slingshot and the ReDeads' faces
none, as before 26062f9e gone gone

Two things pointed at the words idea first. The mesh shaders read up to 16,384 bytes of slots bound with 4,096, and pixel shaders read up to 20,480 of 5,120, which is exactly 4× in both cases. But with the words bound, 5,179 slots across 465 shaders could still read past it at computed offsets, and the flicker stayed. The bound sizes themselves are 16, 64, 256 and 1,024 bytes, which look like plain byte sizes.

So it looks like the Switch 2 doesn't stop a uniform read at the size the game binds, and the game relies on that. Switch 1 games like Paper Mario do need the bound, so I'd keep it for them.

Related

I've opened #PR to turn the bound off for Switch 2 games.

Activity

  1. changed the title [-]Ocarina of Time (Switch 2): vertices stretch and flicker with the uniform read bound on (26062f9e)[/-] [+]Ocarina of Time (Switch 2): vertices streak to the origin and models flicker or drop out with the uniform read bound on (26062f9e)[/+] on Nov 10, 2026
  2. seedds commented on Nov 11, 2026

    @seedds
    Owner

    Thanks for the report and the three-way test, which narrowed this a lot.

    What I found. The Switch 2's driver does give the GPU a size for each uniform binding, so the bound itself exists there too. But both drivers round that size up to 256 bytes first, and the host did not:

    Driver Where What it writes for a binding of n bytes
    NVN2 Ocarina of Time's sdk, nvnCommandBufferBindUniformBuffer at 0x67bc80 method 0xe02, size field ((n + 0xff) >> 8) << 20
    NVN1 Sonic Superstars' sdk, 0x467170 method 0x8e0, (n + 0xff) & ~0xff

    So a read between the bound size and the next multiple of 256 gets the memory there on the console, and got 0 on the host. Ocarina binds 16, 64, 144, 192, 464, 976, 16,960 and 41,600 bytes, all of which this changes.

    What changed. 1d090a6 on main rounds the size up to 256 for both parts of the bound (the zero-padded copy and the size table), for every game. No shader rebuild is needed.

    What I do not know. I could not reproduce the streaks or the flicker on my Mac, with or without the change: the slingshot aimed at Link's house and the ReDeads in adult Castle Town both drew correctly, on the older form of the bound and on main. So I cannot say this fixes it. It does not change your 4,096-byte slots read up to 16,384, which are already multiples of 256; if those are the cause, the streaks will remain.

    Could you retest on main (1d090a6 or later), plain, without #2219? If the streaks or the flicker are still there, these would pin it:

    • the log lines uniform slot N of shader K (stage S) is bound with B bytes (R readable, a multiple of 256) and read up to byte E at fixed offsets, from a run that shows the streaks at the horses or with the slingshot;
    • where you stood (a save at Lon Lon Ranch would let me reproduce it here);
    • whether it also happens on a build from before e45694b (where the bound was only compared in the shader, with no padded copy). If it does not, the copy being taken too early for buffers the game writes later is the next suspect.

    The issue stays open until then.

  3. Know-It-All-Brother commented on Nov 12, 2026

    @Know-It-All-Brother
    ContributorAuthor

    I'm closing this because the cause was in my build, not in main. I tested on main and didn't see the streaks or the flicker.

    Root cause. My build carried an older fast path from another fork, which handles a draw that only rebinds uniform buffers by copying the shader's previous argument table and rewriting just the uniform slots. It was written before the uniform read bound (26062f9), so it didn't know about either part of it:

    • It copied the size table's slot unchanged, so the sizes stayed those of the previous full encode. A draw that first bound 16 bytes and later 976 still had its reads stop at 16, so skinned models like the horses and the slingshot read zero bone matrices and their vertices collapsed to the origin.
    • It skipped the zero padding, so whether a draw was bounded depended on which path encoded it. That could change from frame to frame, which fits the flicker.

    This also explains the three-way test above. Taking sizes as 4-byte words made the stale sizes big enough to hide most of it, and turning the bound off hid all of it, which is why #2219 looked like a fix. I've closed #2219. Main's own version of that path (adaff73, args_cbuf_only) rewrites the size table, so main doesn't have this bug.

    Thanks @seedds for digging into the drivers, and to everyone who tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions