Revert "GHOST: Unify behavior of offscreen context creation"
Commited by mistake
This reverts commit 6535779c92
.
This commit is contained in:
@@ -767,18 +767,13 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const char *title,
|
||||
*/
|
||||
GHOST_IContext *GHOST_SystemCocoa::createOffscreenContext(GHOST_GLSettings glSettings)
|
||||
{
|
||||
NSOpenGLContext *prevContext = [NSOpenGLContext currentContext];
|
||||
|
||||
GHOST_Context *context = new GHOST_ContextCGL(false, NULL, NULL, NULL);
|
||||
if (context->initializeDrawingContext() == false) {
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
context = nullptr;
|
||||
}
|
||||
/* Restore previously bound context. This is just to follow the win32 behavior. */
|
||||
if (prevContext) {
|
||||
[prevContext makeCurrentContext];
|
||||
}
|
||||
return context;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -141,9 +141,6 @@ uint8_t GHOST_SystemSDL::getNumDisplays() const
|
||||
|
||||
GHOST_IContext *GHOST_SystemSDL::createOffscreenContext(GHOST_GLSettings glSettings)
|
||||
{
|
||||
SDL_GLContext prev_context = SDL_GL_GetCurrentContext();
|
||||
SDL_Window *prev_window = SDL_GL_GetCurrentWindow();
|
||||
|
||||
GHOST_Context *context = new GHOST_ContextSDL(0,
|
||||
NULL,
|
||||
0, /* Profile bit. */
|
||||
@@ -152,18 +149,12 @@ GHOST_IContext *GHOST_SystemSDL::createOffscreenContext(GHOST_GLSettings glSetti
|
||||
GHOST_OPENGL_SDL_CONTEXT_FLAGS,
|
||||
GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
/* Pass */
|
||||
}
|
||||
else {
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
context = nullptr;
|
||||
}
|
||||
|
||||
if (m_context) {
|
||||
SDL_GL_MakeCurrent(prev_window, prev_context);
|
||||
}
|
||||
return context;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_SystemSDL::disposeContext(GHOST_IContext *context)
|
||||
|
@@ -1599,47 +1599,45 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g
|
||||
|
||||
GHOST_Context *context;
|
||||
|
||||
EGLDisplay prev_display = eglGetCurrentDisplay();
|
||||
/* It doesn't matter which one we query since we use the same surface for both read and write. */
|
||||
EGLSurface prev_surface = eglGetCurrentSurface(EGL_DRAW);
|
||||
EGLContext prev_context = eglGetCurrentContext();
|
||||
|
||||
const int versions[][2] = {{4, 6}, {4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0}, {3, 3}};
|
||||
const int versions_len = sizeof(versions) / sizeof(versions[0]);
|
||||
|
||||
for (int i = 0; i < versions_len; i++) {
|
||||
int major = versions[i][0];
|
||||
int minor = versions[i][1];
|
||||
|
||||
for (int minor = 6; minor >= 0; --minor) {
|
||||
context = new GHOST_ContextEGL(this,
|
||||
false,
|
||||
EGLNativeWindowType(os_egl_window),
|
||||
EGLNativeDisplayType(d->display),
|
||||
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
|
||||
major,
|
||||
4,
|
||||
minor,
|
||||
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
|
||||
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
|
||||
EGL_OPENGL_API);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
context = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (context == nullptr) {
|
||||
GHOST_PRINT("Cannot create off-screen EGL context" << std::endl);
|
||||
context = new GHOST_ContextEGL(this,
|
||||
false,
|
||||
EGLNativeWindowType(os_egl_window),
|
||||
EGLNativeDisplayType(d->display),
|
||||
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
|
||||
3,
|
||||
3,
|
||||
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
|
||||
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
|
||||
EGL_OPENGL_API);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
}
|
||||
else {
|
||||
delete context;
|
||||
}
|
||||
|
||||
if (prev_context) {
|
||||
/* Restore previously bound context. This is just to follow the win32 behavior. */
|
||||
eglMakeCurrent(prev_display, prev_surface, prev_surface, prev_context);
|
||||
}
|
||||
return context;
|
||||
GHOST_PRINT("Cannot create off-screen EGL context" << std::endl);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_SystemWayland::disposeContext(GHOST_IContext *context)
|
||||
|
@@ -284,36 +284,69 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GLSettings glSet
|
||||
HDC mHDC = GetDC(wnd);
|
||||
HDC prev_hdc = wglGetCurrentDC();
|
||||
HGLRC prev_context = wglGetCurrentContext();
|
||||
|
||||
const int versions[][2] = {{4, 6}, {4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0}, {3, 3}};
|
||||
const int versions_len = sizeof(versions) / sizeof(versions[0]);
|
||||
|
||||
for (int i = 0; i < versions_len; i++) {
|
||||
int major = versions[i][0];
|
||||
int minor = versions[i][1];
|
||||
|
||||
#if defined(WITH_GL_PROFILE_CORE)
|
||||
for (int minor = 5; minor >= 0; --minor) {
|
||||
context = new GHOST_ContextWGL(false,
|
||||
true,
|
||||
wnd,
|
||||
mHDC,
|
||||
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
major,
|
||||
4,
|
||||
minor,
|
||||
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
break;
|
||||
goto finished;
|
||||
}
|
||||
else {
|
||||
delete context;
|
||||
context = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_context) {
|
||||
wglMakeCurrent(prev_hdc, prev_context);
|
||||
context = new GHOST_ContextWGL(false,
|
||||
true,
|
||||
wnd,
|
||||
mHDC,
|
||||
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
3,
|
||||
3,
|
||||
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
goto finished;
|
||||
}
|
||||
else {
|
||||
delete context;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||
// ask for 2.1 context, driver gives any GL version >= 2.1
|
||||
// (hopefully the latest compatibility profile)
|
||||
// 2.1 ignores the profile bit & is incompatible with core profile
|
||||
context = new GHOST_ContextWGL(false,
|
||||
true,
|
||||
NULL,
|
||||
NULL,
|
||||
0, // no profile bit
|
||||
2,
|
||||
1,
|
||||
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
return context;
|
||||
}
|
||||
else {
|
||||
delete context;
|
||||
}
|
||||
#else
|
||||
# error // must specify either core or compat at build time
|
||||
#endif
|
||||
finished:
|
||||
wglMakeCurrent(prev_hdc, prev_context);
|
||||
return context;
|
||||
}
|
||||
|
||||
|
@@ -437,32 +437,16 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(WITH_GL_EGL)
|
||||
EGLDisplay prev_display = eglGetCurrentDisplay();
|
||||
/* It doesn't matter which one we query since we use the same surface for both read and write. */
|
||||
EGLSurface prev_surface = eglGetCurrentSurface(EGL_DRAW);
|
||||
EGLContext prev_context = eglGetCurrentContext();
|
||||
#else
|
||||
Display *prev_display = glXGetCurrentDisplay();
|
||||
GLXDrawable prev_drawable = glXGetCurrentDrawable();
|
||||
GLXContext prev_context = glXGetCurrentContext();
|
||||
#endif
|
||||
|
||||
GHOST_Context *context;
|
||||
|
||||
const int versions[][2] = {{4, 6}, {4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0}, {3, 3}};
|
||||
const int versions_len = sizeof(versions) / sizeof(versions[0]);
|
||||
|
||||
for (int i = 0; i < versions_len; i++) {
|
||||
int major = versions[i][0];
|
||||
int minor = versions[i][1];
|
||||
for (int minor = 5; minor >= 0; --minor) {
|
||||
#if defined(WITH_GL_EGL)
|
||||
context = new GHOST_ContextEGL(this,
|
||||
false,
|
||||
EGLNativeWindowType(nullptr),
|
||||
EGLNativeDisplayType(m_display),
|
||||
profile_mask,
|
||||
major,
|
||||
4,
|
||||
minor,
|
||||
GHOST_OPENGL_EGL_CONTEXT_FLAGS |
|
||||
(debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
|
||||
@@ -474,31 +458,50 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti
|
||||
m_display,
|
||||
(GLXFBConfig)NULL,
|
||||
profile_mask,
|
||||
major,
|
||||
4,
|
||||
minor,
|
||||
GHOST_OPENGL_GLX_CONTEXT_FLAGS |
|
||||
(debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
#endif
|
||||
|
||||
if (context->initializeDrawingContext()) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
context = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_context) {
|
||||
/* Restore previously bound context. This is just to follow the win32 behavior. */
|
||||
#if defined(WITH_GL_EGL)
|
||||
eglMakeCurrent(prev_display, prev_surface, prev_surface, prev_context);
|
||||
context = new GHOST_ContextEGL(this,
|
||||
false,
|
||||
EGLNativeWindowType(nullptr),
|
||||
EGLNativeDisplayType(m_display),
|
||||
profile_mask,
|
||||
3,
|
||||
3,
|
||||
GHOST_OPENGL_EGL_CONTEXT_FLAGS |
|
||||
(debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
|
||||
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
|
||||
EGL_OPENGL_API);
|
||||
#else
|
||||
glXMakeCurrent(prev_display, prev_drawable, prev_context);
|
||||
context = new GHOST_ContextGLX(false,
|
||||
(Window)NULL,
|
||||
m_display,
|
||||
(GLXFBConfig)NULL,
|
||||
profile_mask,
|
||||
3,
|
||||
3,
|
||||
GHOST_OPENGL_GLX_CONTEXT_FLAGS |
|
||||
(debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
#endif
|
||||
}
|
||||
return context;
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user