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
|
2010-04-25 00:31:27 +00:00
|
|
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, 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)
|
|
|
|
|
|
|
|
struct MergeConstantBuffer
|
|
|
|
{
|
|
|
|
GSVector4 BGColor;
|
|
|
|
|
|
|
|
struct MergeConstantBuffer() {memset(this, 0, sizeof(*this));}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct InterlaceConstantBuffer
|
|
|
|
{
|
|
|
|
GSVector2 ZrH;
|
|
|
|
float hH;
|
|
|
|
float _pad[1];
|
|
|
|
|
|
|
|
struct InterlaceConstantBuffer() {memset(this, 0, sizeof(*this));}
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
class GSDevice : public GSAlignedClass<16>
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-05-22 01:22:52 +00:00
|
|
|
list<GSTexture*> m_pool;
|
|
|
|
|
2009-08-02 23:07:30 +00:00
|
|
|
GSTexture* Fetch(int type, int w, int h, bool msaa, int format);
|
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;
|
|
|
|
GSTexture* m_1x1;
|
|
|
|
GSTexture* m_current;
|
2009-07-22 03:55:28 +00:00
|
|
|
struct {D3D_FEATURE_LEVEL level; string model, vs, gs, ps;} m_shader;
|
2009-07-31 23:59:06 +00:00
|
|
|
struct {size_t stride, start, count, limit;} m_vertices;
|
2009-08-02 23:07:30 +00:00
|
|
|
uint32 m_msaa;
|
|
|
|
DXGI_SAMPLE_DESC m_msaa_desc;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-08-02 23:07:30 +00:00
|
|
|
virtual GSTexture* Create(int type, int w, int h, bool msaa, int format) = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-22 01:22:52 +00:00
|
|
|
virtual void DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c) = 0;
|
|
|
|
virtual void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset) = 0;
|
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);
|
|
|
|
virtual void Flip() {}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 22:45:28 +00:00
|
|
|
virtual void BeginScene() {}
|
2009-06-23 04:12:32 +00:00
|
|
|
virtual void DrawPrimitive() {};
|
2009-07-31 23:59:06 +00:00
|
|
|
virtual void EndScene();
|
2009-10-31 01:06:23 +00:00
|
|
|
virtual void SetVsync(bool enable) { m_vsync = enable; }
|
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) {}
|
|
|
|
|
2009-05-22 23:23:38 +00:00
|
|
|
virtual void StretchRect(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true);
|
|
|
|
virtual void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true) {}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-07-22 03:55:28 +00:00
|
|
|
virtual void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) {}
|
|
|
|
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
|
|
|
|
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);
|
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;}
|
|
|
|
|
2009-07-22 03:55:28 +00:00
|
|
|
template<class T> void PrepareShaderMacro(vector<T>& dst, const T* src)
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
|
|
|
dst.clear();
|
|
|
|
|
|
|
|
while(src && src->Definition && src->Name)
|
|
|
|
{
|
|
|
|
dst.push_back(*src++);
|
|
|
|
}
|
|
|
|
|
|
|
|
T m;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-06-19 20:24:18 +00:00
|
|
|
m.Name = "SHADER_MODEL";
|
2009-07-22 03:55:28 +00:00
|
|
|
m.Definition = m_shader.model.c_str();
|
2009-06-19 20:24:18 +00:00
|
|
|
|
|
|
|
dst.push_back(m);
|
|
|
|
|
|
|
|
m.Name = NULL;
|
|
|
|
m.Definition = NULL;
|
|
|
|
|
|
|
|
dst.push_back(m);
|
|
|
|
}
|
2009-07-22 03:55:28 +00:00
|
|
|
|
|
|
|
bool SetFeatureLevel(D3D_FEATURE_LEVEL level, bool compat_mode); // TODO: GSDeviceDX
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|