Commit 6e9018bd by Jonah Ryan-Davis Committed by Commit Bot

GL: Clean up Display code related to multithreading

Rename mCurrentData to mCurrentNativeContexts, and clean up some logic to be easier to read. Bug: angleproject:4724 Change-Id: I6fd6d99d4f9a3af808d0baa665edfbdde7fb0500 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2267424Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
parent 5b8dec52
......@@ -148,6 +148,7 @@ DisplayCGL::DisplayCGL(const egl::DisplayState &state)
: DisplayGL(state),
mEGLDisplay(nullptr),
mContext(nullptr),
mThreadsWithCurrentContext(),
mPixelFormat(nullptr),
mSupportsGPUSwitching(false),
mCurrentGPUID(0),
......
......@@ -113,6 +113,7 @@ DisplayEGL::DisplayEGL(const egl::DisplayState &state)
mRenderer(nullptr),
mEGL(nullptr),
mConfig(EGL_NO_CONFIG_KHR),
mCurrentNativeContexts(),
mHasEXTCreateContextRobustness(false),
mHasNVRobustnessVideoMemoryPurge(false)
{}
......
......@@ -74,6 +74,7 @@ DisplayGLX::DisplayGLX(const egl::DisplayState &state)
mVisuals(nullptr),
mContext(nullptr),
mSharedContext(nullptr),
mCurrentNativeContexts(),
mInitPbuffer(0),
mUsesNewXDisplay(false),
mIsMesa(false),
......@@ -264,7 +265,7 @@ egl::Error DisplayGLX::initialize(egl::Display *display)
}
ASSERT(mContext);
mCurrentContexts[std::this_thread::get_id()] = mContext;
mCurrentNativeContexts[std::this_thread::get_id()] = mContext;
// FunctionsGL and DisplayGL need to make a few GL calls, for example to
// query the version of the context so we need to make the context current.
......@@ -367,7 +368,7 @@ void DisplayGLX::terminate()
}
mWorkerPbufferPool.clear();
mCurrentContexts.clear();
mCurrentNativeContexts.clear();
if (mContext)
{
......@@ -407,14 +408,14 @@ egl::Error DisplayGLX::makeCurrent(egl::Display *display,
newContext = 0;
}
if (newDrawable != mCurrentDrawable ||
newContext != mCurrentContexts[std::this_thread::get_id()])
newContext != mCurrentNativeContexts[std::this_thread::get_id()])
{
if (mGLX.makeCurrent(newDrawable, newContext) != True)
{
return egl::EglContextLost() << "Failed to make the GLX context current";
}
mCurrentContexts[std::this_thread::get_id()] = newContext;
mCurrentDrawable = newDrawable;
mCurrentNativeContexts[std::this_thread::get_id()] = newContext;
mCurrentDrawable = newDrawable;
}
return DisplayGL::makeCurrent(display, drawSurface, readSurface, context);
......
......@@ -126,7 +126,8 @@ class DisplayGLX : public DisplayGL
XVisualInfo *mVisuals;
glx::Context mContext;
glx::Context mSharedContext;
angle::HashMap<std::thread::id, glx::Context> mCurrentContexts;
angle::HashMap<std::thread::id, glx::Context> mCurrentNativeContexts;
// A pbuffer the context is current on during ANGLE initialization
glx::Pbuffer mInitPbuffer;
......
......@@ -90,7 +90,7 @@ class FunctionsGLWindows : public FunctionsGL
DisplayWGL::DisplayWGL(const egl::DisplayState &state)
: DisplayGL(state),
mRenderer(nullptr),
mCurrentData(),
mCurrentNativeContexts(),
mOpenGLModule(nullptr),
mFunctionsWGL(nullptr),
mHasWGLCreateContextRobustness(false),
......@@ -354,7 +354,7 @@ void DisplayWGL::destroy()
mFunctionsWGL->makeCurrent(mDeviceContext, nullptr);
}
}
mCurrentData.clear();
mCurrentNativeContexts.clear();
SafeDelete(mFunctionsWGL);
......@@ -678,18 +678,14 @@ egl::Error DisplayWGL::makeCurrent(egl::Display *display,
egl::Surface *readSurface,
gl::Context *context)
{
CurrentNativeContext &currentContext = mCurrentData[std::this_thread::get_id()];
CurrentNativeContext &currentContext = mCurrentNativeContexts[std::this_thread::get_id()];
HDC newDC = currentContext.dc;
HDC newDC = mDeviceContext;
if (drawSurface)
{
SurfaceWGL *drawSurfaceWGL = GetImplAs<SurfaceWGL>(drawSurface);
newDC = drawSurfaceWGL->getDC();
}
else
{
newDC = mDeviceContext;
}
HGLRC newContext = currentContext.glrc;
if (context)
......@@ -911,7 +907,7 @@ egl::Error DisplayWGL::createRenderer(std::shared_ptr<RendererWGL> *outRenderer)
{
return egl::EglNotInitialized() << "Failed to make the intermediate WGL context current.";
}
CurrentNativeContext &currentContext = mCurrentData[std::this_thread::get_id()];
CurrentNativeContext &currentContext = mCurrentNativeContexts[std::this_thread::get_id()];
currentContext.dc = mDeviceContext;
currentContext.glrc = context;
......
......@@ -118,7 +118,7 @@ class DisplayWGL : public DisplayGL
HDC dc = nullptr;
HGLRC glrc = nullptr;
};
angle::HashMap<std::thread::id, CurrentNativeContext> mCurrentData;
angle::HashMap<std::thread::id, CurrentNativeContext> mCurrentNativeContexts;
HMODULE mOpenGLModule;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment