diff --git a/irr/include/CIndexBuffer.h b/irr/include/CIndexBuffer.h index 4318ddaab..904b0ab9a 100644 --- a/irr/include/CIndexBuffer.h +++ b/irr/include/CIndexBuffer.h @@ -7,6 +7,13 @@ #include #include "IIndexBuffer.h" +// Define to receive warnings when violating the hw mapping hints +//#define INDEXBUFFER_HINT_DEBUG + +#ifdef INDEXBUFFER_HINT_DEBUG +#include "../src/os.h" +#endif + namespace irr { namespace scene @@ -58,6 +65,13 @@ public: void setDirty() override { ++ChangedID; +#ifdef INDEXBUFFER_HINT_DEBUG + if (MappingHint == EHM_STATIC && HWBuffer) { + char buf[100]; + snprintf_irr(buf, sizeof(buf), "CIndexBuffer @ %p modified, but it has a static hint", this); + os::Printer::log(buf, ELL_WARNING); + } +#endif } u32 getChangedID() const override { return ChangedID; } diff --git a/irr/include/CVertexBuffer.h b/irr/include/CVertexBuffer.h index 3559bbddb..4b3f33688 100644 --- a/irr/include/CVertexBuffer.h +++ b/irr/include/CVertexBuffer.h @@ -7,6 +7,13 @@ #include #include "IVertexBuffer.h" +// Define to receive warnings when violating the hw mapping hints +//#define VERTEXBUFFER_HINT_DEBUG + +#ifdef VERTEXBUFFER_HINT_DEBUG +#include "../src/os.h" +#endif + namespace irr { namespace scene @@ -87,6 +94,13 @@ public: void setDirty() override { ++ChangedID; +#ifdef VERTEXBUFFER_HINT_DEBUG + if (MappingHint == EHM_STATIC && HWBuffer) { + char buf[100]; + snprintf_irr(buf, sizeof(buf), "CVertexBuffer @ %p modified, but it has a static hint", this); + os::Printer::log(buf, ELL_WARNING); + } +#endif } u32 getChangedID() const override { return ChangedID; } diff --git a/irr/include/IReferenceCounted.h b/irr/include/IReferenceCounted.h index e1000d389..68aa20fb6 100644 --- a/irr/include/IReferenceCounted.h +++ b/irr/include/IReferenceCounted.h @@ -42,7 +42,7 @@ class IReferenceCounted public: //! Constructor. IReferenceCounted() : - DebugName(0), ReferenceCounter(1) + ReferenceCounter(1) { } @@ -136,6 +136,7 @@ public: return ReferenceCounter; } +#ifdef _DEBUG //! Returns the debug name of the object. /** The Debugname may only be set and changed by the object itself. This method should only be used in Debug mode. @@ -157,7 +158,10 @@ protected: private: //! The debug name. - const c8 *DebugName; + const c8 *DebugName = nullptr; +#endif + +private: //! The reference counter. Mutable to do reference counting on const objects. mutable s32 ReferenceCounter; diff --git a/irr/src/CMakeLists.txt b/irr/src/CMakeLists.txt index 742d27f72..22a0d0093 100644 --- a/irr/src/CMakeLists.txt +++ b/irr/src/CMakeLists.txt @@ -510,6 +510,9 @@ target_link_libraries(IrrlichtMt PRIVATE if(WIN32) target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header endif() +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + target_compile_definitions(IrrlichtMt INTERFACE _DEBUG) # same +endif() if(APPLE OR ANDROID OR EMSCRIPTEN) target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS) endif() diff --git a/irr/src/os.h b/irr/src/os.h index 58699ab3e..bcc096f95 100644 --- a/irr/src/os.h +++ b/irr/src/os.h @@ -52,7 +52,6 @@ public: // prints out a string to the console out stdout or debug log or whatever static void print(const c8 *message, ELOG_LEVEL ll = ELL_INFORMATION); static void log(const c8 *message, ELOG_LEVEL ll = ELL_INFORMATION); - static void log(const wchar_t *message, ELOG_LEVEL ll = ELL_INFORMATION); // The string ": " is added between message and hint static void log(const c8 *message, const c8 *hint, ELOG_LEVEL ll = ELL_INFORMATION);