From a4bf237b05b39f97deb603bdce3a9d94722d500f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 26 Mar 2015 15:01:09 -0700 Subject: [PATCH] Fixed handle check. --- src/bgfx_p.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index b17b7b312..fd88a9004 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -29,6 +29,7 @@ #include #include +// Check handle, cannot be bgfx::invalidHandle and must be valid. #define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \ BX_CHECK(isValid(_handle) \ && _handleAlloc.isValid(_handle.idx) \ @@ -36,7 +37,17 @@ , _desc \ , _handle.idx \ , _handleAlloc.getMaxHandles() \ - ); + ) + +// Check handle, it's ok to be bgfx::invalidHandle or must be valid. +#define BGFX_CHECK_HANDLE_INVALID_OK(_desc, _handleAlloc, _handle) \ + BX_CHECK(!isValid(_handle) \ + || _handleAlloc.isValid(_handle.idx) \ + , "Invalid handle. %s handle: %d (max %d)" \ + , _desc \ + , _handle.idx \ + , _handleAlloc.getMaxHandles() \ + ) namespace bgfx { @@ -3091,7 +3102,7 @@ namespace bgfx BGFX_API_FUNC(void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle) ) { - BGFX_CHECK_HANDLE("setViewFrameBuffer", m_frameBufferHandle, _handle); + BGFX_CHECK_HANDLE_INVALID_OK("setViewFrameBuffer", m_frameBufferHandle, _handle); m_fb[_id] = _handle; }