mirror of https://github.com/PCSX2/pcsx2.git
GSdx: GSDeviceSW almost ready, just need an image resizer.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4331 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
b62d4801ac
commit
eeb9757e94
|
@ -23,8 +23,6 @@
|
||||||
|
|
||||||
#include "GPU.h"
|
#include "GPU.h"
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
|
|
||||||
__aligned(class, 32) GPUDrawingEnvironment
|
__aligned(class, 32) GPUDrawingEnvironment
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -75,5 +73,3 @@ public:
|
||||||
return STATUS.ISPAL ? 50 : 60;
|
return STATUS.ISPAL ? 50 : 60;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
|
@ -196,6 +196,7 @@ void GSDevice::Merge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, const GSVec
|
||||||
if(!m_merge || !(m_merge->GetSize() == fs))
|
if(!m_merge || !(m_merge->GetSize() == fs))
|
||||||
{
|
{
|
||||||
Recycle(m_merge);
|
Recycle(m_merge);
|
||||||
|
|
||||||
m_merge = CreateRenderTarget(fs.x, fs.y, false);
|
m_merge = CreateRenderTarget(fs.x, fs.y, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "GSDeviceSW.h"
|
#include "GSDeviceSW.h"
|
||||||
|
|
||||||
|
GSDeviceSW::GSDeviceSW()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool GSDeviceSW::Create(GSWnd* wnd)
|
bool GSDeviceSW::Create(GSWnd* wnd)
|
||||||
{
|
{
|
||||||
if(!GSDevice::Create(wnd))
|
if(!GSDevice::Create(wnd))
|
||||||
|
@ -37,11 +41,14 @@ bool GSDeviceSW::Reset(int w, int h)
|
||||||
if(!GSDevice::Reset(w, h))
|
if(!GSDevice::Reset(w, h))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
m_backbuffer = new GSTextureSW(GSTexture::RenderTarget, w, h);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSDeviceSW::Flip()
|
void GSDeviceSW::Flip()
|
||||||
{
|
{
|
||||||
|
// TODO: derived class should present m_backbuffer here
|
||||||
}
|
}
|
||||||
|
|
||||||
GSTexture* GSDeviceSW::Create(int type, int w, int h, bool msaa, int format)
|
GSTexture* GSDeviceSW::Create(int type, int w, int h, bool msaa, int format)
|
||||||
|
@ -68,7 +75,7 @@ void GSDeviceSW::EndScene()
|
||||||
|
|
||||||
void GSDeviceSW::ClearRenderTarget(GSTexture* t, const GSVector4& c)
|
void GSDeviceSW::ClearRenderTarget(GSTexture* t, const GSVector4& c)
|
||||||
{
|
{
|
||||||
Clear(t, c.rgba32());
|
Clear(t, (c * 255 + 0.5f).rgba32());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSDeviceSW::ClearRenderTarget(GSTexture* t, uint32 c)
|
void GSDeviceSW::ClearRenderTarget(GSTexture* t, uint32 c)
|
||||||
|
@ -88,24 +95,31 @@ void GSDeviceSW::ClearStencil(GSTexture* t, uint8 c)
|
||||||
|
|
||||||
GSTexture* GSDeviceSW::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format)
|
GSTexture* GSDeviceSW::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format)
|
||||||
{
|
{
|
||||||
// TODO
|
GSTexture* dst = CreateOffscreen(w, h, format);
|
||||||
|
|
||||||
return NULL;
|
if(dst != NULL)
|
||||||
|
{
|
||||||
|
CopyRect(src, dst, GSVector4i(0, 0, w, h));
|
||||||
|
}
|
||||||
|
|
||||||
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSDeviceSW::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r)
|
void GSDeviceSW::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r)
|
||||||
{
|
{
|
||||||
// TODO
|
GSTexture::GSMap m;
|
||||||
}
|
|
||||||
|
|
||||||
void GSDeviceSW::StretchRect(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader, bool linear)
|
if(st->Map(m, &r))
|
||||||
{
|
{
|
||||||
// TODO
|
dt->Update(r, m.bits, m.pitch);
|
||||||
|
|
||||||
|
st->Unmap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSDeviceSW::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear)
|
void GSDeviceSW::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO: only used to stretch m_current to m_backbuffer, no blending needed (yet)
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSDeviceSW::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1)
|
void GSDeviceSW::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1)
|
||||||
|
@ -127,18 +141,40 @@ void GSDeviceSW::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector
|
||||||
|
|
||||||
void GSDeviceSW::DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c)
|
void GSDeviceSW::DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c)
|
||||||
{
|
{
|
||||||
// TODO
|
ClearRenderTarget(dt, c);
|
||||||
|
|
||||||
|
if(st[1] && !slbg)
|
||||||
|
{
|
||||||
|
// TODO: copy (StretchRect)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st[0])
|
||||||
|
{
|
||||||
|
// TODO: blend
|
||||||
|
//
|
||||||
|
// mmod 0 => alpha = min(st[0].a * 2, 1)
|
||||||
|
// mmod 1 => alpha = c.a
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSDeviceSW::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset)
|
void GSDeviceSW::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset)
|
||||||
{
|
{
|
||||||
|
GSVector4 s = GSVector4(dt->GetSize());
|
||||||
|
|
||||||
|
GSVector4 sr(0, 0, 1, 1);
|
||||||
|
GSVector4 dr(0.0f, yoffset, s.x, s.y + yoffset);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
//
|
||||||
|
// shader 0/1 => copy even/odd lines
|
||||||
|
// shader 2 => blend lines (1:2:1 filter)
|
||||||
|
// shader 3 => copy all lines (StretchRect)
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSDeviceSW::Clear(GSTexture* t, uint32 c)
|
void GSDeviceSW::Clear(GSTexture* t, uint32 c)
|
||||||
{
|
{
|
||||||
int h = t->GetHeight();
|
|
||||||
int w = t->GetWidth();
|
int w = t->GetWidth();
|
||||||
|
int h = t->GetHeight();
|
||||||
|
|
||||||
GSTexture::GSMap m;
|
GSTexture::GSMap m;
|
||||||
|
|
||||||
|
@ -146,13 +182,16 @@ void GSDeviceSW::Clear(GSTexture* t, uint32 c)
|
||||||
{
|
{
|
||||||
GSVector4i v((int)c);
|
GSVector4i v((int)c);
|
||||||
|
|
||||||
uint8* p = m.bits;
|
w >>= 2;
|
||||||
|
|
||||||
for(int j = 0; j < h; j++, p += m.pitch)
|
for(int j = 0; j < h; j++, m.bits += m.pitch)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < w; i += 4)
|
GSVector4i* RESTRICT dst = (GSVector4i*)m.bits;
|
||||||
|
|
||||||
|
for(int i = 0; i < w; i += 2)
|
||||||
{
|
{
|
||||||
*(GSVector4i*)&p[i] = v;
|
dst[i + 0] = v;
|
||||||
|
dst[i + 1] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,6 @@ public:
|
||||||
GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format = 0);
|
GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format = 0);
|
||||||
|
|
||||||
void CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r);
|
void CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r);
|
||||||
|
|
||||||
void StretchRect(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true);
|
|
||||||
void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true);
|
void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true);
|
||||||
|
|
||||||
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
|
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
|
||||||
|
|
|
@ -245,6 +245,13 @@ bool GSRenderer::Merge(int field)
|
||||||
|
|
||||||
if(tex[0] || tex[1])
|
if(tex[0] || tex[1])
|
||||||
{
|
{
|
||||||
|
if(tex[0] == tex[1] && !slbg && (src[0] == src[1] & dst[0] == dst[1]).alltrue())
|
||||||
|
{
|
||||||
|
// the two outputs are identical, skip drawing one of them (the one that is alpha blended)
|
||||||
|
|
||||||
|
tex[0] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
GSVector4 c = GSVector4((int)m_regs->BGCOLOR.R, (int)m_regs->BGCOLOR.G, (int)m_regs->BGCOLOR.B, (int)m_regs->PMODE.ALP) / 255;
|
GSVector4 c = GSVector4((int)m_regs->BGCOLOR.R, (int)m_regs->BGCOLOR.G, (int)m_regs->BGCOLOR.B, (int)m_regs->PMODE.ALP) / 255;
|
||||||
|
|
||||||
m_dev->Merge(tex, src, dst, fs, slbg, mmod, c);
|
m_dev->Merge(tex, src, dst, fs, slbg, mmod, c);
|
||||||
|
|
|
@ -1503,7 +1503,7 @@ template<int index> void GSState::Transfer(const uint8* mem, uint32 size)
|
||||||
// This can't happen; downloads can not be started or performed as part of
|
// This can't happen; downloads can not be started or performed as part of
|
||||||
// a GIFtag operation. They're an entirely separate process that can only be
|
// a GIFtag operation. They're an entirely separate process that can only be
|
||||||
// done through the ReverseFIFO transfer (aka ReadFIFO). --air
|
// done through the ReverseFIFO transfer (aka ReadFIFO). --air
|
||||||
ASSERT(false);
|
ASSERT(0);
|
||||||
//Read(mem, len * 16);
|
//Read(mem, len * 16);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -1548,7 +1548,7 @@ template<int index> void GSState::Transfer(const uint8* mem, uint32 size)
|
||||||
{
|
{
|
||||||
if(m_mt)
|
if(m_mt)
|
||||||
{
|
{
|
||||||
// Hackfix for BIOS, which sends an incomplete packek when it does an XGKICK without
|
// Hackfix for BIOS, which sends an incomplete packet when it does an XGKICK without
|
||||||
// having an EOP specified anywhere in VU1 memory. Needed until PCSX2 is fixed t
|
// having an EOP specified anywhere in VU1 memory. Needed until PCSX2 is fixed t
|
||||||
// handle it more properly (ie, without looping infinitely).
|
// handle it more properly (ie, without looping infinitely).
|
||||||
|
|
||||||
|
@ -1558,6 +1558,7 @@ template<int index> void GSState::Transfer(const uint8* mem, uint32 size)
|
||||||
{
|
{
|
||||||
// Unused in 0.9.7 and above, but might as well keep this for now; allows GSdx
|
// Unused in 0.9.7 and above, but might as well keep this for now; allows GSdx
|
||||||
// to work with legacy editions of PCSX2.
|
// to work with legacy editions of PCSX2.
|
||||||
|
|
||||||
Transfer<0>(mem - 0x4000, 0x4000 / 16);
|
Transfer<0>(mem - 0x4000, 0x4000 / 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,11 +63,13 @@ bool GSTextureSW::Update(const GSVector4i& r, const void* data, int pitch)
|
||||||
|
|
||||||
bool GSTextureSW::Map(GSMap& m, const GSVector4i* r)
|
bool GSTextureSW::Map(GSMap& m, const GSVector4i* r)
|
||||||
{
|
{
|
||||||
if(m_data != NULL && r->left >= 0 && r->right <= m_size.x && r->top >= 0 && r->bottom <= m_size.y)
|
GSVector4i r2 = r != NULL ? *r : GSVector4i(0, 0, m_size.x, m_size.y);
|
||||||
|
|
||||||
|
if(m_data != NULL && r2.left >= 0 && r2.right <= m_size.x && r2.top >= 0 && r2.bottom <= m_size.y)
|
||||||
{
|
{
|
||||||
if(!_interlockedbittestandset(&m_mapped, 0))
|
if(!_interlockedbittestandset(&m_mapped, 0))
|
||||||
{
|
{
|
||||||
m.bits = (uint8*)m_data + ((m_pitch * r->top + r->left) << 2);
|
m.bits = (uint8*)m_data + ((m_pitch * r2.top + r2.left) << 2);
|
||||||
m.pitch = m_pitch;
|
m.pitch = m_pitch;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -37,6 +37,14 @@
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <atlbase.h>
|
#include <atlbase.h>
|
||||||
|
#include <d3d11.h>
|
||||||
|
#include <d3dx11.h>
|
||||||
|
#include <d3d9.h>
|
||||||
|
#include <d3dx9.h>
|
||||||
|
|
||||||
|
#define D3DCOLORWRITEENABLE_RGBA (D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA)
|
||||||
|
#define D3D11_SHADER_MACRO D3D10_SHADER_MACRO
|
||||||
|
#define ID3D11Blob ID3D10Blob
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -173,25 +181,6 @@ typedef signed long long int64;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
|
|
||||||
// directx
|
|
||||||
|
|
||||||
#include <d3d11.h>
|
|
||||||
#include <d3dx11.h>
|
|
||||||
#include <d3d9.h>
|
|
||||||
#include <d3dx9.h>
|
|
||||||
|
|
||||||
#define D3DCOLORWRITEENABLE_RGBA (D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA)
|
|
||||||
|
|
||||||
#define USE_UPSCALE_HACKS // Hacks intended to fix upscaling / rendering glitches in HW renderers
|
|
||||||
|
|
||||||
// dxsdk is missing these:
|
|
||||||
#define D3D11_SHADER_MACRO D3D10_SHADER_MACRO
|
|
||||||
#define ID3D11Blob ID3D10Blob
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// sse
|
// sse
|
||||||
|
|
||||||
#if !defined(_M_SSE) && (!defined(_WINDOWS) || defined(_M_AMD64) || defined(_M_IX86_FP) && _M_IX86_FP >= 2)
|
#if !defined(_M_SSE) && (!defined(_WINDOWS) || defined(_M_AMD64) || defined(_M_IX86_FP) && _M_IX86_FP >= 2)
|
||||||
|
@ -315,3 +304,6 @@ __forceinline unsigned long long __rdtsc()
|
||||||
|
|
||||||
extern void* vmalloc(size_t size, bool code);
|
extern void* vmalloc(size_t size, bool code);
|
||||||
extern void vmfree(void* ptr, size_t size);
|
extern void vmfree(void* ptr, size_t size);
|
||||||
|
|
||||||
|
#define USE_UPSCALE_HACKS // Hacks intended to fix upscaling / rendering glitches in HW renderers
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue