mirror of https://github.com/PCSX2/pcsx2.git
gsdx-ogl-wnd:
* load extension as gl_Function instead of glFunction git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl-wnd@5635 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
dce89ff1a0
commit
9376b26537
|
@ -22,72 +22,68 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "GLLoader.h"
|
#include "GLLoader.h"
|
||||||
|
|
||||||
// Those are provided on gl.h on linux...
|
PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL;
|
||||||
#ifdef _WINDOWS
|
PFNGLBLENDCOLORPROC gl_BlendColor = NULL;
|
||||||
PFNGLACTIVETEXTUREPROC glActiveTexture = NULL;
|
PFNGLATTACHSHADERPROC gl_AttachShader = NULL;
|
||||||
PFNGLBLENDCOLORPROC glBlendColor = NULL;
|
PFNGLBINDBUFFERPROC gl_BindBuffer = NULL;
|
||||||
#endif
|
PFNGLBINDBUFFERBASEPROC gl_BindBufferBase = NULL;
|
||||||
|
PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed = NULL;
|
||||||
PFNGLATTACHSHADERPROC glAttachShader = NULL;
|
PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer = NULL;
|
||||||
PFNGLBINDBUFFERPROC glBindBuffer = NULL;
|
PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline = NULL;
|
||||||
PFNGLBINDBUFFERBASEPROC glBindBufferBase = NULL;
|
PFNGLBINDSAMPLERPROC gl_BindSampler = NULL;
|
||||||
PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glBindFragDataLocationIndexed = NULL;
|
PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray = NULL;
|
||||||
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = NULL;
|
PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate = NULL;
|
||||||
PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline = NULL;
|
PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate = NULL;
|
||||||
PFNGLBINDSAMPLERPROC glBindSampler = NULL;
|
PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer = NULL;
|
||||||
PFNGLBINDVERTEXARRAYPROC glBindVertexArray = NULL;
|
PFNGLBUFFERDATAPROC gl_BufferData = NULL;
|
||||||
PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate = NULL;
|
PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus = NULL;
|
||||||
PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = NULL;
|
PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv = NULL;
|
||||||
PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = NULL;
|
PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv = NULL;
|
||||||
PFNGLBUFFERDATAPROC glBufferData = NULL;
|
PFNGLCOMPILESHADERPROC gl_CompileShader = NULL;
|
||||||
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = NULL;
|
PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV = NULL;
|
||||||
PFNGLCLEARBUFFERFVPROC glClearBufferfv = NULL;
|
PFNGLCREATEPROGRAMPROC gl_CreateProgram = NULL;
|
||||||
PFNGLCLEARBUFFERIVPROC glClearBufferiv = NULL;
|
PFNGLCREATESHADERPROC gl_CreateShader = NULL;
|
||||||
PFNGLCOMPILESHADERPROC glCompileShader = NULL;
|
PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv = NULL;
|
||||||
PFNGLCOPYIMAGESUBDATANVPROC glCopyImageSubDataNV = NULL;
|
PFNGLDELETEBUFFERSPROC gl_DeleteBuffers = NULL;
|
||||||
PFNGLCREATEPROGRAMPROC glCreateProgram = NULL;
|
PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers = NULL;
|
||||||
PFNGLCREATESHADERPROC glCreateShader = NULL;
|
PFNGLDELETEPROGRAMPROC gl_DeleteProgram = NULL;
|
||||||
PFNGLCREATESHADERPROGRAMVPROC glCreateShaderProgramv = NULL;
|
PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines = NULL;
|
||||||
PFNGLDELETEBUFFERSPROC glDeleteBuffers = NULL;
|
PFNGLDELETESAMPLERSPROC gl_DeleteSamplers = NULL;
|
||||||
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = NULL;
|
PFNGLDELETESHADERPROC gl_DeleteShader = NULL;
|
||||||
PFNGLDELETEPROGRAMPROC glDeleteProgram = NULL;
|
PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays = NULL;
|
||||||
PFNGLDELETEPROGRAMPIPELINESPROC glDeleteProgramPipelines = NULL;
|
PFNGLDETACHSHADERPROC gl_DetachShader = NULL;
|
||||||
PFNGLDELETESAMPLERSPROC glDeleteSamplers = NULL;
|
PFNGLDRAWBUFFERSPROC gl_DrawBuffers = NULL;
|
||||||
PFNGLDELETESHADERPROC glDeleteShader = NULL;
|
PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex = NULL;
|
||||||
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = NULL;
|
PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray = NULL;
|
||||||
PFNGLDETACHSHADERPROC glDetachShader = NULL;
|
PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer = NULL;
|
||||||
PFNGLDRAWBUFFERSPROC glDrawBuffers = NULL;
|
PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D = NULL;
|
||||||
PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex = NULL;
|
PFNGLGENBUFFERSPROC gl_GenBuffers = NULL;
|
||||||
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = NULL;
|
PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers = NULL;
|
||||||
PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = NULL;
|
PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines = NULL;
|
||||||
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = NULL;
|
PFNGLGENSAMPLERSPROC gl_GenSamplers = NULL;
|
||||||
PFNGLGENBUFFERSPROC glGenBuffers = NULL;
|
PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays = NULL;
|
||||||
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = NULL;
|
PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv = NULL;
|
||||||
PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines = NULL;
|
PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB = NULL;
|
||||||
PFNGLGENSAMPLERSPROC glGenSamplers = NULL;
|
PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex = NULL;
|
||||||
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = NULL;
|
PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation = NULL;
|
||||||
PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = NULL;
|
PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog = NULL;
|
||||||
PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB = NULL;
|
PFNGLGETPROGRAMIVPROC gl_GetProgramiv = NULL;
|
||||||
PFNGLGETFRAGDATAINDEXPROC glGetFragDataIndex = NULL;
|
PFNGLGETSHADERIVPROC gl_GetShaderiv = NULL;
|
||||||
PFNGLGETFRAGDATALOCATIONPROC glGetFragDataLocation = NULL;
|
PFNGLGETSTRINGIPROC gl_GetStringi = NULL;
|
||||||
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = NULL;
|
PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer = NULL;
|
||||||
PFNGLGETPROGRAMIVPROC glGetProgramiv = NULL;
|
PFNGLLINKPROGRAMPROC gl_LinkProgram = NULL;
|
||||||
PFNGLGETSHADERIVPROC glGetShaderiv = NULL;
|
PFNGLMAPBUFFERPROC gl_MapBuffer = NULL;
|
||||||
PFNGLGETSTRINGIPROC glGetStringi = NULL;
|
PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange = NULL;
|
||||||
PFNGLISFRAMEBUFFERPROC glIsFramebuffer = NULL;
|
PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri = NULL;
|
||||||
PFNGLLINKPROGRAMPROC glLinkProgram = NULL;
|
PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf = NULL;
|
||||||
PFNGLMAPBUFFERPROC glMapBuffer = NULL;
|
PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri = NULL;
|
||||||
PFNGLMAPBUFFERRANGEPROC glMapBufferRange = NULL;
|
PFNGLSHADERSOURCEPROC gl_ShaderSource = NULL;
|
||||||
PFNGLPROGRAMPARAMETERIPROC glProgramParameteri = NULL;
|
PFNGLUNIFORM1IPROC gl_Uniform1i = NULL;
|
||||||
PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf = NULL;
|
PFNGLUNMAPBUFFERPROC gl_UnmapBuffer = NULL;
|
||||||
PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri = NULL;
|
PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages = NULL;
|
||||||
PFNGLSHADERSOURCEPROC glShaderSource = NULL;
|
PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL;
|
||||||
PFNGLUNIFORM1IPROC glUniform1i = NULL;
|
PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = NULL;
|
||||||
PFNGLUNMAPBUFFERPROC glUnmapBuffer = NULL;
|
PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
|
||||||
PFNGLUSEPROGRAMSTAGESPROC glUseProgramStages = NULL;
|
|
||||||
PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL;
|
|
||||||
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = NULL;
|
|
||||||
PFNGLTEXSTORAGE2DPROC glTexStorage2D = NULL;
|
|
||||||
|
|
||||||
namespace GLLoader {
|
namespace GLLoader {
|
||||||
|
|
||||||
|
@ -107,7 +103,7 @@ namespace GLLoader {
|
||||||
GLuint minor_gl = s[dot+1]-'0';
|
GLuint minor_gl = s[dot+1]-'0';
|
||||||
|
|
||||||
if ( (major_gl < major) || ( major_gl == major && minor_gl < minor ) ) {
|
if ( (major_gl < major) || ( major_gl == major && minor_gl < minor ) ) {
|
||||||
fprintf(stderr, "OPENGL 3.3 is not supported\n");
|
fprintf(stderr, "OPENGL %d.%d is not supported\n", major, minor);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,72 +111,68 @@ namespace GLLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_gl_function() {
|
void init_gl_function() {
|
||||||
// Those are provided on gl.h on linux...
|
GL_LOADFN(gl_ActiveTexture, glActiveTexture);
|
||||||
#ifdef _WINDOWS
|
GL_LOADFN(gl_BlendColor, glBlendColor);
|
||||||
GL_LOADFN(glActiveTexture);
|
GL_LOADFN(gl_AttachShader, glAttachShader);
|
||||||
GL_LOADFN(glBlendColor);
|
GL_LOADFN(gl_BindBuffer, glBindBuffer);
|
||||||
#endif
|
GL_LOADFN(gl_BindBufferBase, glBindBufferBase);
|
||||||
|
GL_LOADFN(gl_BindFragDataLocationIndexed, glBindFragDataLocationIndexed);
|
||||||
GL_LOADFN(glAttachShader);
|
GL_LOADFN(gl_BindFramebuffer, glBindFramebuffer);
|
||||||
GL_LOADFN(glBindBuffer);
|
GL_LOADFN(gl_BindProgramPipeline, glBindProgramPipeline);
|
||||||
GL_LOADFN(glBindBufferBase);
|
GL_LOADFN(gl_BindSampler, glBindSampler);
|
||||||
GL_LOADFN(glBindFragDataLocationIndexed);
|
GL_LOADFN(gl_BindVertexArray, glBindVertexArray);
|
||||||
GL_LOADFN(glBindFramebuffer);
|
GL_LOADFN(gl_BlendEquationSeparate, glBlendEquationSeparate);
|
||||||
GL_LOADFN(glBindProgramPipeline);
|
GL_LOADFN(gl_BlendFuncSeparate, glBlendFuncSeparate);
|
||||||
GL_LOADFN(glBindSampler);
|
GL_LOADFN(gl_BlitFramebuffer, glBlitFramebuffer);
|
||||||
GL_LOADFN(glBindVertexArray);
|
GL_LOADFN(gl_BufferData, glBufferData);
|
||||||
GL_LOADFN(glBlendEquationSeparate);
|
GL_LOADFN(gl_CheckFramebufferStatus, glCheckFramebufferStatus);
|
||||||
GL_LOADFN(glBlendFuncSeparate);
|
GL_LOADFN(gl_ClearBufferfv, glClearBufferfv);
|
||||||
GL_LOADFN(glBlitFramebuffer);
|
GL_LOADFN(gl_ClearBufferiv, glClearBufferiv);
|
||||||
GL_LOADFN(glBufferData);
|
GL_LOADFN(gl_CompileShader, glCompileShader);
|
||||||
GL_LOADFN(glCheckFramebufferStatus);
|
GL_LOADFN(gl_CopyImageSubDataNV, glCopyImageSubDataNV);
|
||||||
GL_LOADFN(glClearBufferfv);
|
GL_LOADFN(gl_CreateProgram, glCreateProgram);
|
||||||
GL_LOADFN(glClearBufferiv);
|
GL_LOADFN(gl_CreateShader, glCreateShader);
|
||||||
GL_LOADFN(glCompileShader);
|
GL_LOADFN(gl_CreateShaderProgramv, glCreateShaderProgramv);
|
||||||
GL_LOADFN(glCopyImageSubDataNV);
|
GL_LOADFN(gl_DeleteBuffers, glDeleteBuffers);
|
||||||
GL_LOADFN(glCreateProgram);
|
GL_LOADFN(gl_DeleteFramebuffers, glDeleteFramebuffers);
|
||||||
GL_LOADFN(glCreateShader);
|
GL_LOADFN(gl_DeleteProgram, glDeleteProgram);
|
||||||
GL_LOADFN(glCreateShaderProgramv);
|
GL_LOADFN(gl_DeleteProgramPipelines, glDeleteProgramPipelines);
|
||||||
GL_LOADFN(glDeleteBuffers);
|
GL_LOADFN(gl_DeleteSamplers, glDeleteSamplers);
|
||||||
GL_LOADFN(glDeleteFramebuffers);
|
GL_LOADFN(gl_DeleteShader, glDeleteShader);
|
||||||
GL_LOADFN(glDeleteProgram);
|
GL_LOADFN(gl_DeleteVertexArrays, glDeleteVertexArrays);
|
||||||
GL_LOADFN(glDeleteProgramPipelines);
|
GL_LOADFN(gl_DetachShader, glDetachShader);
|
||||||
GL_LOADFN(glDeleteSamplers);
|
GL_LOADFN(gl_DrawBuffers, glDrawBuffers);
|
||||||
GL_LOADFN(glDeleteShader);
|
GL_LOADFN(gl_DrawElementsBaseVertex, glDrawElementsBaseVertex);
|
||||||
GL_LOADFN(glDeleteVertexArrays);
|
GL_LOADFN(gl_EnableVertexAttribArray, glEnableVertexAttribArray);
|
||||||
GL_LOADFN(glDetachShader);
|
GL_LOADFN(gl_FramebufferRenderbuffer, glFramebufferRenderbuffer);
|
||||||
GL_LOADFN(glDrawBuffers);
|
GL_LOADFN(gl_FramebufferTexture2D, glFramebufferTexture2D);
|
||||||
GL_LOADFN(glDrawElementsBaseVertex);
|
GL_LOADFN(gl_GenBuffers, glGenBuffers);
|
||||||
GL_LOADFN(glEnableVertexAttribArray);
|
GL_LOADFN(gl_GenFramebuffers, glGenFramebuffers);
|
||||||
GL_LOADFN(glFramebufferRenderbuffer);
|
GL_LOADFN(gl_GenProgramPipelines, glGenProgramPipelines);
|
||||||
GL_LOADFN(glFramebufferTexture2D);
|
GL_LOADFN(gl_GenSamplers, glGenSamplers);
|
||||||
GL_LOADFN(glGenBuffers);
|
GL_LOADFN(gl_GenVertexArrays, glGenVertexArrays);
|
||||||
GL_LOADFN(glGenFramebuffers);
|
GL_LOADFN(gl_GetBufferParameteriv, glGetBufferParameteriv);
|
||||||
GL_LOADFN(glGenProgramPipelines);
|
GL_LOADFN(gl_GetDebugMessageLogARB, glGetDebugMessageLogARB);
|
||||||
GL_LOADFN(glGenSamplers);
|
GL_LOADFN(gl_GetFragDataIndex, glGetFragDataIndex);
|
||||||
GL_LOADFN(glGenVertexArrays);
|
GL_LOADFN(gl_GetFragDataLocation, glGetFragDataLocation);
|
||||||
GL_LOADFN(glGetBufferParameteriv);
|
GL_LOADFN(gl_GetProgramInfoLog, glGetProgramInfoLog);
|
||||||
GL_LOADFN(glGetDebugMessageLogARB);
|
GL_LOADFN(gl_GetProgramiv, glGetProgramiv);
|
||||||
GL_LOADFN(glGetFragDataIndex);
|
GL_LOADFN(gl_GetShaderiv, glGetShaderiv);
|
||||||
GL_LOADFN(glGetFragDataLocation);
|
GL_LOADFN(gl_GetStringi, glGetStringi);
|
||||||
GL_LOADFN(glGetProgramInfoLog);
|
GL_LOADFN(gl_IsFramebuffer, glIsFramebuffer);
|
||||||
GL_LOADFN(glGetProgramiv);
|
GL_LOADFN(gl_LinkProgram, glLinkProgram);
|
||||||
GL_LOADFN(glGetShaderiv);
|
GL_LOADFN(gl_MapBuffer, glMapBuffer);
|
||||||
GL_LOADFN(glGetStringi);
|
GL_LOADFN(gl_MapBufferRange, glMapBufferRange);
|
||||||
GL_LOADFN(glIsFramebuffer);
|
GL_LOADFN(gl_ProgramParameteri, glProgramParameteri);
|
||||||
GL_LOADFN(glLinkProgram);
|
GL_LOADFN(gl_SamplerParameterf, glSamplerParameterf);
|
||||||
GL_LOADFN(glMapBuffer);
|
GL_LOADFN(gl_SamplerParameteri, glSamplerParameteri);
|
||||||
GL_LOADFN(glMapBufferRange);
|
GL_LOADFN(gl_ShaderSource, glShaderSource);
|
||||||
GL_LOADFN(glProgramParameteri);
|
GL_LOADFN(gl_Uniform1i, glUniform1i);
|
||||||
GL_LOADFN(glSamplerParameterf);
|
GL_LOADFN(gl_UnmapBuffer, glUnmapBuffer);
|
||||||
GL_LOADFN(glSamplerParameteri);
|
GL_LOADFN(gl_UseProgramStages, glUseProgramStages);
|
||||||
GL_LOADFN(glShaderSource);
|
GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer);
|
||||||
GL_LOADFN(glUniform1i);
|
GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer);
|
||||||
GL_LOADFN(glUnmapBuffer);
|
GL_LOADFN(gl_TexStorage2D, glTexStorage2D);
|
||||||
GL_LOADFN(glUseProgramStages);
|
|
||||||
GL_LOADFN(glVertexAttribIPointer);
|
|
||||||
GL_LOADFN(glVertexAttribPointer);
|
|
||||||
GL_LOADFN(glTexStorage2D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_gl_supported_extension() {
|
bool check_gl_supported_extension() {
|
||||||
|
@ -192,9 +184,9 @@ namespace GLLoader {
|
||||||
bool found_GL_ARB_texture_storage = 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 (glGetStringi && 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*)glGetStringi(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;
|
found_GL_ARB_separate_shader_objects = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,92 +28,89 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define GL_LOADFN(name) { \
|
#define GL_LOADFN(name, glName) { \
|
||||||
if( (*(void**)&name = (void*)wglGetProcAddress(#name)) == NULL ) { \
|
if( (*(void**)&name = (void*)wglGetProcAddress(#glName)) == NULL ) { \
|
||||||
fprintf(stderr,"Failed to find %s\n", #name); \
|
fprintf(stderr,"Failed to find %s\n", #glName); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef EGL_API
|
#ifdef EGL_API
|
||||||
#define GL_LOADFN(name) { \
|
#define GL_LOADFN(name, glName) { \
|
||||||
if( (*(void**)&name = (void*)eglGetProcAddress(#name)) == NULL ) { \
|
if( (*(void**)&name = (void*)eglGetProcAddress(#glName)) == NULL ) { \
|
||||||
fprintf(stderr,"Failed to find %s\n", #name); \
|
fprintf(stderr,"Failed to find %s\n", #glName); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define GL_LOADFN(name) { \
|
#define GL_LOADFN(name, glName) { \
|
||||||
if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#name)) == NULL ) { \
|
if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#glName)) == NULL ) { \
|
||||||
fprintf(stderr,"Failed to find %s\n", #name); \
|
fprintf(stderr,"Failed to find %s\n", #glName); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Those are provided on gl.h on linux...
|
extern PFNGLACTIVETEXTUREPROC gl_ActiveTexture;
|
||||||
#ifdef _WINDOWS
|
extern PFNGLBLENDCOLORPROC gl_BlendColor;
|
||||||
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
extern PFNGLATTACHSHADERPROC gl_AttachShader;
|
||||||
extern PFNGLBLENDCOLORPROC glBlendColor;
|
extern PFNGLBINDBUFFERPROC gl_BindBuffer;
|
||||||
#endif
|
extern PFNGLBINDBUFFERBASEPROC gl_BindBufferBase;
|
||||||
extern PFNGLATTACHSHADERPROC glAttachShader;
|
extern PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed;
|
||||||
extern PFNGLBINDBUFFERPROC glBindBuffer;
|
extern PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer;
|
||||||
extern PFNGLBINDBUFFERBASEPROC glBindBufferBase;
|
extern PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline;
|
||||||
extern PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glBindFragDataLocationIndexed;
|
extern PFNGLBINDSAMPLERPROC gl_BindSampler;
|
||||||
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
extern PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray;
|
||||||
extern PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline;
|
extern PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate;
|
||||||
extern PFNGLBINDSAMPLERPROC glBindSampler;
|
extern PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate;
|
||||||
extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
extern PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer;
|
||||||
extern PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate;
|
extern PFNGLBUFFERDATAPROC gl_BufferData;
|
||||||
extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate;
|
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus;
|
||||||
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
|
extern PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv;
|
||||||
extern PFNGLBUFFERDATAPROC glBufferData;
|
extern PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv;
|
||||||
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
extern PFNGLCOMPILESHADERPROC gl_CompileShader;
|
||||||
extern PFNGLCLEARBUFFERFVPROC glClearBufferfv;
|
extern PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV;
|
||||||
extern PFNGLCLEARBUFFERIVPROC glClearBufferiv;
|
extern PFNGLCREATEPROGRAMPROC gl_CreateProgram;
|
||||||
extern PFNGLCOMPILESHADERPROC glCompileShader;
|
extern PFNGLCREATESHADERPROC gl_CreateShader;
|
||||||
extern PFNGLCOPYIMAGESUBDATANVPROC glCopyImageSubDataNV;
|
extern PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv;
|
||||||
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
extern PFNGLDELETEBUFFERSPROC gl_DeleteBuffers;
|
||||||
extern PFNGLCREATESHADERPROC glCreateShader;
|
extern PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers;
|
||||||
extern PFNGLCREATESHADERPROGRAMVPROC glCreateShaderProgramv;
|
extern PFNGLDELETEPROGRAMPROC gl_DeleteProgram;
|
||||||
extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
extern PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines;
|
||||||
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
extern PFNGLDELETESAMPLERSPROC gl_DeleteSamplers;
|
||||||
extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
|
extern PFNGLDELETESHADERPROC gl_DeleteShader;
|
||||||
extern PFNGLDELETEPROGRAMPIPELINESPROC glDeleteProgramPipelines;
|
extern PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays;
|
||||||
extern PFNGLDELETESAMPLERSPROC glDeleteSamplers;
|
extern PFNGLDETACHSHADERPROC gl_DetachShader;
|
||||||
extern PFNGLDELETESHADERPROC glDeleteShader;
|
extern PFNGLDRAWBUFFERSPROC gl_DrawBuffers;
|
||||||
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
extern PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex;
|
||||||
extern PFNGLDETACHSHADERPROC glDetachShader;
|
extern PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray;
|
||||||
extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
|
extern PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer;
|
||||||
extern PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex;
|
extern PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D;
|
||||||
extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
extern PFNGLGENBUFFERSPROC gl_GenBuffers;
|
||||||
extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
|
extern PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers;
|
||||||
extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
extern PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines;
|
||||||
extern PFNGLGENBUFFERSPROC glGenBuffers;
|
extern PFNGLGENSAMPLERSPROC gl_GenSamplers;
|
||||||
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
extern PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays;
|
||||||
extern PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines;
|
extern PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv;
|
||||||
extern PFNGLGENSAMPLERSPROC glGenSamplers;
|
extern PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB;
|
||||||
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
extern PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex;
|
||||||
extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
|
extern PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation;
|
||||||
extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB;
|
extern PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog;
|
||||||
extern PFNGLGETFRAGDATAINDEXPROC glGetFragDataIndex;
|
extern PFNGLGETPROGRAMIVPROC gl_GetProgramiv;
|
||||||
extern PFNGLGETFRAGDATALOCATIONPROC glGetFragDataLocation;
|
extern PFNGLGETSHADERIVPROC gl_GetShaderiv;
|
||||||
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
extern PFNGLGETSTRINGIPROC gl_GetStringi;
|
||||||
extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
extern PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer;
|
||||||
extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
extern PFNGLLINKPROGRAMPROC gl_LinkProgram;
|
||||||
extern PFNGLGETSTRINGIPROC glGetStringi;
|
extern PFNGLMAPBUFFERPROC gl_MapBuffer;
|
||||||
extern PFNGLISFRAMEBUFFERPROC glIsFramebuffer;
|
extern PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange;
|
||||||
extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
extern PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri;
|
||||||
extern PFNGLMAPBUFFERPROC glMapBuffer;
|
extern PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf;
|
||||||
extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
extern PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri;
|
||||||
extern PFNGLPROGRAMPARAMETERIPROC glProgramParameteri;
|
extern PFNGLSHADERSOURCEPROC gl_ShaderSource;
|
||||||
extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf;
|
extern PFNGLUNIFORM1IPROC gl_Uniform1i;
|
||||||
extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri;
|
extern PFNGLUNMAPBUFFERPROC gl_UnmapBuffer;
|
||||||
extern PFNGLSHADERSOURCEPROC glShaderSource;
|
extern PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages;
|
||||||
extern PFNGLUNIFORM1IPROC glUniform1i;
|
extern PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer;
|
||||||
extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
extern PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer;
|
||||||
extern PFNGLUSEPROGRAMSTAGESPROC glUseProgramStages;
|
extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D;
|
||||||
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
|
|
||||||
extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
|
||||||
extern PFNGLTEXSTORAGE2DPROC glTexStorage2D;
|
|
||||||
|
|
||||||
namespace GLLoader {
|
namespace GLLoader {
|
||||||
bool check_gl_version(uint32 major, uint32 minor);
|
bool check_gl_version(uint32 major, uint32 minor);
|
||||||
|
|
|
@ -76,9 +76,9 @@ 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
|
#ifndef DISABLE_GL41_SSO
|
||||||
glDeleteProgram(m_merge_obj.ps[i]);
|
gl_DeleteProgram(m_merge_obj.ps[i]);
|
||||||
#else
|
#else
|
||||||
glDeleteShader(m_merge_obj.ps[i]);
|
gl_DeleteShader(m_merge_obj.ps[i]);
|
||||||
#endif
|
#endif
|
||||||
delete (m_merge_obj.cb);
|
delete (m_merge_obj.cb);
|
||||||
delete (m_merge_obj.bs);
|
delete (m_merge_obj.bs);
|
||||||
|
@ -86,24 +86,24 @@ GSDeviceOGL::~GSDeviceOGL()
|
||||||
// Clean m_interlace
|
// Clean m_interlace
|
||||||
for (uint32 i = 0; i < 2; i++)
|
for (uint32 i = 0; i < 2; i++)
|
||||||
#ifndef DISABLE_GL41_SSO
|
#ifndef DISABLE_GL41_SSO
|
||||||
glDeleteProgram(m_interlace.ps[i]);
|
gl_DeleteProgram(m_interlace.ps[i]);
|
||||||
#else
|
#else
|
||||||
glDeleteShader(m_interlace.ps[i]);
|
gl_DeleteShader(m_interlace.ps[i]);
|
||||||
#endif
|
#endif
|
||||||
delete (m_interlace.cb);
|
delete (m_interlace.cb);
|
||||||
|
|
||||||
// Clean m_convert
|
// Clean m_convert
|
||||||
#ifndef DISABLE_GL41_SSO
|
#ifndef DISABLE_GL41_SSO
|
||||||
glDeleteProgram(m_convert.vs);
|
gl_DeleteProgram(m_convert.vs);
|
||||||
for (uint32 i = 0; i < 2; i++)
|
for (uint32 i = 0; i < 2; i++)
|
||||||
glDeleteProgram(m_convert.ps[i]);
|
gl_DeleteProgram(m_convert.ps[i]);
|
||||||
#else
|
#else
|
||||||
glDeleteShader(m_convert.vs);
|
gl_DeleteShader(m_convert.vs);
|
||||||
for (uint i = 0; i < 2; i++)
|
for (uint i = 0; i < 2; i++)
|
||||||
glDeleteShader(m_convert.ps[i]);
|
gl_DeleteShader(m_convert.ps[i]);
|
||||||
#endif
|
#endif
|
||||||
glDeleteSamplers(1, &m_convert.ln);
|
gl_DeleteSamplers(1, &m_convert.ln);
|
||||||
glDeleteSamplers(1, &m_convert.pt);
|
gl_DeleteSamplers(1, &m_convert.pt);
|
||||||
delete m_convert.dss;
|
delete m_convert.dss;
|
||||||
delete m_convert.bs;
|
delete m_convert.bs;
|
||||||
|
|
||||||
|
@ -113,30 +113,30 @@ GSDeviceOGL::~GSDeviceOGL()
|
||||||
|
|
||||||
// Clean various opengl allocation
|
// Clean various opengl allocation
|
||||||
#ifndef DISABLE_GL41_SSO
|
#ifndef DISABLE_GL41_SSO
|
||||||
glDeleteProgramPipelines(1, &m_pipeline);
|
gl_DeleteProgramPipelines(1, &m_pipeline);
|
||||||
#endif
|
#endif
|
||||||
glDeleteFramebuffers(1, &m_fbo);
|
gl_DeleteFramebuffers(1, &m_fbo);
|
||||||
glDeleteFramebuffers(1, &m_fbo_read);
|
gl_DeleteFramebuffers(1, &m_fbo_read);
|
||||||
|
|
||||||
// Delete HW FX
|
// Delete HW FX
|
||||||
delete m_vs_cb;
|
delete m_vs_cb;
|
||||||
delete m_ps_cb;
|
delete m_ps_cb;
|
||||||
glDeleteSamplers(1, &m_rt_ss);
|
gl_DeleteSamplers(1, &m_rt_ss);
|
||||||
delete m_vb;
|
delete m_vb;
|
||||||
|
|
||||||
#ifndef DISABLE_GL41_SSO
|
#ifndef DISABLE_GL41_SSO
|
||||||
for (auto it = m_vs.begin(); it != m_vs.end() ; it++) glDeleteProgram(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++) glDeleteProgram(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++) glDeleteProgram(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++) glDeleteShader(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++) glDeleteShader(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++) glDeleteShader(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++) glDeleteProgram(it->second);
|
for (auto it = m_single_prog.begin(); it != m_single_prog.end() ; it++) gl_DeleteProgram(it->second);
|
||||||
m_single_prog.clear();
|
m_single_prog.clear();
|
||||||
#endif
|
#endif
|
||||||
for (auto it = m_ps_ss.begin(); it != m_ps_ss.end() ; it++) glDeleteSamplers(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();
|
||||||
m_ps.clear();
|
m_ps.clear();
|
||||||
|
@ -197,12 +197,12 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
||||||
// Various object
|
// Various object
|
||||||
// ****************************************************************
|
// ****************************************************************
|
||||||
#ifndef DISABLE_GL41_SSO
|
#ifndef DISABLE_GL41_SSO
|
||||||
glGenProgramPipelines(1, &m_pipeline);
|
gl_GenProgramPipelines(1, &m_pipeline);
|
||||||
glBindProgramPipeline(m_pipeline);
|
gl_BindProgramPipeline(m_pipeline);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glGenFramebuffers(1, &m_fbo);
|
gl_GenFramebuffers(1, &m_fbo);
|
||||||
glGenFramebuffers(1, &m_fbo_read);
|
gl_GenFramebuffers(1, &m_fbo_read);
|
||||||
|
|
||||||
// ****************************************************************
|
// ****************************************************************
|
||||||
// Vertex buffer state
|
// Vertex buffer state
|
||||||
|
@ -240,35 +240,35 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
||||||
|
|
||||||
hr = m_dev->CreateBlendState(&bsd, &m_convert.bs);
|
hr = m_dev->CreateBlendState(&bsd, &m_convert.bs);
|
||||||
#endif
|
#endif
|
||||||
glGenSamplers(1, &m_convert.ln);
|
gl_GenSamplers(1, &m_convert.ln);
|
||||||
glSamplerParameteri(m_convert.ln, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glSamplerParameteri(m_convert.ln, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glSamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||||
glSamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glSamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
// FIXME which value for GL_TEXTURE_MIN_LOD
|
// FIXME which value for GL_TEXTURE_MIN_LOD
|
||||||
glSamplerParameterf(m_convert.ln, GL_TEXTURE_MAX_LOD, FLT_MAX);
|
gl_SamplerParameterf(m_convert.ln, GL_TEXTURE_MAX_LOD, FLT_MAX);
|
||||||
// FIXME: seems there is 2 possibility in opengl
|
// FIXME: seems there is 2 possibility in opengl
|
||||||
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||||
// glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
// gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||||
glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||||
glSamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
gl_SamplerParameteri(m_convert.ln, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
||||||
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
|
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
|
||||||
|
|
||||||
|
|
||||||
glGenSamplers(1, &m_convert.pt);
|
gl_GenSamplers(1, &m_convert.pt);
|
||||||
glSamplerParameteri(m_convert.pt, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glSamplerParameteri(m_convert.pt, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glSamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||||
glSamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glSamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
// FIXME which value for GL_TEXTURE_MIN_LOD
|
// FIXME which value for GL_TEXTURE_MIN_LOD
|
||||||
glSamplerParameterf(m_convert.pt, GL_TEXTURE_MAX_LOD, FLT_MAX);
|
gl_SamplerParameterf(m_convert.pt, GL_TEXTURE_MAX_LOD, FLT_MAX);
|
||||||
// FIXME: seems there is 2 possibility in opengl
|
// FIXME: seems there is 2 possibility in opengl
|
||||||
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||||
// glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
// gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||||
glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||||
glSamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
gl_SamplerParameteri(m_convert.pt, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
||||||
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
|
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
|
||||||
|
|
||||||
m_convert.dss = new GSDepthStencilOGL();
|
m_convert.dss = new GSDepthStencilOGL();
|
||||||
|
@ -530,7 +530,7 @@ void GSDeviceOGL::DebugBB()
|
||||||
|
|
||||||
static_cast<GSTextureOGL*>(rt)->Attach(GL_COLOR_ATTACHMENT0);
|
static_cast<GSTextureOGL*>(rt)->Attach(GL_COLOR_ATTACHMENT0);
|
||||||
|
|
||||||
glBlitFramebuffer(0, 0, size.x, size.y,
|
gl_BlitFramebuffer(0, 0, size.x, size.y,
|
||||||
0, 0, size.x, size.y,
|
0, 0, size.x, size.y,
|
||||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
|
||||||
|
@ -599,21 +599,21 @@ static void set_uniform_buffer_binding(GLuint prog, GLchar* name, GLuint binding
|
||||||
#ifdef DISABLE_GL41_SSO
|
#ifdef DISABLE_GL41_SSO
|
||||||
GLuint GSDeviceOGL::link_prog()
|
GLuint GSDeviceOGL::link_prog()
|
||||||
{
|
{
|
||||||
GLuint single_prog = glCreateProgram();
|
GLuint single_prog = gl_CreateProgram();
|
||||||
if (m_state.vs) glAttachShader(single_prog, m_state.vs);
|
if (m_state.vs) gl_AttachShader(single_prog, m_state.vs);
|
||||||
if (m_state.ps) glAttachShader(single_prog, m_state.ps);
|
if (m_state.ps) gl_AttachShader(single_prog, m_state.ps);
|
||||||
if (m_state.gs) glAttachShader(single_prog, m_state.gs);
|
if (m_state.gs) gl_AttachShader(single_prog, m_state.gs);
|
||||||
|
|
||||||
glLinkProgram(single_prog);
|
gl_LinkProgram(single_prog);
|
||||||
|
|
||||||
GLint status;
|
GLint status;
|
||||||
glGetProgramiv(single_prog, GL_LINK_STATUS, &status);
|
gl_GetProgramiv(single_prog, GL_LINK_STATUS, &status);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
GLint log_length = 0;
|
GLint log_length = 0;
|
||||||
glGetProgramiv(single_prog, GL_INFO_LOG_LENGTH, &log_length);
|
gl_GetProgramiv(single_prog, GL_INFO_LOG_LENGTH, &log_length);
|
||||||
if (log_length > 0) {
|
if (log_length > 0) {
|
||||||
char* log = new char[log_length];
|
char* log = new char[log_length];
|
||||||
glGetProgramInfoLog(single_prog, log_length, NULL, log);
|
gl_GetProgramInfoLog(single_prog, log_length, NULL, log);
|
||||||
fprintf(stderr, "%s", log);
|
fprintf(stderr, "%s", log);
|
||||||
delete[] log;
|
delete[] log;
|
||||||
}
|
}
|
||||||
|
@ -621,9 +621,9 @@ GLuint GSDeviceOGL::link_prog()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (m_state.vs) glDetachShader(single_prog, m_state.vs);
|
if (m_state.vs) gl_DetachShader(single_prog, m_state.vs);
|
||||||
if (m_state.ps) glDetachShader(single_prog, m_state.ps);
|
if (m_state.ps) gl_DetachShader(single_prog, m_state.ps);
|
||||||
if (m_state.gs) glDetachShader(single_prog, m_state.gs);
|
if (m_state.gs) gl_DetachShader(single_prog, m_state.gs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return single_prog;
|
return single_prog;
|
||||||
|
@ -700,8 +700,8 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c)
|
||||||
if (static_cast<GSTextureOGL*>(t)->IsBackbuffer()) {
|
if (static_cast<GSTextureOGL*>(t)->IsBackbuffer()) {
|
||||||
// FIXME I really not sure
|
// FIXME I really not sure
|
||||||
OMSetFBO(0);
|
OMSetFBO(0);
|
||||||
//glClearBufferfv(GL_COLOR, GL_LEFT, c.v);
|
//gl_ClearBufferfv(GL_COLOR, GL_LEFT, c.v);
|
||||||
glClearBufferfv(GL_COLOR, 0, c.v);
|
gl_ClearBufferfv(GL_COLOR, 0, c.v);
|
||||||
// code for the old interface
|
// code for the old interface
|
||||||
// glClearColor(c.x, c.y, c.z, c.w);
|
// glClearColor(c.x, c.y, c.z, c.w);
|
||||||
// glClear(GL_COLOR_BUFFER_BIT);
|
// glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
@ -710,7 +710,7 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c)
|
||||||
// I would like to avoid FBO for a basic clean operation
|
// I would like to avoid FBO for a basic clean operation
|
||||||
OMSetFBO(m_fbo);
|
OMSetFBO(m_fbo);
|
||||||
static_cast<GSTextureOGL*>(t)->Attach(GL_COLOR_ATTACHMENT0);
|
static_cast<GSTextureOGL*>(t)->Attach(GL_COLOR_ATTACHMENT0);
|
||||||
glClearBufferfv(GL_COLOR, 0, c.v);
|
gl_ClearBufferfv(GL_COLOR, 0, c.v);
|
||||||
}
|
}
|
||||||
OMSetFBO(fbo_old);
|
OMSetFBO(fbo_old);
|
||||||
}
|
}
|
||||||
|
@ -733,10 +733,10 @@ void GSDeviceOGL::ClearDepth(GSTexture* t, float c)
|
||||||
// could be smaller than the texture and we really want to clean all pixels.
|
// could be smaller than the texture and we really want to clean all pixels.
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
if (m_state.dss != NULL && m_state.dss->IsMaskEnable()) {
|
if (m_state.dss != NULL && m_state.dss->IsMaskEnable()) {
|
||||||
glClearBufferfv(GL_DEPTH, 0, &c);
|
gl_ClearBufferfv(GL_DEPTH, 0, &c);
|
||||||
} else {
|
} else {
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
glClearBufferfv(GL_DEPTH, 0, &c);
|
gl_ClearBufferfv(GL_DEPTH, 0, &c);
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
}
|
}
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
@ -752,7 +752,7 @@ void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c)
|
||||||
static_cast<GSTextureOGL*>(t)->Attach(GL_DEPTH_STENCIL_ATTACHMENT);
|
static_cast<GSTextureOGL*>(t)->Attach(GL_DEPTH_STENCIL_ATTACHMENT);
|
||||||
GLint color = c;
|
GLint color = c;
|
||||||
// FIXME can you clean depth and stencil separately
|
// FIXME can you clean depth and stencil separately
|
||||||
glClearBufferiv(GL_STENCIL, 0, &color);
|
gl_ClearBufferiv(GL_STENCIL, 0, &color);
|
||||||
OMSetFBO(fbo_old);
|
OMSetFBO(fbo_old);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,7 +841,7 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r)
|
||||||
// uint32 srcName, enum srcTarget, int srcLevel, int srcX, int srcY, int srcZ,
|
// uint32 srcName, enum srcTarget, int srcLevel, int srcX, int srcY, int srcZ,
|
||||||
// uint32 dstName, enum dstTarget, int dstLevel, int dstX, int dstY, int dstZ,
|
// uint32 dstName, enum dstTarget, int dstLevel, int dstX, int dstY, int dstZ,
|
||||||
// sizei width, sizei height, sizei depth);
|
// sizei width, sizei height, sizei depth);
|
||||||
glCopyImageSubDataNV( static_cast<GSTextureOGL*>(st)->GetID(), static_cast<GSTextureOGL*>(st)->GetTarget(),
|
gl_CopyImageSubDataNV( static_cast<GSTextureOGL*>(st)->GetID(), static_cast<GSTextureOGL*>(st)->GetTarget(),
|
||||||
0, r.x, r.y, 0,
|
0, r.x, r.y, 0,
|
||||||
static_cast<GSTextureOGL*>(dt)->GetID(), static_cast<GSTextureOGL*>(dt)->GetTarget(),
|
static_cast<GSTextureOGL*>(dt)->GetID(), static_cast<GSTextureOGL*>(dt)->GetTarget(),
|
||||||
0, r.x, r.y, 0,
|
0, r.x, r.y, 0,
|
||||||
|
@ -1140,7 +1140,7 @@ void GSDeviceOGL::VSSetShader(GLuint vs)
|
||||||
{
|
{
|
||||||
m_state.vs = vs;
|
m_state.vs = vs;
|
||||||
#ifndef DISABLE_GL41_SSO
|
#ifndef DISABLE_GL41_SSO
|
||||||
glUseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs);
|
gl_UseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, vs);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1151,7 +1151,7 @@ void GSDeviceOGL::GSSetShader(GLuint gs)
|
||||||
{
|
{
|
||||||
m_state.gs = gs;
|
m_state.gs = gs;
|
||||||
#ifndef DISABLE_GL41_SSO
|
#ifndef DISABLE_GL41_SSO
|
||||||
glUseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs);
|
gl_UseProgramStages(m_pipeline, GL_GEOMETRY_SHADER_BIT, gs);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1194,24 +1194,24 @@ void GSDeviceOGL::PSSetShader(GLuint ps)
|
||||||
{
|
{
|
||||||
m_state.ps = ps;
|
m_state.ps = ps;
|
||||||
#ifndef DISABLE_GL41_SSO
|
#ifndef DISABLE_GL41_SSO
|
||||||
glUseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps);
|
gl_UseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, ps);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sampler and texture must be set at the same time
|
// Sampler and texture must be set at the same time
|
||||||
// 1/ select the texture unit
|
// 1/ select the texture unit
|
||||||
// glActiveTexture(GL_TEXTURE0 + 1);
|
// gl_ActiveTexture(GL_TEXTURE0 + 1);
|
||||||
// 2/ bind the texture
|
// 2/ bind the texture
|
||||||
// glBindTexture(GL_TEXTURE_2D , brickTexture);
|
// glBindTexture(GL_TEXTURE_2D , brickTexture);
|
||||||
// 3/ sets the texture sampler in GLSL (could be useless with layout stuff)
|
// 3/ sets the texture sampler in GLSL (could be useless with layout stuff)
|
||||||
// glUniform1i(brickSamplerId , 1);
|
// gl_Uniform1i(brickSamplerId , 1);
|
||||||
// 4/ set the sampler state
|
// 4/ set the sampler state
|
||||||
// glBindSampler(1 , sampler);
|
// gl_BindSampler(1 , sampler);
|
||||||
if (m_srv_changed || m_ss_changed) {
|
if (m_srv_changed || m_ss_changed) {
|
||||||
for (uint32 i=0 ; i < 1; i++) {
|
for (uint32 i=0 ; i < 1; i++) {
|
||||||
if (m_state.ps_srv[i] != NULL) {
|
if (m_state.ps_srv[i] != NULL) {
|
||||||
m_state.ps_srv[i]->EnableUnit(i);
|
m_state.ps_srv[i]->EnableUnit(i);
|
||||||
glBindSampler(i, m_state.ps_ss[i]);
|
gl_BindSampler(i, m_state.ps_ss[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1221,9 +1221,9 @@ void GSDeviceOGL::OMSetFBO(GLuint fbo, GLenum buffer)
|
||||||
{
|
{
|
||||||
if (m_state.fbo != fbo) {
|
if (m_state.fbo != fbo) {
|
||||||
m_state.fbo = fbo;
|
m_state.fbo = fbo;
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
gl_BindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||||
// FIXME DEBUG
|
// FIXME DEBUG
|
||||||
//if (fbo) fprintf(stderr, "FB status %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER));
|
//if (fbo) fprintf(stderr, "FB status %x\n", gl_CheckFramebufferStatus(GL_FRAMEBUFFER));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_state.draw != buffer) {
|
if (m_state.draw != buffer) {
|
||||||
|
@ -1396,14 +1396,14 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
|
||||||
// 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 = glCreateShaderProgramv(type, 1, &ShaderSource[0]);
|
*program = gl_CreateShaderProgramv(type, 1, &ShaderSource[0]);
|
||||||
#else
|
#else
|
||||||
*program = glCreateShaderProgramv(type, 2, sources_array);
|
*program = gl_CreateShaderProgramv(type, 2, sources_array);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
*program = glCreateShader(type);
|
*program = gl_CreateShader(type);
|
||||||
glShaderSource(*program, 2, sources_array, NULL);
|
gl_ShaderSource(*program, 2, sources_array, NULL);
|
||||||
glCompileShader(*program);
|
gl_CompileShader(*program);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
free(source_str);
|
free(source_str);
|
||||||
|
@ -1417,14 +1417,14 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
|
||||||
|
|
||||||
GLint log_length = 0;
|
GLint log_length = 0;
|
||||||
#ifndef DISABLE_GL41_SSO
|
#ifndef DISABLE_GL41_SSO
|
||||||
glGetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length);
|
gl_GetProgramiv(*program, GL_INFO_LOG_LENGTH, &log_length);
|
||||||
#else
|
#else
|
||||||
glGetShaderiv(*program, GL_INFO_LOG_LENGTH, &log_length);
|
gl_GetShaderiv(*program, GL_INFO_LOG_LENGTH, &log_length);
|
||||||
#endif
|
#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
|
#ifndef DISABLE_GL41_SSO
|
||||||
glGetProgramInfoLog(*program, log_length, NULL, log);
|
gl_GetProgramInfoLog(*program, log_length, NULL, log);
|
||||||
#else
|
#else
|
||||||
glGetShaderInfoLog(*program, log_length, NULL, log);
|
glGetShaderInfoLog(*program, log_length, NULL, log);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1446,7 +1446,7 @@ void GSDeviceOGL::CheckDebugLog()
|
||||||
int* lengths = new int[count];
|
int* lengths = new int[count];
|
||||||
char* messageLog = new char[bufsize];
|
char* messageLog = new char[bufsize];
|
||||||
|
|
||||||
unsigned int retVal = glGetDebugMessageLogARB(count, bufsize, sources, types, ids, severities, lengths, messageLog);
|
unsigned int retVal = gl_GetDebugMessageLogARB(count, bufsize, sources, types, ids, severities, lengths, messageLog);
|
||||||
|
|
||||||
if(retVal > 0)
|
if(retVal > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,11 +105,11 @@ public:
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
if (HasConstantFactor()) {
|
if (HasConstantFactor()) {
|
||||||
debug_factor = factor;
|
debug_factor = factor;
|
||||||
glBlendColor(factor, factor, factor, 0);
|
gl_BlendColor(factor, factor, factor, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBlendEquationSeparate(m_equation_RGB, m_equation_ALPHA);
|
gl_BlendEquationSeparate(m_equation_RGB, m_equation_ALPHA);
|
||||||
glBlendFuncSeparate(m_func_sRGB, m_func_dRGB, m_func_sALPHA, m_func_dALPHA);
|
gl_BlendFuncSeparate(m_func_sRGB, m_func_dRGB, m_func_sALPHA, m_func_dALPHA);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,22 +33,22 @@ void GSDeviceOGL::CreateTextureFX()
|
||||||
m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer));
|
m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer));
|
||||||
m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer));
|
m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer));
|
||||||
|
|
||||||
glGenSamplers(1, &m_rt_ss);
|
gl_GenSamplers(1, &m_rt_ss);
|
||||||
// FIXME, seem to have no difference between sampler !!!
|
// FIXME, seem to have no difference between sampler !!!
|
||||||
m_palette_ss = m_rt_ss;
|
m_palette_ss = m_rt_ss;
|
||||||
|
|
||||||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
// FIXME which value for GL_TEXTURE_MIN_LOD
|
// FIXME which value for GL_TEXTURE_MIN_LOD
|
||||||
glSamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX);
|
gl_SamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX);
|
||||||
// FIXME: seems there is 2 possibility in opengl
|
// FIXME: seems there is 2 possibility in opengl
|
||||||
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||||
// glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
// gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
||||||
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
|
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
|
||||||
|
|
||||||
GSInputLayoutOGL vert_format[] =
|
GSInputLayoutOGL vert_format[] =
|
||||||
|
@ -200,35 +200,35 @@ void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerS
|
||||||
// *************************************************************
|
// *************************************************************
|
||||||
// Static
|
// Static
|
||||||
// *************************************************************
|
// *************************************************************
|
||||||
glGenSamplers(1, &ss0);
|
gl_GenSamplers(1, &ss0);
|
||||||
if (ssel.ltf) {
|
if (ssel.ltf) {
|
||||||
glSamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
gl_SamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glSamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
gl_SamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
} else {
|
} else {
|
||||||
glSamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
gl_SamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glSamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
gl_SamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME ensure U -> S, V -> T and W->R
|
// FIXME ensure U -> S, V -> T and W->R
|
||||||
if (ssel.tau)
|
if (ssel.tau)
|
||||||
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
else
|
else
|
||||||
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
if (ssel.tav)
|
if (ssel.tav)
|
||||||
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
else
|
else
|
||||||
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
gl_SamplerParameteri(ss0, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
// FIXME which value for GL_TEXTURE_MIN_LOD
|
// FIXME which value for GL_TEXTURE_MIN_LOD
|
||||||
glSamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX);
|
gl_SamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX);
|
||||||
// FIXME: seems there is 2 possibility in opengl
|
// FIXME: seems there is 2 possibility in opengl
|
||||||
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||||
// glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
// gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
gl_SamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
||||||
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
|
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
|
||||||
|
|
||||||
m_ps_ss[ssel] = ss0;
|
m_ps_ss[ssel] = ss0;
|
||||||
|
|
|
@ -33,19 +33,19 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
|
||||||
// Opengl world
|
// Opengl world
|
||||||
|
|
||||||
// Render work in parallal with framebuffer object (FBO) http://www.opengl.org/wiki/Framebuffer_Objects
|
// Render work in parallal with framebuffer object (FBO) http://www.opengl.org/wiki/Framebuffer_Objects
|
||||||
// render are attached to FBO through : glFramebufferRenderbuffer. You can query the number of colorattachement with GL_MAX_COLOR_ATTACHMENTS
|
// render are attached to FBO through : gl_FramebufferRenderbuffer. You can query the number of colorattachement with GL_MAX_COLOR_ATTACHMENTS
|
||||||
// FBO : constructor -> glGenFramebuffers, glDeleteFramebuffers
|
// FBO : constructor -> gl_GenFramebuffers, gl_DeleteFramebuffers
|
||||||
// binding -> glBindFramebuffer (target can be read/write/both)
|
// binding -> gl_BindFramebuffer (target can be read/write/both)
|
||||||
// blit -> glBlitFramebuffer (read FB to draw FB)
|
// blit -> gl_BlitFramebuffer (read FB to draw FB)
|
||||||
// info -> glIsFramebuffer, glGetFramebufferAttachmentParameter, glCheckFramebufferStatus
|
// info -> gl_IsFramebuffer, glGetFramebufferAttachmentParameter, gl_CheckFramebufferStatus
|
||||||
//
|
//
|
||||||
// There are two types of framebuffer-attachable images; texture images and renderbuffer images.
|
// There are two types of framebuffer-attachable images; texture images and renderbuffer images.
|
||||||
// If an image of a texture object is attached to a framebuffer, OpenGL performs "render to texture".
|
// If an image of a texture object is attached to a framebuffer, OpenGL performs "render to texture".
|
||||||
// And if an image of a renderbuffer object is attached to a framebuffer, then OpenGL performs "offscreen rendering".
|
// And if an image of a renderbuffer object is attached to a framebuffer, then OpenGL performs "offscreen rendering".
|
||||||
// Blitting:
|
// Blitting:
|
||||||
// glDrawBuffers
|
// gl_DrawBuffers
|
||||||
// glReadBuffer
|
// glReadBuffer
|
||||||
// glBlitFramebuffer
|
// gl_BlitFramebuffer
|
||||||
|
|
||||||
// *************************************************************
|
// *************************************************************
|
||||||
// m_size.x = w;
|
// m_size.x = w;
|
||||||
|
@ -62,7 +62,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case GSTexture::Offscreen:
|
case GSTexture::Offscreen:
|
||||||
//FIXME I not sure we need a pixel buffer object. It seems more a texture
|
//FIXME I not sure we need a pixel buffer object. It seems more a texture
|
||||||
// glGenBuffers(1, &m_texture_id);
|
// gl_GenBuffers(1, &m_texture_id);
|
||||||
// m_texture_target = GL_PIXEL_UNPACK_BUFFER;
|
// m_texture_target = GL_PIXEL_UNPACK_BUFFER;
|
||||||
// ASSERT(0);
|
// ASSERT(0);
|
||||||
// Note there is also a buffer texture!!!
|
// Note there is also a buffer texture!!!
|
||||||
|
@ -84,7 +84,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Extra buffer to handle various pixel transfer
|
// Extra buffer to handle various pixel transfer
|
||||||
glGenBuffers(1, &m_pbo_id);
|
gl_GenBuffers(1, &m_pbo_id);
|
||||||
|
|
||||||
uint32 msaa_level;
|
uint32 msaa_level;
|
||||||
if (m_msaa) {
|
if (m_msaa) {
|
||||||
|
@ -105,9 +105,9 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
|
||||||
ASSERT(0); // TODO Later
|
ASSERT(0); // TODO Later
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id);
|
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id);
|
||||||
glBufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW);
|
gl_BufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW);
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||||
ASSERT(!m_msaa);
|
ASSERT(!m_msaa);
|
||||||
|
|
||||||
case GSTexture::DepthStencil:
|
case GSTexture::DepthStencil:
|
||||||
|
@ -121,9 +121,9 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
|
||||||
if (m_msaa) {
|
if (m_msaa) {
|
||||||
ASSERT(m_texture_target == GL_TEXTURE_2D_MULTISAMPLE);
|
ASSERT(m_texture_target == GL_TEXTURE_2D_MULTISAMPLE);
|
||||||
// Require a recent GLEW and GL4.3
|
// Require a recent GLEW and GL4.3
|
||||||
//glTexStorage2DMultisample(m_texture_target, msaa_level, m_format, m_size.x, m_size.y, false);
|
//gl_TexStorage2DMultisample(m_texture_target, msaa_level, m_format, m_size.x, m_size.y, false);
|
||||||
} else {
|
} else {
|
||||||
glTexStorage2D(m_texture_target, 1, m_format, m_size.x, m_size.y);
|
gl_TexStorage2D(m_texture_target, 1, m_format, m_size.x, m_size.y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
|
@ -132,16 +132,16 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
|
||||||
|
|
||||||
GSTextureOGL::~GSTextureOGL()
|
GSTextureOGL::~GSTextureOGL()
|
||||||
{
|
{
|
||||||
glDeleteBuffers(1, &m_pbo_id);
|
gl_DeleteBuffers(1, &m_pbo_id);
|
||||||
glDeleteTextures(1, &m_texture_id);
|
glDeleteTextures(1, &m_texture_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSTextureOGL::Attach(GLenum attachment)
|
void GSTextureOGL::Attach(GLenum attachment)
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "format %d,%x\n", m_type, m_format);
|
//fprintf(stderr, "format %d,%x\n", m_type, m_format);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0);
|
gl_FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0);
|
||||||
// FIXME DEBUG
|
// FIXME DEBUG
|
||||||
//fprintf(stderr, "FB status %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER));
|
//fprintf(stderr, "FB status %x\n", gl_CheckFramebufferStatus(GL_FRAMEBUFFER));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
|
bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
|
||||||
|
@ -206,7 +206,7 @@ void GSTextureOGL::EnableUnit(uint32 unit)
|
||||||
// For the moment SW renderer only use 1 so don't bother
|
// For the moment SW renderer only use 1 so don't bother
|
||||||
if (g_state_texture_unit != unit) {
|
if (g_state_texture_unit != unit) {
|
||||||
g_state_texture_unit = unit;
|
g_state_texture_unit = unit;
|
||||||
glActiveTexture(GL_TEXTURE0 + unit);
|
gl_ActiveTexture(GL_TEXTURE0 + unit);
|
||||||
// When you change the texture unit, texture must be rebinded
|
// When you change the texture unit, texture must be rebinded
|
||||||
g_state_texture_id = m_texture_id;
|
g_state_texture_id = m_texture_id;
|
||||||
glBindTexture(m_texture_target, m_texture_id);
|
glBindTexture(m_texture_target, m_texture_id);
|
||||||
|
@ -224,18 +224,18 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r)
|
||||||
// Set m.pitch <- size of a row
|
// Set m.pitch <- size of a row
|
||||||
// I think in opengl we need to copy back the data to the RAM: glReadPixels — read a block of pixels from the frame buffer
|
// I think in opengl we need to copy back the data to the RAM: glReadPixels — read a block of pixels from the frame buffer
|
||||||
//
|
//
|
||||||
// glMapBuffer — map a buffer object's data store
|
// gl_MapBuffer — map a buffer object's data store
|
||||||
// Can be used on GL_PIXEL_UNPACK_BUFFER or GL_TEXTURE_BUFFER
|
// Can be used on GL_PIXEL_UNPACK_BUFFER or GL_TEXTURE_BUFFER
|
||||||
if (m_type == GSTexture::Offscreen) {
|
if (m_type == GSTexture::Offscreen) {
|
||||||
// Bind the texture to the read framebuffer to avoid any disturbance
|
// Bind the texture to the read framebuffer to avoid any disturbance
|
||||||
EnableUnit(0);
|
EnableUnit(0);
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
|
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0);
|
gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0);
|
||||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||||
|
|
||||||
// FIXME It might be possible to only read a subrange of the texture based on r object
|
// FIXME It might be possible to only read a subrange of the texture based on r object
|
||||||
// Load the PBO with the data
|
// Load the PBO with the data
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id);
|
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id);
|
||||||
if (m_format == GL_RGBA8) {
|
if (m_format == GL_RGBA8) {
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||||
glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||||
|
@ -249,17 +249,17 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r)
|
||||||
fprintf(stderr, "wrong texture pixel format :%x\n", m_format);
|
fprintf(stderr, "wrong texture pixel format :%x\n", m_format);
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
// Give access from the CPU
|
// Give access from the CPU
|
||||||
m.bits = (uint8*) glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, GL_MAP_READ_BIT);
|
m.bits = (uint8*) gl_MapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, GL_MAP_READ_BIT);
|
||||||
m.pitch = m_size.x;
|
m.pitch = m_size.x;
|
||||||
|
|
||||||
if ( m.bits ) {
|
if ( m.bits ) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "bad mapping of the pbo\n");
|
fprintf(stderr, "bad mapping of the pbo\n");
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,8 +286,8 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r)
|
||||||
void GSTextureOGL::Unmap()
|
void GSTextureOGL::Unmap()
|
||||||
{
|
{
|
||||||
if (m_type == GSTexture::Offscreen) {
|
if (m_type == GSTexture::Offscreen) {
|
||||||
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
gl_UnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,22 +405,22 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
|
||||||
// for us
|
// for us
|
||||||
if (IsBackbuffer()) {
|
if (IsBackbuffer()) {
|
||||||
//glReadBuffer(GL_BACK);
|
//glReadBuffer(GL_BACK);
|
||||||
//glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
//gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||||
glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||||
} else if(IsDss()) {
|
} else if(IsDss()) {
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
|
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
|
||||||
|
|
||||||
//EnableUnit(0);
|
//EnableUnit(0);
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_texture_target, m_texture_id, 0);
|
gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_texture_target, m_texture_id, 0);
|
||||||
glReadPixels(0, 0, m_size.x, m_size.y, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image);
|
glReadPixels(0, 0, m_size.x, m_size.y, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image);
|
||||||
|
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||||
} else {
|
} else {
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
|
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
|
||||||
|
|
||||||
EnableUnit(0);
|
EnableUnit(0);
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0);
|
gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0);
|
||||||
|
|
||||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||||
if (m_format == GL_RGBA8)
|
if (m_format == GL_RGBA8)
|
||||||
|
@ -438,7 +438,7 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
|
||||||
status = false;
|
status = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status) Save(fn, image, pitch);
|
if (status) Save(fn, image, pitch);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
, size(size)
|
, size(size)
|
||||||
,target(GL_UNIFORM_BUFFER)
|
,target(GL_UNIFORM_BUFFER)
|
||||||
{
|
{
|
||||||
glGenBuffers(1, &buffer);
|
gl_GenBuffers(1, &buffer);
|
||||||
bind();
|
bind();
|
||||||
allocate();
|
allocate();
|
||||||
attach();
|
attach();
|
||||||
|
@ -40,28 +40,28 @@ public:
|
||||||
|
|
||||||
void bind()
|
void bind()
|
||||||
{
|
{
|
||||||
glBindBuffer(target, buffer);
|
gl_BindBuffer(target, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void allocate()
|
void allocate()
|
||||||
{
|
{
|
||||||
glBufferData(target, size, NULL, GL_STREAM_DRAW);
|
gl_BufferData(target, size, NULL, GL_STREAM_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void attach()
|
void attach()
|
||||||
{
|
{
|
||||||
glBindBufferBase(target, index, buffer);
|
gl_BindBufferBase(target, index, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void upload(const void* src)
|
void upload(const void* src)
|
||||||
{
|
{
|
||||||
uint32 flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT;
|
uint32 flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT;
|
||||||
uint8* dst = (uint8*) glMapBufferRange(target, 0, size, flags);
|
uint8* dst = (uint8*) gl_MapBufferRange(target, 0, size, flags);
|
||||||
memcpy(dst, src, size);
|
memcpy(dst, src, size);
|
||||||
glUnmapBuffer(target);
|
gl_UnmapBuffer(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
~GSUniformBufferOGL() {
|
~GSUniformBufferOGL() {
|
||||||
glDeleteBuffers(1, &buffer);
|
gl_DeleteBuffers(1, &buffer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,12 +47,12 @@ class GSBufferOGL {
|
||||||
, m_limit(0)
|
, m_limit(0)
|
||||||
, m_target(target)
|
, m_target(target)
|
||||||
{
|
{
|
||||||
glGenBuffers(1, &m_buffer);
|
gl_GenBuffers(1, &m_buffer);
|
||||||
// Opengl works best with 1-4MB buffer.
|
// Opengl works best with 1-4MB buffer.
|
||||||
m_default_size = 2 * 1024 * 1024 / m_stride;
|
m_default_size = 2 * 1024 * 1024 / m_stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
~GSBufferOGL() { glDeleteBuffers(1, &m_buffer); }
|
~GSBufferOGL() { gl_DeleteBuffers(1, &m_buffer); }
|
||||||
|
|
||||||
void allocate() { allocate(m_default_size); }
|
void allocate() { allocate(m_default_size); }
|
||||||
|
|
||||||
|
@ -60,12 +60,12 @@ class GSBufferOGL {
|
||||||
{
|
{
|
||||||
m_start = 0;
|
m_start = 0;
|
||||||
m_limit = new_limit;
|
m_limit = new_limit;
|
||||||
glBufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW);
|
gl_BufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bind()
|
void bind()
|
||||||
{
|
{
|
||||||
glBindBuffer(m_target, m_buffer);
|
gl_BindBuffer(m_target, m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void upload(const void* src, uint32 count)
|
void upload(const void* src, uint32 count)
|
||||||
|
@ -83,7 +83,7 @@ class GSBufferOGL {
|
||||||
bool Map(void** pointer, uint32 count ) {
|
bool Map(void** pointer, uint32 count ) {
|
||||||
#ifdef ENABLE_OGL_DEBUG
|
#ifdef ENABLE_OGL_DEBUG
|
||||||
GLint b_size = -1;
|
GLint b_size = -1;
|
||||||
glGetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size);
|
gl_GetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size);
|
||||||
|
|
||||||
if (b_size <= 0) return false;
|
if (b_size <= 0) return false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -112,7 +112,7 @@ class GSBufferOGL {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload the data to the buffer
|
// Upload the data to the buffer
|
||||||
*pointer = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags);
|
*pointer = (uint8*) gl_MapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags);
|
||||||
//fprintf(stderr, "Map %x from %d to %d\n", *pointer, m_start, m_start+m_count);
|
//fprintf(stderr, "Map %x from %d to %d\n", *pointer, m_start, m_start+m_count);
|
||||||
#ifdef ENABLE_OGL_DEBUG
|
#ifdef ENABLE_OGL_DEBUG
|
||||||
if (*pointer == NULL) {
|
if (*pointer == NULL) {
|
||||||
|
@ -123,7 +123,7 @@ class GSBufferOGL {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmap() { glUnmapBuffer(m_target); }
|
void Unmap() { gl_UnmapBuffer(m_target); }
|
||||||
|
|
||||||
void EndScene()
|
void EndScene()
|
||||||
{
|
{
|
||||||
|
@ -138,12 +138,12 @@ class GSBufferOGL {
|
||||||
|
|
||||||
void Draw(GLenum mode, GLint basevertex)
|
void Draw(GLenum mode, GLint basevertex)
|
||||||
{
|
{
|
||||||
glDrawElementsBaseVertex(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride), basevertex);
|
gl_DrawElementsBaseVertex(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride), basevertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw(GLenum mode, GLint basevertex, int offset, int count)
|
void Draw(GLenum mode, GLint basevertex, int offset, int count)
|
||||||
{
|
{
|
||||||
glDrawElementsBaseVertex(mode, count, GL_UNSIGNED_INT, (void*)((m_start + offset) * m_stride), basevertex);
|
gl_DrawElementsBaseVertex(mode, count, GL_UNSIGNED_INT, (void*)((m_start + offset) * m_stride), basevertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GetStart() { return m_start; }
|
size_t GetStart() { return m_start; }
|
||||||
|
@ -165,7 +165,7 @@ class GSVertexBufferStateOGL {
|
||||||
public:
|
public:
|
||||||
GSVertexBufferStateOGL(size_t stride, GSInputLayoutOGL* layout, uint32 layout_nbr)
|
GSVertexBufferStateOGL(size_t stride, GSInputLayoutOGL* layout, uint32 layout_nbr)
|
||||||
{
|
{
|
||||||
glGenVertexArrays(1, &m_va);
|
gl_GenVertexArrays(1, &m_va);
|
||||||
|
|
||||||
m_vb = new GSBufferOGL(GL_ARRAY_BUFFER, stride);
|
m_vb = new GSBufferOGL(GL_ARRAY_BUFFER, stride);
|
||||||
m_ib = new GSBufferOGL(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32));
|
m_ib = new GSBufferOGL(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32));
|
||||||
|
@ -181,7 +181,7 @@ public:
|
||||||
|
|
||||||
void bind()
|
void bind()
|
||||||
{
|
{
|
||||||
glBindVertexArray(m_va);
|
gl_BindVertexArray(m_va);
|
||||||
m_vb->bind();
|
m_vb->bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,15 +189,15 @@ public:
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i < layout_nbr; i++) {
|
for (uint32 i = 0; i < layout_nbr; i++) {
|
||||||
// Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer
|
// Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer
|
||||||
glEnableVertexAttribArray(layout[i].index);
|
gl_EnableVertexAttribArray(layout[i].index);
|
||||||
switch (layout[i].type) {
|
switch (layout[i].type) {
|
||||||
case GL_UNSIGNED_SHORT:
|
case GL_UNSIGNED_SHORT:
|
||||||
case GL_UNSIGNED_INT:
|
case GL_UNSIGNED_INT:
|
||||||
// Rule: when shader use integral (not normalized) you must use glVertexAttribIPointer (note the extra I)
|
// Rule: when shader use integral (not normalized) you must use gl_VertexAttribIPointer (note the extra I)
|
||||||
glVertexAttribIPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].stride, layout[i].offset);
|
gl_VertexAttribIPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].stride, layout[i].offset);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset);
|
gl_VertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ public:
|
||||||
|
|
||||||
~GSVertexBufferStateOGL()
|
~GSVertexBufferStateOGL()
|
||||||
{
|
{
|
||||||
glDeleteVertexArrays(1, &m_va);
|
gl_DeleteVertexArrays(1, &m_va);
|
||||||
delete m_vb;
|
delete m_vb;
|
||||||
delete m_ib;
|
delete m_ib;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue