Fix saving states on mesa3d and clean up the handling of asynchronous requests
(those originating from a thread other than the gpu thread) glxMakeCurrent is supposed to error out when the context is still current in another thread. NVIDIA handles that, but mesa3d errors. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6054 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
9b6180ab27
commit
e5f629da37
|
@ -142,8 +142,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||||
{
|
{
|
||||||
video_initialize.pPeekMessages();
|
video_initialize.pPeekMessages();
|
||||||
|
|
||||||
VideoFifo_CheckEFBAccess();
|
VideoFifo_CheckAsyncRequest();
|
||||||
VideoFifo_CheckSwapRequest();
|
|
||||||
|
|
||||||
// check if we are able to run this buffer
|
// check if we are able to run this buffer
|
||||||
|
|
||||||
|
@ -209,8 +208,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||||
// If we don't, s_swapRequested (OGL only) or s_efbAccessRequested won't be set to false
|
// If we don't, s_swapRequested (OGL only) or s_efbAccessRequested won't be set to false
|
||||||
// leading the CPU thread to wait in Video_BeginField or Video_AccessEFB thus slowing things down.
|
// leading the CPU thread to wait in Video_BeginField or Video_AccessEFB thus slowing things down.
|
||||||
|
|
||||||
VideoFifo_CheckEFBAccess();
|
VideoFifo_CheckAsyncRequest();
|
||||||
VideoFifo_CheckSwapRequest();
|
|
||||||
CommandProcessor::isFifoBusy = false;
|
CommandProcessor::isFifoBusy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,6 @@ void Fifo_DoState(PointerWrap &f);
|
||||||
void Fifo_SetRendering(bool bEnabled);
|
void Fifo_SetRendering(bool bEnabled);
|
||||||
|
|
||||||
// Implemented by the Video Plugin
|
// Implemented by the Video Plugin
|
||||||
void VideoFifo_CheckSwapRequest();
|
void VideoFifo_CheckAsyncRequest();
|
||||||
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
|
|
||||||
void VideoFifo_CheckEFBAccess();
|
|
||||||
|
|
||||||
#endif // _FIFO_H
|
#endif // _FIFO_H
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "NativeVertexFormat.h"
|
#include "NativeVertexFormat.h"
|
||||||
#include "NativeVertexWriter.h"
|
#include "NativeVertexWriter.h"
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#include "BPStructs.h"
|
#include "BPStructs.h"
|
||||||
#include "XFStructs.h"
|
#include "XFStructs.h"
|
||||||
|
|
|
@ -409,6 +409,10 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoFifo_CheckAsyncRequest() {
|
||||||
|
VideoFifo_CheckSwapRequest();
|
||||||
|
VideoFifo_CheckEFBAccess();
|
||||||
|
}
|
||||||
|
|
||||||
void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address)
|
void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,5 +23,7 @@
|
||||||
|
|
||||||
extern SVideoInitialize g_VideoInitialize;
|
extern SVideoInitialize g_VideoInitialize;
|
||||||
extern volatile u32 s_swapRequested;
|
extern volatile u32 s_swapRequested;
|
||||||
|
void VideoFifo_CheckEFBAccess();
|
||||||
|
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "NativeVertexFormat.h"
|
#include "NativeVertexFormat.h"
|
||||||
#include "NativeVertexWriter.h"
|
#include "NativeVertexWriter.h"
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#include "BPStructs.h"
|
#include "BPStructs.h"
|
||||||
#include "XFStructs.h"
|
#include "XFStructs.h"
|
||||||
|
|
|
@ -435,6 +435,10 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y,u32 InputData)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoFifo_CheckAsyncRequest() {
|
||||||
|
VideoFifo_CheckSwapRequest();
|
||||||
|
VideoFifo_CheckEFBAccess();
|
||||||
|
}
|
||||||
|
|
||||||
void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address)
|
void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,5 +23,7 @@
|
||||||
|
|
||||||
extern SVideoInitialize g_VideoInitialize;
|
extern SVideoInitialize g_VideoInitialize;
|
||||||
extern volatile u32 s_swapRequested;
|
extern volatile u32 s_swapRequested;
|
||||||
|
void VideoFifo_CheckEFBAccess();
|
||||||
|
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include "OpcodeDecoding.h"
|
#include "OpcodeDecoding.h"
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
// internal state for loading vertices
|
// internal state for loading vertices
|
||||||
extern NativeVertexFormat *g_nativeVertexFmt;
|
extern NativeVertexFormat *g_nativeVertexFmt;
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,9 @@ int GLScissorX, GLScissorY, GLScissorW, GLScissorH;
|
||||||
static bool s_PluginInitialized = false;
|
static bool s_PluginInitialized = false;
|
||||||
|
|
||||||
volatile u32 s_swapRequested = FALSE;
|
volatile u32 s_swapRequested = FALSE;
|
||||||
|
#if defined(HAVE_X11) && HAVE_X11
|
||||||
|
static volatile u32 s_doStateRequested = FALSE;
|
||||||
|
#endif
|
||||||
static u32 s_efbAccessRequested = FALSE;
|
static u32 s_efbAccessRequested = FALSE;
|
||||||
static volatile u32 s_FifoShuttingDown = FALSE;
|
static volatile u32 s_FifoShuttingDown = FALSE;
|
||||||
|
|
||||||
|
@ -191,24 +194,53 @@ void Initialize(void *init)
|
||||||
OSD::AddMessage("Dolphin OpenGL Video Plugin", 5000);
|
OSD::AddMessage("Dolphin OpenGL Video Plugin", 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoState(unsigned char **ptr, int mode)
|
static volatile struct
|
||||||
{
|
{
|
||||||
|
unsigned char **ptr;
|
||||||
|
int mode;
|
||||||
|
} s_doStateArgs;
|
||||||
|
|
||||||
|
// Run from the GPU thread on X11, CPU thread on the rest
|
||||||
|
static void check_DoState() {
|
||||||
#if defined(HAVE_X11) && HAVE_X11
|
#if defined(HAVE_X11) && HAVE_X11
|
||||||
OpenGL_MakeCurrent();
|
if (Common::AtomicLoadAcquire(s_doStateRequested))
|
||||||
#endif
|
|
||||||
// Clear all caches that touch RAM
|
|
||||||
TextureMngr::Invalidate(false);
|
|
||||||
VertexLoaderManager::MarkAllDirty();
|
|
||||||
|
|
||||||
PointerWrap p(ptr, mode);
|
|
||||||
VideoCommon_DoState(p);
|
|
||||||
|
|
||||||
// Refresh state.
|
|
||||||
if (mode == PointerWrap::MODE_READ)
|
|
||||||
{
|
{
|
||||||
BPReload();
|
#endif
|
||||||
RecomputeCachedArraybases();
|
// Clear all caches that touch RAM
|
||||||
|
TextureMngr::Invalidate(false);
|
||||||
|
VertexLoaderManager::MarkAllDirty();
|
||||||
|
|
||||||
|
PointerWrap p(s_doStateArgs.ptr, s_doStateArgs.mode);
|
||||||
|
VideoCommon_DoState(p);
|
||||||
|
|
||||||
|
// Refresh state.
|
||||||
|
if (s_doStateArgs.mode == PointerWrap::MODE_READ)
|
||||||
|
{
|
||||||
|
BPReload();
|
||||||
|
RecomputeCachedArraybases();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_X11) && HAVE_X11
|
||||||
|
Common::AtomicStoreRelease(s_doStateRequested, FALSE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run from the CPU thread
|
||||||
|
void DoState(unsigned char **ptr, int mode) {
|
||||||
|
s_doStateArgs.ptr = ptr;
|
||||||
|
s_doStateArgs.mode = mode;
|
||||||
|
#if defined(HAVE_X11) && HAVE_X11
|
||||||
|
Common::AtomicStoreRelease(s_doStateRequested, TRUE);
|
||||||
|
if (g_VideoInitialize.bOnThread)
|
||||||
|
{
|
||||||
|
while (Common::AtomicLoadAcquire(s_doStateRequested) && !s_FifoShuttingDown)
|
||||||
|
//Common::SleepCurrentThread(1);
|
||||||
|
Common::YieldCPU();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
check_DoState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuStateChange(PLUGIN_EMUSTATE newState)
|
void EmuStateChange(PLUGIN_EMUSTATE newState)
|
||||||
|
@ -216,7 +248,8 @@ void EmuStateChange(PLUGIN_EMUSTATE newState)
|
||||||
Fifo_RunLoop((newState == PLUGIN_EMUSTATE_PLAY) ? true : false);
|
Fifo_RunLoop((newState == PLUGIN_EMUSTATE_PLAY) ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is called after Video_Initialize() from the Core
|
// This is called after Initialize() from the Core
|
||||||
|
// Run from the graphics thread
|
||||||
void Video_Prepare(void)
|
void Video_Prepare(void)
|
||||||
{
|
{
|
||||||
OpenGL_MakeCurrent();
|
OpenGL_MakeCurrent();
|
||||||
|
@ -335,7 +368,7 @@ void VideoFifo_CheckSwapRequest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
|
static inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
|
||||||
{
|
{
|
||||||
return !((aLower >= bUpper) || (bLower >= aUpper));
|
return !((aLower >= bUpper) || (bLower >= aUpper));
|
||||||
}
|
}
|
||||||
|
@ -430,6 +463,14 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoFifo_CheckAsyncRequest() {
|
||||||
|
VideoFifo_CheckSwapRequest();
|
||||||
|
VideoFifo_CheckEFBAccess();
|
||||||
|
#if defined(HAVE_X11) && HAVE_X11
|
||||||
|
check_DoState();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address)
|
void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address)
|
||||||
{
|
{
|
||||||
CommandProcessor::Read16(_rReturnValue, _Address);
|
CommandProcessor::Read16(_rReturnValue, _Address);
|
||||||
|
|
|
@ -22,5 +22,7 @@
|
||||||
|
|
||||||
extern SVideoInitialize g_VideoInitialize;
|
extern SVideoInitialize g_VideoInitialize;
|
||||||
extern volatile u32 s_swapRequested;
|
extern volatile u32 s_swapRequested;
|
||||||
|
void VideoFifo_CheckEFBAccess();
|
||||||
|
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
|
||||||
|
|
||||||
#endif // _MAIN_H_
|
#endif // _MAIN_H_
|
||||||
|
|
Loading…
Reference in New Issue