Commit 84a6c5b2 by Corentin Wallez Committed by Commit Bot

Perform all glXMakeCurrent in DisplayGLX

This allows caching the current surface more efficiently than at the egl layer because we can take advantage of having only one backing context. BUG=angleproject:1651 Change-Id: I62867b16ac5e06901a988dc41a3d4812accdb74c Reviewed-on: https://chromium-review.googlesource.com/543835 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 665e4d97
......@@ -75,6 +75,7 @@ DisplayGLX::DisplayGLX(const egl::DisplayState &state)
mMinSwapInterval(0),
mMaxSwapInterval(0),
mCurrentSwapInterval(-1),
mCurrentDrawable(0),
mXDisplay(nullptr),
mEGLDisplay(nullptr)
{
......@@ -331,6 +332,26 @@ void DisplayGLX::terminate()
SafeDelete(mFunctionsGL);
}
egl::Error DisplayGLX::makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context)
{
if (drawSurface)
{
glx::Drawable drawable = GetImplAs<SurfaceGLX>(drawSurface)->getDrawable();
if (drawable != mCurrentDrawable)
{
if (mGLX.makeCurrent(drawable, mContext) != True)
{
return egl::EglContextLost() << "Failed to make the GLX context current";
}
mCurrentDrawable = drawable;
}
}
return DisplayGL::makeCurrent(drawSurface, readSurface, context);
}
SurfaceImpl *DisplayGLX::createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs)
......@@ -339,7 +360,7 @@ SurfaceImpl *DisplayGLX::createWindowSurface(const egl::SurfaceState &state,
glx::FBConfig fbConfig = configIdToGLXConfig[state.config->configID];
return new WindowSurfaceGLX(state, mGLX, this, getRenderer(), window, mGLX.getDisplay(),
mContext, fbConfig);
fbConfig);
}
SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::SurfaceState &state,
......@@ -352,8 +373,7 @@ SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::SurfaceState &state,
EGLint height = static_cast<EGLint>(attribs.get(EGL_HEIGHT, 0));
bool largest = (attribs.get(EGL_LARGEST_PBUFFER, EGL_FALSE) == EGL_TRUE);
return new PbufferSurfaceGLX(state, getRenderer(), width, height, largest, mGLX, mContext,
fbConfig);
return new PbufferSurfaceGLX(state, getRenderer(), width, height, largest, mGLX, fbConfig);
}
SurfaceImpl *DisplayGLX::createPbufferFromClientBuffer(const egl::SurfaceState &state,
......
......@@ -44,6 +44,10 @@ class DisplayGLX : public DisplayGL
egl::Error initialize(egl::Display *display) override;
void terminate() override;
egl::Error makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context) override;
SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs) override;
......@@ -133,6 +137,8 @@ class DisplayGLX : public DisplayGL
int mMaxSwapInterval;
int mCurrentSwapInterval;
glx::Drawable mCurrentDrawable;
FunctionsGLX mGLX;
Display *mXDisplay;
egl::Display *mEGLDisplay;
......
......@@ -21,14 +21,12 @@ PbufferSurfaceGLX::PbufferSurfaceGLX(const egl::SurfaceState &state,
EGLint height,
bool largest,
const FunctionsGLX &glx,
glx::Context context,
glx::FBConfig fbConfig)
: SurfaceGLX(state, renderer),
mWidth(width),
mHeight(height),
mLargest(largest),
mGLX(glx),
mContext(context),
mFBConfig(fbConfig),
mPbuffer(0)
{
......@@ -75,10 +73,6 @@ egl::Error PbufferSurfaceGLX::initialize(const egl::Display *display)
egl::Error PbufferSurfaceGLX::makeCurrent()
{
if (mGLX.makeCurrent(mPbuffer, mContext) != True)
{
return egl::EglBadDisplay();
}
return egl::NoError();
}
......@@ -144,4 +138,10 @@ egl::Error PbufferSurfaceGLX::checkForResize()
// The size of pbuffers never change
return egl::NoError();
}
glx::Drawable PbufferSurfaceGLX::getDrawable() const
{
return mPbuffer;
}
} // namespace rx
......@@ -26,7 +26,6 @@ class PbufferSurfaceGLX : public SurfaceGLX
EGLint height,
bool largest,
const FunctionsGLX &glx,
glx::Context context,
glx::FBConfig fbConfig);
~PbufferSurfaceGLX() override;
......@@ -51,6 +50,7 @@ class PbufferSurfaceGLX : public SurfaceGLX
EGLint getSwapBehavior() const override;
egl::Error checkForResize() override;
glx::Drawable getDrawable() const override;
private:
unsigned mWidth;
......@@ -58,7 +58,6 @@ class PbufferSurfaceGLX : public SurfaceGLX
bool mLargest;
const FunctionsGLX &mGLX;
glx::Context mContext;
glx::FBConfig mFBConfig;
glx::Pbuffer mPbuffer;
};
......
......@@ -20,6 +20,7 @@ class SurfaceGLX : public SurfaceGL
SurfaceGLX(const egl::SurfaceState &state, RendererGL *renderer) : SurfaceGL(state, renderer) {}
virtual egl::Error checkForResize() = 0;
virtual glx::Drawable getDrawable() const = 0;
};
}
......
......@@ -27,7 +27,6 @@ WindowSurfaceGLX::WindowSurfaceGLX(const egl::SurfaceState &state,
RendererGL *renderer,
Window window,
Display *display,
glx::Context context,
glx::FBConfig fbConfig)
: SurfaceGLX(state, renderer),
mParent(window),
......@@ -35,7 +34,6 @@ WindowSurfaceGLX::WindowSurfaceGLX(const egl::SurfaceState &state,
mDisplay(display),
mGLX(glx),
mGLXDisplay(glxDisplay),
mContext(context),
mFBConfig(fbConfig),
mGLXWindow(0)
{
......@@ -133,10 +131,6 @@ egl::Error WindowSurfaceGLX::initialize(const egl::Display *display)
egl::Error WindowSurfaceGLX::makeCurrent()
{
if (mGLX.makeCurrent(mGLXWindow, mContext) != True)
{
return egl::EglBadDisplay();
}
return egl::NoError();
}
......@@ -235,6 +229,11 @@ egl::Error WindowSurfaceGLX::checkForResize()
return egl::NoError();
}
glx::Drawable WindowSurfaceGLX::getDrawable() const
{
return mGLXWindow;
}
bool WindowSurfaceGLX::getWindowDimensions(Window window, unsigned int *width, unsigned int *height) const
{
Window root;
......
......@@ -28,7 +28,6 @@ class WindowSurfaceGLX : public SurfaceGLX
RendererGL *renderer,
Window window,
Display *display,
glx::Context context,
glx::FBConfig fbConfig);
~WindowSurfaceGLX() override;
......@@ -53,6 +52,7 @@ class WindowSurfaceGLX : public SurfaceGLX
EGLint getSwapBehavior() const override;
egl::Error checkForResize() override;
glx::Drawable getDrawable() const override;
private:
bool getWindowDimensions(Window window, unsigned int *width, unsigned int *height) const;
......@@ -65,7 +65,6 @@ class WindowSurfaceGLX : public SurfaceGLX
const FunctionsGLX &mGLX;
DisplayGLX *mGLXDisplay;
glx::Context mContext;
glx::FBConfig mFBConfig;
glx::Window mGLXWindow;
......
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