Skip to content

Conversation

@krajzeg
Copy link
Contributor

@krajzeg krajzeg commented Dec 14, 2025

When you change the pipeline to one that uses a different number of vertex/fragment uniform buffers, that moves the actual locations storage buffers should be bound to on the Metal side.

This PR makes the GPU Metal driver take that into account when changing the pipeline. Beforehand, buffers would not be rebound at their new locations, causing issues.

Description

The new code compares the previous and new pipeline when they change, and checks whether the base index of where storage buffers are located on the Metal side has changed (this is caused by uniform buffers pushing them higher/lower). If the base index has changed, it forces a rebind.

This logic is repeated for vertex and fragment storage buffers.

It's possible there are similar bugs to this one if other resource types also share indices on the Metal side in this way, eg. storage textures. It would probably be good if someone more familiar with the Metal backend checked whether that is the case, possibly adding more forced rebinds on pipeline change if needed.

Existing Issue(s)

Fixes #14652.

@slouken slouken requested a review from TheSpydog December 14, 2025 16:06
@slouken slouken modified the milestones: 3.2.30, 3.4.0 Dec 14, 2025
@slouken
Copy link
Collaborator

slouken commented Dec 15, 2025

@TheSpydog, do we need similar changes for other resource types?

@slouken slouken merged commit 73c9f25 into libsdl-org:main Dec 15, 2025
43 checks passed
@slouken slouken modified the milestones: 3.4.0, 3.2.30 Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPU: Metal: Storage buffers not rebound correctly when pipeline changes

3 participants