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"
#pragma pack(push, 1)
__aligned(class, 32) GPUDrawingEnvironment
{
public:
@ -74,6 +72,4 @@ public:
{
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))
{
Recycle(m_merge);
m_merge = CreateRenderTarget(fs.x, fs.y, false);
}

View File

@ -1,161 +1,200 @@
/*
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "GSDeviceSW.h"
bool GSDeviceSW::Create(GSWnd* wnd)
{
if(!GSDevice::Create(wnd))
return false;
Reset(1, 1);
return true;
}
bool GSDeviceSW::Reset(int w, int h)
{
if(!GSDevice::Reset(w, h))
return false;
return true;
}
void GSDeviceSW::Flip()
{
}
GSTexture* GSDeviceSW::Create(int type, int w, int h, bool msaa, int format)
{
if(format != 0) return false; // there is only one format
return new GSTextureSW(type, w, h);
}
void GSDeviceSW::BeginScene()
{
// TODO
}
void GSDeviceSW::DrawPrimitive()
{
// TODO
}
void GSDeviceSW::EndScene()
{
// TODO
}
void GSDeviceSW::ClearRenderTarget(GSTexture* t, const GSVector4& c)
{
Clear(t, c.rgba32());
}
void GSDeviceSW::ClearRenderTarget(GSTexture* t, uint32 c)
{
Clear(t, c);
}
void GSDeviceSW::ClearDepth(GSTexture* t, float c)
{
Clear(t, *(uint32*)&c);
}
void GSDeviceSW::ClearStencil(GSTexture* t, uint8 c)
{
Clear(t, c);
}
GSTexture* GSDeviceSW::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format)
{
// TODO
return NULL;
}
void GSDeviceSW::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r)
{
// TODO
}
void GSDeviceSW::StretchRect(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader, bool linear)
{
// TODO
}
void GSDeviceSW::StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader, bool linear)
{
// TODO
}
void GSDeviceSW::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1)
{
// TODO
}
void GSDeviceSW::PSSetShaderResource(int i, GSTexture* sr)
{
// TODO
}
void GSDeviceSW::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor)
{
// TODO
}
//
void GSDeviceSW::DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c)
{
// TODO
}
void GSDeviceSW::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset)
{
// TODO
}
void GSDeviceSW::Clear(GSTexture* t, uint32 c)
{
int h = t->GetHeight();
int w = t->GetWidth();
GSTexture::GSMap m;
if(t->Map(m, NULL))
{
GSVector4i v((int)c);
uint8* p = m.bits;
for(int j = 0; j < h; j++, p += m.pitch)
{
for(int i = 0; i < w; i += 4)
{
*(GSVector4i*)&p[i] = v;
}
}
t->Unmap();
}
}
/*
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "GSDeviceSW.h"
GSDeviceSW::GSDeviceSW()
{
}
bool GSDeviceSW::Create(GSWnd* wnd)
{
if(!GSDevice::Create(wnd))
return false;
Reset(1, 1);
return true;
}
bool GSDeviceSW::Reset(int w, int h)
{
if(!GSDevice::Reset(w, h))
return false;
m_backbuffer = new GSTextureSW(GSTexture::RenderTarget, w, h);
return true;
}
void GSDeviceSW::Flip()
{
// TODO: derived class should present m_backbuffer here
}
GSTexture* GSDeviceSW::Create(int type, int w, int h, bool msaa, int format)
{
if(format != 0) return false; // there is only one format
return new GSTextureSW(type, w, h);
}
void GSDeviceSW::BeginScene()
{
// TODO
}
void GSDeviceSW::DrawPrimitive()
{
// TODO
}
void GSDeviceSW::EndScene()
{
// TODO
}
void GSDeviceSW::ClearRenderTarget(GSTexture* t, const GSVector4& c)
{
Clear(t, (c * 255 + 0.5f).rgba32());
}
void GSDeviceSW::ClearRenderTarget(GSTexture* t, uint32 c)
{
Clear(t, c);
}
void GSDeviceSW::ClearDepth(GSTexture* t, float c)
{
Clear(t, *(uint32*)&c);
}
void GSDeviceSW::ClearStencil(GSTexture* t, uint8 c)
{
Clear(t, c);
}
GSTexture* GSDeviceSW::CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format)
{
GSTexture* dst = CreateOffscreen(w, h, format);
if(dst != NULL)
{
CopyRect(src, dst, GSVector4i(0, 0, w, h));
}
return dst;
}
void GSDeviceSW::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r)
{
GSTexture::GSMap m;
if(st->Map(m, &r))
{
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)
{
// TODO: only used to stretch m_current to m_backbuffer, no blending needed (yet)
}
void GSDeviceSW::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1)
{
// TODO
}
void GSDeviceSW::PSSetShaderResource(int i, GSTexture* sr)
{
// TODO
}
void GSDeviceSW::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor)
{
// TODO
}
//
void GSDeviceSW::DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c)
{
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)
{
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
* http://www.gabest.org
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#pragma once
#include "GSDevice.h"
#include "GSTextureSW.h"
class GSDeviceSW : public GSDevice
{
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 DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0);
void Clear(GSTexture* t, uint32 c);
public:
GSDeviceSW();
bool Create(GSWnd* wnd);
bool Reset(int w, int h);
void Flip();
// drawing may be routed through here, the software renderers use the rasterizer directly now
void BeginScene();
void DrawPrimitive();
void EndScene();
void ClearRenderTarget(GSTexture* t, const GSVector4& c);
void ClearRenderTarget(GSTexture* t, uint32 c);
void ClearDepth(GSTexture* t, float c);
void ClearStencil(GSTexture* t, uint8 c);
GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format = 0);
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 PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
void PSSetShaderResource(int i, GSTexture* sr);
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
};
/*
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#pragma once
#include "GSDevice.h"
#include "GSTextureSW.h"
class GSDeviceSW : public GSDevice
{
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 DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0);
void Clear(GSTexture* t, uint32 c);
public:
GSDeviceSW();
bool Create(GSWnd* wnd);
bool Reset(int w, int h);
void Flip();
// drawing may be routed through here, the software renderers use the rasterizer directly now
void BeginScene();
void DrawPrimitive();
void EndScene();
void ClearRenderTarget(GSTexture* t, const GSVector4& c);
void ClearRenderTarget(GSTexture* t, uint32 c);
void ClearDepth(GSTexture* t, float c);
void ClearStencil(GSTexture* t, uint8 c);
GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format = 0);
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 PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
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] && !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;
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
// a GIFtag operation. They're an entirely separate process that can only be
// done through the ReverseFIFO transfer (aka ReadFIFO). --air
ASSERT(false);
ASSERT(0);
//Read(mem, len * 16);
break;
case 2:
@ -1548,7 +1548,7 @@ template<int index> void GSState::Transfer(const uint8* mem, uint32 size)
{
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
// handle it more properly (ie, without looping infinitely).
@ -1556,8 +1556,9 @@ template<int index> void GSState::Transfer(const uint8* mem, uint32 size)
}
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.
Transfer<0>(mem - 0x4000, 0x4000 / 16);
}
}

View File

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

View File

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

View File

@ -37,6 +37,14 @@
#include <commdlg.h>
#include <shellapi.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
@ -173,25 +181,6 @@ typedef signed long long int64;
#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
#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 vmfree(void* ptr, size_t size);
#define USE_UPSCALE_HACKS // Hacks intended to fix upscaling / rendering glitches in HW renderers