2014-09-07 15:27:49 +00:00
|
|
|
/* * Copyright (C) 2011-2014 Gregory hainaut
|
2013-01-14 09:15:39 +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
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "GLLoader.h"
|
2013-05-27 16:53:38 +00:00
|
|
|
#include "GSdx.h"
|
2016-10-22 12:44:40 +00:00
|
|
|
#include "GS.h"
|
2013-01-14 09:15:39 +00:00
|
|
|
|
2015-10-18 09:16:54 +00:00
|
|
|
PFNGLBLENDCOLORPROC gl_BlendColor = NULL;
|
|
|
|
|
2015-10-17 15:05:15 +00:00
|
|
|
PFNGLATTACHSHADERPROC glAttachShader = NULL;
|
|
|
|
PFNGLBINDBUFFERPROC glBindBuffer = NULL;
|
|
|
|
PFNGLBINDBUFFERBASEPROC glBindBufferBase = NULL;
|
|
|
|
PFNGLBINDBUFFERRANGEPROC glBindBufferRange = NULL;
|
|
|
|
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = NULL;
|
|
|
|
PFNGLBINDSAMPLERPROC glBindSampler = NULL;
|
|
|
|
PFNGLBINDVERTEXARRAYPROC glBindVertexArray = NULL;
|
|
|
|
PFNGLBLENDEQUATIONSEPARATEIARBPROC glBlendEquationSeparateiARB = NULL;
|
|
|
|
PFNGLBLENDFUNCSEPARATEIARBPROC glBlendFuncSeparateiARB = NULL;
|
|
|
|
PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = NULL;
|
|
|
|
PFNGLBUFFERDATAPROC glBufferData = NULL;
|
|
|
|
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = NULL;
|
|
|
|
PFNGLCLEARBUFFERFVPROC glClearBufferfv = NULL;
|
|
|
|
PFNGLCLEARBUFFERIVPROC glClearBufferiv = NULL;
|
|
|
|
PFNGLCLEARBUFFERUIVPROC glClearBufferuiv = NULL;
|
|
|
|
PFNGLCOLORMASKIPROC glColorMaski = NULL;
|
|
|
|
PFNGLCREATESHADERPROGRAMVPROC glCreateShaderProgramv = NULL;
|
|
|
|
PFNGLDELETEBUFFERSPROC glDeleteBuffers = NULL;
|
|
|
|
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = NULL;
|
|
|
|
PFNGLDELETEPROGRAMPROC glDeleteProgram = NULL;
|
|
|
|
PFNGLDELETESAMPLERSPROC glDeleteSamplers = NULL;
|
|
|
|
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = NULL;
|
|
|
|
PFNGLDETACHSHADERPROC glDetachShader = NULL;
|
|
|
|
PFNGLDRAWBUFFERSPROC glDrawBuffers = NULL;
|
|
|
|
PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex = NULL;
|
|
|
|
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = NULL;
|
|
|
|
PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = NULL;
|
|
|
|
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = NULL;
|
|
|
|
PFNGLGENBUFFERSPROC glGenBuffers = NULL;
|
|
|
|
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = NULL;
|
|
|
|
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = NULL;
|
|
|
|
PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = NULL;
|
|
|
|
PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB = NULL;
|
|
|
|
PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback = NULL;
|
|
|
|
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = NULL;
|
|
|
|
PFNGLGETPROGRAMIVPROC glGetProgramiv = NULL;
|
|
|
|
PFNGLGETSHADERIVPROC glGetShaderiv = NULL;
|
|
|
|
PFNGLGETSTRINGIPROC glGetStringi = NULL;
|
|
|
|
PFNGLISFRAMEBUFFERPROC glIsFramebuffer = NULL;
|
|
|
|
PFNGLMAPBUFFERPROC glMapBuffer = NULL;
|
|
|
|
PFNGLMAPBUFFERRANGEPROC glMapBufferRange = NULL;
|
|
|
|
PFNGLPROGRAMPARAMETERIPROC glProgramParameteri = NULL;
|
|
|
|
PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf = NULL;
|
|
|
|
PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri = NULL;
|
|
|
|
PFNGLSHADERSOURCEPROC glShaderSource = NULL;
|
|
|
|
PFNGLUNIFORM1IPROC glUniform1i = NULL;
|
|
|
|
PFNGLUNMAPBUFFERPROC glUnmapBuffer = NULL;
|
|
|
|
PFNGLUSEPROGRAMSTAGESPROC glUseProgramStages = NULL;
|
|
|
|
PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL;
|
|
|
|
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = NULL;
|
|
|
|
PFNGLBUFFERSUBDATAPROC glBufferSubData = NULL;
|
|
|
|
PFNGLFENCESYNCPROC glFenceSync = NULL;
|
|
|
|
PFNGLDELETESYNCPROC glDeleteSync = NULL;
|
|
|
|
PFNGLCLIENTWAITSYNCPROC glClientWaitSync = NULL;
|
|
|
|
PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange = NULL;
|
|
|
|
PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate = NULL;
|
|
|
|
PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = NULL;
|
2016-06-01 07:23:48 +00:00
|
|
|
// Shader compilation (Broken driver)
|
|
|
|
PFNGLCOMPILESHADERPROC glCompileShader = NULL;
|
|
|
|
PFNGLCREATEPROGRAMPROC glCreateProgram = NULL;
|
|
|
|
PFNGLCREATESHADERPROC glCreateShader = NULL;
|
|
|
|
PFNGLDELETESHADERPROC glDeleteShader = NULL;
|
|
|
|
PFNGLLINKPROGRAMPROC glLinkProgram = NULL;
|
|
|
|
PFNGLUSEPROGRAMPROC glUseProgram = NULL;
|
|
|
|
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = NULL;
|
|
|
|
PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i = NULL;
|
2016-03-04 20:42:17 +00:00
|
|
|
// Query object
|
|
|
|
PFNGLBEGINQUERYPROC glBeginQuery = NULL;
|
|
|
|
PFNGLENDQUERYPROC glEndQuery = NULL;
|
|
|
|
PFNGLGETQUERYIVPROC glGetQueryiv = NULL;
|
|
|
|
PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv = NULL;
|
|
|
|
PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv = NULL;
|
|
|
|
PFNGLQUERYCOUNTERPROC glQueryCounter = NULL;
|
|
|
|
PFNGLGETQUERYOBJECTI64VPROC glGetQueryObjecti64v = NULL;
|
|
|
|
PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v = NULL;
|
|
|
|
PFNGLGETINTEGER64VPROC glGetInteger64v = NULL;
|
2016-06-26 13:27:57 +00:00
|
|
|
PFNGLCREATEQUERIESPROC glCreateQueries = NULL;
|
|
|
|
PFNGLDELETEQUERIESPROC glDeleteQueries = NULL;
|
2013-08-10 19:43:59 +00:00
|
|
|
// GL4.0
|
|
|
|
// GL4.1
|
2015-10-17 15:05:15 +00:00
|
|
|
PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline = NULL;
|
|
|
|
PFNGLDELETEPROGRAMPIPELINESPROC glDeleteProgramPipelines = NULL;
|
|
|
|
PFNGLGETPROGRAMPIPELINEIVPROC glGetProgramPipelineiv = NULL;
|
|
|
|
PFNGLVALIDATEPROGRAMPIPELINEPROC glValidateProgramPipeline = NULL;
|
|
|
|
PFNGLGETPROGRAMPIPELINEINFOLOGPROC glGetProgramPipelineInfoLog = NULL;
|
|
|
|
PFNGLGETPROGRAMBINARYPROC glGetProgramBinary = NULL;
|
2016-03-10 21:14:41 +00:00
|
|
|
PFNGLVIEWPORTINDEXEDFPROC glViewportIndexedf = NULL;
|
|
|
|
PFNGLVIEWPORTINDEXEDFVPROC glViewportIndexedfv = NULL;
|
|
|
|
PFNGLSCISSORINDEXEDPROC glScissorIndexed = NULL;
|
|
|
|
PFNGLSCISSORINDEXEDVPROC glScissorIndexedv = NULL;
|
2013-08-03 08:29:01 +00:00
|
|
|
// GL4.3
|
2015-10-17 15:05:15 +00:00
|
|
|
PFNGLCOPYIMAGESUBDATAPROC glCopyImageSubData = NULL;
|
|
|
|
PFNGLINVALIDATETEXIMAGEPROC glInvalidateTexImage = NULL;
|
|
|
|
PFNGLPUSHDEBUGGROUPPROC glPushDebugGroup = NULL;
|
|
|
|
PFNGLPOPDEBUGGROUPPROC glPopDebugGroup = NULL;
|
|
|
|
PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert = NULL;
|
2015-10-24 12:05:00 +00:00
|
|
|
PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl = NULL;
|
2016-06-07 17:49:48 +00:00
|
|
|
PFNGLOBJECTLABELPROC glObjectLabel = NULL;
|
|
|
|
PFNGLOBJECTPTRLABELPROC glObjectPtrLabel = NULL;
|
2013-07-28 14:40:43 +00:00
|
|
|
// GL4.2
|
2015-10-17 15:05:15 +00:00
|
|
|
PFNGLBINDIMAGETEXTUREPROC glBindImageTexture = NULL;
|
|
|
|
PFNGLMEMORYBARRIERPROC glMemoryBarrier = NULL;
|
2013-08-02 16:38:12 +00:00
|
|
|
// GL4.4
|
2015-10-17 15:05:15 +00:00
|
|
|
PFNGLCLEARTEXIMAGEPROC glClearTexImage = NULL;
|
2016-05-15 11:11:21 +00:00
|
|
|
PFNGLCLEARTEXSUBIMAGEPROC glClearTexSubImage = NULL;
|
2015-10-17 15:05:15 +00:00
|
|
|
PFNGLBUFFERSTORAGEPROC glBufferStorage = NULL;
|
2014-09-07 15:27:49 +00:00
|
|
|
|
|
|
|
// GL4.5
|
2015-10-17 15:05:15 +00:00
|
|
|
PFNGLCREATETEXTURESPROC glCreateTextures = NULL;
|
|
|
|
PFNGLTEXTURESTORAGE2DPROC glTextureStorage2D = NULL;
|
|
|
|
PFNGLTEXTURESUBIMAGE2DPROC glTextureSubImage2D = NULL;
|
|
|
|
PFNGLCOPYTEXTURESUBIMAGE2DPROC glCopyTextureSubImage2D = NULL;
|
|
|
|
PFNGLBINDTEXTUREUNITPROC glBindTextureUnit = NULL;
|
|
|
|
PFNGLGETTEXTUREIMAGEPROC glGetTextureImage = NULL;
|
|
|
|
PFNGLTEXTUREPARAMETERIPROC glTextureParameteri = NULL;
|
2016-10-02 08:41:18 +00:00
|
|
|
PFNGLGENERATETEXTUREMIPMAPPROC glGenerateTextureMipmap = NULL;
|
2015-10-17 15:05:15 +00:00
|
|
|
|
|
|
|
PFNGLCREATEFRAMEBUFFERSPROC glCreateFramebuffers = NULL;
|
|
|
|
PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glClearNamedFramebufferfv = NULL;
|
|
|
|
PFNGLCLEARNAMEDFRAMEBUFFERIVPROC glClearNamedFramebufferiv = NULL;
|
|
|
|
PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC glClearNamedFramebufferuiv = NULL;
|
|
|
|
PFNGLNAMEDFRAMEBUFFERTEXTUREPROC glNamedFramebufferTexture = NULL;
|
|
|
|
PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC glNamedFramebufferDrawBuffers = NULL;
|
|
|
|
PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC glNamedFramebufferReadBuffer = NULL;
|
2016-04-07 21:29:03 +00:00
|
|
|
PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC glNamedFramebufferParameteri = NULL;
|
2015-10-17 15:05:15 +00:00
|
|
|
PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glCheckNamedFramebufferStatus = NULL;
|
|
|
|
|
|
|
|
PFNGLCREATEBUFFERSPROC glCreateBuffers = NULL;
|
|
|
|
PFNGLNAMEDBUFFERSTORAGEPROC glNamedBufferStorage = NULL;
|
|
|
|
PFNGLNAMEDBUFFERDATAPROC glNamedBufferData = NULL;
|
|
|
|
PFNGLNAMEDBUFFERSUBDATAPROC glNamedBufferSubData = NULL;
|
|
|
|
PFNGLMAPNAMEDBUFFERPROC glMapNamedBuffer = NULL;
|
|
|
|
PFNGLMAPNAMEDBUFFERRANGEPROC glMapNamedBufferRange = NULL;
|
|
|
|
PFNGLUNMAPNAMEDBUFFERPROC glUnmapNamedBuffer = NULL;
|
|
|
|
PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC glFlushMappedNamedBufferRange = NULL;
|
|
|
|
|
|
|
|
PFNGLCREATESAMPLERSPROC glCreateSamplers = NULL;
|
|
|
|
PFNGLCREATEPROGRAMPIPELINESPROC glCreateProgramPipelines = NULL;
|
|
|
|
|
|
|
|
PFNGLCLIPCONTROLPROC glClipControl = NULL;
|
|
|
|
PFNGLTEXTUREBARRIERPROC glTextureBarrier = NULL;
|
2016-05-16 16:45:47 +00:00
|
|
|
PFNGLGETTEXTURESUBIMAGEPROC glGetTextureSubImage = NULL;
|
2014-01-31 21:30:54 +00:00
|
|
|
|
2017-02-17 16:44:26 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL;
|
|
|
|
PFNGLTEXSTORAGE2DPROC glTexStorage2D = NULL;
|
|
|
|
PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines = NULL;
|
|
|
|
PFNGLGENSAMPLERSPROC glGenSamplers = NULL;
|
|
|
|
PFNGLGENERATEMIPMAPPROC glGenerateMipmap = NULL;
|
|
|
|
#endif
|
|
|
|
|
2016-05-14 15:15:30 +00:00
|
|
|
namespace ReplaceGL {
|
|
|
|
void APIENTRY ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height)
|
|
|
|
{
|
|
|
|
glScissor(left, bottom, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIENTRY ViewportIndexedf(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h)
|
|
|
|
{
|
2016-06-29 17:42:05 +00:00
|
|
|
glViewport(GLint(x), GLint(y), GLsizei(w), GLsizei(h));
|
2016-05-14 15:15:30 +00:00
|
|
|
}
|
2017-02-03 16:33:07 +00:00
|
|
|
|
|
|
|
void APIENTRY TextureBarrier()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-05-14 15:15:30 +00:00
|
|
|
}
|
|
|
|
|
2017-02-17 16:44:26 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
namespace Emulate_DSA {
|
|
|
|
// Texture entry point
|
|
|
|
void APIENTRY BindTextureUnit(GLuint unit, GLuint texture) {
|
|
|
|
gl_ActiveTexture(GL_TEXTURE0 + unit);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texture);
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIENTRY CreateTexture(GLenum target, GLsizei n, GLuint *textures) {
|
|
|
|
glGenTextures(1, textures);
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIENTRY TextureStorage(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) {
|
|
|
|
BindTextureUnit(7, texture);
|
|
|
|
glTexStorage2D(GL_TEXTURE_2D, levels, internalformat, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIENTRY TextureSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) {
|
|
|
|
BindTextureUnit(7, texture);
|
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, width, height, format, type, pixels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIENTRY CopyTextureSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
|
|
|
|
BindTextureUnit(7, texture);
|
|
|
|
glCopyTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIENTRY GetTexureImage(GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels) {
|
|
|
|
BindTextureUnit(7, texture);
|
|
|
|
glGetTexImage(GL_TEXTURE_2D, level, format, type, pixels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIENTRY TextureParameteri (GLuint texture, GLenum pname, GLint param) {
|
|
|
|
BindTextureUnit(7, texture);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, pname, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIENTRY GenerateTextureMipmap(GLuint texture) {
|
|
|
|
BindTextureUnit(7, texture);
|
|
|
|
glGenerateMipmap(GL_TEXTURE_2D);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Misc entry point
|
|
|
|
// (only purpose is to have a consistent API otherwise it is useless)
|
|
|
|
void APIENTRY CreateProgramPipelines(GLsizei n, GLuint *pipelines) {
|
|
|
|
glGenProgramPipelines(n, pipelines);
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIENTRY CreateSamplers(GLsizei n, GLuint *samplers) {
|
|
|
|
glGenSamplers(n, samplers);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Replace function pointer to emulate DSA behavior
|
|
|
|
void Init() {
|
|
|
|
fprintf(stderr, "DSA is not supported. Expect slower performance\n");
|
|
|
|
glBindTextureUnit = BindTextureUnit;
|
|
|
|
glCreateTextures = CreateTexture;
|
|
|
|
glTextureStorage2D = TextureStorage;
|
|
|
|
glTextureSubImage2D = TextureSubImage;
|
|
|
|
glCopyTextureSubImage2D = CopyTextureSubImage;
|
|
|
|
glGetTextureImage = GetTexureImage;
|
|
|
|
glTextureParameteri = TextureParameteri;
|
|
|
|
|
|
|
|
glCreateProgramPipelines = CreateProgramPipelines;
|
|
|
|
glCreateSamplers = CreateSamplers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-01-14 09:15:39 +00:00
|
|
|
namespace GLLoader {
|
|
|
|
|
2016-05-28 16:49:49 +00:00
|
|
|
bool legacy_fglrx_buggy_driver = false;
|
2014-03-29 09:47:53 +00:00
|
|
|
bool fglrx_buggy_driver = false;
|
2016-10-23 10:42:54 +00:00
|
|
|
bool mesa_buggy_driver = false;
|
2014-03-29 09:47:53 +00:00
|
|
|
bool nvidia_buggy_driver = false;
|
|
|
|
bool intel_buggy_driver = false;
|
|
|
|
bool in_replayer = false;
|
2016-06-01 18:58:10 +00:00
|
|
|
bool buggy_sso_dual_src = false;
|
2013-07-11 17:08:42 +00:00
|
|
|
|
2015-08-07 12:46:57 +00:00
|
|
|
|
2014-09-30 20:04:42 +00:00
|
|
|
bool found_geometry_shader = true; // we require GL3.3 so geometry must be supported by default
|
2015-05-02 08:53:19 +00:00
|
|
|
bool found_GL_EXT_texture_filter_anisotropic = false;
|
2017-02-03 17:30:27 +00:00
|
|
|
bool found_GL_ARB_clear_texture = false;
|
2016-05-16 16:45:47 +00:00
|
|
|
bool found_GL_ARB_get_texture_sub_image = false; // Not yet used
|
2016-03-10 20:56:36 +00:00
|
|
|
// DX11 GPU
|
|
|
|
bool found_GL_ARB_gpu_shader5 = false; // Require IvyBridge
|
|
|
|
bool found_GL_ARB_shader_image_load_store = false; // Intel IB. Nvidia/AMD miss Mesa implementation.
|
2016-03-10 21:14:41 +00:00
|
|
|
bool found_GL_ARB_viewport_array = false; // Intel IB. AMD/NVIDIA DX10
|
2016-07-07 20:02:10 +00:00
|
|
|
// Bonus to monitor the VRAM
|
|
|
|
bool found_GL_NVX_gpu_memory_info = false;
|
2014-09-07 15:27:49 +00:00
|
|
|
|
2013-08-03 08:29:01 +00:00
|
|
|
// Mandatory
|
2016-04-07 20:29:35 +00:00
|
|
|
bool found_GL_ARB_buffer_storage = false;
|
|
|
|
bool found_GL_ARB_clip_control = false;
|
2016-04-19 16:58:25 +00:00
|
|
|
bool found_GL_ARB_copy_image = false;
|
2016-04-07 20:29:35 +00:00
|
|
|
bool found_GL_ARB_direct_state_access = false;
|
|
|
|
bool found_GL_ARB_separate_shader_objects = false;
|
2014-10-01 07:50:59 +00:00
|
|
|
bool found_GL_ARB_shading_language_420pack = false;
|
2016-04-07 20:29:35 +00:00
|
|
|
bool found_GL_ARB_texture_barrier = false;
|
|
|
|
bool found_GL_ARB_texture_storage = false;
|
2016-04-19 21:03:42 +00:00
|
|
|
bool found_GL_KHR_debug = false;
|
2013-08-03 08:29:01 +00:00
|
|
|
|
|
|
|
static bool status_and_override(bool& found, const std::string& name, bool mandatory = false)
|
|
|
|
{
|
2015-05-01 12:18:05 +00:00
|
|
|
if (mandatory) {
|
|
|
|
if (!found) {
|
2014-10-01 07:50:59 +00:00
|
|
|
fprintf(stderr, "ERROR: %s is NOT SUPPORTED\n", name.c_str());
|
|
|
|
}
|
2015-05-01 12:18:05 +00:00
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
2015-12-20 13:01:01 +00:00
|
|
|
fprintf(stdout, "INFO: %s is NOT SUPPORTED\n", name.c_str());
|
2014-02-01 11:11:14 +00:00
|
|
|
} else {
|
2015-12-20 13:01:01 +00:00
|
|
|
fprintf(stdout, "INFO: %s is available\n", name.c_str());
|
2013-08-03 08:29:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string opt("override_");
|
|
|
|
opt += name;
|
|
|
|
|
2016-05-24 19:52:06 +00:00
|
|
|
if (theApp.GetConfigI(opt.c_str()) != -1) {
|
|
|
|
found = theApp.GetConfigB(opt.c_str());
|
2013-08-03 08:29:01 +00:00
|
|
|
fprintf(stderr, "Override %s detection (%s)\n", name.c_str(), found ? "Enabled" : "Disabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-05-19 12:42:55 +00:00
|
|
|
|
2015-07-13 10:35:55 +00:00
|
|
|
bool check_gl_version(int major, int minor) {
|
2013-05-19 12:42:55 +00:00
|
|
|
|
|
|
|
const GLubyte* s = glGetString(GL_VERSION);
|
2013-07-28 14:40:43 +00:00
|
|
|
if (s == NULL) {
|
|
|
|
fprintf(stderr, "Error: GLLoader failed to get GL version\n");
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-13 10:35:55 +00:00
|
|
|
GLuint v = 1;
|
|
|
|
while (s[v] != '\0' && s[v-1] != ' ') v++;
|
2013-05-19 12:42:55 +00:00
|
|
|
|
2013-06-11 11:14:26 +00:00
|
|
|
const char* vendor = (const char*)glGetString(GL_VENDOR);
|
2015-12-20 13:01:01 +00:00
|
|
|
fprintf(stdout, "OpenGL information. GPU: %s. Vendor: %s. Driver: %s\n", glGetString(GL_RENDERER), vendor, &s[v]);
|
2013-06-11 11:14:26 +00:00
|
|
|
|
2015-08-07 12:46:57 +00:00
|
|
|
// Name changed but driver is still bad!
|
2017-03-28 21:02:19 +00:00
|
|
|
if (strstr(vendor, "Advanced Micro Devices") || strstr(vendor, "ATI Technologies Inc.") || strstr(vendor, "ATI"))
|
2013-05-19 12:42:55 +00:00
|
|
|
fglrx_buggy_driver = true;
|
2016-08-09 12:35:47 +00:00
|
|
|
if (fglrx_buggy_driver && (
|
2017-03-28 21:02:19 +00:00
|
|
|
strstr((const char*)&s[v], " 15.") || // Blacklist all 2015 AMD drivers.
|
|
|
|
strstr((const char*)&s[v], " 16.") || // Blacklist all 2016 AMD drivers.
|
|
|
|
strstr((const char*)&s[v], " 17.") // Blacklist all 2017 AMD drivers for now.
|
2017-02-17 16:14:41 +00:00
|
|
|
))
|
2016-05-28 16:43:55 +00:00
|
|
|
legacy_fglrx_buggy_driver = true;
|
2016-10-23 10:42:54 +00:00
|
|
|
|
2013-07-11 17:08:42 +00:00
|
|
|
if (strstr(vendor, "NVIDIA Corporation"))
|
|
|
|
nvidia_buggy_driver = true;
|
2013-01-14 09:15:39 +00:00
|
|
|
|
2016-06-01 18:58:10 +00:00
|
|
|
#ifdef _WIN32
|
2016-10-23 10:42:54 +00:00
|
|
|
if (strstr(vendor, "Intel"))
|
|
|
|
intel_buggy_driver = true;
|
2016-06-01 18:58:10 +00:00
|
|
|
#else
|
2016-10-23 10:42:54 +00:00
|
|
|
// On linux assumes the free driver if it isn't nvidia or amd pro driver
|
|
|
|
mesa_buggy_driver = !nvidia_buggy_driver && !fglrx_buggy_driver;
|
2016-06-01 18:58:10 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-28 21:02:19 +00:00
|
|
|
buggy_sso_dual_src = intel_buggy_driver || fglrx_buggy_driver || legacy_fglrx_buggy_driver;
|
2016-10-23 10:42:54 +00:00
|
|
|
|
2016-05-24 19:52:06 +00:00
|
|
|
if (theApp.GetConfigI("override_geometry_shader") != -1) {
|
|
|
|
found_geometry_shader = theApp.GetConfigB("override_geometry_shader");
|
2015-06-06 19:28:59 +00:00
|
|
|
fprintf(stderr, "Overriding geometry shaders detection\n");
|
2013-05-27 16:53:38 +00:00
|
|
|
}
|
2015-07-13 10:35:55 +00:00
|
|
|
|
|
|
|
GLint major_gl = 0;
|
|
|
|
GLint minor_gl = 0;
|
|
|
|
glGetIntegerv(GL_MAJOR_VERSION, &major_gl);
|
|
|
|
glGetIntegerv(GL_MINOR_VERSION, &minor_gl);
|
2013-01-14 09:15:39 +00:00
|
|
|
if ( (major_gl < major) || ( major_gl == major && minor_gl < minor ) ) {
|
2015-06-30 21:04:54 +00:00
|
|
|
fprintf(stderr, "OpenGL %d.%d is not supported. Only OpenGL %d.%d\n was found", major, minor, major_gl, minor_gl);
|
2013-01-14 09:15:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool check_gl_supported_extension() {
|
|
|
|
int max_ext = 0;
|
|
|
|
glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext);
|
|
|
|
|
2015-10-17 15:05:15 +00:00
|
|
|
if (glGetStringi && max_ext) {
|
2013-01-14 09:15:39 +00:00
|
|
|
for (GLint i = 0; i < max_ext; i++) {
|
2015-10-17 15:05:15 +00:00
|
|
|
string ext((const char*)glGetStringi(GL_EXTENSIONS, i));
|
2015-05-02 08:53:19 +00:00
|
|
|
// Bonus
|
|
|
|
if (ext.compare("GL_EXT_texture_filter_anisotropic") == 0) found_GL_EXT_texture_filter_anisotropic = true;
|
2016-07-07 20:02:10 +00:00
|
|
|
if (ext.compare("GL_NVX_gpu_memory_info") == 0) found_GL_NVX_gpu_memory_info = true;
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.0
|
|
|
|
if (ext.compare("GL_ARB_gpu_shader5") == 0) found_GL_ARB_gpu_shader5 = true;
|
|
|
|
// GL4.1
|
2016-03-10 21:14:41 +00:00
|
|
|
if (ext.compare("GL_ARB_viewport_array") == 0) found_GL_ARB_viewport_array = true;
|
2016-04-07 20:11:35 +00:00
|
|
|
if (ext.compare("GL_ARB_separate_shader_objects") == 0) found_GL_ARB_separate_shader_objects = true;
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.2
|
|
|
|
if (ext.compare("GL_ARB_shading_language_420pack") == 0) found_GL_ARB_shading_language_420pack = true;
|
|
|
|
if (ext.compare("GL_ARB_texture_storage") == 0) found_GL_ARB_texture_storage = true;
|
2015-05-08 08:40:43 +00:00
|
|
|
if (ext.compare("GL_ARB_shader_image_load_store") == 0) found_GL_ARB_shader_image_load_store = true;
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.3
|
|
|
|
if (ext.compare("GL_ARB_copy_image") == 0) found_GL_ARB_copy_image = true;
|
2016-04-19 21:03:42 +00:00
|
|
|
if (ext.compare("GL_KHR_debug") == 0) found_GL_KHR_debug = true;
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.4
|
|
|
|
if (ext.compare("GL_ARB_buffer_storage") == 0) found_GL_ARB_buffer_storage = true;
|
2015-05-15 18:58:14 +00:00
|
|
|
if (ext.compare("GL_ARB_clear_texture") == 0) found_GL_ARB_clear_texture = true;
|
2014-09-15 20:28:35 +00:00
|
|
|
// GL4.5
|
|
|
|
if (ext.compare("GL_ARB_direct_state_access") == 0) found_GL_ARB_direct_state_access = true;
|
|
|
|
if (ext.compare("GL_ARB_clip_control") == 0) found_GL_ARB_clip_control = true;
|
2015-04-25 07:59:25 +00:00
|
|
|
if (ext.compare("GL_ARB_texture_barrier") == 0) found_GL_ARB_texture_barrier = true;
|
2016-05-16 16:45:47 +00:00
|
|
|
if (ext.compare("GL_ARB_get_texture_sub_image") == 0) found_GL_ARB_get_texture_sub_image = true;
|
2014-09-30 19:56:36 +00:00
|
|
|
|
|
|
|
//fprintf(stderr, "DEBUG ext: %s\n", ext.c_str());
|
2013-01-14 09:15:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-03 08:29:01 +00:00
|
|
|
bool status = true;
|
2017-04-04 16:37:26 +00:00
|
|
|
bool required_for_hw = (theApp.GetCurrentRendererType() == GSRendererType::OGL_HW);
|
2013-01-14 09:15:39 +00:00
|
|
|
|
2015-05-02 08:53:19 +00:00
|
|
|
// Bonus
|
|
|
|
status &= status_and_override(found_GL_EXT_texture_filter_anisotropic, "GL_EXT_texture_filter_anisotropic");
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.0
|
2015-05-02 08:53:19 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_gpu_shader5, "GL_ARB_gpu_shader5");
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.1
|
2016-03-10 21:14:41 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_viewport_array, "GL_ARB_viewport_array");
|
2016-04-07 20:11:35 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_separate_shader_objects, "GL_ARB_separate_shader_objects", true);
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.2
|
2015-05-02 08:53:19 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_shader_image_load_store, "GL_ARB_shader_image_load_store");
|
|
|
|
status &= status_and_override(found_GL_ARB_shading_language_420pack, "GL_ARB_shading_language_420pack", true);
|
2013-08-03 08:29:01 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_texture_storage, "GL_ARB_texture_storage", true);
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.3
|
2017-04-05 17:35:00 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_copy_image, "GL_ARB_copy_image", required_for_hw);
|
2016-04-19 21:03:42 +00:00
|
|
|
status &= status_and_override(found_GL_KHR_debug, "GL_KHR_debug", true);
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.4
|
2016-04-07 20:17:22 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_buffer_storage,"GL_ARB_buffer_storage", true);
|
2015-05-15 18:58:14 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_clear_texture,"GL_ARB_clear_texture");
|
2014-09-27 17:12:30 +00:00
|
|
|
// GL4.5
|
2017-04-04 16:37:26 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_clip_control, "GL_ARB_clip_control", required_for_hw);
|
2017-02-17 16:44:26 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_direct_state_access, "GL_ARB_direct_state_access");
|
2017-02-03 16:33:07 +00:00
|
|
|
// Mandatory for the advance HW renderer effect. Unfortunately Mesa LLVMPIPE/SWR renderers doesn't support this extension.
|
|
|
|
// Rendering might be corrupted but it could be good enough for test/virtual machine.
|
|
|
|
status &= status_and_override(found_GL_ARB_texture_barrier, "GL_ARB_texture_barrier");
|
2016-05-16 16:45:47 +00:00
|
|
|
status &= status_and_override(found_GL_ARB_get_texture_sub_image, "GL_ARB_get_texture_sub_image");
|
2015-05-01 17:16:18 +00:00
|
|
|
|
2017-02-17 16:14:41 +00:00
|
|
|
if (fglrx_buggy_driver) {
|
2017-03-28 21:02:19 +00:00
|
|
|
fprintf(stderr, "The OpenGL hardware renderer is slow on AMD GPUs due to an inefficient driver.\n"
|
|
|
|
"Check out the link below for further information.\n"
|
|
|
|
"https://github.com/PCSX2/pcsx2/wiki/OpenGL-and-AMD-GPUs---All-you-need-to-know\n");
|
2015-12-20 13:01:01 +00:00
|
|
|
}
|
|
|
|
|
2016-05-14 15:15:30 +00:00
|
|
|
if (!found_GL_ARB_viewport_array) {
|
|
|
|
fprintf(stderr, "GL_ARB_viewport_array: not supported ! function pointer will be replaced\n");
|
|
|
|
glScissorIndexed = ReplaceGL::ScissorIndexed;
|
|
|
|
glViewportIndexedf = ReplaceGL::ViewportIndexedf;
|
|
|
|
}
|
|
|
|
|
2017-02-03 16:33:07 +00:00
|
|
|
if (!found_GL_ARB_texture_barrier) {
|
|
|
|
fprintf(stderr, "GL_ARB_texture_barrier: not supported ! Rendering will be corrupted\n");
|
|
|
|
glTextureBarrier = ReplaceGL::TextureBarrier;
|
|
|
|
}
|
|
|
|
|
2017-02-17 16:44:26 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
// Thanks you Intel to not provide support of basic feature on your iGPU
|
|
|
|
if (!found_GL_ARB_direct_state_access) {
|
|
|
|
Emulate_DSA::Init();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-20 13:01:01 +00:00
|
|
|
fprintf(stdout, "\n");
|
2013-05-26 13:05:03 +00:00
|
|
|
|
2013-08-03 08:29:01 +00:00
|
|
|
return status;
|
2013-01-14 09:15:39 +00:00
|
|
|
}
|
|
|
|
}
|