2010-04-25 00:31:27 +00:00
|
|
|
/*
|
2010-04-24 21:37:39 +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.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2010-04-24 21:37:39 +00:00
|
|
|
* 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.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2010-04-24 21:37:39 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
2012-09-09 18:16:11 +00:00
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
2010-04-24 21:37:39 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GSTexture11.h"
|
2019-01-25 17:06:08 +00:00
|
|
|
#include "GSVector.h"
|
|
|
|
#include "Renderers/Common/GSDevice.h"
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
struct GSVertexShader11
|
|
|
|
{
|
|
|
|
CComPtr<ID3D11VertexShader> vs;
|
|
|
|
CComPtr<ID3D11InputLayout> il;
|
|
|
|
};
|
|
|
|
|
2019-01-25 17:06:08 +00:00
|
|
|
class GSDevice11 final : public GSDevice
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2019-01-25 17:06:08 +00:00
|
|
|
public:
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
|
|
|
struct alignas(32) VSConstantBuffer
|
|
|
|
{
|
|
|
|
GSVector4 VertexScale;
|
|
|
|
GSVector4 VertexOffset;
|
|
|
|
GSVector4 Texture_Scale_Offset;
|
|
|
|
|
|
|
|
VSConstantBuffer()
|
|
|
|
{
|
|
|
|
VertexScale = GSVector4::zero();
|
|
|
|
VertexOffset = GSVector4::zero();
|
|
|
|
Texture_Scale_Offset = GSVector4::zero();
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline bool Update(const VSConstantBuffer* cb)
|
|
|
|
{
|
|
|
|
GSVector4i* a = (GSVector4i*)this;
|
|
|
|
GSVector4i* b = (GSVector4i*)cb;
|
|
|
|
|
|
|
|
if(!((a[0] == b[0]) & (a[1] == b[1]) & (a[2] == b[2]) & (a[3] == b[3])).alltrue())
|
|
|
|
{
|
|
|
|
a[0] = b[0];
|
|
|
|
a[1] = b[1];
|
|
|
|
a[2] = b[2];
|
|
|
|
a[3] = b[3];
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VSSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 bppz:2;
|
|
|
|
uint32 tme:1;
|
|
|
|
uint32 fst:1;
|
|
|
|
|
|
|
|
uint32 _free:28;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
|
|
|
operator uint32() const {return key;}
|
|
|
|
|
|
|
|
VSSelector() : key(0) {}
|
|
|
|
VSSelector(uint32 k) : key(k) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct alignas(32) PSConstantBuffer
|
|
|
|
{
|
|
|
|
GSVector4 FogColor_AREF;
|
|
|
|
GSVector4 HalfTexel;
|
|
|
|
GSVector4 WH;
|
|
|
|
GSVector4 MinMax;
|
|
|
|
GSVector4 MinF_TA;
|
|
|
|
GSVector4i MskFix;
|
|
|
|
GSVector4i ChannelShuffle;
|
2019-04-17 20:14:17 +00:00
|
|
|
GSVector4i FbMask;
|
2019-01-25 17:06:08 +00:00
|
|
|
|
|
|
|
GSVector4 TC_OffsetHack;
|
2019-06-06 15:56:22 +00:00
|
|
|
GSVector4 Af;
|
2019-01-25 17:06:08 +00:00
|
|
|
|
|
|
|
PSConstantBuffer()
|
|
|
|
{
|
|
|
|
FogColor_AREF = GSVector4::zero();
|
|
|
|
HalfTexel = GSVector4::zero();
|
|
|
|
WH = GSVector4::zero();
|
|
|
|
MinMax = GSVector4::zero();
|
|
|
|
MinF_TA = GSVector4::zero();
|
|
|
|
MskFix = GSVector4i::zero();
|
|
|
|
ChannelShuffle = GSVector4i::zero();
|
2019-04-17 20:14:17 +00:00
|
|
|
FbMask = GSVector4i::zero();
|
2019-06-06 15:56:22 +00:00
|
|
|
Af = GSVector4::zero();
|
2019-01-25 17:06:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline bool Update(const PSConstantBuffer* cb)
|
|
|
|
{
|
|
|
|
GSVector4i* a = (GSVector4i*)this;
|
|
|
|
GSVector4i* b = (GSVector4i*)cb;
|
|
|
|
|
2019-06-06 15:56:22 +00:00
|
|
|
if(!((a[0] == b[0]) /*& (a[1] == b1)*/ & (a[2] == b[2]) & (a[3] == b[3]) & (a[4] == b[4]) & (a[5] == b[5]) &
|
|
|
|
(a[6] == b[6]) & (a[7] == b[7]) & (a[9] == b[9])).alltrue()) // if WH matches HalfTexel does too
|
2019-01-25 17:06:08 +00:00
|
|
|
{
|
|
|
|
a[0] = b[0];
|
|
|
|
a[1] = b[1];
|
|
|
|
a[2] = b[2];
|
|
|
|
a[3] = b[3];
|
|
|
|
a[4] = b[4];
|
|
|
|
a[5] = b[5];
|
|
|
|
a[6] = b[6];
|
2019-04-17 20:14:17 +00:00
|
|
|
a[7] = b[7];
|
2019-06-06 15:56:22 +00:00
|
|
|
a[9] = b[9];
|
2019-01-25 17:06:08 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct alignas(32) GSConstantBuffer
|
|
|
|
{
|
|
|
|
GSVector2 PointSize;
|
|
|
|
|
|
|
|
GSConstantBuffer()
|
|
|
|
{
|
|
|
|
PointSize = GSVector2(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline bool Update(const GSConstantBuffer* cb)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GSSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 iip:1;
|
|
|
|
uint32 prim:2;
|
|
|
|
uint32 point:1;
|
|
|
|
uint32 line:1;
|
|
|
|
|
|
|
|
uint32 _free:27;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
|
|
|
operator uint32() {return key;}
|
|
|
|
|
|
|
|
GSSelector() : key(0) {}
|
|
|
|
GSSelector(uint32 k) : key(k) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PSSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
// *** Word 1
|
|
|
|
// Format
|
|
|
|
uint32 fmt:4;
|
|
|
|
uint32 dfmt:2;
|
|
|
|
uint32 depth_fmt:2;
|
|
|
|
// Alpha extension/Correction
|
|
|
|
uint32 aem:1;
|
|
|
|
uint32 fba:1;
|
|
|
|
// Fog
|
|
|
|
uint32 fog:1;
|
|
|
|
// Pixel test
|
|
|
|
uint32 atst:3;
|
|
|
|
// Color sampling
|
|
|
|
uint32 fst:1;
|
|
|
|
uint32 tfx:3;
|
|
|
|
uint32 tcc:1;
|
|
|
|
uint32 wms:2;
|
|
|
|
uint32 wmt:2;
|
|
|
|
uint32 ltf:1;
|
|
|
|
// Shuffle and fbmask effect
|
|
|
|
uint32 shuffle:1;
|
|
|
|
uint32 read_ba:1;
|
2019-04-17 20:14:17 +00:00
|
|
|
uint32 fbmask:1;
|
2019-01-25 17:06:08 +00:00
|
|
|
|
|
|
|
// Blend and Colclip
|
2019-06-06 15:56:22 +00:00
|
|
|
uint32 blend_a:2;
|
|
|
|
uint32 blend_b:2;
|
|
|
|
uint32 blend_c:2;
|
|
|
|
uint32 blend_d:2;
|
2019-01-25 17:06:08 +00:00
|
|
|
uint32 clr1:1;
|
2019-06-06 15:56:22 +00:00
|
|
|
uint32 hdr:1;
|
2019-06-26 14:07:03 +00:00
|
|
|
uint32 colclip:1;
|
2019-01-25 17:06:08 +00:00
|
|
|
|
|
|
|
// Others ways to fetch the texture
|
|
|
|
uint32 channel:3;
|
|
|
|
|
|
|
|
// Hack
|
|
|
|
uint32 tcoffsethack:1;
|
|
|
|
uint32 urban_chaos_hle:1;
|
|
|
|
uint32 tales_of_abyss_hle:1;
|
|
|
|
uint32 point_sampler:1;
|
2019-02-20 11:11:23 +00:00
|
|
|
uint32 invalid_tex0:1; // Lupin the 3rd
|
2019-01-25 17:06:08 +00:00
|
|
|
|
2019-06-26 14:07:03 +00:00
|
|
|
uint32 _free:18;
|
2019-01-25 17:06:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
uint64 key;
|
|
|
|
};
|
|
|
|
|
|
|
|
operator uint64() {return key;}
|
|
|
|
|
|
|
|
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 date_one:1;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
|
|
|
operator uint32() {return key & 0x3f;}
|
|
|
|
|
|
|
|
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;
|
2019-06-06 15:56:22 +00:00
|
|
|
uint32 accu_blend:1;
|
2019-01-25 17:06:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 _pad:1;
|
|
|
|
uint32 abcd:8;
|
|
|
|
uint32 wrgba:4;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
2019-06-06 15:56:22 +00:00
|
|
|
operator uint32() {return key & 0x3fff;}
|
2019-01-25 17:06:08 +00:00
|
|
|
|
|
|
|
OMBlendSelector() : key(0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2019-06-14 18:24:37 +00:00
|
|
|
class ShaderMacro
|
|
|
|
{
|
|
|
|
struct mcstr
|
|
|
|
{
|
|
|
|
const char* name, * def;
|
|
|
|
mcstr(const char* n, const char* d) : name(n), def(d) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mstring
|
|
|
|
{
|
|
|
|
std::string name, def;
|
|
|
|
mstring(const char* n, std::string d) : name(n), def(d) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<mstring> mlist;
|
|
|
|
std::vector<mcstr> mout;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ShaderMacro(std::string& smodel);
|
|
|
|
void AddMacro(const char* n, int d);
|
|
|
|
D3D_SHADER_MACRO* GetPtr(void);
|
|
|
|
};
|
|
|
|
|
2019-01-25 17:06:08 +00:00
|
|
|
private:
|
|
|
|
float m_hack_topleft_offset;
|
|
|
|
int m_upscale_multiplier;
|
2020-01-18 20:25:08 +00:00
|
|
|
int m_aniso_filter;
|
2019-01-25 17:06:08 +00:00
|
|
|
int m_mipmap;
|
2019-08-18 21:16:04 +00:00
|
|
|
int m_d3d_texsize;
|
2019-01-25 17:06:08 +00:00
|
|
|
|
2019-01-14 21:28:23 +00:00
|
|
|
GSTexture* CreateSurface(int type, int w, int h, int format);
|
2019-01-25 17:06:08 +00:00
|
|
|
GSTexture* FetchSurface(int type, int w, int h, int format);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2019-01-25 19:43:43 +00:00
|
|
|
void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) final;
|
|
|
|
void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0) final;
|
|
|
|
void DoFXAA(GSTexture* sTex, GSTexture* dTex) final;
|
|
|
|
void DoShadeBoost(GSTexture* sTex, GSTexture* dTex) final;
|
|
|
|
void DoExternalFX(GSTexture* sTex, GSTexture* dTex) final;
|
2014-01-17 10:17:24 +00:00
|
|
|
void InitExternalFX();
|
2014-01-09 21:51:42 +00:00
|
|
|
void InitFXAA(); // Bug workaround! Stack corruption? Heap corruption? No idea
|
2019-01-25 19:43:43 +00:00
|
|
|
void RenderOsd(GSTexture* dt);
|
2019-01-25 06:50:40 +00:00
|
|
|
void BeforeDraw();
|
|
|
|
void AfterDraw();
|
2014-01-17 10:17:24 +00:00
|
|
|
|
2019-06-06 14:21:32 +00:00
|
|
|
uint16 ConvertBlendEnum(uint16 generic) final;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
CComPtr<ID3D11Device> m_dev;
|
|
|
|
CComPtr<ID3D11DeviceContext> m_ctx;
|
|
|
|
CComPtr<IDXGISwapChain> m_swapchain;
|
|
|
|
CComPtr<ID3D11Buffer> m_vb;
|
|
|
|
CComPtr<ID3D11Buffer> m_vb_old;
|
2012-01-05 02:40:24 +00:00
|
|
|
CComPtr<ID3D11Buffer> m_ib;
|
|
|
|
CComPtr<ID3D11Buffer> m_ib_old;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ID3D11Buffer* vb;
|
|
|
|
size_t vb_stride;
|
2012-01-05 02:40:24 +00:00
|
|
|
ID3D11Buffer* ib;
|
2010-04-24 21:37:39 +00:00
|
|
|
ID3D11InputLayout* layout;
|
|
|
|
D3D11_PRIMITIVE_TOPOLOGY topology;
|
|
|
|
ID3D11VertexShader* vs;
|
|
|
|
ID3D11Buffer* vs_cb;
|
|
|
|
ID3D11GeometryShader* gs;
|
2017-03-03 21:18:49 +00:00
|
|
|
ID3D11Buffer* gs_cb;
|
2018-12-15 18:44:45 +00:00
|
|
|
std::array<ID3D11ShaderResourceView*, 16> ps_sr_views;
|
|
|
|
std::array<GSTexture11*, 16> ps_sr_texture;
|
2010-04-24 21:37:39 +00:00
|
|
|
ID3D11PixelShader* ps;
|
|
|
|
ID3D11Buffer* ps_cb;
|
2010-05-14 14:05:39 +00:00
|
|
|
ID3D11SamplerState* ps_ss[3];
|
2010-04-24 21:37:39 +00:00
|
|
|
GSVector2i viewport;
|
|
|
|
GSVector4i scissor;
|
|
|
|
ID3D11DepthStencilState* dss;
|
|
|
|
uint8 sref;
|
|
|
|
ID3D11BlendState* bs;
|
|
|
|
float bf;
|
2018-12-15 18:42:58 +00:00
|
|
|
ID3D11RenderTargetView* rt_view;
|
|
|
|
GSTexture11* rt_texture;
|
2019-01-20 06:04:07 +00:00
|
|
|
GSTexture11* rt_ds;
|
2010-04-24 21:37:39 +00:00
|
|
|
ID3D11DepthStencilView* dsv;
|
2019-01-25 06:50:40 +00:00
|
|
|
uint16_t ps_sr_bitfield;
|
2010-04-24 21:37:39 +00:00
|
|
|
} m_state;
|
|
|
|
|
|
|
|
CComPtr<ID3D11RasterizerState> m_rs;
|
|
|
|
|
2014-02-02 17:50:32 +00:00
|
|
|
bool FXAA_Compiled;
|
2014-01-17 10:17:24 +00:00
|
|
|
bool ExShader_Compiled;
|
2014-01-05 23:31:26 +00:00
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CComPtr<ID3D11InputLayout> il;
|
|
|
|
CComPtr<ID3D11VertexShader> vs;
|
2018-12-14 15:45:42 +00:00
|
|
|
CComPtr<ID3D11PixelShader> ps[ShaderConvert_Count];
|
2010-04-24 21:37:39 +00:00
|
|
|
CComPtr<ID3D11SamplerState> ln;
|
|
|
|
CComPtr<ID3D11SamplerState> pt;
|
|
|
|
CComPtr<ID3D11DepthStencilState> dss;
|
2018-12-03 17:04:18 +00:00
|
|
|
CComPtr<ID3D11DepthStencilState> dss_write;
|
2010-04-24 21:37:39 +00:00
|
|
|
CComPtr<ID3D11BlendState> bs;
|
|
|
|
} m_convert;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
CComPtr<ID3D11PixelShader> ps[2];
|
|
|
|
CComPtr<ID3D11Buffer> cb;
|
|
|
|
CComPtr<ID3D11BlendState> bs;
|
|
|
|
} m_merge;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
CComPtr<ID3D11PixelShader> ps[4];
|
|
|
|
CComPtr<ID3D11Buffer> cb;
|
|
|
|
} m_interlace;
|
|
|
|
|
2014-01-17 10:17:24 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CComPtr<ID3D11PixelShader> ps;
|
|
|
|
CComPtr<ID3D11Buffer> cb;
|
|
|
|
} m_shaderfx;
|
|
|
|
|
2011-07-25 11:16:01 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CComPtr<ID3D11PixelShader> ps;
|
|
|
|
CComPtr<ID3D11Buffer> cb;
|
|
|
|
} m_fxaa;
|
|
|
|
|
2012-02-29 00:29:29 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CComPtr<ID3D11PixelShader> ps;
|
|
|
|
CComPtr<ID3D11Buffer> cb;
|
|
|
|
} m_shadeboost;
|
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
CComPtr<ID3D11DepthStencilState> dss;
|
|
|
|
CComPtr<ID3D11BlendState> bs;
|
|
|
|
} m_date;
|
|
|
|
|
|
|
|
// Shaders...
|
|
|
|
|
2017-05-26 15:41:52 +00:00
|
|
|
std::unordered_map<uint32, GSVertexShader11> m_vs;
|
2010-04-24 21:37:39 +00:00
|
|
|
CComPtr<ID3D11Buffer> m_vs_cb;
|
2017-05-26 15:41:52 +00:00
|
|
|
std::unordered_map<uint32, CComPtr<ID3D11GeometryShader>> m_gs;
|
2017-03-03 21:18:49 +00:00
|
|
|
CComPtr<ID3D11Buffer> m_gs_cb;
|
2017-05-26 15:41:52 +00:00
|
|
|
std::unordered_map<uint64, CComPtr<ID3D11PixelShader>> m_ps;
|
2010-04-24 21:37:39 +00:00
|
|
|
CComPtr<ID3D11Buffer> m_ps_cb;
|
2017-05-26 15:41:52 +00:00
|
|
|
std::unordered_map<uint32, CComPtr<ID3D11SamplerState>> m_ps_ss;
|
2010-04-24 21:37:39 +00:00
|
|
|
CComPtr<ID3D11SamplerState> m_palette_ss;
|
2017-05-26 15:41:52 +00:00
|
|
|
std::unordered_map<uint32, CComPtr<ID3D11DepthStencilState>> m_om_dss;
|
|
|
|
std::unordered_map<uint32, CComPtr<ID3D11BlendState>> m_om_bs;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
VSConstantBuffer m_vs_cb_cache;
|
2017-03-03 21:18:49 +00:00
|
|
|
GSConstantBuffer m_gs_cb_cache;
|
2010-04-24 21:37:39 +00:00
|
|
|
PSConstantBuffer m_ps_cb_cache;
|
|
|
|
|
2018-12-14 22:53:28 +00:00
|
|
|
std::unique_ptr<GSTexture> m_font;
|
2018-12-14 15:45:42 +00:00
|
|
|
|
2019-01-25 17:06:08 +00:00
|
|
|
protected:
|
|
|
|
struct {D3D_FEATURE_LEVEL level; std::string model, vs, gs, ps, cs;} m_shader;
|
|
|
|
|
|
|
|
static HMODULE s_d3d_compiler_dll;
|
|
|
|
static decltype(&D3DCompile) s_pD3DCompile;
|
|
|
|
// Older version doesn't support D3D_COMPILE_STANDARD_FILE_INCLUDE, which
|
|
|
|
// could be useful for external shaders.
|
|
|
|
static bool s_old_d3d_compiler_dll;
|
2011-02-20 18:59:02 +00:00
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
public:
|
|
|
|
GSDevice11();
|
2019-01-25 17:06:08 +00:00
|
|
|
virtual ~GSDevice11() {}
|
|
|
|
|
|
|
|
bool SetFeatureLevel(D3D_FEATURE_LEVEL level, bool compat_mode);
|
|
|
|
void GetFeatureLevel(D3D_FEATURE_LEVEL& level) const { level = m_shader.level; }
|
|
|
|
|
|
|
|
static bool LoadD3DCompiler();
|
|
|
|
static void FreeD3DCompiler();
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2017-02-22 21:02:34 +00:00
|
|
|
bool Create(const std::shared_ptr<GSWnd> &wnd);
|
2010-04-24 21:37:39 +00:00
|
|
|
bool Reset(int w, int h);
|
|
|
|
void Flip();
|
2017-08-23 18:55:42 +00:00
|
|
|
void SetVSync(int vsync) final;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2019-01-25 19:43:43 +00:00
|
|
|
void DrawPrimitive() final;
|
2012-01-05 02:40:24 +00:00
|
|
|
void DrawIndexedPrimitive();
|
2019-01-25 19:43:43 +00:00
|
|
|
void DrawIndexedPrimitive(int offset, int count) final;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2019-01-25 19:43:43 +00:00
|
|
|
void ClearRenderTarget(GSTexture* t, const GSVector4& c) final;
|
|
|
|
void ClearRenderTarget(GSTexture* t, uint32 c) final;
|
|
|
|
void ClearDepth(GSTexture* t) final;
|
|
|
|
void ClearStencil(GSTexture* t, uint8 c) final;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2019-01-25 19:43:43 +00:00
|
|
|
GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) final;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2019-01-20 06:09:47 +00:00
|
|
|
void CloneTexture(GSTexture* src, GSTexture** dest);
|
2018-12-16 02:06:11 +00:00
|
|
|
|
2015-05-15 18:45:31 +00:00
|
|
|
void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2019-01-25 19:43:43 +00:00
|
|
|
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true) final;
|
2015-05-15 18:49:25 +00:00
|
|
|
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ID3D11PixelShader* ps, ID3D11Buffer* ps_cb, bool linear = true);
|
2019-06-19 14:47:57 +00:00
|
|
|
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, bool red, bool green, bool blue, bool alpha);
|
2015-05-15 18:49:25 +00:00
|
|
|
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ID3D11PixelShader* ps, ID3D11Buffer* ps_cb, ID3D11BlendState* bs, bool linear = true);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2019-01-25 17:06:08 +00:00
|
|
|
void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm);
|
|
|
|
|
2012-01-05 02:40:24 +00:00
|
|
|
void IASetVertexBuffer(const void* vertex, size_t stride, size_t count);
|
2012-01-19 04:53:36 +00:00
|
|
|
bool IAMapVertexBuffer(void** vertex, size_t stride, size_t count);
|
|
|
|
void IAUnmapVertexBuffer();
|
2010-04-24 21:37:39 +00:00
|
|
|
void IASetVertexBuffer(ID3D11Buffer* vb, size_t stride);
|
2012-01-05 02:40:24 +00:00
|
|
|
void IASetIndexBuffer(const void* index, size_t count);
|
|
|
|
void IASetIndexBuffer(ID3D11Buffer* ib);
|
2010-04-24 21:37:39 +00:00
|
|
|
void IASetInputLayout(ID3D11InputLayout* layout);
|
|
|
|
void IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY topology);
|
2019-01-25 19:43:43 +00:00
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
void VSSetShader(ID3D11VertexShader* vs, ID3D11Buffer* vs_cb);
|
2017-03-03 21:18:49 +00:00
|
|
|
void GSSetShader(ID3D11GeometryShader* gs, ID3D11Buffer* gs_cb = NULL);
|
2019-01-25 19:43:43 +00:00
|
|
|
|
|
|
|
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) final;
|
|
|
|
void PSSetShaderResource(int i, GSTexture* sr) final;
|
2018-12-15 18:44:45 +00:00
|
|
|
void PSSetShaderResourceView(int i, ID3D11ShaderResourceView* srv, GSTexture* sr);
|
2010-04-24 21:37:39 +00:00
|
|
|
void PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb);
|
2018-12-16 08:51:00 +00:00
|
|
|
void PSUpdateShaderState();
|
2018-12-20 00:19:36 +00:00
|
|
|
void PSSetSamplerState(ID3D11SamplerState* ss0, ID3D11SamplerState* ss1);
|
2019-01-25 19:43:43 +00:00
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
void OMSetDepthStencilState(ID3D11DepthStencilState* dss, uint8 sref);
|
|
|
|
void OMSetBlendState(ID3D11BlendState* bs, float bf);
|
2019-01-25 19:43:43 +00:00
|
|
|
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL) final;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2019-01-25 17:06:08 +00:00
|
|
|
bool CreateTextureFX();
|
2010-04-24 21:37:39 +00:00
|
|
|
void SetupVS(VSSelector sel, const VSConstantBuffer* cb);
|
2017-03-03 21:18:49 +00:00
|
|
|
void SetupGS(GSSelector sel, const GSConstantBuffer* cb);
|
2010-04-24 21:37:39 +00:00
|
|
|
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;}
|
|
|
|
|
2018-12-19 19:28:05 +00:00
|
|
|
void CreateShader(std::vector<char> source, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11VertexShader** vs, D3D11_INPUT_ELEMENT_DESC* layout, int count, ID3D11InputLayout** il);
|
|
|
|
void CreateShader(std::vector<char> source, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11GeometryShader** gs);
|
|
|
|
void CreateShader(std::vector<char> source, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3D11PixelShader** ps);
|
|
|
|
|
|
|
|
void CompileShader(std::vector<char> source, const char* fn, ID3DInclude *include, const char* entry, D3D_SHADER_MACRO* macro, ID3DBlob** shader, std::string shader_model);
|
2010-04-24 21:37:39 +00:00
|
|
|
};
|
2011-02-22 23:39:02 +00:00
|
|
|
|