metal: Clear bogus pointer if we fail to get a new drawable.

Reference Issue #16232.

(cherry picked from commit ea74d3b018)
This commit is contained in:
Ryan C. Gordon
2026-09-04 15:50:05 -04:00
parent 9a29f763e1
commit 9e7e1271fd

View File

@@ -466,6 +466,8 @@ static bool METAL_ActivateRenderCommandEncoder(SDL_Renderer *renderer, MTLLoadAc
}
}
data.mtlpassdesc.colorAttachments[0].texture = mtltexture;
/* mtltexture can be nil here if macOS refused to give us a drawable,
which apparently can happen for minimized windows, etc. */
if (mtltexture == nil) {
@@ -478,7 +480,6 @@ static bool METAL_ActivateRenderCommandEncoder(SDL_Renderer *renderer, MTLLoadAc
}
data.mtlpassdesc.colorAttachments[0].loadAction = load;
data.mtlpassdesc.colorAttachments[0].texture = mtltexture;
data.mtlcmdbuffer = [data.mtlcmdqueue commandBuffer];
data.mtlcmdencoder = [data.mtlcmdbuffer renderCommandEncoderWithDescriptor:data.mtlpassdesc];