GSdx: just squeezing a few more fps.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1534 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gabest11 2009-07-16 21:36:07 +00:00
parent 800039c829
commit e58776e095
55 changed files with 441 additions and 456 deletions

View File

@ -162,7 +162,7 @@ void GPURenderer::VSync()
GetClientRect(m_hWnd, r); GetClientRect(m_hWnd, r);
m_dev->Present(r.fit(m_aspectratio), 0); m_dev->Present(r.fit(m_aspectratio), 0, true);
} }
bool GPURenderer::MakeSnapshot(const string& path) bool GPURenderer::MakeSnapshot(const string& path)

View File

@ -303,7 +303,7 @@ EXPORT_C GSsetFrameSkip(int frameskip)
EXPORT_C GSsetFrameLimit(int limit) EXPORT_C GSsetFrameLimit(int limit)
{ {
s_gs->SetFrameLimit(limit); s_gs->SetFrameLimit(limit != 0);
} }
#ifdef _WINDOWS #ifdef _WINDOWS

View File

@ -815,7 +815,7 @@ REG64_(GIFReg, TEX1)
uint32 _PAD2:9; uint32 _PAD2:9;
uint32 L:2; uint32 L:2;
uint32 _PAD3:11; uint32 _PAD3:11;
uint32 K:12; uint32 K:12; // TODO: 1:7:4 (signed? 16x scaled?)
uint32 _PAD4:20; uint32 _PAD4:20;
REG_END2 REG_END2

View File

@ -314,43 +314,56 @@ void GSClut::GetAlphaMinMax32(int& amin, int& amax)
{ {
m_read.adirty = false; m_read.adirty = false;
// uint32 bpp = GSLocalMemory::m_psm[m_read.TEX0.PSM].trbpp; if(GSLocalMemory::m_psm[m_read.TEX0.CPSM].trbpp == 24 && m_read.TEXA.AEM == 0)
uint32 cbpp = GSLocalMemory::m_psm[m_read.TEX0.CPSM].trbpp;
uint32 pal = GSLocalMemory::m_psm[m_read.TEX0.PSM].pal;
if(cbpp == 24 && m_read.TEXA.AEM == 0)
{ {
m_read.amin = m_read.TEXA.TA0; m_read.amin = m_read.TEXA.TA0;
m_read.amax = m_read.TEXA.TA0; m_read.amax = m_read.TEXA.TA0;
} }
else else
{ {
int amin = 255;
int amax = 0;
const GSVector4i* p = (const GSVector4i*)m_buff32; const GSVector4i* p = (const GSVector4i*)m_buff32;
for(int i = 0, j = pal >> 4; i < j; i++) GSVector4i amin, amax;
if(GSLocalMemory::m_psm[m_read.TEX0.PSM].pal == 256)
{ {
GSVector4i v0 = (p[i * 4 + 0] >> 24).ps32(p[i * 4 + 1] >> 24); amin = GSVector4i::xffffffff();
GSVector4i v1 = (p[i * 4 + 2] >> 24).ps32(p[i * 4 + 3] >> 24); amax = GSVector4i::zero();
GSVector4i v2 = v0.min_i16(v1); for(int i = 0; i < 16; i++)
GSVector4i v3 = v0.max_i16(v1); {
GSVector4i v0 = (p[i * 4 + 0] >> 24).ps32(p[i * 4 + 1] >> 24);
GSVector4i v1 = (p[i * 4 + 2] >> 24).ps32(p[i * 4 + 3] >> 24);
GSVector4i v2 = v0.pu16(v1);
v2 = v2.min_i16(v2.zwxy()); amin = amin.min_u8(v2);
v3 = v3.max_i16(v3.zwxy()); amax = amax.max_u8(v2);
v2 = v2.min_i16(v2.zwxyl()); }
v3 = v3.max_i16(v3.zwxyl()); }
v2 = v2.min_i16(v2.yxwzl()); else
v3 = v3.max_i16(v3.yxwzl()); {
ASSERT(GSLocalMemory::m_psm[m_read.TEX0.PSM].pal == 16);
amin = min(amin, v2.extract16<0>()); GSVector4i v0 = (p[0] >> 24).ps32(p[1] >> 24);
amax = max(amax, v3.extract16<0>()); GSVector4i v1 = (p[2] >> 24).ps32(p[3] >> 24);
GSVector4i v2 = v0.pu16(v1);
amin = v2;
amax = v2;
} }
m_read.amin = amin; amin = amin.min_u8(amin.zwxy());
m_read.amax = amax; amax = amax.max_u8(amax.zwxy());
amin = amin.min_u8(amin.zwxyl());
amax = amax.max_u8(amax.zwxyl());
amin = amin.min_u8(amin.yxwzl());
amax = amax.max_u8(amax.yxwzl());
GSVector4i v0 = amin.upl8(amax).u8to16();
GSVector4i v1 = v0.yxwz();
m_read.amin = v0.min_i16(v1).extract16<0>();
m_read.amax = v0.max_i16(v1).extract16<1>();
} }
} }

View File

@ -89,6 +89,7 @@ CRC::Game CRC::m_games[] =
{0x7D8F539A, SoTC, EU, 0}, {0x7D8F539A, SoTC, EU, 0},
{0x3122B508, OnePieceGrandAdventure, US, 0}, {0x3122B508, OnePieceGrandAdventure, US, 0},
{0x8DF14A24, OnePieceGrandAdventure, Unknown, 0}, {0x8DF14A24, OnePieceGrandAdventure, Unknown, 0},
{0xB049DD5E, OnePieceGrandBattle, US, 0},
{0x5D02CC5B, OnePieceGrandBattle, Unknown, 0}, {0x5D02CC5B, OnePieceGrandBattle, Unknown, 0},
{0x6F8545DB, ICO, US, 0}, {0x6F8545DB, ICO, US, 0},
{0xB01A4C95, ICO, JP, 0}, {0xB01A4C95, ICO, JP, 0},

View File

@ -75,14 +75,14 @@ bool GSDevice::Reset(int w, int h, int mode)
return true; return true;
} }
void GSDevice::Present(const GSVector4i& r, int shader) void GSDevice::Present(const GSVector4i& r, int shader, bool limit)
{ {
GSVector4i cr = m_wnd->GetClientRect(); GSVector4i cr = m_wnd->GetClientRect();
int w = std::max(cr.width(), 1); int w = std::max(cr.width(), 1);
int h = std::max(cr.height(), 1); int h = std::max(cr.height(), 1);
if(!m_backbuffer || m_backbuffer->GetWidth() != w || m_backbuffer->GetHeight() != h) if(!m_backbuffer || m_backbuffer->m_size.x != w || m_backbuffer->m_size.y != h)
{ {
if(!Reset(w, h, DontCare)) if(!Reset(w, h, DontCare))
{ {
@ -99,7 +99,7 @@ void GSDevice::Present(const GSVector4i& r, int shader)
StretchRect(m_current, m_backbuffer, GSVector4(r), s_shader[shader]); StretchRect(m_current, m_backbuffer, GSVector4(r), s_shader[shader]);
} }
Flip(); Flip(limit);
} }
GSTexture* GSDevice::Fetch(int type, int w, int h, int format) GSTexture* GSDevice::Fetch(int type, int w, int h, int format)
@ -240,7 +240,7 @@ bool GSDevice::ResizeTexture(GSTexture** t, int w, int h)
GSTexture* t2 = *t; GSTexture* t2 = *t;
if(t2 == NULL || t2->GetWidth() != w || t2->GetHeight() != h) if(t2 == NULL || t2->m_size.x != w || t2->m_size.y != h)
{ {
delete t2; delete t2;
@ -251,8 +251,3 @@ bool GSDevice::ResizeTexture(GSTexture** t, int w, int h)
return t2 != NULL; return t2 != NULL;
} }
void GSDevice::SetVSync(bool vsync)
{
m_vsync = vsync;
}

View File

@ -79,8 +79,8 @@ public:
virtual bool Create(GSWnd* wnd, bool vsync); virtual bool Create(GSWnd* wnd, bool vsync);
virtual bool Reset(int w, int h, int mode); virtual bool Reset(int w, int h, int mode);
virtual bool IsLost(bool update = false) {return false;} virtual bool IsLost(bool update = false) {return false;}
virtual void Present(const GSVector4i& r, int shader); virtual void Present(const GSVector4i& r, int shader, bool limit);
virtual void Flip() {} virtual void Flip(bool limit) {}
virtual void BeginScene() {} virtual void BeginScene() {}
virtual void DrawPrimitive() {}; virtual void DrawPrimitive() {};
@ -103,8 +103,6 @@ public:
virtual void StretchRect(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true); virtual void StretchRect(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true);
virtual void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true) {} virtual void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true) {}
virtual void SetVSync(bool vsync);
GSTexture* GetCurrent(); GSTexture* GetCurrent();
void Merge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, const GSVector2i& fs, bool slbg, bool mmod, const GSVector4& c); void Merge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, const GSVector2i& fs, bool slbg, bool mmod, const GSVector4& c);

View File

@ -231,9 +231,9 @@ bool GSDevice10::Reset(int w, int h, int mode)
return true; return true;
} }
void GSDevice10::Flip() void GSDevice10::Flip(bool limit)
{ {
m_swapchain->Present(m_vsync ? 1 : 0, 0); m_swapchain->Present(m_vsync && limit ? 1 : 0, 0);
} }
void GSDevice10::BeginScene() void GSDevice10::BeginScene()
@ -456,7 +456,7 @@ void GSDevice10::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt,
// rs // rs
RSSet(ds.x, ds.y); RSSet(ds);
// //
@ -665,9 +665,9 @@ void GSDevice10::PSSetSamplerState(ID3D10SamplerState* ss0, ID3D10SamplerState*
} }
} }
void GSDevice10::RSSet(int width, int height, const GSVector4i* scissor) void GSDevice10::RSSet(const GSVector2i& size, const GSVector4i* scissor)
{ {
if(m_viewport.x != width || m_viewport.y != height) if(m_viewport != size)
{ {
D3D10_VIEWPORT vp; D3D10_VIEWPORT vp;
@ -675,17 +675,17 @@ void GSDevice10::RSSet(int width, int height, const GSVector4i* scissor)
vp.TopLeftX = 0; vp.TopLeftX = 0;
vp.TopLeftY = 0; vp.TopLeftY = 0;
vp.Width = width; vp.Width = size.x;
vp.Height = height; vp.Height = size.y;
vp.MinDepth = 0.0f; vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f; vp.MaxDepth = 1.0f;
m_dev->RSSetViewports(1, &vp); m_dev->RSSetViewports(1, &vp);
m_viewport = GSVector2i(width, height); m_viewport = size;
} }
GSVector4i r = scissor ? *scissor : GSVector4i(0, 0, width, height); GSVector4i r = scissor ? *scissor : GSVector4i(size).zwxy();
if(!m_scissor.eq(r)) if(!m_scissor.eq(r))
{ {

View File

@ -97,7 +97,7 @@ public:
bool Create(GSWnd* wnd, bool vsync); bool Create(GSWnd* wnd, bool vsync);
bool Reset(int w, int h, int mode); bool Reset(int w, int h, int mode);
void Flip(); void Flip(bool limit);
void BeginScene(); void BeginScene();
void DrawPrimitive(); void DrawPrimitive();
@ -130,7 +130,7 @@ public:
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
void PSSetShader(ID3D10PixelShader* ps, ID3D10Buffer* ps_cb); void PSSetShader(ID3D10PixelShader* ps, ID3D10Buffer* ps_cb);
void PSSetSamplerState(ID3D10SamplerState* ss0, ID3D10SamplerState* ss1); void PSSetSamplerState(ID3D10SamplerState* ss0, ID3D10SamplerState* ss1);
void RSSet(int width, int height, const GSVector4i* scissor = NULL); void RSSet(const GSVector2i& size, const GSVector4i* scissor = NULL);
void OMSetDepthStencilState(ID3D10DepthStencilState* dss, uint8 sref); void OMSetDepthStencilState(ID3D10DepthStencilState* dss, uint8 sref);
void OMSetBlendState(ID3D10BlendState* bs, float bf); void OMSetBlendState(ID3D10BlendState* bs, float bf);
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds); void OMSetRenderTargets(GSTexture* rt, GSTexture* ds);

View File

@ -268,9 +268,9 @@ bool GSDevice11::Reset(int w, int h, int mode)
return true; return true;
} }
void GSDevice11::Flip() void GSDevice11::Flip(bool limit)
{ {
m_swapchain->Present(m_vsync ? 1 : 0, 0); m_swapchain->Present(m_vsync && limit ? 1 : 0, 0);
} }
void GSDevice11::BeginScene() void GSDevice11::BeginScene()
@ -493,7 +493,7 @@ void GSDevice11::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt,
// rs // rs
RSSet(ds.x, ds.y); RSSet(ds);
// //
@ -702,9 +702,9 @@ void GSDevice11::PSSetSamplerState(ID3D11SamplerState* ss0, ID3D11SamplerState*
} }
} }
void GSDevice11::RSSet(int width, int height, const GSVector4i* scissor) void GSDevice11::RSSet(const GSVector2i& size, const GSVector4i* scissor)
{ {
if(m_viewport.x != width || m_viewport.y != height) if(m_viewport != size)
{ {
D3D11_VIEWPORT vp; D3D11_VIEWPORT vp;
@ -712,17 +712,17 @@ void GSDevice11::RSSet(int width, int height, const GSVector4i* scissor)
vp.TopLeftX = 0; vp.TopLeftX = 0;
vp.TopLeftY = 0; vp.TopLeftY = 0;
vp.Width = width; vp.Width = size.x;
vp.Height = height; vp.Height = size.y;
vp.MinDepth = 0.0f; vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f; vp.MaxDepth = 1.0f;
m_ctx->RSSetViewports(1, &vp); m_ctx->RSSetViewports(1, &vp);
m_viewport = GSVector2i(width, height); m_viewport = size;
} }
GSVector4i r = scissor ? *scissor : GSVector4i(0, 0, width, height); GSVector4i r = scissor ? *scissor : GSVector4i(size).zwxy();
if(!m_scissor.eq(r)) if(!m_scissor.eq(r))
{ {

View File

@ -100,7 +100,7 @@ public:
bool Create(GSWnd* wnd, bool vsync); bool Create(GSWnd* wnd, bool vsync);
bool Reset(int w, int h, int mode); bool Reset(int w, int h, int mode);
void Flip(); void Flip(bool limit);
void BeginScene(); void BeginScene();
void DrawPrimitive(); void DrawPrimitive();
@ -133,7 +133,7 @@ public:
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
void PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb); void PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb);
void PSSetSamplerState(ID3D11SamplerState* ss0, ID3D11SamplerState* ss1); void PSSetSamplerState(ID3D11SamplerState* ss0, ID3D11SamplerState* ss1);
void RSSet(int width, int height, const GSVector4i* scissor = NULL); void RSSet(const GSVector2i& size, const GSVector4i* scissor = NULL);
void OMSetDepthStencilState(ID3D11DepthStencilState* dss, uint8 sref); void OMSetDepthStencilState(ID3D11DepthStencilState* dss, uint8 sref);
void OMSetBlendState(ID3D11BlendState* bs, float bf); void OMSetBlendState(ID3D11BlendState* bs, float bf);
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds); void OMSetRenderTargets(GSTexture* rt, GSTexture* ds);

View File

@ -136,7 +136,7 @@ bool GSDevice7::Reset(int w, int h, int mode)
return true; return true;
} }
void GSDevice7::Present(const GSVector4i& r, int shader) void GSDevice7::Present(const GSVector4i& r, int shader, bool limit)
{ {
HRESULT hr; HRESULT hr;
@ -145,7 +145,7 @@ void GSDevice7::Present(const GSVector4i& r, int shader)
int w = std::max(cr.width(), 1); int w = std::max(cr.width(), 1);
int h = std::max(cr.height(), 1); int h = std::max(cr.height(), 1);
if(!m_backbuffer || m_backbuffer->GetWidth() != w || m_backbuffer->GetHeight() != h) if(!m_backbuffer || m_backbuffer->m_size.x != w || m_backbuffer->m_size.y != h)
{ {
if(!Reset(w, h, DontCare)) if(!Reset(w, h, DontCare))
{ {
@ -177,7 +177,7 @@ void GSDevice7::Present(const GSVector4i& r, int shader)
MapWindowPoints((HWND)m_wnd->GetHandle(), HWND_DESKTOP, (POINT*)&r2, 2); MapWindowPoints((HWND)m_wnd->GetHandle(), HWND_DESKTOP, (POINT*)&r2, 2);
if(m_vsync) if(m_vsync && limit)
{ {
hr = m_dd->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL); hr = m_dd->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
} }

View File

@ -43,5 +43,5 @@ public:
bool Create(GSWnd* wnd, bool vsync); bool Create(GSWnd* wnd, bool vsync);
bool Reset(int w, int h, int mode); bool Reset(int w, int h, int mode);
bool IsLost(bool update) {return m_lost;} bool IsLost(bool update) {return m_lost;}
void Present(const GSVector4i& r, int shader); void Present(const GSVector4i& r, int shader, bool limit);
}; };

View File

@ -348,7 +348,7 @@ bool GSDevice9::IsLost(bool update)
return m_lost; return m_lost;
} }
void GSDevice9::Flip() void GSDevice9::Flip(bool limit)
{ {
m_dev->EndScene(); m_dev->EndScene();
@ -427,7 +427,7 @@ void GSDevice9::ClearRenderTarget(GSTexture* rt, uint32 c)
void GSDevice9::ClearDepth(GSTexture* t, float c) void GSDevice9::ClearDepth(GSTexture* t, float c)
{ {
GSTexture* rt = CreateRenderTarget(t->GetWidth(), t->GetHeight()); GSTexture* rt = CreateRenderTarget(t->m_size.x, t->m_size.y);
CComPtr<IDirect3DSurface9> rtsurface; CComPtr<IDirect3DSurface9> rtsurface;
CComPtr<IDirect3DSurface9> dssurface; CComPtr<IDirect3DSurface9> dssurface;
@ -448,7 +448,7 @@ void GSDevice9::ClearDepth(GSTexture* t, float c)
void GSDevice9::ClearStencil(GSTexture* t, uint8 c) void GSDevice9::ClearStencil(GSTexture* t, uint8 c)
{ {
GSTexture* rt = CreateRenderTarget(t->GetWidth(), t->GetHeight()); GSTexture* rt = CreateRenderTarget(t->m_size.x, t->m_size.y);
CComPtr<IDirect3DSurface9> rtsurface; CComPtr<IDirect3DSurface9> rtsurface;
CComPtr<IDirect3DSurface9> dssurface; CComPtr<IDirect3DSurface9> dssurface;
@ -637,7 +637,7 @@ void GSDevice9::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, c
// rs // rs
RSSet(ds.x, ds.y); RSSet(ds);
// //
@ -865,9 +865,9 @@ void GSDevice9::PSSetSamplerState(Direct3DSamplerState9* ss)
} }
} }
void GSDevice9::RSSet(int width, int height, const GSVector4i* scissor) void GSDevice9::RSSet(const GSVector2i& size, const GSVector4i* scissor)
{ {
GSVector4i r = scissor ? *scissor : GSVector4i(0, 0, width, height); GSVector4i r = scissor ? *scissor : GSVector4i(size).zwxy();
if(!m_scissor.eq(r)) if(!m_scissor.eq(r))
{ {

View File

@ -135,7 +135,7 @@ public:
bool Create(GSWnd* wnd, bool vsync); bool Create(GSWnd* wnd, bool vsync);
bool Reset(int w, int h, int mode); bool Reset(int w, int h, int mode);
bool IsLost(bool update); bool IsLost(bool update);
void Flip(); void Flip(bool limit);
void BeginScene(); void BeginScene();
void DrawPrimitive(); void DrawPrimitive();
@ -167,7 +167,7 @@ public:
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
void PSSetShader(IDirect3DPixelShader9* ps, const float* ps_cb, int ps_cb_len); void PSSetShader(IDirect3DPixelShader9* ps, const float* ps_cb, int ps_cb_len);
void PSSetSamplerState(Direct3DSamplerState9* ss); void PSSetSamplerState(Direct3DSamplerState9* ss);
void RSSet(int width, int height, const GSVector4i* scissor = NULL); void RSSet(const GSVector2i& size, const GSVector4i* scissor = NULL);
void OMSetDepthStencilState(Direct3DDepthStencilState9* dss); void OMSetDepthStencilState(Direct3DDepthStencilState9* dss);
void OMSetBlendState(Direct3DBlendState9* bs, uint32 bf); void OMSetBlendState(Direct3DBlendState9* bs, uint32 bf);
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds); void OMSetRenderTargets(GSTexture* rt, GSTexture* ds);

View File

@ -185,16 +185,16 @@ bool GSDeviceOGL::Reset(int w, int h, int mode)
return true; return true;
} }
void GSDeviceOGL::Present(const GSVector4i& r, int shader) void GSDeviceOGL::Present(const GSVector4i& r, int shader, bool limit)
{ {
glBindFramebuffer(GL_FRAMEBUFFER, 0); CheckError(); glBindFramebuffer(GL_FRAMEBUFFER, 0); CheckError();
// TODO: m_current => backbuffer // TODO: m_current => backbuffer
Flip(); Flip(limit);
} }
void GSDeviceOGL::Flip() void GSDeviceOGL::Flip(bool limit)
{ {
#ifdef _WINDOWS #ifdef _WINDOWS
@ -438,16 +438,16 @@ void GSDeviceOGL::PSSetSamplerState(SamplerStateOGL* ss)
} }
} }
void GSDeviceOGL::RSSet(int width, int height, const GSVector4i* scissor) void GSDeviceOGL::RSSet(const GSVector2i& size, const GSVector4i* scissor)
{ {
if(m_viewport.x != width || m_viewport.y != height) if(m_viewport != size)
{ {
glViewport(0, 0, width, height); CheckError(); glViewport(0, 0, size.x, size.y); CheckError();
m_viewport = GSVector2i(width, height); m_viewport = size;
} }
GSVector4i r = scissor ? *scissor : GSVector4i(0, 0, width, height); GSVector4i r = scissor ? *scissor : GSVector4i(size).zwxy();
if(!m_scissor.eq(r)) if(!m_scissor.eq(r))
{ {

View File

@ -111,8 +111,8 @@ public:
bool Create(GSWnd* wnd, bool vsync); bool Create(GSWnd* wnd, bool vsync);
bool Reset(int w, int h, int mode); bool Reset(int w, int h, int mode);
void Present(const GSVector4i& r, int shader); void Present(const GSVector4i& r, int shader, bool limit);
void Flip(); void Flip(bool limit);
void BeginScene(); void BeginScene();
void DrawPrimitive(); void DrawPrimitive();
@ -139,7 +139,7 @@ public:
void IASetPrimitiveTopology(int topology); void IASetPrimitiveTopology(int topology);
void PSSetSamplerState(SamplerStateOGL* ss); void PSSetSamplerState(SamplerStateOGL* ss);
void RSSet(int width, int height, const GSVector4i* scissor); void RSSet(const GSVector2i& size, const GSVector4i* scissor);
void OMSetDepthStencilState(DepthStencilStateOGL* dss); void OMSetDepthStencilState(DepthStencilStateOGL* dss);
void OMSetBlendState(BlendStateOGL* bs, float bf); void OMSetBlendState(BlendStateOGL* bs, float bf);
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds); void OMSetRenderTargets(GSTexture* rt, GSTexture* ds);

View File

@ -66,14 +66,14 @@ int GSLocalMemory::rowOffset16SZ[2048];
int GSLocalMemory::rowOffset8[2][2048]; int GSLocalMemory::rowOffset8[2][2048];
int GSLocalMemory::rowOffset4[2][2048]; int GSLocalMemory::rowOffset4[2][2048];
int GSLocalMemory::blockOffset32[256]; short GSLocalMemory::blockOffset32[256];
int GSLocalMemory::blockOffset32Z[256]; short GSLocalMemory::blockOffset32Z[256];
int GSLocalMemory::blockOffset16[256]; short GSLocalMemory::blockOffset16[256];
int GSLocalMemory::blockOffset16S[256]; short GSLocalMemory::blockOffset16S[256];
int GSLocalMemory::blockOffset16Z[256]; short GSLocalMemory::blockOffset16Z[256];
int GSLocalMemory::blockOffset16SZ[256]; short GSLocalMemory::blockOffset16SZ[256];
int GSLocalMemory::blockOffset8[256]; short GSLocalMemory::blockOffset8[256];
int GSLocalMemory::blockOffset4[256]; short GSLocalMemory::blockOffset4[256];
// //
@ -159,42 +159,42 @@ GSLocalMemory::GSLocalMemory()
for(int x = 0; x < countof(blockOffset32); x++) for(int x = 0; x < countof(blockOffset32); x++)
{ {
blockOffset32[x] = (int)BlockNumber32(x << 3, 0, 0, 32) - (int)BlockNumber32(0, 0, 0, 32); blockOffset32[x] = (short)((int)BlockNumber32(x << 3, 0, 0, 32) - (int)BlockNumber32(0, 0, 0, 32));
} }
for(int x = 0; x < countof(blockOffset32Z); x++) for(int x = 0; x < countof(blockOffset32Z); x++)
{ {
blockOffset32Z[x] = (int)BlockNumber32Z(x << 3, 0, 0, 32) - (int)BlockNumber32Z(0, 0, 0, 32); blockOffset32Z[x] = (short)((int)BlockNumber32Z(x << 3, 0, 0, 32) - (int)BlockNumber32Z(0, 0, 0, 32));
} }
for(int x = 0; x < countof(blockOffset16); x++) for(int x = 0; x < countof(blockOffset16); x++)
{ {
blockOffset16[x] = (int)BlockNumber16(x << 3, 0, 0, 32) - (int)BlockNumber16(0, 0, 0, 32); blockOffset16[x] = (short)((int)BlockNumber16(x << 3, 0, 0, 32) - (int)BlockNumber16(0, 0, 0, 32));
} }
for(int x = 0; x < countof(blockOffset16S); x++) for(int x = 0; x < countof(blockOffset16S); x++)
{ {
blockOffset16S[x] = (int)BlockNumber16S(x << 3, 0, 0, 32) - (int)BlockNumber16S(0, 0, 0, 32); blockOffset16S[x] = (short)((int)BlockNumber16S(x << 3, 0, 0, 32) - (int)BlockNumber16S(0, 0, 0, 32));
} }
for(int x = 0; x < countof(blockOffset16Z); x++) for(int x = 0; x < countof(blockOffset16Z); x++)
{ {
blockOffset16Z[x] = (int)BlockNumber16Z(x << 3, 0, 0, 32) - (int)BlockNumber16Z(0, 0, 0, 32); blockOffset16Z[x] = (short)((int)BlockNumber16Z(x << 3, 0, 0, 32) - (int)BlockNumber16Z(0, 0, 0, 32));
} }
for(int x = 0; x < countof(blockOffset16SZ); x++) for(int x = 0; x < countof(blockOffset16SZ); x++)
{ {
blockOffset16SZ[x] = (int)BlockNumber16SZ(x << 3, 0, 0, 32) - (int)BlockNumber16SZ(0, 0, 0, 32); blockOffset16SZ[x] = (short)((int)BlockNumber16SZ(x << 3, 0, 0, 32) - (int)BlockNumber16SZ(0, 0, 0, 32));
} }
for(int x = 0; x < countof(blockOffset8); x++) for(int x = 0; x < countof(blockOffset8); x++)
{ {
blockOffset8[x] = (int)BlockNumber8(x << 3, 0, 0, 32) - (int)BlockNumber8(0, 0, 0, 32); blockOffset8[x] = (short)((int)BlockNumber8(x << 3, 0, 0, 32) - (int)BlockNumber8(0, 0, 0, 32));
} }
for(int x = 0; x < countof(blockOffset4); x++) for(int x = 0; x < countof(blockOffset4); x++)
{ {
blockOffset4[x] = (int)BlockNumber4(x << 3, 0, 0, 32) - (int)BlockNumber4(0, 0, 0, 32); blockOffset4[x] = (short)((int)BlockNumber4(x << 3, 0, 0, 32) - (int)BlockNumber4(0, 0, 0, 32));
} }
for(int i = 0; i < countof(m_psm); i++) for(int i = 0; i < countof(m_psm); i++)
@ -417,9 +417,6 @@ GSLocalMemory::GSLocalMemory()
m_psm[PSM_PSMZ16].rtxbP = &GSLocalMemory::ReadTextureBlock16Z; m_psm[PSM_PSMZ16].rtxbP = &GSLocalMemory::ReadTextureBlock16Z;
m_psm[PSM_PSMZ16S].rtxbP = &GSLocalMemory::ReadTextureBlock16SZ; m_psm[PSM_PSMZ16S].rtxbP = &GSLocalMemory::ReadTextureBlock16SZ;
m_psm[PSM_PSMT8].pal = m_psm[PSM_PSMT8H].pal = 256;
m_psm[PSM_PSMT4].pal = m_psm[PSM_PSMT4HL].pal = m_psm[PSM_PSMT4HH].pal = 16;
m_psm[PSM_PSMCT16].bpp = m_psm[PSM_PSMCT16S].bpp = 16; m_psm[PSM_PSMCT16].bpp = m_psm[PSM_PSMCT16S].bpp = 16;
m_psm[PSM_PSMT8].bpp = 8; m_psm[PSM_PSMT8].bpp = 8;
m_psm[PSM_PSMT4].bpp = 4; m_psm[PSM_PSMT4].bpp = 4;
@ -432,6 +429,15 @@ GSLocalMemory::GSLocalMemory()
m_psm[PSM_PSMZ24].trbpp = 24; m_psm[PSM_PSMZ24].trbpp = 24;
m_psm[PSM_PSMZ16].trbpp = m_psm[PSM_PSMZ16S].trbpp = 16; m_psm[PSM_PSMZ16].trbpp = m_psm[PSM_PSMZ16S].trbpp = 16;
m_psm[PSM_PSMT8].pal = m_psm[PSM_PSMT8H].pal = 256;
m_psm[PSM_PSMT4].pal = m_psm[PSM_PSMT4HL].pal = m_psm[PSM_PSMT4HH].pal = 16;
for(int i = 0; i < countof(m_psm); i++) m_psm[i].fmt = 3;
m_psm[PSM_PSMCT32].fmt = m_psm[PSM_PSMZ32].fmt = 0;
m_psm[PSM_PSMCT24].fmt = m_psm[PSM_PSMZ24].fmt = 1;
m_psm[PSM_PSMCT16].fmt = m_psm[PSM_PSMZ16].fmt = 2;
m_psm[PSM_PSMCT16S].fmt = m_psm[PSM_PSMZ16S].fmt = 2;
m_psm[PSM_PSMCT16].bs = m_psm[PSM_PSMCT16S].bs = GSVector2i(16, 8); m_psm[PSM_PSMCT16].bs = m_psm[PSM_PSMCT16S].bs = GSVector2i(16, 8);
m_psm[PSM_PSMT8].bs = GSVector2i(16, 16); m_psm[PSM_PSMT8].bs = GSVector2i(16, 16);
m_psm[PSM_PSMT4].bs = GSVector2i(32, 16); m_psm[PSM_PSMT4].bs = GSVector2i(32, 16);
@ -489,7 +495,7 @@ GSLocalMemory::BlockOffset* GSLocalMemory::GetBlockOffset(uint32 bp, uint32 bw,
for(int i = 0; i < 256; i++) for(int i = 0; i < 256; i++)
{ {
o->row[i] = (int)bn(0, i << 3, bp, bw); o->row[i] = (short)bn(0, i << 3, bp, bw);
} }
o->col = m_psm[psm].blockOffset; o->col = m_psm[psm].blockOffset;

View File

@ -62,11 +62,10 @@ public:
readImage ri; readImage ri;
readTexture rtx, rtxNP, rtxP; readTexture rtx, rtxNP, rtxP;
readTextureBlock rtxb, rtxbP; readTextureBlock rtxb, rtxbP;
short bpp, trbpp; uint16 bpp, trbpp, pal, fmt;
int pal;
GSVector2i bs, pgs; GSVector2i bs, pgs;
int* rowOffset[8]; int* rowOffset[8];
int* blockOffset; short* blockOffset;
}; };
uint8 dummy[128]; uint8 dummy[128];
@ -83,8 +82,8 @@ public:
struct BlockOffset struct BlockOffset
{ {
int row[256]; // yn (n = 0 8 16 ...) short row[256]; // yn (n = 0 8 16 ...)
int* col; // blockOffset* short* col; // blockOffset*
uint32 hash; uint32 hash;
}; };
@ -123,14 +122,14 @@ protected:
static int rowOffset8[2][2048]; static int rowOffset8[2][2048];
static int rowOffset4[2][2048]; static int rowOffset4[2][2048];
static int blockOffset32[256]; static short blockOffset32[256];
static int blockOffset32Z[256]; static short blockOffset32Z[256];
static int blockOffset16[256]; static short blockOffset16[256];
static int blockOffset16S[256]; static short blockOffset16S[256];
static int blockOffset16Z[256]; static short blockOffset16Z[256];
static int blockOffset16SZ[256]; static short blockOffset16SZ[256];
static int blockOffset8[256]; static short blockOffset8[256];
static int blockOffset4[256]; static short blockOffset4[256];
__forceinline static uint32 Expand24To32(uint32 c, const GIFRegTEXA& TEXA) __forceinline static uint32 Expand24To32(uint32 c, const GIFRegTEXA& TEXA)
{ {
@ -701,7 +700,7 @@ public:
uint32 rb = s[x] & 0x00f800f8; uint32 rb = s[x] & 0x00f800f8;
uint32 ga = s[x] & 0x8000f800; uint32 ga = s[x] & 0x8000f800;
d[o[x]] = (ga >> 16) | (rb >> 9) | (ga >> 6) | (rb >> 3); d[o[x]] = (uint16)((ga >> 16) | (rb >> 9) | (ga >> 6) | (rb >> 3));
} }
} }
} }

View File

@ -325,7 +325,7 @@ void GSRenderer::VSync(int field)
// present // present
m_dev->Present(m_wnd.GetClientRect().fit(m_aspectratio), m_shader); m_dev->Present(m_wnd.GetClientRect().fit(m_aspectratio), m_shader, m_framelimit);
// snapshot // snapshot
@ -435,12 +435,6 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
} }
} }
void GSRenderer::SetFrameLimit(bool limit)
{
m_dev->SetVSync(m_vsync && limit);
}
void GSRenderer::GetTextureMinMax(GSVector4i& r, bool linear) void GSRenderer::GetTextureMinMax(GSVector4i& r, bool linear)
{ {
const GSDrawingContext* context = m_context; const GSDrawingContext* context = m_context;
@ -579,28 +573,25 @@ void GSRenderer::GetAlphaMinMax()
if(PRIM->TME && context->TEX0.TCC) if(PRIM->TME && context->TEX0.TCC)
{ {
uint32 bpp = GSLocalMemory::m_psm[context->TEX0.PSM].trbpp; switch(GSLocalMemory::m_psm[context->TEX0.PSM].fmt)
uint32 cbpp = GSLocalMemory::m_psm[context->TEX0.CPSM].trbpp;
uint32 pal = GSLocalMemory::m_psm[context->TEX0.PSM].pal;
if(bpp == 32)
{ {
case 0:
a.y = 0; a.y = 0;
a.w = 0xff; a.w = 0xff;
} break;
else if(bpp == 24) case 1:
{
a.y = env.TEXA.AEM ? 0 : env.TEXA.TA0; a.y = env.TEXA.AEM ? 0 : env.TEXA.TA0;
a.w = env.TEXA.TA0; a.w = env.TEXA.TA0;
} break;
else if(bpp == 16) case 2:
{
a.y = env.TEXA.AEM ? 0 : min(env.TEXA.TA0, env.TEXA.TA1); a.y = env.TEXA.AEM ? 0 : min(env.TEXA.TA0, env.TEXA.TA1);
a.w = max(env.TEXA.TA0, env.TEXA.TA1); a.w = max(env.TEXA.TA0, env.TEXA.TA1);
} break;
else case 3:
{
m_mem.m_clut.GetAlphaMinMax32(a.y, a.w); m_mem.m_clut.GetAlphaMinMax32(a.y, a.w);
break;
default:
__assume(0);
} }
switch(context->TEX0.TFX) switch(context->TEX0.TFX)
@ -714,17 +705,25 @@ bool GSRenderer::TryAlphaTest(uint32& fm, uint32& zm)
bool GSRenderer::IsLinear() bool GSRenderer::IsLinear()
{ {
float qmin = m_vt.m_min.t.z; const GIFRegTEX1& TEX1 = m_context->TEX1;
float qmax = m_vt.m_max.t.z;
if(PRIM->FST) bool mmin = TEX1.IsMinLinear();
bool mmag = TEX1.IsMagLinear();
if(mmag == mmin) return mmag;
float LODmin = (float)TEX1.K;
float LODmax = (float)TEX1.K;
if(!TEX1.LCM && !PRIM->FST) // if FST => assume Q = 1.0f (should not, but Q is very often bogus, 0 or DEN)
{ {
// assume Q = 1.0f => LOD > 0 (should not, but Q is very often bogus, 0 or DEN) float f = (float)(1 << TEX1.L) / log(2.0f);
qmin = qmax = 1.0f; LODmin += log(1.0f / abs(m_vt.m_min.t.z)) * f;
LODmax += log(1.0f / abs(m_vt.m_max.t.z)) * f;
} }
return m_context->TEX1.IsLinear(qmin, qmax); return LODmax <= 0 ? mmag : LODmin > 0 ? mmin : mmag || mmin;
} }
bool GSRenderer::IsOpaque() bool GSRenderer::IsOpaque()

View File

@ -77,7 +77,6 @@ public:
virtual void VSync(int field); virtual void VSync(int field);
virtual bool MakeSnapshot(const string& path); virtual bool MakeSnapshot(const string& path);
virtual void KeyEvent(GSKeyEventData* e); virtual void KeyEvent(GSKeyEventData* e);
virtual void SetFrameLimit(bool limit);
virtual bool CanUpscale() virtual bool CanUpscale()
{ {
@ -125,7 +124,7 @@ protected:
PRIM->TME ? (int)m_context->TEX0.PSM : 0xff); PRIM->TME ? (int)m_context->TEX0.PSM : 0xff);
*/ */
if(GSUtil::EncodePSM(m_context->FRAME.PSM) != 3 && GSUtil::EncodePSM(m_context->ZBUF.PSM) != 3) if(GSLocalMemory::m_psm[m_context->FRAME.PSM].fmt < 3 && GSLocalMemory::m_psm[m_context->ZBUF.PSM].fmt < 3)
{ {
// FIXME: berserk fpsm = 27 (8H) // FIXME: berserk fpsm = 27 (8H)

View File

@ -82,9 +82,21 @@ public:
GSTextureFX::OMDepthStencilSelector om_dssel; GSTextureFX::OMDepthStencilSelector om_dssel;
if(context->TEST.ZTE)
{
om_dssel.ztst = context->TEST.ZTST;
om_dssel.zwe = !context->ZBUF.ZMSK;
}
else
{
om_dssel.ztst = ZTST_ALWAYS;
om_dssel.zwe = 0;
}
/*
om_dssel.zte = context->TEST.ZTE; om_dssel.zte = context->TEST.ZTE;
om_dssel.ztst = context->TEST.ZTST; om_dssel.ztst = context->TEST.ZTST;
om_dssel.zwe = !context->ZBUF.ZMSK; om_dssel.zwe = !context->ZBUF.ZMSK;
*/
om_dssel.date = context->FRAME.PSM != PSM_PSMCT24 ? context->TEST.DATE : 0; om_dssel.date = context->FRAME.PSM != PSM_PSMCT24 ? context->TEST.DATE : 0;
om_dssel.fba = m_fba ? context->FBA.FBA : 0; om_dssel.fba = m_fba ? context->FBA.FBA : 0;
@ -115,22 +127,17 @@ public:
} }
} }
om_bsel.wr = (context->FRAME.FBMSK & 0x000000ff) != 0x000000ff; om_bsel.wrgba = ~GSVector4i::load((int)context->FRAME.FBMSK).eq8(GSVector4i::xffffffff()).mask();
om_bsel.wg = (context->FRAME.FBMSK & 0x0000ff00) != 0x0000ff00;
om_bsel.wb = (context->FRAME.FBMSK & 0x00ff0000) != 0x00ff0000;
om_bsel.wa = (context->FRAME.FBMSK & 0xff000000) != 0xff000000;
// vs // vs
GSTextureFX::VSSelector vs_sel; GSTextureFX::VSSelector vs_sel;
vs_sel.bppz = 0;
vs_sel.tme = PRIM->TME; vs_sel.tme = PRIM->TME;
vs_sel.fst = PRIM->FST; vs_sel.fst = PRIM->FST;
vs_sel.logz = m_logz ? 1 : 0; vs_sel.logz = m_logz ? 1 : 0;
vs_sel.prim = primclass;
if(om_dssel.zte && om_dssel.ztst > 0 && om_dssel.zwe) if(om_dssel.ztst >= ZTST_ALWAYS && om_dssel.zwe)
{ {
if(context->ZBUF.PSM == PSM_PSMZ24) if(context->ZBUF.PSM == PSM_PSMZ24)
{ {
@ -139,7 +146,7 @@ public:
ASSERT(m_vt.m_min.p.z > 0xffffff); ASSERT(m_vt.m_min.p.z > 0xffffff);
vs_sel.bppz = 1; vs_sel.bppz = 1;
om_dssel.ztst = 1; om_dssel.ztst = ZTST_ALWAYS;
} }
} }
else if(context->ZBUF.PSM == PSM_PSMZ16 || context->ZBUF.PSM == PSM_PSMZ16S) else if(context->ZBUF.PSM == PSM_PSMZ16 || context->ZBUF.PSM == PSM_PSMZ16S)
@ -149,36 +156,23 @@ public:
ASSERT(m_vt.m_min.p.z > 0xffff); // sfex capcom logo ASSERT(m_vt.m_min.p.z > 0xffff); // sfex capcom logo
vs_sel.bppz = 2; vs_sel.bppz = 2;
om_dssel.ztst = 1; om_dssel.ztst = ZTST_ALWAYS;
} }
} }
} }
GSTextureFX::VSConstantBuffer vs_cb; GSTextureFX::VSConstantBuffer vs_cb;
float sx = 2.0f * rt->m_scale.x / (rt->GetWidth() * 16); float sx = 2.0f * rt->m_scale.x / (rt->m_size.x << 4);
float sy = 2.0f * rt->m_scale.y / (rt->GetHeight() * 16); float sy = 2.0f * rt->m_scale.y / (rt->m_size.y << 4);
float ox = (float)(int)context->XYOFFSET.OFX; float ox = (float)(int)context->XYOFFSET.OFX;
float oy = (float)(int)context->XYOFFSET.OFY; float oy = (float)(int)context->XYOFFSET.OFY;
float ox2 = 2.0f * m_pixelcenter.x / rt->GetWidth(); float ox2 = 2.0f * m_pixelcenter.x / rt->m_size.x;
float oy2 = 2.0f * m_pixelcenter.y / rt->GetHeight(); float oy2 = 2.0f * m_pixelcenter.y / rt->m_size.y;
vs_cb.VertexScale = GSVector4(sx, -sy, 1.0f / UINT_MAX, 0.0f); vs_cb.VertexScale = GSVector4(sx, -sy, 1.0f / UINT_MAX, 0.0f);
vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f); vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f);
if(PRIM->TME)
{
if(PRIM->FST)
{
vs_cb.TextureScale.x = 1.0f / (16 << context->TEX0.TW);
vs_cb.TextureScale.y = 1.0f / (16 << context->TEX0.TH);
}
else
{
vs_cb.TextureScale = GSVector2(1.0f, 1.0f);
}
}
// gs // gs
GSTextureFX::GSSelector gs_sel; GSTextureFX::GSSelector gs_sel;
@ -224,7 +218,6 @@ public:
if(tex) if(tex)
{ {
ps_sel.fst = PRIM->FST;
ps_sel.wms = context->CLAMP.WMS; ps_sel.wms = context->CLAMP.WMS;
ps_sel.wmt = context->CLAMP.WMT; ps_sel.wmt = context->CLAMP.WMT;
ps_sel.fmt = tex->m_fmt; ps_sel.fmt = tex->m_fmt;
@ -234,46 +227,34 @@ public:
ps_sel.ltf = m_filter == 2 ? IsLinear() : m_filter; ps_sel.ltf = m_filter == 2 ? IsLinear() : m_filter;
ps_sel.rt = tex->m_target; ps_sel.rt = tex->m_target;
int w = tex->m_texture->GetWidth(); int w = tex->m_texture->m_size.x;
int h = tex->m_texture->GetHeight(); int h = tex->m_texture->m_size.y;
int tw = (int)(1 << context->TEX0.TW); int tw = (int)(1 << context->TEX0.TW);
int th = (int)(1 << context->TEX0.TH); int th = (int)(1 << context->TEX0.TH);
ps_cb.WH = GSVector4(tw, th, w, h); GSVector4 WH(tw, th, w, h);
ps_cb.HalfTexel = GSVector4(-0.5f, 0.5f).xxyy() / GSVector4(w, h).xyxy();
ps_cb.MinF_TA.z = (float)(int)env.TEXA.TA0 / 255; if(PRIM->FST)
ps_cb.MinF_TA.w = (float)(int)env.TEXA.TA1 / 255; {
vs_cb.TextureScale = GSVector4(1.0f / 16) / WH.xyxy();
ps_sel.fst = 1;
}
ps_cb.WH = WH;
ps_cb.HalfTexel = GSVector4(-0.5f, 0.5f).xxyy() / WH.zwzw();
ps_cb.MskFix = GSVector4i(context->CLAMP.MINU, context->CLAMP.MINV, context->CLAMP.MAXU, context->CLAMP.MAXV);
GSVector4 clamp(ps_cb.MskFix);
GSVector4 ta(env.TEXA & GSVector4i::x000000ff());
ps_cb.MinMax = clamp / WH.xyxy();
ps_cb.MinF_TA = (clamp + 0.5f).xyxy(ta) / WH.xyxy(GSVector4(255, 255));
ps_ssel.tau = (context->CLAMP.WMS + 3) >> 1; ps_ssel.tau = (context->CLAMP.WMS + 3) >> 1;
ps_ssel.tav = (context->CLAMP.WMT + 3) >> 1; ps_ssel.tav = (context->CLAMP.WMT + 3) >> 1;
ps_ssel.ltf = ps_sel.ltf; ps_ssel.ltf = ps_sel.ltf;
switch(ps_sel.wms)
{
case CLAMP_REGION_CLAMP:
ps_cb.MinMax.x = (float)(int)context->CLAMP.MINU / tw;
ps_cb.MinMax.z = (float)(int)context->CLAMP.MAXU / tw;
ps_cb.MinF_TA.x = ((float)(int)context->CLAMP.MINU + 0.5f) / tw;
break;
case CLAMP_REGION_REPEAT:
ps_cb.MskFix.x = context->CLAMP.MINU;
ps_cb.MskFix.z = context->CLAMP.MAXU;
break;
}
switch(ps_sel.wmt)
{
case CLAMP_REGION_CLAMP:
ps_cb.MinMax.y = (float)(int)context->CLAMP.MINV / th;
ps_cb.MinMax.w = (float)(int)context->CLAMP.MAXV / th;
ps_cb.MinF_TA.y = ((float)(int)context->CLAMP.MINV + 0.5f) / th;
break;
case CLAMP_REGION_REPEAT:
ps_cb.MskFix.y = context->CLAMP.MINV;
ps_cb.MskFix.w = context->CLAMP.MAXV;
break;
}
} }
else else
{ {
@ -282,10 +263,7 @@ public:
// rs // rs
int w = rt->GetWidth(); GSVector4i scissor = GSVector4i(GSVector4(rt->m_scale).xyxy() * context->scissor.in).rintersect(GSVector4i(rt->GetSize()).zwxy());
int h = rt->GetHeight();
GSVector4i scissor = GSVector4i(GSVector4(rt->m_scale).xyxy() * context->scissor.in).rintersect(GSVector4i(0, 0, w, h));
// //
@ -296,7 +274,7 @@ public:
m_tfx->SetupVS(vs_sel, &vs_cb); m_tfx->SetupVS(vs_sel, &vs_cb);
m_tfx->SetupGS(gs_sel); m_tfx->SetupGS(gs_sel);
m_tfx->SetupPS(ps_sel, &ps_cb, ps_ssel, tex ? tex->m_texture : NULL, tex ? tex->m_palette : NULL); m_tfx->SetupPS(ps_sel, &ps_cb, ps_ssel, tex ? tex->m_texture : NULL, tex ? tex->m_palette : NULL);
m_tfx->SetupRS(w, h, scissor); m_tfx->SetupRS(rt->m_size, scissor);
// draw // draw

View File

@ -86,9 +86,11 @@ void GSRendererDX10::VertexKick(bool skip)
{ {
GSVector4i scissor = m_context->scissor.dx10; GSVector4i scissor = m_context->scissor.dx10;
GSVector4i pmin, pmax;
#if _M_SSE >= 0x401 #if _M_SSE >= 0x401
GSVector4i pmin, pmax, v0, v1, v2; GSVector4i v0, v1, v2;
switch(prim) switch(prim)
{ {
@ -116,52 +118,53 @@ void GSRendererDX10::VertexKick(bool skip)
break; break;
} }
GSVector4i test = (pmax < scissor) | (pmin > scissor.zwxy());
if(test.mask() & 0xff)
{
return;
}
#else #else
switch(prim) switch(prim)
{ {
case GS_POINTLIST: case GS_POINTLIST:
if(v[0].p.x < scissor.x pmin.x = v[0].p.x;
|| v[0].p.x > scissor.z pmin.y = v[0].p.y;
|| v[0].p.y < scissor.y pmax.x = v[0].p.x;
|| v[0].p.y > scissor.w) pmax.y = v[0].p.y;
{
return;
}
break; break;
case GS_LINELIST: case GS_LINELIST:
case GS_LINESTRIP: case GS_LINESTRIP:
case GS_SPRITE: case GS_SPRITE:
if(v[0].p.x < scissor.x && v[1].p.x < scissor.x pmin.x = std::min<uint16>(v[0].p.x, v[1].p.x);
|| v[0].p.x > scissor.z && v[1].p.x > scissor.z pmin.y = std::min<uint16>(v[0].p.y, v[1].p.y);
|| v[0].p.y < scissor.y && v[1].p.y < scissor.y pmax.x = std::max<uint16>(v[0].p.x, v[1].p.x);
|| v[0].p.y > scissor.w && v[1].p.y > scissor.w) pmax.y = std::max<uint16>(v[0].p.y, v[1].p.y);
{
return;
}
break; break;
case GS_TRIANGLELIST: case GS_TRIANGLELIST:
case GS_TRIANGLESTRIP: case GS_TRIANGLESTRIP:
case GS_TRIANGLEFAN: case GS_TRIANGLEFAN:
if(v[0].p.x < scissor.x && v[1].p.x < scissor.x && v[2].p.x < scissor.x pmin.x = std::min<uint16>(std::min<uint16>(v[0].p.x, v[1].p.x), v[2].p.x);
|| v[0].p.x > scissor.z && v[1].p.x > scissor.z && v[2].p.x > scissor.z pmin.y = std::min<uint16>(std::min<uint16>(v[0].p.y, v[1].p.y), v[2].p.y);
|| v[0].p.y < scissor.y && v[1].p.y < scissor.y && v[2].p.y < scissor.y pmax.x = std::max<uint16>(std::max<uint16>(v[0].p.x, v[1].p.x), v[2].p.x);
|| v[0].p.y > scissor.w && v[1].p.y > scissor.w && v[2].p.y > scissor.w) pmax.y = std::max<uint16>(std::max<uint16>(v[0].p.y, v[1].p.y), v[2].p.y);
{
return;
}
break; break;
} }
#endif #endif
GSVector4i test = (pmax < scissor) | (pmin > scissor.zwxy());
switch(prim)
{
case GS_TRIANGLELIST:
case GS_TRIANGLESTRIP:
case GS_TRIANGLEFAN:
case GS_SPRITE:
test |= pmin == pmax;
break;
}
if(test.mask() & 0xff)
{
return;
}
m_count += count; m_count += count;
} }
} }
@ -196,10 +199,9 @@ void GSRendererDX10::SetupDATE(GSTexture* rt, GSTexture* ds)
GSDevice10* dev = (GSDevice10*)m_dev; GSDevice10* dev = (GSDevice10*)m_dev;
int w = rt->GetWidth(); const GSVector2i& size = rt->m_size;
int h = rt->GetHeight();
if(GSTexture* t = dev->CreateRenderTarget(w, h)) if(GSTexture* t = dev->CreateRenderTarget(size.x, size.y))
{ {
// sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows
@ -215,7 +217,7 @@ void GSRendererDX10::SetupDATE(GSTexture* rt, GSTexture* ds)
// ia // ia
GSVector4 s = GSVector4(rt->m_scale.x / w, rt->m_scale.y / h); GSVector4 s = GSVector4(rt->m_scale.x / size.x, rt->m_scale.y / size.y);
GSVector4 o = GSVector4(-1.0f, 1.0f); GSVector4 o = GSVector4(-1.0f, 1.0f);
GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy());
@ -249,7 +251,7 @@ void GSRendererDX10::SetupDATE(GSTexture* rt, GSTexture* ds)
// rs // rs
dev->RSSet(w, h); dev->RSSet(size);
// set // set

View File

@ -86,9 +86,11 @@ void GSRendererDX11::VertexKick(bool skip)
{ {
GSVector4i scissor = m_context->scissor.dx10; GSVector4i scissor = m_context->scissor.dx10;
GSVector4i pmin, pmax;
#if _M_SSE >= 0x401 #if _M_SSE >= 0x401
GSVector4i pmin, pmax, v0, v1, v2; GSVector4i v0, v1, v2;
switch(prim) switch(prim)
{ {
@ -116,52 +118,53 @@ void GSRendererDX11::VertexKick(bool skip)
break; break;
} }
GSVector4i test = (pmax < scissor) | (pmin > scissor.zwxy());
if(test.mask() & 0xff)
{
return;
}
#else #else
switch(prim) switch(prim)
{ {
case GS_POINTLIST: case GS_POINTLIST:
if(v[0].p.x < scissor.x pmin.x = v[0].p.x;
|| v[0].p.x > scissor.z pmin.y = v[0].p.y;
|| v[0].p.y < scissor.y pmax.x = v[0].p.x;
|| v[0].p.y > scissor.w) pmax.y = v[0].p.y;
{
return;
}
break; break;
case GS_LINELIST: case GS_LINELIST:
case GS_LINESTRIP: case GS_LINESTRIP:
case GS_SPRITE: case GS_SPRITE:
if(v[0].p.x < scissor.x && v[1].p.x < scissor.x pmin.x = std::min<uint16>(v[0].p.x, v[1].p.x);
|| v[0].p.x > scissor.z && v[1].p.x > scissor.z pmin.y = std::min<uint16>(v[0].p.y, v[1].p.y);
|| v[0].p.y < scissor.y && v[1].p.y < scissor.y pmax.x = std::max<uint16>(v[0].p.x, v[1].p.x);
|| v[0].p.y > scissor.w && v[1].p.y > scissor.w) pmax.y = std::max<uint16>(v[0].p.y, v[1].p.y);
{
return;
}
break; break;
case GS_TRIANGLELIST: case GS_TRIANGLELIST:
case GS_TRIANGLESTRIP: case GS_TRIANGLESTRIP:
case GS_TRIANGLEFAN: case GS_TRIANGLEFAN:
if(v[0].p.x < scissor.x && v[1].p.x < scissor.x && v[2].p.x < scissor.x pmin.x = std::min<uint16>(std::min<uint16>(v[0].p.x, v[1].p.x), v[2].p.x);
|| v[0].p.x > scissor.z && v[1].p.x > scissor.z && v[2].p.x > scissor.z pmin.y = std::min<uint16>(std::min<uint16>(v[0].p.y, v[1].p.y), v[2].p.y);
|| v[0].p.y < scissor.y && v[1].p.y < scissor.y && v[2].p.y < scissor.y pmax.x = std::max<uint16>(std::max<uint16>(v[0].p.x, v[1].p.x), v[2].p.x);
|| v[0].p.y > scissor.w && v[1].p.y > scissor.w && v[2].p.y > scissor.w) pmax.y = std::max<uint16>(std::max<uint16>(v[0].p.y, v[1].p.y), v[2].p.y);
{
return;
}
break; break;
} }
#endif #endif
GSVector4i test = (pmax < scissor) | (pmin > scissor.zwxy());
switch(prim)
{
case GS_TRIANGLELIST:
case GS_TRIANGLESTRIP:
case GS_TRIANGLEFAN:
case GS_SPRITE:
test |= pmin == pmax;
break;
}
if(test.mask() & 0xff)
{
return;
}
m_count += count; m_count += count;
} }
} }
@ -196,10 +199,9 @@ void GSRendererDX11::SetupDATE(GSTexture* rt, GSTexture* ds)
GSDevice11* dev = (GSDevice11*)m_dev; GSDevice11* dev = (GSDevice11*)m_dev;
int w = rt->GetWidth(); const GSVector2i& size = rt->m_size;
int h = rt->GetHeight();
if(GSTexture* t = dev->CreateRenderTarget(w, h)) if(GSTexture* t = dev->CreateRenderTarget(size.x, size.y))
{ {
// sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows
@ -215,7 +217,7 @@ void GSRendererDX11::SetupDATE(GSTexture* rt, GSTexture* ds)
// ia // ia
GSVector4 s = GSVector4(rt->m_scale.x / w, rt->m_scale.y / h); GSVector4 s = GSVector4(rt->m_scale.x / size.x, rt->m_scale.y / size.y);
GSVector4 o = GSVector4(-1.0f, 1.0f); GSVector4 o = GSVector4(-1.0f, 1.0f);
GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy());
@ -249,7 +251,7 @@ void GSRendererDX11::SetupDATE(GSTexture* rt, GSTexture* ds)
// rs // rs
dev->RSSet(w, h); dev->RSSet(size);
// set // set

View File

@ -135,6 +135,16 @@ void GSRendererDX9::VertexKick(bool skip)
GSVector4 test = (pmax < scissor) | (pmin > scissor.zwxy()); GSVector4 test = (pmax < scissor) | (pmin > scissor.zwxy());
switch(prim)
{
case GS_TRIANGLELIST:
case GS_TRIANGLESTRIP:
case GS_TRIANGLEFAN:
case GS_SPRITE:
test |= pmin == pmax;
break;
}
if(test.mask() & 3) if(test.mask() & 3)
{ {
return; return;
@ -206,10 +216,9 @@ void GSRendererDX9::SetupDATE(GSTexture* rt, GSTexture* ds)
GSDevice9* dev = (GSDevice9*)m_dev; GSDevice9* dev = (GSDevice9*)m_dev;
int w = rt->GetWidth(); const GSVector2i& size = rt->m_size;
int h = rt->GetHeight();
if(GSTexture* t = dev->CreateRenderTarget(w, h)) if(GSTexture* t = dev->CreateRenderTarget(size.x, size.y))
{ {
// sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows // sfex3 (after the capcom logo), vf4 (first menu fading in), ffxii shadows, rumble roses shadows, persona4 shadows
@ -225,7 +234,7 @@ void GSRendererDX9::SetupDATE(GSTexture* rt, GSTexture* ds)
// ia // ia
GSVector4 s = GSVector4(rt->m_scale.x / w, rt->m_scale.y / h); GSVector4 s = GSVector4(rt->m_scale.x / size.x, rt->m_scale.y / size.y);
GSVector4 o = GSVector4(-1.0f, 1.0f); GSVector4 o = GSVector4(-1.0f, 1.0f);
GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy());
@ -255,7 +264,7 @@ void GSRendererDX9::SetupDATE(GSTexture* rt, GSTexture* ds)
// rs // rs
dev->RSSet(w, h); dev->RSSet(size);
// //
@ -282,7 +291,7 @@ void GSRendererDX9::UpdateFBA(GSTexture* rt)
// ia // ia
GSVector4 s = GSVector4(rt->m_scale.x / rt->GetWidth(), rt->m_scale.y / rt->GetHeight()); GSVector4 s = GSVector4(rt->m_scale.x / rt->m_size.x, rt->m_scale.y / rt->m_size.y);
GSVector4 o = GSVector4(-1.0f, 1.0f); GSVector4 o = GSVector4(-1.0f, 1.0f);
GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy()); GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + o.xxyy()) * s.xyxy()).sat(o.zzyy());
@ -310,7 +319,7 @@ void GSRendererDX9::UpdateFBA(GSTexture* rt)
// rs // rs
dev->RSSet(rt->GetWidth(), rt->GetHeight()); dev->RSSet(rt->m_size);
// //

View File

@ -305,7 +305,7 @@ void GSRendererSW::GetScanlineParam(GSScanlineParam& p, GS_PRIM_CLASS primclass)
if(fwrite || ftest) if(fwrite || ftest)
{ {
p.sel.fpsm = GSUtil::EncodePSM(context->FRAME.PSM); p.sel.fpsm = GSLocalMemory::m_psm[context->FRAME.PSM].fmt;
if((primclass == GS_LINE_CLASS || primclass == GS_TRIANGLE_CLASS) && m_vt.m_eq.rgba != 0xffff) if((primclass == GS_LINE_CLASS || primclass == GS_TRIANGLE_CLASS) && m_vt.m_eq.rgba != 0xffff)
{ {
@ -433,15 +433,15 @@ void GSRendererSW::GetScanlineParam(GSScanlineParam& p, GS_PRIM_CLASS primclass)
} }
bool zwrite = p.zm != 0xffffffff; bool zwrite = p.zm != 0xffffffff;
bool ztest = context->TEST.ZTE && context->TEST.ZTST > 1; bool ztest = context->TEST.ZTE && context->TEST.ZTST > ZTST_ALWAYS;
p.sel.zwrite = zwrite; p.sel.zwrite = zwrite;
p.sel.ztest = ztest; p.sel.ztest = ztest;
if(zwrite || ztest) if(zwrite || ztest)
{ {
p.sel.zpsm = GSUtil::EncodePSM(context->ZBUF.PSM); p.sel.zpsm = GSLocalMemory::m_psm[context->ZBUF.PSM].fmt;
p.sel.ztst = ztest ? context->TEST.ZTST : 1; p.sel.ztst = ztest ? context->TEST.ZTST : ZTST_ALWAYS;
p.sel.zoverflow = GSVector4i(m_vt.m_max.p).z == 0x80000000; p.sel.zoverflow = GSVector4i(m_vt.m_max.p).z == 0x80000000;
} }
} }

View File

@ -32,6 +32,7 @@ GSState::GSState(uint8* base, bool mt, void (*irq)())
, m_vprim(1) , m_vprim(1)
, m_version(5) , m_version(5)
, m_frameskip(0) , m_frameskip(0)
, m_framelimit(true)
, m_vkf(NULL) , m_vkf(NULL)
{ {
m_sssize = 0; m_sssize = 0;
@ -421,7 +422,7 @@ void GSState::GIFRegHandlerPRIM(GIFReg* r)
if(GSUtil::GetPrimClass(m_env.PRIM.PRIM) == GSUtil::GetPrimClass(r->PRIM.PRIM)) if(GSUtil::GetPrimClass(m_env.PRIM.PRIM) == GSUtil::GetPrimClass(r->PRIM.PRIM))
{ {
if(((m_env.PRIM.u64 ^ r->PRIM.u64) & ~7) != 0) if((m_env.PRIM.u32[0] ^ r->PRIM.u32[0]) & 0x7f8) // all fields except PRIM
{ {
Flush(); Flush();
} }
@ -1663,13 +1664,13 @@ void GSState::SetGameCRC(uint32 crc, int options)
m_game = CRC::Lookup(crc); m_game = CRC::Lookup(crc);
} }
void GSState::SetFrameSkip(int frameskip) void GSState::SetFrameSkip(int skip)
{ {
if(m_frameskip != frameskip) if(m_frameskip != skip)
{ {
m_frameskip = frameskip; m_frameskip = skip;
if(frameskip) if(skip)
{ {
m_fpGIFPackedRegHandlers[GIF_REG_PRIM] = &GSState::GIFPackedRegHandlerNOP; m_fpGIFPackedRegHandlers[GIF_REG_PRIM] = &GSState::GIFPackedRegHandlerNOP;
m_fpGIFPackedRegHandlers[GIF_REG_RGBA] = &GSState::GIFPackedRegHandlerNOP; m_fpGIFPackedRegHandlers[GIF_REG_RGBA] = &GSState::GIFPackedRegHandlerNOP;
@ -1722,6 +1723,11 @@ void GSState::SetFrameSkip(int frameskip)
} }
} }
void GSState::SetFrameLimit(bool limit)
{
m_framelimit = limit;
}
// GSTransferBuffer // GSTransferBuffer
GSState::GSTransferBuffer::GSTransferBuffer() GSState::GSTransferBuffer::GSTransferBuffer()

View File

@ -210,6 +210,7 @@ public:
uint32 m_crc; uint32 m_crc;
int m_options; int m_options;
int m_frameskip; int m_frameskip;
bool m_framelimit;
CRC::Game m_game; CRC::Game m_game;
GSDump m_dump; GSDump m_dump;
@ -247,6 +248,7 @@ public:
int Defrost(const GSFreezeData* fd); int Defrost(const GSFreezeData* fd);
void GetLastTag(uint32* tag) {*tag = m_path3hack; m_path3hack = 0;} void GetLastTag(uint32* tag) {*tag = m_path3hack; m_path3hack = 0;}
virtual void SetGameCRC(uint32 crc, int options); virtual void SetGameCRC(uint32 crc, int options);
void SetFrameSkip(int frameskip); void SetFrameSkip(int skip);
void SetFrameLimit(bool limit);
}; };

View File

@ -27,20 +27,19 @@ class GSTexture
{ {
public: public:
GSVector2 m_scale; GSVector2 m_scale;
GSVector2i m_size;
struct GSMap {uint8* bits; int pitch;}; struct GSMap {uint8* bits; int pitch;};
enum {None, RenderTarget, DepthStencil, Texture, Offscreen}; enum {None, RenderTarget, DepthStencil, Texture, Offscreen};
public: public:
GSTexture() : m_scale(1, 1) {} GSTexture() : m_scale(1, 1), m_size(0, 0) {}
virtual ~GSTexture() {} virtual ~GSTexture() {}
virtual operator bool() {ASSERT(0); return false;} virtual operator bool() {ASSERT(0); return false;}
virtual int GetType() const = 0; virtual int GetType() const = 0;
virtual int GetWidth() const = 0;
virtual int GetHeight() const = 0;
virtual int GetFormat() const = 0; virtual int GetFormat() const = 0;
virtual bool Update(const GSVector4i& r, const void* data, int pitch) = 0; virtual bool Update(const GSVector4i& r, const void* data, int pitch) = 0;
@ -48,5 +47,8 @@ public:
virtual void Unmap() = 0; virtual void Unmap() = 0;
virtual bool Save(const string& fn, bool dds = false) = 0; virtual bool Save(const string& fn, bool dds = false) = 0;
GSVector2i GetSize() const {return GSVector2i(GetWidth(), GetHeight());} int GetWidth() const {return m_size.x;}
int GetHeight() const {return m_size.y;}
GSVector2i GetSize() const {return m_size;}
}; };

View File

@ -29,6 +29,9 @@ GSTexture10::GSTexture10(ID3D10Texture2D* texture)
m_texture->GetDevice(&m_dev); m_texture->GetDevice(&m_dev);
m_texture->GetDesc(&m_desc); m_texture->GetDesc(&m_desc);
m_size.x = (int)m_desc.Width;
m_size.y = (int)m_desc.Height;
} }
int GSTexture10::GetType() const int GSTexture10::GetType() const
@ -40,16 +43,6 @@ int GSTexture10::GetType() const
return GSTexture::None; return GSTexture::None;
} }
int GSTexture10::GetWidth() const
{
return m_desc.Width;
}
int GSTexture10::GetHeight() const
{
return m_desc.Height;
}
int GSTexture10::GetFormat() const int GSTexture10::GetFormat() const
{ {
return m_desc.Format; return m_desc.Format;

View File

@ -36,8 +36,6 @@ public:
explicit GSTexture10(ID3D10Texture2D* texture); explicit GSTexture10(ID3D10Texture2D* texture);
int GetType() const; int GetType() const;
int GetWidth() const;
int GetHeight() const;
int GetFormat() const; int GetFormat() const;
bool Update(const GSVector4i& r, const void* data, int pitch); bool Update(const GSVector4i& r, const void* data, int pitch);

View File

@ -31,6 +31,9 @@ GSTexture11::GSTexture11(ID3D11Texture2D* texture)
m_texture->GetDesc(&m_desc); m_texture->GetDesc(&m_desc);
m_dev->GetImmediateContext(&m_ctx); m_dev->GetImmediateContext(&m_ctx);
m_size.x = (int)m_desc.Width;
m_size.y = (int)m_desc.Height;
} }
int GSTexture11::GetType() const int GSTexture11::GetType() const
@ -42,16 +45,6 @@ int GSTexture11::GetType() const
return GSTexture::None; return GSTexture::None;
} }
int GSTexture11::GetWidth() const
{
return m_desc.Width;
}
int GSTexture11::GetHeight() const
{
return m_desc.Height;
}
int GSTexture11::GetFormat() const int GSTexture11::GetFormat() const
{ {
return m_desc.Format; return m_desc.Format;

View File

@ -37,8 +37,6 @@ public:
explicit GSTexture11(ID3D11Texture2D* texture); explicit GSTexture11(ID3D11Texture2D* texture);
int GetType() const; int GetType() const;
int GetWidth() const;
int GetHeight() const;
int GetFormat() const; int GetFormat() const;
bool Update(const GSVector4i& r, const void* data, int pitch); bool Update(const GSVector4i& r, const void* data, int pitch);

View File

@ -31,6 +31,9 @@ GSTexture7::GSTexture7(int type, IDirectDrawSurface7* system)
m_desc.dwSize = sizeof(m_desc); m_desc.dwSize = sizeof(m_desc);
system->GetSurfaceDesc(&m_desc); system->GetSurfaceDesc(&m_desc);
m_size.x = (int)m_desc.dwWidth;
m_size.y = (int)m_desc.dwHeight;
} }
GSTexture7::GSTexture7(int type, IDirectDrawSurface7* system, IDirectDrawSurface7* video) GSTexture7::GSTexture7(int type, IDirectDrawSurface7* system, IDirectDrawSurface7* video)
@ -43,6 +46,9 @@ GSTexture7::GSTexture7(int type, IDirectDrawSurface7* system, IDirectDrawSurface
m_desc.dwSize = sizeof(m_desc); m_desc.dwSize = sizeof(m_desc);
video->GetSurfaceDesc(&m_desc); video->GetSurfaceDesc(&m_desc);
m_size.x = (int)m_desc.dwWidth;
m_size.y = (int)m_desc.dwHeight;
} }
int GSTexture7::GetType() const int GSTexture7::GetType() const
@ -50,16 +56,6 @@ int GSTexture7::GetType() const
return m_type; return m_type;
} }
int GSTexture7::GetWidth() const
{
return m_desc.dwWidth;
}
int GSTexture7::GetHeight() const
{
return m_desc.dwHeight;
}
int GSTexture7::GetFormat() const int GSTexture7::GetFormat() const
{ {
return (int)m_desc.ddpfPixelFormat.dwFourCC; return (int)m_desc.ddpfPixelFormat.dwFourCC;

View File

@ -36,8 +36,6 @@ public:
GSTexture7(int type, IDirectDrawSurface7* system, IDirectDrawSurface7* video); GSTexture7(int type, IDirectDrawSurface7* system, IDirectDrawSurface7* video);
int GetType() const; int GetType() const;
int GetWidth() const;
int GetHeight() const;
int GetFormat() const; int GetFormat() const;
bool Update(const GSVector4i& r, const void* data, int pitch); bool Update(const GSVector4i& r, const void* data, int pitch);

View File

@ -35,6 +35,9 @@ GSTexture9::GSTexture9(IDirect3DSurface9* surface)
ASSERT(m_texture != NULL); ASSERT(m_texture != NULL);
} }
m_size.x = (int)m_desc.Width;
m_size.y = (int)m_desc.Height;
} }
GSTexture9::GSTexture9(IDirect3DTexture9* texture) GSTexture9::GSTexture9(IDirect3DTexture9* texture)
@ -46,6 +49,9 @@ GSTexture9::GSTexture9(IDirect3DTexture9* texture)
texture->GetSurfaceLevel(0, &m_surface); texture->GetSurfaceLevel(0, &m_surface);
ASSERT(m_surface != NULL); ASSERT(m_surface != NULL);
m_size.x = (int)m_desc.Width;
m_size.y = (int)m_desc.Height;
} }
GSTexture9::~GSTexture9() GSTexture9::~GSTexture9()
@ -61,16 +67,6 @@ int GSTexture9::GetType() const
return GSTexture::None; return GSTexture::None;
} }
int GSTexture9::GetWidth() const
{
return m_desc.Width;
}
int GSTexture9::GetHeight() const
{
return m_desc.Height;
}
int GSTexture9::GetFormat() const int GSTexture9::GetFormat() const
{ {
return m_desc.Format; return m_desc.Format;

View File

@ -36,8 +36,6 @@ public:
virtual ~GSTexture9(); virtual ~GSTexture9();
int GetType() const; int GetType() const;
int GetWidth() const;
int GetHeight() const;
int GetFormat() const; int GetFormat() const;
bool Update(const GSVector4i& r, const void* data, int pitch); bool Update(const GSVector4i& r, const void* data, int pitch);

View File

@ -445,11 +445,11 @@ void GSTextureCache::IncAge()
{ {
int maxage = m_src.m_used ? 3 : 30; int maxage = m_src.m_used ? 3 : 30;
for(hash_map<Source*, bool>::iterator i = m_src.m_surfaces.begin(); i != m_src.m_surfaces.end(); ) for(hash_set<Source*>::iterator i = m_src.m_surfaces.begin(); i != m_src.m_surfaces.end(); )
{ {
hash_map<Source*, bool>::iterator j = i++; hash_set<Source*>::iterator j = i++;
Source* s = j->first; Source* s = *j;
if(++s->m_age > maxage) if(++s->m_age > maxage)
{ {
@ -673,8 +673,8 @@ bool GSTextureCache::Source::Create(Target* dst)
} }
else else
{ {
sr.z /= st->GetWidth(); sr.z /= st->m_size.x;
sr.w /= st->GetHeight(); sr.w /= st->m_size.y;
m_renderer->m_dev->StretchRect(st, sr, dt, dr); m_renderer->m_dev->StretchRect(st, sr, dt, dr);
} }
@ -733,9 +733,12 @@ void GSTextureCache::Source::Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TE
GSVector2i bs = GSLocalMemory::m_psm[m_TEX0.PSM].bs; GSVector2i bs = GSLocalMemory::m_psm[m_TEX0.PSM].bs;
GSVector4i r = rect.ralign<GSVector4i::Outside>(bs); int tw = std::max<int>(1 << m_TEX0.TW, bs.x);
int th = std::max<int>(1 << m_TEX0.TH, bs.y);
if(r.eq(GSVector4i(0, 0, 1 << m_TEX0.TW, 1 << m_TEX0.TH))) GSVector4i r = rect.ralign<GSVector4i::Outside>(bs);
if(r.eq(GSVector4i(0, 0, tw, th)))
{ {
m_complete = true; // lame, but better than nothing m_complete = true; // lame, but better than nothing
} }
@ -995,7 +998,7 @@ void GSTextureCache::Target::Update()
void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, GSLocalMemory& mem) void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, GSLocalMemory& mem)
{ {
m_surfaces[s] = true; m_surfaces.insert(s);
if(s->m_target) if(s->m_target)
{ {
@ -1038,12 +1041,13 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, GSLocalMe
list<Source*>* m = &m_map[i << 5]; list<Source*>* m = &m_map[i << 5];
for(int j = 0; j < 32; j++) unsigned long j;
while(_BitScanForward(&j, p))
{ {
if(p & (1 << j)) p ^= 1 << j;
{
m[j].push_front(s); m[j].push_front(s);
}
} }
} }
} }
@ -1051,7 +1055,7 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, GSLocalMe
void GSTextureCache::SourceMap::RemoveAll() void GSTextureCache::SourceMap::RemoveAll()
{ {
for_each(m_surfaces.begin(), m_surfaces.end(), delete_first()); for_each(m_surfaces.begin(), m_surfaces.end(), delete_object());
m_surfaces.clear(); m_surfaces.clear();

View File

@ -98,7 +98,7 @@ protected:
struct SourceMap struct SourceMap
{ {
hash_map<Source*, bool> m_surfaces; hash_set<Source*> m_surfaces;
list<Source*> m_map[MAX_PAGES]; list<Source*> m_map[MAX_PAGES];
uint32 m_pages[16]; uint32 m_pages[16];
bool m_used; bool m_used;

View File

@ -68,7 +68,7 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE
{ {
t = new GSTexture(m_state); t = new GSTexture(m_state);
m_textures[t] = true; m_textures.insert(t);
const GSLocalMemory::BlockOffset* bo = m_state->m_mem.GetBlockOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM); const GSLocalMemory::BlockOffset* bo = m_state->m_mem.GetBlockOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM);
@ -100,12 +100,13 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE
list<GSTexture*>* m = &m_map[i << 5]; list<GSTexture*>* m = &m_map[i << 5];
for(int j = 0; j < 32; j++) unsigned long j;
while(_BitScanForward(&j, p))
{ {
if(p & (1 << j)) p ^= 1 << j;
{
m[j].push_front(t); m[j].push_front(t);
}
} }
} }
} }
@ -125,7 +126,7 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE
void GSTextureCacheSW::RemoveAll() void GSTextureCacheSW::RemoveAll()
{ {
for_each(m_textures.begin(), m_textures.end(), delete_first()); for_each(m_textures.begin(), m_textures.end(), delete_object());
m_textures.clear(); m_textures.clear();
@ -156,11 +157,11 @@ void GSTextureCacheSW::RemoveAt(GSTexture* t)
void GSTextureCacheSW::IncAge() void GSTextureCacheSW::IncAge()
{ {
for(hash_map<GSTexture*, bool>::iterator i = m_textures.begin(); i != m_textures.end(); ) for(hash_set<GSTexture*>::iterator i = m_textures.begin(); i != m_textures.end(); )
{ {
hash_map<GSTexture*, bool>::iterator j = i++; hash_set<GSTexture*>::iterator j = i++;
GSTexture* t = j->first; GSTexture* t = *j;
if(++t->m_age > 30) if(++t->m_age > 30)
{ {
@ -242,8 +243,8 @@ bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEX
GSVector2i bs = psm.bs; GSVector2i bs = psm.bs;
int tw = max(1 << TEX0.TW, bs.x); int tw = std::max<int>(1 << TEX0.TW, bs.x);
int th = max(1 << TEX0.TH, bs.y); int th = std::max<int>(1 << TEX0.TH, bs.y);
GSVector4i r = rect.ralign<GSVector4i::Outside>(bs); GSVector4i r = rect.ralign<GSVector4i::Outside>(bs);

View File

@ -46,7 +46,7 @@ public:
protected: protected:
GSState* m_state; GSState* m_state;
hash_map<GSTexture*, bool> m_textures; hash_set<GSTexture*> m_textures;
list<GSTexture*> m_map[MAX_PAGES]; list<GSTexture*> m_map[MAX_PAGES];
uint32 m_pages[16]; uint32 m_pages[16];

View File

@ -45,12 +45,13 @@ public:
{ {
GSVector4 VertexScale; GSVector4 VertexScale;
GSVector4 VertexOffset; GSVector4 VertexOffset;
GSVector2 TextureScale; GSVector4 TextureScale;
float _pad[2];
struct VSConstantBuffer() struct VSConstantBuffer()
{ {
memset(this, 0, sizeof(*this)); VertexScale = GSVector4::zero();
VertexOffset = GSVector4::zero();
TextureScale = GSVector4::zero();
} }
__forceinline bool Update(const VSConstantBuffer* cb) __forceinline bool Update(const VSConstantBuffer* cb)
@ -85,13 +86,12 @@ public:
uint32 tme:1; uint32 tme:1;
uint32 fst:1; uint32 fst:1;
uint32 logz:1; uint32 logz:1;
uint32 prim:2;
}; };
uint32 key; uint32 key;
}; };
operator uint32() {return key & 0x7f;} operator uint32() {return key & 0x1f;}
VSSelector() : key(0) {} VSSelector() : key(0) {}
}; };
@ -107,7 +107,12 @@ public:
struct PSConstantBuffer() struct PSConstantBuffer()
{ {
memset(this, 0, sizeof(*this)); FogColor_AREF = GSVector4::zero();
HalfTexel = GSVector4::zero();
WH = GSVector4::zero();
MinMax = GSVector4::zero();
MinF_TA = GSVector4::zero();
MskFix = GSVector4i::zero();
} }
__forceinline bool Update(const PSConstantBuffer* cb) __forceinline bool Update(const PSConstantBuffer* cb)
@ -212,7 +217,6 @@ public:
{ {
struct struct
{ {
uint32 zte:1;
uint32 ztst:2; uint32 ztst:2;
uint32 zwe:1; uint32 zwe:1;
uint32 date:1; uint32 date:1;
@ -222,7 +226,7 @@ public:
uint32 key; uint32 key;
}; };
operator uint32() {return key & 0x3f;} operator uint32() {return key & 0x1f;}
OMDepthStencilSelector() : key(0) {} OMDepthStencilSelector() : key(0) {}
}; };
@ -244,6 +248,13 @@ public:
uint32 wa:1; uint32 wa:1;
}; };
struct
{
uint32 _pad:1;
uint32 abcd:8;
uint32 wrgba:4;
};
uint32 key; uint32 key;
}; };
@ -273,7 +284,7 @@ public:
virtual void SetupGS(GSSelector sel) = 0; virtual void SetupGS(GSSelector sel) = 0;
virtual void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, GSTexture* tex, GSTexture* pal) = 0; virtual void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, GSTexture* tex, GSTexture* pal) = 0;
virtual void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel) = 0; virtual void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel) = 0;
virtual void SetupRS(int w, int h, const GSVector4i& scissor) = 0; virtual void SetupRS(const GSVector2i& size, const GSVector4i& scissor) = 0;
virtual void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds) = 0; virtual void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds) = 0;
virtual void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix) = 0; virtual void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix) = 0;
}; };

View File

@ -76,6 +76,13 @@ bool GSTextureFX10::Create(GSDevice* dev)
if(FAILED(hr)) return false; if(FAILED(hr)) return false;
// create layout
VSSelector sel;
VSConstantBuffer cb;
SetupVS(sel, &cb);
// //
return true; return true;
@ -98,19 +105,17 @@ void GSTextureFX10::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
if(i == m_vs.end()) if(i == m_vs.end())
{ {
string str[4]; string str[3];
str[0] = format("%d", sel.bppz); str[0] = format("%d", sel.bppz);
str[1] = format("%d", sel.tme); str[1] = format("%d", sel.tme);
str[2] = format("%d", sel.fst); str[2] = format("%d", sel.fst);
str[3] = format("%d", sel.prim);
D3D10_SHADER_MACRO macro[] = D3D10_SHADER_MACRO macro[] =
{ {
{"VS_BPPZ", str[0].c_str()}, {"VS_BPPZ", str[0].c_str()},
{"VS_TME", str[1].c_str()}, {"VS_TME", str[1].c_str()},
{"VS_FST", str[2].c_str()}, {"VS_FST", str[2].c_str()},
{"VS_PRIM", str[3].c_str()},
{NULL, NULL}, {NULL, NULL},
}; };
@ -297,9 +302,9 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
dev->PSSetSamplerState(ss0, ss1); dev->PSSetSamplerState(ss0, ss1);
} }
void GSTextureFX10::SetupRS(int w, int h, const GSVector4i& scissor) void GSTextureFX10::SetupRS(const GSVector2i& size, const GSVector4i& scissor)
{ {
((GSDevice10*)m_dev)->RSSet(w, h, &scissor); ((GSDevice10*)m_dev)->RSSet(size, &scissor);
} }
void GSTextureFX10::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds) void GSTextureFX10::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds)
@ -312,11 +317,17 @@ void GSTextureFX10::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix) void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
{ {
GSDevice10* dev = (GSDevice10*)m_dev; GSDevice10* dev = (GSDevice10*)m_dev;
/*
hash_map<uint32, CComPtr<ID3D10DepthStencilState> >::const_iterator i = m_om_dss.find(dssel); hash_map<uint32, CComPtr<ID3D10DepthStencilState> >::const_iterator i = m_om_dss.find(dssel);
if(i == m_om_dss.end()) if(i == m_om_dss.end())
{ {
*/
CComPtr<ID3D10DepthStencilState>& om_dss = m_om_dss[dssel];
if(om_dss == NULL)
{
D3D10_DEPTH_STENCIL_DESC dsd; D3D10_DEPTH_STENCIL_DESC dsd;
memset(&dsd, 0, sizeof(dsd)); memset(&dsd, 0, sizeof(dsd));
@ -336,7 +347,7 @@ void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
dsd.BackFace.StencilDepthFailOp = D3D10_STENCIL_OP_KEEP; dsd.BackFace.StencilDepthFailOp = D3D10_STENCIL_OP_KEEP;
} }
if(!(dssel.zte && dssel.ztst == 1 && !dssel.zwe)) if(dssel.ztst != ZTST_ALWAYS || dssel.zwe)
{ {
static const D3D10_COMPARISON_FUNC ztst[] = static const D3D10_COMPARISON_FUNC ztst[] =
{ {
@ -346,11 +357,11 @@ void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
D3D10_COMPARISON_GREATER D3D10_COMPARISON_GREATER
}; };
dsd.DepthEnable = dssel.zte; dsd.DepthEnable = true;
dsd.DepthWriteMask = dssel.zwe ? D3D10_DEPTH_WRITE_MASK_ALL : D3D10_DEPTH_WRITE_MASK_ZERO; dsd.DepthWriteMask = dssel.zwe ? D3D10_DEPTH_WRITE_MASK_ALL : D3D10_DEPTH_WRITE_MASK_ZERO;
dsd.DepthFunc = ztst[dssel.ztst]; dsd.DepthFunc = ztst[dssel.ztst];
} }
/*
CComPtr<ID3D10DepthStencilState> dss; CComPtr<ID3D10DepthStencilState> dss;
(*dev)->CreateDepthStencilState(&dsd, &dss); (*dev)->CreateDepthStencilState(&dsd, &dss);
@ -358,9 +369,13 @@ void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
m_om_dss[dssel] = dss; m_om_dss[dssel] = dss;
i = m_om_dss.find(dssel); i = m_om_dss.find(dssel);
*/
(*dev)->CreateDepthStencilState(&dsd, &om_dss);
} }
dev->OMSetDepthStencilState(i->second, 1); // dev->OMSetDepthStencilState(i->second, 1);
dev->OMSetDepthStencilState(om_dss, 1);
hash_map<uint32, CComPtr<ID3D10BlendState> >::const_iterator j = m_om_bs.find(bsel); hash_map<uint32, CComPtr<ID3D10BlendState> >::const_iterator j = m_om_bs.find(bsel);

View File

@ -34,7 +34,8 @@ class GSTextureFX10 : public GSTextureFX
CComPtr<ID3D10Buffer> m_ps_cb; CComPtr<ID3D10Buffer> m_ps_cb;
hash_map<uint32, CComPtr<ID3D10SamplerState> > m_ps_ss; hash_map<uint32, CComPtr<ID3D10SamplerState> > m_ps_ss;
CComPtr<ID3D10SamplerState> m_palette_ss; CComPtr<ID3D10SamplerState> m_palette_ss;
hash_map<uint32, CComPtr<ID3D10DepthStencilState> > m_om_dss; // hash_map<uint32, CComPtr<ID3D10DepthStencilState> > m_om_dss;
CComPtr<ID3D10DepthStencilState> m_om_dss[32];
hash_map<uint32, CComPtr<ID3D10BlendState> > m_om_bs; hash_map<uint32, CComPtr<ID3D10BlendState> > m_om_bs;
VSConstantBuffer m_vs_cb_cache; VSConstantBuffer m_vs_cb_cache;
@ -50,7 +51,7 @@ public:
void SetupGS(GSSelector sel); void SetupGS(GSSelector sel);
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, GSTexture* tex, GSTexture* pal); void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, GSTexture* tex, GSTexture* pal);
void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel); void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
void SetupRS(int w, int h, const GSVector4i& scissor); void SetupRS(const GSVector2i& size, const GSVector4i& scissor);
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds); void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds);
void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix); void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
}; };

View File

@ -76,6 +76,13 @@ bool GSTextureFX11::Create(GSDevice* dev)
if(FAILED(hr)) return false; if(FAILED(hr)) return false;
// create layout
VSSelector sel;
VSConstantBuffer cb;
SetupVS(sel, &cb);
// //
return true; return true;
@ -98,19 +105,17 @@ void GSTextureFX11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
if(i == m_vs.end()) if(i == m_vs.end())
{ {
string str[4]; string str[3];
str[0] = format("%d", sel.bppz); str[0] = format("%d", sel.bppz);
str[1] = format("%d", sel.tme); str[1] = format("%d", sel.tme);
str[2] = format("%d", sel.fst); str[2] = format("%d", sel.fst);
str[3] = format("%d", sel.prim);
D3D11_SHADER_MACRO macro[] = D3D11_SHADER_MACRO macro[] =
{ {
{"VS_BPPZ", str[0].c_str()}, {"VS_BPPZ", str[0].c_str()},
{"VS_TME", str[1].c_str()}, {"VS_TME", str[1].c_str()},
{"VS_FST", str[2].c_str()}, {"VS_FST", str[2].c_str()},
{"VS_PRIM", str[3].c_str()},
{NULL, NULL}, {NULL, NULL},
}; };
@ -301,9 +306,9 @@ void GSTextureFX11::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
dev->PSSetSamplerState(ss0, ss1); dev->PSSetSamplerState(ss0, ss1);
} }
void GSTextureFX11::SetupRS(int w, int h, const GSVector4i& scissor) void GSTextureFX11::SetupRS(const GSVector2i& size, const GSVector4i& scissor)
{ {
((GSDevice11*)m_dev)->RSSet(w, h, &scissor); ((GSDevice11*)m_dev)->RSSet(size, &scissor);
} }
void GSTextureFX11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds) void GSTextureFX11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds)
@ -340,7 +345,7 @@ void GSTextureFX11::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
dsd.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP; dsd.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
} }
if(!(dssel.zte && dssel.ztst == 1 && !dssel.zwe)) if(dssel.ztst != ZTST_ALWAYS || dssel.zwe)
{ {
static const D3D11_COMPARISON_FUNC ztst[] = static const D3D11_COMPARISON_FUNC ztst[] =
{ {
@ -350,7 +355,7 @@ void GSTextureFX11::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
D3D11_COMPARISON_GREATER D3D11_COMPARISON_GREATER
}; };
dsd.DepthEnable = dssel.zte; dsd.DepthEnable = true;
dsd.DepthWriteMask = dssel.zwe ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; dsd.DepthWriteMask = dssel.zwe ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
dsd.DepthFunc = ztst[dssel.ztst]; dsd.DepthFunc = ztst[dssel.ztst];
} }

View File

@ -50,7 +50,7 @@ public:
void SetupGS(GSSelector sel); void SetupGS(GSSelector sel);
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, GSTexture* tex, GSTexture* pal); void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, GSTexture* tex, GSTexture* pal);
void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel); void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
void SetupRS(int w, int h, const GSVector4i& scissor); void SetupRS(const GSVector2i& size, const GSVector4i& scissor);
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds); void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds);
void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix); void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
}; };

View File

@ -158,7 +158,7 @@ void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSampler
{ {
if(sel.wms == 3) if(sel.wms == 3)
{ {
if(GSTexture* t = CreateMskFix(tex->GetWidth(), cb->MskFix.x, cb->MskFix.z)) if(GSTexture* t = CreateMskFix(tex->m_size.x, cb->MskFix.x, cb->MskFix.z))
{ {
(*dev)->SetTexture(2, *(GSTexture9*)t); (*dev)->SetTexture(2, *(GSTexture9*)t);
} }
@ -166,7 +166,7 @@ void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSampler
if(sel.wmt == 3) if(sel.wmt == 3)
{ {
if(GSTexture* t = CreateMskFix(tex->GetHeight(), cb->MskFix.y, cb->MskFix.w)) if(GSTexture* t = CreateMskFix(tex->m_size.y, cb->MskFix.y, cb->MskFix.w))
{ {
(*dev)->SetTexture(3, *(GSTexture9*)t); (*dev)->SetTexture(3, *(GSTexture9*)t);
} }
@ -265,9 +265,9 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample
dev->PSSetSamplerState(ss); dev->PSSetSamplerState(ss);
} }
void GSTextureFX9::SetupRS(int w, int h, const GSVector4i& scissor) void GSTextureFX9::SetupRS(const GSVector2i& size, const GSVector4i& scissor)
{ {
((GSDevice9*)m_dev)->RSSet(w, h, &scissor); ((GSDevice9*)m_dev)->RSSet(size, &scissor);
} }
void GSTextureFX9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds) void GSTextureFX9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds)
@ -303,7 +303,7 @@ void GSTextureFX9::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
dss->StencilRef = 3; dss->StencilRef = 3;
} }
if(!(dssel.zte && dssel.ztst == 1 && !dssel.zwe)) if(dssel.ztst != ZTST_ALWAYS || dssel.zwe)
{ {
static const D3DCMPFUNC ztst[] = static const D3DCMPFUNC ztst[] =
{ {
@ -313,7 +313,7 @@ void GSTextureFX9::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
D3DCMP_GREATER D3DCMP_GREATER
}; };
dss->DepthEnable = dssel.zte; dss->DepthEnable = true;
dss->DepthWriteMask = dssel.zwe; dss->DepthWriteMask = dssel.zwe;
dss->DepthFunc = ztst[dssel.ztst]; dss->DepthFunc = ztst[dssel.ztst];
} }

View File

@ -48,7 +48,7 @@ public:
void SetupGS(GSSelector sel) {} void SetupGS(GSSelector sel) {}
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, GSTexture* tex, GSTexture* pal); void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, GSTexture* tex, GSTexture* pal);
void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel); void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
void SetupRS(int w, int h, const GSVector4i& scissor); void SetupRS(const GSVector2i& size, const GSVector4i& scissor);
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds); void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix, GSTexture* rt, GSTexture* ds);
void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix); void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
}; };

View File

@ -32,9 +32,8 @@ public:
GSTextureNull(int type, int w, int h, int format); GSTextureNull(int type, int w, int h, int format);
int GetType() const {return m_desc.type;} int GetType() const {return m_desc.type;}
int GetWidth() const {return m_desc.w;}
int GetHeight() const {return m_desc.h;}
int GetFormat() const {return m_desc.format;} int GetFormat() const {return m_desc.format;}
bool Update(const GSVector4i& r, const void* data, int pitch) {return true;} bool Update(const GSVector4i& r, const void* data, int pitch) {return true;}
bool Map(GSMap& m, const GSVector4i* r) {return false;} bool Map(GSMap& m, const GSVector4i* r) {return false;}
void Unmap() {} void Unmap() {}

View File

@ -26,10 +26,11 @@
GSTextureOGL::GSTextureOGL(GLuint texture, int type, int width, int height, int format) GSTextureOGL::GSTextureOGL(GLuint texture, int type, int width, int height, int format)
: m_texture(texture) : m_texture(texture)
, m_type(type) , m_type(type)
, m_width(width)
, m_height(height)
, m_format(format) , m_format(format)
{ {
m_size.x = width;
m_size.y = height;
// TODO: offscreen type should be just a memory array, also returned in Map // TODO: offscreen type should be just a memory array, also returned in Map
glGenBuffers(1, &m_pbo); GSDeviceOGL::CheckError(); glGenBuffers(1, &m_pbo); GSDeviceOGL::CheckError();
@ -61,16 +62,6 @@ int GSTextureOGL::GetType() const
return m_type; return m_type;
} }
int GSTextureOGL::GetWidth() const
{
return m_width;
}
int GSTextureOGL::GetHeight() const
{
return m_height;
}
int GSTextureOGL::GetFormat() const int GSTextureOGL::GetFormat() const
{ {
return m_format; return m_format;

View File

@ -29,8 +29,6 @@ class GSTextureOGL : public GSTexture
GLuint m_pbo; GLuint m_pbo;
int m_type; int m_type;
int m_width;
int m_height;
int m_format; int m_format;
public: public:
@ -38,8 +36,6 @@ public:
virtual ~GSTextureOGL(); virtual ~GSTextureOGL();
int GetType() const; int GetType() const;
int GetWidth() const;
int GetHeight() const;
int GetFormat() const; int GetFormat() const;
bool Update(const GSVector4i& r, const void* data, int pitch); bool Update(const GSVector4i& r, const void* data, int pitch);

View File

@ -22,6 +22,7 @@
#pragma once #pragma once
#include "GS.h" #include "GS.h"
#include "GSLocalMemory.h"
class GSUtil class GSUtil
{ {
@ -32,26 +33,6 @@ public:
static bool HasSharedBits(uint32 sbp, uint32 spsm, uint32 dbp, uint32 dpsm); static bool HasSharedBits(uint32 sbp, uint32 spsm, uint32 dbp, uint32 dpsm);
static bool HasCompatibleBits(uint32 spsm, uint32 dpsm); static bool HasCompatibleBits(uint32 spsm, uint32 dpsm);
static uint32 EncodePSM(uint32 psm)
{
switch(psm)
{
case PSM_PSMCT32:
case PSM_PSMZ32:
return 0;
case PSM_PSMCT24:
case PSM_PSMZ24:
return 1;
case PSM_PSMCT16:
case PSM_PSMCT16S:
case PSM_PSMZ16:
case PSM_PSMZ16S:
return 2;
default:
return 3;
}
}
static bool CheckDirectX(); static bool CheckDirectX();
static bool CheckSSE(); static bool CheckSSE();

View File

@ -28,6 +28,11 @@ public:
{ {
return x == v.x && y == v.y; return x == v.x && y == v.y;
} }
bool operator != (const GSVector2T& v) const
{
return x != v.x || y != v.y;
}
}; };
typedef GSVector2T<float> GSVector2; typedef GSVector2T<float> GSVector2;

View File

@ -12,7 +12,6 @@
#define VS_BPPZ 0 #define VS_BPPZ 0
#define VS_TME 1 #define VS_TME 1
#define VS_FST 1 #define VS_FST 1
#define VS_PRIM 0
#endif #endif
#ifndef GS_IIP #ifndef GS_IIP
@ -520,11 +519,6 @@ VS_OUTPUT vs_main(VS_INPUT input)
input.z = input.z & 0xffff; input.z = input.z & 0xffff;
} }
if(VS_PRIM == 3) // sprite
{
//input.p.xy = (input.p.xy + 15) & ~15; // HACK
}
VS_OUTPUT output; VS_OUTPUT output;
// pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go) // pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go)

View File

@ -53,6 +53,7 @@
#include <list> #include <list>
#include <map> #include <map>
#include <hash_map> #include <hash_map>
#include <hash_set>
#include <algorithm> #include <algorithm>
using namespace std; using namespace std;