From 475fea23bc1061461168fd99de41ebc8ee321b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sun, 29 Nov 2020 17:55:06 -0800 Subject: [PATCH] Skip reset when nothing changes. --- src/bgfx_p.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index d49209a5a..e875f4818 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2985,6 +2985,17 @@ namespace bgfx BGFX_API_FUNC(void reset(uint32_t _width, uint32_t _height, uint32_t _flags, TextureFormat::Enum _format) ) { + const TextureFormat::Enum format = TextureFormat::Count != _format ? _format : m_init.resolution.format; + + if (m_init.resolution.format == format + && m_init.resolution.width == _width + && m_init.resolution.height == _height + && m_init.resolution.reset == _flags) + { + // Nothing changed, ignore request. + return; + } + BX_WARN(g_caps.limits.maxTextureSize >= _width && g_caps.limits.maxTextureSize >= _height , "Frame buffer resolution width or height can't be larger than limits.maxTextureSize %d (width %d, height %d)." @@ -2992,7 +3003,7 @@ namespace bgfx , _width , _height ); - m_init.resolution.format = TextureFormat::Count != _format ? _format : m_init.resolution.format; + m_init.resolution.format = format; m_init.resolution.width = bx::clamp(_width, 1u, g_caps.limits.maxTextureSize); m_init.resolution.height = bx::clamp(_height, 1u, g_caps.limits.maxTextureSize); m_init.resolution.reset = 0