mirror of https://github.com/PCSX2/pcsx2.git
GSopen2: Simplified the multithreaded and irq callback parameter passing scheme, and made them more "robust" so that they can be changed dynamically without the GS exploding (important with the new correct GSState preservation across open/close).
git-svn-id: http://pcsx2.googlecode.com/svn/branches/GSopen2@1860 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
73a39b012c
commit
27af8d80ca
|
@ -126,7 +126,7 @@ EXPORT_C GSclose()
|
|||
s_gs->m_wnd.Detach();
|
||||
}
|
||||
|
||||
static INT32 GSopen(void* dsp, char* title, int mt, int renderer)
|
||||
static INT32 _GSopen(void* dsp, char* title, int renderer)
|
||||
{
|
||||
GSclose();
|
||||
|
||||
|
@ -153,17 +153,17 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer)
|
|||
switch(renderer)
|
||||
{
|
||||
default:
|
||||
case 0: s_gs = new GSRendererDX9(!!mt, s_irq); break;
|
||||
case 3: s_gs = new GSRendererDX10(!!mt, s_irq); break;
|
||||
case 6: s_gs = new GSRendererDX11(!!mt, s_irq); break;
|
||||
case 0: s_gs = new GSRendererDX9(); break;
|
||||
case 3: s_gs = new GSRendererDX10(); break;
|
||||
case 6: s_gs = new GSRendererDX11(); break;
|
||||
#if 0
|
||||
case 9: s_gs = new GSRendererOGL(!!mt, s_irq); break;
|
||||
case 9: s_gs = new GSRendererOGL(); break;
|
||||
#endif
|
||||
case 2: case 5: case 8: case 11: case 13:
|
||||
s_gs = new GSRendererNull(!!mt, s_irq); break;
|
||||
s_gs = new GSRendererNull(); break;
|
||||
|
||||
case 1: case 4: case 7: case 10: case 12:
|
||||
s_gs = new GSRendererSW(!!mt, s_irq); break;
|
||||
s_gs = new GSRendererSW(); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,6 +177,7 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer)
|
|||
}
|
||||
|
||||
s_gs->SetRegsMem(s_basemem);
|
||||
s_gs->SetIrqCallback(s_irq);
|
||||
|
||||
if( *(HWND*)dsp == NULL )
|
||||
{
|
||||
|
@ -196,6 +197,7 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer)
|
|||
}
|
||||
else
|
||||
{
|
||||
s_gs->SetMultithreaded( true );
|
||||
s_gs->m_wnd.Attach( *(HWND*)dsp, false );
|
||||
}
|
||||
|
||||
|
@ -221,7 +223,7 @@ EXPORT_C_(INT32) GSopen2( void* dsp, INT32 flags )
|
|||
renderer = 1;
|
||||
}
|
||||
|
||||
return GSopen( dsp, NULL, true, renderer );
|
||||
return _GSopen( dsp, NULL, renderer );
|
||||
}
|
||||
|
||||
EXPORT_C_(INT32) GSopen(void* dsp, char* title, int mt)
|
||||
|
@ -241,7 +243,15 @@ EXPORT_C_(INT32) GSopen(void* dsp, char* title, int mt)
|
|||
}
|
||||
|
||||
*(HWND*)dsp = NULL;
|
||||
return GSopen(dsp, title, mt, renderer);
|
||||
|
||||
int retval = _GSopen(dsp, title, renderer);
|
||||
|
||||
if( retval == 0 && s_gs )
|
||||
{
|
||||
s_gs->SetMultithreaded( false );
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
EXPORT_C GSreset()
|
||||
|
@ -348,6 +358,10 @@ EXPORT_C GSabout()
|
|||
EXPORT_C GSirqCallback(void (*irq)())
|
||||
{
|
||||
s_irq = irq;
|
||||
if( s_gs )
|
||||
{
|
||||
s_gs->SetIrqCallback(s_irq);
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_C_(int) GSsetupRecording(int start, void* data)
|
||||
|
@ -409,7 +423,7 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
|
|||
GSsetBaseMem(regs);
|
||||
|
||||
HWND hWnd = NULL;
|
||||
GSopen(&hWnd, "", true, renderer);
|
||||
GSopen(&hWnd, "", renderer);
|
||||
|
||||
uint32 crc;
|
||||
fread(&crc, 4, 1, fp);
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include "StdAfx.h"
|
||||
#include "GSRenderer.h"
|
||||
|
||||
GSRenderer::GSRenderer(bool mt, void (*irq)())
|
||||
: GSState(mt, irq)
|
||||
GSRenderer::GSRenderer()
|
||||
: GSState()
|
||||
, m_dev(NULL)
|
||||
, m_shader(0)
|
||||
, m_vt(this)
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
int s_saven;
|
||||
|
||||
public:
|
||||
GSRenderer(bool mt, void (*irq)());
|
||||
GSRenderer();
|
||||
virtual ~GSRenderer();
|
||||
|
||||
virtual bool CreateWnd(const string& title, int w, int h);
|
||||
|
@ -217,8 +217,8 @@ protected:
|
|||
virtual void Draw() = 0;
|
||||
|
||||
public:
|
||||
GSRendererT(bool mt, void (*irq)())
|
||||
: GSRenderer(mt, irq)
|
||||
GSRendererT()
|
||||
: GSRenderer()
|
||||
, m_vertices(NULL)
|
||||
, m_count(0)
|
||||
, m_maxcount(0)
|
||||
|
|
|
@ -40,8 +40,8 @@ protected:
|
|||
virtual void UpdateFBA(GSTexture* rt) {}
|
||||
|
||||
public:
|
||||
GSRendererDX(bool mt, void (*irq)(), GSTextureCache* tc, const GSVector2& pixelcenter = GSVector2(0, 0))
|
||||
: GSRendererHW<Vertex>(mt, irq, tc)
|
||||
GSRendererDX(GSTextureCache* tc, const GSVector2& pixelcenter = GSVector2(0, 0))
|
||||
: GSRendererHW<Vertex>(tc)
|
||||
, m_pixelcenter(pixelcenter)
|
||||
, m_topology(-1)
|
||||
{
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include "GSCrc.h"
|
||||
#include "resource.h"
|
||||
|
||||
GSRendererDX10::GSRendererDX10(bool mt, void (*irq)())
|
||||
: GSRendererDX<GSVertexHW10>(mt, irq, new GSTextureCache10(this), GSVector2(-0.5f, -0.5f))
|
||||
GSRendererDX10::GSRendererDX10()
|
||||
: GSRendererDX<GSVertexHW10>(new GSTextureCache10(this), GSVector2(-0.5f, -0.5f))
|
||||
{
|
||||
InitVertexKick<GSRendererDX10>();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
|||
void SetupDATE(GSTexture* rt, GSTexture* ds);
|
||||
|
||||
public:
|
||||
GSRendererDX10(bool mt, void (*irq)());
|
||||
GSRendererDX10();
|
||||
|
||||
bool CreateDevice(GSDevice* dev);
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include "GSCrc.h"
|
||||
#include "resource.h"
|
||||
|
||||
GSRendererDX11::GSRendererDX11(bool mt, void (*irq)())
|
||||
: GSRendererDX<GSVertexHW11>(mt, irq, new GSTextureCache11(this), GSVector2(-0.5f, -0.5f))
|
||||
GSRendererDX11::GSRendererDX11()
|
||||
: GSRendererDX<GSVertexHW11>(new GSTextureCache11(this), GSVector2(-0.5f, -0.5f))
|
||||
{
|
||||
InitVertexKick<GSRendererDX11>();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ protected:
|
|||
void SetupDATE(GSTexture* rt, GSTexture* ds);
|
||||
|
||||
public:
|
||||
GSRendererDX11(bool mt, void (*irq)());
|
||||
GSRendererDX11();
|
||||
|
||||
bool CreateDevice(GSDevice* dev);
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include "GSCrc.h"
|
||||
#include "resource.h"
|
||||
|
||||
GSRendererDX9::GSRendererDX9(bool mt, void (*irq)())
|
||||
: GSRendererDX<GSVertexHW9>(mt, irq, new GSTextureCache9(this))
|
||||
GSRendererDX9::GSRendererDX9()
|
||||
: GSRendererDX<GSVertexHW9>(new GSTextureCache9(this))
|
||||
{
|
||||
InitVertexKick<GSRendererDX9>();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ protected:
|
|||
void UpdateFBA(GSTexture* rt);
|
||||
|
||||
public:
|
||||
GSRendererDX9(bool mt, void (*irq)());
|
||||
GSRendererDX9();
|
||||
|
||||
bool CreateDevice(GSDevice* dev);
|
||||
|
||||
|
|
|
@ -704,8 +704,8 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
GSRendererHW(bool mt, void (*irq)(), GSTextureCache* tc)
|
||||
: GSRendererT<Vertex>(mt, irq)
|
||||
GSRendererHW(GSTextureCache* tc)
|
||||
: GSRendererT<Vertex>()
|
||||
, m_tc(tc)
|
||||
, m_width(1024)
|
||||
, m_height(1024)
|
||||
|
|
|
@ -37,8 +37,8 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
GSRendererNull(bool mt, void (*irq)())
|
||||
: GSRendererT<GSVertexNull>(mt, irq)
|
||||
GSRendererNull()
|
||||
: GSRendererT<GSVertexNull>()
|
||||
{
|
||||
InitVertexKick<GSRendererNull>();
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include "GSCrc.h"
|
||||
#include "resource.h"
|
||||
|
||||
GSRendererOGL::GSRendererOGL(bool mt, void (*irq)())
|
||||
: GSRendererHW<GSVertexOGL>(mt, irq, new GSTextureCacheOGL(this))
|
||||
GSRendererOGL::GSRendererOGL()
|
||||
: GSRendererHW<GSVertexOGL>(new GSTextureCacheOGL(this))
|
||||
{
|
||||
InitVertexKick<GSRendererOGL>();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ protected:
|
|||
void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex);
|
||||
|
||||
public:
|
||||
GSRendererOGL(bool mt, void (*irq)());
|
||||
GSRendererOGL();
|
||||
|
||||
bool CreateDevice(GSDevice* dev);
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
const GSVector4 g_pos_scale(1.0f / 16, 1.0f / 16, 1.0f, 128.0f);
|
||||
|
||||
GSRendererSW::GSRendererSW(bool mt, void (*irq)())
|
||||
: GSRendererT(mt, irq)
|
||||
GSRendererSW::GSRendererSW()
|
||||
: GSRendererT()
|
||||
{
|
||||
m_tc = new GSTextureCacheSW(this);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
|||
void GetScanlineParam(GSScanlineParam& p, GS_PRIM_CLASS primclass);
|
||||
|
||||
public:
|
||||
GSRendererSW(bool mt, void (*irq)());
|
||||
GSRendererSW();
|
||||
virtual ~GSRendererSW();
|
||||
|
||||
template<uint32 prim, uint32 tme, uint32 fst>
|
||||
|
|
|
@ -22,9 +22,10 @@
|
|||
#include "stdafx.h"
|
||||
#include "GSState.h"
|
||||
|
||||
GSState::GSState(bool mt, void (*irq)())
|
||||
: m_mt(mt)
|
||||
, m_irq(irq)
|
||||
GSState::GSState()
|
||||
: m_mt(false)
|
||||
, m_irq(NULL)
|
||||
, m_regs(NULL)
|
||||
, m_crc(0)
|
||||
, m_options(0)
|
||||
, m_path3hack(0)
|
||||
|
@ -103,6 +104,32 @@ void GSState::SetRegsMem( uint8* basemem )
|
|||
m_regs = (GSPrivRegSet*)basemem;
|
||||
}
|
||||
|
||||
void GSState::SetIrqCallback(void (*irq)())
|
||||
{
|
||||
m_irq = irq;
|
||||
}
|
||||
|
||||
void GSState::SetMultithreaded( bool isMT )
|
||||
{
|
||||
// Some older versions of PCSX2 didn't properly set the irq callback to NULL
|
||||
// in multithreaded mode (possibly because ZeroGS itself would assert in such
|
||||
// cases), and didn't bind them to a dummy callback either. PCSX2 handles all
|
||||
// IRQs internally when multithreaded anyway -- so let's ignore them here:
|
||||
|
||||
m_mt = isMT;
|
||||
if( isMT )
|
||||
{
|
||||
m_fpGIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GSState::GIFRegHandlerNull;
|
||||
m_fpGIFRegHandlers[GIF_A_D_REG_FINISH] = &GSState::GIFRegHandlerNull;
|
||||
m_fpGIFRegHandlers[GIF_A_D_REG_LABEL] = &GSState::GIFRegHandlerNull;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fpGIFRegHandlers[GIF_A_D_REG_SIGNAL] = &GSState::GIFRegHandlerSIGNAL;
|
||||
m_fpGIFRegHandlers[GIF_A_D_REG_FINISH] = &GSState::GIFRegHandlerFINISH;
|
||||
m_fpGIFRegHandlers[GIF_A_D_REG_LABEL] = &GSState::GIFRegHandlerLABEL;
|
||||
}
|
||||
}
|
||||
|
||||
void GSState::Reset()
|
||||
{
|
||||
|
@ -915,8 +942,6 @@ void GSState::GIFRegHandlerHWREG(GIFReg* r)
|
|||
|
||||
void GSState::GIFRegHandlerSIGNAL(GIFReg* r)
|
||||
{
|
||||
if(m_mt) return;
|
||||
|
||||
m_regs->SIGLBLID.SIGID = (m_regs->SIGLBLID.SIGID & ~r->SIGNAL.IDMSK) | (r->SIGNAL.ID & r->SIGNAL.IDMSK);
|
||||
|
||||
if(m_regs->CSR.wSIGNAL) m_regs->CSR.rSIGNAL = 1;
|
||||
|
@ -925,16 +950,12 @@ void GSState::GIFRegHandlerSIGNAL(GIFReg* r)
|
|||
|
||||
void GSState::GIFRegHandlerFINISH(GIFReg* r)
|
||||
{
|
||||
if(m_mt) return;
|
||||
|
||||
if(m_regs->CSR.wFINISH) m_regs->CSR.rFINISH = 1;
|
||||
if(!m_regs->IMR.FINISHMSK && m_irq) m_irq();
|
||||
}
|
||||
|
||||
void GSState::GIFRegHandlerLABEL(GIFReg* r)
|
||||
{
|
||||
if(m_mt) return;
|
||||
|
||||
m_regs->SIGLBLID.LBLID = (m_regs->SIGLBLID.LBLID & ~r->LABEL.IDMSK) | (r->LABEL.ID & r->LABEL.IDMSK);
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ public:
|
|||
GSDump m_dump;
|
||||
|
||||
public:
|
||||
GSState(bool mt, void (*irq)());
|
||||
GSState();
|
||||
virtual ~GSState();
|
||||
|
||||
void ResetHandlers();
|
||||
|
@ -251,5 +251,7 @@ public:
|
|||
void SetFrameSkip(int skip);
|
||||
void SetFrameLimit(bool limit);
|
||||
void SetRegsMem( uint8* basemem );
|
||||
void SetIrqCallback(void (*irq)());
|
||||
void SetMultithreaded( bool isMT=true );
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue