mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl-wnd:
* replace both DISABLE_GL41_SSO and DISABLE_GL42 macro with a dynamic check based on the extension support * glsl2h: use static instead of extern git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl-wnd@5636 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
9376b26537
commit
6779edfe28
|
@ -45,7 +45,7 @@ sub glsl2h {
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
extern const char* ${glsl}_glsl =
|
static const char* ${glsl}_glsl =
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
print $H $header;
|
print $H $header;
|
||||||
|
|
|
@ -22,78 +22,91 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "GLLoader.h"
|
#include "GLLoader.h"
|
||||||
|
|
||||||
PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL;
|
PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL;
|
||||||
PFNGLBLENDCOLORPROC gl_BlendColor = NULL;
|
PFNGLBLENDCOLORPROC gl_BlendColor = NULL;
|
||||||
PFNGLATTACHSHADERPROC gl_AttachShader = NULL;
|
PFNGLATTACHSHADERPROC gl_AttachShader = NULL;
|
||||||
PFNGLBINDBUFFERPROC gl_BindBuffer = NULL;
|
PFNGLBINDBUFFERPROC gl_BindBuffer = NULL;
|
||||||
PFNGLBINDBUFFERBASEPROC gl_BindBufferBase = NULL;
|
PFNGLBINDBUFFERBASEPROC gl_BindBufferBase = NULL;
|
||||||
PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed = NULL;
|
PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed = NULL;
|
||||||
PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer = NULL;
|
PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer = NULL;
|
||||||
PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline = NULL;
|
PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline = NULL;
|
||||||
PFNGLBINDSAMPLERPROC gl_BindSampler = NULL;
|
PFNGLBINDSAMPLERPROC gl_BindSampler = NULL;
|
||||||
PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray = NULL;
|
PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray = NULL;
|
||||||
PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate = NULL;
|
PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate = NULL;
|
||||||
PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate = NULL;
|
PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate = NULL;
|
||||||
PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer = NULL;
|
PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer = NULL;
|
||||||
PFNGLBUFFERDATAPROC gl_BufferData = NULL;
|
PFNGLBUFFERDATAPROC gl_BufferData = NULL;
|
||||||
PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus = NULL;
|
PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus = NULL;
|
||||||
PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv = NULL;
|
PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv = NULL;
|
||||||
PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv = NULL;
|
PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv = NULL;
|
||||||
PFNGLCOMPILESHADERPROC gl_CompileShader = NULL;
|
PFNGLCOMPILESHADERPROC gl_CompileShader = NULL;
|
||||||
PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV = NULL;
|
PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV = NULL;
|
||||||
PFNGLCREATEPROGRAMPROC gl_CreateProgram = NULL;
|
PFNGLCREATEPROGRAMPROC gl_CreateProgram = NULL;
|
||||||
PFNGLCREATESHADERPROC gl_CreateShader = NULL;
|
PFNGLCREATESHADERPROC gl_CreateShader = NULL;
|
||||||
PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv = NULL;
|
PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv = NULL;
|
||||||
PFNGLDELETEBUFFERSPROC gl_DeleteBuffers = NULL;
|
PFNGLDELETEBUFFERSPROC gl_DeleteBuffers = NULL;
|
||||||
PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers = NULL;
|
PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers = NULL;
|
||||||
PFNGLDELETEPROGRAMPROC gl_DeleteProgram = NULL;
|
PFNGLDELETEPROGRAMPROC gl_DeleteProgram = NULL;
|
||||||
PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines = NULL;
|
PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines = NULL;
|
||||||
PFNGLDELETESAMPLERSPROC gl_DeleteSamplers = NULL;
|
PFNGLDELETESAMPLERSPROC gl_DeleteSamplers = NULL;
|
||||||
PFNGLDELETESHADERPROC gl_DeleteShader = NULL;
|
PFNGLDELETESHADERPROC gl_DeleteShader = NULL;
|
||||||
PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays = NULL;
|
PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays = NULL;
|
||||||
PFNGLDETACHSHADERPROC gl_DetachShader = NULL;
|
PFNGLDETACHSHADERPROC gl_DetachShader = NULL;
|
||||||
PFNGLDRAWBUFFERSPROC gl_DrawBuffers = NULL;
|
PFNGLDRAWBUFFERSPROC gl_DrawBuffers = NULL;
|
||||||
PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex = NULL;
|
PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex = NULL;
|
||||||
PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray = NULL;
|
PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray = NULL;
|
||||||
PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer = NULL;
|
PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer = NULL;
|
||||||
PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D = NULL;
|
PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D = NULL;
|
||||||
PFNGLGENBUFFERSPROC gl_GenBuffers = NULL;
|
PFNGLGENBUFFERSPROC gl_GenBuffers = NULL;
|
||||||
PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers = NULL;
|
PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers = NULL;
|
||||||
PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines = NULL;
|
PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines = NULL;
|
||||||
PFNGLGENSAMPLERSPROC gl_GenSamplers = NULL;
|
PFNGLGENSAMPLERSPROC gl_GenSamplers = NULL;
|
||||||
PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays = NULL;
|
PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays = NULL;
|
||||||
PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv = NULL;
|
PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv = NULL;
|
||||||
PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB = NULL;
|
PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB = NULL;
|
||||||
PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex = NULL;
|
PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex = NULL;
|
||||||
PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation = NULL;
|
PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation = NULL;
|
||||||
PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog = NULL;
|
PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog = NULL;
|
||||||
PFNGLGETPROGRAMIVPROC gl_GetProgramiv = NULL;
|
PFNGLGETPROGRAMIVPROC gl_GetProgramiv = NULL;
|
||||||
PFNGLGETSHADERIVPROC gl_GetShaderiv = NULL;
|
PFNGLGETSHADERIVPROC gl_GetShaderiv = NULL;
|
||||||
PFNGLGETSTRINGIPROC gl_GetStringi = NULL;
|
PFNGLGETSTRINGIPROC gl_GetStringi = NULL;
|
||||||
PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer = NULL;
|
PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer = NULL;
|
||||||
PFNGLLINKPROGRAMPROC gl_LinkProgram = NULL;
|
PFNGLLINKPROGRAMPROC gl_LinkProgram = NULL;
|
||||||
PFNGLMAPBUFFERPROC gl_MapBuffer = NULL;
|
PFNGLMAPBUFFERPROC gl_MapBuffer = NULL;
|
||||||
PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange = NULL;
|
PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange = NULL;
|
||||||
PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri = NULL;
|
PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri = NULL;
|
||||||
PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf = NULL;
|
PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf = NULL;
|
||||||
PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri = NULL;
|
PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri = NULL;
|
||||||
PFNGLSHADERSOURCEPROC gl_ShaderSource = NULL;
|
PFNGLSHADERSOURCEPROC gl_ShaderSource = NULL;
|
||||||
PFNGLUNIFORM1IPROC gl_Uniform1i = NULL;
|
PFNGLUNIFORM1IPROC gl_Uniform1i = NULL;
|
||||||
PFNGLUNMAPBUFFERPROC gl_UnmapBuffer = NULL;
|
PFNGLUNMAPBUFFERPROC gl_UnmapBuffer = NULL;
|
||||||
PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages = NULL;
|
PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages = NULL;
|
||||||
PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL;
|
PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL;
|
||||||
PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = NULL;
|
PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = NULL;
|
||||||
PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
|
PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
|
||||||
|
// NO GL4.1
|
||||||
|
PFNGLUSEPROGRAMPROC gl_UseProgram = NULL;
|
||||||
|
PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog = NULL;
|
||||||
|
// NO GL4.2
|
||||||
|
PFNGLGETUNIFORMBLOCKINDEXPROC gl_GetUniformBlockIndex = NULL;
|
||||||
|
PFNGLUNIFORMBLOCKBINDINGPROC gl_UniformBlockBinding = NULL;
|
||||||
|
|
||||||
namespace GLLoader {
|
namespace GLLoader {
|
||||||
|
|
||||||
|
bool fglrx_buggy_driver = false;
|
||||||
|
bool found_GL_ARB_separate_shader_objects = false;
|
||||||
|
bool found_GL_ARB_shading_language_420pack = false;
|
||||||
|
bool found_GL_ARB_texture_storage = false;
|
||||||
|
|
||||||
bool check_gl_version(uint32 major, uint32 minor) {
|
bool check_gl_version(uint32 major, uint32 minor) {
|
||||||
const GLubyte* s;
|
|
||||||
s = glGetString(GL_VERSION);
|
const GLubyte* s = glGetString(GL_VERSION);
|
||||||
if (s == NULL) return false;
|
if (s == NULL) return false;
|
||||||
fprintf(stderr, "Supported Opengl version: %s on GPU: %s. Vendor: %s\n", s, glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
fprintf(stderr, "Supported Opengl version: %s on GPU: %s. Vendor: %s\n", s, glGetString(GL_RENDERER), glGetString(GL_VENDOR));
|
||||||
|
|
||||||
// Could be useful to detect the GPU vendor:
|
// Could be useful to detect the GPU vendor:
|
||||||
// if ( strcmp((const char*)glGetString(GL_VENDOR), "ATI Technologies Inc.") == 0 )
|
if (strcmp((const char*)glGetString(GL_VENDOR), "ATI Technologies Inc.") == 0)
|
||||||
|
fglrx_buggy_driver = true;
|
||||||
|
|
||||||
GLuint dot = 0;
|
GLuint dot = 0;
|
||||||
while (s[dot] != '\0' && s[dot] != '.') dot++;
|
while (s[dot] != '\0' && s[dot] != '.') dot++;
|
||||||
|
@ -173,22 +186,25 @@ namespace GLLoader {
|
||||||
GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer);
|
GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer);
|
||||||
GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer);
|
GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer);
|
||||||
GL_LOADFN(gl_TexStorage2D, glTexStorage2D);
|
GL_LOADFN(gl_TexStorage2D, glTexStorage2D);
|
||||||
|
// NO GL4.1
|
||||||
|
GL_LOADFN(gl_UseProgram, glUseProgram);
|
||||||
|
GL_LOADFN(gl_GetShaderInfoLog, glGetShaderInfoLog);
|
||||||
|
// NO GL4.2
|
||||||
|
GL_LOADFN(gl_GetUniformBlockIndex, glGetUniformBlockIndex);
|
||||||
|
GL_LOADFN(gl_UniformBlockBinding, glUniformBlockBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_gl_supported_extension() {
|
bool check_gl_supported_extension() {
|
||||||
int max_ext = 0;
|
int max_ext = 0;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext);
|
||||||
|
|
||||||
bool found_GL_ARB_separate_shader_objects = false;
|
|
||||||
bool found_GL_ARB_shading_language_420pack = false;
|
|
||||||
bool found_GL_ARB_texture_storage = false;
|
|
||||||
fprintf(stderr, "DEBUG: check_gl_supported_extension\n");
|
fprintf(stderr, "DEBUG: check_gl_supported_extension\n");
|
||||||
|
|
||||||
if (gl_GetStringi && max_ext) {
|
if (gl_GetStringi && max_ext) {
|
||||||
for (GLint i = 0; i < max_ext; i++) {
|
for (GLint i = 0; i < max_ext; i++) {
|
||||||
string ext((const char*)gl_GetStringi(GL_EXTENSIONS, i));
|
string ext((const char*)gl_GetStringi(GL_EXTENSIONS, i));
|
||||||
if (ext.compare("GL_ARB_separate_shader_objects") == 0) {
|
if (ext.compare("GL_ARB_separate_shader_objects") == 0) {
|
||||||
found_GL_ARB_separate_shader_objects = true;
|
if (!fglrx_buggy_driver) found_GL_ARB_separate_shader_objects = true;
|
||||||
}
|
}
|
||||||
if (ext.compare("GL_ARB_shading_language_420pack") == 0) {
|
if (ext.compare("GL_ARB_shading_language_420pack") == 0) {
|
||||||
found_GL_ARB_shading_language_420pack = true;
|
found_GL_ARB_shading_language_420pack = true;
|
||||||
|
@ -202,7 +218,7 @@ namespace GLLoader {
|
||||||
|
|
||||||
if (!found_GL_ARB_separate_shader_objects) {
|
if (!found_GL_ARB_separate_shader_objects) {
|
||||||
fprintf(stderr, "GL_ARB_separate_shader_objects is not supported\n");
|
fprintf(stderr, "GL_ARB_separate_shader_objects is not supported\n");
|
||||||
return false;
|
//return false;
|
||||||
}
|
}
|
||||||
if (!found_GL_ARB_shading_language_420pack) {
|
if (!found_GL_ARB_shading_language_420pack) {
|
||||||
fprintf(stderr, "GL_ARB_shading_language_420pack is not supported\n");
|
fprintf(stderr, "GL_ARB_shading_language_420pack is not supported\n");
|
||||||
|
|
|
@ -110,10 +110,22 @@ extern PFNGLUNMAPBUFFERPROC gl_UnmapBuffer;
|
||||||
extern PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages;
|
extern PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages;
|
||||||
extern PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer;
|
extern PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer;
|
||||||
extern PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer;
|
extern PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer;
|
||||||
extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D;
|
extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D;
|
||||||
|
// NO GL4.1
|
||||||
|
extern PFNGLUSEPROGRAMPROC gl_UseProgram;
|
||||||
|
extern PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog;
|
||||||
|
// NO GL4.2
|
||||||
|
extern PFNGLGETUNIFORMBLOCKINDEXPROC gl_GetUniformBlockIndex;
|
||||||
|
extern PFNGLUNIFORMBLOCKBINDINGPROC gl_UniformBlockBinding;
|
||||||
|
|
||||||
|
|
||||||
namespace GLLoader {
|
namespace GLLoader {
|
||||||
bool check_gl_version(uint32 major, uint32 minor);
|
bool check_gl_version(uint32 major, uint32 minor);
|
||||||
void init_gl_function();
|
void init_gl_function();
|
||||||
bool check_gl_supported_extension();
|
bool check_gl_supported_extension();
|
||||||
|
|
||||||
|
extern bool found_GL_ARB_separate_shader_objects;
|
||||||
|
extern bool found_GL_ARB_shading_language_420pack;
|
||||||
|
extern bool found_GL_ARB_texture_storage;
|
||||||
|
extern bool fglrx_buggy_driver;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,33 +75,31 @@ GSDeviceOGL::~GSDeviceOGL()
|
||||||
|
|
||||||
// Clean m_merge_obj
|
// Clean m_merge_obj
|
||||||
for (uint32 i = 0; i < 2; i++)
|
for (uint32 i = 0; i < 2; i++)
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects)
|
||||||
gl_DeleteProgram(m_merge_obj.ps[i]);
|
gl_DeleteProgram(m_merge_obj.ps[i]);
|
||||||
#else
|
else
|
||||||
gl_DeleteShader(m_merge_obj.ps[i]);
|
gl_DeleteShader(m_merge_obj.ps[i]);
|
||||||
#endif
|
|
||||||
delete (m_merge_obj.cb);
|
delete (m_merge_obj.cb);
|
||||||
delete (m_merge_obj.bs);
|
delete (m_merge_obj.bs);
|
||||||
|
|
||||||
// Clean m_interlace
|
// Clean m_interlace
|
||||||
for (uint32 i = 0; i < 2; i++)
|
for (uint32 i = 0; i < 2; i++)
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects)
|
||||||
gl_DeleteProgram(m_interlace.ps[i]);
|
gl_DeleteProgram(m_interlace.ps[i]);
|
||||||
#else
|
else
|
||||||
gl_DeleteShader(m_interlace.ps[i]);
|
gl_DeleteShader(m_interlace.ps[i]);
|
||||||
#endif
|
|
||||||
delete (m_interlace.cb);
|
delete (m_interlace.cb);
|
||||||
|
|
||||||
// Clean m_convert
|
// Clean m_convert
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||||
gl_DeleteProgram(m_convert.vs);
|
gl_DeleteProgram(m_convert.vs);
|
||||||
for (uint32 i = 0; i < 2; i++)
|
for (uint32 i = 0; i < 2; i++)
|
||||||
gl_DeleteProgram(m_convert.ps[i]);
|
gl_DeleteProgram(m_convert.ps[i]);
|
||||||
#else
|
} else {
|
||||||
gl_DeleteShader(m_convert.vs);
|
gl_DeleteShader(m_convert.vs);
|
||||||
for (uint i = 0; i < 2; i++)
|
for (uint i = 0; i < 2; i++)
|
||||||
gl_DeleteShader(m_convert.ps[i]);
|
gl_DeleteShader(m_convert.ps[i]);
|
||||||
#endif
|
}
|
||||||
gl_DeleteSamplers(1, &m_convert.ln);
|
gl_DeleteSamplers(1, &m_convert.ln);
|
||||||
gl_DeleteSamplers(1, &m_convert.pt);
|
gl_DeleteSamplers(1, &m_convert.pt);
|
||||||
delete m_convert.dss;
|
delete m_convert.dss;
|
||||||
|
@ -112,9 +110,8 @@ GSDeviceOGL::~GSDeviceOGL()
|
||||||
delete m_date.bs;
|
delete m_date.bs;
|
||||||
|
|
||||||
// Clean various opengl allocation
|
// Clean various opengl allocation
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects)
|
||||||
gl_DeleteProgramPipelines(1, &m_pipeline);
|
gl_DeleteProgramPipelines(1, &m_pipeline);
|
||||||
#endif
|
|
||||||
gl_DeleteFramebuffers(1, &m_fbo);
|
gl_DeleteFramebuffers(1, &m_fbo);
|
||||||
gl_DeleteFramebuffers(1, &m_fbo_read);
|
gl_DeleteFramebuffers(1, &m_fbo_read);
|
||||||
|
|
||||||
|
@ -124,18 +121,19 @@ GSDeviceOGL::~GSDeviceOGL()
|
||||||
gl_DeleteSamplers(1, &m_rt_ss);
|
gl_DeleteSamplers(1, &m_rt_ss);
|
||||||
delete m_vb;
|
delete m_vb;
|
||||||
|
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||||
for (auto it = m_vs.begin(); it != m_vs.end() ; it++) gl_DeleteProgram(it->second);
|
for (auto it = m_vs.begin(); it != m_vs.end() ; it++) gl_DeleteProgram(it->second);
|
||||||
for (auto it = m_gs.begin(); it != m_gs.end() ; it++) gl_DeleteProgram(it->second);
|
for (auto it = m_gs.begin(); it != m_gs.end() ; it++) gl_DeleteProgram(it->second);
|
||||||
for (auto it = m_ps.begin(); it != m_ps.end() ; it++) gl_DeleteProgram(it->second);
|
for (auto it = m_ps.begin(); it != m_ps.end() ; it++) gl_DeleteProgram(it->second);
|
||||||
#else
|
} else {
|
||||||
for (auto it = m_vs.begin(); it != m_vs.end() ; it++) gl_DeleteShader(it->second);
|
for (auto it = m_vs.begin(); it != m_vs.end() ; it++) gl_DeleteShader(it->second);
|
||||||
for (auto it = m_gs.begin(); it != m_gs.end() ; it++) gl_DeleteShader(it->second);
|
for (auto it = m_gs.begin(); it != m_gs.end() ; it++) gl_DeleteShader(it->second);
|
||||||
for (auto it = m_ps.begin(); it != m_ps.end() ; it++) gl_DeleteShader(it->second);
|
for (auto it = m_ps.begin(); it != m_ps.end() ; it++) gl_DeleteShader(it->second);
|
||||||
|
|
||||||
|
for (auto it = m_single_prog.begin(); it != m_single_prog.end() ; it++) gl_DeleteProgram(it->second);
|
||||||
|
m_single_prog.clear();
|
||||||
|
}
|
||||||
|
|
||||||
for (auto it = m_single_prog.begin(); it != m_single_prog.end() ; it++) gl_DeleteProgram(it->second);
|
|
||||||
m_single_prog.clear();
|
|
||||||
#endif
|
|
||||||
for (auto it = m_ps_ss.begin(); it != m_ps_ss.end() ; it++) gl_DeleteSamplers(1, &it->second);
|
for (auto it = m_ps_ss.begin(); it != m_ps_ss.end() ; it++) gl_DeleteSamplers(1, &it->second);
|
||||||
m_vs.clear();
|
m_vs.clear();
|
||||||
m_gs.clear();
|
m_gs.clear();
|
||||||
|
@ -196,10 +194,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
||||||
// ****************************************************************
|
// ****************************************************************
|
||||||
// Various object
|
// Various object
|
||||||
// ****************************************************************
|
// ****************************************************************
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||||
gl_GenProgramPipelines(1, &m_pipeline);
|
gl_GenProgramPipelines(1, &m_pipeline);
|
||||||
gl_BindProgramPipeline(m_pipeline);
|
gl_BindProgramPipeline(m_pipeline);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
gl_GenFramebuffers(1, &m_fbo);
|
gl_GenFramebuffers(1, &m_fbo);
|
||||||
gl_GenFramebuffers(1, &m_fbo_read);
|
gl_GenFramebuffers(1, &m_fbo_read);
|
||||||
|
@ -586,17 +584,14 @@ void GSDeviceOGL::DebugOutput()
|
||||||
//DebugBB();
|
//DebugBB();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DISABLE_GL42
|
|
||||||
static void set_uniform_buffer_binding(GLuint prog, GLchar* name, GLuint binding) {
|
static void set_uniform_buffer_binding(GLuint prog, GLchar* name, GLuint binding) {
|
||||||
GLuint index;
|
GLuint index;
|
||||||
index = glGetUniformBlockIndex(prog, name);
|
index = gl_GetUniformBlockIndex(prog, name);
|
||||||
if (index != GL_INVALID_INDEX) {
|
if (index != GL_INVALID_INDEX) {
|
||||||
glUniformBlockBinding(prog, index, binding);
|
gl_UniformBlockBinding(prog, index, binding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DISABLE_GL41_SSO
|
|
||||||
GLuint GSDeviceOGL::link_prog()
|
GLuint GSDeviceOGL::link_prog()
|
||||||
{
|
{
|
||||||
GLuint single_prog = gl_CreateProgram();
|
GLuint single_prog = gl_CreateProgram();
|
||||||
|
@ -628,7 +623,6 @@ GLuint GSDeviceOGL::link_prog()
|
||||||
|
|
||||||
return single_prog;
|
return single_prog;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void GSDeviceOGL::BeforeDraw()
|
void GSDeviceOGL::BeforeDraw()
|
||||||
{
|
{
|
||||||
|
@ -636,29 +630,28 @@ void GSDeviceOGL::BeforeDraw()
|
||||||
DebugInput();
|
DebugInput();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DISABLE_GL41_SSO
|
if (!GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||||
// Note: shader are integer lookup pointer. They start from 1 and incr
|
// Note: shader are integer lookup pointer. They start from 1 and incr
|
||||||
// every time you create a new shader OR a new program.
|
// every time you create a new shader OR a new program.
|
||||||
uint64 sel = (uint64)m_state.vs << 40 | (uint64)m_state.gs << 20 | m_state.ps;
|
uint64 sel = (uint64)m_state.vs << 40 | (uint64)m_state.gs << 20 | m_state.ps;
|
||||||
auto single_prog = m_single_prog.find(sel);
|
auto single_prog = m_single_prog.find(sel);
|
||||||
if (single_prog == m_single_prog.end()) {
|
if (single_prog == m_single_prog.end()) {
|
||||||
m_single_prog[sel] = link_prog();
|
m_single_prog[sel] = link_prog();
|
||||||
single_prog = m_single_prog.find(sel);
|
single_prog = m_single_prog.find(sel);
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_UseProgram(single_prog->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram(single_prog->second);
|
if (!GLLoader::found_GL_ARB_shading_language_420pack) {
|
||||||
|
set_uniform_buffer_binding(m_state.vs, "cb20", 20);
|
||||||
|
set_uniform_buffer_binding(m_state.ps, "cb21", 21);
|
||||||
|
|
||||||
#endif
|
set_uniform_buffer_binding(m_state.ps, "cb10", 10);
|
||||||
|
set_uniform_buffer_binding(m_state.ps, "cb11", 11);
|
||||||
#ifdef DISABLE_GL42
|
set_uniform_buffer_binding(m_state.ps, "cb12", 12);
|
||||||
set_uniform_buffer_binding(m_state.vs, "cb20", 20);
|
set_uniform_buffer_binding(m_state.ps, "cb13", 13);
|
||||||
set_uniform_buffer_binding(m_state.ps, "cb21", 21);
|
}
|
||||||
|
|
||||||
set_uniform_buffer_binding(m_state.ps, "cb10", 10);
|
|
||||||
set_uniform_buffer_binding(m_state.ps, "cb11", 11);
|
|
||||||
set_uniform_buffer_binding(m_state.ps, "cb12", 12);
|
|
||||||
set_uniform_buffer_binding(m_state.ps, "cb13", 13);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSDeviceOGL::AfterDraw()
|
void GSDeviceOGL::AfterDraw()
|
||||||
|
@ -1139,9 +1132,8 @@ void GSDeviceOGL::VSSetShader(GLuint vs)
|
||||||
if(m_state.vs != vs)
|
if(m_state.vs != vs)
|
||||||
{
|
{
|
||||||
m_state.vs = vs;
|
m_state.vs = vs;
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects)
|
||||||
gl_UseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs);
|
gl_UseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,9 +1142,8 @@ void GSDeviceOGL::GSSetShader(GLuint gs)
|
||||||
if(m_state.gs != gs)
|
if(m_state.gs != gs)
|
||||||
{
|
{
|
||||||
m_state.gs = gs;
|
m_state.gs = gs;
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects)
|
||||||
gl_UseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs);
|
gl_UseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1193,9 +1184,8 @@ void GSDeviceOGL::PSSetShader(GLuint ps)
|
||||||
if(m_state.ps != ps)
|
if(m_state.ps != ps)
|
||||||
{
|
{
|
||||||
m_state.ps = ps;
|
m_state.ps = ps;
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects)
|
||||||
gl_UseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps);
|
gl_UseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sampler and texture must be set at the same time
|
// Sampler and texture must be set at the same time
|
||||||
|
@ -1309,20 +1299,15 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
|
||||||
// Build a header string
|
// Build a header string
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
// First select the version (must be the first line so we need to generate it
|
// First select the version (must be the first line so we need to generate it
|
||||||
#ifdef DISABLE_GL41_SSO
|
std::string version = "#version 330\n";
|
||||||
#ifdef DISABLE_GL42
|
if (GLLoader::found_GL_ARB_shading_language_420pack) {
|
||||||
std::string version = "#version 330\n#define DISABLE_GL42\n";
|
version += "#extension GL_ARB_shading_language_420pack: require\n";
|
||||||
#else
|
} else {
|
||||||
std::string version = "#version 330\n#extension GL_ARB_shading_language_420pack: require\n";
|
version += "#define DISABLE_GL42\n";
|
||||||
#endif
|
}
|
||||||
#else
|
if (GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||||
#ifdef DISABLE_GL42
|
version += "#extension GL_ARB_separate_shader_objects : require\n";
|
||||||
std::string version = "#version 330\n#extension GL_ARB_separate_shader_objects : require\n#define DISABLE_GL42\n";
|
}
|
||||||
#else
|
|
||||||
std::string version = "#version 330\n#extension GL_ARB_shading_language_420pack: require\n#extension GL_ARB_separate_shader_objects : require\n";
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
//std::string version = "#version 420\n";
|
|
||||||
|
|
||||||
// Allow to puts several shader in 1 files
|
// Allow to puts several shader in 1 files
|
||||||
std::string shader_type;
|
std::string shader_type;
|
||||||
|
@ -1391,20 +1376,20 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects) {
|
||||||
#if 0
|
#if 0
|
||||||
// Could be useful one day
|
// Could be useful one day
|
||||||
const GLchar* ShaderSource[1];
|
const GLchar* ShaderSource[1];
|
||||||
ShaderSource[0] = header.append(source).c_str();
|
ShaderSource[0] = header.append(source).c_str();
|
||||||
*program = gl_CreateShaderProgramv(type, 1, &ShaderSource[0]);
|
*program = gl_CreateShaderProgramv(type, 1, &ShaderSource[0]);
|
||||||
#else
|
#else
|
||||||
*program = gl_CreateShaderProgramv(type, 2, sources_array);
|
*program = gl_CreateShaderProgramv(type, 2, sources_array);
|
||||||
#endif
|
#endif
|
||||||
#else
|
} else {
|
||||||
*program = gl_CreateShader(type);
|
*program = gl_CreateShader(type);
|
||||||
gl_ShaderSource(*program, 2, sources_array, NULL);
|
gl_ShaderSource(*program, 2, sources_array, NULL);
|
||||||
gl_CompileShader(*program);
|
gl_CompileShader(*program);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
free(source_str);
|
free(source_str);
|
||||||
free(header_str);
|
free(header_str);
|
||||||
|
@ -1416,18 +1401,18 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
|
||||||
fprintf(stderr, "\n%s", macro_sel.c_str());
|
fprintf(stderr, "\n%s", macro_sel.c_str());
|
||||||
|
|
||||||
GLint log_length = 0;
|
GLint log_length = 0;
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects)
|
||||||
gl_GetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length);
|
gl_GetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length);
|
||||||
#else
|
else
|
||||||
gl_GetShaderiv(*program, GL_INFO_LOG_LENGTH, &log_length);
|
gl_GetShaderiv(*program, GL_INFO_LOG_LENGTH, &log_length);
|
||||||
#endif
|
|
||||||
if (log_length > 0) {
|
if (log_length > 0) {
|
||||||
char* log = new char[log_length];
|
char* log = new char[log_length];
|
||||||
#ifndef DISABLE_GL41_SSO
|
if (GLLoader::found_GL_ARB_separate_shader_objects)
|
||||||
gl_GetProgramInfoLog(*program, log_length, NULL, log);
|
gl_GetProgramInfoLog(*program, log_length, NULL, log);
|
||||||
#else
|
else
|
||||||
glGetShaderInfoLog(*program, log_length, NULL, log);
|
gl_GetShaderInfoLog(*program, log_length, NULL, log);
|
||||||
#endif
|
|
||||||
fprintf(stderr, "%s", log);
|
fprintf(stderr, "%s", log);
|
||||||
delete[] log;
|
delete[] log;
|
||||||
}
|
}
|
||||||
|
|
|
@ -657,9 +657,6 @@ class GSDeviceOGL : public GSDevice
|
||||||
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
|
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
|
||||||
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
|
||||||
|
|
||||||
#ifdef DISABLE_GL41_SSO
|
|
||||||
hash_map<uint64, GLuint > m_single_prog;
|
hash_map<uint64, GLuint > m_single_prog;
|
||||||
GLuint link_prog();
|
GLuint link_prog();
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,9 +40,3 @@
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define ENABLE_OGL_DEBUG // Create a debug context and check opengl command status. Allow also to dump various textures/states.
|
#define ENABLE_OGL_DEBUG // Create a debug context and check opengl command status. Allow also to dump various textures/states.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set manually uniform buffer index
|
|
||||||
//#define DISABLE_GL42
|
|
||||||
|
|
||||||
// Debug: use single program for all shaders.
|
|
||||||
//#define DISABLE_GL41_SSO
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
extern const char* convert_glsl =
|
static const char* convert_glsl =
|
||||||
"//#version 420 // Keep it for editor detection\n"
|
"//#version 420 // Keep it for editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"struct vertex_basic\n"
|
"struct vertex_basic\n"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
extern const char* interlace_glsl =
|
static const char* interlace_glsl =
|
||||||
"//#version 420 // Keep it for editor detection\n"
|
"//#version 420 // Keep it for editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"struct vertex_basic\n"
|
"struct vertex_basic\n"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
extern const char* merge_glsl =
|
static const char* merge_glsl =
|
||||||
"//#version 420 // Keep it for editor detection\n"
|
"//#version 420 // Keep it for editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"struct vertex_basic\n"
|
"struct vertex_basic\n"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
extern const char* shadeboost_glsl =
|
static const char* shadeboost_glsl =
|
||||||
"//#version 420 // Keep it for editor detection\n"
|
"//#version 420 // Keep it for editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"/*\n"
|
"/*\n"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
extern const char* tfx_glsl =
|
static const char* tfx_glsl =
|
||||||
"//#version 420 // Keep it for text editor detection\n"
|
"//#version 420 // Keep it for text editor detection\n"
|
||||||
"\n"
|
"\n"
|
||||||
"// note lerp => mix\n"
|
"// note lerp => mix\n"
|
||||||
|
|
Loading…
Reference in New Issue