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

Issue 2286593002: [Command Buffer] emulate SRGB color format for BlitFramebuffer in OpenGL (Closed)

Created:
4 years, 3 months ago by yunchao
Modified:
4 years, 3 months ago
CC:
chromium-reviews, piman+watch_chromium.org, Yang Gu, yizhou.jiang, Corentin Wallez
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Command Buffer] emulate SRGB color format for BlitFramebuffer in OpenGL. In Desktop OGLs whose version < 4.4, they maybe don't enable srgb conversion between srgb color format and linear color format. This change can emulate srgb and do the conversion for machines with these OGL profiles. BUG=634525 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/fd79169d48f8d31025b69c5dc05b7f00994a4f3d Cr-Commit-Position: refs/heads/master@{#419396}

Patch Set 1 #

Patch Set 2 : Fix build issue, run framebufferblit tests #

Patch Set 3 : remove unnecessary code #

Patch Set 4 : remove printf to upload code to review #

Patch Set 5 : fix a small bug #

Patch Set 6 : comment unnecessary code #

Patch Set 7 : Remove unnecessary code, fix a build bug #

Patch Set 8 : fix a small error #

Total comments: 41

Patch Set 9 : Addressed zmo@'s feedback #

Total comments: 8

Patch Set 10 : addressed feedbacks from zhenyao and qiankun #

Total comments: 8

Patch Set 11 : Addressed zmo@'s feedback #

Total comments: 36

Patch Set 12 : addressed piman@'s feedbacks, and rebased code #

Total comments: 1

Patch Set 13 : addressed piman's feedback #

Patch Set 14 : addressed piman's feedback: add support to blit from srgb read buffer to srgb draw buffer, and consider filtering srgb image #

Total comments: 2

Patch Set 15 : addressed piman@'s feedback: don't use shader to do srgb conversion if possible #

Patch Set 16 : code rebase #

Patch Set 17 : addressed piman's feedback: use a trivial fragment shader, don't need to explicitly convert linear … #

Total comments: 6

Patch Set 18 : blitFramebuffer can resolove multisampled srgb image #

Patch Set 19 : addressed piman@'s feedback: combine all srgb converters into one function #

Patch Set 20 : code rebase #

Patch Set 21 : addressed piman's feedback: reuse resources when decode/encode srgb to/from linear #

Total comments: 13

Patch Set 22 : addressed feedbacks from piman and kbr #

Unified diffs Side-by-side diffs Delta from patch set Stats (+527 lines, -75 lines) Patch
M content/test/gpu/gpu_tests/webgl2_conformance_expectations.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 3 chunks +26 lines, -56 lines 0 comments Download
M gpu/command_buffer/service/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +2 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_copy_tex_image.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 12 chunks +98 lines, -17 lines 0 comments Download
A gpu/command_buffer/service/gles2_cmd_srgb_converter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +73 lines, -0 lines 0 comments Download
A gpu/command_buffer/service/gles2_cmd_srgb_converter.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +326 lines, -0 lines 0 comments Download

Messages

Total messages: 171 (122 generated)
yunchao
PTAL. Thanks a lot! Some explanations and concerns are inline. https://codereview.chromium.org/2286593002/diff/220001/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py File content/test/gpu/gpu_tests/webgl2_conformance_expectations.py (left): https://codereview.chromium.org/2286593002/diff/220001/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py#oldcode227 ...
4 years, 3 months ago (2016-08-29 14:33:47 UTC) #40
yunchao
One more explanation. https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc File gpu/command_buffer/service/gles2_cmd_srgb_converter.cc (right): https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc#newcode93 gpu/command_buffer/service/gles2_cmd_srgb_converter.cc:93: " output_color = vec4(decode(c.r), decode(c.g), decode(c.b), ...
4 years, 3 months ago (2016-08-29 15:16:53 UTC) #41
Zhenyao Mo
yunchao, this is great! It still needs some work to get details correct (preferably by ...
4 years, 3 months ago (2016-08-29 23:36:50 UTC) #43
Zhenyao Mo
geoff, FYI. We need the same mechanism in MANGLE.
4 years, 3 months ago (2016-08-29 23:37:22 UTC) #44
Zhenyao Mo
https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode7606 gpu/command_buffer/service/gles2_cmd_decoder.cc:7606: state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); This is a nasty situation. We define ...
4 years, 3 months ago (2016-08-29 23:39:59 UTC) #45
Zhenyao Mo
https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc File gpu/command_buffer/service/gles2_cmd_srgb_converter.cc (right): https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc#newcode318 gpu/command_buffer/service/gles2_cmd_srgb_converter.cc:318: c.width(), c.height(), Thinking more about this, it seems to ...
4 years, 3 months ago (2016-08-30 00:22:05 UTC) #46
yunchao
On 2016/08/30 00:22:05, Zhenyao Mo wrote: > https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc > File gpu/command_buffer/service/gles2_cmd_srgb_converter.cc (right): > > https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc#newcode318 ...
4 years, 3 months ago (2016-08-30 01:23:14 UTC) #47
Zhenyao Mo
On 2016/08/30 01:23:14, yunchao wrote: > On 2016/08/30 00:22:05, Zhenyao Mo wrote: > > > ...
4 years, 3 months ago (2016-08-30 01:33:53 UTC) #48
qiankun
Some bugs in the shader. https://codereview.chromium.org/2286593002/diff/260001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc File gpu/command_buffer/service/gles2_cmd_srgb_converter.cc (right): https://codereview.chromium.org/2286593002/diff/260001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc#newcode85 gpu/command_buffer/service/gles2_cmd_srgb_converter.cc:85: " decoded_color = pow(decoded_color, ...
4 years, 3 months ago (2016-08-30 16:38:42 UTC) #61
yunchao
Thanks for your review, Zhenyao. Code has been updated. PTAL. https://codereview.chromium.org/2286593002/diff/220001/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py File content/test/gpu/gpu_tests/webgl2_conformance_expectations.py (left): https://codereview.chromium.org/2286593002/diff/220001/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py#oldcode209 ...
4 years, 3 months ago (2016-08-31 09:18:45 UTC) #66
yunchao
Thanks for your suggestions, Qiankun. https://codereview.chromium.org/2286593002/diff/260001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc File gpu/command_buffer/service/gles2_cmd_srgb_converter.cc (right): https://codereview.chromium.org/2286593002/diff/260001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc#newcode85 gpu/command_buffer/service/gles2_cmd_srgb_converter.cc:85: " decoded_color = pow(decoded_color, ...
4 years, 3 months ago (2016-08-31 09:39:03 UTC) #70
yunchao
Any feedback about this one? Then I can proceed the follow-ups.
4 years, 3 months ago (2016-09-01 00:30:22 UTC) #73
Zhenyao Mo
https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode7600 gpu/command_buffer/service/gles2_cmd_decoder.cc:7600: (read_buffer_has_srgb && draw_buffers_has_srgb && same_size) || On 2016/08/31 09:18:44, ...
4 years, 3 months ago (2016-09-01 19:28:33 UTC) #74
yunchao
Thanks for your careful review, Zhenyao. Code has been updated, please take another look. https://codereview.chromium.org/2286593002/diff/220001/gpu/command_buffer/service/gles2_cmd_decoder.cc ...
4 years, 3 months ago (2016-09-02 14:11:17 UTC) #80
yunchao
Please see the conformance test at https://github.com/KhronosGroup/WebGL/pull/2010 to test blitframebuffer when bliting outside of read ...
4 years, 3 months ago (2016-09-05 16:59:51 UTC) #81
Zhenyao Mo
lgtm with one request to expand the tests. Thanks for working on this challenging task. ...
4 years, 3 months ago (2016-09-06 22:30:11 UTC) #82
Zhenyao Mo
piman: can you also take a look? I feel a second pair of eyes is ...
4 years, 3 months ago (2016-09-06 22:31:08 UTC) #83
yunchao
Thanks for your review, Zhenyao. https://codereview.chromium.org/2286593002/diff/340001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc File gpu/command_buffer/service/gles2_cmd_srgb_converter.cc (right): https://codereview.chromium.org/2286593002/diff/340001/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc#newcode368 gpu/command_buffer/service/gles2_cmd_srgb_converter.cc:368: srcY0 < srcY1 ? ...
4 years, 3 months ago (2016-09-07 03:46:26 UTC) #84
piman
https://codereview.chromium.org/2286593002/diff/340001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2286593002/diff/340001/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode7651 gpu/command_buffer/service/gles2_cmd_decoder.cc:7651: if (draw_buffers_has_srgb) { What if both read and draw ...
4 years, 3 months ago (2016-09-07 23:08:33 UTC) #85
yunchao
Thanks for your careful review, piman. Code has been updated, please take another look. Thanks ...
4 years, 3 months ago (2016-09-08 18:32:49 UTC) #93
piman
https://codereview.chromium.org/2286593002/diff/340001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2286593002/diff/340001/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode7651 gpu/command_buffer/service/gles2_cmd_decoder.cc:7651: if (draw_buffers_has_srgb) { On 2016/09/08 18:32:49, yunchao wrote: > ...
4 years, 3 months ago (2016-09-08 19:39:18 UTC) #94
yunchao
@piman, thanks for your review. I explained my concerns for your comments. May be I ...
4 years, 3 months ago (2016-09-08 23:16:49 UTC) #97
piman
I think there is a major confusion about how sRGB works, hence why this is ...
4 years, 3 months ago (2016-09-08 23:52:29 UTC) #98
yunchao
Excellent explanation about how sRGB works! I got it finally. It is much clear now. ...
4 years, 3 months ago (2016-09-09 00:06:00 UTC) #99
yunchao
@piman (and all), I have updated the code to support bliting from srgb read buffer ...
4 years, 3 months ago (2016-09-09 14:34:58 UTC) #109
yunchao
On 2016/09/09 14:34:58, yunchao wrote: > @piman (and all), I have updated the code to ...
4 years, 3 months ago (2016-09-12 10:50:35 UTC) #110
piman
https://codereview.chromium.org/2286593002/diff/440001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2286593002/diff/440001/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode7727 gpu/command_buffer/service/gles2_cmd_decoder.cc:7727: state_.EnableDisableFramebufferSRGB(false); Once more. Why do you do disable GL_FRAMEBUFFER_SRGB ...
4 years, 3 months ago (2016-09-13 00:39:23 UTC) #111
yunchao
Code has been updated per your suggestion, @piman. Could you take another look. Thanks a ...
4 years, 3 months ago (2016-09-13 08:37:17 UTC) #114
piman
On Tue, Sep 13, 2016 at 1:37 AM, <yunchao.he@intel.com> wrote: > > Code has been ...
4 years, 3 months ago (2016-09-13 16:16:20 UTC) #117
yunchao
On 2016/09/13 16:16:20, piman OOO back 2016-09-12 wrote: > On Tue, Sep 13, 2016 at ...
4 years, 3 months ago (2016-09-14 16:04:57 UTC) #120
yunchao
I came across a corner case for srgb decoding, do you have any suggestions, @piman? ...
4 years, 3 months ago (2016-09-14 16:11:33 UTC) #121
piman
Thanks, this looks better already. I would like to try to reduce the code duplication, ...
4 years, 3 months ago (2016-09-15 03:34:31 UTC) #124
yunchao
Thanks for your review, @piman. I have combined all srgb converters into one function (SRGBConverter::Blit). ...
4 years, 3 months ago (2016-09-16 06:20:52 UTC) #134
yunchao
@piman, I have updated the code as your suggestion: unify and share resources (textures, vao, ...
4 years, 3 months ago (2016-09-16 14:07:56 UTC) #141
piman
Thanks, this is great. LGTM after a couple of nits fixed. https://codereview.chromium.org/2286593002/diff/640001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): ...
4 years, 3 months ago (2016-09-16 20:49:27 UTC) #142
Ken Russell (switch to Gerrit)
Appreciate piman thoroughly reviewing this -- sorry, just coming to this review for the first ...
4 years, 3 months ago (2016-09-16 22:32:29 UTC) #144
Ken Russell (switch to Gerrit)
BTW, thank you for this patch, Yunchao -- it's a nice piece of work and ...
4 years, 3 months ago (2016-09-16 22:33:07 UTC) #145
piman
https://codereview.chromium.org/2286593002/diff/640001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2286593002/diff/640001/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode7711 gpu/command_buffer/service/gles2_cmd_decoder.cc:7711: read_buffer_samples > 0 || On 2016/09/16 22:32:29, Ken Russell ...
4 years, 3 months ago (2016-09-16 22:53:29 UTC) #146
Ken Russell (switch to Gerrit)
https://codereview.chromium.org/2286593002/diff/640001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2286593002/diff/640001/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode7711 gpu/command_buffer/service/gles2_cmd_decoder.cc:7711: read_buffer_samples > 0 || On 2016/09/16 22:53:29, piman OOO ...
4 years, 3 months ago (2016-09-16 23:19:42 UTC) #147
piman
https://codereview.chromium.org/2286593002/diff/640001/gpu/command_buffer/service/gles2_cmd_decoder.cc File gpu/command_buffer/service/gles2_cmd_decoder.cc (right): https://codereview.chromium.org/2286593002/diff/640001/gpu/command_buffer/service/gles2_cmd_decoder.cc#newcode7711 gpu/command_buffer/service/gles2_cmd_decoder.cc:7711: read_buffer_samples > 0 || On 2016/09/16 23:19:42, Ken Russell ...
4 years, 3 months ago (2016-09-16 23:28:44 UTC) #148
yunchao
Thanks for your review, @piman and @kbr. Code has been updated, please take another look. ...
4 years, 3 months ago (2016-09-17 15:14:13 UTC) #155
yunchao
Merge this now.
4 years, 3 months ago (2016-09-18 07:20:22 UTC) #160
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/2286593002/700001
4 years, 3 months ago (2016-09-18 07:21:00 UTC) #163
commit-bot: I haz the power
Committed patchset #22 (id:700001)
4 years, 3 months ago (2016-09-18 07:27:28 UTC) #165
commit-bot: I haz the power
Patchset 22 (id:??) landed as https://crrev.com/fd79169d48f8d31025b69c5dc05b7f00994a4f3d Cr-Commit-Position: refs/heads/master@{#419396}
4 years, 3 months ago (2016-09-18 07:29:14 UTC) #167
yunchao
@kbr and @piman, Here are some discussions about bliting multisampled srgb image. See the comments ...
4 years, 3 months ago (2016-09-19 07:25:00 UTC) #168
ccameron
I think this is causing GPU FYI failure: https://build.chromium.org/p/chromium.gpu.fyi/builders/Linux%20Release%20%28New%20Intel%29/builds/2977 WebglConformance_deqp_functional_gles3_framebufferblit_conversion_04 et al
4 years, 3 months ago (2016-09-19 17:49:59 UTC) #169
ynovikov
On 2016/09/19 17:49:59, ccameron wrote: > I think this is causing GPU FYI failure: > ...
4 years, 3 months ago (2016-09-19 18:14:00 UTC) #170
piman
4 years, 3 months ago (2016-09-20 01:17:44 UTC) #171
Message was sent while issue was closed.
On Mon, Sep 19, 2016 at 12:25 AM, <yunchao.he@intel.com> wrote:

> @kbr and @piman,
> Here are some discussions about bliting multisampled srgb image. See the
> comments inline. Thanks a lot!
>
> Look forward to your insight.
>
>
> https://codereview.chromium.org/2286593002/diff/640001/gpu/
> command_buffer/service/gles2_cmd_decoder.cc
> File gpu/command_buffer/service/gles2_cmd_decoder.cc (right):
>
> https://codereview.chromium.org/2286593002/diff/640001/gpu/
> command_buffer/service/gles2_cmd_decoder.cc#newcode7711
> gpu/command_buffer/service/gles2_cmd_decoder.cc:7711:
> read_buffer_samples > 0 ||
> On 2016/09/16 23:19:42, Ken Russell wrote:
> > On 2016/09/16 22:53:29, piman OOO back 2016-09-12 wrote:
> > > On 2016/09/16 22:32:29, Ken Russell wrote:
> > > > Per
> https://bugs.chromium.org/p/chromium/issues/detail?id=634525#c4 , when
> > the
> > > > source is a multisampled sRGB renderbuffer and the OpenGL version
> is less
> > than
> > > > 4.2, it's necessary to first blit to a temporary sRGB texture, and
> then use
> > > your
> > > > SRGBConverter class to blit from that temporary texture to the
> destination
> > > > texture.
> > > >
> > > > It's fine by me to defer this work to a later patch, but could you
> please
> > add
> > > a
> > > > TODO(yunchao) here indicating that this code isn't fully correct,
> and needs
> > > > tests of this code path?
> > >
> > > Ah, you're right. I was under the impression that the
> glCopyTexImage2D would
> > do
> > > the resolve, but that is not the case (it would
> GL_INVALID_OPERATION)
> >
> > Maybe I'm missing something. This code path only executes
> BlitFramebuffer and
> > then returns; I don't see a glCopyTexImage2D being done. Assuming
> > BlitFramebuffer is not doing the desired thing in all cases from an
> (sRGB or
> > not) multisampled renderbuffer to an (sRGB or not) texture for older
> OpenGL
> > versions, that's the reason I thought more code would be needed.
>
> @piman and @kbr, I revisit this feature. multi-sampled srgb image can
> not blit to linear image, and multi-sampled linear image can not blit to
> srgb image too. Because if the read buffer is multi-sampled, the
> format/type of the read buffer and draw buffer should be exactly the
> same.
>
> In addition, the src region and the dst region should be exactly the
> same too.
>
> So if the read buffer is multi-sampled, there are only two possible
> cases:
> 1. blit multi-sampled linear image to a single-sampled linear image.
> (This case is OK, I think. It is not under the discussion to emulate
> srgb for desktop OGL)
> 2. blit multi-sampled srgb image to a single-sampled srgb image (This is
> the only case under discussion).
> So maybe we don't need to do any extra work here. Just call
> blitFramebuffer directly. Because my code need to do like this:
> multi-sampled srgb image - (copy) - srgb image - (decode) - linear image
> - (blit) - linear image - (encode) - srgb image.
> But the first step is wrong, we can not copy a multi-sampled image to a
> single-sampled image. Copy operation can not do resolution for
> multi-sampled image. It will report INVALID_OPERATION. Considering that
> the src region and the dst region is exactly the same (no filtering),
> and both the read buffer and draw buffer are srgb image (no conversion).
> I suppose that the only work is resolve multi-sampled image to a
> single-sampled image. I think the blitframebuffer itself can do this
> underlying.
> WDYT?
>

Yes, I think so. The ES3 restrictions mean that BlitFramebuffer +
multisampling is only allowed for a straightforward resolve (no filtering,
same format, same bounds, only source is MS). This should be ok in OpenGL
4.2, and besides, there's no other way to get a single-sample buffer out of
the source, so no matter what we do we'd need a BlitFramebuffer sRGB->sRGB
before doing anything else.

So I agree that the right way to proceed is to:
1- check the restrictions for MS (need to check that the draw buffer are
not MS if the source is MS - the rest seems already handled)
2- go directly to BlitFramebuffer


> I have a conformance test for this two:
> https://github.com/KhronosGroup/WebGL/pull/2034. PTAL.
>
> https://codereview.chromium.org/2286593002/
>

-- 
You received this message because you are subscribed to the Google Groups
"Chromium-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698