aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2021-05-04 20:16:00 +0200
committerAndre Weissflog <floooh@gmail.com>2021-05-04 20:16:00 +0200
commita35bea524ffafe6bd1f399a25a6cda6332c0752a (patch)
treeeb6280a04d05defc51ed732c4d1085f7620f5c21
parent23239cfc8cf9309b2bd8983fcd771f2635fc992b (diff)
sokol_gfx.h mtl: ignore context commit if context wasn't rendered to
-rw-r--r--sokol_gfx.h11
1 files 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<MTLDrawable>) 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);