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"
|
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:
|
|
|
|
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
|
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
|
|
|
|
2011-02-21 23:25:25 +00:00
|
|
|
virtual void DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c) = 0;
|
2009-05-22 01:22:52 +00:00
|
|
|
virtual void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset) = 0;
|
2011-07-25 11:16:01 +00:00
|
|
|
virtual void DoFXAA(GSTexture* st, GSTexture* dt) {}
|
2012-02-29 00:29:29 +00:00
|
|
|
virtual void DoShadeBoost(GSTexture* st, GSTexture* dt) {}
|
2014-01-17 10:17:24 +00:00
|
|
|
virtual void DoExternalFX(GSTexture* st, GSTexture* dt) {}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
public:
|
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);
|
2011-02-22 09:43:59 +00:00
|
|
|
virtual void Present(GSTexture* st, GSTexture* dt, const GSVector4& dr, 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) {}
|
|
|
|
virtual void ClearDepth(GSTexture* t, float c) {}
|
|
|
|
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;}
|
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
virtual GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format = 0) {return NULL;}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-07-06 16:35:06 +00:00
|
|
|
virtual void CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) {}
|
2011-02-22 21:12:04 +00:00
|
|
|
virtual void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true) {}
|
2011-02-22 20:58:21 +00:00
|
|
|
|
2011-02-22 23:39:02 +00:00
|
|
|
void StretchRect(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true);
|
|
|
|
|
2009-07-22 03:55:28 +00:00
|
|
|
virtual void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) {}
|
2010-05-14 14:05:39 +00:00
|
|
|
virtual void PSSetShaderResource(int i, GSTexture* sr) {}
|
2009-07-22 03:55:28 +00:00
|
|
|
virtual void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL) {}
|
|
|
|
|
2013-10-24 20:54:27 +00:00
|
|
|
// Used for opengl multithread hack
|
|
|
|
virtual void AttachContext() {}
|
|
|
|
virtual void DetachContext() {}
|
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
GSTexture* GetCurrent();
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
void Merge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, const GSVector2i& fs, bool slbg, bool mmod, 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();
|
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();
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _WINDOWS
|
|
|
|
GSAdapter(const DXGI_ADAPTER_DESC1 &desc_dxgi);
|
|
|
|
GSAdapter(const D3DADAPTER_IDENTIFIER9 &desc_d3d9);
|
|
|
|
#endif
|
|
|
|
#ifdef _LINUX
|
|
|
|
// TODO
|
|
|
|
#endif
|
2013-10-24 20:54:27 +00:00
|
|
|
};
|