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) ...@@ -75,6 +75,7 @@ DisplayGLX::DisplayGLX(const egl::DisplayState &state)
mMinSwapInterval(0), mMinSwapInterval(0),
mMaxSwapInterval(0), mMaxSwapInterval(0),
mCurrentSwapInterval(-1), mCurrentSwapInterval(-1),
mCurrentDrawable(0),
mXDisplay(nullptr), mXDisplay(nullptr),
mEGLDisplay(nullptr) mEGLDisplay(nullptr)
{ {
...@@ -331,6 +332,26 @@ void DisplayGLX::terminate() ...@@ -331,6 +332,26 @@ void DisplayGLX::terminate()
SafeDelete(mFunctionsGL); 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, SurfaceImpl *DisplayGLX::createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
...@@ -339,7 +360,7 @@ SurfaceImpl *DisplayGLX::createWindowSurface(const egl::SurfaceState &state, ...@@ -339,7 +360,7 @@ SurfaceImpl *DisplayGLX::createWindowSurface(const egl::SurfaceState &state,
glx::FBConfig fbConfig = configIdToGLXConfig[state.config->configID]; glx::FBConfig fbConfig = configIdToGLXConfig[state.config->configID];
return new WindowSurfaceGLX(state, mGLX, this, getRenderer(), window, mGLX.getDisplay(), return new WindowSurfaceGLX(state, mGLX, this, getRenderer(), window, mGLX.getDisplay(),
mContext, fbConfig); fbConfig);
} }
SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayGLX::createPbufferSurface(const egl::SurfaceState &state,
...@@ -352,8 +373,7 @@ 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)); EGLint height = static_cast<EGLint>(attribs.get(EGL_HEIGHT, 0));
bool largest = (attribs.get(EGL_LARGEST_PBUFFER, EGL_FALSE) == EGL_TRUE); bool largest = (attribs.get(EGL_LARGEST_PBUFFER, EGL_FALSE) == EGL_TRUE);
return new PbufferSurfaceGLX(state, getRenderer(), width, height, largest, mGLX, mContext, return new PbufferSurfaceGLX(state, getRenderer(), width, height, largest, mGLX, fbConfig);
fbConfig);
} }
SurfaceImpl *DisplayGLX::createPbufferFromClientBuffer(const egl::SurfaceState &state, SurfaceImpl *DisplayGLX::createPbufferFromClientBuffer(const egl::SurfaceState &state,
......
...@@ -44,6 +44,10 @@ class DisplayGLX : public DisplayGL ...@@ -44,6 +44,10 @@ class DisplayGLX : public DisplayGL
egl::Error initialize(egl::Display *display) override; egl::Error initialize(egl::Display *display) override;
void terminate() override; void terminate() override;
egl::Error makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context) override;
SurfaceImpl *createWindowSurface(const egl::SurfaceState &state, SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window,
const egl::AttributeMap &attribs) override; const egl::AttributeMap &attribs) override;
...@@ -133,6 +137,8 @@ class DisplayGLX : public DisplayGL ...@@ -133,6 +137,8 @@ class DisplayGLX : public DisplayGL
int mMaxSwapInterval; int mMaxSwapInterval;
int mCurrentSwapInterval; int mCurrentSwapInterval;
glx::Drawable mCurrentDrawable;
FunctionsGLX mGLX; FunctionsGLX mGLX;
Display *mXDisplay; Display *mXDisplay;
egl::Display *mEGLDisplay; egl::Display *mEGLDisplay;
......
...@@ -21,14 +21,12 @@ PbufferSurfaceGLX::PbufferSurfaceGLX(const egl::SurfaceState &state, ...@@ -21,14 +21,12 @@ PbufferSurfaceGLX::PbufferSurfaceGLX(const egl::SurfaceState &state,
EGLint height, EGLint height,
bool largest, bool largest,
const FunctionsGLX &glx, const FunctionsGLX &glx,
glx::Context context,
glx::FBConfig fbConfig) glx::FBConfig fbConfig)
: SurfaceGLX(state, renderer), : SurfaceGLX(state, renderer),
mWidth(width), mWidth(width),
mHeight(height), mHeight(height),
mLargest(largest), mLargest(largest),
mGLX(glx), mGLX(glx),
mContext(context),
mFBConfig(fbConfig), mFBConfig(fbConfig),
mPbuffer(0) mPbuffer(0)
{ {
...@@ -75,10 +73,6 @@ egl::Error PbufferSurfaceGLX::initialize(const egl::Display *display) ...@@ -75,10 +73,6 @@ egl::Error PbufferSurfaceGLX::initialize(const egl::Display *display)
egl::Error PbufferSurfaceGLX::makeCurrent() egl::Error PbufferSurfaceGLX::makeCurrent()
{ {
if (mGLX.makeCurrent(mPbuffer, mContext) != True)
{
return egl::EglBadDisplay();
}
return egl::NoError(); return egl::NoError();
} }
...@@ -144,4 +138,10 @@ egl::Error PbufferSurfaceGLX::checkForResize() ...@@ -144,4 +138,10 @@ egl::Error PbufferSurfaceGLX::checkForResize()
// The size of pbuffers never change // The size of pbuffers never change
return egl::NoError(); return egl::NoError();
} }
glx::Drawable PbufferSurfaceGLX::getDrawable() const
{
return mPbuffer;
}
} // namespace rx } // namespace rx
...@@ -26,7 +26,6 @@ class PbufferSurfaceGLX : public SurfaceGLX ...@@ -26,7 +26,6 @@ class PbufferSurfaceGLX : public SurfaceGLX
EGLint height, EGLint height,
bool largest, bool largest,
const FunctionsGLX &glx, const FunctionsGLX &glx,
glx::Context context,
glx::FBConfig fbConfig); glx::FBConfig fbConfig);
~PbufferSurfaceGLX() override; ~PbufferSurfaceGLX() override;
...@@ -51,6 +50,7 @@ class PbufferSurfaceGLX : public SurfaceGLX ...@@ -51,6 +50,7 @@ class PbufferSurfaceGLX : public SurfaceGLX
EGLint getSwapBehavior() const override; EGLint getSwapBehavior() const override;
egl::Error checkForResize() override; egl::Error checkForResize() override;
glx::Drawable getDrawable() const override;
private: private:
unsigned mWidth; unsigned mWidth;
...@@ -58,7 +58,6 @@ class PbufferSurfaceGLX : public SurfaceGLX ...@@ -58,7 +58,6 @@ class PbufferSurfaceGLX : public SurfaceGLX
bool mLargest; bool mLargest;
const FunctionsGLX &mGLX; const FunctionsGLX &mGLX;
glx::Context mContext;
glx::FBConfig mFBConfig; glx::FBConfig mFBConfig;
glx::Pbuffer mPbuffer; glx::Pbuffer mPbuffer;
}; };
......
...@@ -20,6 +20,7 @@ class SurfaceGLX : public SurfaceGL ...@@ -20,6 +20,7 @@ class SurfaceGLX : public SurfaceGL
SurfaceGLX(const egl::SurfaceState &state, RendererGL *renderer) : SurfaceGL(state, renderer) {} SurfaceGLX(const egl::SurfaceState &state, RendererGL *renderer) : SurfaceGL(state, renderer) {}
virtual egl::Error checkForResize() = 0; virtual egl::Error checkForResize() = 0;
virtual glx::Drawable getDrawable() const = 0;
}; };
} }
......
...@@ -27,7 +27,6 @@ WindowSurfaceGLX::WindowSurfaceGLX(const egl::SurfaceState &state, ...@@ -27,7 +27,6 @@ WindowSurfaceGLX::WindowSurfaceGLX(const egl::SurfaceState &state,
RendererGL *renderer, RendererGL *renderer,
Window window, Window window,
Display *display, Display *display,
glx::Context context,
glx::FBConfig fbConfig) glx::FBConfig fbConfig)
: SurfaceGLX(state, renderer), : SurfaceGLX(state, renderer),
mParent(window), mParent(window),
...@@ -35,7 +34,6 @@ WindowSurfaceGLX::WindowSurfaceGLX(const egl::SurfaceState &state, ...@@ -35,7 +34,6 @@ WindowSurfaceGLX::WindowSurfaceGLX(const egl::SurfaceState &state,
mDisplay(display), mDisplay(display),
mGLX(glx), mGLX(glx),
mGLXDisplay(glxDisplay), mGLXDisplay(glxDisplay),
mContext(context),
mFBConfig(fbConfig), mFBConfig(fbConfig),
mGLXWindow(0) mGLXWindow(0)
{ {
...@@ -133,10 +131,6 @@ egl::Error WindowSurfaceGLX::initialize(const egl::Display *display) ...@@ -133,10 +131,6 @@ egl::Error WindowSurfaceGLX::initialize(const egl::Display *display)
egl::Error WindowSurfaceGLX::makeCurrent() egl::Error WindowSurfaceGLX::makeCurrent()
{ {
if (mGLX.makeCurrent(mGLXWindow, mContext) != True)
{
return egl::EglBadDisplay();
}
return egl::NoError(); return egl::NoError();
} }
...@@ -235,6 +229,11 @@ egl::Error WindowSurfaceGLX::checkForResize() ...@@ -235,6 +229,11 @@ egl::Error WindowSurfaceGLX::checkForResize()
return egl::NoError(); return egl::NoError();
} }
glx::Drawable WindowSurfaceGLX::getDrawable() const
{
return mGLXWindow;
}
bool WindowSurfaceGLX::getWindowDimensions(Window window, unsigned int *width, unsigned int *height) const bool WindowSurfaceGLX::getWindowDimensions(Window window, unsigned int *width, unsigned int *height) const
{ {
Window root; Window root;
......
...@@ -28,7 +28,6 @@ class WindowSurfaceGLX : public SurfaceGLX ...@@ -28,7 +28,6 @@ class WindowSurfaceGLX : public SurfaceGLX
RendererGL *renderer, RendererGL *renderer,
Window window, Window window,
Display *display, Display *display,
glx::Context context,
glx::FBConfig fbConfig); glx::FBConfig fbConfig);
~WindowSurfaceGLX() override; ~WindowSurfaceGLX() override;
...@@ -53,6 +52,7 @@ class WindowSurfaceGLX : public SurfaceGLX ...@@ -53,6 +52,7 @@ class WindowSurfaceGLX : public SurfaceGLX
EGLint getSwapBehavior() const override; EGLint getSwapBehavior() const override;
egl::Error checkForResize() override; egl::Error checkForResize() override;
glx::Drawable getDrawable() const override;
private: private:
bool getWindowDimensions(Window window, unsigned int *width, unsigned int *height) const; bool getWindowDimensions(Window window, unsigned int *width, unsigned int *height) const;
...@@ -65,7 +65,6 @@ class WindowSurfaceGLX : public SurfaceGLX ...@@ -65,7 +65,6 @@ class WindowSurfaceGLX : public SurfaceGLX
const FunctionsGLX &mGLX; const FunctionsGLX &mGLX;
DisplayGLX *mGLXDisplay; DisplayGLX *mGLXDisplay;
glx::Context mContext;
glx::FBConfig mFBConfig; glx::FBConfig mFBConfig;
glx::Window mGLXWindow; 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