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:
gabest11 2011-02-20 22:33:22 +00:00
parent b62d4801ac
commit eeb9757e94
9 changed files with 491 additions and 455 deletions

View File

@ -23,8 +23,6 @@
#include "GPU.h" #include "GPU.h"
#pragma pack(push, 1)
__aligned(class, 32) GPUDrawingEnvironment __aligned(class, 32) GPUDrawingEnvironment
{ {
public: public:
@ -74,6 +72,4 @@ public:
{ {
return STATUS.ISPAL ? 50 : 60; return STATUS.ISPAL ? 50 : 60;
} }
}; };
#pragma pack(pop)

View File

@ -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);
} }

View File

@ -1,161 +1,200 @@
/* /*
* Copyright (C) 2007-2009 Gabest * Copyright (C) 2007-2009 Gabest
* http://www.gabest.org * http://www.gabest.org
* *
* This Program is free software; you can redistribute it and/or modify * This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option) * the Free Software Foundation; either version 2, or (at your option)
* any later version. * any later version.
* *
* This Program is distributed in the hope that it will be useful, * This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to * along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html * http://www.gnu.org/copyleft/gpl.html
* *
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "GSDeviceSW.h" #include "GSDeviceSW.h"
bool GSDeviceSW::Create(GSWnd* wnd) GSDeviceSW::GSDeviceSW()
{ {
if(!GSDevice::Create(wnd)) }
return false;
bool GSDeviceSW::Create(GSWnd* wnd)
Reset(1, 1); {
if(!GSDevice::Create(wnd))
return true; return false;
}
Reset(1, 1);
bool GSDeviceSW::Reset(int w, int h)
{ return true;
if(!GSDevice::Reset(w, h)) }
return false;
bool GSDeviceSW::Reset(int w, int h)
return true; {
} if(!GSDevice::Reset(w, h))
return false;
void GSDeviceSW::Flip()
{ m_backbuffer = new GSTextureSW(GSTexture::RenderTarget, w, h);
}
return true;
GSTexture* GSDeviceSW::Create(int type, int w, int h, bool msaa, int format) }
{
if(format != 0) return false; // there is only one format void GSDeviceSW::Flip()
{
return new GSTextureSW(type, w, h); // TODO: derived class should present m_backbuffer here
} }
void GSDeviceSW::BeginScene() GSTexture* GSDeviceSW::Create(int type, int w, int h, bool msaa, int format)
{ {
// TODO if(format != 0) return false; // there is only one format
}
return new GSTextureSW(type, w, h);
void GSDeviceSW::DrawPrimitive() }
{
// TODO void GSDeviceSW::BeginScene()
} {
// TODO
void GSDeviceSW::EndScene() }
{
// TODO void GSDeviceSW::DrawPrimitive()
} {
// TODO
void GSDeviceSW::ClearRenderTarget(GSTexture* t, const GSVector4& c) }
{
Clear(t, c.rgba32()); void GSDeviceSW::EndScene()
} {
// TODO
void GSDeviceSW::ClearRenderTarget(GSTexture* t, uint32 c) }
{
Clear(t, c); void GSDeviceSW::ClearRenderTarget(GSTexture* t, const GSVector4& c)
} {
Clear(t, (c * 255 + 0.5f).rgba32());
void GSDeviceSW::ClearDepth(GSTexture* t, float c) }
{
Clear(t, *(uint32*)&c); void GSDeviceSW::ClearRenderTarget(GSTexture* t, uint32 c)
} {
Clear(t, c);
void GSDeviceSW::ClearStencil(GSTexture* t, uint8 c) }
{
Clear(t, c); void GSDeviceSW::ClearDepth(GSTexture* t, float c)
} {
Clear(t, *(uint32*)&c);
GSTexture* GSDeviceSW::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format) }
{
// TODO void GSDeviceSW::ClearStencil(GSTexture* t, uint8 c)
{
return NULL; Clear(t, c);
} }
void GSDeviceSW::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) GSTexture* GSDeviceSW::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format)
{ {
// TODO GSTexture* dst = CreateOffscreen(w, h, format);
}
if(dst != NULL)
void GSDeviceSW::StretchRect(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader, bool linear) {
{ CopyRect(src, dst, GSVector4i(0, 0, w, h));
// TODO }
}
return dst;
void GSDeviceSW::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear) }
{
// TODO void GSDeviceSW::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r)
} {
GSTexture::GSMap m;
void GSDeviceSW::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1)
{ if(st->Map(m, &r))
// TODO {
} dt->Update(r, m.bits, m.pitch);
void GSDeviceSW::PSSetShaderResource(int i, GSTexture* sr) st->Unmap();
{ }
// TODO }
}
void GSDeviceSW::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear)
void GSDeviceSW::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor) {
{ // TODO: only used to stretch m_current to m_backbuffer, no blending needed (yet)
// TODO }
}
void GSDeviceSW::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1)
// {
// TODO
void GSDeviceSW::DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c) }
{
// TODO void GSDeviceSW::PSSetShaderResource(int i, GSTexture* sr)
} {
// TODO
void GSDeviceSW::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset) }
{
// TODO void GSDeviceSW::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor)
} {
// TODO
void GSDeviceSW::Clear(GSTexture* t, uint32 c) }
{
int h = t->GetHeight(); //
int w = t->GetWidth();
void GSDeviceSW::DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c)
GSTexture::GSMap m; {
ClearRenderTarget(dt, c);
if(t->Map(m, NULL))
{ if(st[1] && !slbg)
GSVector4i v((int)c); {
// TODO: copy (StretchRect)
uint8* p = m.bits; }
for(int j = 0; j < h; j++, p += m.pitch) if(st[0])
{ {
for(int i = 0; i < w; i += 4) // TODO: blend
{ //
*(GSVector4i*)&p[i] = v; // mmod 0 => alpha = min(st[0].a * 2, 1)
} // mmod 1 => alpha = c.a
} }
}
t->Unmap();
} 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
//
// 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)
{
int w = t->GetWidth();
int h = t->GetHeight();
GSTexture::GSMap m;
if(t->Map(m, NULL))
{
GSVector4i v((int)c);
w >>= 2;
for(int j = 0; j < h; j++, m.bits += m.pitch)
{
GSVector4i* RESTRICT dst = (GSVector4i*)m.bits;
for(int i = 0; i < w; i += 2)
{
dst[i + 0] = v;
dst[i + 1] = v;
}
}
t->Unmap();
}
}

View File

@ -1,64 +1,62 @@
/* /*
* Copyright (C) 2007-2009 Gabest * Copyright (C) 2007-2009 Gabest
* http://www.gabest.org * http://www.gabest.org
* *
* This Program is free software; you can redistribute it and/or modify * This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option) * the Free Software Foundation; either version 2, or (at your option)
* any later version. * any later version.
* *
* This Program is distributed in the hope that it will be useful, * This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to * along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html * http://www.gnu.org/copyleft/gpl.html
* *
*/ */
#pragma once #pragma once
#include "GSDevice.h" #include "GSDevice.h"
#include "GSTextureSW.h" #include "GSTextureSW.h"
class GSDeviceSW : public GSDevice class GSDeviceSW : public GSDevice
{ {
GSTexture* Create(int type, int w, int h, bool msaa, int format); GSTexture* Create(int type, int w, int h, bool msaa, int format);
void DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c); void DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c);
void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0); void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0);
void Clear(GSTexture* t, uint32 c); void Clear(GSTexture* t, uint32 c);
public: public:
GSDeviceSW(); GSDeviceSW();
bool Create(GSWnd* wnd); bool Create(GSWnd* wnd);
bool Reset(int w, int h); bool Reset(int w, int h);
void Flip(); void Flip();
// drawing may be routed through here, the software renderers use the rasterizer directly now // drawing may be routed through here, the software renderers use the rasterizer directly now
void BeginScene(); void BeginScene();
void DrawPrimitive(); void DrawPrimitive();
void EndScene(); void EndScene();
void ClearRenderTarget(GSTexture* t, const GSVector4& c); void ClearRenderTarget(GSTexture* t, const GSVector4& c);
void ClearRenderTarget(GSTexture* t, uint32 c); void ClearRenderTarget(GSTexture* t, uint32 c);
void ClearDepth(GSTexture* t, float c); void ClearDepth(GSTexture* t, float c);
void ClearStencil(GSTexture* t, uint8 c); void ClearStencil(GSTexture* t, uint8 c);
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, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true);
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 PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
void PSSetShaderResource(int i, GSTexture* sr);
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
void PSSetShaderResource(int i, GSTexture* sr); };
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
};

View File

@ -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);

View File

@ -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).
@ -1556,8 +1556,9 @@ template<int index> void GSState::Transfer(const uint8* mem, uint32 size)
} }
else else
{ {
// 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);
} }
} }

View File

@ -1,166 +1,168 @@
/* /*
* Copyright (C) 2007-2009 Gabest * Copyright (C) 2007-2009 Gabest
* http://www.gabest.org * http://www.gabest.org
* *
* This Program is free software; you can redistribute it and/or modify * This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option) * the Free Software Foundation; either version 2, or (at your option)
* any later version. * any later version.
* *
* This Program is distributed in the hope that it will be useful, * This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to * along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html * http://www.gnu.org/copyleft/gpl.html
* *
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "GSTextureSW.h" #include "GSTextureSW.h"
GSTextureSW::GSTextureSW(int type, int width, int height) GSTextureSW::GSTextureSW(int type, int width, int height)
: m_mapped(0) : m_mapped(0)
{ {
m_size = GSVector2i(width, height); m_size = GSVector2i(width, height);
m_type = type; m_type = type;
m_format = 0; m_format = 0;
m_pitch = ((width << 2) + 31) & ~31; m_pitch = ((width << 2) + 31) & ~31;
m_data = _aligned_malloc(m_pitch * height, 32); m_data = _aligned_malloc(m_pitch * height, 32);
} }
GSTextureSW::~GSTextureSW() GSTextureSW::~GSTextureSW()
{ {
_aligned_free(m_data); _aligned_free(m_data);
} }
bool GSTextureSW::Update(const GSVector4i& r, const void* data, int pitch) bool GSTextureSW::Update(const GSVector4i& r, const void* data, int pitch)
{ {
GSMap m; GSMap m;
if(m_data != NULL && Map(m, &r)) if(m_data != NULL && Map(m, &r))
{ {
uint8* RESTRICT src = (uint8*)data; uint8* RESTRICT src = (uint8*)data;
uint8* RESTRICT dst = m.bits; uint8* RESTRICT dst = m.bits;
int rowbytes = r.width() << 2; int rowbytes = r.width() << 2;
for(int h = r.height(); h > 0; h--, src += pitch, dst += m.pitch) for(int h = r.height(); h > 0; h--, src += pitch, dst += m.pitch)
{ {
memcpy(dst, src, rowbytes); memcpy(dst, src, rowbytes);
} }
Unmap(); Unmap();
return true; return true;
} }
return false; return false;
} }
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(!_interlockedbittestandset(&m_mapped, 0)) if(m_data != NULL && r2.left >= 0 && r2.right <= m_size.x && r2.top >= 0 && r2.bottom <= m_size.y)
{ {
m.bits = (uint8*)m_data + ((m_pitch * r->top + r->left) << 2); if(!_interlockedbittestandset(&m_mapped, 0))
m.pitch = m_pitch; {
m.bits = (uint8*)m_data + ((m_pitch * r2.top + r2.left) << 2);
return true; m.pitch = m_pitch;
}
} return true;
}
return false; }
}
return false;
void GSTextureSW::Unmap() }
{
m_mapped = 0; void GSTextureSW::Unmap()
} {
m_mapped = 0;
#ifndef _WINDOWS }
#pragma pack(push, 1) #ifndef _WINDOWS
struct BITMAPFILEHEADER #pragma pack(push, 1)
{
uint16 bfType; struct BITMAPFILEHEADER
uint32 bfSize; {
uint16 bfReserved1; uint16 bfType;
uint16 bfReserved2; uint32 bfSize;
uint32 bfOffBits; uint16 bfReserved1;
}; uint16 bfReserved2;
uint32 bfOffBits;
struct BITMAPINFOHEADER };
{
uint32 biSize; struct BITMAPINFOHEADER
int32 biWidth; {
int32 biHeight; uint32 biSize;
uint16 biPlanes; int32 biWidth;
uint16 biBitCount; int32 biHeight;
uint32 biCompression; uint16 biPlanes;
uint32 biSizeImage; uint16 biBitCount;
int32 biXPelsPerMeter; uint32 biCompression;
int32 biYPelsPerMeter; uint32 biSizeImage;
uint32 biClrUsed; int32 biXPelsPerMeter;
uint32 biClrImportant; int32 biYPelsPerMeter;
}; uint32 biClrUsed;
uint32 biClrImportant;
};
#define BI_RGB 0 #define BI_RGB 0
#pragma pack(pop) #pragma pack(pop)
#endif #endif
bool GSTextureSW::Save(const string& fn, bool dds) bool GSTextureSW::Save(const string& fn, bool dds)
{ {
if(dds) return false; // not implemented if(dds) return false; // not implemented
if(FILE* fp = fopen(fn.c_str(), "wb")) if(FILE* fp = fopen(fn.c_str(), "wb"))
{ {
BITMAPINFOHEADER bih; BITMAPINFOHEADER bih;
memset(&bih, 0, sizeof(bih)); memset(&bih, 0, sizeof(bih));
bih.biSize = sizeof(bih); bih.biSize = sizeof(bih);
bih.biWidth = m_size.x; bih.biWidth = m_size.x;
bih.biHeight = m_size.y; bih.biHeight = m_size.y;
bih.biPlanes = 1; bih.biPlanes = 1;
bih.biBitCount = 32; bih.biBitCount = 32;
bih.biCompression = BI_RGB; bih.biCompression = BI_RGB;
bih.biSizeImage = m_size.x * m_size.y << 2; bih.biSizeImage = m_size.x * m_size.y << 2;
BITMAPFILEHEADER bfh; BITMAPFILEHEADER bfh;
memset(&bfh, 0, sizeof(bfh)); memset(&bfh, 0, sizeof(bfh));
uint8* bfType = (uint8*)bfh.bfType; uint8* bfType = (uint8*)bfh.bfType;
// bfh.bfType = 'MB'; // bfh.bfType = 'MB';
bfType[0] = 0x42; bfType[0] = 0x42;
bfType[1] = 0x4d; bfType[1] = 0x4d;
bfh.bfOffBits = sizeof(bfh) + sizeof(bih); bfh.bfOffBits = sizeof(bfh) + sizeof(bih);
bfh.bfSize = bfh.bfOffBits + bih.biSizeImage; bfh.bfSize = bfh.bfOffBits + bih.biSizeImage;
bfh.bfReserved1 = bfh.bfReserved2 = 0; bfh.bfReserved1 = bfh.bfReserved2 = 0;
fwrite(&bfh, 1, sizeof(bfh), fp); fwrite(&bfh, 1, sizeof(bfh), fp);
fwrite(&bih, 1, sizeof(bih), fp); fwrite(&bih, 1, sizeof(bih), fp);
uint8* data = (uint8*)m_data + (m_size.y - 1) * m_pitch; uint8* data = (uint8*)m_data + (m_size.y - 1) * m_pitch;
for(int h = m_size.y; h > 0; h--, data -= m_pitch) for(int h = m_size.y; h > 0; h--, data -= m_pitch)
{ {
fwrite(data, 1, m_size.x << 2, fp); // TODO: swap red-blue? fwrite(data, 1, m_size.x << 2, fp); // TODO: swap red-blue?
} }
fclose(fp); fclose(fp);
return true; return true;
} }
return false; return false;
} }

View File

@ -1,42 +1,42 @@
/* /*
* Copyright (C) 2007-2009 Gabest * Copyright (C) 2007-2009 Gabest
* http://www.gabest.org * http://www.gabest.org
* *
* This Program is free software; you can redistribute it and/or modify * This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option) * the Free Software Foundation; either version 2, or (at your option)
* any later version. * any later version.
* *
* This Program is distributed in the hope that it will be useful, * This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to * along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html * http://www.gnu.org/copyleft/gpl.html
* *
*/ */
#pragma once #pragma once
#include "GSTexture.h" #include "GSTexture.h"
class GSTextureSW : public GSTexture class GSTextureSW : public GSTexture
{ {
// mem texture, always 32-bit rgba (might add 8-bit for palette if needed) // mem texture, always 32-bit rgba (might add 8-bit for palette if needed)
int m_pitch; int m_pitch;
void* m_data; void* m_data;
long m_mapped; long m_mapped;
public: public:
GSTextureSW(int type, int width, int height); GSTextureSW(int type, int width, int height);
virtual ~GSTextureSW(); virtual ~GSTextureSW();
bool Update(const GSVector4i& r, const void* data, int pitch); bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(GSMap& m, const GSVector4i* r); bool Map(GSMap& m, const GSVector4i* r);
void Unmap(); void Unmap();
bool Save(const string& fn, bool dds = false); bool Save(const string& fn, bool dds = false);
}; };

View File

@ -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