From a35bea524ffafe6bd1f399a25a6cda6332c0752a Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Tue, 4 May 2021 20:16:00 +0200 Subject: sokol_gfx.h mtl: ignore context commit if context wasn't rendered to --- sokol_gfx.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sokol_gfx.h b/sokol_gfx.h index cf9014df..5167b2d5 100644 --- a/sokol_gfx.h +++ b/sokol_gfx.h @@ -10719,7 +10719,6 @@ _SOKOL_PRIVATE void _sg_mtl_commit(_sg_context_t* ctx) { SOKOL_ASSERT(!_sg.mtl.pass_valid); SOKOL_ASSERT(ctx->mtl.drawable_cb || ctx->mtl.drawable_userdata_cb); SOKOL_ASSERT(nil == _sg.mtl.cmd_encoder); - SOKOL_ASSERT(nil != ctx->mtl.cmd_buffer); _SOKOL_UNUSED(ctx); #if defined(_SG_TARGET_MACOS) @@ -10734,10 +10733,14 @@ _SOKOL_PRIVATE void _sg_mtl_commit(_sg_context_t* ctx) { else { cur_drawable = (__bridge id) ctx->mtl.drawable_userdata_cb(ctx->mtl.user_data); } - if (nil != cur_drawable) { - [ctx->mtl.cmd_buffer presentDrawable:cur_drawable]; + + // cmd_buffer will be nil if nothing was rendered this frame + if (nil != ctx->mtl.cmd_buffer) { + if (nil != cur_drawable) { + [ctx->mtl.cmd_buffer presentDrawable:cur_drawable]; + } + [ctx->mtl.cmd_buffer commit]; } - [ctx->mtl.cmd_buffer commit]; /* garbage-collect resources pending for release */ _sg_mtl_garbage_collect(_sg.frame_index); -- cgit v1.2.3