From e5969e73c643ec64b96f1442729f1ec665bb6b13 Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Tue, 25 Aug 2026 15:07:59 +0100 Subject: [PATCH] Metal: Fix wrong setScissor: calls after window resize (#3927) Unlike the other backends, FrameBufferMtl::postReset was empty, so nothing was updating FrameBufferMtl::width/height on window resize, causing wrong setScissorRect: calls to be emitted. This adds code to postReset that sets m_width/m_height from the sizes of the attached textures, like the other backends do. --- src/renderer_mtl.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/renderer_mtl.cpp b/src/renderer_mtl.cpp index dfeeb6475..194f78919 100644 --- a/src/renderer_mtl.cpp +++ b/src/renderer_mtl.cpp @@ -5204,6 +5204,33 @@ static_assert(BX_COUNTOF(s_accessNames) == Access::Count, "Invalid s_accessNames void FrameBufferMtl::postReset() { + m_width = 0; + m_height = 0; + + for (uint32_t ii = 0; ii < m_num; ++ii) + { + const Attachment& at = m_colorAttachment[ii]; + + if (isValid(at.handle) ) + { + const TextureMtl& texture = s_renderMtl->m_textures[at.handle.idx]; + + if (0 == m_width) + { + m_width = bx::max(1, texture.m_width >> at.mip); + m_height = bx::max(1, texture.m_height >> at.mip); + } + } + } + + if (0 == m_width + && isValid(m_depthHandle) ) + { + const Attachment& at = m_depthAttachment; + const TextureMtl& texture = s_renderMtl->m_textures[at.handle.idx]; + m_width = bx::max(1, texture.m_width >> at.mip); + m_height = bx::max(1, texture.m_height >> at.mip); + } } uint16_t FrameBufferMtl::destroy()