From ef640ecf1004f7af9cfde09f5ce1cde2fb70747f Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Sat, 22 Apr 2017 00:35:04 -0400 Subject: 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. --- intern/cycles/blender/blender_sync.cpp | 13 ++----- intern/cycles/util/util_opengl.h | 8 +---- intern/cycles/util/util_view.cpp | 2 +- intern/ghost/intern/GHOST_Context.cpp | 6 +--- intern/ghost/intern/GHOST_Context.h | 11 +----- intern/ghost/intern/GHOST_ContextCGL.h | 13 ------- intern/ghost/intern/GHOST_ContextCGL.mm | 3 -- intern/ghost/intern/GHOST_ContextEGL.cpp | 33 ++---------------- intern/ghost/intern/GHOST_ContextEGL.h | 20 ----------- intern/ghost/intern/GHOST_ContextGLX.cpp | 25 -------------- intern/ghost/intern/GHOST_ContextGLX.h | 19 ----------- intern/ghost/intern/GHOST_ContextSDL.cpp | 2 -- intern/ghost/intern/GHOST_ContextWGL.cpp | 29 ---------------- intern/ghost/intern/GHOST_ContextWGL.h | 19 ----------- intern/glew-mx/glew-mx.h | 29 ---------------- intern/glew-mx/intern/glew-mx.c | 58 -------------------------------- 16 files changed, 8 insertions(+), 282 deletions(-) (limited to 'intern') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 3b071bf0e7d..5926b2a04a6 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -710,17 +710,8 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine, params.shadingsystem = SHADINGSYSTEM_OSL; /* color managagement */ -#ifdef GLEW_MX - /* When using GLEW MX we need to check whether we've got an OpenGL - * context for current window. This is because command line rendering - * doesn't have OpenGL context actually. - */ - if(glewGetContext() != NULL) -#endif - { - params.display_buffer_linear = GLEW_ARB_half_float_pixel && - b_engine.support_display_space_shader(b_scene); - } + params.display_buffer_linear = GLEW_ARB_half_float_pixel && + b_engine.support_display_space_shader(b_scene); if(b_engine.is_preview()) { /* For preview rendering we're using same timeout as diff --git a/intern/cycles/util/util_opengl.h b/intern/cycles/util/util_opengl.h index 0b5462e0a09..7a8d5eec1f9 100644 --- a/intern/cycles/util/util_opengl.h +++ b/intern/cycles/util/util_opengl.h @@ -20,12 +20,6 @@ /* OpenGL header includes, used everywhere we use OpenGL, to deal with * platform differences in one central place. */ -#ifdef WITH_GLEW_MX -# include "glew-mx.h" -#else -# include -# define mxCreateContext() glewInit() -# define mxMakeCurrentContext(x) (x) -#endif +#include #endif /* __UTIL_OPENGL_H__ */ diff --git a/intern/cycles/util/util_view.cpp b/intern/cycles/util/util_view.cpp index 10d86167921..7b453d123b8 100644 --- a/intern/cycles/util/util_view.cpp +++ b/intern/cycles/util/util_view.cpp @@ -252,7 +252,7 @@ void view_main_loop(const char *title, int width, int height, glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH); glutCreateWindow(title); - mxMakeCurrentContext(mxCreateContext()); + glewInit(); view_reshape(width, height); 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 -//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 -#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 -#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 -#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 -#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 -#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; diff --git a/intern/glew-mx/glew-mx.h b/intern/glew-mx/glew-mx.h index 813e95958b5..86f48a1068d 100644 --- a/intern/glew-mx/glew-mx.h +++ b/intern/glew-mx/glew-mx.h @@ -49,12 +49,6 @@ #ifndef __GLEW_MX_H__ #define __GLEW_MX_H__ -#ifdef WITH_GLEW_MX -/* glew itself expects this */ -# define GLEW_MX 1 -# define glewGetContext() (&(_mx_context->glew_context)) -#endif - #include @@ -62,23 +56,6 @@ extern "C" { #endif -/* MXContext is used instead of GLEWContext directly so that - extending what data is held by a context is easier. - */ -typedef struct MXContext { -#ifdef WITH_GLEW_MX - GLEWContext glew_context; -#endif - - int reserved; /* structs need at least one member */ - -} MXContext; - -#ifdef WITH_GLEW_MX -extern MXContext *_mx_context; -#endif - - #include "intern/symbol-binding.h" @@ -89,12 +66,6 @@ extern MXContext *_mx_context; # include "intern/gl-deprecated.h" #endif - -MXContext *mxCreateContext (void); -MXContext *mxGetCurrentContext (void); -void mxMakeCurrentContext(MXContext *ctx); -void mxDestroyContext (MXContext *ctx); - GLenum glew_chk(GLenum error, const char *file, int line, const char *text); #ifndef NDEBUG diff --git a/intern/glew-mx/intern/glew-mx.c b/intern/glew-mx/intern/glew-mx.c index 6fbb1a7a2e2..9db2d233085 100644 --- a/intern/glew-mx/intern/glew-mx.c +++ b/intern/glew-mx/intern/glew-mx.c @@ -84,61 +84,3 @@ GLenum glew_chk(GLenum error, const char *file, int line, const char *text) return error; } - - -#ifdef WITH_GLEW_MX -MXContext *_mx_context = NULL; -#endif - - -MXContext *mxCreateContext(void) -{ -#ifdef WITH_GLEW_MX - MXContext* new_ctx = calloc(1, sizeof(MXContext)); - - if (new_ctx != NULL) { - MXContext* cur_ctx = _mx_context; - _mx_context = new_ctx; - GLEW_CHK(glewInit()); - _mx_context = cur_ctx; - } - - return new_ctx; -#else - GLEW_CHK(glewInit()); - return NULL; -#endif -} - - -MXContext *mxGetCurrentContext(void) -{ -#ifdef WITH_GLEW_MX - return _mx_context; -#else - return NULL; -#endif -} - - -void mxMakeCurrentContext(MXContext *ctx) -{ -#ifdef WITH_GLEW_MX - _mx_context = ctx; -#else - (void)ctx; -#endif -} - - -void mxDestroyContext(MXContext *ctx) -{ -#ifdef WITH_GLEW_MX - if (_mx_context == ctx) - _mx_context = NULL; - - free(ctx); -#else - (void)ctx; -#endif -} -- cgit v1.2.3