From d19f3a5222f0a73486b85808f132a2caf9481adf 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, 28 Dec 2025 17:56:51 -0800 Subject: [PATCH] Validate that texutre supports MSAA. --- src/bgfx.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 18eaf5a65..61d29ae29 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -4701,8 +4701,8 @@ namespace bgfx BGFX_ERROR_CHECK( // if BGFX_TEXTURE_RT_MSAA_X2 or greater than either BGFX_TEXTURE_RT_WRITE_ONLY or BGFX_TEXTURE_MSAA_SAMPLE is required // if BGFX_TEXTURE_RT with no MSSA then this is not required. - (1 == ((tr.m_flags & BGFX_TEXTURE_RT_MSAA_MASK) >> BGFX_TEXTURE_RT_MSAA_SHIFT)) - || (0 != (tr.m_flags & (BGFX_TEXTURE_RT_WRITE_ONLY | BGFX_TEXTURE_MSAA_SAMPLE))) + (1 == ( (tr.m_flags & BGFX_TEXTURE_RT_MSAA_MASK) >> BGFX_TEXTURE_RT_MSAA_SHIFT) ) + || (0 != (tr.m_flags & (BGFX_TEXTURE_RT_WRITE_ONLY | BGFX_TEXTURE_MSAA_SAMPLE) ) ) , _err , BGFX_ERROR_FRAME_BUFFER_VALIDATION , "Frame buffer depth MSAA texture cannot be resolved. It must be created with either `BGFX_TEXTURE_RT_WRITE_ONLY` or `BGFX_TEXTURE_MSAA_SAMPLE` flag." @@ -4893,6 +4893,16 @@ namespace bgfx , getName(_format) ); + BGFX_ERROR_CHECK(false + || 0 == (_flags & BGFX_TEXTURE_RT_MSAA_MASK) + || 0 != (g_caps.formats[_format] & BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA) + , _err + , BGFX_ERROR_TEXTURE_VALIDATION + , "Creating MSAA render target for this texture format is not supported." + , "Texture format: %s." + , getName(_format) + ); + BGFX_ERROR_CHECK(false || 0 == (_flags & BGFX_TEXTURE_MSAA_SAMPLE) || 0 != (g_caps.formats[_format] & BGFX_CAPS_FORMAT_TEXTURE_MSAA)