summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry.cpp
diff options
context:
space:
mode:
author Branimir Karadzic <branimirkaradzic@gmail.com>2016-01-04 19:00:51 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2016-01-04 19:00:51 +0100
commitfc07cc3621be84d6b54b9a02f946ca9e33272758 (patch)
tree8e906945079bd6b41eb6051a2b71f0f196c06c04 /3rdparty/bgfx/examples/common/entry/entry.cpp
parent3f4fe77c75571ff17436909c3e579da27b646368 (diff)
Added latest BX and BGFX (nw)
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry.cpp64
1 files changed, 58 insertions, 6 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry.cpp b/3rdparty/bgfx/examples/common/entry/entry.cpp
index 08ac26e4e66..1fb0497be85 100644
--- a/3rdparty/bgfx/examples/common/entry/entry.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry.cpp
@@ -1,8 +1,9 @@
/*
- * Copyright 2011-2015 Branimir Karadzic. All rights reserved.
- * License: http://www.opensource.org/licenses/BSD-2-Clause
+ * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
+#include <bx/bx.h>
#include <bgfx/bgfx.h>
#include <bx/string.h>
#include <bx/readerwriter.h>
@@ -17,6 +18,9 @@
#include "cmd.h"
#include "input.h"
+#define RMT_ENABLED ENTRY_CONFIG_PROFILER
+#include <remotery/lib/Remotery.h>
+
extern "C" int _main_(int _argc, char** _argv);
namespace entry
@@ -24,14 +28,32 @@ namespace entry
static uint32_t s_debug = BGFX_DEBUG_NONE;
static uint32_t s_reset = BGFX_RESET_NONE;
static bool s_exit = false;
+
+ static Remotery* s_rmt = NULL;
+
static bx::FileReaderI* s_fileReader = NULL;
static bx::FileWriterI* s_fileWriter = NULL;
- extern bx::ReallocatorI* getDefaultAllocator();
- static bx::ReallocatorI* s_allocator = getDefaultAllocator();
+ 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::ReallocatorI* getDefaultAllocator()
+ bx::AllocatorI* getDefaultAllocator()
{
BX_PRAGMA_DIAGNOSTIC_PUSH();
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4459); // warning C4459: declaration of 's_allocator' hides global declaration
@@ -238,6 +260,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|| setOrToggle(s_reset, "flush", BGFX_RESET_FLUSH_AFTER_RENDER, 1, _argc, _argv)
|| setOrToggle(s_reset, "flip", BGFX_RESET_FLIP_AFTER_RENDER, 1, _argc, _argv)
|| setOrToggle(s_reset, "hidpi", BGFX_RESET_HIDPI, 1, _argc, _argv)
+ || setOrToggle(s_reset, "depthclamp", BGFX_RESET_DEPTH_CLAMP, 1, _argc, _argv)
)
{
return 0;
@@ -338,6 +361,29 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
//DBG(BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME);
+ if (BX_ENABLED(ENTRY_CONFIG_PROFILER) )
+ {
+ rmtSettings* settings = rmt_Settings();
+ BX_WARN(NULL != settings, "Remotery is not enabled.");
+ if (NULL != settings)
+ {
+ 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)
+ {
+ rmt_SetCurrentThreadName("Main");
+ }
+ else
+ {
+ s_rmt = NULL;
+ }
+ }
+ }
+
#if BX_CONFIG_CRT_FILE_READER_WRITER
s_fileReader = new bx::CrtFileReader;
s_fileWriter = new bx::CrtFileWriter;
@@ -370,6 +416,12 @@ BX_PRAGMA_DIAGNOSTIC_POP();
s_fileWriter = NULL;
#endif // BX_CONFIG_CRT_FILE_READER_WRITER
+ if (BX_ENABLED(ENTRY_CONFIG_PROFILER)
+ && NULL != s_rmt)
+ {
+ rmt_DestroyGlobalInstance(s_rmt);
+ }
+
return result;
}
@@ -666,7 +718,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
return s_fileWriter;
}
- bx::ReallocatorI* getAllocator()
+ bx::AllocatorI* getAllocator()
{
return s_allocator;
}