Thread affinity on OS X and *BSD.

Keep building the software plugin to prevent rot.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7045 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2011-02-02 21:52:43 +00:00
parent 39b1ade020
commit a3ba93d9ce
8 changed files with 38 additions and 35 deletions

View File

@ -344,7 +344,7 @@ dirs = [
'Source/Core/VideoUICommon/Src', 'Source/Core/VideoUICommon/Src',
'Source/DSPTool/Src', 'Source/DSPTool/Src',
'Source/Plugins/Plugin_VideoOGL/Src', 'Source/Plugins/Plugin_VideoOGL/Src',
#'Source/Plugins/Plugin_VideoSoftware/Src', 'Source/Plugins/Plugin_VideoSoftware/Src',
'Source/UnitTests', 'Source/UnitTests',
] ]

View File

@ -19,6 +19,12 @@
#include "Thread.h" #include "Thread.h"
#include "Common.h" #include "Common.h"
#ifdef __APPLE__
#include <mach/mach.h>
#elif defined BSD4_4
#include <pthread_np.h>
#endif
#ifdef USE_BEGINTHREADEX #ifdef USE_BEGINTHREADEX
#include <process.h> #include <process.h>
#endif #endif
@ -30,6 +36,8 @@ int CurrentThreadId()
{ {
#ifdef _WIN32 #ifdef _WIN32
return GetCurrentThreadId(); return GetCurrentThreadId();
#elif defined __APPLE__
return mach_thread_self();
#else #else
return 0; return 0;
#endif #endif
@ -263,10 +271,12 @@ void SetCurrentThreadAffinity(u32 mask)
#else // !WIN32, so must be POSIX threads #else // !WIN32, so must be POSIX threads
void LinuxSetThreadAffinity(pthread_t thread, u32 mask) void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
{ {
// This is non-standard #ifdef __APPLE__
#ifdef __linux__ thread_policy_set(pthread_mach_thread_np(thread),
THREAD_AFFINITY_POLICY, (integer_t *)&mask, 1);
#elif defined __linux__ || defined BSD4_4
cpu_set_t cpu_set; cpu_set_t cpu_set;
CPU_ZERO(&cpu_set); CPU_ZERO(&cpu_set);
@ -278,14 +288,9 @@ void LinuxSetThreadAffinity(pthread_t thread, u32 mask)
#endif #endif
} }
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
{
LinuxSetThreadAffinity(thread, mask);
}
void SetCurrentThreadAffinity(u32 mask) void SetCurrentThreadAffinity(u32 mask)
{ {
LinuxSetThreadAffinity(pthread_self(), mask); SetThreadAffinity(pthread_self(), mask);
} }
static pthread_key_t threadname_key; static pthread_key_t threadname_key;

View File

@ -101,7 +101,7 @@ void CheckFile(std::string File, u64 Size)
std::string Str = StringFromFormat("%s kB %s", ThousandSeparate(Size, 7).c_str(), File.c_str()); std::string Str = StringFromFormat("%s kB %s", ThousandSeparate(Size, 7).c_str(), File.c_str());
if (ShowSound(File)) if (ShowSound(File))
{ {
NOTICE_LOG(FILEMON, "%s", Str.c_str()); INFO_LOG(FILEMON, "%s", Str.c_str());
} }
else else
{ {

View File

@ -1,3 +1,3 @@
add_subdirectory(Plugin_VideoOGL) add_subdirectory(Plugin_VideoOGL)
#add_subdirectory(Plugin_VideoSoftware) add_subdirectory(Plugin_VideoSoftware)
# TODO: Add other plugins here! # TODO: Add other plugins here!

View File

@ -22,10 +22,6 @@ if(wxWidgets_FOUND)
set(LIBS videouicommon ${LIBS} ${wxWidgets_LIBRARIES}) set(LIBS videouicommon ${LIBS} ${wxWidgets_LIBRARIES})
endif(wxWidgets_FOUND) endif(wxWidgets_FOUND)
if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND NOT wxWidgets_FOUND)
set(SRCS ${SRCS} Src/cocoaGL.m)
endif()
if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux") if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LIBS ${LIBS} Cg CgGL) set(LIBS ${LIBS} Cg CgGL)
endif() endif()

View File

@ -48,7 +48,7 @@ void OpenGL_SwapBuffers()
#if defined(USE_WX) && USE_WX #if defined(USE_WX) && USE_WX
GLWin.glCanvas->SwapBuffers(); GLWin.glCanvas->SwapBuffers();
#elif defined(__APPLE__) #elif defined(__APPLE__)
[GLWin.cocoaCtx flushBuffer]; [GLWin.cocoaCtx flushBuffer];
#elif defined(_WIN32) #elif defined(_WIN32)
SwapBuffers(hDC); SwapBuffers(hDC);
#elif defined(HAVE_X11) && HAVE_X11 #elif defined(HAVE_X11) && HAVE_X11
@ -322,7 +322,7 @@ void XEventThread()
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize() // Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool OpenGL_Create(int _iwidth, int _iheight) bool OpenGL_Create(int _iwidth, int _iheight)
{ {
int _tx, _ty, _twidth, _theight; int _tx, _ty, _twidth, _theight;
Core::Callback_VideoGetWindowSize(_tx, _ty, _twidth, _theight); Core::Callback_VideoGetWindowSize(_tx, _ty, _twidth, _theight);
// Control window size and picture scaling // Control window size and picture scaling
@ -342,7 +342,7 @@ bool OpenGL_Create(int _iwidth, int _iheight)
NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc]
initWithAttributes: attr]; initWithAttributes: attr];
if (fmt == nil) { if (fmt == nil) {
printf("failed to create pixel format\n"); ERROR_LOG(VIDEO, "failed to create pixel format");
return NULL; return NULL;
} }
@ -350,16 +350,18 @@ bool OpenGL_Create(int _iwidth, int _iheight)
initWithFormat: fmt shareContext: nil]; initWithFormat: fmt shareContext: nil];
[fmt release]; [fmt release];
if (GLWin.cocoaCtx == nil) { if (GLWin.cocoaCtx == nil) {
printf("failed to create context\n"); ERROR_LOG(VIDEO, "failed to create context");
return NULL; return NULL;
} }
GLWin.cocoaWin = [[NSWindow alloc] (void)VideoWindowHandle;
initWithContentRect: NSMakeRect(50, 50, _twidth, _theight) CGDisplayCapture(CGMainDisplayID());
styleMask: NSTitledWindowMask | NSResizableWindowMask GLWin.cocoaWin = [[NSWindow alloc]
backing: NSBackingStoreBuffered defer: FALSE]; initWithContentRect: [[NSScreen mainScreen] frame]
[GLWin.cocoaWin setReleasedWhenClosed: YES]; styleMask: NSBorderlessWindowMask
[GLWin.cocoaWin makeKeyAndOrderFront: nil]; backing: NSBackingStoreBuffered defer: NO];
[GLWin.cocoaWin makeKeyAndOrderFront: nil];
[GLWin.cocoaWin setLevel: CGShieldingWindowLevel()];
[GLWin.cocoaCtx setView: [GLWin.cocoaWin contentView]]; [GLWin.cocoaCtx setView: [GLWin.cocoaWin contentView]];
#elif defined(_WIN32) #elif defined(_WIN32)
@ -583,9 +585,9 @@ void OpenGL_Shutdown()
// XXX GLWin.glCanvas->Destroy(); // XXX GLWin.glCanvas->Destroy();
// XXX delete GLWin.glCtxt; // XXX delete GLWin.glCtxt;
#elif defined(__APPLE__) #elif defined(__APPLE__)
[GLWin.cocoaWin close]; [GLWin.cocoaWin close];
[GLWin.cocoaCtx clearDrawable]; [GLWin.cocoaCtx clearDrawable];
[GLWin.cocoaCtx release]; [GLWin.cocoaCtx release];
#elif defined(_WIN32) #elif defined(_WIN32)
if (hRC) // Do We Have A Rendering Context? if (hRC) // Do We Have A Rendering Context?
{ {

View File

@ -35,11 +35,11 @@ set(LIBS videocommon
${X11_LIBRARIES} ${X11_LIBRARIES}
${wxWidgets_LIBRARIES}) ${wxWidgets_LIBRARIES})
if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND NOT wxWidgets_FOUND) if(WIN32)
set(SRCS ${SRCS} Src/cocoaGL.m)
elseif(WIN32)
set(SRCS ${SRCS} Src/Win32.cpp) set(SRCS ${SRCS} Src/Win32.cpp)
elseif(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) endif()
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
set(LIBS ${LIBS} clrun) set(LIBS ${LIBS} clrun)
endif() endif()

View File

@ -81,7 +81,7 @@ void BPWritten(int address, int newvalue)
break; break;
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bpmem.petokenint & 0xFFFF)); DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bpmem.petokenint & 0xFFFF));
PixelEngine::SetToken(static_cast<u16>(bpmem.petokenint & 0xFFFF), TRUE); PixelEngine::SetToken(static_cast<u16>(bpmem.petokenint & 0xFFFF), true);
break; break;
case BPMEM_TRIGGER_EFB_COPY: case BPMEM_TRIGGER_EFB_COPY:
EfbCopy::CopyEfb(); EfbCopy::CopyEfb();