From 87a5652b46bc2c538e95ebe360c26edb5039873f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 14 Apr 2015 17:03:07 -0700 Subject: [PATCH] Added extra error checking when creating frame buffer. --- src/bgfx.cpp | 5 +++++ src/bgfx_p.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 5081a346..8be7d84d 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -2656,6 +2656,11 @@ again: FrameBufferHandle createFrameBuffer(uint8_t _num, TextureHandle* _handles, bool _destroyTextures) { BGFX_CHECK_MAIN_THREAD(); + BX_CHECK(_num != 0, "Number of frame buffer attachments can't be 0."); + BX_CHECK(_num <= BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS, "Number of frame buffer attachments is larger than allowed %d (max: %d)." + , _num + , BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS + ); BX_CHECK(NULL != _handles, "_handles can't be NULL"); FrameBufferHandle handle = s_ctx->createFrameBuffer(_num, _handles); if (_destroyTextures) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 67524d0c..2c91b0b5 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2875,10 +2875,12 @@ namespace bgfx FrameBufferRef& ref = m_frameBufferRef[handle.idx]; ref.m_window = false; memset(ref.un.m_th, 0xff, sizeof(ref.un.m_th) ); + BackbufferRatio::Enum bbRatio = BackbufferRatio::Enum(m_textureRef[_handles[0].idx].m_bbRatio); for (uint32_t ii = 0; ii < _num; ++ii) { TextureHandle texHandle = _handles[ii]; BGFX_CHECK_HANDLE("createFrameBuffer texture handle", m_textureHandle, texHandle); + BX_CHECK(bbRatio == m_textureRef[texHandle.idx].m_bbRatio, "Mismatch in texture back-buffer ratio."); cmdbuf.write(texHandle);