mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-19 21:42:59 +01:00
Workaround C4127 MSVC level 4 warning.
This commit is contained in:
@@ -534,7 +534,7 @@ struct NVGcontext* nvgCreate(int atlasw, int atlash, int edgeaa);
|
||||
//
|
||||
void nvgDelete(struct NVGcontext* ctx);
|
||||
|
||||
#define NVG_NOTUSED(v) do { (void)(true ? (void)0 : ( (void)(v) ) ); } while(0)
|
||||
#define NVG_NOTUSED(v) for (;;) { (void)(true ? (void)0 : ( (void)(v) ) ); break; }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -974,13 +974,13 @@ namespace bgfx
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
||||
{
|
||||
#define CHECK_HANDLE_LEAK(_handleAlloc) \
|
||||
do { \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
BX_WARN(0 == _handleAlloc.getNumHandles() \
|
||||
, "LEAK: " #_handleAlloc " %d (max: %d)" \
|
||||
, _handleAlloc.getNumHandles() \
|
||||
, _handleAlloc.getMaxHandles() \
|
||||
); \
|
||||
} while (0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
CHECK_HANDLE_LEAK(m_dynamicIndexBufferHandle);
|
||||
CHECK_HANDLE_LEAK(m_dynamicVertexBufferHandle);
|
||||
|
||||
22
src/bgfx_p.h
22
src/bgfx_p.h
@@ -23,26 +23,26 @@ namespace bgfx
|
||||
}
|
||||
|
||||
#define _BX_TRACE(_format, ...) \
|
||||
do { \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
bgfx::dbgPrintf(BX_FILE_LINE_LITERAL "BGFX " _format "\n", ##__VA_ARGS__); \
|
||||
} while(0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _BX_WARN(_condition, _format, ...) \
|
||||
do { \
|
||||
if (!(_condition) ) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!BX_IGNORE_C4127(_condition) ) \
|
||||
{ \
|
||||
BX_TRACE("WARN " _format, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _BX_CHECK(_condition, _format, ...) \
|
||||
do { \
|
||||
if (!(_condition) ) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!BX_IGNORE_C4127(_condition) ) \
|
||||
{ \
|
||||
BX_TRACE("CHECK " _format, ##__VA_ARGS__); \
|
||||
bgfx::fatal(bgfx::Fatal::DebugCheck, _format, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#if BGFX_CONFIG_DEBUG
|
||||
# define BX_TRACE _BX_TRACE
|
||||
@@ -52,12 +52,12 @@ namespace bgfx
|
||||
#endif // BGFX_CONFIG_DEBUG
|
||||
|
||||
#define BGFX_FATAL(_condition, _err, _format, ...) \
|
||||
do { \
|
||||
if (!(_condition) ) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!BX_IGNORE_C4127(_condition) ) \
|
||||
{ \
|
||||
fatal(_err, _format, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#include <bx/bx.h>
|
||||
#include <bx/debug.h>
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace bgfx
|
||||
{ \
|
||||
BX_TRACE("wgl %p " #_func " (" #_import ")", _func); \
|
||||
} \
|
||||
BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGL context. wglGetProcAddress(\"%s\")", #_import); \
|
||||
BGFX_FATAL(BX_IGNORE_C4127(_optional) || NULL != _func, Fatal::UnableToInitialize, "Failed to create OpenGL context. wglGetProcAddress(\"%s\")", #_import); \
|
||||
} \
|
||||
}
|
||||
# include "glimports.h"
|
||||
|
||||
@@ -22,29 +22,29 @@
|
||||
namespace bgfx
|
||||
{
|
||||
#define _DX_CHECK(_call) \
|
||||
do { \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
HRESULT __hr__ = _call; \
|
||||
BX_CHECK(SUCCEEDED(__hr__), #_call " FAILED 0x%08x" DX_CHECK_EXTRA_F "\n" \
|
||||
, (uint32_t)__hr__ \
|
||||
DX_CHECK_EXTRA_ARGS \
|
||||
); \
|
||||
} while (0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _DX_RELEASE(_ptr, _expected, _check) \
|
||||
do { \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (NULL != _ptr) \
|
||||
{ \
|
||||
ULONG count = _ptr->Release(); \
|
||||
_check(isGraphicsDebuggerPresent() || _expected == count, "%p RefCount is %d (expected %d).", _ptr, count, _expected); BX_UNUSED(count); \
|
||||
_ptr = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
# define _DX_CHECK_REFCOUNT(_ptr, _expected) \
|
||||
do { \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
ULONG count = getRefCount(_ptr); \
|
||||
BX_CHECK(isGraphicsDebuggerPresent() || _expected == count, "%p RefCount is %d (expected %d).", _ptr, count, _expected); \
|
||||
} while (0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#if BGFX_CONFIG_DEBUG
|
||||
# define DX_CHECK(_call) _DX_CHECK(_call)
|
||||
|
||||
@@ -1239,7 +1239,7 @@ namespace bgfx
|
||||
|
||||
IDirect3DDevice9* device = m_device;
|
||||
|
||||
do
|
||||
for (;;)
|
||||
{
|
||||
uint32_t opcode = _constantBuffer.read();
|
||||
|
||||
@@ -1348,7 +1348,7 @@ namespace bgfx
|
||||
|
||||
#undef CASE_IMPLEMENT_UNIFORM
|
||||
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
|
||||
@@ -30,9 +30,9 @@ typedef IDirect3D9* (WINAPI *Direct3DCreate9Fn)(UINT SDKVersion);
|
||||
|
||||
# define D3DFMT_DF24 D3DFMT_D24FS8
|
||||
|
||||
# define _PIX_SETMARKER(_col, _name) do {} while(0)
|
||||
# define _PIX_BEGINEVENT(_col, _name) do {} while(0)
|
||||
# define _PIX_ENDEVENT() do {} while(0)
|
||||
# define _PIX_SETMARKER(_col, _name) BX_NOOP()
|
||||
# define _PIX_BEGINEVENT(_col, _name) BX_NOOP()
|
||||
# define _PIX_ENDEVENT() BX_NOOP
|
||||
#endif // BX_PLATFORM_
|
||||
|
||||
#ifndef D3DSTREAMSOURCE_INDEXEDDATA
|
||||
|
||||
@@ -1852,7 +1852,7 @@ namespace bgfx
|
||||
{
|
||||
_constantBuffer.reset();
|
||||
|
||||
do
|
||||
for (;;)
|
||||
{
|
||||
uint32_t opcode = _constantBuffer.read();
|
||||
|
||||
@@ -1928,7 +1928,7 @@ namespace bgfx
|
||||
#undef CASE_IMPLEMENT_UNIFORM
|
||||
#undef CASE_IMPLEMENT_UNIFORM_T
|
||||
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
|
||||
void clearQuad(ClearQuad& _clearQuad, const Rect& _rect, const Clear& _clear, uint32_t _height)
|
||||
@@ -2859,7 +2859,7 @@ namespace bgfx
|
||||
&& GL_RGBA == m_fmt
|
||||
&& !s_renderGL->m_textureSwizzleSupport
|
||||
;
|
||||
const bool unpackRowLength = !!BGFX_CONFIG_RENDERER_OPENGL || s_extension[Extension::EXT_unpack_subimage].m_supported;
|
||||
const bool unpackRowLength = BX_IGNORE_C4127(!!BGFX_CONFIG_RENDERER_OPENGL || s_extension[Extension::EXT_unpack_subimage].m_supported);
|
||||
const bool convert = m_textureFormat != m_requestedFormat;
|
||||
const bool compressed = isCompressed(TextureFormat::Enum(m_textureFormat) );
|
||||
|
||||
|
||||
@@ -376,15 +376,15 @@ namespace bgfx
|
||||
const char* glEnumName(GLenum _enum);
|
||||
|
||||
#define _GL_CHECK(_check, _call) \
|
||||
do { \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
/*BX_TRACE(#_call);*/ \
|
||||
_call; \
|
||||
GLenum err = glGetError(); \
|
||||
_check(0 == err, #_call "; GL error 0x%x: %s", err, glEnumName(err) ); \
|
||||
BX_UNUSED(err); \
|
||||
} while (0)
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define IGNORE_GL_ERROR_CHECK(...) do {} while(0)
|
||||
#define IGNORE_GL_ERROR_CHECK(...) BX_NOOP()
|
||||
|
||||
#if BGFX_CONFIG_DEBUG
|
||||
# define GL_CHECK(_call) _GL_CHECK(BX_CHECK, _call)
|
||||
|
||||
Reference in New Issue
Block a user