experimental multi-core support on linux

- Input seems not to work for some reason (please check and tell me if it's not only me)
- Skip frames is not supported

Report to me of other problems


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@740 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2008-10-02 10:43:32 +00:00
parent a1837662a0
commit dc3fd905c9
4 changed files with 26 additions and 4 deletions

View File

@ -157,11 +157,16 @@ void Init()
#ifdef _WIN32 #ifdef _WIN32
InitializeCriticalSection(&fifo.sync); InitializeCriticalSection(&fifo.sync);
#else
fifo.sync = new Common::CriticalSection(0);
#endif #endif
} }
void Shutdown() void Shutdown()
{ {
#ifndef _WIN32
delete fifo.sync;
#endif
} }
void Read16(u16& _rReturnValue, const u32 _Address) void Read16(u16& _rReturnValue, const u32 _Address)
@ -249,6 +254,8 @@ void Write16(const u16 _Value, const u32 _Address)
} }
#ifdef _WIN32 #ifdef _WIN32
EnterCriticalSection(&fifo.sync); EnterCriticalSection(&fifo.sync);
#else
fifo.sync->Enter();
#endif #endif
} }
@ -332,9 +339,11 @@ void Write16(const u16 _Value, const u32 _Address)
// update the registers and run the fifo // update the registers and run the fifo
// This will recursively enter fifo.sync, TODO(ector): is this good? // This will recursively enter fifo.sync, TODO(ector): is this good?
UpdateFifoRegister(); UpdateFifoRegister();
#ifdef _WIN32
if (Core::g_CoreStartupParameter.bUseDualCore) if (Core::g_CoreStartupParameter.bUseDualCore)
#ifdef _WIN32
LeaveCriticalSection(&fifo.sync); LeaveCriticalSection(&fifo.sync);
#else
fifo.sync->Leave();
#endif #endif
fifo.bPauseRead = false; // pauseread is not actually used anywhere! TOOD(ector): huh! fifo.bPauseRead = false; // pauseread is not actually used anywhere! TOOD(ector): huh!
} }
@ -369,6 +378,10 @@ void GatherPipeBursted()
Common::SleepCurrentThread(1); Common::SleepCurrentThread(1);
#ifdef _WIN32 #ifdef _WIN32
InterlockedExchangeAdd((LONG*)&fifo.CPReadWriteDistance, GPFifo::GATHER_PIPE_SIZE); InterlockedExchangeAdd((LONG*)&fifo.CPReadWriteDistance, GPFifo::GATHER_PIPE_SIZE);
#else
fifo.sync->Enter();
fifo.CPReadWriteDistance += GPFifo::GATHER_PIPE_SIZE;
fifo.sync->Leave();
#endif #endif
// check if we are in sync // check if we are in sync

View File

@ -181,7 +181,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) #if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32)
while(_fifo.CPReadWriteDistance > 0) while(_fifo.CPReadWriteDistance > 0)
#else #else
int count = 200; int count = 200;
while(_fifo.CPReadWriteDistance > 0 && count) while(_fifo.CPReadWriteDistance > 0 && count)
#endif #endif
{ {
@ -200,12 +200,17 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
u8 *uData = video_initialize.pGetMemoryPointer(_fifo.CPReadPointer); u8 *uData = video_initialize.pGetMemoryPointer(_fifo.CPReadPointer);
#ifdef _WIN32 #ifdef _WIN32
EnterCriticalSection(&_fifo.sync); EnterCriticalSection(&_fifo.sync);
#else
_fifo.sync->Enter();
#endif #endif
_fifo.CPReadPointer += 32; _fifo.CPReadPointer += 32;
Video_SendFifoData(uData); Video_SendFifoData(uData);
#ifdef _WIN32 #ifdef _WIN32
InterlockedExchangeAdd((LONG*)&_fifo.CPReadWriteDistance, -32); InterlockedExchangeAdd((LONG*)&_fifo.CPReadWriteDistance, -32);
LeaveCriticalSection(&_fifo.sync); LeaveCriticalSection(&_fifo.sync);
#else
_fifo.CPReadWriteDistance -= 32;
_fifo.sync->Leave();
#endif #endif
// increase the ReadPtr // increase the ReadPtr
if (_fifo.CPReadPointer >= _fifo.CPEnd) if (_fifo.CPReadPointer >= _fifo.CPEnd)

View File

@ -5,10 +5,12 @@
#ifndef _VIDEO_H_INCLUDED__ #ifndef _VIDEO_H_INCLUDED__
#define _VIDEO_H_INCLUDED__ #define _VIDEO_H_INCLUDED__
#include "Thread.h"
#include "PluginSpecs.h" #include "PluginSpecs.h"
#include "ExportProlog.h" #include "ExportProlog.h"
typedef void (*TSetPEToken)(const unsigned short _token, const int _bSetTokenAcknowledge); typedef void (*TSetPEToken)(const unsigned short _token, const int _bSetTokenAcknowledge);
typedef void (*TSetPEFinish)(void); typedef void (*TSetPEFinish)(void);
typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _iAddress); typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _iAddress);
@ -40,6 +42,8 @@ typedef struct
volatile bool bPauseRead; volatile bool bPauseRead;
#ifdef _WIN32 #ifdef _WIN32
CRITICAL_SECTION sync; CRITICAL_SECTION sync;
#else
Common::CriticalSection *sync;
#endif #endif
} SCPFifoStruct; } SCPFifoStruct;

View File

@ -79,7 +79,7 @@ BOOL Callback_PeekMessages()
// TODO: There is no documentation of this function and the calling code // TODO: There is no documentation of this function and the calling code
// ignores the return value, so I have no idea what would be the // ignores the return value, so I have no idea what would be the
// proper value to return. // proper value to return.
return FALSE; return TRUE;
#elif defined(_WIN32) #elif defined(_WIN32)
//TODO: peekmessage //TODO: peekmessage
MSG msg; MSG msg;
@ -94,7 +94,7 @@ BOOL Callback_PeekMessages()
#else // GLX #else // GLX
// This is called from Outside of our video thread, from EmuThread // This is called from Outside of our video thread, from EmuThread
// The calls are NOT thread safe, so it breaks everything // The calls are NOT thread safe, so it breaks everything
return FALSE; return TRUE;
#endif #endif
} }