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.
This commit is contained in:
Robin Allen
2026-08-25 15:07:59 +01:00
committed by GitHub
parent d611ecef3f
commit e5969e73c6

View File

@@ -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<uint32_t>(1, texture.m_width >> at.mip);
m_height = bx::max<uint32_t>(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<uint32_t>(1, texture.m_width >> at.mip);
m_height = bx::max<uint32_t>(1, texture.m_height >> at.mip);
}
}
uint16_t FrameBufferMtl::destroy()