|
|
@@ -72,8 +72,6 @@ extern HWND g_bgfxHwnd;
|
|
|
#elif BX_PLATFORM_XBOX360
|
|
|
# include <malloc.h>
|
|
|
# include <xtl.h>
|
|
|
-#elif BX_PLATFORM_POSIX
|
|
|
-# include <pthread.h>
|
|
|
#endif // BX_PLATFORM_*
|
|
|
|
|
|
#include "dds.h"
|
|
|
@@ -107,11 +105,8 @@ namespace stl = std;
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
-#if BGFX_CONFIG_MULTITHREADED
|
|
|
-# include <bx/sem.h>
|
|
|
-#endif // BGFX_CONFIG_MULTITHREADED
|
|
|
-
|
|
|
#include <bx/cpu.h>
|
|
|
+#include <bx/thread.h>
|
|
|
#include <bx/timer.h>
|
|
|
|
|
|
#define BGFX_DRAW_WHOLE_INDEX_BUFFER 0xffffffff
|
|
|
@@ -1414,16 +1409,11 @@ namespace bgfx
|
|
|
UsedList m_used;
|
|
|
};
|
|
|
|
|
|
-#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
|
|
|
- DWORD WINAPI renderThread(LPVOID _arg);
|
|
|
-#elif BX_PLATFORM_POSIX
|
|
|
- void* renderThread(void*);
|
|
|
-#endif // BX_PLATFORM_
|
|
|
-
|
|
|
struct Context
|
|
|
{
|
|
|
Context()
|
|
|
- : m_render(&m_frame[0])
|
|
|
+ : m_thread(renderThread, thisSuppressC4355() )
|
|
|
+ , m_render(&m_frame[0])
|
|
|
, m_submit(&m_frame[1])
|
|
|
, m_dynamicIndexBufferHandle(BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS)
|
|
|
, m_dynamicVertexBufferHandle(BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS)
|
|
|
@@ -1447,6 +1437,18 @@ namespace bgfx
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+ Context* thisSuppressC4355()
|
|
|
+ {
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ static int32_t renderThread(void* _userData)
|
|
|
+ {
|
|
|
+ Context* ctx = (Context*)_userData;
|
|
|
+ while (!ctx->renderFrame() );
|
|
|
+ return EXIT_SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
// game thread
|
|
|
void init(bool _createRenderThread);
|
|
|
void shutdown();
|
|
|
@@ -2736,13 +2738,6 @@ namespace bgfx
|
|
|
|
|
|
Semaphore m_renderSem;
|
|
|
Semaphore m_gameSem;
|
|
|
-
|
|
|
-# if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360
|
|
|
- HANDLE m_renderThread;
|
|
|
-# else
|
|
|
- pthread_t m_renderThread;
|
|
|
-# endif // BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360
|
|
|
-
|
|
|
#else
|
|
|
void gameSemPost()
|
|
|
{
|
|
|
@@ -2761,6 +2756,7 @@ namespace bgfx
|
|
|
}
|
|
|
#endif // BGFX_CONFIG_MULTITHREADED
|
|
|
|
|
|
+ Thread m_thread;
|
|
|
Frame m_frame[2];
|
|
|
Frame* m_render;
|
|
|
Frame* m_submit;
|