From 8c33afdd09ac7376fc83abdc19d4221037af8fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 13 Nov 2015 21:11:19 -0800 Subject: [PATCH] Added --with-profiler option. --- 3rdparty/remotery/lib/Remotery.c | 10 +--------- examples/common/entry/entry.cpp | 31 ++++++++++++++++++++++++++++--- scripts/genie.lua | 12 ++++++++++++ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/3rdparty/remotery/lib/Remotery.c b/3rdparty/remotery/lib/Remotery.c index de8cd3d63..a3e2ed231 100644 --- a/3rdparty/remotery/lib/Remotery.c +++ b/3rdparty/remotery/lib/Remotery.c @@ -488,15 +488,7 @@ static void AtomicSub(rmtS32 volatile* value, rmtS32 sub) } -// Compiler read/write fences (windows implementation) -static void ReadFence() -{ -#if defined(RMT_PLATFORM_WINDOWS) - _ReadBarrier(); -#else - asm volatile ("" : : : "memory"); -#endif -} +// Compiler write fences (windows implementation) static void WriteFence() { #if defined(RMT_PLATFORM_WINDOWS) && !defined(__MINGW32__) diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index e7f82d7f8..66519a6b1 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -39,6 +39,21 @@ namespace entry extern bx::AllocatorI* getDefaultAllocator(); static bx::AllocatorI* s_allocator = getDefaultAllocator(); + void* rmtMalloc(void* /*_context*/, rmtU32 _size) + { + return BX_ALLOC(s_allocator, _size); + } + + void* rmtRealloc(void* /*_context*/, void* _ptr, rmtU32 _size) + { + return BX_REALLOC(s_allocator, _ptr, _size); + } + + void rmtFree(void* /*_context*/, void* _ptr) + { + BX_FREE(s_allocator, _ptr); + } + #if ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR bx::AllocatorI* getDefaultAllocator() { @@ -349,10 +364,20 @@ BX_PRAGMA_DIAGNOSTIC_POP(); if (BX_ENABLED(ENTRY_CONFIG_PROFILER) ) { -// rmtSettings* settings = rmt_Settings(); - if (RMT_ERROR_NONE != rmt_CreateGlobalInstance(&s_rmt) ) + rmtSettings* settings = rmt_Settings(); + BX_WARN(NULL != settings, "Remotery is not enabled."); + if (NULL != settings) { - s_rmt = NULL; + settings->malloc = rmtMalloc; + settings->realloc = rmtRealloc; + settings->free = rmtFree; + + rmtError err = rmt_CreateGlobalInstance(&s_rmt); + BX_WARN(RMT_ERROR_NONE != err, "Remotery failed to create global instance."); + if (RMT_ERROR_NONE != err) + { + s_rmt = NULL; + } } } diff --git a/scripts/genie.lua b/scripts/genie.lua index d6887faf6..96e1e022e 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -23,6 +23,11 @@ newoption { description = "Enable GLFW entry.", } +newoption { + trigger = "with-profiler", + description = "Enable build with intrusive profiler.", +} + newoption { trigger = "with-scintilla", description = "Enable building with Scintilla editor.", @@ -85,6 +90,13 @@ if _OPTIONS["with-sdl"] then end end +if _OPTIONS["with-profiler"] then + defines { + "ENTRY_CONFIG_PROFILER=1", + "BGFX_CONFIG_PROFILER_REMOTERY=1", + } +end + function exampleProject(_name) project ("example-" .. _name)