Add some debug helpers around this area
Some checks failed
android / build (push) Has been cancelled
cpp_lint / clang_tidy (push) Has been cancelled
linux / gcc_7 (push) Has been cancelled
linux / gcc_14 (push) Has been cancelled
linux / clang_7 (push) Has been cancelled
linux / clang_18 (push) Has been cancelled
windows / MinGW cross-compiler (${{ matrix.bits }}-bit) (32) (push) Has been cancelled
linux / clang_11 (PROMETHEUS=1) (push) Has been cancelled
macos / build (push) Has been cancelled
whitespace_checks / trailing_whitespaces (push) Has been cancelled
whitespace_checks / tabs_lua_api_files (push) Has been cancelled
windows / MinGW cross-compiler (${{ matrix.bits }}-bit) (64) (push) Has been cancelled
windows / VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }} (map[arch:x64 generator:-G'Visual Studio 16 2019' -A x64 vcpkg_triplet:x64-windows], portable) (push) Has been cancelled
windows / VS 2019 ${{ matrix.config.arch }}-${{ matrix.type }} (map[arch:x86 generator:-G'Visual Studio 16 2019' -A Win32 vcpkg_triplet:x86-windows], portable) (push) Has been cancelled

This commit is contained in:
sfan5 2024-09-12 17:18:13 +02:00
parent 6f275e2ba0
commit 58ea11c2b3
5 changed files with 37 additions and 3 deletions

View File

@ -7,6 +7,13 @@
#include <vector> #include <vector>
#include "IIndexBuffer.h" #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 irr
{ {
namespace scene namespace scene
@ -58,6 +65,13 @@ public:
void setDirty() override void setDirty() override
{ {
++ChangedID; ++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; } u32 getChangedID() const override { return ChangedID; }

View File

@ -7,6 +7,13 @@
#include <vector> #include <vector>
#include "IVertexBuffer.h" #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 irr
{ {
namespace scene namespace scene
@ -87,6 +94,13 @@ public:
void setDirty() override void setDirty() override
{ {
++ChangedID; ++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; } u32 getChangedID() const override { return ChangedID; }

View File

@ -42,7 +42,7 @@ class IReferenceCounted
public: public:
//! Constructor. //! Constructor.
IReferenceCounted() : IReferenceCounted() :
DebugName(0), ReferenceCounter(1) ReferenceCounter(1)
{ {
} }
@ -136,6 +136,7 @@ public:
return ReferenceCounter; return ReferenceCounter;
} }
#ifdef _DEBUG
//! Returns the debug name of the object. //! Returns the debug name of the object.
/** The Debugname may only be set and changed by the object /** The Debugname may only be set and changed by the object
itself. This method should only be used in Debug mode. itself. This method should only be used in Debug mode.
@ -157,7 +158,10 @@ protected:
private: private:
//! The debug name. //! The debug name.
const c8 *DebugName; const c8 *DebugName = nullptr;
#endif
private:
//! The reference counter. Mutable to do reference counting on const objects. //! The reference counter. Mutable to do reference counting on const objects.
mutable s32 ReferenceCounter; mutable s32 ReferenceCounter;

View File

@ -510,6 +510,9 @@ target_link_libraries(IrrlichtMt PRIVATE
if(WIN32) if(WIN32)
target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header
endif() endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(IrrlichtMt INTERFACE _DEBUG) # same
endif()
if(APPLE OR ANDROID OR EMSCRIPTEN) if(APPLE OR ANDROID OR EMSCRIPTEN)
target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS) target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS)
endif() endif()

View File

@ -52,7 +52,6 @@ public:
// prints out a string to the console out stdout or debug log or whatever // 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 print(const c8 *message, ELOG_LEVEL ll = ELL_INFORMATION);
static void log(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 // The string ": " is added between message and hint
static void log(const c8 *message, const c8 *hint, ELOG_LEVEL ll = ELL_INFORMATION); static void log(const c8 *message, const c8 *hint, ELOG_LEVEL ll = ELL_INFORMATION);