From 9b037a381377d4dfcbde080a342ea8f006b6c396 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Sun, 16 Jun 2013 08:43:50 +0000 Subject: [PATCH] pcsx2: increase a bit the minimum size of the plugin dialogs (GSdx name is too long) gsdx: * move gl function loading into GSwnd. Clean the header and avoid to rely on macro. * Always require libegl for GSdx. You still need to select the API at compilation. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5670 96395faa-99c1-11dd-bbfe-3dabce05a288 --- cmake/SearchForStuff.cmake | 4 +- cmake/SelectPcsx2Plugins.cmake | 8 +-- pcsx2/gui/Dialogs/SysConfigDialog.cpp | 2 +- plugins/GSdx/CMakeLists.txt | 6 +-- plugins/GSdx/GLLoader.cpp | 74 -------------------------- plugins/GSdx/GLLoader.h | 28 ---------- plugins/GSdx/GSDeviceOGL.cpp | 2 - plugins/GSdx/GSRenderer.cpp | 5 +- plugins/GSdx/GSWnd.cpp | 76 +++++++++++++++++++++++++++ plugins/GSdx/GSWnd.h | 33 ++++++++++++ plugins/GSdx/GSWndEGL.cpp | 37 ++++++------- plugins/GSdx/GSWndEGL.h | 27 ++++++++-- plugins/GSdx/GSWndOGL.cpp | 41 +++++---------- plugins/GSdx/GSWndOGL.h | 6 +-- plugins/GSdx/GSWndWGL.cpp | 13 ++++- plugins/GSdx/GSWndWGL.h | 6 +-- plugins/GSdx/stdafx.h | 6 ++- 17 files changed, 194 insertions(+), 180 deletions(-) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index a39d1858f2..025cc65210 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -48,9 +48,6 @@ else() endif() find_package(wxWidgets COMPONENTS base core adv) find_package(ZLIB) -if (EGL_API) - include(FindEGL) -endif() ## Use pcsx2 package to find module include(FindAio) @@ -58,6 +55,7 @@ include(FindAio) #if(NOT GLSL_API) include(FindCg) #endif(NOT GLSL_API) +include(FindEGL) include(FindGlew) include(FindLibc) include(FindPortAudio) diff --git a/cmake/SelectPcsx2Plugins.cmake b/cmake/SelectPcsx2Plugins.cmake index 101c49356a..2a3934513f 100644 --- a/cmake/SelectPcsx2Plugins.cmake +++ b/cmake/SelectPcsx2Plugins.cmake @@ -5,7 +5,7 @@ set(msg_dep_common_libs "check these libraries -> wxWidgets (>=2.8.10), sparseha set(msg_dep_pcsx2 "check these libraries -> wxWidgets (>=2.8.10), gtk2 (>=2.16), zlib (>=1.2.4), pcsx2 common libs") set(msg_dep_cdvdiso "check these libraries -> bzip2 (>=1.0.5), gtk2 (>=2.16)") set(msg_dep_zerogs "check these libraries -> glew (>=1.6), opengl, X11, nvidia-cg-toolkit (>=2.1)") -set(msg_dep_gsdx "check these libraries -> opengl, X11") +set(msg_dep_gsdx "check these libraries -> opengl, egl, X11") set(msg_dep_onepad "check these libraries -> sdl (>=1.2)") set(msg_dep_spu2x "check these libraries -> soundtouch (>=1.5), alsa, portaudio (>=1.9), pcsx2 common libs") set(msg_dep_zerospu2 "check these libraries -> soundtouch (>=1.5), alsa") @@ -130,15 +130,15 @@ endif(GTK2_FOUND) # requires: -OpenGL # -X11 #--------------------------------------- -if(OPENGL_FOUND AND X11_FOUND) +if(OPENGL_FOUND AND X11_FOUND AND EGL_FOUND) set(GSdx TRUE) elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/plugins/GSdx") set(GSdx FALSE) -else(OPENGL_FOUND AND X11_FOUND) +else(OPENGL_FOUND AND X11_FOUND AND EGL_FOUND) set(GSdx FALSE) message(STATUS "Skip build of GSdx: miss some dependencies") message(STATUS "${msg_dep_gsdx}") -endif(OPENGL_FOUND AND X11_FOUND) +endif(OPENGL_FOUND AND X11_FOUND AND EGL_FOUND) #--------------------------------------- #--------------------------------------- diff --git a/pcsx2/gui/Dialogs/SysConfigDialog.cpp b/pcsx2/gui/Dialogs/SysConfigDialog.cpp index 77dc47a3cd..455f9fa362 100644 --- a/pcsx2/gui/Dialogs/SysConfigDialog.cpp +++ b/pcsx2/gui/Dialogs/SysConfigDialog.cpp @@ -234,7 +234,7 @@ Dialogs::SysConfigDialog::SysConfigDialog(wxWindow* parent) } Dialogs::ComponentsConfigDialog::ComponentsConfigDialog(wxWindow* parent) - : BaseConfigurationDialog( parent, AddAppName(_("Components Selectors - %s")), 600 ) + : BaseConfigurationDialog( parent, AddAppName(_("Components Selectors - %s")), 650 ) { ScopedBusyCursor busy( Cursor_ReallyBusy ); diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index e8a3b0f359..d3cfbee77c 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -45,7 +45,7 @@ if(XDG_STD) endif(XDG_STD) # Select the EGL API -if(EGL_API AND EGL_FOUND) +if(EGL_API) add_definitions(-DEGL_API) endif() @@ -188,9 +188,7 @@ add_library(${Output} SHARED ${GSdxSources} ${GSdxHeaders}) target_link_libraries(${Output} ${X11_LIBRARIES}) target_link_libraries(${Output} ${OPENGL_LIBRARIES}) -if(EGL_API AND EGL_FOUND) - target_link_libraries(${Output} ${EGL_LIBRARIES}) -endif() +target_link_libraries(${Output} ${EGL_LIBRARIES}) if(Linux) target_link_libraries(${Output} ${GTK2_LIBRARIES}) diff --git a/plugins/GSdx/GLLoader.cpp b/plugins/GSdx/GLLoader.cpp index 4c1fd793d3..5e191e3daf 100644 --- a/plugins/GSdx/GLLoader.cpp +++ b/plugins/GSdx/GLLoader.cpp @@ -147,80 +147,6 @@ namespace GLLoader { return true; } - void init_gl_function() { - GL_LOADFN(gl_ActiveTexture, glActiveTexture); - GL_LOADFN(gl_BlendColor, glBlendColor); - GL_LOADFN(gl_AttachShader, glAttachShader); - GL_LOADFN(gl_BindBuffer, glBindBuffer); - GL_LOADFN(gl_BindBufferBase, glBindBufferBase); - GL_LOADFN(gl_BindFragDataLocationIndexed, glBindFragDataLocationIndexed); - GL_LOADFN(gl_BindFramebuffer, glBindFramebuffer); - GL_LOADFN(gl_BindProgramPipeline, glBindProgramPipeline); - GL_LOADFN(gl_BindSampler, glBindSampler); - GL_LOADFN(gl_BindVertexArray, glBindVertexArray); - GL_LOADFN(gl_BlendEquationSeparate, glBlendEquationSeparate); - GL_LOADFN(gl_BlendFuncSeparate, glBlendFuncSeparate); - GL_LOADFN(gl_BlitFramebuffer, glBlitFramebuffer); - GL_LOADFN(gl_BufferData, glBufferData); - GL_LOADFN(gl_CheckFramebufferStatus, glCheckFramebufferStatus); - GL_LOADFN(gl_ClearBufferfv, glClearBufferfv); - GL_LOADFN(gl_ClearBufferiv, glClearBufferiv); - GL_LOADFN(gl_CompileShader, glCompileShader); - GL_LOADFN(gl_CopyImageSubDataNV, glCopyImageSubDataNV); - GL_LOADFN(gl_CreateProgram, glCreateProgram); - GL_LOADFN(gl_CreateShader, glCreateShader); - GL_LOADFN(gl_CreateShaderProgramv, glCreateShaderProgramv); - GL_LOADFN(gl_DeleteBuffers, glDeleteBuffers); - GL_LOADFN(gl_DeleteFramebuffers, glDeleteFramebuffers); - GL_LOADFN(gl_DeleteProgram, glDeleteProgram); - GL_LOADFN(gl_DeleteProgramPipelines, glDeleteProgramPipelines); - GL_LOADFN(gl_DeleteSamplers, glDeleteSamplers); - GL_LOADFN(gl_DeleteShader, glDeleteShader); - GL_LOADFN(gl_DeleteVertexArrays, glDeleteVertexArrays); - GL_LOADFN(gl_DetachShader, glDetachShader); - GL_LOADFN(gl_DrawBuffers, glDrawBuffers); - GL_LOADFN(gl_DrawElementsBaseVertex, glDrawElementsBaseVertex); - GL_LOADFN(gl_EnableVertexAttribArray, glEnableVertexAttribArray); - GL_LOADFN(gl_FramebufferRenderbuffer, glFramebufferRenderbuffer); - GL_LOADFN(gl_FramebufferTexture2D, glFramebufferTexture2D); - GL_LOADFN(gl_GenBuffers, glGenBuffers); - GL_LOADFN(gl_GenFramebuffers, glGenFramebuffers); - GL_LOADFN(gl_GenProgramPipelines, glGenProgramPipelines); - GL_LOADFN(gl_GenSamplers, glGenSamplers); - GL_LOADFN(gl_GenVertexArrays, glGenVertexArrays); - GL_LOADFN(gl_GetBufferParameteriv, glGetBufferParameteriv); - GL_LOADFN(gl_GetDebugMessageLogARB, glGetDebugMessageLogARB); - GL_LOADFN(gl_GetFragDataIndex, glGetFragDataIndex); - GL_LOADFN(gl_GetFragDataLocation, glGetFragDataLocation); - GL_LOADFN(gl_GetProgramInfoLog, glGetProgramInfoLog); - GL_LOADFN(gl_GetProgramiv, glGetProgramiv); - GL_LOADFN(gl_GetShaderiv, glGetShaderiv); - GL_LOADFN(gl_GetStringi, glGetStringi); - GL_LOADFN(gl_IsFramebuffer, glIsFramebuffer); - GL_LOADFN(gl_LinkProgram, glLinkProgram); - GL_LOADFN(gl_MapBuffer, glMapBuffer); - GL_LOADFN(gl_MapBufferRange, glMapBufferRange); - GL_LOADFN(gl_ProgramParameteri, glProgramParameteri); - GL_LOADFN(gl_SamplerParameterf, glSamplerParameterf); - GL_LOADFN(gl_SamplerParameteri, glSamplerParameteri); - GL_LOADFN(gl_ShaderSource, glShaderSource); - GL_LOADFN(gl_Uniform1i, glUniform1i); - GL_LOADFN(gl_UnmapBuffer, glUnmapBuffer); - GL_LOADFN(gl_UseProgramStages, glUseProgramStages); - GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer); - GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer); - GL_LOADFN(gl_TexStorage2D, glTexStorage2D); - GL_LOADFN(gl_BufferSubData, glBufferSubData); - // NO GL4.1 - GL_LOADFN(gl_UseProgram, glUseProgram); - GL_LOADFN(gl_GetShaderInfoLog, glGetShaderInfoLog); - GL_LOADFN(gl_ProgramUniform1i, glProgramUniform1i); - // NO GL4.2 - GL_LOADFN(gl_GetUniformBlockIndex, glGetUniformBlockIndex); - GL_LOADFN(gl_UniformBlockBinding, glUniformBlockBinding); - GL_LOADFN(gl_GetUniformLocation, glGetUniformLocation); - } - bool check_gl_supported_extension() { int max_ext = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext); diff --git a/plugins/GSdx/GLLoader.h b/plugins/GSdx/GLLoader.h index c388eb5d8a..2db78ec60d 100644 --- a/plugins/GSdx/GLLoader.h +++ b/plugins/GSdx/GLLoader.h @@ -21,34 +21,6 @@ #pragma once -#ifdef _LINUX -#include -#include -#include -#endif - -#ifdef _WINDOWS -#define GL_LOADFN(name, glName) { \ - if( (*(void**)&name = (void*)wglGetProcAddress(#glName)) == NULL ) { \ - fprintf(stderr,"Failed to find %s\n", #glName); \ - } \ -} -#else -#ifdef EGL_API -#define GL_LOADFN(name, glName) { \ - if( (*(void**)&name = (void*)eglGetProcAddress(#glName)) == NULL ) { \ - fprintf(stderr,"Failed to find %s\n", #glName); \ - } \ -} -#else -#define GL_LOADFN(name, glName) { \ - if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#glName)) == NULL ) { \ - fprintf(stderr,"Failed to find %s\n", #glName); \ - } \ -} -#endif -#endif - extern PFNGLACTIVETEXTUREPROC gl_ActiveTexture; extern PFNGLBLENDCOLORPROC gl_BlendColor; extern PFNGLATTACHSHADERPROC gl_AttachShader; diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 3e848018b4..b0b1b15071 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -191,8 +191,6 @@ GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, bool msaa, int form bool GSDeviceOGL::Create(GSWnd* wnd) { if (m_window == NULL) { - GLLoader::init_gl_function(); - if (!GLLoader::check_gl_version(3, 0)) return false; if (!GLLoader::check_gl_supported_extension()) return false; diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index ee1ea5c7bb..ce3e850333 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -21,6 +21,9 @@ #include "stdafx.h" #include "GSRenderer.h" +#ifdef _LINUX +#include +#endif GSRenderer::GSRenderer() : m_wnd(NULL) @@ -560,7 +563,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e) } } -#else +#elif defined(_LINUX) if(e->type == KEYPRESS) { int step = m_shift_key ? -1 : 1; diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index c52c87ffbc..779dc8a100 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -20,3 +20,79 @@ */ #include "stdafx.h" +#include "GSWnd.h" + +void GSWndGL::PopulateGlFunction() +{ + *(void**)&(gl_ActiveTexture) = GetProcAddress("glActiveTexture"); + *(void**)&(gl_BlendColor) = GetProcAddress("glBlendColor"); + *(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_BindProgramPipeline) = GetProcAddress("glBindProgramPipeline"); + *(void**)&(gl_BindSampler) = GetProcAddress("glBindSampler"); + *(void**)&(gl_BindVertexArray) = GetProcAddress("glBindVertexArray"); + *(void**)&(gl_BlendEquationSeparate) = GetProcAddress("glBlendEquationSeparate"); + *(void**)&(gl_BlendFuncSeparate) = GetProcAddress("glBlendFuncSeparate"); + *(void**)&(gl_BlitFramebuffer) = GetProcAddress("glBlitFramebuffer"); + *(void**)&(gl_BufferData) = GetProcAddress("glBufferData"); + *(void**)&(gl_CheckFramebufferStatus) = GetProcAddress("glCheckFramebufferStatus"); + *(void**)&(gl_ClearBufferfv) = GetProcAddress("glClearBufferfv"); + *(void**)&(gl_ClearBufferiv) = GetProcAddress("glClearBufferiv"); + *(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"); + *(void**)&(gl_DeleteBuffers) = GetProcAddress("glDeleteBuffers"); + *(void**)&(gl_DeleteFramebuffers) = GetProcAddress("glDeleteFramebuffers"); + *(void**)&(gl_DeleteProgram) = GetProcAddress("glDeleteProgram"); + *(void**)&(gl_DeleteProgramPipelines) = GetProcAddress("glDeleteProgramPipelines"); + *(void**)&(gl_DeleteSamplers) = GetProcAddress("glDeleteSamplers"); + *(void**)&(gl_DeleteShader) = GetProcAddress("glDeleteShader"); + *(void**)&(gl_DeleteVertexArrays) = GetProcAddress("glDeleteVertexArrays"); + *(void**)&(gl_DetachShader) = GetProcAddress("glDetachShader"); + *(void**)&(gl_DrawBuffers) = GetProcAddress("glDrawBuffers"); + *(void**)&(gl_DrawElementsBaseVertex) = GetProcAddress("glDrawElementsBaseVertex"); + *(void**)&(gl_EnableVertexAttribArray) = GetProcAddress("glEnableVertexAttribArray"); + *(void**)&(gl_FramebufferRenderbuffer) = GetProcAddress("glFramebufferRenderbuffer"); + *(void**)&(gl_FramebufferTexture2D) = GetProcAddress("glFramebufferTexture2D"); + *(void**)&(gl_GenBuffers) = GetProcAddress("glGenBuffers"); + *(void**)&(gl_GenFramebuffers) = GetProcAddress("glGenFramebuffers"); + *(void**)&(gl_GenProgramPipelines) = GetProcAddress("glGenProgramPipelines"); + *(void**)&(gl_GenSamplers) = GetProcAddress("glGenSamplers"); + *(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"); + *(void**)&(gl_GetStringi) = GetProcAddress("glGetStringi"); + *(void**)&(gl_IsFramebuffer) = GetProcAddress("glIsFramebuffer"); + *(void**)&(gl_LinkProgram) = GetProcAddress("glLinkProgram"); + *(void**)&(gl_MapBuffer) = GetProcAddress("glMapBuffer"); + *(void**)&(gl_MapBufferRange) = GetProcAddress("glMapBufferRange"); + *(void**)&(gl_ProgramParameteri) = GetProcAddress("glProgramParameteri"); + *(void**)&(gl_SamplerParameterf) = GetProcAddress("glSamplerParameterf"); + *(void**)&(gl_SamplerParameteri) = GetProcAddress("glSamplerParameteri"); + *(void**)&(gl_ShaderSource) = GetProcAddress("glShaderSource"); + *(void**)&(gl_Uniform1i) = GetProcAddress("glUniform1i"); + *(void**)&(gl_UnmapBuffer) = GetProcAddress("glUnmapBuffer"); + *(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"); + // NO GL4.1 + *(void**)&(gl_UseProgram) = GetProcAddress("glUseProgram"); + *(void**)&(gl_GetShaderInfoLog) = GetProcAddress("glGetShaderInfoLog"); + *(void**)&(gl_ProgramUniform1i) = GetProcAddress("glProgramUniform1i"); + // NO GL4.2 + *(void**)&(gl_GetUniformBlockIndex) = GetProcAddress("glGetUniformBlockIndex"); + *(void**)&(gl_UniformBlockBinding) = GetProcAddress("glUniformBlockBinding"); + *(void**)&(gl_GetUniformLocation) = GetProcAddress("glGetUniformLocation"); +} diff --git a/plugins/GSdx/GSWnd.h b/plugins/GSdx/GSWnd.h index 4b71b1a1b7..550eff7a9e 100644 --- a/plugins/GSdx/GSWnd.h +++ b/plugins/GSdx/GSWnd.h @@ -55,3 +55,36 @@ public: virtual void SetVSync(bool enable) {}; }; + +class GSWndGL : public GSWnd +{ +protected: + bool m_ctx_attached; + + bool IsContextAttached() const { return m_ctx_attached; } + +public: + GSWndGL() : m_ctx_attached(false) {}; + virtual ~GSWndGL() {}; + + virtual bool Create(const string& title, int w, int h) = 0; + virtual bool Attach(void* handle, bool managed = true) = 0; + virtual void Detach() = 0; + + virtual void* GetDisplay() = 0; + virtual void* GetHandle() = 0; + virtual GSVector4i GetClientRect() = 0; + virtual bool SetWindowText(const char* title) = 0; + + virtual void AttachContext() = 0; + virtual void DetachContext() = 0; + virtual void* GetProcAddress(const char* name) = 0; + + virtual void Show() = 0; + virtual void Hide() = 0; + virtual void HideFrame() = 0; + virtual void Flip() = 0; + virtual void SetVSync(bool enable) = 0; + + void PopulateGlFunction(); +}; diff --git a/plugins/GSdx/GSWndEGL.cpp b/plugins/GSdx/GSWndEGL.cpp index d36a30b66d..63c4399531 100644 --- a/plugins/GSdx/GSWndEGL.cpp +++ b/plugins/GSdx/GSWndEGL.cpp @@ -22,27 +22,10 @@ #include "stdafx.h" #include "GSWndEGL.h" -// Need at least MESA 9.0 (plan for october/november 2012) -// So force the destiny to at least check the compilation -#ifndef EGL_KHR_create_context -#define EGL_KHR_create_context 1 -#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION -#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB -#define EGL_CONTEXT_FLAGS_KHR 0x30FC -#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD -#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF -#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 -#endif +#if defined(_LINUX) -#if defined(_LINUX) && defined (EGL_API) GSWndEGL::GSWndEGL() - : m_NativeWindow(0), m_NativeDisplay(NULL), m_ctx_attached(false) + : m_NativeWindow(0), m_NativeDisplay(NULL) { } @@ -146,6 +129,8 @@ bool GSWndEGL::Attach(void* handle, bool managed) CheckContext(); + PopulateGlFunction(); + return true; } @@ -185,9 +170,22 @@ bool GSWndEGL::Create(const string& title, int w, int h) AttachContext(); + CheckContext(); + + PopulateGlFunction(); + return (m_NativeWindow != 0); } +void* GSWndEGL::GetProcAddress(const char* name) +{ + void* ptr = (void*)eglGetProcAddress(name); + if (ptr == NULL) { + fprintf(stderr, "Failed to find %s\n", name); + } + return ptr; +} + void* GSWndEGL::GetDisplay() { // note this part must be only executed when replaying .gs debug file @@ -278,5 +276,4 @@ EGLBoolean GSWndEGL::OpenEGLDisplay() return EGL_TRUE; } - #endif diff --git a/plugins/GSdx/GSWndEGL.h b/plugins/GSdx/GSWndEGL.h index 3c1a6f3eec..d016ced5f1 100644 --- a/plugins/GSdx/GSWndEGL.h +++ b/plugins/GSdx/GSWndEGL.h @@ -21,12 +21,31 @@ #include "GSWnd.h" -#if defined(_LINUX) && defined (EGL_API) +#if defined(_LINUX) #include #include #include -class GSWndEGL : public GSWnd +// Need at least MESA 9.0 (plan for october/november 2012) +// So force the destiny to at least check the compilation +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#endif + + +class GSWndEGL : public GSWndGL { EGLNativeWindowType m_NativeWindow; EGLNativeDisplayType m_NativeDisplay; @@ -35,9 +54,6 @@ class GSWndEGL : public GSWnd EGLSurface m_eglSurface; EGLContext m_eglContext; - bool m_ctx_attached; - - bool IsContextAttached() const { return m_ctx_attached; } bool CreateContext(int major, int minor); void CheckContext(); @@ -59,6 +75,7 @@ public: void AttachContext(); void DetachContext(); + void* GetProcAddress(const char* name); void Show(); void Hide(); diff --git a/plugins/GSdx/GSWndOGL.cpp b/plugins/GSdx/GSWndOGL.cpp index ce57287157..7a6555be20 100644 --- a/plugins/GSdx/GSWndOGL.cpp +++ b/plugins/GSdx/GSWndOGL.cpp @@ -24,7 +24,7 @@ #ifdef _LINUX GSWndOGL::GSWndOGL() - : m_NativeWindow(0), m_NativeDisplay(NULL), m_swapinterval(NULL), m_ctx_attached(false) + : m_NativeWindow(0), m_NativeDisplay(NULL), m_swapinterval(NULL) { } @@ -147,6 +147,7 @@ bool GSWndOGL::Attach(void* handle, bool managed) m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); //PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapInterval"); + PopulateGlFunction(); return true; } @@ -178,34 +179,7 @@ bool GSWndOGL::Create(const string& title, int w, int h) // note this part must be only executed when replaying .gs debug file m_NativeDisplay = XOpenDisplay(NULL); -#if 0 - int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - GLX_DEPTH_SIZE, 24, - None - }; - XVisualInfo* vi = glXChooseVisual(m_NativeDisplay, DefaultScreen(m_NativeDisplay), attrListDbl); - - /* create a color map */ - XSetWindowAttributes attr; - attr.colormap = XCreateColormap(m_NativeDisplay, RootWindow(m_NativeDisplay, vi->screen), - vi->visual, AllocNone); - attr.border_pixel = 0; - attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | - StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask | - EnterWindowMask | LeaveWindowMask | FocusChangeMask ; - - // Create a window at the last position/size - m_NativeWindow = XCreateWindow(m_NativeDisplay, RootWindow(m_NativeDisplay, vi->screen), - 0 , 0 , w, h, 0, vi->depth, InputOutput, vi->visual, - CWBorderPixel | CWColormap | CWEventMask, &attr); - - XFree(vi); -#else m_NativeWindow = XCreateSimpleWindow(m_NativeDisplay, DefaultRootWindow(m_NativeDisplay), 0, 0, w, h, 0, 0, 0); -#endif XMapWindow (m_NativeDisplay, m_NativeWindow); @@ -216,9 +190,20 @@ bool GSWndOGL::Create(const string& title, int w, int h) CheckContext(); + PopulateGlFunction(); + return (m_NativeWindow != 0); } +void* GSWndOGL::GetProcAddress(const char* name) +{ + void* ptr = (void*)glXGetProcAddress((const GLubyte*)name); + if (ptr == NULL) { + fprintf(stderr, "Failed to find %s\n", name); + } + return ptr; +} + void* GSWndOGL::GetDisplay() { // note this part must be only executed when replaying .gs debug file diff --git a/plugins/GSdx/GSWndOGL.h b/plugins/GSdx/GSWndOGL.h index a8da30ea86..1f64230415 100644 --- a/plugins/GSdx/GSWndOGL.h +++ b/plugins/GSdx/GSWndOGL.h @@ -25,17 +25,14 @@ #include #include -class GSWndOGL : public GSWnd +class GSWndOGL : public GSWndGL { Window m_NativeWindow; Display* m_NativeDisplay; GLXContext m_context; - bool m_ctx_attached; - PFNGLXSWAPINTERVALMESAPROC m_swapinterval; - bool IsContextAttached() const { return m_ctx_attached; } bool CreateContext(int major, int minor); void CheckContext(); @@ -54,6 +51,7 @@ public: void AttachContext(); void DetachContext(); + void* GetProcAddress(const char* name); void Show(); void Hide(); diff --git a/plugins/GSdx/GSWndWGL.cpp b/plugins/GSdx/GSWndWGL.cpp index 03f98dfdaf..416e491972 100644 --- a/plugins/GSdx/GSWndWGL.cpp +++ b/plugins/GSdx/GSWndWGL.cpp @@ -24,7 +24,7 @@ #ifdef _WINDOWS GSWndWGL::GSWndWGL() - : m_NativeWindow(NULL), m_NativeDisplay(NULL), m_context(NULL), m_ctx_attached(false) + : m_NativeWindow(NULL), m_NativeDisplay(NULL), m_context(NULL) { } @@ -128,6 +128,8 @@ bool GSWndWGL::Attach(void* handle, bool managed) //m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); //PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapInterval"); + PopulateGlFunction(); + UpdateWindow(m_NativeWindow); return true; @@ -263,6 +265,15 @@ GSVector4i GSWndWGL::GetClientRect() return r; } +void* GSWndWGL::GetProcAddress(const char* name) +{ + void* ptr = (void*)wglGetProcAddress(name); + if (ptr == NULL) { + fprintf(stderr, "Failed to find %s\n", name); + } + return ptr; +} + //TODO: check extensions supported or not //FIXME : extension allocation void GSWndWGL::SetVSync(bool enable) diff --git a/plugins/GSdx/GSWndWGL.h b/plugins/GSdx/GSWndWGL.h index 77251f8deb..b42e95f3ff 100644 --- a/plugins/GSdx/GSWndWGL.h +++ b/plugins/GSdx/GSWndWGL.h @@ -23,17 +23,14 @@ #ifdef _WINDOWS -class GSWndWGL : public GSWnd +class GSWndWGL : public GSWndGL { HWND m_NativeWindow; HDC m_NativeDisplay; HGLRC m_context; - bool m_ctx_attached; - //PFNGLXSWAPINTERVALMESAPROC m_swapinterval; - bool IsContextAttached() const { return m_ctx_attached; } bool CreateContext(int major, int minor); void CheckContext(); @@ -55,6 +52,7 @@ public: void AttachContext(); void DetachContext(); + void* GetProcAddress(const char* name); void Show(); void Hide(); diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index d7d4c407ac..ba207635de 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -262,10 +262,14 @@ struct aligned_free_second {template void operator()(T& p) {_aligned_fr #define RESTRICT restrict - #elif _MSC_VER >= 1400 // TODO: gcc + #elif _MSC_VER >= 1400 #define RESTRICT __restrict + #elif defined(__GNUC__) + + #define RESTRICT __restrict__ + #else #define RESTRICT