From 51eede9ca3ab1d535fc376c29604f971e5d38880 Mon Sep 17 00:00:00 2001 From: Nicolas Capens Date: Wed, 25 Mar 2015 14:03:21 -0400 Subject: [PATCH] Implement EGL_SWAP_BEHAVIOR for eglSurfaceAttrib(). SwiftShader currently always preserves the color buffer on eglSwapBuffers, so both EGL_BUFFER_PRESERVED and EGL_BUFFER_DESTROYED can be used without real changes. Change-Id: I55fcd7d4b4211483d8876c15d3d6ea77ea2685e6 Reviewed-on: https://swiftshader-review.googlesource.com/2721 Reviewed-by: Ping-Hao Wu Reviewed-by: Nicolas Capens Tested-by: Nicolas Capens --- src/OpenGL/libEGL/Surface.cpp | 20 +++++++++++++++----- src/OpenGL/libEGL/Surface.h | 5 ++++- src/OpenGL/libEGL/libEGL.cpp | 20 +++++++++++++++++++- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/OpenGL/libEGL/Surface.cpp b/src/OpenGL/libEGL/Surface.cpp index 7d9998887..466f10f50 100644 --- a/src/OpenGL/libEGL/Surface.cpp +++ b/src/OpenGL/libEGL/Surface.cpp @@ -208,6 +208,11 @@ egl::Image *Surface::getDepthStencil() return mDepthStencil; } +void Surface::setSwapBehavior(EGLenum swapBehavior) +{ + mSwapBehavior = swapBehavior; +} + void Surface::setSwapInterval(EGLint interval) { if(mSwapInterval == interval) @@ -225,6 +230,16 @@ EGLint Surface::getConfigID() const return mConfig->mConfigID; } +EGLenum Surface::getSurfaceType() const +{ + return mConfig->mSurfaceType; +} + +sw::Format Surface::getInternalFormat() const +{ + return mConfig->mRenderTargetFormat; +} + EGLint Surface::getWidth() const { return mWidth; @@ -270,11 +285,6 @@ egl::Texture *Surface::getBoundTexture() const return mTexture; } -sw::Format Surface::getInternalFormat() const -{ - return mConfig->mRenderTargetFormat; -} - bool Surface::checkForResize() { #if defined(_WIN32) diff --git a/src/OpenGL/libEGL/Surface.h b/src/OpenGL/libEGL/Surface.h index 55cbed351..1db6fc1a4 100644 --- a/src/OpenGL/libEGL/Surface.h +++ b/src/OpenGL/libEGL/Surface.h @@ -44,9 +44,13 @@ public: virtual egl::Image *getRenderTarget(); virtual egl::Image *getDepthStencil(); + void setSwapBehavior(EGLenum swapBehavior); void setSwapInterval(EGLint interval); virtual EGLint getConfigID() const; + virtual EGLenum getSurfaceType() const; + virtual sw::Format getInternalFormat() const; + virtual EGLint getWidth() const; virtual EGLint getHeight() const; virtual EGLint getPixelAspectRatio() const; @@ -54,7 +58,6 @@ public: virtual EGLenum getSwapBehavior() const; virtual EGLenum getTextureFormat() const; virtual EGLenum getTextureTarget() const; - virtual sw::Format getInternalFormat() const; virtual void setBoundTexture(egl::Texture *texture); virtual egl::Texture *getBoundTexture() const; diff --git a/src/OpenGL/libEGL/libEGL.cpp b/src/OpenGL/libEGL/libEGL.cpp index 3a3dce9d7..e0163908f 100644 --- a/src/OpenGL/libEGL/libEGL.cpp +++ b/src/OpenGL/libEGL/libEGL.cpp @@ -479,7 +479,25 @@ EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLi return EGL_FALSE; } - UNIMPLEMENTED(); // FIXME + switch(attribute) + { + case EGL_SWAP_BEHAVIOR: + if(value == EGL_BUFFER_PRESERVED) + { + if(!(eglSurface->getSurfaceType() && EGL_SWAP_BEHAVIOR_PRESERVED_BIT)) + { + return error(EGL_BAD_MATCH, EGL_FALSE); + } + } + else if(value != EGL_BUFFER_DESTROYED) + { + return error(EGL_BAD_PARAMETER, EGL_FALSE); + } + eglSurface->setSwapBehavior(value); + break; + default: + UNIMPLEMENTED(); // FIXME + } return success(EGL_TRUE); } -- 2.11.0