diff --git a/3rdparty/dear-imgui/imgui_draw.cpp b/3rdparty/dear-imgui/imgui_draw.cpp index 12f094dbe..c024e5a89 100644 --- a/3rdparty/dear-imgui/imgui_draw.cpp +++ b/3rdparty/dear-imgui/imgui_draw.cpp @@ -829,7 +829,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun // Anti-aliased Fill const float AA_SIZE = 1.0f; const ImU32 col_trans = col & ~IM_COL32_A_MASK; - const int idx_count = (points_count-2)*3 + points_count*6; + const int idx_count = ImMax(0, (points_count-2)*3) + points_count*6; const int vtx_count = (points_count*2); PrimReserve(idx_count, vtx_count); diff --git a/examples/07-callback/callback.cpp b/examples/07-callback/callback.cpp index 5ea3bd2aa..e28acb437 100644 --- a/examples/07-callback/callback.cpp +++ b/examples/07-callback/callback.cpp @@ -97,8 +97,10 @@ struct BgfxCallback : public bgfx::CallbackI { } - virtual void fatal(bgfx::Fatal::Enum _code, const char* _str) override + virtual void fatal(const char* _filePath, uint16_t _line, bgfx::Fatal::Enum _code, const char* _str) override { + BX_UNUSED(_filePath, _line); + // Something unexpected happened, inform user and bail out. bx::debugPrintf("Fatal error: 0x%08x: %s", _code, _str); diff --git a/include/bgfx/bgfx.h b/include/bgfx/bgfx.h index e9e364bf6..ff48be4cd 100644 --- a/include/bgfx/bgfx.h +++ b/include/bgfx/bgfx.h @@ -430,7 +430,12 @@ namespace bgfx /// /// @attention C99 equivalent is `bgfx_callback_vtbl.fatal`. /// - virtual void fatal(Fatal::Enum _code, const char* _str) = 0; + virtual void fatal( + const char* _filePath + , uint16_t _line + , Fatal::Enum _code + , const char* _str + ) = 0; /// Print debug message. /// diff --git a/include/bgfx/c99/bgfx.h b/include/bgfx/c99/bgfx.h index cbed3c6d1..4a6f255e0 100644 --- a/include/bgfx/c99/bgfx.h +++ b/include/bgfx/c99/bgfx.h @@ -567,7 +567,7 @@ typedef struct bgfx_callback_interface_s /**/ typedef struct bgfx_callback_vtbl_s { - void (*fatal)(bgfx_callback_interface_t* _this, bgfx_fatal_t _code, const char* _str); + void (*fatal)(bgfx_callback_interface_t* _this, const char* _filePath, uint16_t _line, bgfx_fatal_t _code, const char* _str); void (*trace_vargs)(bgfx_callback_interface_t* _this, const char* _filePath, uint16_t _line, const char* _format, va_list _argList); void (*profiler_begin)(bgfx_callback_interface_t* _this, const char* _name, uint32_t _abgr, const char* _filePath, uint16_t _line); void (*profiler_begin_literal)(bgfx_callback_interface_t* _this, const char* _name, uint32_t _abgr, const char* _filePath, uint16_t _line); diff --git a/include/bgfx/defines.h b/include/bgfx/defines.h index 80fd25ac5..f9a83234e 100644 --- a/include/bgfx/defines.h +++ b/include/bgfx/defines.h @@ -6,7 +6,7 @@ #ifndef BGFX_DEFINES_H_HEADER_GUARD #define BGFX_DEFINES_H_HEADER_GUARD -#define BGFX_API_VERSION UINT32_C(82) +#define BGFX_API_VERSION UINT32_C(83) /// Color RGB/alpha/depth write. When it's not specified write will be disabled. #define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write. diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 72f2498ee..87162a182 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -54,7 +54,7 @@ namespace bgfx { } - virtual void fatal(Fatal::Enum _code, const char* _str) override + virtual void fatal(const char* _filePath, uint16_t _line, Fatal::Enum _code, const char* _str) override { if (Fatal::DebugCheck == _code) { @@ -62,7 +62,7 @@ namespace bgfx } else { - BX_TRACE("0x%08x: %s", _code, _str); + bgfx::trace(_filePath, _line, "BGFX 0x%08x: %s\n", _code, _str); BX_UNUSED(_code, _str); abort(); } @@ -387,29 +387,29 @@ namespace bgfx return s_graphicsDebuggerPresent; } - void fatal(Fatal::Enum _code, const char* _format, ...) + void fatal(const char* _filePath, uint16_t _line, Fatal::Enum _code, const char* _format, ...) { va_list argList; va_start(argList, _format); + char temp[8192]; + char* out = temp; + int32_t len = bx::vsnprintf(out, sizeof(temp), _format, argList); + if ( (int32_t)sizeof(temp) < len) + { + out = (char*)alloca(len+1); + len = bx::vsnprintf(out, len, _format, argList); + } + out[len] = '\0'; + if (BX_UNLIKELY(NULL == g_callback) ) { - bx::debugPrintfVargs(_format, argList); + bx::debugPrintf("%s(%d): BGFX 0x%08x: %s", _filePath, _line, _code, out); abort(); } else { - char temp[8192]; - char* out = temp; - int32_t len = bx::vsnprintf(out, sizeof(temp), _format, argList); - if ( (int32_t)sizeof(temp) < len) - { - out = (char*)alloca(len+1); - len = bx::vsnprintf(out, len, _format, argList); - } - out[len] = '\0'; - - g_callback->fatal(_code, out); + g_callback->fatal(_filePath, _line, _code, out); } va_end(argList); @@ -4684,9 +4684,9 @@ namespace bgfx { } - virtual void fatal(Fatal::Enum _code, const char* _str) override + virtual void fatal(const char* _filePath, uint16_t _line, Fatal::Enum _code, const char* _str) override { - m_interface->vtbl->fatal(m_interface, (bgfx_fatal_t)_code, _str); + m_interface->vtbl->fatal(m_interface, _filePath, _line, (bgfx_fatal_t)_code, _str); } virtual void traceVargs(const char* _filePath, uint16_t _line, const char* _format, va_list _argList) override diff --git a/src/bgfx_p.h b/src/bgfx_p.h index d1817fa4c..825b5f248 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -67,7 +67,7 @@ namespace bgfx #if BX_COMPILER_CLANG_ANALYZER void __attribute__( (analyzer_noreturn) ) fatal(Fatal::Enum _code, const char* _format, ...); #else - void fatal(Fatal::Enum _code, const char* _format, ...); + void fatal(const char* _filePath, uint16_t _line, Fatal::Enum _code, const char* _format, ...); #endif // BX_COMPILER_CLANG_ANALYZER void trace(const char* _filePath, uint16_t _line, const char* _format, ...); @@ -89,21 +89,21 @@ namespace bgfx } \ BX_MACRO_BLOCK_END -#define _BX_CHECK(_condition, _format, ...) \ - BX_MACRO_BLOCK_BEGIN \ - if (!BX_IGNORE_C4127(_condition) ) \ - { \ - BX_TRACE("CHECK " _format, ##__VA_ARGS__); \ - bgfx::fatal(bgfx::Fatal::DebugCheck, _format, ##__VA_ARGS__); \ - } \ +#define _BX_CHECK(_condition, _format, ...) \ + BX_MACRO_BLOCK_BEGIN \ + if (!BX_IGNORE_C4127(_condition) ) \ + { \ + BX_TRACE("CHECK " _format, ##__VA_ARGS__); \ + bgfx::fatal(__FILE__, uint16_t(__LINE__), bgfx::Fatal::DebugCheck, _format, ##__VA_ARGS__); \ + } \ BX_MACRO_BLOCK_END -#define BGFX_FATAL(_condition, _err, _format, ...) \ - BX_MACRO_BLOCK_BEGIN \ - if (!BX_IGNORE_C4127(_condition) ) \ - { \ - fatal(_err, _format, ##__VA_ARGS__); \ - } \ +#define BGFX_FATAL(_condition, _err, _format, ...) \ + BX_MACRO_BLOCK_BEGIN \ + if (!BX_IGNORE_C4127(_condition) ) \ + { \ + fatal(__FILE__, uint16_t(__LINE__), _err, _format, ##__VA_ARGS__); \ + } \ BX_MACRO_BLOCK_END #include diff --git a/src/dxgi.cpp b/src/dxgi.cpp index 56d641cc0..2cfdb8c91 100644 --- a/src/dxgi.cpp +++ b/src/dxgi.cpp @@ -288,7 +288,7 @@ namespace bgfx } // BK - warn only because RenderDoc might be present. - DX_RELEASE_WARNONLY(output6, 1); + DX_RELEASE_W(output6, 1); } #endif // BX_PLATFORM_WINDOWS @@ -358,7 +358,7 @@ namespace bgfx DX_CHECK(m_adapter->GetParent(IID_IDXGIFactory2, (void**)&m_factory) ); } - DX_RELEASE(dxgiDevice, 2); + DX_RELEASE_I(dxgiDevice); } static const GUID IID_ID3D12CommandQueue = { 0x0ec870a6, 0x5d7e, 0x4c22, { 0x8c, 0xfc, 0x5b, 0xaa, 0xe0, 0x76, 0x16, 0xed } }; @@ -411,7 +411,7 @@ namespace bgfx if (NULL != dxgiDevice1) { dxgiDevice1->SetMaximumFrameLatency(_scd.maxFrameLatency); - DX_RELEASE(dxgiDevice1, 3); + DX_RELEASE_I(dxgiDevice1); } } #else diff --git a/src/renderer_d3d.h b/src/renderer_d3d.h index 4d0405885..25983d6dc 100644 --- a/src/renderer_d3d.h +++ b/src/renderer_d3d.h @@ -122,7 +122,8 @@ namespace bgfx #endif // BGFX_CONFIG_DEBUG_OBJECT_NAME #define DX_RELEASE(_ptr, _expected) _DX_RELEASE(_ptr, _expected, BX_CHECK) -#define DX_RELEASE_WARNONLY(_ptr, _expected) _DX_RELEASE(_ptr, _expected, BX_WARN) +#define DX_RELEASE_W(_ptr, _expected) _DX_RELEASE(_ptr, _expected, BX_WARN) +#define DX_RELEASE_I(_ptr) _DX_RELEASE(_ptr, 0, BX_NOOP) typedef int (WINAPI* PFN_D3DPERF_BEGIN_EVENT)(DWORD _color, LPCWSTR _name); typedef int (WINAPI* PFN_D3DPERF_END_EVENT)(); @@ -204,7 +205,7 @@ namespace bgfx typename HashMap::iterator it = m_hashMap.find(_key); if (it != m_hashMap.end() ) { - DX_RELEASE_WARNONLY(it->second, 0); + DX_RELEASE_W(it->second, 0); m_hashMap.erase(it); } } diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 451f83137..1341e55e0 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -1524,7 +1524,7 @@ namespace bgfx { namespace d3d11 { case ErrorState::LoadedDXGI: DX_RELEASE(m_annotation, 1); - DX_RELEASE_WARNONLY(m_infoQueue, 0); + DX_RELEASE_W(m_infoQueue, 0); DX_RELEASE(m_msaaRt, 0); DX_RELEASE(m_swapChain, 0); DX_RELEASE(m_deviceCtx, 0); @@ -1611,7 +1611,7 @@ namespace bgfx { namespace d3d11 } DX_RELEASE(m_annotation, 1); - DX_RELEASE_WARNONLY(m_infoQueue, 0); + DX_RELEASE_W(m_infoQueue, 0); DX_RELEASE(m_msaaRt, 0); DX_RELEASE(m_swapChain, 0); DX_RELEASE(m_deviceCtx, 0); diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index c07242aca..4c5760cd6 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -1381,7 +1381,7 @@ namespace bgfx { namespace d3d12 } #if BX_PLATFORM_WINDOWS - DX_RELEASE_WARNONLY(m_infoQueue, 0); + DX_RELEASE_W(m_infoQueue, 0); #endif // BX_PLATFORM_WINDOWS DX_RELEASE(m_rtvDescriptorHeap, 0); diff --git a/src/renderer_noop.cpp b/src/renderer_noop.cpp index 119389b91..c4977464f 100644 --- a/src/renderer_noop.cpp +++ b/src/renderer_noop.cpp @@ -62,10 +62,11 @@ namespace bgfx { namespace noop } // Pretend we have no limits - g_caps.limits.maxTextureSize = 16384; - g_caps.limits.maxTextureLayers = 2048; - g_caps.limits.maxFBAttachments = BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS; - g_caps.limits.maxVertexStreams = BGFX_CONFIG_MAX_VERTEX_STREAMS; + g_caps.limits.maxTextureSize = 16384; + g_caps.limits.maxTextureLayers = 2048; + g_caps.limits.maxComputeBindings = g_caps.limits.maxTextureSamplers; + g_caps.limits.maxFBAttachments = BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS; + g_caps.limits.maxVertexStreams = BGFX_CONFIG_MAX_VERTEX_STREAMS; } ~RendererContextNOOP()