瀏覽代碼

Added --with-profiler option.

Branimir Karadžić 10 年之前
父節點
當前提交
8c33afdd09
共有 3 個文件被更改,包括 41 次插入12 次删除
  1. 1 9
      3rdparty/remotery/lib/Remotery.c
  2. 28 3
      examples/common/entry/entry.cpp
  3. 12 0
      scripts/genie.lua

+ 1 - 9
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()
 static void WriteFence()
 {
 {
 #if defined(RMT_PLATFORM_WINDOWS) && !defined(__MINGW32__)
 #if defined(RMT_PLATFORM_WINDOWS) && !defined(__MINGW32__)

+ 28 - 3
examples/common/entry/entry.cpp

@@ -39,6 +39,21 @@ namespace entry
 	extern bx::AllocatorI* getDefaultAllocator();
 	extern bx::AllocatorI* getDefaultAllocator();
 	static bx::AllocatorI* s_allocator = 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
 #if ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR
 	bx::AllocatorI* getDefaultAllocator()
 	bx::AllocatorI* getDefaultAllocator()
 	{
 	{
@@ -349,10 +364,20 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 
 
 		if (BX_ENABLED(ENTRY_CONFIG_PROFILER) )
 		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;
+				}
 			}
 			}
 		}
 		}
 
 

+ 12 - 0
scripts/genie.lua

@@ -23,6 +23,11 @@ newoption {
 	description = "Enable GLFW entry.",
 	description = "Enable GLFW entry.",
 }
 }
 
 
+newoption {
+	trigger = "with-profiler",
+	description = "Enable build with intrusive profiler.",
+}
+
 newoption {
 newoption {
 	trigger = "with-scintilla",
 	trigger = "with-scintilla",
 	description = "Enable building with Scintilla editor.",
 	description = "Enable building with Scintilla editor.",
@@ -85,6 +90,13 @@ if _OPTIONS["with-sdl"] then
 	end
 	end
 end
 end
 
 
+if _OPTIONS["with-profiler"] then
+	defines {
+		"ENTRY_CONFIG_PROFILER=1",
+		"BGFX_CONFIG_PROFILER_REMOTERY=1",
+	}
+end
+
 function exampleProject(_name)
 function exampleProject(_name)
 
 
 	project ("example-" .. _name)
 	project ("example-" .. _name)