2010-04-25 00:31:27 +00:00
|
|
|
/*
|
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.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +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
|
|
|
*
|
2009-02-09 21:15:56 +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.
|
2009-02-09 21:15:56 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
#include "GSWnd.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
#include "GSTexture.h"
|
|
|
|
#include "GSVertex.h"
|
2009-05-22 01:22:52 +00:00
|
|
|
#include "GSAlignedClass.h"
|
2016-09-18 20:40:51 +00:00
|
|
|
#include "GSOsdManager.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2015-09-08 14:36:23 +00:00
|
|
|
enum ShaderConvert {
|
|
|
|
ShaderConvert_COPY = 0,
|
|
|
|
ShaderConvert_RGBA8_TO_16_BITS,
|
|
|
|
ShaderConvert_DATM_1,
|
|
|
|
ShaderConvert_DATM_0,
|
|
|
|
ShaderConvert_MOD_256,
|
|
|
|
ShaderConvert_SCANLINE = 5,
|
|
|
|
ShaderConvert_DIAGONAL_FILTER,
|
|
|
|
ShaderConvert_TRANSPARENCY_FILTER,
|
|
|
|
ShaderConvert_TRIANGULAR_FILTER,
|
|
|
|
ShaderConvert_COMPLEX_FILTER,
|
|
|
|
ShaderConvert_FLOAT32_TO_32_BITS = 10,
|
|
|
|
ShaderConvert_FLOAT32_TO_RGBA8,
|
|
|
|
ShaderConvert_FLOAT16_TO_RGB5A1,
|
|
|
|
ShaderConvert_RGBA8_TO_FLOAT32 = 13,
|
|
|
|
ShaderConvert_RGBA8_TO_FLOAT24,
|
|
|
|
ShaderConvert_RGBA8_TO_FLOAT16,
|
|
|
|
ShaderConvert_RGB5A1_TO_FLOAT16,
|
2016-10-09 12:17:54 +00:00
|
|
|
ShaderConvert_RGBA_TO_8I = 17,
|
|
|
|
ShaderConvert_OSD,
|
2016-10-09 12:28:49 +00:00
|
|
|
ShaderConvert_YUV,
|
2016-10-09 12:17:54 +00:00
|
|
|
ShaderConvert_Count
|
2015-09-08 14:36:23 +00:00
|
|
|
};
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
2011-02-18 01:56:05 +00:00
|
|
|
class MergeConstantBuffer
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2011-02-18 01:56:05 +00:00
|
|
|
public:
|
2009-02-09 21:15:56 +00:00
|
|
|
GSVector4 BGColor;
|
|
|
|
|
2011-02-18 01:56:05 +00:00
|
|
|
MergeConstantBuffer() {memset(this, 0, sizeof(*this));}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2011-02-18 01:56:05 +00:00
|
|
|
class InterlaceConstantBuffer
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2011-02-18 01:56:05 +00:00
|
|
|
public:
|
2009-02-09 21:15:56 +00:00
|
|
|
GSVector2 ZrH;
|
|
|
|
float hH;
|
|
|
|
float _pad[1];
|
|
|
|
|
2011-02-18 01:56:05 +00:00
|
|
|
InterlaceConstantBuffer() {memset(this, 0, sizeof(*this));}
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
|
|
|
|
2014-01-17 10:17:24 +00:00
|
|
|
class ExternalFXConstantBuffer
|
|
|
|
{
|
|
|
|
public:
|
2014-11-03 07:15:34 +00:00
|
|
|
GSVector2 xyFrame;
|
2014-01-17 10:17:24 +00:00
|
|
|
GSVector4 rcpFrame;
|
|
|
|
GSVector4 rcpFrameOpt;
|
|
|
|
|
|
|
|
ExternalFXConstantBuffer() { memset(this, 0, sizeof(*this)); }
|
|
|
|
};
|
|
|
|
|
2011-07-25 11:16:01 +00:00
|
|
|
class FXAAConstantBuffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GSVector4 rcpFrame;
|
|
|
|
GSVector4 rcpFrameOpt;
|
|
|
|
|
|
|
|
FXAAConstantBuffer() {memset(this, 0, sizeof(*this));}
|
|
|
|
};
|
|
|
|
|
2012-02-29 00:29:29 +00:00
|
|
|
class ShadeBoostConstantBuffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GSVector4 rcpFrame;
|
|
|
|
GSVector4 rcpFrameOpt;
|
|
|
|
|
|
|
|
ShadeBoostConstantBuffer() {memset(this, 0, sizeof(*this));}
|
|
|
|
};
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
#pragma pack(pop)
|
|
|
|
|
2011-02-07 01:59:05 +00:00
|
|
|
class GSDevice : public GSAlignedClass<32>
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-05-22 01:22:52 +00:00
|
|
|
list<GSTexture*> m_pool;
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
protected:
|
2009-06-03 12:09:04 +00:00
|
|
|
GSWnd* m_wnd;
|
2009-02-09 21:15:56 +00:00
|
|
|
bool m_vsync;
|
2009-07-06 16:35:06 +00:00
|
|
|
bool m_rbswapped;
|
2009-05-22 01:22:52 +00:00
|
|
|
GSTexture* m_backbuffer;
|
|
|
|
GSTexture* m_merge;
|
|
|
|
GSTexture* m_weavebob;
|
|
|
|
GSTexture* m_blend;
|
2014-01-17 10:17:24 +00:00
|
|
|
GSTexture* m_shaderfx;
|
2011-07-25 11:16:01 +00:00
|
|
|
GSTexture* m_fxaa;
|
2012-02-29 00:29:29 +00:00
|
|
|
GSTexture* m_shadeboost;
|
2009-05-22 01:22:52 +00:00
|
|
|
GSTexture* m_1x1;
|
|
|
|
GSTexture* m_current;
|
2012-01-05 02:40:24 +00:00
|
|
|
struct {size_t stride, start, count, limit;} m_vertex;
|
|
|
|
struct {size_t start, count, limit;} m_index;
|
2011-02-07 01:59:05 +00:00
|
|
|
unsigned int m_frame; // for ageing the pool
|
2016-08-27 17:23:12 +00:00
|
|
|
bool m_linear_present;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2011-02-22 23:39:02 +00:00
|
|
|
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);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2016-10-09 11:20:31 +00:00
|
|
|
virtual void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) = 0;
|
2015-05-15 18:45:31 +00:00
|
|
|
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) {}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
public:
|
2016-09-18 20:40:51 +00:00
|
|
|
GSOsdManager m_osd;
|
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
GSDevice();
|
|
|
|
virtual ~GSDevice();
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
void Recycle(GSTexture* t);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-07-04 15:14:04 +00:00
|
|
|
enum {Windowed, Fullscreen, DontCare};
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-10-31 01:06:23 +00:00
|
|
|
virtual bool Create(GSWnd* wnd);
|
2009-09-18 18:45:37 +00:00
|
|
|
virtual bool Reset(int w, int h);
|
2009-07-04 15:14:04 +00:00
|
|
|
virtual bool IsLost(bool update = false) {return false;}
|
2009-10-31 01:06:23 +00:00
|
|
|
virtual void Present(const GSVector4i& r, int shader);
|
2015-05-15 18:49:25 +00:00
|
|
|
virtual void Present(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, int shader = 0);
|
2009-10-31 01:06:23 +00:00
|
|
|
virtual void Flip() {}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2011-02-19 03:36:30 +00:00
|
|
|
virtual void SetVSync(bool enable) {m_vsync = enable;}
|
|
|
|
|
2009-06-03 22:45:28 +00:00
|
|
|
virtual void BeginScene() {}
|
2009-06-23 04:12:32 +00:00
|
|
|
virtual void DrawPrimitive() {};
|
2012-01-05 02:40:24 +00:00
|
|
|
virtual void DrawIndexedPrimitive() {}
|
2012-01-27 11:56:49 +00:00
|
|
|
virtual void DrawIndexedPrimitive(int offset, int count) {}
|
2009-07-31 23:59:06 +00:00
|
|
|
virtual void EndScene();
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 22:45:28 +00:00
|
|
|
virtual void ClearRenderTarget(GSTexture* t, const GSVector4& c) {}
|
|
|
|
virtual void ClearRenderTarget(GSTexture* t, uint32 c) {}
|
2016-07-27 21:22:46 +00:00
|
|
|
virtual void ClearDepth(GSTexture* t) {}
|
2009-06-03 22:45:28 +00:00
|
|
|
virtual void ClearStencil(GSTexture* t, uint8 c) {}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-08-02 23:07:30 +00:00
|
|
|
virtual GSTexture* CreateRenderTarget(int w, int h, bool msaa, int format = 0);
|
|
|
|
virtual GSTexture* CreateDepthStencil(int w, int h, bool msaa, int format = 0);
|
2009-05-22 01:22:52 +00:00
|
|
|
virtual GSTexture* CreateTexture(int w, int h, int format = 0);
|
|
|
|
virtual GSTexture* CreateOffscreen(int w, int h, int format = 0);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-08-02 23:07:30 +00:00
|
|
|
virtual GSTexture* Resolve(GSTexture* t) {return NULL;}
|
|
|
|
|
2015-05-19 10:42:14 +00:00
|
|
|
virtual GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) {return NULL;}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2015-05-15 18:45:31 +00:00
|
|
|
virtual void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r) {}
|
2015-05-15 18:49:25 +00:00
|
|
|
virtual void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true) {}
|
2011-02-22 20:58:21 +00:00
|
|
|
|
2015-05-15 18:49:25 +00:00
|
|
|
void StretchRect(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true);
|
2011-02-22 23:39:02 +00:00
|
|
|
|
2009-07-22 03:55:28 +00:00
|
|
|
virtual void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) {}
|
2015-05-15 18:47:14 +00:00
|
|
|
virtual void PSSetShaderResource(int i, GSTexture* sRect) {}
|
2009-07-22 03:55:28 +00:00
|
|
|
virtual void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL) {}
|
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
GSTexture* GetCurrent();
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2016-10-09 11:20:31 +00:00
|
|
|
void Merge(GSTexture* sTex[3], GSVector4* sRect, GSVector4* dRect, const GSVector2i& fs, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c);
|
2009-06-03 12:09:04 +00:00
|
|
|
void Interlace(const GSVector2i& ds, int field, int mode, float yoffset);
|
2011-07-25 11:16:01 +00:00
|
|
|
void FXAA();
|
2012-02-29 00:29:29 +00:00
|
|
|
void ShadeBoost();
|
2014-01-17 10:17:24 +00:00
|
|
|
void ExternalFX();
|
2016-09-18 20:40:51 +00:00
|
|
|
virtual void RenderOsd(GSTexture* dt) {};
|
2009-06-19 20:24:18 +00:00
|
|
|
|
2009-07-04 15:14:04 +00:00
|
|
|
bool ResizeTexture(GSTexture** t, int w, int h);
|
|
|
|
|
2009-07-06 16:35:06 +00:00
|
|
|
bool IsRBSwapped() {return m_rbswapped;}
|
|
|
|
|
2010-05-23 15:33:50 +00:00
|
|
|
void AgePool();
|
2016-05-05 14:43:02 +00:00
|
|
|
void PurgePool();
|
2015-07-10 19:11:14 +00:00
|
|
|
|
|
|
|
virtual void PrintMemoryUsage();
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|
2011-02-22 23:39:02 +00:00
|
|
|
|
2012-08-06 05:26:44 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-01-27 15:33:10 +00:00
|
|
|
#ifdef _WIN32
|
2012-08-06 05:26:44 +00:00
|
|
|
GSAdapter(const DXGI_ADAPTER_DESC1 &desc_dxgi);
|
|
|
|
GSAdapter(const D3DADAPTER_IDENTIFIER9 &desc_d3d9);
|
|
|
|
#endif
|
2014-12-15 18:14:30 +00:00
|
|
|
#ifdef __linux__
|
2012-08-06 05:26:44 +00:00
|
|
|
// TODO
|
|
|
|
#endif
|
2013-10-24 20:54:27 +00:00
|
|
|
};
|