Commit 1ee33552 by Courtney Goeltzenleuchter Committed by Commit Bot

Emulate eglSwapBuffersWithDamageKHR when needed

When driver does not support the EGL_KHR_swap_buffers_with_damage extension, call regular eglSwapBuffers instead. BUG=angleproject:2464 Change-Id: Ie3a395d37b61ef5ac65b098b312e9ead1c8bc799 Reviewed-on: https://chromium-review.googlesource.com/1117832 Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 1698d7d4
...@@ -100,7 +100,6 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const ...@@ -100,7 +100,6 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
mEGL->hasExtension("EGL_EXT_create_context_robustness"); mEGL->hasExtension("EGL_EXT_create_context_robustness");
outExtensions->postSubBuffer = false; // Since SurfaceEGL::postSubBuffer is not implemented outExtensions->postSubBuffer = false; // Since SurfaceEGL::postSubBuffer is not implemented
outExtensions->swapBuffersWithDamage = mEGL->hasExtension("EGL_KHR_swap_buffers_with_damage");
outExtensions->presentationTime = mEGL->hasExtension("EGL_ANDROID_presentation_time"); outExtensions->presentationTime = mEGL->hasExtension("EGL_ANDROID_presentation_time");
// Contexts are virtualized so textures can be shared globally // Contexts are virtualized so textures can be shared globally
...@@ -109,6 +108,10 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const ...@@ -109,6 +108,10 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
// Surfaceless contexts are emulated even if there is no native support. // Surfaceless contexts are emulated even if there is no native support.
outExtensions->surfacelessContext = true; outExtensions->surfacelessContext = true;
// We will fallback to regular swap if swapBuffersWithDamage isn't
// supported, so indicate support here to keep validation happy.
outExtensions->swapBuffersWithDamage = true;
DisplayGL::generateExtensions(outExtensions); DisplayGL::generateExtensions(outExtensions);
} }
......
...@@ -14,7 +14,11 @@ namespace rx ...@@ -14,7 +14,11 @@ namespace rx
{ {
SurfaceEGL::SurfaceEGL(const egl::SurfaceState &state, const FunctionsEGL *egl, EGLConfig config) SurfaceEGL::SurfaceEGL(const egl::SurfaceState &state, const FunctionsEGL *egl, EGLConfig config)
: SurfaceGL(state), mEGL(egl), mConfig(config), mSurface(EGL_NO_SURFACE) : SurfaceGL(state),
mEGL(egl),
mConfig(config),
mSurface(EGL_NO_SURFACE),
mHasSwapBuffersWithDamage(mEGL->hasExtension("EGL_KHR_swap_buffers_with_damage"))
{ {
} }
...@@ -45,7 +49,15 @@ egl::Error SurfaceEGL::swap(const gl::Context *context) ...@@ -45,7 +49,15 @@ egl::Error SurfaceEGL::swap(const gl::Context *context)
egl::Error SurfaceEGL::swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects) egl::Error SurfaceEGL::swapWithDamage(const gl::Context *context, EGLint *rects, EGLint n_rects)
{ {
EGLBoolean success = mEGL->swapBuffersWithDamageKHR(mSurface, rects, n_rects); EGLBoolean success;
if (mHasSwapBuffersWithDamage)
{
success = mEGL->swapBuffersWithDamageKHR(mSurface, rects, n_rects);
}
else
{
success = mEGL->swapBuffers(mSurface);
}
if (success == EGL_FALSE) if (success == EGL_FALSE)
{ {
return egl::Error(mEGL->getError(), "eglSwapBuffersWithDamageKHR failed"); return egl::Error(mEGL->getError(), "eglSwapBuffersWithDamageKHR failed");
......
...@@ -49,6 +49,9 @@ class SurfaceEGL : public SurfaceGL ...@@ -49,6 +49,9 @@ class SurfaceEGL : public SurfaceGL
const FunctionsEGL *mEGL; const FunctionsEGL *mEGL;
EGLConfig mConfig; EGLConfig mConfig;
EGLSurface mSurface; EGLSurface mSurface;
private:
bool mHasSwapBuffersWithDamage;
}; };
} // namespace rx } // namespace rx
......
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