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/DSPTool/Src',
'Source/Plugins/Plugin_VideoOGL/Src',
#'Source/Plugins/Plugin_VideoSoftware/Src',
'Source/Plugins/Plugin_VideoSoftware/Src',
'Source/UnitTests',
]

View File

@ -19,6 +19,12 @@
#include "Thread.h"
#include "Common.h"
#ifdef __APPLE__
#include <mach/mach.h>
#elif defined BSD4_4
#include <pthread_np.h>
#endif
#ifdef USE_BEGINTHREADEX
#include <process.h>
#endif
@ -30,6 +36,8 @@ int CurrentThreadId()
{
#ifdef _WIN32
return GetCurrentThreadId();
#elif defined __APPLE__
return mach_thread_self();
#else
return 0;
#endif
@ -263,10 +271,12 @@ void SetCurrentThreadAffinity(u32 mask)
#else // !WIN32, so must be POSIX threads
void LinuxSetThreadAffinity(pthread_t thread, u32 mask)
{
// This is non-standard
#ifdef __linux__
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
{
#ifdef __APPLE__
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_ZERO(&cpu_set);
@ -278,14 +288,9 @@ void LinuxSetThreadAffinity(pthread_t thread, u32 mask)
#endif
}
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
{
LinuxSetThreadAffinity(thread, mask);
}
void SetCurrentThreadAffinity(u32 mask)
{
LinuxSetThreadAffinity(pthread_self(), mask);
SetThreadAffinity(pthread_self(), mask);
}
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());
if (ShowSound(File))
{
NOTICE_LOG(FILEMON, "%s", Str.c_str());
INFO_LOG(FILEMON, "%s", Str.c_str());
}
else
{

View File

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

View File

@ -22,10 +22,6 @@ if(wxWidgets_FOUND)
set(LIBS videouicommon ${LIBS} ${wxWidgets_LIBRARIES})
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")
set(LIBS ${LIBS} Cg CgGL)
endif()

View File

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

View File

@ -35,11 +35,11 @@ set(LIBS videocommon
${X11_LIBRARIES}
${wxWidgets_LIBRARIES})
if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND NOT wxWidgets_FOUND)
set(SRCS ${SRCS} Src/cocoaGL.m)
elseif(WIN32)
if(WIN32)
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)
endif()

View File

@ -81,7 +81,7 @@ void BPWritten(int address, int newvalue)
break;
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
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;
case BPMEM_TRIGGER_EFB_COPY:
EfbCopy::CopyEfb();