Revert "GHOST: Delay opengl context initialization"

This reverts commit 128926a41b.
This commit is contained in:
Clément Foucault 2018-07-02 19:39:50 +02:00
parent 6c9fe9cd8c
commit 433e3db8d8
4 changed files with 8 additions and 31 deletions

View File

@ -18,7 +18,7 @@
#include <mutex>
#include <unordered_set>
#if 0
#if TRUST_NO_ONE
extern "C" {
extern int BLI_thread_is_main(void); // Blender-specific function
}
@ -68,8 +68,7 @@ static void clear_orphans(Gwn_Context* ctx)
Gwn_Context* GWN_context_create(void)
{
#if TRUST_NO_ONE
/* We cannot rely on this anymore. */
// assert(thread_is_main());
assert(thread_is_main());
#endif
Gwn_Context* ctx = new Gwn_Context;
glGenVertexArrays(1, &ctx->default_vao);

View File

@ -110,9 +110,6 @@ GHOST_TSuccess GHOST_ContextGLX::swapBuffers()
GHOST_TSuccess GHOST_ContextGLX::activateDrawingContext()
{
if (m_init == false) {
initContext();
}
if (m_display) {
return ::glXMakeCurrent(m_display, m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure;
}
@ -187,8 +184,7 @@ const bool GLXEW_ARB_create_context_robustness =
glxewInit();
#endif /* USE_GLXEW_INIT_WORKAROUND */
/* Only init the non-offscreen context directly */
const bool do_init = (m_window != None);
if (GLXEW_ARB_create_context) {
int profileBitCore = m_contextProfileMask & GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
@ -308,27 +304,12 @@ const bool GLXEW_ARB_create_context_robustness =
GHOST_TSuccess success;
if (m_context != NULL) {
const unsigned char *version;
if (!s_sharedContext)
s_sharedContext = m_context;
s_sharedCount++;
}
if (do_init) {
success = initContext();
}
GHOST_X11_ERROR_HANDLERS_RESTORE(handler_store);
return success;
}
GHOST_TSuccess GHOST_ContextGLX::initContext()
{
GHOST_TSuccess success;
if (m_context != NULL) {
const unsigned char *version;
glXMakeCurrent(m_display, m_window, m_context);
@ -360,12 +341,13 @@ GHOST_TSuccess GHOST_ContextGLX::initContext()
success = GHOST_kFailure;
}
/* We tag as init even if it fails. */
m_init = true;
GHOST_X11_ERROR_HANDLERS_RESTORE(handler_store);
return success;
}
GHOST_TSuccess GHOST_ContextGLX::releaseNativeHandles()
{
m_window = 0;

View File

@ -116,7 +116,6 @@ public:
private:
void initContextGLXEW();
GHOST_TSuccess initContext();
Display *m_display;
GLXFBConfig m_fbconfig;
@ -129,7 +128,6 @@ private:
const int m_contextResetNotificationStrategy;
GLXContext m_context;
bool m_init;
/** The first created OpenGL context (for sharing display lists) */
static GLXContext s_sharedContext;

View File

@ -2184,8 +2184,6 @@ void DRW_opengl_context_create(void)
}
/* This changes the active context. */
DST.gl_context = WM_opengl_context_create();
/* Make the context active for this thread (main thread) */
WM_opengl_context_activate(DST.gl_context);
/* Be sure to create gawain.context too. */
DST.gwn_context = GWN_context_create();
if (!G.background) {