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"
|
2016-09-18 20:40:51 +00:00
|
|
|
#include "GSOsdManager.h"
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2015-05-19 22:12:52 +00:00
|
|
|
// A couple of flag to determine the blending behavior
|
2015-07-31 07:24:10 +00:00
|
|
|
#define BLEND_A_MAX (0x100) // Impossible blending uses coeff bigger than 1
|
|
|
|
#define BLEND_C_CLR (0x200) // Clear color blending (use directly the destination color as blending factor)
|
|
|
|
#define BLEND_NO_BAR (0x400) // don't require texture barrier for the blending (because the RT is not used)
|
2015-07-31 07:09:44 +00:00
|
|
|
#define BLEND_ACCU (0x800) // Allow to use a mix of SW and HW blending to keep the best of the 2 worlds
|
2015-05-19 22:12:52 +00:00
|
|
|
|
2014-03-24 14:03:02 +00:00
|
|
|
#ifdef ENABLE_OGL_DEBUG_MEM_BW
|
2015-04-25 12:18:21 +00:00
|
|
|
extern uint64 g_real_texture_upload_byte;
|
|
|
|
extern uint64 g_vertex_upload_byte;
|
2014-03-24 14:03:02 +00:00
|
|
|
#endif
|
|
|
|
|
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;
|
2014-01-26 00:58:21 +00:00
|
|
|
bool 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)
|
2015-06-05 21:26:03 +00:00
|
|
|
, m_depth_func(GL_ALWAYS)
|
2011-11-26 11:46:51 +00:00
|
|
|
, 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
|
|
|
{
|
|
|
|
}
|
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; }
|
|
|
|
|
2014-01-26 00:58:21 +00:00
|
|
|
void SetDepth(GLenum func, bool 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;
|
2014-01-26 00:58:21 +00:00
|
|
|
glDepthMask((GLboolean)m_depth_mask);
|
2013-08-05 20:25:25 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
};
|
|
|
|
|
2016-04-04 22:01:43 +00:00
|
|
|
class GSDeviceOGL final : public GSDevice
|
2011-11-16 22:17:37 +00:00
|
|
|
{
|
2016-05-11 23:24:37 +00:00
|
|
|
public:
|
|
|
|
struct alignas(32) VSConstantBuffer
|
2011-12-19 21:03:23 +00:00
|
|
|
{
|
2013-06-26 20:09:07 +00:00
|
|
|
GSVector4 Vertex_Scale_Offset;
|
2016-06-21 07:45:37 +00:00
|
|
|
|
|
|
|
GSVector4 TextureOffset;
|
|
|
|
|
2016-06-01 07:14:06 +00:00
|
|
|
GSVector2i DepthMask;
|
2016-08-21 16:34:03 +00:00
|
|
|
GSVector2 PointSize;
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
VSConstantBuffer()
|
|
|
|
{
|
2013-06-26 20:09:07 +00:00
|
|
|
Vertex_Scale_Offset = GSVector4::zero();
|
2016-06-21 07:45:37 +00:00
|
|
|
TextureOffset = GSVector4::zero();
|
2016-10-13 09:25:48 +00:00
|
|
|
DepthMask = GSVector2i(0);
|
|
|
|
PointSize = GSVector2(0);
|
2011-12-19 21:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline bool Update(const VSConstantBuffer* cb)
|
|
|
|
{
|
|
|
|
GSVector4i* a = (GSVector4i*)this;
|
|
|
|
GSVector4i* b = (GSVector4i*)cb;
|
|
|
|
|
2016-06-21 07:45:37 +00:00
|
|
|
if(!((a[0] == b[0]) & (a[1] == b[1]) & (a[2] == b[2])).alltrue())
|
2011-12-19 21:03:23 +00:00
|
|
|
{
|
2014-10-02 18:22:45 +00:00
|
|
|
a[0] = b[0];
|
|
|
|
a[1] = b[1];
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VSSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2016-06-01 07:14:06 +00:00
|
|
|
uint32 _free:32;
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
2016-04-10 12:14:30 +00:00
|
|
|
operator uint32() const {return key;}
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
VSSelector() : key(0) {}
|
2013-06-26 20:09:07 +00:00
|
|
|
VSSelector(uint32 k) : key(k) {}
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
2015-07-10 21:59:14 +00:00
|
|
|
struct GSSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 sprite:1;
|
|
|
|
uint32 point:1;
|
2016-08-21 16:34:03 +00:00
|
|
|
uint32 line:1;
|
2015-07-10 21:59:14 +00:00
|
|
|
|
2016-08-21 16:34:03 +00:00
|
|
|
uint32 _free:29;
|
2015-07-10 21:59:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
2016-04-10 12:14:30 +00:00
|
|
|
operator uint32() const {return key;}
|
2015-07-10 21:59:14 +00:00
|
|
|
|
|
|
|
GSSelector() : key(0) {}
|
|
|
|
GSSelector(uint32 k) : key(k) {}
|
|
|
|
};
|
|
|
|
|
2016-05-11 23:24:37 +00:00
|
|
|
struct alignas(32) PSConstantBuffer
|
2011-12-19 21:03:23 +00:00
|
|
|
{
|
|
|
|
GSVector4 FogColor_AREF;
|
|
|
|
GSVector4 WH;
|
2016-03-06 19:45:51 +00:00
|
|
|
GSVector4 TA_Af;
|
2011-12-19 21:03:23 +00:00
|
|
|
GSVector4i MskFix;
|
2015-06-21 06:47:45 +00:00
|
|
|
GSVector4i FbMask;
|
2011-12-19 21:03:23 +00:00
|
|
|
|
2014-10-07 17:11:43 +00:00
|
|
|
GSVector4 HalfTexel;
|
|
|
|
GSVector4 MinMax;
|
2015-08-20 19:39:30 +00:00
|
|
|
GSVector4 TC_OH_TS;
|
2013-02-23 15:35:56 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
PSConstantBuffer()
|
|
|
|
{
|
|
|
|
FogColor_AREF = GSVector4::zero();
|
2015-06-21 06:47:45 +00:00
|
|
|
HalfTexel = GSVector4::zero();
|
|
|
|
WH = GSVector4::zero();
|
2016-07-19 18:15:46 +00:00
|
|
|
TA_Af = GSVector4::zero();
|
2015-06-21 06:47:45 +00:00
|
|
|
MinMax = GSVector4::zero();
|
|
|
|
MskFix = GSVector4i::zero();
|
2015-08-20 19:39:30 +00:00
|
|
|
TC_OH_TS = GSVector4::zero();
|
2015-06-21 06:47:45 +00:00
|
|
|
FbMask = GSVector4i::zero();
|
2011-12-19 21:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline bool Update(const PSConstantBuffer* cb)
|
|
|
|
{
|
|
|
|
GSVector4i* a = (GSVector4i*)this;
|
|
|
|
GSVector4i* b = (GSVector4i*)cb;
|
|
|
|
|
2015-08-20 19:39:30 +00:00
|
|
|
// if WH matches both HalfTexel and TC_OH_TS do too
|
2014-10-02 18:22:45 +00:00
|
|
|
// MinMax depends on WH and MskFix so no need to check it too
|
2016-03-06 19:45:51 +00:00
|
|
|
if(!((a[0] == b[0]) & (a[1] == b[1]) & (a[2] == b[2]) & (a[3] == b[3]) & (a[4] == b[4])).alltrue())
|
2011-12-19 21:03:23 +00:00
|
|
|
{
|
2014-10-07 17:11:43 +00:00
|
|
|
// Note previous check uses SSE already, a plain copy will be faster than any memcpy
|
2014-10-02 18:22:45 +00:00
|
|
|
a[0] = b[0];
|
2014-10-07 17:11:43 +00:00
|
|
|
a[1] = b[1];
|
2014-10-02 18:22:45 +00:00
|
|
|
a[2] = b[2];
|
2014-10-07 17:11:43 +00:00
|
|
|
a[3] = b[3];
|
2015-05-08 18:23:38 +00:00
|
|
|
a[4] = b[4];
|
2015-06-21 06:47:45 +00:00
|
|
|
a[5] = b[5];
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PSSelector
|
|
|
|
{
|
2015-07-31 17:41:32 +00:00
|
|
|
// Performance note: there are too many shader combinations
|
|
|
|
// It might hurt the performance due to frequent toggling worse it could consume
|
|
|
|
// a lots of memory.
|
2011-12-19 21:03:23 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2015-07-31 17:41:32 +00:00
|
|
|
// *** Word 1
|
|
|
|
// Format
|
2015-08-08 11:34:55 +00:00
|
|
|
uint32 tex_fmt:4;
|
2015-07-31 17:41:32 +00:00
|
|
|
uint32 dfmt:2;
|
2016-04-23 10:06:10 +00:00
|
|
|
uint32 depth_fmt:2;
|
2015-07-31 17:41:32 +00:00
|
|
|
// Alpha extension/Correction
|
2011-12-19 21:03:23 +00:00
|
|
|
uint32 aem:1;
|
|
|
|
uint32 fba:1;
|
2015-07-31 17:41:32 +00:00
|
|
|
// Fog
|
|
|
|
uint32 fog:1;
|
|
|
|
// Flat/goround shading
|
2013-08-14 10:18:38 +00:00
|
|
|
uint32 iip:1;
|
2015-07-31 17:41:32 +00:00
|
|
|
// Pixel test
|
|
|
|
uint32 date:3;
|
2013-10-24 20:54:27 +00:00
|
|
|
uint32 atst:3;
|
2015-07-31 17:41:32 +00:00
|
|
|
// Color sampling
|
|
|
|
uint32 fst:1; // Investigate to do it on the VS
|
2013-10-24 20:54:27 +00:00
|
|
|
uint32 tfx:3;
|
|
|
|
uint32 tcc:1;
|
|
|
|
uint32 wms:2;
|
|
|
|
uint32 wmt:2;
|
|
|
|
uint32 ltf:1;
|
2015-07-31 17:41:32 +00:00
|
|
|
// Shuffle and fbmask effect
|
2015-06-06 11:56:08 +00:00
|
|
|
uint32 shuffle:1;
|
|
|
|
uint32 read_ba:1;
|
2015-08-04 18:08:33 +00:00
|
|
|
uint32 write_rg:1;
|
2015-07-19 20:43:48 +00:00
|
|
|
uint32 fbmask:1;
|
2015-05-07 16:32:58 +00:00
|
|
|
|
2016-04-23 10:06:10 +00:00
|
|
|
//uint32 _free1:0;
|
2015-05-19 22:51:37 +00:00
|
|
|
|
2015-07-31 17:41:32 +00:00
|
|
|
// *** Word 2
|
|
|
|
// Blend and Colclip
|
2015-07-13 13:19:33 +00:00
|
|
|
uint32 blend_a:2;
|
|
|
|
uint32 blend_b:2;
|
|
|
|
uint32 blend_c:2;
|
|
|
|
uint32 blend_d:2;
|
2015-07-31 17:41:32 +00:00
|
|
|
uint32 clr1:1; // useful?
|
2015-08-07 10:06:45 +00:00
|
|
|
uint32 pabe:1;
|
2015-07-30 20:05:08 +00:00
|
|
|
uint32 hdr:1;
|
2015-07-31 17:41:32 +00:00
|
|
|
uint32 colclip:1;
|
|
|
|
|
2016-04-28 20:15:28 +00:00
|
|
|
// Others ways to fetch the texture
|
|
|
|
uint32 channel:3;
|
|
|
|
|
2015-07-31 17:41:32 +00:00
|
|
|
// Hack
|
|
|
|
uint32 tcoffsethack:1;
|
2016-05-06 17:57:42 +00:00
|
|
|
uint32 urban_chaos_hle:1;
|
|
|
|
uint32 tales_of_abyss_hle:1;
|
2016-09-08 21:26:38 +00:00
|
|
|
uint32 tex_is_fb:1; // Jak Shadows
|
2016-10-06 18:15:50 +00:00
|
|
|
uint32 automatic_lod:1;
|
|
|
|
uint32 manual_lod:1;
|
2015-05-26 12:59:07 +00:00
|
|
|
|
2016-10-06 18:15:50 +00:00
|
|
|
uint32 _free2:11;
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
2015-05-19 22:51:37 +00:00
|
|
|
uint64 key;
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
2015-05-07 16:32:58 +00:00
|
|
|
// FIXME is the & useful ?
|
2016-04-10 12:14:30 +00:00
|
|
|
operator uint64() const {return key;}
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
PSSelector() : key(0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PSSamplerSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 tau:1;
|
|
|
|
uint32 tav:1;
|
2016-10-01 15:33:36 +00:00
|
|
|
uint32 biln:1;
|
|
|
|
uint32 triln:3;
|
2015-10-17 12:39:26 +00:00
|
|
|
uint32 aniso:1;
|
2015-05-07 16:32:58 +00:00
|
|
|
|
2016-10-01 15:33:36 +00:00
|
|
|
uint32 _free:25;
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
2015-07-25 08:14:53 +00:00
|
|
|
operator uint32() {return key;}
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
PSSamplerSelector() : key(0) {}
|
2013-06-26 20:09:07 +00:00
|
|
|
PSSamplerSelector(uint32 k) : key(k) {}
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OMDepthStencilSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 ztst:2;
|
|
|
|
uint32 zwe:1;
|
|
|
|
uint32 date:1;
|
2016-05-15 15:22:58 +00:00
|
|
|
uint32 date_one:1;
|
2015-05-07 16:32:58 +00:00
|
|
|
|
2016-05-15 15:22:58 +00:00
|
|
|
uint32 _free:27;
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
2015-05-07 16:32:58 +00:00
|
|
|
// FIXME is the & useful ?
|
2015-07-25 08:14:53 +00:00
|
|
|
operator uint32() {return key;}
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
OMDepthStencilSelector() : key(0) {}
|
2013-06-26 20:09:07 +00:00
|
|
|
OMDepthStencilSelector(uint32 k) : key(k) {}
|
2011-12-19 21:03:23 +00:00
|
|
|
};
|
|
|
|
|
2015-05-05 08:26:01 +00:00
|
|
|
struct OMColorMaskSelector
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 wr:1;
|
|
|
|
uint32 wg:1;
|
|
|
|
uint32 wb:1;
|
|
|
|
uint32 wa:1;
|
2015-05-07 16:32:58 +00:00
|
|
|
|
|
|
|
uint32 _free:28;
|
2015-05-05 08:26:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32 wrgba:4;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32 key;
|
|
|
|
};
|
|
|
|
|
2015-05-07 16:32:58 +00:00
|
|
|
// FIXME is the & useful ?
|
2015-05-05 08:26:01 +00:00
|
|
|
operator uint32() {return key & 0xf;}
|
|
|
|
|
|
|
|
OMColorMaskSelector() : key(0xF) {}
|
2015-05-15 10:52:03 +00:00
|
|
|
OMColorMaskSelector(uint32 c) { wrgba = c; }
|
2015-05-05 08:26:01 +00:00
|
|
|
};
|
|
|
|
|
2016-05-29 08:03:26 +00:00
|
|
|
struct alignas(32) MiscConstantBuffer
|
|
|
|
{
|
|
|
|
GSVector4i ScalingFactor;
|
|
|
|
GSVector4i ChannelShuffle;
|
2016-10-09 12:28:49 +00:00
|
|
|
GSVector4i EMOD_AC;
|
2016-05-29 08:03:26 +00:00
|
|
|
|
|
|
|
MiscConstantBuffer() {memset(this, 0, sizeof(*this));}
|
|
|
|
};
|
|
|
|
|
2015-08-07 17:43:42 +00:00
|
|
|
struct OGLBlend {uint16 bogus, op, src, dst;};
|
|
|
|
static const OGLBlend m_blendMapOGL[3*3*3*3 + 1];
|
2015-07-31 18:28:54 +00:00
|
|
|
static const int m_NO_BLEND;
|
|
|
|
static const int m_MERGE_BLEND;
|
2011-12-19 21:03:23 +00:00
|
|
|
|
2016-06-10 20:01:48 +00:00
|
|
|
static int m_shader_inst;
|
|
|
|
static int m_shader_reg;
|
2015-05-16 11:58:36 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
private:
|
2011-11-21 22:36:03 +00:00
|
|
|
uint32 m_msaa; // Level of Msaa
|
2016-06-24 16:41:55 +00:00
|
|
|
int m_force_texture_clear;
|
2016-09-30 18:04:24 +00:00
|
|
|
int m_mipmap;
|
2016-10-14 13:30:17 +00:00
|
|
|
Filtering m_filter;
|
2011-11-21 22:36:03 +00:00
|
|
|
|
2015-05-07 21:20:01 +00:00
|
|
|
static bool m_debug_gl_call;
|
2015-05-17 12:43:56 +00:00
|
|
|
static FILE* m_debug_gl_file;
|
2015-05-07 21:20:01 +00:00
|
|
|
|
2017-01-11 17:43:45 +00:00
|
|
|
bool m_disable_hw_gl_draw;
|
|
|
|
|
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
|
|
|
|
2014-10-02 07:33:41 +00:00
|
|
|
GSVertexBufferStateOGL* m_va;// state of the vertex buffer/array
|
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
|
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
|
2016-10-09 12:17:54 +00:00
|
|
|
GLuint ps[ShaderConvert_Count]; // program object
|
2011-11-16 22:17:37 +00:00
|
|
|
GLuint ln; // sampler object
|
|
|
|
GLuint pt; // sampler object
|
|
|
|
GSDepthStencilOGL* dss;
|
2015-06-05 21:26:03 +00:00
|
|
|
GSDepthStencilOGL* dss_write;
|
2015-06-29 17:17:46 +00:00
|
|
|
GSUniformBufferOGL* cb;
|
2011-11-16 22:17:37 +00:00
|
|
|
} 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;
|
|
|
|
|
2014-11-09 14:27:24 +00:00
|
|
|
struct {
|
|
|
|
GLuint ps;
|
|
|
|
GSUniformBufferOGL* cb;
|
|
|
|
} m_shaderfx;
|
|
|
|
|
2012-01-31 17:08:05 +00:00
|
|
|
struct {
|
2011-11-16 22:17:37 +00:00
|
|
|
GSDepthStencilOGL* dss;
|
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;
|
|
|
|
} m_shadeboost;
|
|
|
|
|
2016-06-26 13:27:57 +00:00
|
|
|
struct {
|
|
|
|
uint16 last_query;
|
|
|
|
GLuint timer_query[1<<16];
|
|
|
|
|
|
|
|
GLuint timer() { return timer_query[last_query]; }
|
|
|
|
} m_profiler;
|
|
|
|
|
2016-06-01 07:14:06 +00:00
|
|
|
GLuint m_vs[1];
|
2016-08-21 16:34:03 +00:00
|
|
|
GLuint m_gs[1<<3];
|
2016-10-01 15:33:36 +00:00
|
|
|
GLuint m_ps_ss[1<<7];
|
2016-05-15 15:22:58 +00:00
|
|
|
GSDepthStencilOGL* m_om_dss[1<<5];
|
2015-05-19 22:51:37 +00:00
|
|
|
hash_map<uint64, GLuint > m_ps;
|
2013-08-28 08:44:16 +00:00
|
|
|
GLuint m_apitrace;
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
GLuint m_palette_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;
|
2016-05-29 08:03:26 +00:00
|
|
|
MiscConstantBuffer m_misc_cb_cache;
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2016-09-18 20:40:51 +00:00
|
|
|
GSTextureOGL* m_font;
|
|
|
|
|
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
|
|
|
|
2016-10-09 11:20:31 +00:00
|
|
|
void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) final;
|
2016-04-04 20:48:10 +00:00
|
|
|
void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0) final;
|
|
|
|
void DoFXAA(GSTexture* sTex, GSTexture* dTex) final;
|
|
|
|
void DoShadeBoost(GSTexture* sTex, GSTexture* dTex) final;
|
|
|
|
void DoExternalFX(GSTexture* sTex, GSTexture* dTex) final;
|
2016-09-18 20:40:51 +00:00
|
|
|
void RenderOsd(GSTexture* dt);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2015-05-12 16:18:04 +00:00
|
|
|
void OMAttachRt(GSTextureOGL* rt = NULL);
|
|
|
|
void OMAttachDs(GSTextureOGL* ds = NULL);
|
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();
|
|
|
|
|
2016-06-26 13:27:57 +00:00
|
|
|
void GenerateProfilerData();
|
|
|
|
|
2013-10-24 20:54:27 +00:00
|
|
|
static void CheckDebugLog();
|
2015-09-26 21:10:50 +00:00
|
|
|
// Used by OpenGL, so the same calling convention is required.
|
|
|
|
static void APIENTRY DebugOutputToFile(GLenum gl_source, GLenum gl_type, GLuint id, GLenum gl_severity, GLsizei gl_length, const GLchar *gl_message, const void* userParam);
|
2011-12-19 21:03:23 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2016-04-04 20:48:10 +00:00
|
|
|
void DrawPrimitive() final;
|
2015-08-01 11:33:30 +00:00
|
|
|
void DrawPrimitive(int offset, int count);
|
2016-04-04 20:48:10 +00:00
|
|
|
void DrawIndexedPrimitive() final;
|
|
|
|
void DrawIndexedPrimitive(int offset, int count) final;
|
|
|
|
inline void BeforeDraw();
|
|
|
|
inline void AfterDraw();
|
2011-12-08 16:39:14 +00:00
|
|
|
|
2016-04-04 20:48:10 +00:00
|
|
|
void ClearRenderTarget(GSTexture* t, const GSVector4& c) final;
|
|
|
|
void ClearRenderTarget(GSTexture* t, uint32 c) final;
|
2015-05-02 14:53:34 +00:00
|
|
|
void ClearRenderTarget_i(GSTexture* t, int32 c);
|
2016-07-27 21:22:46 +00:00
|
|
|
void ClearDepth(GSTexture* t) final;
|
2016-04-04 20:48:10 +00:00
|
|
|
void ClearStencil(GSTexture* t, uint8 c) final;
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2016-04-04 20:48:10 +00:00
|
|
|
GSTexture* CreateRenderTarget(int w, int h, bool msaa, int format = 0) final;
|
|
|
|
GSTexture* CreateDepthStencil(int w, int h, bool msaa, int format = 0) final;
|
|
|
|
GSTexture* CreateTexture(int w, int h, int format = 0) final;
|
|
|
|
GSTexture* CreateOffscreen(int w, int h, int format = 0) final;
|
2016-05-15 13:54:29 +00:00
|
|
|
void InitPrimDateTexture(GSTexture* rt, const GSVector4i& area);
|
2013-07-28 14:40:43 +00:00
|
|
|
void RecycleDateTexture();
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2016-04-04 20:48:10 +00:00
|
|
|
GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) final;
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2016-04-04 20:48:10 +00:00
|
|
|
void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r) final;
|
2015-07-24 20:06:35 +00:00
|
|
|
void CopyRectConv(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r, bool at_origin);
|
2016-04-04 20:48:10 +00:00
|
|
|
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true) final;
|
2015-05-15 18:49:25 +00:00
|
|
|
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, GLuint ps, bool linear = true);
|
2015-07-31 18:28:54 +00:00
|
|
|
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, GLuint ps, int bs, bool linear = true);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2014-10-01 19:46:20 +00:00
|
|
|
void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2016-04-04 21:31:29 +00:00
|
|
|
void BeginScene() final {}
|
2016-04-04 20:48:10 +00:00
|
|
|
void EndScene() final;
|
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-01-15 17:25:49 +00:00
|
|
|
void IASetIndexBuffer(const void* index, size_t count);
|
2011-12-15 18:27:58 +00:00
|
|
|
|
2016-04-04 20:48:10 +00:00
|
|
|
void PSSetShaderResource(int i, GSTexture* sr) final;
|
|
|
|
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) final;
|
2013-08-02 16:38:12 +00:00
|
|
|
void PSSetSamplerState(GLuint ss);
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2015-08-01 09:35:21 +00:00
|
|
|
void OMSetDepthStencilState(GSDepthStencilOGL* dss);
|
2016-06-11 11:01:42 +00:00
|
|
|
void OMSetBlendState(uint8 blend_index = 0, uint8 blend_factor = 0, bool is_blend_constant = false, bool accumulation_blend = false);
|
2016-04-04 20:48:10 +00:00
|
|
|
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL) final;
|
2015-05-05 08:26:01 +00:00
|
|
|
void OMSetColorMaskState(OMColorMaskSelector sel = OMColorMaskSelector());
|
|
|
|
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2011-12-19 21:03:23 +00:00
|
|
|
void CreateTextureFX();
|
2016-04-07 19:57:54 +00:00
|
|
|
GLuint CompileVS(VSSelector sel);
|
2015-07-10 21:59:14 +00:00
|
|
|
GLuint CompileGS(GSSelector sel);
|
2013-06-26 20:09:07 +00:00
|
|
|
GLuint CompilePS(PSSelector sel);
|
|
|
|
GLuint CreateSampler(PSSamplerSelector sel);
|
|
|
|
GSDepthStencilOGL* CreateDepthStencil(OMDepthStencilSelector dssel);
|
|
|
|
|
2016-06-10 20:01:48 +00:00
|
|
|
void SelfShaderTestPrint(const string& test, int& nb_shader);
|
|
|
|
void SelfShaderTestRun(const string& dir, const string& file, const PSSelector& sel, int& nb_shader);
|
2015-07-15 06:59:16 +00:00
|
|
|
void SelfShaderTest();
|
|
|
|
|
2012-01-15 17:25:49 +00:00
|
|
|
void SetupIA(const void* vertex, int vertex_count, const uint32* index, int index_count, int prim);
|
2016-04-10 12:14:30 +00:00
|
|
|
void SetupPipeline(const VSSelector& vsel, const GSSelector& gsel, const PSSelector& psel);
|
2015-05-06 06:44:27 +00:00
|
|
|
void SetupCB(const VSConstantBuffer* vs_cb, const PSConstantBuffer* ps_cb);
|
2016-05-29 08:03:26 +00:00
|
|
|
void SetupCBMisc(const GSVector4i& channel);
|
2013-08-17 08:57:52 +00:00
|
|
|
void SetupSampler(PSSamplerSelector ssel);
|
2015-07-31 18:28:54 +00:00
|
|
|
void SetupOM(OMDepthStencilSelector dssel);
|
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
|
|
|
};
|