mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl: AMD users upgrade to 13.8 now ;)
* clean extension management and fix compilation of previous gl44 code. * Use pixel buffer object to upload texture data. => avoid crash on AMD driver => a bit faster and probably got some margins for the future git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5712 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
64f783410e
commit
34045eb8f7
|
@ -29,7 +29,6 @@ PFNGLBLENDCOLORPROC gl_BlendColor = NULL;
|
|||
PFNGLATTACHSHADERPROC gl_AttachShader = NULL;
|
||||
PFNGLBINDBUFFERPROC gl_BindBuffer = NULL;
|
||||
PFNGLBINDBUFFERBASEPROC gl_BindBufferBase = NULL;
|
||||
PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed = NULL;
|
||||
PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer = NULL;
|
||||
PFNGLBINDSAMPLERPROC gl_BindSampler = NULL;
|
||||
PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray = NULL;
|
||||
|
@ -42,7 +41,6 @@ PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv = NULL;
|
|||
PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv = NULL;
|
||||
PFNGLCLEARBUFFERUIVPROC gl_ClearBufferuiv = NULL;
|
||||
PFNGLCOMPILESHADERPROC gl_CompileShader = NULL;
|
||||
PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV = NULL;
|
||||
PFNGLCREATEPROGRAMPROC gl_CreateProgram = NULL;
|
||||
PFNGLCREATESHADERPROC gl_CreateShader = NULL;
|
||||
PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv = NULL;
|
||||
|
@ -64,8 +62,6 @@ 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;
|
||||
|
@ -83,7 +79,6 @@ PFNGLUNMAPBUFFERPROC gl_UnmapBuffer = NULL;
|
|||
PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages = NULL;
|
||||
PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL;
|
||||
PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = NULL;
|
||||
PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
|
||||
PFNGLBUFFERSUBDATAPROC gl_BufferSubData = NULL;
|
||||
// GL 4.1
|
||||
PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline = NULL;
|
||||
|
@ -100,14 +95,17 @@ PFNGLPROGRAMUNIFORM1IPROC gl_ProgramUniform1i = NULL;
|
|||
PFNGLGETUNIFORMBLOCKINDEXPROC gl_GetUniformBlockIndex = NULL;
|
||||
PFNGLUNIFORMBLOCKBINDINGPROC gl_UniformBlockBinding = NULL;
|
||||
PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation = NULL;
|
||||
// GL4.3
|
||||
PFNGLCOPYIMAGESUBDATAPROC gl_CopyImageSubData = NULL;
|
||||
// GL4.2
|
||||
PFNGLBINDIMAGETEXTUREPROC gl_BindImageTexture = NULL;
|
||||
PFNGLMEMORYBARRIERPROC gl_MemoryBarrier = NULL;
|
||||
PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
|
||||
// GL4.4
|
||||
#ifdef GL44
|
||||
PFNGLCLEARTEXIMAGEPROC gl ClearTexImage = NULL;
|
||||
PFNGLBINDTEXTURESPROC gl BindTextures = NULL;
|
||||
#endif
|
||||
PFNGLCLEARTEXIMAGEPROC gl_ClearTexImage = NULL;
|
||||
PFNGLBINDTEXTURESPROC gl_BindTextures = NULL;
|
||||
PFNGLBUFFERSTORAGEPROC gl_BufferStorage = NULL;
|
||||
|
||||
#endif
|
||||
|
||||
namespace GLLoader {
|
||||
|
@ -116,17 +114,41 @@ namespace GLLoader {
|
|||
bool nvidia_buggy_driver = false;
|
||||
bool in_replayer = false;
|
||||
|
||||
// Optional
|
||||
bool found_GL_ARB_separate_shader_objects = false;
|
||||
bool found_GL_ARB_shading_language_420pack = false;
|
||||
bool found_GL_ARB_texture_storage = false;
|
||||
bool found_geometry_shader = true;
|
||||
bool found_GL_NV_copy_image = false;
|
||||
bool found_only_gl30 = false; // Drop it when mesa support GLSL330
|
||||
bool found_GL_ARB_clear_texture = false; // Don't know if GL3 hardawe can support it
|
||||
bool found_GL_ARB_buffer_storage = false;
|
||||
// GL4 hardware
|
||||
bool found_GL_ARB_copy_image = false;
|
||||
bool found_only_gl30 = false;
|
||||
bool found_GL_ARB_gpu_shader5 = false;
|
||||
bool found_GL_ARB_shader_image_load_store = false;
|
||||
bool found_GL_ARB_clear_texture = false;
|
||||
bool found_GL_ARB_multi_bind = false;
|
||||
|
||||
// Mandatory for FULL GL (but optional for GLES)
|
||||
bool found_GL_ARB_multi_bind = false; // Not yet. Wait Mesa & AMD drivers
|
||||
bool found_GL_ARB_shading_language_420pack = false; // Not yet. Wait Mesa & AMD drivers
|
||||
|
||||
// Mandatory
|
||||
bool found_GL_ARB_texture_storage = false;
|
||||
|
||||
static bool status_and_override(bool& found, const std::string& name, bool mandatory = false)
|
||||
{
|
||||
if (!found) {
|
||||
fprintf(stderr, "INFO: %s is not supported\n", name.c_str());
|
||||
if(mandatory) return false;
|
||||
}
|
||||
|
||||
std::string opt("override_");
|
||||
opt += name;
|
||||
|
||||
if (theApp.GetConfig(opt.c_str(), -1) != -1) {
|
||||
found = !!theApp.GetConfig(opt.c_str(), -1);
|
||||
fprintf(stderr, "Override %s detection (%s)\n", name.c_str(), found ? "Enabled" : "Disabled");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool check_gl_version(uint32 major, uint32 minor) {
|
||||
|
||||
|
@ -195,14 +217,13 @@ namespace GLLoader {
|
|||
}
|
||||
if (ext.compare("GL_ARB_shading_language_420pack") == 0) found_GL_ARB_shading_language_420pack = true;
|
||||
if (ext.compare("GL_ARB_texture_storage") == 0) found_GL_ARB_texture_storage = true;
|
||||
if (ext.compare("GL_NV_copy_image") == 0) found_GL_NV_copy_image = true;
|
||||
// Replace previous extensions (when driver will be updated)
|
||||
if (ext.compare("GL_ARB_copy_image") == 0) found_GL_ARB_copy_image = true;
|
||||
if (ext.compare("GL_ARB_gpu_shader5") == 0) found_GL_ARB_gpu_shader5 = true;
|
||||
if (ext.compare("GL_ARB_shader_image_load_store") == 0) found_GL_ARB_shader_image_load_store = true;
|
||||
#ifdef GL44
|
||||
#ifdef GL44 // Need to debug the code first
|
||||
if (ext.compare("GL_ARB_clear_texture") == 0) found_GL_ARB_clear_texture = true;
|
||||
if (ext.compare("GL_ARB_multi_bind") == 0) found_GL_ARB_multi_bind = true;
|
||||
if (ext.compare("GL_ARB_buffer_storage") == 0) found_GL_ARB_buffer_storage = true;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_GLES
|
||||
|
@ -211,41 +232,23 @@ namespace GLLoader {
|
|||
}
|
||||
}
|
||||
|
||||
bool status = true;
|
||||
#ifndef ENABLE_GLES
|
||||
if (!found_GL_ARB_separate_shader_objects) fprintf(stderr, "INFO: GL_ARB_separate_shader_objects is not supported\n");
|
||||
if (!found_GL_ARB_shading_language_420pack) fprintf(stderr, "INFO: GL_ARB_shading_language_420pack is not supported\n");
|
||||
if (!found_GL_ARB_gpu_shader5) fprintf(stderr, "INFO: GL_ARB_gpu_shader5 is not supported\n");
|
||||
if (!found_GL_ARB_shader_image_load_store) fprintf(stderr, "INFO: GL_ARB_shader_image_load_store is not supported\n");
|
||||
if (!found_GL_ARB_clear_texture) fprintf(stderr, "INFO: GL_ARB_clear_texture is not supported\n");
|
||||
if (!found_GL_ARB_multi_bind) fprintf(stderr, "INFO: GL_ARB_multi_bind is not supported\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (!found_GL_ARB_texture_storage) {
|
||||
fprintf(stderr, "FATAL: GL_ARB_texture_storage is not supported\n");
|
||||
return false;
|
||||
}
|
||||
status &= status_and_override(found_GL_ARB_separate_shader_objects,"GL_ARB_separate_shader_objects");
|
||||
status &= status_and_override(found_GL_ARB_gpu_shader5,"GL_ARB_gpu_shader5");
|
||||
status &= status_and_override(found_GL_ARB_shader_image_load_store,"GL_ARB_shader_image_load_store");
|
||||
status &= status_and_override(found_GL_ARB_clear_texture,"GL_ARB_clear_texture");
|
||||
status &= status_and_override(found_GL_ARB_buffer_storage,"GL_ARB_buffer_storage");
|
||||
|
||||
status &= status_and_override(found_GL_ARB_texture_storage, "GL_ARB_texture_storage", true);
|
||||
status &= status_and_override(found_GL_ARB_shading_language_420pack,"GL_ARB_shading_language_420pack");
|
||||
status &= status_and_override(found_GL_ARB_multi_bind,"GL_ARB_multi_bind");
|
||||
|
||||
if (theApp.GetConfig("override_GL_ARB_shading_language_420pack", -1) != -1) {
|
||||
found_GL_ARB_shading_language_420pack = !!theApp.GetConfig("override_GL_ARB_shading_language_420pack", -1);
|
||||
fprintf(stderr, "Override GL_ARB_shading_language_420pack detection\n");
|
||||
}
|
||||
if (theApp.GetConfig("override_GL_ARB_separate_shader_objects", -1) != -1) {
|
||||
found_GL_ARB_separate_shader_objects = !!theApp.GetConfig("override_GL_ARB_separate_shader_objects", -1);
|
||||
fprintf(stderr, "Override GL_ARB_separate_shader_objects detection\n");
|
||||
}
|
||||
if (theApp.GetConfig("override_GL_ARB_shader_image_load_store", -1) != -1) {
|
||||
found_GL_ARB_shader_image_load_store = !!theApp.GetConfig("override_GL_ARB_shader_image_load_store", -1);
|
||||
fprintf(stderr, "Override GL_ARB_shader_image_load_store detection\n");
|
||||
}
|
||||
if (theApp.GetConfig("override_GL_ARB_copy_image", -1) != -1) {
|
||||
// Same extension so override both
|
||||
found_GL_ARB_copy_image = !!theApp.GetConfig("override_GL_ARB_copy_image", -1);
|
||||
found_GL_NV_copy_image = !!theApp.GetConfig("override_GL_ARB_copy_image", -1);
|
||||
fprintf(stderr, "Override GL_ARB_copy_image detection\n");
|
||||
fprintf(stderr, "Override GL_NV_copy_image detection\n");
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,13 +21,67 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef ENABLE_GLES
|
||||
// Allow compilation with older mesa
|
||||
|
||||
#ifndef GL_ARB_copy_image
|
||||
#define GL_ARB_copy_image 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_4_4
|
||||
#define GL_VERSION_4_4 1
|
||||
#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5
|
||||
#define GL_MAP_PERSISTENT_BIT 0x0040
|
||||
#define GL_MAP_COHERENT_BIT 0x0080
|
||||
#define GL_DYNAMIC_STORAGE_BIT 0x0100
|
||||
#define GL_CLIENT_STORAGE_BIT 0x0200
|
||||
#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000
|
||||
#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F
|
||||
#define GL_BUFFER_STORAGE_FLAGS 0x8220
|
||||
#define GL_CLEAR_TEXTURE 0x9365
|
||||
#define GL_LOCATION_COMPONENT 0x934A
|
||||
#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B
|
||||
#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C
|
||||
#define GL_QUERY_BUFFER 0x9192
|
||||
#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000
|
||||
#define GL_QUERY_BUFFER_BINDING 0x9193
|
||||
#define GL_QUERY_RESULT_NO_WAIT 0x9194
|
||||
#define GL_MIRROR_CLAMP_TO_EDGE 0x8743
|
||||
typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);
|
||||
typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data);
|
||||
typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
|
||||
typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers);
|
||||
typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes);
|
||||
typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures);
|
||||
typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers);
|
||||
typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures);
|
||||
typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);
|
||||
GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data);
|
||||
GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
|
||||
GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers);
|
||||
GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes);
|
||||
GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures);
|
||||
GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers);
|
||||
GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures);
|
||||
GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);
|
||||
#endif
|
||||
#endif /* GL_VERSION_4_4 */
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_GLES
|
||||
extern PFNGLACTIVETEXTUREPROC gl_ActiveTexture;
|
||||
extern PFNGLBLENDCOLORPROC gl_BlendColor;
|
||||
extern PFNGLATTACHSHADERPROC gl_AttachShader;
|
||||
extern PFNGLBINDBUFFERPROC gl_BindBuffer;
|
||||
extern PFNGLBINDBUFFERBASEPROC gl_BindBufferBase;
|
||||
extern PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed;
|
||||
extern PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer;
|
||||
extern PFNGLBINDSAMPLERPROC gl_BindSampler;
|
||||
extern PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray;
|
||||
|
@ -40,7 +94,6 @@ extern PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv;
|
|||
extern PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv;
|
||||
extern PFNGLCLEARBUFFERUIVPROC gl_ClearBufferuiv;
|
||||
extern PFNGLCOMPILESHADERPROC gl_CompileShader;
|
||||
extern PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV;
|
||||
extern PFNGLCREATEPROGRAMPROC gl_CreateProgram;
|
||||
extern PFNGLCREATESHADERPROC gl_CreateShader;
|
||||
extern PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv;
|
||||
|
@ -62,8 +115,6 @@ extern PFNGLGENSAMPLERSPROC gl_GenSamplers;
|
|||
extern PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays;
|
||||
extern PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv;
|
||||
extern PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB;
|
||||
extern PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex;
|
||||
extern PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation;
|
||||
extern PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog;
|
||||
extern PFNGLGETPROGRAMIVPROC gl_GetProgramiv;
|
||||
extern PFNGLGETSHADERIVPROC gl_GetShaderiv;
|
||||
|
@ -81,7 +132,6 @@ extern PFNGLUNMAPBUFFERPROC gl_UnmapBuffer;
|
|||
extern PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages;
|
||||
extern PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer;
|
||||
extern PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer;
|
||||
extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D;
|
||||
extern PFNGLBUFFERSUBDATAPROC gl_BufferSubData;
|
||||
// GL4.1
|
||||
extern PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline;
|
||||
|
@ -101,11 +151,13 @@ extern PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation;
|
|||
// GL4.2
|
||||
extern PFNGLBINDIMAGETEXTUREPROC gl_BindImageTexture;
|
||||
extern PFNGLMEMORYBARRIERPROC gl_MemoryBarrier;
|
||||
extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D;
|
||||
// GL4.3
|
||||
extern PFNGLCOPYIMAGESUBDATAPROC gl_CopyImageSubData;
|
||||
// GL4.4
|
||||
#ifdef GL44
|
||||
extern PFNGLCLEARTEXIMAGEPROC gl_ClearTexImage;
|
||||
extern PFNGLBINDTEXTURESPROC gl_BindTextures;
|
||||
#endif
|
||||
extern PFNGLBUFFERSTORAGEPROC gl_BufferStorage;
|
||||
|
||||
#else
|
||||
#define gl_ActiveTexture glActiveTexture
|
||||
|
@ -113,7 +165,6 @@ extern PFNGLBINDTEXTURESPROC gl_BindTextures;
|
|||
#define gl_AttachShader glAttachShader
|
||||
#define gl_BindBuffer glBindBuffer
|
||||
#define gl_BindBufferBase glBindBufferBase
|
||||
#define gl_BindFragDataLocationIndexed glBindFragDataLocationIndexed
|
||||
#define gl_BindFramebuffer glBindFramebuffer
|
||||
#define gl_BindSampler glBindSampler
|
||||
#define gl_BindVertexArray glBindVertexArray
|
||||
|
@ -125,7 +176,6 @@ extern PFNGLBINDTEXTURESPROC gl_BindTextures;
|
|||
#define gl_ClearBufferfv glClearBufferfv
|
||||
#define gl_ClearBufferiv glClearBufferiv
|
||||
#define gl_CompileShader glCompileShader
|
||||
#define gl_CopyImageSubDataNV glCopyImageSubDataNV
|
||||
#define gl_CreateProgram glCreateProgram
|
||||
#define gl_CreateShader glCreateShader
|
||||
#define gl_CreateShaderProgramv glCreateShaderProgramv
|
||||
|
@ -147,8 +197,6 @@ extern PFNGLBINDTEXTURESPROC gl_BindTextures;
|
|||
#define gl_GenVertexArrays glGenVertexArrays
|
||||
#define gl_GetBufferParameteriv glGetBufferParameteriv
|
||||
#define gl_GetDebugMessageLogARB glGetDebugMessageLogARB
|
||||
#define gl_GetFragDataIndex glGetFragDataIndex
|
||||
#define gl_GetFragDataLocation glGetFragDataLocation
|
||||
#define gl_GetProgramInfoLog glGetProgramInfoLog
|
||||
#define gl_GetProgramiv glGetProgramiv
|
||||
#define gl_GetShaderiv glGetShaderiv
|
||||
|
@ -197,13 +245,12 @@ namespace GLLoader {
|
|||
|
||||
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 found_GL_ARB_copy_image;
|
||||
extern bool found_GL_NV_copy_image;
|
||||
extern bool found_geometry_shader;
|
||||
extern bool found_only_gl30;
|
||||
extern bool found_GL_ARB_gpu_shader5;
|
||||
extern bool found_GL_ARB_shader_image_load_store;
|
||||
extern bool found_GL_ARB_clear_texture;
|
||||
extern bool found_GL_ARB_multi_bind;
|
||||
extern bool found_GL_ARB_buffer_storage;
|
||||
}
|
||||
|
|
|
@ -123,6 +123,8 @@ GSDeviceOGL::~GSDeviceOGL()
|
|||
for (auto it = m_om_bs.begin(); it != m_om_bs.end(); it++) delete it->second;
|
||||
m_om_bs.clear();
|
||||
|
||||
PboPool::Destroy();
|
||||
|
||||
// Must be done after the destruction of all shader/program objects
|
||||
delete m_shader;
|
||||
m_shader = NULL;
|
||||
|
@ -296,6 +298,11 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
|
|||
// ****************************************************************
|
||||
CreateTextureFX();
|
||||
|
||||
// ****************************************************************
|
||||
// Pbo Pool allocation
|
||||
// ****************************************************************
|
||||
PboPool::Init();
|
||||
|
||||
// ****************************************************************
|
||||
// Finish window setup and backbuffer
|
||||
// ****************************************************************
|
||||
|
@ -441,9 +448,7 @@ void GSDeviceOGL::ClearDepth(GSTexture* t, float c)
|
|||
// TODO is it possible with GL44 ClearTexture?
|
||||
// It is seriously not clear if we can clear only the depth
|
||||
if (GLLoader::found_GL_ARB_clear_texture) {
|
||||
#ifdef GL44
|
||||
gl_ClearTexImage(static_cast<GSTextureOGL*>(t)->GetID(), 0, GL_DEPTH_STENCIL, GL_FLOAT, &c);
|
||||
#endif
|
||||
} else {
|
||||
OMSetFBO(m_fbo);
|
||||
OMSetWriteBuffer();
|
||||
|
@ -466,9 +471,7 @@ void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c)
|
|||
// TODO is it possible with GL44 ClearTexture?
|
||||
// It is seriously not clear if we can clear only the stencil
|
||||
if (GLLoader::found_GL_ARB_clear_texture) {
|
||||
#ifdef GL44
|
||||
gl_ClearTexImage(static_cast<GSTextureOGL*>(t)->GetID(), 0, GL_DEPTH_STENCIL, GL_BYTE, &c);
|
||||
#endif
|
||||
} else {
|
||||
OMSetFBO(m_fbo);
|
||||
OMSetWriteBuffer();
|
||||
|
@ -664,18 +667,8 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r)
|
|||
{
|
||||
ASSERT(st && dt);
|
||||
|
||||
// FIXME: the extension was integrated in opengl 4.3 (now we need driver that support OGL4.3)
|
||||
if (GLLoader::found_GL_NV_copy_image) {
|
||||
if (GLLoader::found_GL_ARB_copy_image) {
|
||||
#ifndef ENABLE_GLES
|
||||
gl_CopyImageSubDataNV( static_cast<GSTextureOGL*>(st)->GetID(), GL_TEXTURE_2D,
|
||||
0, r.x, r.y, 0,
|
||||
static_cast<GSTextureOGL*>(dt)->GetID(), GL_TEXTURE_2D,
|
||||
0, r.x, r.y, 0,
|
||||
r.width(), r.height(), 1);
|
||||
#endif
|
||||
} else if (GLLoader::found_GL_ARB_copy_image) {
|
||||
// Would need an update of GL definition. For the moment it isn't supported by driver anyway.
|
||||
#if 0
|
||||
gl_CopyImageSubData( static_cast<GSTextureOGL*>(st)->GetID(), GL_TEXTURE_2D,
|
||||
0, r.x, r.y, 0,
|
||||
static_cast<GSTextureOGL*>(dt)->GetID(), GL_TEXTURE_2D,
|
||||
|
@ -992,9 +985,8 @@ void GSDeviceOGL::PSSetShaderResource(const int i, GSTexture* sr)
|
|||
m_state.tex_unit[i] = sr;
|
||||
|
||||
if (GLLoader::found_GL_ARB_multi_bind) {
|
||||
#ifdef GL44
|
||||
GLuint textures[1] = {static_cast<GSTextureOGL*>(sr)->GetID()};
|
||||
gl_BindTextures(i, 1, textures);
|
||||
#endif
|
||||
} else {
|
||||
gl_ActiveTexture(GL_TEXTURE0 + i);
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<GSTextureOGL*>(sr)->GetID());
|
||||
|
@ -1007,15 +999,12 @@ void GSDeviceOGL::PSSetShaderResource(const int i, GSTexture* sr)
|
|||
|
||||
void GSDeviceOGL::PSSetShaderResources(GSTexture* tex[2])
|
||||
{
|
||||
// FIXME how to check the state
|
||||
#ifdef GL44
|
||||
if (m_state.tex_unit[0] != tex[0] || m_state.tex_unit[1] != tex[1]) {
|
||||
GLuint textures[2] = {static_cast<GSTextureOGL*>(tex[0])->GetID(), static_cast<GSTextureOGL*>(tex[1])->GetID()};
|
||||
gl_BindTextures(0, 2, textures);
|
||||
}
|
||||
#endif
|
||||
|
||||
// FIXME without multibind
|
||||
// FIXME without multibind?
|
||||
#if 0
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (m_state.tex_unit[i] != id) {
|
||||
|
|
|
@ -22,6 +22,38 @@
|
|||
#include "stdafx.h"
|
||||
#include <limits.h>
|
||||
#include "GSTextureOGL.h"
|
||||
|
||||
namespace PboPool {
|
||||
|
||||
GLuint pool[8];
|
||||
uint32 current_pbo = 0;
|
||||
|
||||
void Init() {
|
||||
gl_GenBuffers(countof(pool), pool);
|
||||
|
||||
GLuint size = (640*480*16) << 2;
|
||||
|
||||
for (size_t i = 0; i < countof(pool); i++) {
|
||||
BindPbo();
|
||||
gl_BufferData(GL_PIXEL_UNPACK_BUFFER, size, NULL, GL_STREAM_DRAW);
|
||||
}
|
||||
UnbindPbo();
|
||||
}
|
||||
|
||||
void Destroy() {
|
||||
gl_DeleteBuffers(countof(pool), pool);
|
||||
}
|
||||
|
||||
void BindPbo() {
|
||||
gl_BindBuffer(GL_PIXEL_UNPACK_BUFFER, pool[current_pbo]);
|
||||
current_pbo = (current_pbo + 1) & (countof(pool)-1);
|
||||
}
|
||||
|
||||
void UnbindPbo() {
|
||||
gl_BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static GLuint g_tex3_state = 0;
|
||||
|
||||
// FIXME: check if it possible to always use those setup by default
|
||||
|
@ -87,6 +119,18 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read)
|
|||
m_int_alignment = 1;
|
||||
m_int_shift = 0;
|
||||
break;
|
||||
case 0:
|
||||
case GL_DEPTH32F_STENCIL8:
|
||||
// Backbuffer & dss aren't important
|
||||
m_int_format = 0;
|
||||
m_int_type = 0;
|
||||
m_int_alignment = 0;
|
||||
m_int_shift = 0;
|
||||
break;
|
||||
m_int_format = 0;
|
||||
m_int_type = 0;
|
||||
m_int_alignment = 0;
|
||||
m_int_shift = 0;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -149,20 +193,37 @@ GSTextureOGL::~GSTextureOGL()
|
|||
|
||||
void GSTextureOGL::Clear(const void *data)
|
||||
{
|
||||
#ifdef GL44
|
||||
gl_ClearTexImage(m_texture_id, 0, m_format, m_int_type, const void * data);
|
||||
#endif
|
||||
gl_ClearTexImage(m_texture_id, 0, m_format, m_int_type, data);
|
||||
}
|
||||
|
||||
bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
|
||||
{
|
||||
ASSERT(m_type != GSTexture::DepthStencil && m_type != GSTexture::Offscreen);
|
||||
|
||||
// FIXME warning order of the y axis
|
||||
// FIXME I'm not confident with GL_UNSIGNED_BYTE type
|
||||
|
||||
EnableUnit();
|
||||
|
||||
#if 1
|
||||
PboPool::BindPbo();
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, m_int_alignment);
|
||||
|
||||
char* map = (char*)gl_MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, (pitch * r.height()) << m_int_shift, GL_MAP_WRITE_BIT);
|
||||
char* src = (char*)data;
|
||||
uint32 line_size = r.width() << m_int_shift;
|
||||
for (uint32 h = r.height(); h > 0; h--) {
|
||||
memcpy(map, src, line_size);
|
||||
src += pitch;
|
||||
map += line_size;
|
||||
}
|
||||
gl_UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, r.x, r.y, r.width(), r.height(), m_int_format, m_int_type, (const void*)0);
|
||||
|
||||
PboPool::UnbindPbo();
|
||||
|
||||
return true;
|
||||
#else
|
||||
|
||||
// pitch is in byte wherease GL_UNPACK_ROW_LENGTH is in pixel
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, m_int_alignment);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch >> m_int_shift);
|
||||
|
@ -202,6 +263,7 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
|
|||
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void GSTextureOGL::EnableUnit()
|
||||
|
|
|
@ -23,6 +23,17 @@
|
|||
|
||||
#include "GSTexture.h"
|
||||
|
||||
namespace PboPool {
|
||||
extern GLuint pool[8];
|
||||
extern uint32 current_pbo;
|
||||
|
||||
void BindPbo();
|
||||
void UnbindPbo();
|
||||
|
||||
void Init();
|
||||
void Destroy();
|
||||
}
|
||||
|
||||
class GSTextureOGL : public GSTexture
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -30,7 +30,6 @@ void GSWndGL::PopulateGlFunction()
|
|||
*(void**)&(gl_AttachShader) = GetProcAddress("glAttachShader");
|
||||
*(void**)&(gl_BindBuffer) = GetProcAddress("glBindBuffer");
|
||||
*(void**)&(gl_BindBufferBase) = GetProcAddress("glBindBufferBase");
|
||||
*(void**)&(gl_BindFragDataLocationIndexed) = GetProcAddress("glBindFragDataLocationIndexed");
|
||||
*(void**)&(gl_BindFramebuffer) = GetProcAddress("glBindFramebuffer");
|
||||
*(void**)&(gl_BindSampler) = GetProcAddress("glBindSampler");
|
||||
*(void**)&(gl_BindVertexArray) = GetProcAddress("glBindVertexArray");
|
||||
|
@ -43,7 +42,6 @@ void GSWndGL::PopulateGlFunction()
|
|||
*(void**)&(gl_ClearBufferiv) = GetProcAddress("glClearBufferiv");
|
||||
*(void**)&(gl_ClearBufferuiv) = GetProcAddress("glClearBufferuiv");
|
||||
*(void**)&(gl_CompileShader) = GetProcAddress("glCompileShader");
|
||||
*(void**)&(gl_CopyImageSubDataNV) = GetProcAddress("glCopyImageSubDataNV");
|
||||
*(void**)&(gl_CreateProgram) = GetProcAddress("glCreateProgram");
|
||||
*(void**)&(gl_CreateShader) = GetProcAddress("glCreateShader");
|
||||
*(void**)&(gl_CreateShaderProgramv) = GetProcAddress("glCreateShaderProgramv");
|
||||
|
@ -65,8 +63,6 @@ void GSWndGL::PopulateGlFunction()
|
|||
*(void**)&(gl_GenVertexArrays) = GetProcAddress("glGenVertexArrays");
|
||||
*(void**)&(gl_GetBufferParameteriv) = GetProcAddress("glGetBufferParameteriv");
|
||||
*(void**)&(gl_GetDebugMessageLogARB) = GetProcAddress("glGetDebugMessageLogARB");
|
||||
*(void**)&(gl_GetFragDataIndex) = GetProcAddress("glGetFragDataIndex");
|
||||
*(void**)&(gl_GetFragDataLocation) = GetProcAddress("glGetFragDataLocation");
|
||||
*(void**)&(gl_GetProgramInfoLog) = GetProcAddress("glGetProgramInfoLog");
|
||||
*(void**)&(gl_GetProgramiv) = GetProcAddress("glGetProgramiv");
|
||||
*(void**)&(gl_GetShaderiv) = GetProcAddress("glGetShaderiv");
|
||||
|
@ -84,7 +80,6 @@ void GSWndGL::PopulateGlFunction()
|
|||
*(void**)&(gl_UseProgramStages) = GetProcAddress("glUseProgramStages");
|
||||
*(void**)&(gl_VertexAttribIPointer) = GetProcAddress("glVertexAttribIPointer");
|
||||
*(void**)&(gl_VertexAttribPointer) = GetProcAddress("glVertexAttribPointer");
|
||||
*(void**)&(gl_TexStorage2D) = GetProcAddress("glTexStorage2D");
|
||||
*(void**)&(gl_BufferSubData) = GetProcAddress("glBufferSubData");
|
||||
// GL4.1
|
||||
*(void**)&(gl_BindProgramPipeline) = GetProcAddress("glBindProgramPipeline");
|
||||
|
@ -102,13 +97,15 @@ void GSWndGL::PopulateGlFunction()
|
|||
*(void**)&(gl_UniformBlockBinding) = GetProcAddress("glUniformBlockBinding");
|
||||
*(void**)&(gl_GetUniformLocation) = GetProcAddress("glGetUniformLocation");
|
||||
// GL4.2
|
||||
*(void**)&(gl_BindImageTexture) = GetProcAddress("glBindImageTexture");
|
||||
*(void**)&(gl_MemoryBarrier) = GetProcAddress("glMemoryBarrier");
|
||||
#ifdef GL44
|
||||
*(void**)&(gl_ClearTexImage) = GetProcAddress("glCLearTexImage");
|
||||
*(void**)&(gl_BindTextures) = GetProcAddress("glBindTextures");
|
||||
*(void**)&(gl_BindSamplers) = GetProcAddress("glBindSamplers");
|
||||
#endif
|
||||
*(void**)&(gl_BindImageTexture) = GetProcAddress("glBindImageTexture", true);
|
||||
*(void**)&(gl_MemoryBarrier) = GetProcAddress("glMemoryBarrier", true);
|
||||
*(void**)&(gl_TexStorage2D) = GetProcAddress("glTexStorage2D");
|
||||
// GL4.3
|
||||
*(void**)&(gl_CopyImageSubData) = GetProcAddress("glCopyImageSubData", true);
|
||||
// GL4.4
|
||||
*(void**)&(gl_ClearTexImage) = GetProcAddress("glCLearTexImage", true);
|
||||
*(void**)&(gl_BindTextures) = GetProcAddress("glBindTextures", true);
|
||||
*(void**)&(gl_BufferStorage) = GetProcAddress("glBufferStorage", true);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
virtual void AttachContext() = 0;
|
||||
virtual void DetachContext() = 0;
|
||||
virtual void* GetProcAddress(const char* name) = 0;
|
||||
virtual void* GetProcAddress(const char* name, bool opt = false) = 0;
|
||||
|
||||
virtual void Show() = 0;
|
||||
virtual void Hide() = 0;
|
||||
|
|
|
@ -197,12 +197,13 @@ bool GSWndEGL::Create(const string& title, int w, int h)
|
|||
return true;
|
||||
}
|
||||
|
||||
void* GSWndEGL::GetProcAddress(const char* name)
|
||||
void* GSWndEGL::GetProcAddress(const char* name, bool opt)
|
||||
{
|
||||
void* ptr = (void*)eglGetProcAddress(name);
|
||||
if (ptr == NULL) {
|
||||
fprintf(stderr, "Failed to find %s\n", name);
|
||||
throw GSDXRecoverableError();
|
||||
if (!opt)
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
void AttachContext();
|
||||
void DetachContext();
|
||||
void* GetProcAddress(const char* name);
|
||||
void* GetProcAddress(const char* name, bool opt = false);
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
|
|
|
@ -197,12 +197,13 @@ bool GSWndOGL::Create(const string& title, int w, int h)
|
|||
return true;
|
||||
}
|
||||
|
||||
void* GSWndOGL::GetProcAddress(const char* name)
|
||||
void* GSWndOGL::GetProcAddress(const char* name, bool opt)
|
||||
{
|
||||
void* ptr = (void*)glXGetProcAddress((const GLubyte*)name);
|
||||
if (ptr == NULL) {
|
||||
fprintf(stderr, "Failed to find %s\n", name);
|
||||
throw GSDXRecoverableError();
|
||||
if (!opt)
|
||||
throw GSDXRecoverableError();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
void AttachContext();
|
||||
void DetachContext();
|
||||
void* GetProcAddress(const char* name);
|
||||
void* GetProcAddress(const char* name, bool opt = false);
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
|
|
|
@ -265,7 +265,7 @@ GSVector4i GSWndWGL::GetClientRect()
|
|||
return r;
|
||||
}
|
||||
|
||||
void* GSWndWGL::GetProcAddress(const char* name)
|
||||
void* GSWndWGL::GetProcAddress(const char* name, bool opt)
|
||||
{
|
||||
void* ptr = (void*)wglGetProcAddress(name);
|
||||
if (ptr == NULL) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
void AttachContext();
|
||||
void DetachContext();
|
||||
void* GetProcAddress(const char* name);
|
||||
void* GetProcAddress(const char* name, bool opt);
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
|
|
|
@ -102,6 +102,7 @@ using namespace std;
|
|||
|
||||
#ifdef _WINDOWS
|
||||
|
||||
// Note use GL/glcorearb.h on the future
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#include <GL/wglext.h>
|
||||
|
@ -190,6 +191,7 @@ using namespace std;
|
|||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
#else
|
||||
// Note use GL/glcorearb.h on the future
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue