floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.82k stars 475 forks source link

sokol_gfx.h mtl: new attempt to fix swapchain lifetime issues #873

Closed floooh closed 1 year ago

floooh commented 1 year ago

See https://github.com/floooh/sokol/issues/872

This does away with the separate retained-reference command buffer for the present call, and instead uses the regular 'deferred release queue' for the default pass MTLRenderPassDescriptor. Since the render-pass-descriptor holds a strong-ref to swapchain surfaces this should make sure that those surfaces outlive their command buffer when they are released by MTKView because of a window resize. This means there's a memory spike during window resize, but I guess there's no way around that.

This also replaces the changes from https://github.com/floooh/sokol/pull/763 with a different approach.