diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 24c71324a0..9c98e4d5e9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to igl +# Contributing to IGL We want to make contributing to this project as easy and transparent as possible. @@ -11,7 +11,7 @@ We actively welcome your pull requests. 4. Ensure the test suite passes. 5. Make sure your code lints. 6. If you haven't already, complete the Contributor License Agreement ("CLA"). -7. Please respect // @fb-only comments and do not delete them! +7. Please respect `// @fb-only` comments and do not delete them! ## Contributor License Agreement ("CLA") In order to accept your pull request, we need you to submit a CLA. You only need diff --git a/LICENSE.md b/LICENSE.md index 59b9f246f1..1318ea301e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -80,6 +80,9 @@ https://github.com/corporateshark/lightweightvk/blob/main/LICENSE.md Meshoptimizer https://github.com/zeux/meshoptimizer/blob/master/LICENSE.md +NanoVG +https://github.com/memononen/nanovg/blob/master/LICENSE.txt + Spark SL https://github.com/facebook/igl/releases/download/SparkSL/SparkSL.LICENSE diff --git a/samples/android/vulkan/jni/Tiny.cpp b/samples/android/vulkan/jni/Tiny.cpp index ebf7a47170..a7bf3a74b0 100644 --- a/samples/android/vulkan/jni/Tiny.cpp +++ b/samples/android/vulkan/jni/Tiny.cpp @@ -178,7 +178,7 @@ void render() { // VK_EXT_debug_utils support doesn't exist yet // commands->pushDebugGroupLabel("Render Triangle", igl::Color(1, 0, 0)); - commands->draw(PrimitiveType::Triangle, 0, 3); + commands->draw(3, 0, 3); // commands->popDebugGroupLabel(); commands->endEncoding(); diff --git a/shell/ios/ViewController.mm b/shell/ios/ViewController.mm index 1e1fb3c968..de7b27010f 100644 --- a/shell/ios/ViewController.mm +++ b/shell/ios/ViewController.mm @@ -207,7 +207,6 @@ - (void)loadView { kEAGLDrawablePropertyColorFormat, nil]; self.view = openGLView; - self.view.layer.contentsScale = [UIScreen mainScreen].scale; #endif break; } diff --git a/shell/shared/fileLoader/win/FileLoaderWin.cpp b/shell/shared/fileLoader/win/FileLoaderWin.cpp index f17234ae42..50c6d1e300 100644 --- a/shell/shared/fileLoader/win/FileLoaderWin.cpp +++ b/shell/shared/fileLoader/win/FileLoaderWin.cpp @@ -5,8 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -// @fb-only - #include #include diff --git a/src/igl/Assert.cpp b/src/igl/Assert.cpp index 39f8b6bad4..a9e36b06cd 100644 --- a/src/igl/Assert.cpp +++ b/src/igl/Assert.cpp @@ -10,6 +10,21 @@ // ---------------------------------------------------------------------------- +namespace { +IGLErrorHandlerFunc& GetDebugAbortListener() { + static IGLErrorHandlerFunc sListener = nullptr; + return sListener; +} +} // namespace + +IGL_API void IGLSetDebugAbortListener(IGLErrorHandlerFunc listener) { + GetDebugAbortListener() = listener; +} + +IGL_API IGLErrorHandlerFunc IGLGetDebugAbortListener(void) { + return GetDebugAbortListener(); +} + namespace igl { // Toggle debug break on/off at runtime @@ -58,29 +73,16 @@ void _IGLDebugBreak() { // ---------------------------------------------------------------------------- namespace { -// Default handler is no-op. -// If there's an error, IGL_DEBUG_VERIFY will trap in dev builds -void IGLReportErrorDefault(const char* /* file */, - const char* /* func */, - int /* line */, - const char* /* category */, - const char* /* format */, - ...) {} - -IGLSoftErrorFunc& GetErrorHandler() { - static IGLSoftErrorFunc sHandler = IGLReportErrorDefault; +IGLErrorHandlerFunc& GetSoftErrorHandler() { + static IGLErrorHandlerFunc sHandler = nullptr; return sHandler; } - } // namespace -IGL_API void IGLSetSoftErrorHandler(IGLSoftErrorFunc handler) { - if (!handler) { - handler = IGLReportErrorDefault; // prevent null handler - } - GetErrorHandler() = handler; +IGL_API void IGLSetSoftErrorHandler(IGLErrorHandlerFunc handler) { + GetSoftErrorHandler() = handler; } -IGL_API IGLSoftErrorFunc IGLGetSoftErrorHandler(void) { - return GetErrorHandler(); +IGL_API IGLErrorHandlerFunc IGLGetSoftErrorHandler(void) { + return GetSoftErrorHandler(); } diff --git a/src/igl/Assert.h b/src/igl/Assert.h index 3fca5b456b..ad11f68598 100644 --- a/src/igl/Assert.h +++ b/src/igl/Assert.h @@ -56,6 +56,8 @@ #include +#define IGL_ERROR_CATEGORY "IGL" + #if IGL_DEBUG || defined(IGL_FORCE_ENABLE_LOGS) #define IGL_VERIFY_ENABLED 1 #else @@ -68,61 +70,94 @@ #define IGL_DEBUG_BREAK_ENABLED 0 #endif +using IGLErrorHandlerFunc = void (*)(const char* category, + const char* reason, + const char* file, + const char* func, + int line, + const char* format, + va_list ap); + IGL_API void _IGLDebugBreak(); +IGL_API void IGLSetDebugAbortListener(IGLErrorHandlerFunc listener); +IGL_API IGLErrorHandlerFunc IGLGetDebugAbortListener(void); + namespace igl { bool isDebugBreakEnabled(); void setDebugBreakEnabled(bool enabled); -template -[[nodiscard]] static inline const T& _IGLVerify(const T& cond, - [[maybe_unused]] const char* reason, - [[maybe_unused]] const char* func, - [[maybe_unused]] const char* file, - [[maybe_unused]] int line, - [[maybe_unused]] const char* format, - ...) { +[[nodiscard]] inline bool _IGLAlwaysTrue() { + return true; +} + +inline void _IGLDebugAbortV([[maybe_unused]] const char* category, + [[maybe_unused]] const char* reason, + [[maybe_unused]] const char* func, + [[maybe_unused]] const char* file, + [[maybe_unused]] int line, + [[maybe_unused]] const char* format, + [[maybe_unused]] va_list ap) { #if IGL_VERIFY_ENABLED - if (!cond) { - IGLLog(IGLLogError, "[IGL] %s in '%s' (%s:%d): ", reason, func, file, line); - va_list ap; - va_start(ap, format); - IGLLogV(IGLLogError, format, ap); - va_end(ap); - IGLLog(IGLLogError, IGL_NEWLINE); - _IGLDebugBreak(); + va_list apCopy; + va_copy(apCopy, ap); + auto listener = IGLGetDebugAbortListener(); + if (listener) { + listener(category, reason, file, func, line, format, apCopy); } + va_end(apCopy); + + IGLLog(IGLLogError, "[%s] %s in '%s' (%s:%d): ", category, reason, func, file, line); + IGLLogV(IGLLogError, format, ap); + IGLLog(IGLLogError, IGL_NEWLINE); + _IGLDebugBreak(); #endif // IGL_VERIFY_ENABLED - return cond; +} + +[[nodiscard]] inline bool _IGLDebugAbort(const char* category, + const char* reason, + const char* func, + const char* file, + int line, + const char* format, + ...) { + va_list ap; + va_start(ap, format); + _IGLDebugAbortV(category, reason, func, file, line, format, ap); + va_end(ap); + + return false; } } // namespace igl #if IGL_VERIFY_ENABLED -#define _IGL_DEBUG_ABORT(cond, format, ...) \ - (void)::igl::_IGLVerify( \ - cond, "Abort requested", IGL_FUNCTION, __FILE__, __LINE__, (format), ##__VA_ARGS__) +#define _IGL_DEBUG_ABORT_IMPL(cond, reason, format, ...) \ + (cond \ + ? ::igl::_IGLAlwaysTrue() \ + : ::igl::_IGLDebugAbort( \ + IGL_ERROR_CATEGORY, reason, IGL_FUNCTION, __FILE__, __LINE__, format, ##__VA_ARGS__)) + +#define _IGL_DEBUG_ABORT(format, ...) \ + (void)_IGL_DEBUG_ABORT_IMPL(false, "Abort requested", (format), ##__VA_ARGS__) #define _IGL_DEBUG_ASSERT(cond, format, ...) \ - (void)::igl::_IGLVerify( \ - cond, "Assert failed", IGL_FUNCTION, __FILE__, __LINE__, (format), ##__VA_ARGS__) + (void)_IGL_DEBUG_ABORT_IMPL(!!(cond), "Assert failed", (format), ##__VA_ARGS__) #define _IGL_DEBUG_VERIFY(cond, format, ...) \ - ::igl::_IGLVerify( \ - (cond), "Verify failed", IGL_FUNCTION, __FILE__, __LINE__, (format), ##__VA_ARGS__) + _IGL_DEBUG_ABORT_IMPL(!!(cond), "Verify failed", (format), ##__VA_ARGS__) #define _IGL_DEBUG_VERIFY_NOT(cond, format, ...) \ - (!::igl::_IGLVerify( \ - 0 == !!(cond), "Verify failed", IGL_FUNCTION, __FILE__, __LINE__, (format), ##__VA_ARGS__)) + !_IGL_DEBUG_ABORT_IMPL(!(cond), "Verify failed", (format), ##__VA_ARGS__) #else -#define _IGL_DEBUG_ABORT(cond, format, ...) static_cast(0) +#define _IGL_DEBUG_ABORT(format, ...) static_cast(0) #define _IGL_DEBUG_ASSERT(cond, format, ...) static_cast(0) #define _IGL_DEBUG_VERIFY(cond, format, ...) (cond) #define _IGL_DEBUG_VERIFY_NOT(cond, format, ...) (cond) #endif // IGL_VERIFY_ENABLED -#define IGL_DEBUG_ABORT(format, ...) _IGL_DEBUG_ABORT(false, (format), ##__VA_ARGS__) +#define IGL_DEBUG_ABORT(format, ...) _IGL_DEBUG_ABORT((format), ##__VA_ARGS__) #define _IGL_DEBUG_ASSERT_0(cond) _IGL_DEBUG_ASSERT(cond, #cond) #define _IGL_DEBUG_ASSERT_1(cond, format, ...) _IGL_DEBUG_ASSERT(cond, (format), ##__VA_ARGS__) @@ -156,78 +191,71 @@ template ///-------------------------------------- /// MARK: - Custom -#define IGL_ERROR_CATEGORY "IGL" - -using IGLSoftErrorFunc = void (*)(const char* file, - const char* func, - int line, - const char* category, - const char* format, - ...); -IGL_API void IGLSetSoftErrorHandler(IGLSoftErrorFunc handler); -IGL_API IGLSoftErrorFunc IGLGetSoftErrorHandler(void); -IGL_API void IGLSoftError(const char* file, +IGL_API void IGLSetSoftErrorHandler(IGLErrorHandlerFunc handler); +IGL_API IGLErrorHandlerFunc IGLGetSoftErrorHandler(void); +IGL_API void IGLSoftError(const char* category, + const char* reason, + const char* file, const char* func, int line, - const char* category, const char* format, ...); namespace igl { -template -[[nodiscard]] static inline const T& _IGLSoftError(const T& cond, - [[maybe_unused]] const char* reason, - [[maybe_unused]] const char* func, - [[maybe_unused]] const char* file, - [[maybe_unused]] int line, - [[maybe_unused]] const char* format, - [[maybe_unused]] const Args&... args) { -#if IGL_VERIFY_ENABLED - const auto& verifiedCond = _IGLVerify(cond, reason, func, file, line, format, args...); -#else - const auto& verifiedCond = cond; -#endif // IGL_VERIFY_ENABLED +[[nodiscard]] inline bool _IGLSoftError(const char* category, + const char* reason, + const char* func, + const char* file, + int line, + const char* format, + ...) { + va_list ap, apCopy; + va_start(ap, format); + va_copy(apCopy, ap); + + _IGLDebugAbortV(category, reason, func, file, line, format, apCopy); + va_end(apCopy); #if IGL_SOFT_ERROR_ENABLED - if (!verifiedCond) { - IGLGetSoftErrorHandler()(file, func, line, IGL_ERROR_CATEGORY, format, args...); + auto handler = IGLGetSoftErrorHandler(); + if (handler) { + handler(category, reason, file, func, line, format, ap); } #endif // IGL_SOFT_ERROR_ENABLED - return verifiedCond; + va_end(ap); + + return false; // Always return false } } // namespace igl #if IGL_SOFT_ERROR_ENABLED -#define _IGL_SOFT_ERROR(cond, format, ...) \ - (void)::igl::_IGLSoftError( \ - cond, "Soft error", IGL_FUNCTION, __FILE__, __LINE__, (format), ##__VA_ARGS__) +#define _IGL_SOFT_ERROR_IMPL(cond, reason, format, ...) \ + (cond \ + ? ::igl::_IGLAlwaysTrue() \ + : ::igl::_IGLSoftError( \ + IGL_ERROR_CATEGORY, reason, IGL_FUNCTION, __FILE__, __LINE__, format, ##__VA_ARGS__)) + +#define _IGL_SOFT_ERROR(format, ...) \ + (void)_IGL_SOFT_ERROR_IMPL(false, "Soft error", (format), ##__VA_ARGS__) #define _IGL_SOFT_ASSERT(cond, format, ...) \ - (void)::igl::_IGLSoftError( \ - cond, "Soft assert failed", IGL_FUNCTION, __FILE__, __LINE__, (format), ##__VA_ARGS__) + (void)_IGL_SOFT_ERROR_IMPL(!!(cond), "Soft assert failed", (format), ##__VA_ARGS__) #define _IGL_SOFT_VERIFY(cond, format, ...) \ - ::igl::_IGLSoftError( \ - (cond), "Soft verify failed", IGL_FUNCTION, __FILE__, __LINE__, (format), ##__VA_ARGS__) + _IGL_SOFT_ERROR_IMPL(!!(cond), "Soft verify failed", (format), ##__VA_ARGS__) #define _IGL_SOFT_VERIFY_NOT(cond, format, ...) \ - (!::igl::_IGLSoftError(0 == !!(cond), \ - "Soft verify failed", \ - IGL_FUNCTION, \ - __FILE__, \ - __LINE__, \ - (format), \ - ##__VA_ARGS__)) + !_IGL_SOFT_ERROR_IMPL(!(cond), "Soft verify failed", (format), ##__VA_ARGS__) #else -#define _IGL_SOFT_ERROR(cond, format, ...) static_cast(0) +#define _IGL_SOFT_ERROR(format, ...) static_cast(0) #define _IGL_SOFT_ASSERT(cond, format, ...) static_cast(0) #define _IGL_SOFT_VERIFY(cond, format, ...) (cond) #define _IGL_SOFT_VERIFY_NOT(cond, format, ...) (cond) #endif // IGL_SOFT_ERROR_ENABLED -#define IGL_SOFT_ERROR(format, ...) _IGL_SOFT_ERROR(false, (format), ##__VA_ARGS__) +#define IGL_SOFT_ERROR(format, ...) _IGL_SOFT_ERROR((format), ##__VA_ARGS__) #define _IGL_SOFT_ASSERT_0(cond) _IGL_SOFT_ASSERT(cond, #cond) #define _IGL_SOFT_ASSERT_1(cond, format, ...) _IGL_SOFT_ASSERT(cond, (format), ##__VA_ARGS__) diff --git a/src/igl/opengl/RenderCommandAdapter.cpp b/src/igl/opengl/RenderCommandAdapter.cpp index d6f9794a17..d82931cfa9 100644 --- a/src/igl/opengl/RenderCommandAdapter.cpp +++ b/src/igl/opengl/RenderCommandAdapter.cpp @@ -224,12 +224,11 @@ void RenderCommandAdapter::clearDependentResources( clearFragmentTexture(); } - if (!newStateOpenGL || !curStateOpenGL->matchesVertexInputState(*newStateOpenGL)) { - // We do need to clear vertex attributes, when pipelinestate is modified. - // If we don't, subsequent draw calls might try to read from these locations - // and crashes might happen. - unbindVertexAttributes(); + if (curStateOpenGL && newStateOpenGL) { + newStateOpenGL->savePrevPipelineStateAttributesLocations(*curStateOpenGL); + } + if (!newStateOpenGL || !curStateOpenGL->matchesVertexInputState(*newStateOpenGL)) { // Don't reuse previously set vertex buffers. clearVertexBuffers(); } @@ -343,6 +342,7 @@ void RenderCommandAdapter::willDraw() { // Vertex Buffers must be bound before pipelineState->bind() if (pipelineState) { + pipelineState->clearActiveAttributesLocations(); for (size_t bufferIndex = 0; bufferIndex < IGL_VERTEX_BUFFER_MAX; ++bufferIndex) { if (IS_DIRTY(vertexBuffersDirty_, bufferIndex)) { auto& bufferState = vertexBuffers_[bufferIndex]; @@ -352,6 +352,7 @@ void RenderCommandAdapter::willDraw() { CLEAR_DIRTY(vertexBuffersDirty_, bufferIndex); } } + pipelineState->unbindPrevPipelineVertexAttributes(); if (isDirty(StateMask::PIPELINE)) { pipelineState->bind(); clearDirty(StateMask::PIPELINE); diff --git a/src/igl/tests/Assert.cpp b/src/igl/tests/Assert.cpp new file mode 100644 index 0000000000..2b6bb3b0ec --- /dev/null +++ b/src/igl/tests/Assert.cpp @@ -0,0 +1,195 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include + +// Only include Assert.h and ensure it is configured to enable both soft errors and debug aborts +#define IGL_DEBUG 1 +#define IGL_SOFT_ERROR_ENABLED 1 +#define IGL_COMMON_SKIP_CHECK 1 +#include + +namespace igl::tests { +namespace { +bool sAbort = false; +bool sSoftError = false; +} // namespace + +class AssertTest : public ::testing::Test { + public: + void SetUp() override { + igl::setDebugBreakEnabled(false); + IGLSetDebugAbortListener([](const char* /*category*/, + const char* /*reason*/, + const char* /*file*/, + const char* /*func*/, + int /*line*/, + const char* /*format*/, + va_list /*ap*/) { sAbort = true; }); + IGLSetSoftErrorHandler([](const char* /*category*/, + const char* /*reason*/, + const char* /*file*/, + const char* /*func*/, + int /*line*/, + const char* /*format*/, + va_list /*ap*/) { sSoftError = true; }); + } + + void TearDown() override { + IGLSetDebugAbortListener(nullptr); + IGLSetSoftErrorHandler(nullptr); + } +}; + +TEST_F(AssertTest, DebugAbort) { + sAbort = false; + EXPECT_FALSE(sAbort); + IGL_DEBUG_ABORT("Aborting"); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + IGL_DEBUG_ABORT("Aborting with arg %d", 1); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + IGL_DEBUG_ASSERT(false); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + IGL_DEBUG_ASSERT(false, "Aborting"); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + IGL_DEBUG_ASSERT(false, "Aborting with arg %d", 1); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + std::ignore = IGL_DEBUG_VERIFY(false); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + std::ignore = IGL_DEBUG_VERIFY(false, "Aborting"); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + std::ignore = IGL_DEBUG_VERIFY(false, "Aborting with arg %d", 1); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + std::ignore = IGL_DEBUG_VERIFY_NOT(true); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + std::ignore = IGL_DEBUG_VERIFY_NOT(true, "Aborting"); + EXPECT_TRUE(sAbort); + + sAbort = false; + EXPECT_FALSE(sAbort); + std::ignore = IGL_DEBUG_VERIFY_NOT(true, "Aborting with arg %d", 1); + EXPECT_TRUE(sAbort); +} + +TEST_F(AssertTest, SoftError) { + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + IGL_SOFT_ERROR("Aborting"); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + IGL_SOFT_ERROR("Aborting with arg %d", 1); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + IGL_SOFT_ASSERT(false); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + IGL_SOFT_ASSERT(false, "Aborting"); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + IGL_SOFT_ASSERT(false, "Aborting with arg %d", 1); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + std::ignore = IGL_SOFT_VERIFY(false); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + std::ignore = IGL_SOFT_VERIFY(false, "Aborting"); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + std::ignore = IGL_SOFT_VERIFY(false, "Aborting with arg %d", 1); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + std::ignore = IGL_SOFT_VERIFY_NOT(true); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + std::ignore = IGL_SOFT_VERIFY_NOT(true, "Aborting"); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); + + sAbort = false; + sSoftError = false; + EXPECT_FALSE(sAbort); + EXPECT_FALSE(sSoftError); + std::ignore = IGL_SOFT_VERIFY_NOT(true, "Aborting with arg %d", 1); + EXPECT_TRUE(sAbort); + EXPECT_TRUE(sSoftError); +} + +} // namespace igl::tests diff --git a/src/igl/tests/util/TestErrorGuard.cpp b/src/igl/tests/util/TestErrorGuard.cpp index 685c8dfdba..eb60b7fb7c 100644 --- a/src/igl/tests/util/TestErrorGuard.cpp +++ b/src/igl/tests/util/TestErrorGuard.cpp @@ -26,16 +26,14 @@ igl::tests::util::TestErrorGuard::~TestErrorGuard() { #endif } -void igl::tests::util::TestErrorGuard::ReportErrorHandler(const char* file, +void igl::tests::util::TestErrorGuard::ReportErrorHandler(const char* category, + const char* /*reason*/, + const char* file, const char* /*func*/, int line, - const char* category, const char* format, - ...) { + va_list ap) { #if IGL_SOFT_ERROR_ENABLED - va_list ap; - va_start(ap, format); - va_list apCopy; va_copy(apCopy, ap); const auto len = std::vsnprintf(nullptr, 0, format, apCopy); @@ -45,7 +43,6 @@ void igl::tests::util::TestErrorGuard::ReportErrorHandler(const char* file, fmtString.resize(len + 1); std::vsnprintf(&fmtString.front(), len + 1, format, ap); fmtString.resize(len); - va_end(ap); ADD_FAILURE() << "IGL error encountered in " << file << ":" << line << " category=" << category << " " << fmtString; diff --git a/src/igl/tests/util/TestErrorGuard.h b/src/igl/tests/util/TestErrorGuard.h index f848f80567..edfc2c0cd8 100644 --- a/src/igl/tests/util/TestErrorGuard.h +++ b/src/igl/tests/util/TestErrorGuard.h @@ -17,16 +17,17 @@ class TestErrorGuard final { virtual ~TestErrorGuard(); - static void ReportErrorHandler(const char* file, + static void ReportErrorHandler(const char* category, + const char* reason, + const char* file, const char* func, int line, - const char* category, const char* format, - ...); + va_list ap); private: #if IGL_SOFT_ERROR_ENABLED - IGLSoftErrorFunc savedErrorHandler_; + IGLErrorHandlerFunc savedErrorHandler_; #endif }; } // namespace igl::tests::util