Merge pull request #25 from MikePopoloski/master

Improving WinRT Platform Support
This commit is contained in:
Branimir Karadžić
2014-11-15 14:40:14 -08:00
7 changed files with 49 additions and 7 deletions

View File

@@ -30,6 +30,7 @@
|| BX_PLATFORM_QNX \
|| BX_PLATFORM_RPI \
|| BX_PLATFORM_WINDOWS \
|| BX_PLATFORM_WINRT \
? 1 : 0)
#endif // BX_CONFIG_CRT_FILE_READER_WRITER
@@ -38,7 +39,7 @@
#endif // BX_CONFIG_SEMAPHORE_PTHREAD
#ifndef BX_CONFIG_SUPPORTS_THREADING
# define BX_CONFIG_SUPPORTS_THREADING !(BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_WINRT)
# define BX_CONFIG_SUPPORTS_THREADING !(BX_PLATFORM_EMSCRIPTEN)
#endif // BX_CONFIG_SUPPORTS_THREADING
#endif // BX_CONFIG_H_HEADER_GUARD

View File

@@ -10,6 +10,7 @@
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
# include <windows.h>
# include "debug.h"
#elif BX_PLATFORM_ANDROID \
|| BX_PLATFORM_EMSCRIPTEN \
|| BX_PLATFORM_FREEBSD \

View File

@@ -107,6 +107,7 @@
# define BX_PLATFORM_XBOX360 1
#elif defined(_WIN32) || defined(_WIN64)
// http://msdn.microsoft.com/en-us/library/6sehtctf.aspx
# include <windows.h>
# if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
# undef BX_PLATFORM_WINDOWS
# if !defined(WINVER) && !defined(_WIN32_WINNT)

View File

@@ -202,7 +202,11 @@ namespace bx
public:
Semaphore()
{
#if BX_PLATFORM_WINRT
m_handle = CreateSemaphoreEx(NULL, 0, LONG_MAX, NULL, 0, SEMAPHORE_ALL_ACCESS);
#else
m_handle = CreateSemaphore(NULL, 0, LONG_MAX, NULL);
#endif
BX_CHECK(NULL != m_handle, "Failed to create Semaphore!");
}
@@ -219,7 +223,11 @@ namespace bx
bool wait(int32_t _msecs = -1) const
{
DWORD milliseconds = (0 > _msecs) ? INFINITE : _msecs;
return WAIT_OBJECT_0 == WaitForSingleObject(m_handle, milliseconds);
#if BX_PLATFORM_WINRT
return WAIT_OBJECT_0 == WaitForSingleObjectEx(m_handle, milliseconds, FALSE);
#else
return WAIT_OBJECT_0 == WaitForSingleObject(m_handle, milliseconds);
#endif
}
private:

View File

@@ -8,7 +8,11 @@
#if BX_PLATFORM_POSIX
# include <pthread.h>
#endif // BX_PLATFORM_POSIX
#elif BX_PLATFORM_WINRT
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::System::Threading;
#endif
#include "sem.h"
@@ -27,7 +31,7 @@ namespace bx
public:
Thread()
#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360
#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_WINRT
: m_handle(INVALID_HANDLE_VALUE)
#elif BX_PLATFORM_POSIX
: m_handle(0)
@@ -65,6 +69,15 @@ namespace bx
, 0
, NULL
);
#elif BX_PLATFORM_WINRT
m_handle = CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
auto workItemHandler = ref new WorkItemHandler([=](IAsyncAction^)
{
m_exitCode = threadFunc(this);
SetEvent(m_handle);
}, CallbackContext::Any);
ThreadPool::RunAsync(workItemHandler, WorkItemPriority::Normal, WorkItemOptions::TimeSliced);
#elif BX_PLATFORM_POSIX
int result;
BX_UNUSED(result);
@@ -99,6 +112,10 @@ namespace bx
GetExitCodeThread(m_handle, (DWORD*)&m_exitCode);
CloseHandle(m_handle);
m_handle = INVALID_HANDLE_VALUE;
#elif BX_PLATFORM_WINRT
WaitForSingleObjectEx(m_handle, INFINITE, FALSE);
CloseHandle(m_handle);
m_handle = INVALID_HANDLE_VALUE;
#elif BX_PLATFORM_POSIX
union
{
@@ -129,7 +146,7 @@ namespace bx
return m_fn(m_userData);
}
#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360
#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_WINRT
static DWORD WINAPI threadFunc(LPVOID _arg)
{
Thread* thread = (Thread*)_arg;
@@ -150,7 +167,7 @@ namespace bx
}
#endif // BX_PLATFORM_
#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360
#if BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_WINRT
HANDLE m_handle;
#elif BX_PLATFORM_POSIX
pthread_t m_handle;
@@ -194,7 +211,7 @@ namespace bx
uint32_t m_id;
};
#else
#elif !(BX_PLATFORM_WINRT)
class TlsData
{

View File

@@ -41,6 +41,7 @@ function toolchain(_buildDir, _libDir)
{ "vs2012-clang", "Clang 3.6" },
{ "vs2013-clang", "Clang 3.6" },
{ "winphone8", "Windows Phone 8.0" },
{ "winphone81", "Windows Phone 8.1" }
},
}
@@ -272,6 +273,12 @@ function toolchain(_buildDir, _libDir)
premake.vstudio.toolset = "v110_wp80"
location (_buildDir .. "projects/" .. _ACTION .. "-winphone8")
end
if "winphone81" == _OPTIONS["vs"] then
premake.vstudio.toolset = "v120_wp81"
platforms { "ARM" }
location (_buildDir .. "projects/" .. _ACTION .. "-winphone81")
end
end
flags {
@@ -345,6 +352,10 @@ function toolchain(_buildDir, _libDir)
"$(DXSDK_DIR)/lib/x64",
}
configuration { "ARM", "vs*" }
targetdir (_buildDir .. "arm_" .. _ACTION .. "/bin")
objdir (_buildDir .. "arm_" .. _ACTION .. "/obj")
configuration { "vs*-clang" }
buildoptions {
"-Qunused-arguments",
@@ -358,6 +369,9 @@ function toolchain(_buildDir, _libDir)
targetdir (_buildDir .. "win64_" .. _ACTION .. "-clang/bin")
objdir (_buildDir .. "win64_" .. _ACTION .. "-clang/obj")
configuration { "winphone8*" }
removeflags { "StaticRuntime", "NoExceptions" }
configuration { "mingw-*" }
defines { "WIN32" }
includedirs { bxDir .. "include/compat/mingw" }

Binary file not shown.