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:
gregory.hainaut 2013-05-19 12:42:55 +00:00
parent 9376b26537
commit 6779edfe28
11 changed files with 200 additions and 196 deletions

View File

@ -45,7 +45,7 @@ sub glsl2h {
#include "stdafx.h"
extern const char* ${glsl}_glsl =
static const char* ${glsl}_glsl =
EOS
print $H $header;

View File

@ -22,78 +22,91 @@
#include "stdafx.h"
#include "GLLoader.h"
PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL;
PFNGLBLENDCOLORPROC gl_BlendColor = NULL;
PFNGLATTACHSHADERPROC gl_AttachShader = NULL;
PFNGLBINDBUFFERPROC gl_BindBuffer = NULL;
PFNGLBINDBUFFERBASEPROC gl_BindBufferBase = NULL;
PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed = NULL;
PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer = NULL;
PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline = NULL;
PFNGLBINDSAMPLERPROC gl_BindSampler = NULL;
PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray = NULL;
PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate = NULL;
PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate = NULL;
PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer = NULL;
PFNGLBUFFERDATAPROC gl_BufferData = NULL;
PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus = NULL;
PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv = NULL;
PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv = NULL;
PFNGLCOMPILESHADERPROC gl_CompileShader = NULL;
PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV = NULL;
PFNGLCREATEPROGRAMPROC gl_CreateProgram = NULL;
PFNGLCREATESHADERPROC gl_CreateShader = NULL;
PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv = NULL;
PFNGLDELETEBUFFERSPROC gl_DeleteBuffers = NULL;
PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers = NULL;
PFNGLDELETEPROGRAMPROC gl_DeleteProgram = NULL;
PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines = NULL;
PFNGLDELETESAMPLERSPROC gl_DeleteSamplers = NULL;
PFNGLDELETESHADERPROC gl_DeleteShader = NULL;
PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays = NULL;
PFNGLDETACHSHADERPROC gl_DetachShader = NULL;
PFNGLDRAWBUFFERSPROC gl_DrawBuffers = NULL;
PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex = NULL;
PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray = NULL;
PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer = NULL;
PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D = NULL;
PFNGLGENBUFFERSPROC gl_GenBuffers = NULL;
PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers = NULL;
PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines = NULL;
PFNGLGENSAMPLERSPROC gl_GenSamplers = NULL;
PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays = NULL;
PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv = NULL;
PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB = NULL;
PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex = NULL;
PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation = NULL;
PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog = NULL;
PFNGLGETPROGRAMIVPROC gl_GetProgramiv = NULL;
PFNGLGETSHADERIVPROC gl_GetShaderiv = NULL;
PFNGLGETSTRINGIPROC gl_GetStringi = NULL;
PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer = NULL;
PFNGLLINKPROGRAMPROC gl_LinkProgram = NULL;
PFNGLMAPBUFFERPROC gl_MapBuffer = NULL;
PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange = NULL;
PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri = NULL;
PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf = NULL;
PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri = NULL;
PFNGLSHADERSOURCEPROC gl_ShaderSource = NULL;
PFNGLUNIFORM1IPROC gl_Uniform1i = NULL;
PFNGLUNMAPBUFFERPROC gl_UnmapBuffer = NULL;
PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages = NULL;
PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL;
PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = NULL;
PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL;
PFNGLBLENDCOLORPROC gl_BlendColor = NULL;
PFNGLATTACHSHADERPROC gl_AttachShader = NULL;
PFNGLBINDBUFFERPROC gl_BindBuffer = NULL;
PFNGLBINDBUFFERBASEPROC gl_BindBufferBase = NULL;
PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed = NULL;
PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer = NULL;
PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline = NULL;
PFNGLBINDSAMPLERPROC gl_BindSampler = NULL;
PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray = NULL;
PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate = NULL;
PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate = NULL;
PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer = NULL;
PFNGLBUFFERDATAPROC gl_BufferData = NULL;
PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus = NULL;
PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv = NULL;
PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv = NULL;
PFNGLCOMPILESHADERPROC gl_CompileShader = NULL;
PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV = NULL;
PFNGLCREATEPROGRAMPROC gl_CreateProgram = NULL;
PFNGLCREATESHADERPROC gl_CreateShader = NULL;
PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv = NULL;
PFNGLDELETEBUFFERSPROC gl_DeleteBuffers = NULL;
PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers = NULL;
PFNGLDELETEPROGRAMPROC gl_DeleteProgram = NULL;
PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines = NULL;
PFNGLDELETESAMPLERSPROC gl_DeleteSamplers = NULL;
PFNGLDELETESHADERPROC gl_DeleteShader = NULL;
PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays = NULL;
PFNGLDETACHSHADERPROC gl_DetachShader = NULL;
PFNGLDRAWBUFFERSPROC gl_DrawBuffers = NULL;
PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex = NULL;
PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray = NULL;
PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer = NULL;
PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D = NULL;
PFNGLGENBUFFERSPROC gl_GenBuffers = NULL;
PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers = NULL;
PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines = NULL;
PFNGLGENSAMPLERSPROC gl_GenSamplers = NULL;
PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays = NULL;
PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv = NULL;
PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB = NULL;
PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex = NULL;
PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation = NULL;
PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog = NULL;
PFNGLGETPROGRAMIVPROC gl_GetProgramiv = NULL;
PFNGLGETSHADERIVPROC gl_GetShaderiv = NULL;
PFNGLGETSTRINGIPROC gl_GetStringi = NULL;
PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer = NULL;
PFNGLLINKPROGRAMPROC gl_LinkProgram = NULL;
PFNGLMAPBUFFERPROC gl_MapBuffer = NULL;
PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange = NULL;
PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri = NULL;
PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf = NULL;
PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri = NULL;
PFNGLSHADERSOURCEPROC gl_ShaderSource = NULL;
PFNGLUNIFORM1IPROC gl_Uniform1i = NULL;
PFNGLUNMAPBUFFERPROC gl_UnmapBuffer = NULL;
PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages = NULL;
PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL;
PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = 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 {
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) {
const GLubyte* s;
s = glGetString(GL_VERSION);
const GLubyte* s = glGetString(GL_VERSION);
if (s == NULL) return false;
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:
// 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;
while (s[dot] != '\0' && s[dot] != '.') dot++;
@ -173,22 +186,25 @@ namespace GLLoader {
GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer);
GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer);
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() {
int max_ext = 0;
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");
if (gl_GetStringi && max_ext) {
for (GLint i = 0; i < max_ext; i++) {
string ext((const char*)gl_GetStringi(GL_EXTENSIONS, i));
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) {
found_GL_ARB_shading_language_420pack = true;
@ -202,7 +218,7 @@ namespace GLLoader {
if (!found_GL_ARB_separate_shader_objects) {
fprintf(stderr, "GL_ARB_separate_shader_objects is not supported\n");
return false;
//return false;
}
if (!found_GL_ARB_shading_language_420pack) {
fprintf(stderr, "GL_ARB_shading_language_420pack is not supported\n");

View File

@ -110,10 +110,22 @@ extern PFNGLUNMAPBUFFERPROC gl_UnmapBuffer;
extern PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages;
extern PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer;
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 {
bool check_gl_version(uint32 major, uint32 minor);
void init_gl_function();
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;
}

View File

@ -75,33 +75,31 @@ GSDeviceOGL::~GSDeviceOGL()
// Clean m_merge_obj
for (uint32 i = 0; i < 2; i++)
#ifndef DISABLE_GL41_SSO
gl_DeleteProgram(m_merge_obj.ps[i]);
#else
gl_DeleteShader(m_merge_obj.ps[i]);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects)
gl_DeleteProgram(m_merge_obj.ps[i]);
else
gl_DeleteShader(m_merge_obj.ps[i]);
delete (m_merge_obj.cb);
delete (m_merge_obj.bs);
// Clean m_interlace
for (uint32 i = 0; i < 2; i++)
#ifndef DISABLE_GL41_SSO
gl_DeleteProgram(m_interlace.ps[i]);
#else
gl_DeleteShader(m_interlace.ps[i]);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects)
gl_DeleteProgram(m_interlace.ps[i]);
else
gl_DeleteShader(m_interlace.ps[i]);
delete (m_interlace.cb);
// Clean m_convert
#ifndef DISABLE_GL41_SSO
gl_DeleteProgram(m_convert.vs);
for (uint32 i = 0; i < 2; i++)
gl_DeleteProgram(m_convert.ps[i]);
#else
gl_DeleteShader(m_convert.vs);
for (uint i = 0; i < 2; i++)
gl_DeleteShader(m_convert.ps[i]);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects) {
gl_DeleteProgram(m_convert.vs);
for (uint32 i = 0; i < 2; i++)
gl_DeleteProgram(m_convert.ps[i]);
} else {
gl_DeleteShader(m_convert.vs);
for (uint i = 0; i < 2; i++)
gl_DeleteShader(m_convert.ps[i]);
}
gl_DeleteSamplers(1, &m_convert.ln);
gl_DeleteSamplers(1, &m_convert.pt);
delete m_convert.dss;
@ -112,9 +110,8 @@ GSDeviceOGL::~GSDeviceOGL()
delete m_date.bs;
// Clean various opengl allocation
#ifndef DISABLE_GL41_SSO
gl_DeleteProgramPipelines(1, &m_pipeline);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects)
gl_DeleteProgramPipelines(1, &m_pipeline);
gl_DeleteFramebuffers(1, &m_fbo);
gl_DeleteFramebuffers(1, &m_fbo_read);
@ -124,18 +121,19 @@ GSDeviceOGL::~GSDeviceOGL()
gl_DeleteSamplers(1, &m_rt_ss);
delete m_vb;
#ifndef DISABLE_GL41_SSO
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_ps.begin(); it != m_ps.end() ; it++) gl_DeleteProgram(it->second);
#else
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_ps.begin(); it != m_ps.end() ; it++) gl_DeleteShader(it->second);
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_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);
} else {
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_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);
m_vs.clear();
m_gs.clear();
@ -196,10 +194,10 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
// ****************************************************************
// Various object
// ****************************************************************
#ifndef DISABLE_GL41_SSO
gl_GenProgramPipelines(1, &m_pipeline);
gl_BindProgramPipeline(m_pipeline);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects) {
gl_GenProgramPipelines(1, &m_pipeline);
gl_BindProgramPipeline(m_pipeline);
}
gl_GenFramebuffers(1, &m_fbo);
gl_GenFramebuffers(1, &m_fbo_read);
@ -586,17 +584,14 @@ void GSDeviceOGL::DebugOutput()
//DebugBB();
}
#ifdef DISABLE_GL42
static void set_uniform_buffer_binding(GLuint prog, GLchar* name, GLuint binding) {
GLuint index;
index = glGetUniformBlockIndex(prog, name);
index = gl_GetUniformBlockIndex(prog, name);
if (index != GL_INVALID_INDEX) {
glUniformBlockBinding(prog, index, binding);
gl_UniformBlockBinding(prog, index, binding);
}
}
#endif
#ifdef DISABLE_GL41_SSO
GLuint GSDeviceOGL::link_prog()
{
GLuint single_prog = gl_CreateProgram();
@ -628,7 +623,6 @@ GLuint GSDeviceOGL::link_prog()
return single_prog;
}
#endif
void GSDeviceOGL::BeforeDraw()
{
@ -636,29 +630,28 @@ void GSDeviceOGL::BeforeDraw()
DebugInput();
#endif
#ifdef DISABLE_GL41_SSO
// Note: shader are integer lookup pointer. They start from 1 and incr
// 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;
auto single_prog = m_single_prog.find(sel);
if (single_prog == m_single_prog.end()) {
m_single_prog[sel] = link_prog();
single_prog = m_single_prog.find(sel);
if (!GLLoader::found_GL_ARB_separate_shader_objects) {
// Note: shader are integer lookup pointer. They start from 1 and incr
// 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;
auto single_prog = m_single_prog.find(sel);
if (single_prog == m_single_prog.end()) {
m_single_prog[sel] = link_prog();
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
#ifdef DISABLE_GL42
set_uniform_buffer_binding(m_state.vs, "cb20", 20);
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
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);
}
}
void GSDeviceOGL::AfterDraw()
@ -1139,9 +1132,8 @@ void GSDeviceOGL::VSSetShader(GLuint vs)
if(m_state.vs != vs)
{
m_state.vs = vs;
#ifndef DISABLE_GL41_SSO
gl_UseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects)
gl_UseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs);
}
}
@ -1150,9 +1142,8 @@ void GSDeviceOGL::GSSetShader(GLuint gs)
if(m_state.gs != gs)
{
m_state.gs = gs;
#ifndef DISABLE_GL41_SSO
gl_UseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects)
gl_UseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs);
}
}
@ -1193,9 +1184,8 @@ void GSDeviceOGL::PSSetShader(GLuint ps)
if(m_state.ps != ps)
{
m_state.ps = ps;
#ifndef DISABLE_GL41_SSO
gl_UseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects)
gl_UseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps);
}
// 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
// *****************************************************
// First select the version (must be the first line so we need to generate it
#ifdef DISABLE_GL41_SSO
#ifdef DISABLE_GL42
std::string version = "#version 330\n#define DISABLE_GL42\n";
#else
std::string version = "#version 330\n#extension GL_ARB_shading_language_420pack: require\n";
#endif
#else
#ifdef DISABLE_GL42
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";
std::string version = "#version 330\n";
if (GLLoader::found_GL_ARB_shading_language_420pack) {
version += "#extension GL_ARB_shading_language_420pack: require\n";
} else {
version += "#define DISABLE_GL42\n";
}
if (GLLoader::found_GL_ARB_separate_shader_objects) {
version += "#extension GL_ARB_separate_shader_objects : require\n";
}
// Allow to puts several shader in 1 files
std::string shader_type;
@ -1391,20 +1376,20 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
}
#ifndef DISABLE_GL41_SSO
#if 0
// Could be useful one day
const GLchar* ShaderSource[1];
ShaderSource[0] = header.append(source).c_str();
*program = gl_CreateShaderProgramv(type, 1, &ShaderSource[0]);
#else
*program = gl_CreateShaderProgramv(type, 2, sources_array);
#endif
#else
*program = gl_CreateShader(type);
gl_ShaderSource(*program, 2, sources_array, NULL);
gl_CompileShader(*program);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects) {
#if 0
// Could be useful one day
const GLchar* ShaderSource[1];
ShaderSource[0] = header.append(source).c_str();
*program = gl_CreateShaderProgramv(type, 1, &ShaderSource[0]);
#else
*program = gl_CreateShaderProgramv(type, 2, sources_array);
#endif
} else {
*program = gl_CreateShader(type);
gl_ShaderSource(*program, 2, sources_array, NULL);
gl_CompileShader(*program);
}
free(source_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());
GLint log_length = 0;
#ifndef DISABLE_GL41_SSO
gl_GetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length);
#else
gl_GetShaderiv(*program, GL_INFO_LOG_LENGTH, &log_length);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects)
gl_GetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length);
else
gl_GetShaderiv(*program, GL_INFO_LOG_LENGTH, &log_length);
if (log_length > 0) {
char* log = new char[log_length];
#ifndef DISABLE_GL41_SSO
gl_GetProgramInfoLog(*program, log_length, NULL, log);
#else
glGetShaderInfoLog(*program, log_length, NULL, log);
#endif
if (GLLoader::found_GL_ARB_separate_shader_objects)
gl_GetProgramInfoLog(*program, log_length, NULL, log);
else
gl_GetShaderInfoLog(*program, log_length, NULL, log);
fprintf(stderr, "%s", log);
delete[] log;
}

View File

@ -657,9 +657,6 @@ class GSDeviceOGL : public GSDevice
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
#ifdef DISABLE_GL41_SSO
hash_map<uint64, GLuint > m_single_prog;
GLuint link_prog();
#endif
};

View File

@ -40,9 +40,3 @@
#ifdef _DEBUG
#define ENABLE_OGL_DEBUG // Create a debug context and check opengl command status. Allow also to dump various textures/states.
#endif
// Set manually uniform buffer index
//#define DISABLE_GL42
// Debug: use single program for all shaders.
//#define DISABLE_GL41_SSO

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* convert_glsl =
static const char* convert_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"struct vertex_basic\n"

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* interlace_glsl =
static const char* interlace_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"struct vertex_basic\n"

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* merge_glsl =
static const char* merge_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"struct vertex_basic\n"

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* shadeboost_glsl =
static const char* shadeboost_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"/*\n"

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* tfx_glsl =
static const char* tfx_glsl =
"//#version 420 // Keep it for text editor detection\n"
"\n"
"// note lerp => mix\n"