Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Issue 2246823002: Disable FRAMEBUFFER_SRGB when restoring from a null context state (Closed)

Created:
4 years, 4 months ago by qiankun
Modified:
4 years, 4 months ago
CC:
chromium-reviews, piman+watch_chromium.org, Geoff Lang, Jamie Madill, Corentin Wallez
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Disable FRAMEBUFFER_SRGB when restoring from a null context state In the following case, FRAMEBUFFER_SRGB state in driver will not be correct: 1. FRAMEBUFFER_SRGB is enabled for sRGB framebuffer. 2. restore from a null context, framebuffer_srgb_ will be false after restoring. But FRAMEBUFFER_SRGB will not be changed if we call EnableDisableFramebufferSRGB(false) to disable FRAMEBUFFER_SRGB, because the function will return early at "if (framebuffer_srgb_ == enable)". This CL disable FRAMEBUFFER_SRGB when restoring from a null context state. BUG=540900, 637801 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Committed: https://crrev.com/a8fe152031cea3017f7dd41990d7e46d49a2ce51 Cr-Commit-Position: refs/heads/master@{#413291}

Patch Set 1 #

Patch Set 2 : fix gl_tests on windows #

Total comments: 5

Patch Set 3 : disable FRAMEBUFFER_SRGB at context initialization time #

Patch Set 4 : fix gpu_unittests #

Total comments: 2

Patch Set 5 : Disable FRAMEBUFFER_SRGB when restoring from a null context state #

Total comments: 2

Patch Set 6 : set framebuffer_srgb_ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+6 lines, -1 line) Patch
M gpu/command_buffer/service/context_state.cc View 1 2 3 4 5 1 chunk +6 lines, -1 line 0 comments Download

Messages

Total messages: 46 (15 generated)
qiankun
I uploaded two patch sets to fix the attached bug. Intuitively, PS1 is very simple. ...
4 years, 4 months ago (2016-08-15 09:45:18 UTC) #8
Zhenyao Mo
https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h File gpu/command_buffer/service/context_state.h (right): https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h#newcode157 gpu/command_buffer/service/context_state.h:157: FRAMEBUFFER_SRGB_UNDEFINED, Do we really need this? If the prev_context ...
4 years, 4 months ago (2016-08-15 22:37:27 UTC) #9
qiankun
https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h File gpu/command_buffer/service/context_state.h (right): https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h#newcode157 gpu/command_buffer/service/context_state.h:157: FRAMEBUFFER_SRGB_UNDEFINED, On 2016/08/15 22:37:27, Zhenyao Mo wrote: > Do ...
4 years, 4 months ago (2016-08-15 23:01:07 UTC) #10
Ken Russell (switch to Gerrit)
I defer to zmo@'s review. If this has been tested then it seems fine to ...
4 years, 4 months ago (2016-08-16 01:58:45 UTC) #11
Zhenyao Mo
https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h File gpu/command_buffer/service/context_state.h (right): https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h#newcode157 gpu/command_buffer/service/context_state.h:157: FRAMEBUFFER_SRGB_UNDEFINED, On 2016/08/15 23:01:06, qiankun wrote: > On 2016/08/15 ...
4 years, 4 months ago (2016-08-16 17:16:48 UTC) #12
qiankun
https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h File gpu/command_buffer/service/context_state.h (right): https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h#newcode157 gpu/command_buffer/service/context_state.h:157: FRAMEBUFFER_SRGB_UNDEFINED, On 2016/08/16 17:16:48, Zhenyao Mo wrote: > On ...
4 years, 4 months ago (2016-08-16 21:30:09 UTC) #13
Zhenyao Mo
On 2016/08/16 21:30:09, qiankun wrote: > https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h > File gpu/command_buffer/service/context_state.h (right): > > https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h#newcode157 > ...
4 years, 4 months ago (2016-08-16 21:31:13 UTC) #14
qiankun
https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h File gpu/command_buffer/service/context_state.h (right): https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h#newcode157 gpu/command_buffer/service/context_state.h:157: FRAMEBUFFER_SRGB_UNDEFINED, On 2016/08/16 17:16:48, Zhenyao Mo wrote: > On ...
4 years, 4 months ago (2016-08-16 21:42:46 UTC) #15
Zhenyao Mo
On 2016/08/16 21:42:46, qiankun wrote: > https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h > File gpu/command_buffer/service/context_state.h (right): > > https://codereview.chromium.org/2246823002/diff/20001/gpu/command_buffer/service/context_state.h#newcode157 > ...
4 years, 4 months ago (2016-08-16 21:55:35 UTC) #16
qiankun
On 2016/08/16 21:55:35, Zhenyao Mo wrote: > On 2016/08/16 21:42:46, qiankun wrote: > > > ...
4 years, 4 months ago (2016-08-16 22:21:08 UTC) #17
Zhenyao Mo
On 2016/08/16 22:21:08, qiankun wrote: > On 2016/08/16 21:55:35, Zhenyao Mo wrote: > > On ...
4 years, 4 months ago (2016-08-16 22:33:04 UTC) #18
qiankun
I updated the CL as we discussed to do glDisable(FRAMEBUFFER_SRGB) at context initialization time. PTAL.
4 years, 4 months ago (2016-08-17 14:29:56 UTC) #19
Zhenyao Mo
https://codereview.chromium.org/2246823002/diff/60001/gpu/command_buffer/service/context_state.cc File gpu/command_buffer/service/context_state.cc (right): https://codereview.chromium.org/2246823002/diff/60001/gpu/command_buffer/service/context_state.cc#newcode499 gpu/command_buffer/service/context_state.cc:499: framebuffer_srgb_ = FRAMEBUFFER_SRGB_UNDEFINED; Per our discussion, this should be ...
4 years, 4 months ago (2016-08-17 17:21:09 UTC) #20
qiankun
https://codereview.chromium.org/2246823002/diff/60001/gpu/command_buffer/service/context_state.cc File gpu/command_buffer/service/context_state.cc (right): https://codereview.chromium.org/2246823002/diff/60001/gpu/command_buffer/service/context_state.cc#newcode499 gpu/command_buffer/service/context_state.cc:499: framebuffer_srgb_ = FRAMEBUFFER_SRGB_UNDEFINED; On 2016/08/17 17:21:09, Zhenyao Mo wrote: ...
4 years, 4 months ago (2016-08-18 00:19:56 UTC) #21
Zhenyao Mo
On 2016/08/18 00:19:56, qiankun wrote: > https://codereview.chromium.org/2246823002/diff/60001/gpu/command_buffer/service/context_state.cc > File gpu/command_buffer/service/context_state.cc (right): > > https://codereview.chromium.org/2246823002/diff/60001/gpu/command_buffer/service/context_state.cc#newcode499 > ...
4 years, 4 months ago (2016-08-18 00:34:43 UTC) #22
piman
On Wed, Aug 17, 2016 at 5:34 PM, <zmo@chromium.org> wrote: > On 2016/08/18 00:19:56, qiankun ...
4 years, 4 months ago (2016-08-18 01:13:55 UTC) #23
qiankun
On 2016/08/18 00:34:43, Zhenyao Mo wrote: > On 2016/08/18 00:19:56, qiankun wrote: > > I ...
4 years, 4 months ago (2016-08-18 07:04:34 UTC) #24
Zhenyao Mo
On 2016/08/18 07:04:34, qiankun wrote: > On 2016/08/18 00:34:43, Zhenyao Mo wrote: > > On ...
4 years, 4 months ago (2016-08-18 21:46:51 UTC) #25
qiankun
On 2016/08/18 21:46:51, Zhenyao Mo wrote: > On 2016/08/18 07:04:34, qiankun wrote: > > On ...
4 years, 4 months ago (2016-08-18 23:04:54 UTC) #26
Zhenyao Mo
On 2016/08/18 23:04:54, qiankun wrote: > On 2016/08/18 21:46:51, Zhenyao Mo wrote: > > On ...
4 years, 4 months ago (2016-08-18 23:34:02 UTC) #27
qiankun
On 2016/08/18 23:34:02, Zhenyao Mo wrote: > On 2016/08/18 23:04:54, qiankun wrote: > > On ...
4 years, 4 months ago (2016-08-18 23:40:37 UTC) #28
qiankun
All bots passed now. Thanks very much for carefully review and discussion zmo@. Please take ...
4 years, 4 months ago (2016-08-19 10:20:03 UTC) #30
Zhenyao Mo
https://codereview.chromium.org/2246823002/diff/80001/gpu/command_buffer/service/context_state.cc File gpu/command_buffer/service/context_state.cc (right): https://codereview.chromium.org/2246823002/diff/80001/gpu/command_buffer/service/context_state.cc#newcode500 gpu/command_buffer/service/context_state.cc:500: glDisable(GL_FRAMEBUFFER_SRGB); We need to set framebuffer_srgb_ to false here.
4 years, 4 months ago (2016-08-19 17:16:59 UTC) #31
qiankun
https://codereview.chromium.org/2246823002/diff/80001/gpu/command_buffer/service/context_state.cc File gpu/command_buffer/service/context_state.cc (right): https://codereview.chromium.org/2246823002/diff/80001/gpu/command_buffer/service/context_state.cc#newcode500 gpu/command_buffer/service/context_state.cc:500: glDisable(GL_FRAMEBUFFER_SRGB); On 2016/08/19 17:16:59, Zhenyao Mo wrote: > We ...
4 years, 4 months ago (2016-08-19 22:03:15 UTC) #32
Zhenyao Mo
lgtm
4 years, 4 months ago (2016-08-19 22:03:42 UTC) #34
piman
lgtm
4 years, 4 months ago (2016-08-19 22:34:57 UTC) #36
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2246823002/100001
4 years, 4 months ago (2016-08-19 23:58:59 UTC) #40
commit-bot: I haz the power
Committed patchset #6 (id:100001)
4 years, 4 months ago (2016-08-20 00:05:04 UTC) #42
commit-bot: I haz the power
Patchset 6 (id:??) landed as https://crrev.com/a8fe152031cea3017f7dd41990d7e46d49a2ce51 Cr-Commit-Position: refs/heads/master@{#413291}
4 years, 4 months ago (2016-08-20 00:07:44 UTC) #44
yunchao
On 2016/08/18 23:34:02, Zhenyao Mo wrote: > On 2016/08/18 23:04:54, qiankun wrote: > > On ...
4 years, 4 months ago (2016-08-24 13:46:03 UTC) #45
Zhenyao Mo
4 years, 4 months ago (2016-08-25 00:29:09 UTC) #46
Message was sent while issue was closed.
On 2016/08/24 13:46:03, yunchao wrote:
> On 2016/08/18 23:34:02, Zhenyao Mo wrote:
> > On 2016/08/18 23:04:54, qiankun wrote:
> > > On 2016/08/18 21:46:51, Zhenyao Mo wrote:
> > > > On 2016/08/18 07:04:34, qiankun wrote:
> > > > > On 2016/08/18 00:34:43, Zhenyao Mo wrote:
> > > > > > On 2016/08/18 00:19:56, qiankun wrote:
> > > > > > > I still cannot revert these changes. There are still some
situations
> > > where
> > > > > > > context is restored from a null context but it isn't a context
> > > > > initialization.
> > > > > > > glDisable(FRAMEBUFFER_SRGB) in context initialization doesn't help
> in
> > > such
> > > > > > > situation.
> > > > > > 
> > > > > > Really? Do you know what are these situations?
> > > > > 
> > > > > See the following call stack:
> > > > > #0  (anonymous namespace)::(anonymous
> > namespace)::ContextState::RestoreState
> > > > > (this=0x315bc8263148, prev_state=0x0) at
> > > > > ../../gpu/command_buffer/service/context_state.cc:499
> > > > > #1  0x0000564e3f3344be in (anonymous namespace)::(anonymous
> > > > > namespace)::GLES2DecoderImpl::RestoreState (this=0x315bc8263020,
> > > > prev_state=0x0)
> > > > > at ../../gpu/command_buffer/service/gles2_cmd_
> > > > > decoder.cc:5393
> > > > > #2  0x0000564e3f2fd084 in (anonymous
> > > > > namespace)::GLStateRestorerImpl::RestoreState (this=0x315bc7aecb60,
> > > > > prev_state=0x0) at
> > > > ../../gpu/command_buffer/service/gl_state_restorer_impl.cc:30
> > > > > #3  0x0000564e38353b2d in (anonymous
> > > > namespace)::GLContext::MakeVirtuallyCurrent
> > > > > (this=0x315bc821ca20, virtual_context=0x315bc7eba200,
> > > surface=0x315bc79984a0)
> > > > at
> > > > > ../../ui/gl/gl_context.cc
> > > > > :231
> > > > > #4  0x0000564e3f2fc844 in (anonymous
> > > namespace)::GLContextVirtual::MakeCurrent
> > > > > (this=0x315bc7eba200, surface=0x315bc79984a0) at
> > > > > ../../gpu/command_buffer/service/gl_context_virtual.cc:38
> > > > > #5  0x0000564e3f32d25f in (anonymous namespace)::(anonymous
> > > > > namespace)::GLES2DecoderImpl::MakeCurrent (this=0x315bc8263020) at
> > > > > ../../gpu/command_buffer/service/gles2_cmd_decoder.cc:4090
> > > > > #6  0x0000564e3e8703b0 in (anonymous
> > > > > namespace)::GpuCommandBufferStub::MakeCurrent (this=0x315bc790ac60) at
> > > > > ../../gpu/ipc/service/gpu_command_buffer_stub.cc:385
> > > > > #7  0x0000564e3e86f336 in (anonymous
> > > > > namespace)::GpuCommandBufferStub::OnMessageReceived
> (this=0x315bc790ac60,
> > > > > message=...) at ../../gpu/ipc/service/gpu_command_buffer_stub.cc:225
> > > > > #8  0x0000564e3e84c65b in (anonymous
> > namespace)::MessageRouter::RouteMessage
> > > > > (this=0x315bc7878430, msg=...) at ../../ipc/message_router.cc:52
> > > > > #9  0x0000564e3e8577a2 in (anonymous
> > > > namespace)::GpuChannel::HandleMessageHelper
> > > > > (this=0x315bc78783a0, msg=...) at
> ../../gpu/ipc/service/gpu_channel.cc:807
> > > > > 
> > > > > Here is the context state status change flow:
> > > > > Open webgl-conformance-tests.html?version=2.0.0 in first tab:
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e196b27f8
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e19779cf8
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e19d9c0f8
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e19d9c7f8
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e1a536ef8
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e1a8267f8
> > > > > in ContextState::RestoreState: context state = 0x67e1a8267f8
prev_state
> =
> > > > (nil)
> > > > > in ContextState::RestoreState: context state = 0x67e196b27f8
prev_state
> =
> > > > (nil)
> > > > > 
> > > > > open a blank page in second tab:
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e1b0048f8
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e1adaf0f8
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e1a0301f8
> > > > > 
> > > > > open a page in second tab:
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e1a5398f8
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e1a03daf8
> > > > > in ContextState::RestoreState: context state = 0x67e1a5398f8
prev_state
> =
> > > > (nil)
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e1a8275f8
> > > > > 
> > > > > open a new page in the second tab:                                    
 
>  
> >  
> > >  
> > > >  
> > > > >                                                                       
 
>  
> >  
> > >  
> > > >  
> > > > >                          
> > > > > in GLES2DecoderImpl::Initialize: context state = 0x67e1acdcef8
> > > > > in ContextState::RestoreState: context state = 0x67e1a5398f8
prev_state
> =
> > > > (nil)
> > > > > 
> > > > > You can see "context state = 0x67e1a5398f8" call RestoreState with a
> null
> > > > > prev_state twice from above context state change list.
> > > > 
> > > > See piman's comment.  Calling glDisable in Decoder::Initialize() is
> exactly
> > > what
> > > > he suggested, we just need to do it in call situations where prev_state
is
> > > null.
> > > > 
> > > > Leaving it as UNDEFINED is buggy - it could be enabled or disabled,
which
> is
> > > > definitely the wrong thing - it just hasn't manifested yet.  We have to
> know
> > > at
> > > > each moment the state of FRAMEBUFFER_SRGB.
> > > 
> > > Leaving framebuffer_srgb_ as FRAMEBUFFER_SRGB_UNDEFINED is not set
> > > FRAMEBUFFER_SRGB flag as undefined. It just let next
> > > EnableDisableFramebufferSRGB() call do glEnable or glDisable. It's
harmless
> to
> > > gl state. 
> > > 
> > > EnableDisableFramebufferSRGB() will set FRAMEBUFFER_SRGB as what we want.
If
> > we
> > > don't use framebuffer_srgb_, it will set FRAMEBUFFER_SRGB flag every time.
> If
> > we
> > > keep updating framebuffer_srgb_, EnableDisableFramebufferSRGB() will not
> > enable
> > > FRAMEBUFFER_SRGB if it's already enabled or disable FRAMEBUFFER_SRGB if
it's
> > > already disabled.
> > 
> > Here is what I think: in general we should leave FRAMEBUFFER_SRGB disabled,
> > unless we need it for a few limited commands to get the correct behaviors.
> > 
> > At the moment we enable/disable lazily, so in the situation we switch
context
> > from when it's enabled, it stays enabled for a long time.  This is
concerning
> > and potentially bug prone and very bad if the bugs are triggered - and it
> could
> > turn Chrome grey.
> > 
> > So what I propose is: whenever we switch context, if it's enabled or unclear
> (no
> > prev_state), we forcefully disable it immediately.
> > 
> > What do you think?
> 
> Zhenyao and all, AFAICT, it is not true that the srgb enable state will be
hold
> for a long time. You know, I am looking at the sRGB related issue(emulate sRGB
> for core profile less than OGL 4.4 for BlitFramebuffer), I found that we would
> check the srgb status for every draw call (BlitFramebuffer,
> drawArrays/drawElements and their variants, clear, clearBuffer, etc) by call
> into CheckBoundDrawFramebufferValid or CheckBoundFramebufferValid. 
> So no matter what we set to srgb enable/disable status for context
init/restore,
> it would be correct in theory: If the srgb enable/disable state is wrong, it
> will be corrected before drawing. So I think there should be some other
mistake
> in the code. Today, I found that there is a bug in Chromium: if the fbo have
> srgb color buffers(attachments), but they are not readBuffer/drawBuffers,
> chromium will enable srgb wrongly... 
> Please see this change: https://codereview.chromium.org/2268503002

Even if we check every draw call, there are a lot of GL calls in between, so I
wouldn't say it's "not" a long time.

As for readBuffer/drawBuffers, what we found is as far as there is an sRGB
attachment in the fbo, whether it is active or not, turning on FRAMEBUFFER_SRGB
the driver behaves correctly.  That's why we didn't care in the first place.

Powered by Google App Engine
This is Rietveld 408576698