2011-11-16 22:17:37 +00:00
|
|
|
/*
|
2013-07-06 10:08:52 +00:00
|
|
|
* Copyright (C) 2011-2013 Gregory hainaut
|
2011-11-16 22:17:37 +00:00
|
|
|
* Copyright (C) 2007-2009 Gabest
|
|
|
|
*
|
|
|
|
* 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
|
2012-09-09 18:16:11 +00:00
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
2011-11-16 22:17:37 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GSDevice.h"
|
|
|
|
#include "GSTextureOGL.h"
|
|
|
|
#include "GSdx.h"
|
2012-05-13 17:09:18 +00:00
|
|
|
#include "GSVertexArrayOGL.h"
|
|
|
|
#include "GSUniformBufferOGL.h"
|
2013-07-06 10:08:52 +00:00
|
|
|
#include "GSShaderOGL.h"
|
2013-08-05 20:25:25 +00:00
|
|
|
#include "GLState.h"
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2012-01-03 13:11:40 +00:00
|
|
|
class GSBlendStateOGL {
|
2011-11-16 22:17:37 +00:00
|
|
|
// Note: You can also select the index of the draw buffer for which to set the blend setting
|
|
|
|
// We will keep basic the first try
|
|
|
|
bool m_enable;
|
|
|
|
GLenum m_equation_RGB;
|
2013-08-05 20:25:25 +00:00
|
|
|
GLenum m_equation_A;
|
2011-11-21 22:36:03 +00:00
|
|
|
GLenum m_func_sRGB;
|
|
|
|
GLenum m_func_dRGB;
|
2013-08-05 20:25:25 +00:00
|
|
|
GLenum m_func_sA;
|
|
|
|
GLenum m_func_dA;
|
2011-12-19 21:03:23 +00:00
|
|
|
bool m_r_msk;
|
|
|
|
bool m_b_msk;
|
|
|
|
bool m_g_msk;
|
|
|
|
bool m_a_msk;
|
2012-01-03 13:11:40 +00:00
|
|
|
bool constant_factor;
|
|
|
|
|
|
|
|
public:
|
2011-11-26 11:46:51 +00:00
|
|
|
|
|
|
|
GSBlendStateOGL() : m_enable(false)
|
|
|
|
, m_equation_RGB(0)
|
2013-08-05 20:25:25 +00:00
|
|
|
, m_equation_A(GL_FUNC_ADD)
|
2011-11-26 11:46:51 +00:00
|
|
|
, m_func_sRGB(0)
|
|
|
|
, m_func_dRGB(0)
|
2013-08-05 20:25:25 +00:00
|
|
|
, m_func_sA(GL_ONE)
|
|
|
|
, m_func_dA(GL_ZERO)
|
2011-12-19 21:03:23 +00:00
|
|
|
, m_r_msk(GL_TRUE)
|
|
|
|
, m_b_msk(GL_TRUE)
|
|
|
|
, m_g_msk(GL_TRUE)
|
|
|
|
, m_a_msk(GL_TRUE)
|
2012-01-08 21:59:42 +00:00
|
|
|
, constant_factor(false)
|
2011-11-26 11:46:51 +00:00
|
|
|
{}
|
|
|
|
|
2012-01-03 13:11:40 +00:00
|
|
|
void SetRGB(GLenum op, GLenum src, GLenum dst)
|
|
|
|
{
|
|
|
|
m_equation_RGB = op;
|
|
|
|
m_func_sRGB = src;
|
|
|
|
m_func_dRGB = dst;
|
|
|
|
if (IsConstant(src) || IsConstant(dst)) constant_factor = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetALPHA(GLenum op, GLenum src, GLenum dst)
|
|
|
|
{
|
2013-08-05 20:25:25 +00:00
|
|
|
m_equation_A = op;
|
|
|
|
m_func_sA = src;
|
|
|
|
m_func_dA = dst;
|
2012-01-03 13:11:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetMask(bool r, bool g, bool b, bool a) { m_r_msk = r; m_g_msk = g; m_b_msk = b; m_a_msk = a; }
|
|
|
|
|
|
|
|
void RevertOp()
|
|
|
|
{
|
|
|
|
if(m_equation_RGB == GL_FUNC_ADD)
|
|
|
|
m_equation_RGB = GL_FUNC_REVERSE_SUBTRACT;
|
|
|
|
else if(m_equation_RGB == GL_FUNC_REVERSE_SUBTRACT)
|
|
|
|
m_equation_RGB = GL_FUNC_ADD;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EnableBlend() { m_enable = true;}
|
|
|
|
|
|
|
|
bool IsConstant(GLenum factor) { return ((factor == GL_CONSTANT_COLOR) || (factor == GL_ONE_MINUS_CONSTANT_COLOR)); }
|
|
|
|
|
|
|
|
bool HasConstantFactor() { return constant_factor; }
|
|
|
|
|
|
|
|
void SetupColorMask()
|
|
|
|
{
|
2013-08-05 20:25:25 +00:00
|
|
|
// FIXME align then SSE
|
|
|
|
if (GLState::r_msk != m_r_msk || GLState::g_msk != m_g_msk || GLState::b_msk != m_b_msk || GLState::a_msk != m_a_msk) {
|
|
|
|
GLState::r_msk = m_r_msk;
|
|
|
|
GLState::g_msk = m_g_msk;
|
|
|
|
GLState::b_msk = m_b_msk;
|
|
|
|
GLState::a_msk = m_a_msk;
|
|
|
|
|
|
|
|
gl_ColorMaski(0, m_r_msk, m_g_msk, m_b_msk, m_a_msk);
|
|
|
|
}
|
2012-01-03 13:11:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetupBlend(float factor)
|
|
|
|
{
|
|
|
|
SetupColorMask();
|
|
|
|
|
2013-08-05 20:25:25 +00:00
|
|
|
if (GLState::blend != m_enable) {
|
|
|
|
GLState::blend = m_enable;
|
|
|
|
if (m_enable)
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
else
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2012-01-03 13:11:40 +00:00
|
|
|
if (m_enable) {
|
2012-01-08 21:59:42 +00:00
|
|
|
if (HasConstantFactor()) {
|
2013-08-05 20:25:25 +00:00
|
|
|
if (GLState::bf != factor) {
|
|
|
|
GLState::bf = factor;
|
|
|
|
gl_BlendColor(factor, factor, factor, 0);
|
|
|
|
}
|
2012-01-08 21:59:42 +00:00
|
|
|
}
|
2012-01-03 13:11:40 +00:00
|
|
|
|
2013-08-05 20:25:25 +00:00
|
|
|
if (GLState::eq_RGB != m_equation_RGB || GLState::eq_A != m_equation_A) {
|
|
|
|
GLState::eq_RGB = m_equation_RGB;
|
|
|
|
GLState::eq_A = m_equation_A;
|
|
|
|
gl_BlendEquationSeparateiARB(0, m_equation_RGB, m_equation_A);
|
|
|
|
}
|
|
|
|
// FIXME align then SSE
|
|
|
|
if (GLState::f_sRGB != m_func_sRGB || GLState::f_dRGB != m_func_dRGB || GLState::f_sA != m_func_sA || GLState::f_dA != m_func_dA) {
|
|
|
|
GLState::f_sRGB = m_func_sRGB;
|
|
|
|
GLState::f_dRGB = m_func_dRGB;
|
|
|
|
GLState::f_sA = m_func_sA;
|
|
|
|
GLState::f_dA = m_func_dA;
|
|
|
|
gl_BlendFuncSeparateiARB(0, m_func_sRGB, m_func_dRGB, m_func_sA, m_func_dA);
|
|
|
|
}
|
2012-01-03 13:11:40 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-16 22:17:37 +00:00
|
|
|
};
|
|
|
|
|
2012-01-03 13:11:40 +00:00
|
|
|
class GSDepthStencilOGL {
|
2011-11-16 22:17:37 +00:00
|
|
|
bool m_depth_enable;
|
|
|
|
GLenum m_depth_func;
|
2011-11-21 22:36:03 +00:00
|
|
|
GLboolean m_depth_mask;
|
2011-12-19 21:03:23 +00:00
|
|
|
// Note front face and back might be split but it seems they have same parameter configuration
|
2011-11-16 22:17:37 +00:00
|
|
|
bool m_stencil_enable;
|
2013-08-05 20:25:25 +00:00
|
|
|
GLenum m_stencil_func;
|
|
|
|
GLenum m_stencil_spass_dpass_op;
|
2011-11-26 11:46:51 +00:00
|
|
|
|
2012-01-03 13:11:40 +00:00
|
|
|
public:
|
|
|
|
|
2011-11-26 11:46:51 +00:00
|
|
|
GSDepthStencilOGL() : m_depth_enable(false)
|
|
|
|
, m_depth_func(0)
|
|
|
|
, m_depth_mask(0)
|
|
|
|
, m_stencil_enable(false)
|
|
|
|
, m_stencil_func(0)
|
2011-12-19 21:03:23 +00:00
|
|
|
, m_stencil_spass_dpass_op(GL_KEEP)
|
2013-07-19 19:25:50 +00:00
|
|
|
{
|
|
|
|
// Only needed once since m_stencil_mask is constant
|
|
|
|
// Control which stencil bitplane are written
|
2013-08-05 20:25:25 +00:00
|
|
|
glStencilMask(1);
|
2013-07-19 19:25:50 +00:00
|
|
|
}
|
2011-12-19 21:03:23 +00:00
|
|
|
|
2012-01-03 13:11:40 +00:00
|
|
|
void EnableDepth() { m_depth_enable = true; }
|
|
|
|
void EnableStencil() { m_stencil_enable = true; }
|
|
|
|
|
|
|
|
void SetDepth(GLenum func, GLboolean mask) { m_depth_func = func; m_depth_mask = mask; }
|
2013-08-05 20:25:25 +00:00
|
|
|
void SetStencil(GLenum func, GLenum pass) { m_stencil_func = func; m_stencil_spass_dpass_op = pass; }
|
2012-01-03 13:11:40 +00:00
|
|
|
|
|
|
|
void SetupDepth()
|
|
|
|
{
|
2013-08-05 20:25:25 +00:00
|
|
|
if (GLState::depth != m_depth_enable) {
|
|
|
|
GLState::depth = m_depth_enable;
|
|
|
|
if (m_depth_enable)
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
else
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
|
2012-01-03 13:11:40 +00:00
|
|
|
if (m_depth_enable) {
|
2013-08-05 20:25:25 +00:00
|
|
|
if (GLState::depth_func != m_depth_func) {
|
|
|
|
GLState::depth_func = m_depth_func;
|
|
|
|
glDepthFunc(m_depth_func);
|
|
|
|
}
|
|
|
|
if (GLState::depth_mask != m_depth_mask) {
|
|
|
|
GLState::depth_mask = m_depth_mask;
|
|
|
|
glDepthMask(m_depth_mask);
|
|
|
|
}
|
|
|
|
}
|
2012-01-03 13:11:40 +00:00
|
|
|
}
|
|
|
|
|
2013-06-14 11:34:44 +00:00
|
|
|
void SetupStencil()
|
2012-01-03 13:11:40 +00:00
|
|
|
{
|
2013-08-05 20:25:25 +00:00
|
|
|
if (GLState::stencil != m_stencil_enable) {
|
|
|
|
GLState::stencil = m_stencil_enable;
|
|
|
|
if (m_stencil_enable)
|
|
|
|
glEnable(GL_STENCIL_TEST);
|
|
|
|
else
|
|
|
|
glDisable(GL_STENCIL_TEST);
|
|
|
|
}
|
|
|
|
|
2012-01-03 13:11:40 +00:00
|
|
|
if (m_stencil_enable) {
|
2013-06-12 20:57:16 +00:00
|
|
|
// Note: here the mask control which bitplane is considered by the operation
|
2013-08-05 20:25:25 +00:00
|
|
|
if (GLState::stencil_func != m_stencil_func) {
|
|
|
|
GLState::stencil_func = m_stencil_func;
|
|
|
|
glStencilFunc(m_stencil_func, 1, 1);
|
|
|
|
}
|
|
|
|
if (GLState::stencil_pass != m_stencil_spass_dpass_op) {
|
|
|
|
GLState::stencil_pass = m_stencil_spass_dpass_op;
|
|
|
|
glStencilOp(GL_KEEP, GL_KEEP, m_stencil_spass_dpass_op);
|
|
|
|
}
|
|
|
|
}
|
2012-01-03 13:11:40 +00:00
|
|
|
}
|
|
|
|
|
2013-06-16 02:48:16 +00:00
|
|
|
bool IsMaskEnable() { return m_depth_mask != GL_FALSE; }
|
2011-11-16 22:17:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class GSDeviceOGL : public GSDevice
|
|
|
|
{
|
2011-12-19 21:03:23 +00:00
|
|
|
public:
|
|
|
|
__aligned(struct, 32) VSConstantBuffer
|
|
|
|
{
|
2013-06-26 20:09:07 +00:00
|
|
|
GSVector4 Vertex_Scale_Offset;
|
2011-12-19 21:03:23 +00:00
|
|
|
GSVector4 TextureScale;
|
|
|
|
|
|
|
|
VSConstantBuffer()
|
|
|
|
{
|
2013-06-26 20:09:07 +00:00
|
|
|
Vertex_Scale_Offset = GSVector4::zero();
|
2011-12-19 21:03:23 +00:00
|
|
|
TextureScale = GSVector4::zero();
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline bool Update(const VSConstantBuffer* cb)
|
|
|
|
{
|
|
|
|
GSVector4i* a = (GSVector4i*)this;
|
|
|
|
GSVector4i* b = (GSVector4i*)cb;
|
|
|
|
|
|
|
|
GSVector4i b0 = b[0];
|
|
|
|
GSVector4i b1 = b[1];
|
|
|
|
|
2013-06-26 20:09:07 +00:00
|
|
|
if(!((a[0] == b0) & (a[1] == b1)).alltrue())
|
2011-12-19 21:03:23 +00:00
|
|
|
{
|
|
|
|
a[0] = b0;
|
|
|
|
a[1] = b1;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VSSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 bppz:2;
|
|
|
|
uint32 tme:1;
|
|
|
|
uint32 fst:1;
|
|
|
|
uint32 logz:1;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
|
|
|
operator uint32() {return key & 0x3f;}
|
|
|
|
|
|
|
|
VSSelector() : key(0) {}
|
2013-06-26 20:09:07 +00:00
|
|
|
VSSelector(uint32 k) : key(k) {}
|
|
|
|
|
|
|
|
static uint32 size() { return 1 << 5; }
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
__aligned(struct, 32) PSConstantBuffer
|
|
|
|
{
|
|
|
|
GSVector4 FogColor_AREF;
|
|
|
|
GSVector4 HalfTexel;
|
|
|
|
GSVector4 WH;
|
|
|
|
GSVector4 MinMax;
|
|
|
|
GSVector4 MinF_TA;
|
|
|
|
GSVector4i MskFix;
|
|
|
|
|
2013-02-23 15:35:56 +00:00
|
|
|
GSVector4 TC_OffsetHack;
|
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
PSConstantBuffer()
|
|
|
|
{
|
|
|
|
FogColor_AREF = GSVector4::zero();
|
|
|
|
HalfTexel = GSVector4::zero();
|
|
|
|
WH = GSVector4::zero();
|
|
|
|
MinMax = GSVector4::zero();
|
|
|
|
MinF_TA = GSVector4::zero();
|
|
|
|
MskFix = GSVector4i::zero();
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline bool Update(const PSConstantBuffer* cb)
|
|
|
|
{
|
|
|
|
GSVector4i* a = (GSVector4i*)this;
|
|
|
|
GSVector4i* b = (GSVector4i*)cb;
|
|
|
|
|
|
|
|
GSVector4i b0 = b[0];
|
|
|
|
GSVector4i b1 = b[1];
|
|
|
|
GSVector4i b2 = b[2];
|
|
|
|
GSVector4i b3 = b[3];
|
|
|
|
GSVector4i b4 = b[4];
|
|
|
|
GSVector4i b5 = b[5];
|
|
|
|
|
2013-06-26 20:09:07 +00:00
|
|
|
// if WH matches both HalfTexel and TC_OffsetHack do too
|
|
|
|
if(!((a[0] == b0) & (a[2] == b2) & (a[3] == b3) & (a[4] == b4) & (a[5] == b5)).alltrue())
|
2011-12-19 21:03:23 +00:00
|
|
|
{
|
|
|
|
a[0] = b0;
|
|
|
|
a[1] = b1;
|
|
|
|
a[2] = b2;
|
|
|
|
a[3] = b3;
|
|
|
|
a[4] = b4;
|
|
|
|
a[5] = b5;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PSSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 fst:1;
|
|
|
|
uint32 wms:2;
|
|
|
|
uint32 wmt:2;
|
|
|
|
uint32 fmt:3;
|
|
|
|
uint32 aem:1;
|
|
|
|
uint32 tfx:3;
|
|
|
|
uint32 tcc:1;
|
|
|
|
uint32 atst:3;
|
|
|
|
uint32 fog:1;
|
|
|
|
uint32 clr1:1;
|
|
|
|
uint32 fba:1;
|
|
|
|
uint32 aout:1;
|
|
|
|
uint32 ltf:1;
|
|
|
|
uint32 colclip:2;
|
|
|
|
uint32 date:2;
|
2012-04-26 21:42:16 +00:00
|
|
|
uint32 spritehack:1;
|
2013-02-23 15:35:56 +00:00
|
|
|
uint32 tcoffsethack:1;
|
2012-08-15 10:14:13 +00:00
|
|
|
uint32 point_sampler:1;
|
2013-08-14 10:18:38 +00:00
|
|
|
uint32 iip:1;
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
2013-08-14 10:18:38 +00:00
|
|
|
operator uint32() {return key & 0x1fffffff;}
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
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) {}
|
2013-06-26 20:09:07 +00:00
|
|
|
PSSamplerSelector(uint32 k) : key(k) {}
|
|
|
|
|
|
|
|
static uint32 size() { return 1 << 3; }
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OMDepthStencilSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 ztst:2;
|
|
|
|
uint32 zwe:1;
|
|
|
|
uint32 date:1;
|
|
|
|
uint32 fba:1;
|
2012-08-15 10:14:13 +00:00
|
|
|
uint32 alpha_stencil:1;
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
2012-08-15 10:14:13 +00:00
|
|
|
operator uint32() {return key & 0x3f;}
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
OMDepthStencilSelector() : key(0) {}
|
2013-06-26 20:09:07 +00:00
|
|
|
OMDepthStencilSelector(uint32 k) : key(k) {}
|
|
|
|
|
|
|
|
static uint32 size() { return 1 << 6; }
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
uint32 negative:1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 _pad:1;
|
|
|
|
uint32 abcd:8;
|
|
|
|
uint32 wrgba:4;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
|
|
|
operator uint32() {return key & 0x3fff;}
|
|
|
|
|
|
|
|
OMBlendSelector() : key(0) {}
|
|
|
|
|
|
|
|
bool IsCLR1() const
|
|
|
|
{
|
|
|
|
return (key & 0x19f) == 0x93; // abe == 1 && a == 1 && b == 2 && d == 1
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct D3D9Blend {int bogus, op, src, dst;};
|
|
|
|
static const D3D9Blend m_blendMapD3D9[3*3*3*3];
|
|
|
|
|
|
|
|
private:
|
2011-11-21 22:36:03 +00:00
|
|
|
uint32 m_msaa; // Level of Msaa
|
|
|
|
|
|
|
|
bool m_free_window;
|
2011-12-08 11:17:59 +00:00
|
|
|
GSWnd* m_window;
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-11-21 22:36:03 +00:00
|
|
|
GLuint m_fbo; // frame buffer container
|
2012-01-08 21:59:42 +00:00
|
|
|
GLuint m_fbo_read; // frame buffer container only for reading
|
2011-12-15 18:27:58 +00:00
|
|
|
|
2011-12-31 14:38:58 +00:00
|
|
|
GSVertexBufferStateOGL* m_vb; // vb_state for HW renderer
|
|
|
|
GSVertexBufferStateOGL* m_vb_sr; // vb_state for StretchRect
|
2011-11-16 22:17:37 +00:00
|
|
|
|
|
|
|
struct {
|
2011-12-11 19:09:08 +00:00
|
|
|
GLuint ps[2]; // program object
|
|
|
|
GSUniformBufferOGL* cb; // uniform buffer object
|
2011-11-16 22:17:37 +00:00
|
|
|
GSBlendStateOGL* bs;
|
2012-01-08 21:59:42 +00:00
|
|
|
} m_merge_obj;
|
2011-11-16 22:17:37 +00:00
|
|
|
|
|
|
|
struct {
|
2011-11-21 22:36:03 +00:00
|
|
|
GLuint ps[4]; // program object
|
2011-11-16 22:17:37 +00:00
|
|
|
GSUniformBufferOGL* cb; // uniform buffer object
|
|
|
|
} m_interlace;
|
|
|
|
|
2011-11-21 22:36:03 +00:00
|
|
|
struct {
|
2011-11-16 22:17:37 +00:00
|
|
|
GLuint vs; // program object
|
|
|
|
GLuint ps[8]; // program object
|
|
|
|
GLuint ln; // sampler object
|
|
|
|
GLuint pt; // sampler object
|
|
|
|
GSDepthStencilOGL* dss;
|
|
|
|
GSBlendStateOGL* bs;
|
|
|
|
} m_convert;
|
|
|
|
|
2012-01-31 17:08:05 +00:00
|
|
|
struct {
|
2011-12-19 21:03:23 +00:00
|
|
|
GLuint ps;
|
|
|
|
GSUniformBufferOGL *cb;
|
|
|
|
} m_fxaa;
|
|
|
|
|
2012-01-31 17:08:05 +00:00
|
|
|
struct {
|
2011-11-16 22:17:37 +00:00
|
|
|
GSDepthStencilOGL* dss;
|
|
|
|
GSBlendStateOGL* bs;
|
2013-07-28 14:40:43 +00:00
|
|
|
GSTexture* t;
|
2011-11-16 22:17:37 +00:00
|
|
|
} m_date;
|
|
|
|
|
2013-08-05 20:25:25 +00:00
|
|
|
struct {
|
2012-04-26 21:42:16 +00:00
|
|
|
GLuint ps;
|
|
|
|
GSUniformBufferOGL *cb;
|
|
|
|
} m_shadeboost;
|
|
|
|
|
2012-01-31 17:08:05 +00:00
|
|
|
struct {
|
2012-01-03 16:12:34 +00:00
|
|
|
GSVertexBufferStateOGL* vb;
|
2011-11-16 22:17:37 +00:00
|
|
|
GSDepthStencilOGL* dss;
|
|
|
|
GSBlendStateOGL* bs;
|
2013-07-19 19:25:50 +00:00
|
|
|
float bf; // blend factor
|
2011-11-16 22:17:37 +00:00
|
|
|
} m_state;
|
|
|
|
|
2013-06-26 20:09:07 +00:00
|
|
|
GLuint m_vs[1<<5];
|
2013-08-14 10:18:38 +00:00
|
|
|
GLuint m_gs;
|
2013-06-26 20:09:07 +00:00
|
|
|
GLuint m_ps_ss[1<<3];
|
|
|
|
GSDepthStencilOGL* m_om_dss[1<<6];
|
2011-12-19 21:03:23 +00:00
|
|
|
hash_map<uint32, GLuint > m_ps;
|
|
|
|
hash_map<uint32, GSBlendStateOGL* > m_om_bs;
|
|
|
|
|
|
|
|
GLuint m_palette_ss;
|
|
|
|
GLuint m_rt_ss;
|
|
|
|
|
|
|
|
GSUniformBufferOGL* m_vs_cb;
|
|
|
|
GSUniformBufferOGL* m_ps_cb;
|
2011-11-16 22:17:37 +00:00
|
|
|
|
|
|
|
VSConstantBuffer m_vs_cb_cache;
|
|
|
|
PSConstantBuffer m_ps_cb_cache;
|
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format);
|
|
|
|
GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format);
|
2013-06-14 21:22:44 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c);
|
|
|
|
void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0);
|
2013-06-14 21:22:44 +00:00
|
|
|
void DoFXAA(GSTexture* st, GSTexture* dt);
|
2012-04-26 21:42:16 +00:00
|
|
|
void DoShadeBoost(GSTexture* st, GSTexture* dt);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2013-08-05 20:25:25 +00:00
|
|
|
void OMAttachRt(GLuint rt);
|
|
|
|
void OMAttachDs(GLuint ds);
|
2013-07-19 19:25:50 +00:00
|
|
|
void OMSetFBO(GLuint fbo);
|
|
|
|
|
2011-11-16 22:17:37 +00:00
|
|
|
public:
|
2013-08-17 08:57:52 +00:00
|
|
|
GSShaderOGL* m_shader;
|
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
GSDeviceOGL();
|
|
|
|
virtual ~GSDeviceOGL();
|
|
|
|
|
|
|
|
void CheckDebugLog();
|
|
|
|
static void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message);
|
|
|
|
|
|
|
|
bool HasStencil() { return true; }
|
|
|
|
bool HasDepth32() { return true; }
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
bool Create(GSWnd* wnd);
|
|
|
|
bool Reset(int w, int h);
|
|
|
|
void Flip();
|
2012-10-21 18:10:13 +00:00
|
|
|
void SetVSync(bool enable);
|
2011-12-08 16:39:14 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void DrawPrimitive();
|
2012-01-15 17:25:49 +00:00
|
|
|
void DrawIndexedPrimitive();
|
2012-02-11 10:22:02 +00:00
|
|
|
void DrawIndexedPrimitive(int offset, int count);
|
2013-04-19 19:16:26 +00:00
|
|
|
void BeforeDraw();
|
|
|
|
void AfterDraw();
|
2011-12-08 16:39:14 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void ClearRenderTarget(GSTexture* t, const GSVector4& c);
|
|
|
|
void ClearRenderTarget(GSTexture* t, uint32 c);
|
2013-07-28 14:40:43 +00:00
|
|
|
void ClearRenderTarget_ui(GSTexture* t, uint32 c);
|
2011-12-19 21:03:23 +00:00
|
|
|
void ClearDepth(GSTexture* t, float c);
|
|
|
|
void ClearStencil(GSTexture* t, uint8 c);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
GSTexture* CreateRenderTarget(int w, int h, bool msaa, int format = 0);
|
|
|
|
GSTexture* CreateDepthStencil(int w, int h, bool msaa, int format = 0);
|
|
|
|
GSTexture* CreateTexture(int w, int h, int format = 0);
|
|
|
|
GSTexture* CreateOffscreen(int w, int h, int format = 0);
|
2013-07-28 14:40:43 +00:00
|
|
|
void InitPrimDateTexture(int w, int h);
|
|
|
|
void RecycleDateTexture();
|
2013-08-02 16:38:12 +00:00
|
|
|
void BindDateTexture();
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sr, int w, int h, int format = 0);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r);
|
|
|
|
void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, int shader = 0, bool linear = true);
|
|
|
|
void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, bool linear = true);
|
|
|
|
void StretchRect(GSTexture* st, const GSVector4& sr, GSTexture* dt, const GSVector4& dr, GLuint ps, GSBlendStateOGL* bs, bool linear = true);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void EndScene();
|
2011-11-21 22:36:03 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void IASetPrimitiveTopology(GLenum topology);
|
|
|
|
void IASetVertexBuffer(const void* vertices, size_t count);
|
2012-02-11 10:22:02 +00:00
|
|
|
bool IAMapVertexBuffer(void** vertex, size_t stride, size_t count);
|
|
|
|
void IAUnmapVertexBuffer();
|
2012-01-15 17:25:49 +00:00
|
|
|
void IASetIndexBuffer(const void* index, size_t count);
|
2012-02-11 10:22:02 +00:00
|
|
|
void IASetVertexState(GSVertexBufferStateOGL* vb = NULL);
|
2011-12-15 18:27:58 +00:00
|
|
|
|
2013-08-10 19:43:59 +00:00
|
|
|
void PSSetShaderResource(GLuint sr);
|
2013-08-05 20:25:25 +00:00
|
|
|
void PSSetShaderResources(GLuint tex[2]);
|
2013-08-02 16:38:12 +00:00
|
|
|
void PSSetSamplerState(GLuint ss);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref);
|
|
|
|
void OMSetBlendState(GSBlendStateOGL* bs, float bf);
|
|
|
|
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
|
2013-07-28 14:40:43 +00:00
|
|
|
void OMSetWriteBuffer(GLenum buffer = GL_COLOR_ATTACHMENT0);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void CreateTextureFX();
|
2013-06-26 20:09:07 +00:00
|
|
|
GLuint CompileVS(VSSelector sel);
|
2013-08-14 10:18:38 +00:00
|
|
|
GLuint CompileGS();
|
2013-06-26 20:09:07 +00:00
|
|
|
GLuint CompilePS(PSSelector sel);
|
|
|
|
GLuint CreateSampler(bool bilinear, bool tau, bool tav);
|
|
|
|
GLuint CreateSampler(PSSamplerSelector sel);
|
|
|
|
GSDepthStencilOGL* CreateDepthStencil(OMDepthStencilSelector dssel);
|
|
|
|
GSBlendStateOGL* CreateBlend(OMBlendSelector bsel, uint8 afix);
|
|
|
|
|
|
|
|
|
2012-01-15 17:25:49 +00:00
|
|
|
void SetupIA(const void* vertex, int vertex_count, const uint32* index, int index_count, int prim);
|
2013-08-10 19:43:59 +00:00
|
|
|
void SetupVS(VSSelector sel);
|
2013-08-14 10:18:38 +00:00
|
|
|
void SetupGS(bool enable);
|
2013-08-10 19:43:59 +00:00
|
|
|
void SetupPS(PSSelector sel);
|
|
|
|
void SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb);
|
2013-08-17 08:57:52 +00:00
|
|
|
void SetupSampler(PSSamplerSelector ssel);
|
2011-12-19 21:03:23 +00:00
|
|
|
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
2013-08-17 08:57:52 +00:00
|
|
|
GLuint GetSamplerID(PSSamplerSelector ssel);
|
|
|
|
GLuint GetPaletteSamplerID();
|
2013-07-19 19:25:50 +00:00
|
|
|
|
2013-08-02 16:38:12 +00:00
|
|
|
void Barrier(GLbitfield b);
|
2011-11-16 22:17:37 +00:00
|
|
|
};
|