mirror of https://github.com/PCSX2/pcsx2.git
GSopen2: Fixed GSdx so that it complies with the implied intent of the PS2E plugin API, where GSopen and GSclose retain the current GS emulation state. This required a couple significant changes:
* Removed GSTextureFX classes * Built shaders right into GSState classes, using GSStateDX as an interface, so that all shader caches get auto-destroyed along with GSState. In addition to being a bit of a code cleanup, it should be a bit more efficient too since all of the extra dereferences to GSState from GSTextureFX have been removed. :) git-svn-id: http://pcsx2.googlecode.com/svn/branches/GSopen2@1849 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
cc1bc8d122
commit
e4c0dfb6d3
|
@ -37,6 +37,8 @@ GPURendererSW::~GPURendererSW()
|
|||
|
||||
void GPURendererSW::ResetDevice()
|
||||
{
|
||||
__super::ResetDevice();
|
||||
|
||||
delete m_texture;
|
||||
|
||||
m_texture = NULL;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
GSDevice10::GSDevice10()
|
||||
{
|
||||
memset(&m_state, 0, sizeof(m_state));
|
||||
memset(&m_vs_cb_cache, 0, sizeof(m_vs_cb_cache));
|
||||
memset(&m_ps_cb_cache, 0, sizeof(m_ps_cb_cache));
|
||||
|
||||
m_state.topology = D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED;
|
||||
m_state.bf = -1;
|
||||
|
@ -226,6 +228,8 @@ bool GSDevice10::Create(GSWnd* wnd, bool vsync)
|
|||
|
||||
//
|
||||
|
||||
CreateTextureFX();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "GSDevice.h"
|
||||
#include "GSDeviceDX.h"
|
||||
#include "GSTexture10.h"
|
||||
|
||||
class GSDevice10 : public GSDevice
|
||||
class GSDevice10 : public GSDeviceDX
|
||||
{
|
||||
GSTexture* Create(int type, int w, int h, bool msaa, int format);
|
||||
|
||||
|
@ -88,11 +88,27 @@ public: // TODO
|
|||
CComPtr<ID3D10Buffer> cb;
|
||||
} m_interlace;
|
||||
|
||||
CComPtr<ID3D10InputLayout> m_il;
|
||||
hash_map<uint32, CComPtr<ID3D10VertexShader> > m_vs;
|
||||
CComPtr<ID3D10Buffer> m_vs_cb;
|
||||
hash_map<uint32, CComPtr<ID3D10GeometryShader> > m_gs;
|
||||
hash_map<uint32, CComPtr<ID3D10PixelShader> > m_ps;
|
||||
CComPtr<ID3D10Buffer> m_ps_cb;
|
||||
hash_map<uint32, CComPtr<ID3D10SamplerState> > m_ps_ss;
|
||||
CComPtr<ID3D10SamplerState> m_palette_ss;
|
||||
// hash_map<uint32, CComPtr<ID3D10DepthStencilState> > m_om_dss;
|
||||
CComPtr<ID3D10DepthStencilState> m_om_dss[32];
|
||||
hash_map<uint32, CComPtr<ID3D10BlendState> > m_om_bs;
|
||||
|
||||
VSConstantBuffer m_vs_cb_cache;
|
||||
PSConstantBuffer m_ps_cb_cache;
|
||||
|
||||
public:
|
||||
GSDevice10();
|
||||
virtual ~GSDevice10();
|
||||
|
||||
bool Create(GSWnd* wnd, bool vsync);
|
||||
bool CreateTextureFX();
|
||||
bool Reset(int w, int h, int mode);
|
||||
void Flip(bool limit);
|
||||
|
||||
|
@ -131,6 +147,12 @@ public:
|
|||
void OMSetBlendState(ID3D10BlendState* bs, float bf);
|
||||
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
|
||||
|
||||
void SetupIA(const void* vertices, int count, int prim);
|
||||
void SetupVS(VSSelector sel, const VSConstantBuffer* cb);
|
||||
void SetupGS(GSSelector sel);
|
||||
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
|
||||
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
||||
|
||||
ID3D10Device* operator->() {return m_dev;}
|
||||
operator ID3D10Device*() {return m_dev;}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
GSDevice11::GSDevice11()
|
||||
{
|
||||
memset(&m_state, 0, sizeof(m_state));
|
||||
memset(&m_vs_cb_cache, 0, sizeof(m_vs_cb_cache));
|
||||
memset(&m_ps_cb_cache, 0, sizeof(m_ps_cb_cache));
|
||||
|
||||
m_state.topology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED;
|
||||
m_state.bf = -1;
|
||||
|
@ -225,6 +227,7 @@ bool GSDevice11::Create(GSWnd* wnd, bool vsync)
|
|||
|
||||
//
|
||||
|
||||
CreateTextureFX();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "GSDevice.h"
|
||||
#include "GSDeviceDX.h"
|
||||
#include "GSTexture11.h"
|
||||
|
||||
class GSDevice11 : public GSDevice
|
||||
class GSDevice11 : public GSDeviceDX
|
||||
{
|
||||
GSTexture* Create(int type, int w, int h, bool msaa, int format);
|
||||
|
||||
|
@ -89,11 +89,28 @@ public: // TODO
|
|||
CComPtr<ID3D11Buffer> cb;
|
||||
} m_interlace;
|
||||
|
||||
// Shaders...
|
||||
|
||||
CComPtr<ID3D11InputLayout> m_il;
|
||||
hash_map<uint32, CComPtr<ID3D11VertexShader> > m_vs;
|
||||
CComPtr<ID3D11Buffer> m_vs_cb;
|
||||
hash_map<uint32, CComPtr<ID3D11GeometryShader> > m_gs;
|
||||
hash_map<uint32, CComPtr<ID3D11PixelShader> > m_ps;
|
||||
CComPtr<ID3D11Buffer> m_ps_cb;
|
||||
hash_map<uint32, CComPtr<ID3D11SamplerState> > m_ps_ss;
|
||||
CComPtr<ID3D11SamplerState> m_palette_ss;
|
||||
hash_map<uint32, CComPtr<ID3D11DepthStencilState> > m_om_dss;
|
||||
hash_map<uint32, CComPtr<ID3D11BlendState> > m_om_bs;
|
||||
|
||||
VSConstantBuffer m_vs_cb_cache;
|
||||
PSConstantBuffer m_ps_cb_cache;
|
||||
|
||||
public:
|
||||
GSDevice11();
|
||||
virtual ~GSDevice11();
|
||||
|
||||
bool Create(GSWnd* wnd, bool vsync);
|
||||
bool CreateTextureFX();
|
||||
bool Reset(int w, int h, int mode);
|
||||
void Flip(bool limit);
|
||||
|
||||
|
@ -132,6 +149,12 @@ public:
|
|||
void OMSetBlendState(ID3D11BlendState* bs, float bf);
|
||||
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
|
||||
|
||||
void SetupIA(const void* vertices, int count, int prim);
|
||||
void SetupVS(VSSelector sel, const VSConstantBuffer* cb);
|
||||
void SetupGS(GSSelector sel);
|
||||
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
|
||||
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
||||
|
||||
ID3D11Device* operator->() {return m_dev;}
|
||||
operator ID3D11Device*() {return m_dev;}
|
||||
operator ID3D11DeviceContext*() {return m_ctx;}
|
||||
|
|
|
@ -40,6 +40,8 @@ GSDevice9::GSDevice9()
|
|||
|
||||
GSDevice9::~GSDevice9()
|
||||
{
|
||||
for_each(m_mskfix.begin(), m_mskfix.end(), delete_second());
|
||||
|
||||
if(m_state.vs_cb) _aligned_free(m_state.vs_cb);
|
||||
if(m_state.ps_cb) _aligned_free(m_state.ps_cb);
|
||||
}
|
||||
|
@ -208,7 +210,12 @@ bool GSDevice9::Create(GSWnd* wnd, bool vsync)
|
|||
CompileShader(IDR_INTERLACE_FX, format("ps_main%d", i), NULL, &m_interlace.ps[i]);
|
||||
}
|
||||
|
||||
//
|
||||
// create shader layout
|
||||
|
||||
VSSelector sel;
|
||||
VSConstantBuffer cb;
|
||||
|
||||
SetupVS(sel, &cb);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "GSDevice.h"
|
||||
#include "GSDeviceDX.h"
|
||||
#include "GSTexture9.h"
|
||||
|
||||
struct Direct3DSamplerState9
|
||||
|
@ -59,7 +59,7 @@ struct Direct3DBlendState9
|
|||
UINT8 RenderTargetWriteMask;
|
||||
};
|
||||
|
||||
class GSDevice9 : public GSDevice
|
||||
class GSDevice9 : public GSDeviceDX
|
||||
{
|
||||
GSTexture* Create(int type, int w, int h, bool msaa, int format);
|
||||
|
||||
|
@ -124,6 +124,19 @@ public: // TODO
|
|||
CComPtr<IDirect3DPixelShader9> ps[4];
|
||||
} m_interlace;
|
||||
|
||||
// Shaders...
|
||||
|
||||
CComPtr<IDirect3DVertexDeclaration9> m_il;
|
||||
hash_map<uint32, CComPtr<IDirect3DVertexShader9> > m_vs;
|
||||
D3DXHANDLE m_vs_params;
|
||||
hash_map<uint32, CComPtr<IDirect3DPixelShader9> > m_ps;
|
||||
hash_map<uint32, Direct3DSamplerState9* > m_ps_ss;
|
||||
hash_map<uint32, Direct3DDepthStencilState9* > m_om_dss;
|
||||
hash_map<uint32, Direct3DBlendState9* > m_om_bs;
|
||||
hash_map<uint32, GSTexture*> m_mskfix;
|
||||
|
||||
GSTexture* CreateMskFix(uint32 size, uint32 msk, uint32 fix);
|
||||
|
||||
public:
|
||||
GSDevice9();
|
||||
virtual ~GSDevice9();
|
||||
|
@ -174,4 +187,10 @@ public:
|
|||
|
||||
HRESULT CompileShader(uint32 id, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il);
|
||||
HRESULT CompileShader(uint32 id, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps);
|
||||
|
||||
void SetupIA(const void* vertices, int count, int prim);
|
||||
void SetupVS(VSSelector sel, const VSConstantBuffer* cb);
|
||||
void SetupGS(GSSelector sel) {}
|
||||
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
|
||||
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
||||
};
|
||||
|
|
|
@ -1,286 +1,283 @@
|
|||
/*
|
||||
* 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 "GSVector.h"
|
||||
#include "GSDevice.h"
|
||||
#include "GSAlignedClass.h"
|
||||
|
||||
class GSTextureFX : public GSAlignedClass<16>
|
||||
{
|
||||
public:
|
||||
#pragma pack(push, 1)
|
||||
|
||||
enum
|
||||
{
|
||||
FMT_32,
|
||||
FMT_24,
|
||||
FMT_16,
|
||||
FMT_8H,
|
||||
FMT_4HL,
|
||||
FMT_4HH,
|
||||
FMT_8,
|
||||
};
|
||||
|
||||
__declspec(align(16)) struct VSConstantBuffer
|
||||
{
|
||||
GSVector4 VertexScale;
|
||||
GSVector4 VertexOffset;
|
||||
GSVector4 TextureScale;
|
||||
|
||||
struct VSConstantBuffer()
|
||||
{
|
||||
VertexScale = GSVector4::zero();
|
||||
VertexOffset = GSVector4::zero();
|
||||
TextureScale = GSVector4::zero();
|
||||
}
|
||||
|
||||
__forceinline bool Update(const VSConstantBuffer* cb)
|
||||
{
|
||||
GSVector4i* a = (GSVector4i*)this;
|
||||
GSVector4i* b = (GSVector4i*)cb;
|
||||
|
||||
GSVector4i b0 = b[0];
|
||||
GSVector4i b1 = b[1];
|
||||
GSVector4i b2 = b[2];
|
||||
|
||||
if(!((a[0] == b0) & (a[1] == b1) & (a[2] == b2)).alltrue())
|
||||
{
|
||||
a[0] = b0;
|
||||
a[1] = b1;
|
||||
a[2] = b2;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct VSSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 bppz:2;
|
||||
uint32 tme:1;
|
||||
uint32 fst:1;
|
||||
uint32 logz:1;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x1f;}
|
||||
|
||||
VSSelector() : key(0) {}
|
||||
};
|
||||
|
||||
__declspec(align(16)) struct PSConstantBuffer
|
||||
{
|
||||
GSVector4 FogColor_AREF;
|
||||
GSVector4 HalfTexel;
|
||||
GSVector4 WH;
|
||||
GSVector4 MinMax;
|
||||
GSVector4 MinF_TA;
|
||||
GSVector4i MskFix;
|
||||
|
||||
struct PSConstantBuffer()
|
||||
{
|
||||
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)
|
||||
{
|
||||
GSVector4i* a = (GSVector4i*)this;
|
||||
GSVector4i* b = (GSVector4i*)cb;
|
||||
|
||||
GSVector4i b0 = b[0];
|
||||
GSVector4i b1 = b[1];
|
||||
GSVector4i b2 = b[2];
|
||||
GSVector4i b3 = b[3];
|
||||
GSVector4i b4 = b[4];
|
||||
GSVector4i b5 = b[5];
|
||||
|
||||
if(!((a[0] == b0) /*& (a[1] == b1)*/ & (a[2] == b2) & (a[3] == b3) & (a[4] == b4) & (a[5] == b5)).alltrue()) // if WH matches HalfTexel does too
|
||||
{
|
||||
a[0] = b0;
|
||||
a[1] = b1;
|
||||
a[2] = b2;
|
||||
a[3] = b3;
|
||||
a[4] = b4;
|
||||
a[5] = b5;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct GSSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 iip:1;
|
||||
uint32 prim:2;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x7;}
|
||||
|
||||
GSSelector() : key(0) {}
|
||||
};
|
||||
|
||||
struct PSSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 fst:1;
|
||||
uint32 wms:2;
|
||||
uint32 wmt:2;
|
||||
uint32 fmt:3;
|
||||
uint32 aem:1;
|
||||
uint32 tfx:3;
|
||||
uint32 tcc:1;
|
||||
uint32 atst:3;
|
||||
uint32 fog:1;
|
||||
uint32 clr1:1;
|
||||
uint32 fba:1;
|
||||
uint32 aout:1;
|
||||
uint32 rt:1;
|
||||
uint32 ltf:1;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x3fffff;}
|
||||
|
||||
PSSelector() : key(0) {}
|
||||
};
|
||||
|
||||
struct PSSamplerSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 tau:1;
|
||||
uint32 tav:1;
|
||||
uint32 ltf:1;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x7;}
|
||||
|
||||
PSSamplerSelector() : key(0) {}
|
||||
};
|
||||
|
||||
struct OMDepthStencilSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 ztst:2;
|
||||
uint32 zwe:1;
|
||||
uint32 date:1;
|
||||
uint32 fba:1;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x1f;}
|
||||
|
||||
OMDepthStencilSelector() : key(0) {}
|
||||
};
|
||||
|
||||
struct OMBlendSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 abe:1;
|
||||
uint32 a:2;
|
||||
uint32 b:2;
|
||||
uint32 c:2;
|
||||
uint32 d:2;
|
||||
uint32 wr:1;
|
||||
uint32 wg:1;
|
||||
uint32 wb:1;
|
||||
uint32 wa:1;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 _pad:1;
|
||||
uint32 abcd:8;
|
||||
uint32 wrgba:4;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x1fff;}
|
||||
|
||||
OMBlendSelector() : key(0) {}
|
||||
|
||||
bool IsCLR1() const
|
||||
{
|
||||
return (key & 0x19f) == 0x93; // abe == 1 && a == 1 && b == 2 && d == 1
|
||||
}
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
protected:
|
||||
GSDevice* m_dev;
|
||||
|
||||
public:
|
||||
GSTextureFX();
|
||||
virtual ~GSTextureFX() {}
|
||||
|
||||
virtual bool Create(GSDevice* dev);
|
||||
|
||||
virtual void SetupIA(const void* vertices, int count, int prim) = 0;
|
||||
virtual void SetupVS(VSSelector sel, const VSConstantBuffer* cb) = 0;
|
||||
virtual void SetupGS(GSSelector sel) = 0;
|
||||
virtual void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel) = 0;
|
||||
virtual void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix) = 0;
|
||||
};
|
||||
/*
|
||||
* 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 "GSVector.h"
|
||||
#include "GSDevice.h"
|
||||
#include "GSAlignedClass.h"
|
||||
|
||||
class GSDeviceDX : public GSDevice
|
||||
{
|
||||
public:
|
||||
#pragma pack(push, 1)
|
||||
|
||||
__declspec(align(16)) struct VSConstantBuffer
|
||||
{
|
||||
GSVector4 VertexScale;
|
||||
GSVector4 VertexOffset;
|
||||
GSVector4 TextureScale;
|
||||
|
||||
struct VSConstantBuffer()
|
||||
{
|
||||
VertexScale = GSVector4::zero();
|
||||
VertexOffset = GSVector4::zero();
|
||||
TextureScale = GSVector4::zero();
|
||||
}
|
||||
|
||||
__forceinline bool Update(const VSConstantBuffer* cb)
|
||||
{
|
||||
GSVector4i* a = (GSVector4i*)this;
|
||||
GSVector4i* b = (GSVector4i*)cb;
|
||||
|
||||
GSVector4i b0 = b[0];
|
||||
GSVector4i b1 = b[1];
|
||||
GSVector4i b2 = b[2];
|
||||
|
||||
if(!((a[0] == b0) & (a[1] == b1) & (a[2] == b2)).alltrue())
|
||||
{
|
||||
a[0] = b0;
|
||||
a[1] = b1;
|
||||
a[2] = b2;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct VSSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 bppz:2;
|
||||
uint32 tme:1;
|
||||
uint32 fst:1;
|
||||
uint32 logz:1;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x1f;}
|
||||
|
||||
VSSelector() : key(0) {}
|
||||
};
|
||||
|
||||
__declspec(align(16)) struct PSConstantBuffer
|
||||
{
|
||||
GSVector4 FogColor_AREF;
|
||||
GSVector4 HalfTexel;
|
||||
GSVector4 WH;
|
||||
GSVector4 MinMax;
|
||||
GSVector4 MinF_TA;
|
||||
GSVector4i MskFix;
|
||||
|
||||
struct PSConstantBuffer()
|
||||
{
|
||||
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)
|
||||
{
|
||||
GSVector4i* a = (GSVector4i*)this;
|
||||
GSVector4i* b = (GSVector4i*)cb;
|
||||
|
||||
GSVector4i b0 = b[0];
|
||||
GSVector4i b1 = b[1];
|
||||
GSVector4i b2 = b[2];
|
||||
GSVector4i b3 = b[3];
|
||||
GSVector4i b4 = b[4];
|
||||
GSVector4i b5 = b[5];
|
||||
|
||||
if(!((a[0] == b0) /*& (a[1] == b1)*/ & (a[2] == b2) & (a[3] == b3) & (a[4] == b4) & (a[5] == b5)).alltrue()) // if WH matches HalfTexel does too
|
||||
{
|
||||
a[0] = b0;
|
||||
a[1] = b1;
|
||||
a[2] = b2;
|
||||
a[3] = b3;
|
||||
a[4] = b4;
|
||||
a[5] = b5;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct GSSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 iip:1;
|
||||
uint32 prim:2;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x7;}
|
||||
|
||||
GSSelector() : key(0) {}
|
||||
};
|
||||
|
||||
struct PSSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 fst:1;
|
||||
uint32 wms:2;
|
||||
uint32 wmt:2;
|
||||
uint32 fmt:3;
|
||||
uint32 aem:1;
|
||||
uint32 tfx:3;
|
||||
uint32 tcc:1;
|
||||
uint32 atst:3;
|
||||
uint32 fog:1;
|
||||
uint32 clr1:1;
|
||||
uint32 fba:1;
|
||||
uint32 aout:1;
|
||||
uint32 rt:1;
|
||||
uint32 ltf:1;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x3fffff;}
|
||||
|
||||
PSSelector() : key(0) {}
|
||||
};
|
||||
|
||||
struct PSSamplerSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 tau:1;
|
||||
uint32 tav:1;
|
||||
uint32 ltf:1;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x7;}
|
||||
|
||||
PSSamplerSelector() : key(0) {}
|
||||
};
|
||||
|
||||
struct OMDepthStencilSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 ztst:2;
|
||||
uint32 zwe:1;
|
||||
uint32 date:1;
|
||||
uint32 fba:1;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x1f;}
|
||||
|
||||
OMDepthStencilSelector() : key(0) {}
|
||||
};
|
||||
|
||||
struct OMBlendSelector
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32 abe:1;
|
||||
uint32 a:2;
|
||||
uint32 b:2;
|
||||
uint32 c:2;
|
||||
uint32 d:2;
|
||||
uint32 wr:1;
|
||||
uint32 wg:1;
|
||||
uint32 wb:1;
|
||||
uint32 wa:1;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
uint32 _pad:1;
|
||||
uint32 abcd:8;
|
||||
uint32 wrgba:4;
|
||||
};
|
||||
|
||||
uint32 key;
|
||||
};
|
||||
|
||||
operator uint32() {return key & 0x1fff;}
|
||||
|
||||
OMBlendSelector() : key(0) {}
|
||||
|
||||
bool IsCLR1() const
|
||||
{
|
||||
return (key & 0x19f) == 0x93; // abe == 1 && a == 1 && b == 2 && d == 1
|
||||
}
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
public:
|
||||
GSDeviceDX() {};
|
||||
virtual ~GSDeviceDX() {}
|
||||
|
||||
virtual bool Create(GSWnd* wnd, bool vsync)
|
||||
{
|
||||
return __super::Create( wnd, vsync );
|
||||
}
|
||||
|
||||
virtual bool Reset(int w, int h, int mode)
|
||||
{
|
||||
return __super::Reset( w, h, mode );
|
||||
}
|
||||
|
||||
//virtual void Present(const GSVector4i& r, int shader, bool limit);
|
||||
//virtual void Flip(bool limit) {}
|
||||
|
||||
virtual void SetupIA(const void* vertices, int count, int prim) = 0;
|
||||
virtual void SetupVS(VSSelector sel, const VSConstantBuffer* cb) = 0;
|
||||
virtual void SetupGS(GSSelector sel) = 0;
|
||||
virtual void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel) = 0;
|
||||
virtual void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix) = 0;
|
||||
};
|
|
@ -32,7 +32,7 @@ GSDialog::GSDialog(UINT id)
|
|||
|
||||
INT_PTR GSDialog::DoModal()
|
||||
{
|
||||
return DialogBoxParam(theApp.GetModuleHandle(), MAKEINTRESOURCE(m_id), NULL, DialogProc, (LPARAM)this);
|
||||
return DialogBoxParam(theApp.GetModuleHandle(), MAKEINTRESOURCE(m_id), GetActiveWindow(), DialogProc, (LPARAM)this);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK GSDialog::DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
|
|
@ -74,7 +74,11 @@ public:
|
|||
|
||||
virtual bool CreateWnd(const string& title, int w, int h);
|
||||
virtual bool CreateDevice(GSDevice* dev);
|
||||
virtual void ResetDevice() {}
|
||||
virtual void ResetDevice()
|
||||
{
|
||||
InvalidateTextureCache();
|
||||
ResetPrim();
|
||||
}
|
||||
virtual void VSync(int field);
|
||||
virtual bool MakeSnapshot(const string& path);
|
||||
virtual void KeyEvent(GSKeyEventData* e, int param = 0);
|
||||
|
|
|
@ -22,12 +22,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "GSRendererHW.h"
|
||||
#include "GSTextureFX.h"
|
||||
//#include "GSTextureFX.h"
|
||||
|
||||
template<class Vertex>
|
||||
class GSRendererDX : public GSRendererHW<Vertex>
|
||||
{
|
||||
GSTextureFX* m_tfx;
|
||||
GSVector2 m_pixelcenter;
|
||||
bool m_logz;
|
||||
bool m_fba;
|
||||
|
@ -41,9 +40,8 @@ protected:
|
|||
virtual void UpdateFBA(GSTexture* rt) {}
|
||||
|
||||
public:
|
||||
GSRendererDX(uint8* base, bool mt, void (*irq)(), GSTextureCache* tc, GSTextureFX* tfx, const GSVector2& pixelcenter = GSVector2(0, 0))
|
||||
GSRendererDX(uint8* base, bool mt, void (*irq)(), GSTextureCache* tc, const GSVector2& pixelcenter = GSVector2(0, 0))
|
||||
: GSRendererHW<Vertex>(base, mt, irq, tc)
|
||||
, m_tfx(tfx)
|
||||
, m_pixelcenter(pixelcenter)
|
||||
, m_topology(-1)
|
||||
{
|
||||
|
@ -55,7 +53,6 @@ public:
|
|||
|
||||
virtual ~GSRendererDX()
|
||||
{
|
||||
delete m_tfx;
|
||||
}
|
||||
|
||||
bool CreateDevice(GSDevice* dev)
|
||||
|
@ -63,28 +60,27 @@ public:
|
|||
if(!__super::CreateDevice(dev))
|
||||
return false;
|
||||
|
||||
if(!m_tfx->Create(m_dev))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex)
|
||||
__forceinline void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex)
|
||||
{
|
||||
GSDrawingEnvironment& env = m_env;
|
||||
GSDrawingContext* context = m_context;
|
||||
|
||||
GSDeviceDX& dev = (GSDeviceDX&)*m_dev;
|
||||
|
||||
//
|
||||
|
||||
SetupDATE(rt, ds);
|
||||
|
||||
//
|
||||
|
||||
m_dev->BeginScene();
|
||||
dev.BeginScene();
|
||||
|
||||
// om
|
||||
|
||||
GSTextureFX::OMDepthStencilSelector om_dssel;
|
||||
GSDeviceDX::OMDepthStencilSelector om_dssel;
|
||||
|
||||
if(context->TEST.ZTE)
|
||||
{
|
||||
|
@ -106,7 +102,7 @@ public:
|
|||
om_dssel.fba = context->FBA.FBA;
|
||||
}
|
||||
|
||||
GSTextureFX::OMBlendSelector om_bsel;
|
||||
GSDeviceDX::OMBlendSelector om_bsel;
|
||||
|
||||
if(!IsOpaque())
|
||||
{
|
||||
|
@ -137,7 +133,7 @@ public:
|
|||
|
||||
// vs
|
||||
|
||||
GSTextureFX::VSSelector vs_sel;
|
||||
GSDeviceDX::VSSelector vs_sel;
|
||||
|
||||
vs_sel.tme = PRIM->TME;
|
||||
vs_sel.fst = PRIM->FST;
|
||||
|
@ -167,7 +163,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
GSTextureFX::VSConstantBuffer vs_cb;
|
||||
GSDeviceDX::VSConstantBuffer vs_cb;
|
||||
|
||||
float sx = 2.0f * rt->GetScale().x / (rt->GetWidth() << 4);
|
||||
float sy = 2.0f * rt->GetScale().y / (rt->GetHeight() << 4);
|
||||
|
@ -181,16 +177,16 @@ public:
|
|||
|
||||
// gs
|
||||
|
||||
GSTextureFX::GSSelector gs_sel;
|
||||
GSDeviceDX::GSSelector gs_sel;
|
||||
|
||||
gs_sel.iip = PRIM->IIP;
|
||||
gs_sel.prim = m_vt.m_primclass;
|
||||
|
||||
// ps
|
||||
|
||||
GSTextureFX::PSSelector ps_sel;
|
||||
GSTextureFX::PSSamplerSelector ps_ssel;
|
||||
GSTextureFX::PSConstantBuffer ps_cb;
|
||||
GSDeviceDX::PSSelector ps_sel;
|
||||
GSDeviceDX::PSSamplerSelector ps_ssel;
|
||||
GSDeviceDX::PSConstantBuffer ps_cb;
|
||||
|
||||
ps_sel.clr1 = om_bsel.IsCLR1();
|
||||
ps_sel.fba = context->FBA.FBA;
|
||||
|
@ -274,22 +270,22 @@ public:
|
|||
|
||||
GSVector4i scissor = GSVector4i(GSVector4(rt->GetScale()).xyxy() * context->scissor.in).rintersect(GSVector4i(rt->GetSize()).zwxy());
|
||||
|
||||
m_dev->OMSetRenderTargets(rt, ds, &scissor);
|
||||
m_dev->PSSetShaderResources(tex ? tex->m_texture : NULL, tex ? tex->m_palette : NULL);
|
||||
dev.OMSetRenderTargets(rt, ds, &scissor);
|
||||
dev.PSSetShaderResources(tex ? tex->m_texture : NULL, tex ? tex->m_palette : NULL);
|
||||
|
||||
uint8 afix = context->ALPHA.FIX;
|
||||
|
||||
m_tfx->SetupOM(om_dssel, om_bsel, afix);
|
||||
m_tfx->SetupIA(m_vertices, m_count, m_topology);
|
||||
m_tfx->SetupVS(vs_sel, &vs_cb);
|
||||
m_tfx->SetupGS(gs_sel);
|
||||
m_tfx->SetupPS(ps_sel, &ps_cb, ps_ssel);
|
||||
dev.SetupOM(om_dssel, om_bsel, afix);
|
||||
dev.SetupIA(m_vertices, m_count, m_topology);
|
||||
dev.SetupVS(vs_sel, &vs_cb);
|
||||
dev.SetupGS(gs_sel);
|
||||
dev.SetupPS(ps_sel, &ps_cb, ps_ssel);
|
||||
|
||||
// draw
|
||||
|
||||
if(context->TEST.DoFirstPass())
|
||||
{
|
||||
m_dev->DrawPrimitive();
|
||||
dev.DrawPrimitive();
|
||||
}
|
||||
|
||||
if(context->TEST.DoSecondPass())
|
||||
|
@ -313,7 +309,7 @@ public:
|
|||
break;
|
||||
}
|
||||
|
||||
m_tfx->SetupPS(ps_sel, &ps_cb, ps_ssel);
|
||||
dev.SetupPS(ps_sel, &ps_cb, ps_ssel);
|
||||
|
||||
bool z = om_dssel.zwe;
|
||||
bool r = om_bsel.wr;
|
||||
|
@ -338,13 +334,13 @@ public:
|
|||
om_bsel.wb = b;
|
||||
om_bsel.wa = a;
|
||||
|
||||
m_tfx->SetupOM(om_dssel, om_bsel, afix);
|
||||
dev.SetupOM(om_dssel, om_bsel, afix);
|
||||
|
||||
m_dev->DrawPrimitive();
|
||||
dev.DrawPrimitive();
|
||||
}
|
||||
}
|
||||
|
||||
m_dev->EndScene();
|
||||
dev.EndScene();
|
||||
|
||||
if(om_dssel.fba) UpdateFBA(rt);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "resource.h"
|
||||
|
||||
GSRendererDX10::GSRendererDX10(uint8* base, bool mt, void (*irq)())
|
||||
: GSRendererDX<GSVertexHW10>(base, mt, irq, new GSTextureCache10(this), new GSTextureFX10(), GSVector2(-0.5f, -0.5f))
|
||||
: GSRendererDX<GSVertexHW10>(base, mt, irq, new GSTextureCache10(this), GSVector2(-0.5f, -0.5f))
|
||||
{
|
||||
InitVertexKick<GSRendererDX10>();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "GSRendererDX.h"
|
||||
#include "GSVertexHW.h"
|
||||
#include "GSTextureCache10.h"
|
||||
#include "GSTextureFX10.h"
|
||||
|
||||
class GSRendererDX10 : public GSRendererDX<GSVertexHW10>
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "resource.h"
|
||||
|
||||
GSRendererDX11::GSRendererDX11(uint8* base, bool mt, void (*irq)())
|
||||
: GSRendererDX<GSVertexHW11>(base, mt, irq, new GSTextureCache11(this), new GSTextureFX11(), GSVector2(-0.5f, -0.5f))
|
||||
: GSRendererDX<GSVertexHW11>(base, mt, irq, new GSTextureCache11(this), GSVector2(-0.5f, -0.5f))
|
||||
{
|
||||
InitVertexKick<GSRendererDX11>();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "GSRendererDX.h"
|
||||
#include "GSVertexHW.h"
|
||||
#include "GSTextureCache11.h"
|
||||
#include "GSTextureFX11.h"
|
||||
|
||||
class GSRendererDX11 : public GSRendererDX<GSVertexHW11>
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "resource.h"
|
||||
|
||||
GSRendererDX9::GSRendererDX9(uint8* base, bool mt, void (*irq)())
|
||||
: GSRendererDX<GSVertexHW9>(base, mt, irq, new GSTextureCache9(this), new GSTextureFX9())
|
||||
: GSRendererDX<GSVertexHW9>(base, mt, irq, new GSTextureCache9(this))
|
||||
{
|
||||
InitVertexKick<GSRendererDX9>();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "GSRendererDX.h"
|
||||
#include "GSVertexHW.h"
|
||||
#include "GSTextureCache9.h"
|
||||
#include "GSTextureFX9.h"
|
||||
|
||||
class GSRendererDX9 : public GSRendererDX<GSVertexHW9>
|
||||
{
|
||||
|
|
|
@ -478,6 +478,7 @@ protected:
|
|||
|
||||
void ResetDevice()
|
||||
{
|
||||
__super::ResetDevice();
|
||||
m_tc->RemoveAll();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "GSRendererHW.h"
|
||||
#include "GSVertexHW.h"
|
||||
#include "GSTextureCacheOGL.h"
|
||||
// TODO: #include "GSTextureFXOGL.h"
|
||||
|
||||
class GSRendererOGL : public GSRendererHW<GSVertexOGL>
|
||||
{
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "StdAfx.h"
|
||||
#include "GSTextureCache.h"
|
||||
#include "GSTextureFX.h"
|
||||
|
||||
GSTextureCache::GSTextureCache(GSRenderer* r)
|
||||
: m_renderer(r)
|
||||
|
@ -497,14 +496,14 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
|
|||
{
|
||||
if(m_paltex && GSLocalMemory::m_psm[TEX0.PSM].pal > 0)
|
||||
{
|
||||
src->m_fmt = GSTextureFX::FMT_8;
|
||||
src->m_fmt = FMT_8;
|
||||
|
||||
src->m_texture = m_renderer->m_dev->CreateTexture(tw, th, Get8bitFormat());
|
||||
src->m_palette = m_renderer->m_dev->CreateTexture(256, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
src->m_fmt = GSTextureFX::FMT_32;
|
||||
src->m_fmt = FMT_32;
|
||||
|
||||
src->m_texture = m_renderer->m_dev->CreateTexture(tw, th);
|
||||
}
|
||||
|
@ -650,25 +649,25 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
|
|||
default:
|
||||
ASSERT(0);
|
||||
case PSM_PSMCT32:
|
||||
src->m_fmt = GSTextureFX::FMT_32;
|
||||
src->m_fmt = FMT_32;
|
||||
break;
|
||||
case PSM_PSMCT24:
|
||||
src->m_fmt = GSTextureFX::FMT_24;
|
||||
src->m_fmt = FMT_24;
|
||||
break;
|
||||
case PSM_PSMCT16:
|
||||
case PSM_PSMCT16S:
|
||||
src->m_fmt = GSTextureFX::FMT_16;
|
||||
src->m_fmt = FMT_16;
|
||||
break;
|
||||
case PSM_PSMT8H:
|
||||
src->m_fmt = GSTextureFX::FMT_8H;
|
||||
src->m_fmt = FMT_8H;
|
||||
src->m_palette = m_renderer->m_dev->CreateTexture(256, 1);
|
||||
break;
|
||||
case PSM_PSMT4HL:
|
||||
src->m_fmt = GSTextureFX::FMT_4HL;
|
||||
src->m_fmt = FMT_4HL;
|
||||
src->m_palette = m_renderer->m_dev->CreateTexture(256, 1);
|
||||
break;
|
||||
case PSM_PSMT4HH:
|
||||
src->m_fmt = GSTextureFX::FMT_4HH;
|
||||
src->m_fmt = FMT_4HH;
|
||||
src->m_palette = m_renderer->m_dev->CreateTexture(256, 1);
|
||||
break;
|
||||
}
|
||||
|
@ -863,7 +862,7 @@ void GSTextureCache::Source::Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TE
|
|||
}
|
||||
}
|
||||
|
||||
m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, bs.x * bs.y * blocks << (m_fmt == GSTextureFX::FMT_32 ? 2 : 0));
|
||||
m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, bs.x * bs.y * blocks << (m_fmt == FMT_32 ? 2 : 0));
|
||||
|
||||
Flush(m_write.count);
|
||||
}
|
||||
|
@ -922,7 +921,7 @@ void GSTextureCache::Source::Flush(uint32 count)
|
|||
|
||||
GSLocalMemory::readTexture rtx = psm.rtx;
|
||||
|
||||
if(m_fmt == GSTextureFX::FMT_8)
|
||||
if(m_fmt == FMT_8)
|
||||
{
|
||||
pitch >>= 2;
|
||||
rtx = psm.rtxP;
|
||||
|
|
|
@ -28,6 +28,17 @@ class GSTextureCache
|
|||
public:
|
||||
enum {RenderTarget, DepthStencil};
|
||||
|
||||
enum TextureFormatType
|
||||
{
|
||||
FMT_32,
|
||||
FMT_24,
|
||||
FMT_16,
|
||||
FMT_8H,
|
||||
FMT_4HL,
|
||||
FMT_4HH,
|
||||
FMT_8,
|
||||
};
|
||||
|
||||
class Surface : public GSAlignedClass<16>
|
||||
{
|
||||
protected:
|
||||
|
|
|
@ -20,22 +20,11 @@
|
|||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GSTextureFX10.h"
|
||||
#include "GSDevice10.h"
|
||||
#include "resource.h"
|
||||
|
||||
GSTextureFX10::GSTextureFX10()
|
||||
bool GSDevice10::CreateTextureFX()
|
||||
{
|
||||
memset(&m_vs_cb_cache, 0, sizeof(m_vs_cb_cache));
|
||||
memset(&m_ps_cb_cache, 0, sizeof(m_ps_cb_cache));
|
||||
}
|
||||
|
||||
bool GSTextureFX10::Create(GSDevice* dev)
|
||||
{
|
||||
if(!__super::Create(dev))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
D3D10_BUFFER_DESC bd;
|
||||
|
@ -46,7 +35,7 @@ bool GSTextureFX10::Create(GSDevice* dev)
|
|||
bd.Usage = D3D10_USAGE_DEFAULT;
|
||||
bd.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
|
||||
|
||||
hr = (*(GSDevice10*)dev)->CreateBuffer(&bd, NULL, &m_vs_cb);
|
||||
hr = m_dev->CreateBuffer(&bd, NULL, &m_vs_cb);
|
||||
|
||||
if(FAILED(hr)) return false;
|
||||
|
||||
|
@ -56,7 +45,7 @@ bool GSTextureFX10::Create(GSDevice* dev)
|
|||
bd.Usage = D3D10_USAGE_DEFAULT;
|
||||
bd.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
|
||||
|
||||
hr = (*(GSDevice10*)dev)->CreateBuffer(&bd, NULL, &m_ps_cb);
|
||||
hr = m_dev->CreateBuffer(&bd, NULL, &m_ps_cb);
|
||||
|
||||
if(FAILED(hr)) return false;
|
||||
|
||||
|
@ -72,7 +61,7 @@ bool GSTextureFX10::Create(GSDevice* dev)
|
|||
sd.MaxAnisotropy = 16;
|
||||
sd.ComparisonFunc = D3D10_COMPARISON_NEVER;
|
||||
|
||||
hr = (*(GSDevice10*)dev)->CreateSamplerState(&sd, &m_palette_ss);
|
||||
hr = m_dev->CreateSamplerState(&sd, &m_palette_ss);
|
||||
|
||||
if(FAILED(hr)) return false;
|
||||
|
||||
|
@ -82,25 +71,19 @@ bool GSTextureFX10::Create(GSDevice* dev)
|
|||
VSConstantBuffer cb;
|
||||
|
||||
SetupVS(sel, &cb);
|
||||
|
||||
//
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GSTextureFX10::SetupIA(const void* vertices, int count, int prim)
|
||||
void GSDevice10::SetupIA(const void* vertices, int count, int prim)
|
||||
{
|
||||
GSDevice10* dev = (GSDevice10*)m_dev;
|
||||
|
||||
dev->IASetVertexBuffer(vertices, sizeof(GSVertexHW10), count);
|
||||
dev->IASetInputLayout(m_il);
|
||||
dev->IASetPrimitiveTopology((D3D10_PRIMITIVE_TOPOLOGY)prim);
|
||||
IASetVertexBuffer(vertices, sizeof(GSVertexHW10), count);
|
||||
IASetInputLayout(m_il);
|
||||
IASetPrimitiveTopology((D3D10_PRIMITIVE_TOPOLOGY)prim);
|
||||
}
|
||||
|
||||
void GSTextureFX10::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
||||
void GSDevice10::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
||||
{
|
||||
GSDevice10* dev = (GSDevice10*)m_dev;
|
||||
|
||||
hash_map<uint32, CComPtr<ID3D10VertexShader> >::const_iterator i = m_vs.find(sel);
|
||||
|
||||
if(i == m_vs.end())
|
||||
|
@ -132,7 +115,7 @@ void GSTextureFX10::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
CComPtr<ID3D10InputLayout> il;
|
||||
CComPtr<ID3D10VertexShader> vs;
|
||||
|
||||
dev->CompileShader(IDR_TFX_FX, "vs_main", macro, &vs, layout, countof(layout), &il);
|
||||
CompileShader(IDR_TFX_FX, "vs_main", macro, &vs, layout, countof(layout), &il);
|
||||
|
||||
if(m_il == NULL)
|
||||
{
|
||||
|
@ -146,16 +129,14 @@ void GSTextureFX10::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
|
||||
if(m_vs_cb_cache.Update(cb))
|
||||
{
|
||||
(*dev)->UpdateSubresource(m_vs_cb, 0, NULL, cb, 0, 0);
|
||||
m_dev->UpdateSubresource(m_vs_cb, 0, NULL, cb, 0, 0);
|
||||
}
|
||||
|
||||
dev->VSSetShader(i->second, m_vs_cb);
|
||||
VSSetShader(i->second, m_vs_cb);
|
||||
}
|
||||
|
||||
void GSTextureFX10::SetupGS(GSSelector sel)
|
||||
void GSDevice10::SetupGS(GSSelector sel)
|
||||
{
|
||||
GSDevice10* dev = (GSDevice10*)m_dev;
|
||||
|
||||
ID3D10GeometryShader* gs = NULL;
|
||||
|
||||
if(sel.prim > 0 && (sel.iip == 0 || sel.prim == 3)) // geometry shader works in every case, but not needed
|
||||
|
@ -180,19 +161,17 @@ void GSTextureFX10::SetupGS(GSSelector sel)
|
|||
{NULL, NULL},
|
||||
};
|
||||
|
||||
dev->CompileShader(IDR_TFX_FX, "gs_main", macro, &gs);
|
||||
CompileShader(IDR_TFX_FX, "gs_main", macro, &gs);
|
||||
|
||||
m_gs[sel] = gs;
|
||||
}
|
||||
}
|
||||
|
||||
dev->GSSetShader(gs);
|
||||
GSSetShader(gs);
|
||||
}
|
||||
|
||||
void GSTextureFX10::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel)
|
||||
void GSDevice10::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel)
|
||||
{
|
||||
GSDevice10* dev = (GSDevice10*)m_dev;
|
||||
|
||||
hash_map<uint32, CComPtr<ID3D10PixelShader> >::const_iterator i = m_ps.find(sel);
|
||||
|
||||
if(i == m_ps.end())
|
||||
|
@ -233,7 +212,7 @@ void GSTextureFX10::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
|||
|
||||
CComPtr<ID3D10PixelShader> ps;
|
||||
|
||||
dev->CompileShader(IDR_TFX_FX, "ps_main", macro, &ps);
|
||||
CompileShader(IDR_TFX_FX, "ps_main", macro, &ps);
|
||||
|
||||
m_ps[sel] = ps;
|
||||
|
||||
|
@ -242,10 +221,10 @@ void GSTextureFX10::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
|||
|
||||
if(m_ps_cb_cache.Update(cb))
|
||||
{
|
||||
(*dev)->UpdateSubresource(m_ps_cb, 0, NULL, cb, 0, 0);
|
||||
m_dev->UpdateSubresource(m_ps_cb, 0, NULL, cb, 0, 0);
|
||||
}
|
||||
|
||||
dev->PSSetShader(i->second, m_ps_cb);
|
||||
PSSetShader(i->second, m_ps_cb);
|
||||
|
||||
ID3D10SamplerState* ss0 = NULL;
|
||||
ID3D10SamplerState* ss1 = NULL;
|
||||
|
@ -279,7 +258,7 @@ void GSTextureFX10::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
|||
sd.MaxAnisotropy = 16;
|
||||
sd.ComparisonFunc = D3D10_COMPARISON_NEVER;
|
||||
|
||||
(*dev)->CreateSamplerState(&sd, &ss0);
|
||||
m_dev->CreateSamplerState(&sd, &ss0);
|
||||
|
||||
m_ps_ss[ssel] = ss0;
|
||||
}
|
||||
|
@ -290,12 +269,11 @@ void GSTextureFX10::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
|||
}
|
||||
}
|
||||
|
||||
dev->PSSetSamplerState(ss0, ss1);
|
||||
PSSetSamplerState(ss0, ss1);
|
||||
}
|
||||
|
||||
void GSTextureFX10::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
|
||||
void GSDevice10::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
|
||||
{
|
||||
GSDevice10* dev = (GSDevice10*)m_dev;
|
||||
/*
|
||||
hash_map<uint32, CComPtr<ID3D10DepthStencilState> >::const_iterator i = m_om_dss.find(dssel);
|
||||
|
||||
|
@ -342,18 +320,18 @@ void GSTextureFX10::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
|
|||
/*
|
||||
CComPtr<ID3D10DepthStencilState> dss;
|
||||
|
||||
(*dev)->CreateDepthStencilState(&dsd, &dss);
|
||||
m_dev->CreateDepthStencilState(&dsd, &dss);
|
||||
|
||||
m_om_dss[dssel] = dss;
|
||||
|
||||
i = m_om_dss.find(dssel);
|
||||
*/
|
||||
(*dev)->CreateDepthStencilState(&dsd, &om_dss);
|
||||
m_dev->CreateDepthStencilState(&dsd, &om_dss);
|
||||
}
|
||||
|
||||
// dev->OMSetDepthStencilState(i->second, 1);
|
||||
// OMSetDepthStencilState(i->second, 1);
|
||||
|
||||
dev->OMSetDepthStencilState(om_dss, 1);
|
||||
OMSetDepthStencilState(om_dss, 1);
|
||||
|
||||
hash_map<uint32, CComPtr<ID3D10BlendState> >::const_iterator j = m_om_bs.find(bsel);
|
||||
|
||||
|
@ -487,12 +465,12 @@ void GSTextureFX10::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
|
|||
|
||||
CComPtr<ID3D10BlendState> bs;
|
||||
|
||||
(*dev)->CreateBlendState(&bd, &bs);
|
||||
m_dev->CreateBlendState(&bd, &bs);
|
||||
|
||||
m_om_bs[bsel] = bs;
|
||||
|
||||
j = m_om_bs.find(bsel);
|
||||
}
|
||||
|
||||
dev->OMSetBlendState(j->second, (float)(int)afix / 0x80);
|
||||
OMSetBlendState(j->second, (float)(int)afix / 0x80);
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* 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 "GSTextureFX.h"
|
||||
#include "GSDevice10.h"
|
||||
|
||||
class GSTextureFX10 : public GSTextureFX
|
||||
{
|
||||
CComPtr<ID3D10InputLayout> m_il;
|
||||
hash_map<uint32, CComPtr<ID3D10VertexShader> > m_vs;
|
||||
CComPtr<ID3D10Buffer> m_vs_cb;
|
||||
hash_map<uint32, CComPtr<ID3D10GeometryShader> > m_gs;
|
||||
hash_map<uint32, CComPtr<ID3D10PixelShader> > m_ps;
|
||||
CComPtr<ID3D10Buffer> m_ps_cb;
|
||||
hash_map<uint32, CComPtr<ID3D10SamplerState> > m_ps_ss;
|
||||
CComPtr<ID3D10SamplerState> m_palette_ss;
|
||||
// hash_map<uint32, CComPtr<ID3D10DepthStencilState> > m_om_dss;
|
||||
CComPtr<ID3D10DepthStencilState> m_om_dss[32];
|
||||
hash_map<uint32, CComPtr<ID3D10BlendState> > m_om_bs;
|
||||
|
||||
VSConstantBuffer m_vs_cb_cache;
|
||||
PSConstantBuffer m_ps_cb_cache;
|
||||
|
||||
public:
|
||||
GSTextureFX10();
|
||||
|
||||
bool Create(GSDevice* dev);
|
||||
|
||||
void SetupIA(const void* vertices, int count, int prim);
|
||||
void SetupVS(VSSelector sel, const VSConstantBuffer* cb);
|
||||
void SetupGS(GSSelector sel);
|
||||
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
|
||||
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
||||
};
|
|
@ -20,22 +20,11 @@
|
|||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GSTextureFX11.h"
|
||||
#include "GSDevice11.h"
|
||||
#include "resource.h"
|
||||
|
||||
GSTextureFX11::GSTextureFX11()
|
||||
bool GSDevice11::CreateTextureFX()
|
||||
{
|
||||
memset(&m_vs_cb_cache, 0, sizeof(m_vs_cb_cache));
|
||||
memset(&m_ps_cb_cache, 0, sizeof(m_ps_cb_cache));
|
||||
}
|
||||
|
||||
bool GSTextureFX11::Create(GSDevice* dev)
|
||||
{
|
||||
if(!__super::Create(dev))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
D3D11_BUFFER_DESC bd;
|
||||
|
@ -46,7 +35,7 @@ bool GSTextureFX11::Create(GSDevice* dev)
|
|||
bd.Usage = D3D11_USAGE_DEFAULT;
|
||||
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
|
||||
hr = (*(GSDevice11*)dev)->CreateBuffer(&bd, NULL, &m_vs_cb);
|
||||
hr = m_dev->CreateBuffer(&bd, NULL, &m_vs_cb);
|
||||
|
||||
if(FAILED(hr)) return false;
|
||||
|
||||
|
@ -56,7 +45,7 @@ bool GSTextureFX11::Create(GSDevice* dev)
|
|||
bd.Usage = D3D11_USAGE_DEFAULT;
|
||||
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
|
||||
hr = (*(GSDevice11*)dev)->CreateBuffer(&bd, NULL, &m_ps_cb);
|
||||
hr = m_dev->CreateBuffer(&bd, NULL, &m_ps_cb);
|
||||
|
||||
if(FAILED(hr)) return false;
|
||||
|
||||
|
@ -72,7 +61,7 @@ bool GSTextureFX11::Create(GSDevice* dev)
|
|||
sd.MaxAnisotropy = 16;
|
||||
sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
|
||||
hr = (*(GSDevice11*)dev)->CreateSamplerState(&sd, &m_palette_ss);
|
||||
hr = m_dev->CreateSamplerState(&sd, &m_palette_ss);
|
||||
|
||||
if(FAILED(hr)) return false;
|
||||
|
||||
|
@ -88,19 +77,15 @@ bool GSTextureFX11::Create(GSDevice* dev)
|
|||
return true;
|
||||
}
|
||||
|
||||
void GSTextureFX11::SetupIA(const void* vertices, int count, int prim)
|
||||
void GSDevice11::SetupIA(const void* vertices, int count, int prim)
|
||||
{
|
||||
GSDevice11* dev = (GSDevice11*)m_dev;
|
||||
|
||||
dev->IASetVertexBuffer(vertices, sizeof(GSVertexHW11), count);
|
||||
dev->IASetInputLayout(m_il);
|
||||
dev->IASetPrimitiveTopology((D3D11_PRIMITIVE_TOPOLOGY)prim);
|
||||
IASetVertexBuffer(vertices, sizeof(GSVertexHW11), count);
|
||||
IASetInputLayout(m_il);
|
||||
IASetPrimitiveTopology((D3D11_PRIMITIVE_TOPOLOGY)prim);
|
||||
}
|
||||
|
||||
void GSTextureFX11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
||||
void GSDevice11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
||||
{
|
||||
GSDevice11* dev = (GSDevice11*)m_dev;
|
||||
|
||||
hash_map<uint32, CComPtr<ID3D11VertexShader> >::const_iterator i = m_vs.find(sel);
|
||||
|
||||
if(i == m_vs.end())
|
||||
|
@ -132,7 +117,7 @@ void GSTextureFX11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
CComPtr<ID3D11InputLayout> il;
|
||||
CComPtr<ID3D11VertexShader> vs;
|
||||
|
||||
dev->CompileShader(IDR_TFX_FX, "vs_main", macro, &vs, layout, countof(layout), &il);
|
||||
CompileShader(IDR_TFX_FX, "vs_main", macro, &vs, layout, countof(layout), &il);
|
||||
|
||||
if(m_il == NULL)
|
||||
{
|
||||
|
@ -146,18 +131,16 @@ void GSTextureFX11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
|
||||
if(m_vs_cb_cache.Update(cb))
|
||||
{
|
||||
ID3D11DeviceContext* ctx = *dev;
|
||||
ID3D11DeviceContext* ctx = m_ctx;
|
||||
|
||||
ctx->UpdateSubresource(m_vs_cb, 0, NULL, cb, 0, 0);
|
||||
}
|
||||
|
||||
dev->VSSetShader(i->second, m_vs_cb);
|
||||
VSSetShader(i->second, m_vs_cb);
|
||||
}
|
||||
|
||||
void GSTextureFX11::SetupGS(GSSelector sel)
|
||||
void GSDevice11::SetupGS(GSSelector sel)
|
||||
{
|
||||
GSDevice11* dev = (GSDevice11*)m_dev;
|
||||
|
||||
ID3D11GeometryShader* gs = NULL;
|
||||
|
||||
if(sel.prim > 0 && (sel.iip == 0 || sel.prim == 3)) // geometry shader works in every case, but not needed
|
||||
|
@ -182,19 +165,17 @@ void GSTextureFX11::SetupGS(GSSelector sel)
|
|||
{NULL, NULL},
|
||||
};
|
||||
|
||||
dev->CompileShader(IDR_TFX_FX, "gs_main", macro, &gs);
|
||||
CompileShader(IDR_TFX_FX, "gs_main", macro, &gs);
|
||||
|
||||
m_gs[sel] = gs;
|
||||
}
|
||||
}
|
||||
|
||||
dev->GSSetShader(gs);
|
||||
GSSetShader(gs);
|
||||
}
|
||||
|
||||
void GSTextureFX11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel)
|
||||
void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel)
|
||||
{
|
||||
GSDevice11* dev = (GSDevice11*)m_dev;
|
||||
|
||||
hash_map<uint32, CComPtr<ID3D11PixelShader> >::const_iterator i = m_ps.find(sel);
|
||||
|
||||
if(i == m_ps.end())
|
||||
|
@ -235,7 +216,7 @@ void GSTextureFX11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
|||
|
||||
CComPtr<ID3D11PixelShader> ps;
|
||||
|
||||
dev->CompileShader(IDR_TFX_FX, "ps_main", macro, &ps);
|
||||
CompileShader(IDR_TFX_FX, "ps_main", macro, &ps);
|
||||
|
||||
m_ps[sel] = ps;
|
||||
|
||||
|
@ -244,12 +225,12 @@ void GSTextureFX11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
|||
|
||||
if(m_ps_cb_cache.Update(cb))
|
||||
{
|
||||
ID3D11DeviceContext* ctx = *dev;
|
||||
ID3D11DeviceContext* ctx = m_ctx;
|
||||
|
||||
ctx->UpdateSubresource(m_ps_cb, 0, NULL, cb, 0, 0);
|
||||
}
|
||||
|
||||
dev->PSSetShader(i->second, m_ps_cb);
|
||||
PSSetShader(i->second, m_ps_cb);
|
||||
|
||||
ID3D11SamplerState* ss0 = NULL;
|
||||
ID3D11SamplerState* ss1 = NULL;
|
||||
|
@ -283,7 +264,7 @@ void GSTextureFX11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
|||
sd.MaxAnisotropy = 16;
|
||||
sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
|
||||
(*dev)->CreateSamplerState(&sd, &ss0);
|
||||
m_dev->CreateSamplerState(&sd, &ss0);
|
||||
|
||||
m_ps_ss[ssel] = ss0;
|
||||
}
|
||||
|
@ -294,13 +275,11 @@ void GSTextureFX11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSample
|
|||
}
|
||||
}
|
||||
|
||||
dev->PSSetSamplerState(ss0, ss1);
|
||||
PSSetSamplerState(ss0, ss1);
|
||||
}
|
||||
|
||||
void GSTextureFX11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
|
||||
void GSDevice11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
|
||||
{
|
||||
GSDevice11* dev = (GSDevice11*)m_dev;
|
||||
|
||||
hash_map<uint32, CComPtr<ID3D11DepthStencilState> >::const_iterator i = m_om_dss.find(dssel);
|
||||
|
||||
if(i == m_om_dss.end())
|
||||
|
@ -341,14 +320,14 @@ void GSTextureFX11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
|
|||
|
||||
CComPtr<ID3D11DepthStencilState> dss;
|
||||
|
||||
(*dev)->CreateDepthStencilState(&dsd, &dss);
|
||||
m_dev->CreateDepthStencilState(&dsd, &dss);
|
||||
|
||||
m_om_dss[dssel] = dss;
|
||||
|
||||
i = m_om_dss.find(dssel);
|
||||
}
|
||||
|
||||
dev->OMSetDepthStencilState(i->second, 1);
|
||||
OMSetDepthStencilState(i->second, 1);
|
||||
|
||||
hash_map<uint32, CComPtr<ID3D11BlendState> >::const_iterator j = m_om_bs.find(bsel);
|
||||
|
||||
|
@ -482,12 +461,12 @@ void GSTextureFX11::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
|
|||
|
||||
CComPtr<ID3D11BlendState> bs;
|
||||
|
||||
(*dev)->CreateBlendState(&bd, &bs);
|
||||
m_dev->CreateBlendState(&bd, &bs);
|
||||
|
||||
m_om_bs[bsel] = bs;
|
||||
|
||||
j = m_om_bs.find(bsel);
|
||||
}
|
||||
|
||||
dev->OMSetBlendState(j->second, (float)(int)afix / 0x80);
|
||||
OMSetBlendState(j->second, (float)(int)afix / 0x80);
|
||||
}
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* 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 "GSTextureFX.h"
|
||||
#include "GSDevice11.h"
|
||||
|
||||
class GSTextureFX11 : public GSTextureFX
|
||||
{
|
||||
CComPtr<ID3D11InputLayout> m_il;
|
||||
hash_map<uint32, CComPtr<ID3D11VertexShader> > m_vs;
|
||||
CComPtr<ID3D11Buffer> m_vs_cb;
|
||||
hash_map<uint32, CComPtr<ID3D11GeometryShader> > m_gs;
|
||||
hash_map<uint32, CComPtr<ID3D11PixelShader> > m_ps;
|
||||
CComPtr<ID3D11Buffer> m_ps_cb;
|
||||
hash_map<uint32, CComPtr<ID3D11SamplerState> > m_ps_ss;
|
||||
CComPtr<ID3D11SamplerState> m_palette_ss;
|
||||
hash_map<uint32, CComPtr<ID3D11DepthStencilState> > m_om_dss;
|
||||
hash_map<uint32, CComPtr<ID3D11BlendState> > m_om_bs;
|
||||
|
||||
VSConstantBuffer m_vs_cb_cache;
|
||||
PSConstantBuffer m_ps_cb_cache;
|
||||
|
||||
public:
|
||||
GSTextureFX11();
|
||||
|
||||
bool Create(GSDevice* dev);
|
||||
|
||||
void SetupIA(const void* vertices, int count, int prim);
|
||||
void SetupVS(VSSelector sel, const VSConstantBuffer* cb);
|
||||
void SetupGS(GSSelector sel);
|
||||
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
|
||||
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
||||
};
|
|
@ -20,38 +20,11 @@
|
|||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GSTextureFX9.h"
|
||||
#include "GSDevice9.h"
|
||||
#include "resource.h"
|
||||
|
||||
GSTextureFX9::GSTextureFX9()
|
||||
{
|
||||
}
|
||||
|
||||
GSTextureFX9::~GSTextureFX9()
|
||||
{
|
||||
for_each(m_mskfix.begin(), m_mskfix.end(), delete_second());
|
||||
}
|
||||
|
||||
bool GSTextureFX9::Create(GSDevice* dev)
|
||||
{
|
||||
if(!__super::Create(dev))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// create layout
|
||||
|
||||
VSSelector sel;
|
||||
VSConstantBuffer cb;
|
||||
|
||||
SetupVS(sel, &cb);
|
||||
|
||||
//
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GSTexture* GSTextureFX9::CreateMskFix(uint32 size, uint32 msk, uint32 fix)
|
||||
GSTexture* GSDevice9::CreateMskFix(uint32 size, uint32 msk, uint32 fix)
|
||||
{
|
||||
GSTexture* t = NULL;
|
||||
|
||||
|
@ -65,7 +38,7 @@ GSTexture* GSTextureFX9::CreateMskFix(uint32 size, uint32 msk, uint32 fix)
|
|||
}
|
||||
else
|
||||
{
|
||||
t = m_dev->CreateTexture(size, 1, D3DFMT_R32F);
|
||||
t = CreateTexture(size, 1, D3DFMT_R32F);
|
||||
|
||||
if(t)
|
||||
{
|
||||
|
@ -88,20 +61,16 @@ GSTexture* GSTextureFX9::CreateMskFix(uint32 size, uint32 msk, uint32 fix)
|
|||
return t;
|
||||
}
|
||||
|
||||
void GSTextureFX9::SetupIA(const void* vertices, int count, int prim)
|
||||
void GSDevice9::SetupIA(const void* vertices, int count, int prim)
|
||||
{
|
||||
GSDevice9* dev = (GSDevice9*)m_dev;
|
||||
|
||||
dev->IASetVertexBuffer(vertices, sizeof(GSVertexHW9), count);
|
||||
dev->IASetInputLayout(m_il);
|
||||
dev->IASetPrimitiveTopology((D3DPRIMITIVETYPE)prim);
|
||||
IASetVertexBuffer(vertices, sizeof(GSVertexHW9), count);
|
||||
IASetInputLayout(m_il);
|
||||
IASetPrimitiveTopology((D3DPRIMITIVETYPE)prim);
|
||||
}
|
||||
|
||||
void GSTextureFX9::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
||||
void GSDevice9::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
||||
{
|
||||
GSDevice9* dev = (GSDevice9*)m_dev;
|
||||
|
||||
hash_map<uint32, CComPtr<IDirect3DVertexShader9> >::const_iterator i = m_vs.find(sel);
|
||||
hash_map< uint32, CComPtr<IDirect3DVertexShader9> >::const_iterator i = m_vs.find(sel);
|
||||
|
||||
if(i == m_vs.end())
|
||||
{
|
||||
|
@ -133,7 +102,7 @@ void GSTextureFX9::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
CComPtr<IDirect3DVertexDeclaration9> il;
|
||||
CComPtr<IDirect3DVertexShader9> vs;
|
||||
|
||||
dev->CompileShader(IDR_TFX_FX, "vs_main", macro, &vs, layout, countof(layout), &il);
|
||||
CompileShader(IDR_TFX_FX, "vs_main", macro, &vs, layout, countof(layout), &il);
|
||||
|
||||
if(m_il == NULL)
|
||||
{
|
||||
|
@ -145,13 +114,11 @@ void GSTextureFX9::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
|||
i = m_vs.find(sel);
|
||||
}
|
||||
|
||||
dev->VSSetShader(i->second, (const float*)cb, sizeof(*cb) / sizeof(GSVector4));
|
||||
VSSetShader(i->second, (const float*)cb, sizeof(*cb) / sizeof(GSVector4));
|
||||
}
|
||||
|
||||
void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel)
|
||||
void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel)
|
||||
{
|
||||
GSDevice9* dev = (GSDevice9*)m_dev;
|
||||
|
||||
if(cb->WH.z > 0 && cb->WH.w > 0 && (sel.wms == 3 || sel.wmt == 3))
|
||||
{
|
||||
GSVector4i size(cb->WH);
|
||||
|
@ -160,7 +127,7 @@ void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSampler
|
|||
{
|
||||
if(GSTexture* t = CreateMskFix(size.z, cb->MskFix.x, cb->MskFix.z))
|
||||
{
|
||||
(*dev)->SetTexture(2, *(GSTexture9*)t);
|
||||
m_dev->SetTexture(2, *(GSTexture9*)t);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,7 +135,7 @@ void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSampler
|
|||
{
|
||||
if(GSTexture* t = CreateMskFix(size.w, cb->MskFix.y, cb->MskFix.w))
|
||||
{
|
||||
(*dev)->SetTexture(3, *(GSTexture9*)t);
|
||||
m_dev->SetTexture(3, *(GSTexture9*)t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,14 +178,14 @@ void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSampler
|
|||
|
||||
CComPtr<IDirect3DPixelShader9> ps;
|
||||
|
||||
dev->CompileShader(IDR_TFX_FX, "ps_main", macro, &ps);
|
||||
CompileShader(IDR_TFX_FX, "ps_main", macro, &ps);
|
||||
|
||||
m_ps[sel] = ps;
|
||||
|
||||
i = m_ps.find(sel);
|
||||
}
|
||||
|
||||
dev->PSSetShader(i->second, (const float*)cb, sizeof(*cb) / sizeof(GSVector4));
|
||||
PSSetShader(i->second, (const float*)cb, sizeof(*cb) / sizeof(GSVector4));
|
||||
|
||||
Direct3DSamplerState9* ss = NULL;
|
||||
|
||||
|
@ -253,13 +220,11 @@ void GSTextureFX9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSampler
|
|||
}
|
||||
}
|
||||
|
||||
dev->PSSetSamplerState(ss);
|
||||
PSSetSamplerState(ss);
|
||||
}
|
||||
|
||||
void GSTextureFX9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
|
||||
void GSDevice9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix)
|
||||
{
|
||||
GSDevice9* dev = (GSDevice9*)m_dev;
|
||||
|
||||
Direct3DDepthStencilState9* dss = NULL;
|
||||
|
||||
hash_map<uint32, Direct3DDepthStencilState9*>::const_iterator i = m_om_dss.find(dssel);
|
||||
|
@ -302,7 +267,7 @@ void GSTextureFX9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, u
|
|||
i = m_om_dss.find(dssel);
|
||||
}
|
||||
|
||||
dev->OMSetDepthStencilState(i->second);
|
||||
OMSetDepthStencilState(i->second);
|
||||
|
||||
hash_map<uint32, Direct3DBlendState9*>::const_iterator j = m_om_bs.find(bsel);
|
||||
|
||||
|
@ -439,5 +404,5 @@ void GSTextureFX9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, u
|
|||
j = m_om_bs.find(bsel);
|
||||
}
|
||||
|
||||
dev->OMSetBlendState(j->second, afix >= 0x80 ? 0xffffff : 0x020202 * afix);
|
||||
OMSetBlendState(j->second, afix >= 0x80 ? 0xffffff : 0x020202 * afix);
|
||||
}
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* 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 "GSTextureFX.h"
|
||||
#include "GSDevice9.h"
|
||||
|
||||
class GSTextureFX9 : public GSTextureFX
|
||||
{
|
||||
CComPtr<IDirect3DVertexDeclaration9> m_il;
|
||||
hash_map<uint32, CComPtr<IDirect3DVertexShader9> > m_vs;
|
||||
D3DXHANDLE m_vs_params;
|
||||
hash_map<uint32, CComPtr<IDirect3DPixelShader9> > m_ps;
|
||||
hash_map<uint32, Direct3DSamplerState9* > m_ps_ss;
|
||||
hash_map<uint32, Direct3DDepthStencilState9* > m_om_dss;
|
||||
hash_map<uint32, Direct3DBlendState9* > m_om_bs;
|
||||
hash_map<uint32, GSTexture*> m_mskfix;
|
||||
|
||||
GSTexture* CreateMskFix(uint32 size, uint32 msk, uint32 fix);
|
||||
|
||||
public:
|
||||
GSTextureFX9();
|
||||
virtual ~GSTextureFX9();
|
||||
|
||||
bool Create(GSDevice* dev);
|
||||
|
||||
void SetupIA(const void* vertices, int count, int prim);
|
||||
void SetupVS(VSSelector sel, const VSConstantBuffer* cb);
|
||||
void SetupGS(GSSelector sel) {}
|
||||
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
|
||||
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
||||
};
|
|
@ -1449,10 +1449,6 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSTextureFX.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSTextureFX10.cpp"
|
||||
>
|
||||
|
@ -1739,6 +1735,10 @@
|
|||
RelativePath=".\GSDevice9.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSDeviceDX.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSDeviceNull.h"
|
||||
>
|
||||
|
@ -1863,10 +1863,6 @@
|
|||
RelativePath=".\GSTexture10.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSTexture11.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSTexture7.h"
|
||||
>
|
||||
|
@ -1899,22 +1895,10 @@
|
|||
RelativePath=".\GSTextureCacheSW.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSTextureFX.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSTextureFX10.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSTextureFX11.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSTextureFX9.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\GSTextureNull.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue