Commit 04b89c97 by Geoff Lang

Explicitly enable framebuffer SRGB blending in StateManagerGL.

In DesktopGL, SRGB blending must be enabled or linear blending will be used. Passes all dEQP-GLES3.functional.fragment_ops.blend.fbo_srgb.* tests (1106 new passing tests). BUG=angleproject:883 BUG=angleproject:885 Change-Id: I0dfb744faa811f10be47c5bd8295b368baf3b04b Reviewed-on: https://chromium-review.googlesource.com/298620Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 83f349ea
......@@ -197,6 +197,7 @@ gl::Error FramebufferGL::invalidateSub(size_t count, const GLenum *attachments,
gl::Error FramebufferGL::clear(const gl::Data &data, GLbitfield mask)
{
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clear(mask);
......@@ -205,6 +206,7 @@ gl::Error FramebufferGL::clear(const gl::Data &data, GLbitfield mask)
gl::Error FramebufferGL::clearBufferfv(const gl::State &state, GLenum buffer, GLint drawbuffer, const GLfloat *values)
{
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clearBufferfv(buffer, drawbuffer, values);
......@@ -213,6 +215,7 @@ gl::Error FramebufferGL::clearBufferfv(const gl::State &state, GLenum buffer, GL
gl::Error FramebufferGL::clearBufferuiv(const gl::State &state, GLenum buffer, GLint drawbuffer, const GLuint *values)
{
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clearBufferuiv(buffer, drawbuffer, values);
......@@ -221,6 +224,7 @@ gl::Error FramebufferGL::clearBufferuiv(const gl::State &state, GLenum buffer, G
gl::Error FramebufferGL::clearBufferiv(const gl::State &state, GLenum buffer, GLint drawbuffer, const GLint *values)
{
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clearBufferiv(buffer, drawbuffer, values);
......@@ -229,6 +233,7 @@ gl::Error FramebufferGL::clearBufferiv(const gl::State &state, GLenum buffer, GL
gl::Error FramebufferGL::clearBufferfi(const gl::State &state, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
{
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clearBufferfi(buffer, drawbuffer, depth, stencil);
......@@ -290,4 +295,13 @@ GLuint FramebufferGL::getFramebufferID() const
return mFramebufferID;
}
void FramebufferGL::syncClearState()
{
if (mFunctions->standard == STANDARD_GL_DESKTOP)
{
// TODO(geofflang): Update this when the framebuffer binding dirty changes, when it exists
// (see StateManagerGL.cpp)
mStateManager->setFramebufferSRGBEnabled(mFramebufferID != 0);
}
}
}
......@@ -60,6 +60,8 @@ class FramebufferGL : public FramebufferImpl
GLuint getFramebufferID() const;
private:
void syncClearState();
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
......
......@@ -90,6 +90,7 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren
mClearColor(0.0f, 0.0f, 0.0f, 0.0f),
mClearDepth(1.0f),
mClearStencil(0),
mFramebufferSRGBEnabled(false),
mTextureCubemapSeamlessEnabled(false),
mLocalDirtyBits()
{
......@@ -505,6 +506,16 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data)
const FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(framebuffer);
bindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferGL->getFramebufferID());
if (mFunctions->standard == STANDARD_GL_DESKTOP)
{
// Enable SRGB blending for all framebuffers except the default framebuffer on Desktop
// OpenGL.
// When SRGB blending is enabled, only SRGB capable formats will use it but the default
// framebuffer will always use it if it is enabled.
// TODO(geofflang): Update this when the framebuffer binding dirty changes, when it exists.
setFramebufferSRGBEnabled(framebufferGL->getFramebufferID() != 0);
}
// Seamless cubemaps are required for ES3 and higher contexts.
setTextureCubemapSeamlessEnabled(data.clientVersion >= 3);
......@@ -1225,6 +1236,22 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit
}
}
void StateManagerGL::setFramebufferSRGBEnabled(bool enabled)
{
if (mFramebufferSRGBEnabled != enabled)
{
mFramebufferSRGBEnabled = enabled;
if (mFramebufferSRGBEnabled)
{
mFunctions->enable(GL_FRAMEBUFFER_SRGB);
}
else
{
mFunctions->disable(GL_FRAMEBUFFER_SRGB);
}
}
}
void StateManagerGL::setTextureCubemapSeamlessEnabled(bool enabled)
{
if (mTextureCubemapSeamlessEnabled != enabled)
......
......@@ -109,6 +109,8 @@ class StateManagerGL final : angle::NonCopyable
GLint skipPixels,
GLuint packBuffer);
void setFramebufferSRGBEnabled(bool enabled);
gl::Error setDrawArraysState(const gl::Data &data,
GLint first,
GLsizei count,
......@@ -213,6 +215,7 @@ class StateManagerGL final : angle::NonCopyable
float mClearDepth;
GLint mClearStencil;
bool mFramebufferSRGBEnabled;
bool mTextureCubemapSeamlessEnabled;
gl::State::DirtyBits mLocalDirtyBits;
......
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