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, ...@@ -197,6 +197,7 @@ gl::Error FramebufferGL::invalidateSub(size_t count, const GLenum *attachments,
gl::Error FramebufferGL::clear(const gl::Data &data, GLbitfield mask) gl::Error FramebufferGL::clear(const gl::Data &data, GLbitfield mask)
{ {
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clear(mask); mFunctions->clear(mask);
...@@ -205,6 +206,7 @@ gl::Error FramebufferGL::clear(const gl::Data &data, GLbitfield 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) gl::Error FramebufferGL::clearBufferfv(const gl::State &state, GLenum buffer, GLint drawbuffer, const GLfloat *values)
{ {
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clearBufferfv(buffer, drawbuffer, values); mFunctions->clearBufferfv(buffer, drawbuffer, values);
...@@ -213,6 +215,7 @@ gl::Error FramebufferGL::clearBufferfv(const gl::State &state, GLenum buffer, GL ...@@ -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) gl::Error FramebufferGL::clearBufferuiv(const gl::State &state, GLenum buffer, GLint drawbuffer, const GLuint *values)
{ {
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clearBufferuiv(buffer, drawbuffer, values); mFunctions->clearBufferuiv(buffer, drawbuffer, values);
...@@ -221,6 +224,7 @@ gl::Error FramebufferGL::clearBufferuiv(const gl::State &state, GLenum buffer, G ...@@ -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) gl::Error FramebufferGL::clearBufferiv(const gl::State &state, GLenum buffer, GLint drawbuffer, const GLint *values)
{ {
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clearBufferiv(buffer, drawbuffer, values); mFunctions->clearBufferiv(buffer, drawbuffer, values);
...@@ -229,6 +233,7 @@ gl::Error FramebufferGL::clearBufferiv(const gl::State &state, GLenum buffer, GL ...@@ -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) gl::Error FramebufferGL::clearBufferfi(const gl::State &state, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
{ {
syncClearState();
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
mFunctions->clearBufferfi(buffer, drawbuffer, depth, stencil); mFunctions->clearBufferfi(buffer, drawbuffer, depth, stencil);
...@@ -290,4 +295,13 @@ GLuint FramebufferGL::getFramebufferID() const ...@@ -290,4 +295,13 @@ GLuint FramebufferGL::getFramebufferID() const
return mFramebufferID; 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 ...@@ -60,6 +60,8 @@ class FramebufferGL : public FramebufferImpl
GLuint getFramebufferID() const; GLuint getFramebufferID() const;
private: private:
void syncClearState();
const FunctionsGL *mFunctions; const FunctionsGL *mFunctions;
StateManagerGL *mStateManager; StateManagerGL *mStateManager;
......
...@@ -90,6 +90,7 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren ...@@ -90,6 +90,7 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren
mClearColor(0.0f, 0.0f, 0.0f, 0.0f), mClearColor(0.0f, 0.0f, 0.0f, 0.0f),
mClearDepth(1.0f), mClearDepth(1.0f),
mClearStencil(0), mClearStencil(0),
mFramebufferSRGBEnabled(false),
mTextureCubemapSeamlessEnabled(false), mTextureCubemapSeamlessEnabled(false),
mLocalDirtyBits() mLocalDirtyBits()
{ {
...@@ -505,6 +506,16 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data) ...@@ -505,6 +506,16 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Data &data)
const FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(framebuffer); const FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(framebuffer);
bindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferGL->getFramebufferID()); 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. // Seamless cubemaps are required for ES3 and higher contexts.
setTextureCubemapSeamlessEnabled(data.clientVersion >= 3); setTextureCubemapSeamlessEnabled(data.clientVersion >= 3);
...@@ -1225,6 +1236,22 @@ void StateManagerGL::syncState(const gl::State &state, const gl::State::DirtyBit ...@@ -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) void StateManagerGL::setTextureCubemapSeamlessEnabled(bool enabled)
{ {
if (mTextureCubemapSeamlessEnabled != enabled) if (mTextureCubemapSeamlessEnabled != enabled)
......
...@@ -109,6 +109,8 @@ class StateManagerGL final : angle::NonCopyable ...@@ -109,6 +109,8 @@ class StateManagerGL final : angle::NonCopyable
GLint skipPixels, GLint skipPixels,
GLuint packBuffer); GLuint packBuffer);
void setFramebufferSRGBEnabled(bool enabled);
gl::Error setDrawArraysState(const gl::Data &data, gl::Error setDrawArraysState(const gl::Data &data,
GLint first, GLint first,
GLsizei count, GLsizei count,
...@@ -213,6 +215,7 @@ class StateManagerGL final : angle::NonCopyable ...@@ -213,6 +215,7 @@ class StateManagerGL final : angle::NonCopyable
float mClearDepth; float mClearDepth;
GLint mClearStencil; GLint mClearStencil;
bool mFramebufferSRGBEnabled;
bool mTextureCubemapSeamlessEnabled; bool mTextureCubemapSeamlessEnabled;
gl::State::DirtyBits mLocalDirtyBits; 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