-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSDevice.h
209 lines (168 loc) · 5.89 KB
/
GSDevice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
* 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#pragma once
#include "GSWnd.h"
#include "GSTexture.h"
#include "GSVertex.h"
#include "GSAlignedClass.h"
#pragma pack(push, 1)
class MergeConstantBuffer
{
public:
GSVector4 BGColor;
MergeConstantBuffer() {memset(this, 0, sizeof(*this));}
};
class InterlaceConstantBuffer
{
public:
GSVector2 ZrH;
float hH;
float fSaturation;
InterlaceConstantBuffer() {memset(this, 0, sizeof(*this));}
};
class ExternalFXConstantBuffer
{
public:
GSVector2 xyFrame;
GSVector4 rcpFrame;
GSVector4 rcpFrameOpt;
ExternalFXConstantBuffer() { memset(this, 0, sizeof(*this)); }
};
class CustomShaderConstantBuffer
{
public:
GSVector2 xyFrame;
GSVector4 rcpFrame;
GSVector4 rcpFrameOpt;
CustomShaderConstantBuffer() { memset(this, 0, sizeof(*this)); }
};
class FXAAConstantBuffer
{
public:
GSVector4 rcpFrame;
GSVector4 rcpFrameOpt;
FXAAConstantBuffer() {memset(this, 0, sizeof(*this));}
};
class ShadeBoostConstantBuffer
{
public:
GSVector4 rcpFrame;
GSVector4 rcpFrameOpt;
ShadeBoostConstantBuffer() {memset(this, 0, sizeof(*this));}
};
#pragma pack(pop)
class GSDevice : public GSAlignedClass<32>
{
list<GSTexture*> m_pool;
protected:
float m_fColorEnginePara; //Output color saturation;
GSWnd* m_wnd;
bool m_vsync;
bool m_rbswapped;
GSTexture* m_backbuffer;
GSTexture* m_merge;
GSTexture* m_weavebob;
GSTexture* m_blend;
GSTexture* m_shaderfx;
GSTexture* m_customshader;
GSTexture* m_fxaa;
GSTexture* m_shadeboost;
GSTexture* m_1x1;
GSTexture* m_current;
struct {size_t stride, start, count, limit;} m_vertex;
struct {size_t start, count, limit;} m_index;
unsigned int m_frame; // for ageing the pool
virtual GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format) = 0;
virtual GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format);
virtual void DoMerge(GSTexture* sTex[2], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, bool slbg, bool mmod, const GSVector4& c) = 0;
virtual void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset) = 0;
virtual void DoFXAA(GSTexture* sTex, GSTexture* dTex) {}
virtual void DoShadeBoost(GSTexture* sTex, GSTexture* dTex) {}
virtual void DoExternalFX(GSTexture* sTex, GSTexture* dTex) {}
virtual void DoCustomShader(GSTexture* sTex, GSTexture* dTex) {}
public:
GSDevice();
virtual ~GSDevice();
void Recycle(GSTexture* t);
enum {Windowed, Fullscreen, DontCare};
virtual bool Create(GSWnd* wnd);
virtual bool Reset(int w, int h);
virtual bool IsLost(bool update = false) {return false;}
virtual void Present(const GSVector4i& r, int shader);
virtual void Present(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, int shader = 0);
virtual void Flip() {}
virtual void SetVSync(bool enable) {m_vsync = enable;}
virtual void BeginScene() {}
virtual void DrawPrimitive() {};
virtual void DrawIndexedPrimitive() {}
virtual void DrawIndexedPrimitive(int offset, int count) {}
virtual void EndScene();
virtual void ClearRenderTarget(GSTexture* t, const GSVector4& c) {}
virtual void ClearRenderTarget(GSTexture* t, uint32 c) {}
virtual void ClearDepth(GSTexture* t, float c) {}
virtual void ClearStencil(GSTexture* t, uint8 c) {}
virtual GSTexture* CreateRenderTarget(int w, int h, bool msaa, int format = 0);
virtual GSTexture* CreateDepthStencil(int w, int h, bool msaa, int format = 0);
virtual GSTexture* CreateTexture(int w, int h, int format = 0);
virtual GSTexture* CreateOffscreen(int w, int h, int format = 0);
virtual GSTexture* Resolve(GSTexture* t) {return NULL;}
virtual GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) {return NULL;}
virtual void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r) {}
virtual void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true) {}
void StretchRect(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true);
virtual void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) {}
virtual void PSSetShaderResource(int i, GSTexture* sRect) {}
virtual void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL) {}
GSTexture* GetCurrent();
void Merge(GSTexture* sTex[2], GSVector4* sRect, GSVector4* dRect, const GSVector2i& fs, bool slbg, bool mmod, const GSVector4& c);
void Interlace(const GSVector2i& ds, int field, int mode, float yoffset);
void FXAA();
void ShadeBoost();
void ExternalFX();
void CustomShader();
bool ResizeTexture(GSTexture** t, int w, int h);
bool IsRBSwapped() {return m_rbswapped;}
void AgePool();
};
struct GSAdapter
{
uint32 vendor;
uint32 device;
uint32 subsys;
uint32 rev;
operator std::string() const;
bool operator==(const GSAdapter&) const;
bool operator==(const std::string &s) const
{
return (std::string)*this == s;
}
bool operator==(const char *s) const
{
return (std::string)*this == s;
}
#ifdef _WINDOWS
GSAdapter(const DXGI_ADAPTER_DESC1 &desc_dxgi);
GSAdapter(const D3DADAPTER_IDENTIFIER9 &desc_d3d9);
#endif
#ifdef __linux__
// TODO
#endif
};