2009-02-09 21:15:56 +00:00
|
|
|
/*
|
|
|
|
* 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 "GSDevice9.h"
|
|
|
|
|
|
|
|
class GSTextureFX9
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
|
|
|
struct VSConstantBuffer
|
|
|
|
{
|
|
|
|
GSVector4 VertexScale;
|
|
|
|
GSVector4 VertexOffset;
|
|
|
|
GSVector2 TextureScale;
|
|
|
|
float _pad[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
union VSSelector
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 bppz:2;
|
|
|
|
uint32 tme:1;
|
|
|
|
uint32 fst:1;
|
|
|
|
uint32 logz:1;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 key;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
operator uint32() {return key & 0x1f;}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PSConstantBuffer
|
|
|
|
{
|
|
|
|
GSVector4 FogColor;
|
|
|
|
float MINU;
|
|
|
|
float MAXU;
|
|
|
|
float MINV;
|
|
|
|
float MAXV;
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 UMSK;
|
|
|
|
uint32 UFIX;
|
|
|
|
uint32 VMSK;
|
|
|
|
uint32 VFIX;
|
2009-02-09 21:15:56 +00:00
|
|
|
float TA0;
|
|
|
|
float TA1;
|
|
|
|
float AREF;
|
|
|
|
float _pad[1];
|
|
|
|
GSVector2 WH;
|
|
|
|
GSVector2 rWrH;
|
|
|
|
};
|
|
|
|
|
|
|
|
union PSSelector
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 fst:1;
|
|
|
|
uint32 wms:2;
|
|
|
|
uint32 wmt:2;
|
|
|
|
uint32 bpp:3;
|
|
|
|
uint32 aem:1;
|
|
|
|
uint32 tfx:3;
|
|
|
|
uint32 tcc:1;
|
|
|
|
uint32 ate:1;
|
|
|
|
uint32 atst:3;
|
|
|
|
uint32 fog:1;
|
|
|
|
uint32 clr1:1;
|
|
|
|
uint32 rt:1;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 key;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
operator uint32() {return key & 0xfffff;}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
union PSSamplerSelector
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 tau:1;
|
|
|
|
uint32 tav:1;
|
|
|
|
uint32 min:1;
|
|
|
|
uint32 mag:1;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 key;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
operator uint32() {return key & 0xf;}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
union OMDepthStencilSelector
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 zte:1;
|
|
|
|
uint32 ztst:2;
|
|
|
|
uint32 zwe:1;
|
|
|
|
uint32 date:1;
|
|
|
|
uint32 fba:1;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 key;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
operator uint32() {return key & 0x3f;}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
union OMBlendSelector
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2009-05-14 16:41:52 +00:00
|
|
|
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;
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 key;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
operator uint32() {return key & 0x1fff;}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
private:
|
|
|
|
GSDevice9* m_dev;
|
|
|
|
CComPtr<IDirect3DVertexDeclaration9> m_il;
|
2009-05-14 16:41:52 +00:00
|
|
|
hash_map<uint32, CComPtr<IDirect3DVertexShader9> > m_vs;
|
2009-02-09 21:15:56 +00:00
|
|
|
D3DXHANDLE m_vs_params;
|
2009-05-14 16:41:52 +00:00
|
|
|
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;
|
2009-05-23 23:52:53 +00:00
|
|
|
|
|
|
|
CComPtr<IDirect3DVertexBuffer9> m_vb, m_vb_old;
|
|
|
|
int m_vb_max;
|
|
|
|
int m_vb_start;
|
|
|
|
int m_vb_count;
|
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
hash_map<uint32, GSTexture*> m_mskfix;
|
|
|
|
|
|
|
|
GSTexture* CreateMskFix(uint32 size, uint32 msk, uint32 fix);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
GSTextureFX9();
|
|
|
|
|
|
|
|
bool Create(GSDevice9* dev);
|
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
bool SetupIA(const GSVertexHW9* vertices, int count, D3DPRIMITIVETYPE prim);
|
2009-02-09 21:15:56 +00:00
|
|
|
bool SetupVS(VSSelector sel, const VSConstantBuffer* cb);
|
2009-05-22 01:22:52 +00:00
|
|
|
bool SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, GSTexture* tex, GSTexture* pal, bool psrr);
|
2009-02-09 21:15:56 +00:00
|
|
|
void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, bool psrr);
|
2009-05-14 16:41:52 +00:00
|
|
|
void SetupRS(int w, int h, const GSVector4i& scissor);
|
2009-05-22 01:22:52 +00:00
|
|
|
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 bf, GSTexture* rt, GSTexture* ds);
|
2009-05-14 16:41:52 +00:00
|
|
|
void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 bf);
|
2009-05-23 23:52:53 +00:00
|
|
|
void Draw();
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|