diff --git a/src/renderer_mtl.h b/src/renderer_mtl.h index cb445b84a..4cfd73217 100644 --- a/src/renderer_mtl.h +++ b/src/renderer_mtl.h @@ -1036,7 +1036,7 @@ namespace bgfx { namespace mtl ~SwapChainMtl(); void init(void* _nwh); - void resize(FrameBufferMtl &_frameBuffer, uint32_t _width, uint32_t _height, uint32_t _flags); + void resize(FrameBufferMtl &_frameBuffer, uint32_t _width, uint32_t _height, uint32_t _flags, uint32_t _maximumDrawableCount); id currentDrawableTexture(); diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index 7636385ce..690e43fd3 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -936,7 +936,7 @@ namespace bgfx { namespace mtl FrameBufferMtl& fb = m_frameBuffers[_handle.idx]; fb.create(denseIdx, _nwh, _width, _height, _format, _depthFormat); - fb.m_swapChain->resize(m_frameBuffers[_handle.idx], _width, _height, m_resolution.reset); + fb.m_swapChain->resize(m_frameBuffers[_handle.idx], _width, _height, m_resolution.reset, m_resolution.maxFrameLatency); } void destroyFrameBuffer(FrameBufferHandle _handle) override @@ -1262,7 +1262,7 @@ namespace bgfx { namespace mtl } m_resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE; - m_mainFrameBuffer.m_swapChain->resize(m_mainFrameBuffer, _resolution.width, _resolution.height, _resolution.reset); + m_mainFrameBuffer.m_swapChain->resize(m_mainFrameBuffer, _resolution.width, _resolution.height, _resolution.reset, m_resolution.maxFrameLatency); for (uint32_t ii = 0; ii < BX_COUNTOF(m_frameBuffers); ++ii) { @@ -3171,7 +3171,7 @@ namespace bgfx { namespace mtl retain(m_metalLayer); } - void SwapChainMtl::resize(FrameBufferMtl &_frameBuffer, uint32_t _width, uint32_t _height, uint32_t _flags) + void SwapChainMtl::resize(FrameBufferMtl &_frameBuffer, uint32_t _width, uint32_t _height, uint32_t _flags, uint32_t _maximumDrawableCount) { const int32_t sampleCount = s_msaa[(_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT]; @@ -3181,6 +3181,10 @@ namespace bgfx { namespace mtl { m_metalLayer.displaySyncEnabled = 0 != (_flags&BGFX_RESET_VSYNC); } + if (@available(macOS 10.13.2, *)) + { + m_metalLayer.maximumDrawableCount = bx::clamp(_maximumDrawableCount, 2, 3); + } #endif // __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 #endif // BX_PLATFORM_OSX