diff options
author | Mike Erwin <significant.bit@gmail.com> | 2017-04-22 07:35:04 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2017-04-22 07:35:04 +0300 |
commit | ef640ecf1004f7af9cfde09f5ce1cde2fb70747f (patch) | |
tree | 0fdf4cc76d005848fee55c5217af1114e45d1607 /intern/ghost | |
parent | 1beed61b761d3f964f57f99235c479ff1ddfe26f (diff) |
OpenGL: remove use of GLEW MX
MX (Multiple conteXt) support was dropped from the GLEW 2.0 library to make core profile support cleaner.
Our WITH_GLEW_MX build option was OFF by default already; this commit removes the inactive code paths.
I'm working on a plan for multiple GPUs, contexts, resource sharing, etc. This commit gives us a cleaner starting point for that upcoming work.
Tested on Mac, will test on Linux & Windows immediately after pushing.
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/intern/GHOST_Context.cpp | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_Context.h | 11 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextCGL.h | 13 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextCGL.mm | 3 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextEGL.cpp | 33 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextEGL.h | 20 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextGLX.cpp | 25 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextGLX.h | 19 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextSDL.cpp | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextWGL.cpp | 29 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextWGL.h | 19 |
11 files changed, 4 insertions, 176 deletions
diff --git a/intern/ghost/intern/GHOST_Context.cpp b/intern/ghost/intern/GHOST_Context.cpp index f69f2181ef7..fc7193ae99b 100644 --- a/intern/ghost/intern/GHOST_Context.cpp +++ b/intern/ghost/intern/GHOST_Context.cpp @@ -143,11 +143,7 @@ bool win32_chk(bool result, const char *file, int line, const char *text) void GHOST_Context::initContextGLEW() { - mxDestroyContext(m_mxContext); // no-op if m_mxContext is NULL - - mxMakeCurrentContext(mxCreateContext()); - - m_mxContext = mxGetCurrentContext(); + GLEW_CHK(glewInit()); } diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h index 18d36c40e9c..8776fa4764f 100644 --- a/intern/ghost/intern/GHOST_Context.h +++ b/intern/ghost/intern/GHOST_Context.h @@ -50,15 +50,13 @@ public: */ GHOST_Context(bool stereoVisual, GHOST_TUns16 numOfAASamples) : m_stereoVisual(stereoVisual), - m_numOfAASamples(numOfAASamples), - m_mxContext(NULL) + m_numOfAASamples(numOfAASamples) {} /** * Destructor. */ virtual ~GHOST_Context() { - mxDestroyContext(m_mxContext); } /** @@ -128,19 +126,12 @@ public: protected: void initContextGLEW(); - inline void activateGLEW() const { - mxMakeCurrentContext(m_mxContext); - } - bool m_stereoVisual; GHOST_TUns16 m_numOfAASamples; static void initClearGL(); -private: - MXContext *m_mxContext; - #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_Context") #endif diff --git a/intern/ghost/intern/GHOST_ContextCGL.h b/intern/ghost/intern/GHOST_ContextCGL.h index 8186eaa759d..6dcc4da0f0a 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.h +++ b/intern/ghost/intern/GHOST_ContextCGL.h @@ -34,10 +34,6 @@ #include "GHOST_Context.h" -//#define cglewGetContext() cglewContext -//#include <GL/cglew.h> -//extern "C" CGLEWContext *cglewContext; - #ifndef GHOST_OPENGL_CGL_CONTEXT_FLAGS #define GHOST_OPENGL_CGL_CONTEXT_FLAGS 0 #endif @@ -120,14 +116,7 @@ public: */ GHOST_TSuccess updateDrawingContext(); -//protected: -// inline void activateCGLEW() const { -// cglewContext = m_cglewContext; -// } - private: - //void initContextCGLEW() - /** The openGL view */ NSOpenGLView *m_openGLView; @@ -136,8 +125,6 @@ private: bool m_coreProfile; - //static CGLEWContext *s_cglewContext; - const bool m_debug; /** The first created OpenGL context (for sharing display lists) */ diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm index f6adb362470..03af3cc497e 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.mm +++ b/intern/ghost/intern/GHOST_ContextCGL.mm @@ -159,9 +159,6 @@ GHOST_TSuccess GHOST_ContextCGL::activateDrawingContext() if (m_openGLContext != nil) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [m_openGLContext makeCurrentContext]; - - activateGLEW(); - [pool drain]; return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp index 520aa0fffb2..a591d9b7583 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.cpp +++ b/intern/ghost/intern/GHOST_ContextEGL.cpp @@ -42,11 +42,6 @@ #include <cstring> -#ifdef WITH_GLEW_MX -EGLEWContext *eglewContext = NULL; -#endif - - #define CASE_CODE_RETURN_STR(code) case code: return #code; static const char *get_egl_error_enum_string(EGLenum error) @@ -168,13 +163,8 @@ static bool egl_chk(bool result, const char *file = NULL, int line = 0, const ch static inline bool bindAPI(EGLenum api) { -#ifdef WITH_GLEW_MX - if (eglewContext != NULL) -#endif - { - if (EGLEW_VERSION_1_2) { - return (EGL_CHK(eglBindAPI(api)) == EGL_TRUE); - } + if (EGLEW_VERSION_1_2) { + return (EGL_CHK(eglBindAPI(api)) == EGL_TRUE); } return false; @@ -238,9 +228,6 @@ GHOST_ContextEGL::GHOST_ContextEGL( m_surface(EGL_NO_SURFACE), m_display(EGL_NO_DISPLAY), m_swap_interval(1), -#ifdef WITH_GLEW_MX - m_eglewContext(NULL), -#endif m_sharedContext(choose_api(api, s_gl_sharedContext, s_gles_sharedContext, s_vg_sharedContext)), m_sharedCount (choose_api(api, s_gl_sharedCount, s_gles_sharedCount, s_vg_sharedCount)) { @@ -252,7 +239,6 @@ GHOST_ContextEGL::GHOST_ContextEGL( GHOST_ContextEGL::~GHOST_ContextEGL() { if (m_display != EGL_NO_DISPLAY) { - activateEGLEW(); bindAPI(m_api); @@ -276,10 +262,6 @@ GHOST_ContextEGL::~GHOST_ContextEGL() EGL_CHK(::eglDestroySurface(m_display, m_surface)); EGL_CHK(::eglTerminate(m_display)); - -#ifdef WITH_GLEW_MX - delete m_eglewContext; -#endif } } @@ -321,9 +303,6 @@ GHOST_TSuccess GHOST_ContextEGL::getSwapInterval(int &intervalOut) GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext() { if (m_display) { - activateEGLEW(); - activateGLEW(); - bindAPI(m_api); return EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)) ? GHOST_kSuccess : GHOST_kFailure; @@ -336,14 +315,6 @@ GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext() void GHOST_ContextEGL::initContextEGLEW() { -#ifdef WITH_GLEW_MX - eglewContext = new EGLEWContext; - memset(eglewContext, 0, sizeof(EGLEWContext)); - - delete m_eglewContext; - m_eglewContext = eglewContext; -#endif - if (GLEW_CHK(eglewInit(m_display)) != GLEW_OK) fprintf(stderr, "Warning! EGLEW failed to initialize properly.\n"); } diff --git a/intern/ghost/intern/GHOST_ContextEGL.h b/intern/ghost/intern/GHOST_ContextEGL.h index 70c26c940fc..6dfb177f26d 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.h +++ b/intern/ghost/intern/GHOST_ContextEGL.h @@ -34,17 +34,8 @@ #include "GHOST_Context.h" -#ifdef WITH_GLEW_MX -# define eglewGetContext() eglewContext -#endif - #include <GL/eglew.h> -#ifdef WITH_GLEW_MX -extern "C" EGLEWContext *eglewContext; -#endif - - #ifndef GHOST_OPENGL_EGL_CONTEXT_FLAGS #define GHOST_OPENGL_EGL_CONTEXT_FLAGS 0 #endif @@ -116,13 +107,6 @@ public: */ GHOST_TSuccess getSwapInterval(int &intervalOut); -protected: - inline void activateEGLEW() const { -#ifdef WITH_GLEW_MX - eglewContext = m_eglewContext; -#endif - } - private: void initContextEGLEW(); @@ -143,10 +127,6 @@ private: EGLint m_swap_interval; -#ifdef WITH_GLEW_MX - EGLEWContext *m_eglewContext; -#endif - EGLContext &m_sharedContext; EGLint &m_sharedCount; diff --git a/intern/ghost/intern/GHOST_ContextGLX.cpp b/intern/ghost/intern/GHOST_ContextGLX.cpp index 60cdce83602..a89b23fe486 100644 --- a/intern/ghost/intern/GHOST_ContextGLX.cpp +++ b/intern/ghost/intern/GHOST_ContextGLX.cpp @@ -48,10 +48,6 @@ static GLuint _glewStrLen(const GLubyte *s); static GLboolean _glewSearchExtension(const char *name, const GLubyte *start, const GLubyte *end); #endif -#ifdef WITH_GLEW_MX -GLXEWContext *glxewContext = NULL; -#endif - GLXContext GHOST_ContextGLX::s_sharedContext = None; int GHOST_ContextGLX::s_sharedCount = 0; @@ -79,10 +75,6 @@ GHOST_ContextGLX::GHOST_ContextGLX( m_contextFlags(contextFlags), m_contextResetNotificationStrategy(contextResetNotificationStrategy), m_context(None) -#ifdef WITH_GLEW_MX - , - m_glxewContext(NULL) -#endif { assert(m_window != 0); assert(m_display != NULL); @@ -109,11 +101,6 @@ GHOST_ContextGLX::~GHOST_ContextGLX() ::glXDestroyContext(m_display, m_context); } } - -#ifdef WITH_GLEW_MX - if (m_glxewContext) - delete m_glxewContext; -#endif } } @@ -129,9 +116,6 @@ GHOST_TSuccess GHOST_ContextGLX::swapBuffers() GHOST_TSuccess GHOST_ContextGLX::activateDrawingContext() { if (m_display) { - activateGLXEW(); - activateGLEW(); - return ::glXMakeCurrent(m_display, m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure; } else { @@ -141,15 +125,6 @@ GHOST_TSuccess GHOST_ContextGLX::activateDrawingContext() void GHOST_ContextGLX::initContextGLXEW() { -#ifdef WITH_GLEW_MX - glxewContext = new GLXEWContext; - memset(glxewContext, 0, sizeof(GLXEWContext)); - - if (m_glxewContext) - delete m_glxewContext; - m_glxewContext = glxewContext; -#endif - initContextGLEW(); } diff --git a/intern/ghost/intern/GHOST_ContextGLX.h b/intern/ghost/intern/GHOST_ContextGLX.h index f0f010d1942..6547a0bd00a 100644 --- a/intern/ghost/intern/GHOST_ContextGLX.h +++ b/intern/ghost/intern/GHOST_ContextGLX.h @@ -34,16 +34,8 @@ #include "GHOST_Context.h" -#ifdef WITH_GLEW_MX -# define glxewGetContext() glxewContext -#endif - #include <GL/glxew.h> -#ifdef WITH_GLEW_MX -extern "C" GLXEWContext *glxewContext; -#endif - #ifndef GHOST_OPENGL_GLX_CONTEXT_FLAGS /* leave as convenience define for the future */ @@ -117,13 +109,6 @@ public: */ GHOST_TSuccess getSwapInterval(int &intervalOut); -protected: - inline void activateGLXEW() const { -#ifdef WITH_GLEW_MX - glxewContext = m_glxewContext; -#endif - } - private: void initContextGLXEW(); @@ -140,10 +125,6 @@ private: GLXContext m_context; -#ifdef WITH_GLEW_MX - GLXEWContext *m_glxewContext; -#endif - /** The first created OpenGL context (for sharing display lists) */ static GLXContext s_sharedContext; static int s_sharedCount; diff --git a/intern/ghost/intern/GHOST_ContextSDL.cpp b/intern/ghost/intern/GHOST_ContextSDL.cpp index 39627fac899..7a02e9743c3 100644 --- a/intern/ghost/intern/GHOST_ContextSDL.cpp +++ b/intern/ghost/intern/GHOST_ContextSDL.cpp @@ -97,8 +97,6 @@ GHOST_TSuccess GHOST_ContextSDL::swapBuffers() GHOST_TSuccess GHOST_ContextSDL::activateDrawingContext() { if (m_context) { - activateGLEW(); - return SDL_GL_MakeCurrent(m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure; } else { diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp index 39ef63fa723..f861631a94e 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cpp +++ b/intern/ghost/intern/GHOST_ContextWGL.cpp @@ -40,10 +40,6 @@ #include <vector> -#ifdef WITH_GLEW_MX -WGLEWContext *wglewContext = NULL; -#endif - HGLRC GHOST_ContextWGL::s_sharedHGLRC = NULL; int GHOST_ContextWGL::s_sharedCount = 0; @@ -82,10 +78,6 @@ GHOST_ContextWGL::GHOST_ContextWGL( m_alphaBackground(alphaBackground), m_contextResetNotificationStrategy(contextResetNotificationStrategy), m_hGLRC(NULL) -#ifdef WITH_GLEW_MX - , - m_wglewContext(NULL) -#endif #ifndef NDEBUG , m_dummyVendor(NULL), @@ -116,10 +108,6 @@ GHOST_ContextWGL::~GHOST_ContextWGL() } } -#ifdef WITH_GLEW_MX - delete m_wglewContext; -#endif - #ifndef NDEBUG free((void*)m_dummyRenderer); free((void*)m_dummyVendor); @@ -158,7 +146,6 @@ GHOST_TSuccess GHOST_ContextWGL::getSwapInterval(int &intervalOut) GHOST_TSuccess GHOST_ContextWGL::activateDrawingContext() { if (WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) { - activateGLEW(); return GHOST_kSuccess; } else { @@ -338,15 +325,6 @@ void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD) int iPixelFormat; - -#ifdef WITH_GLEW_MX - wglewContext = new WGLEWContext; - memset(wglewContext, 0, sizeof(WGLEWContext)); - - delete m_wglewContext; - m_wglewContext = wglewContext; -#endif - SetLastError(NO_ERROR); prevHDC = ::wglGetCurrentDC(); @@ -385,13 +363,8 @@ void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD) if (!WIN32_CHK(::wglMakeCurrent(dummyHDC, dummyHGLRC))) goto finalize; -#ifdef WITH_GLEW_MX - if (GLEW_CHK(wglewInit()) != GLEW_OK) - fprintf(stderr, "Warning! WGLEW failed to initialize properly.\n"); -#else if (GLEW_CHK(glewInit()) != GLEW_OK) fprintf(stderr, "Warning! Dummy GLEW/WGLEW failed to initialize properly.\n"); -#endif // the following are not technially WGLEW, but they also require a context to work @@ -828,8 +801,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext() return GHOST_kFailure; } - activateWGLEW(); - if (WGLEW_ARB_create_context) { int profileBitCore = m_contextProfileMask & WGL_CONTEXT_CORE_PROFILE_BIT_ARB; int profileBitCompat = m_contextProfileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h index 99efcc5ebd7..a07cc1b6301 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.h +++ b/intern/ghost/intern/GHOST_ContextWGL.h @@ -36,16 +36,8 @@ #include "GHOST_Context.h" -#ifdef WITH_GLEW_MX -#define wglewGetContext() wglewContext -#endif - #include <GL/wglew.h> -#ifdef WITH_GLEW_MX -extern "C" WGLEWContext *wglewContext; -#endif - #ifndef GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY #define GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY 0 #endif @@ -113,13 +105,6 @@ public: */ GHOST_TSuccess getSwapInterval(int &intervalOut); -protected: - inline void activateWGLEW() const { -#ifdef WITH_GLEW_MX - wglewContext = m_wglewContext; -#endif - } - private: int choose_pixel_format( bool stereoVisual, @@ -163,10 +148,6 @@ private: const int m_contextResetNotificationStrategy; HGLRC m_hGLRC; - -#ifdef WITH_GLEW_MX - WGLEWContext *m_wglewContext; -#endif #ifndef NDEBUG const char *m_dummyVendor; |