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

Issue 412453002: GLHelper: Address inconsistent mapping of SkColorType to GL format (Closed)

Created:
6 years, 5 months ago by robert.bradford
Modified:
6 years, 4 months ago
Reviewers:
no sievers, piman
CC:
chromium-reviews, jam, sievers+watch_chromium.org, jbauman+watch_chromium.org, darin-cc_chromium.org, kalyank, piman+watch_chromium.org, danakj+watch_chromium.org, epenner, Sami
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

GLHelper: Address inconsistent mapping of SkColorType to GL format In Chromium on Linux, the native Skia format is BGRA8888, however GLHelper has been mapping that to a GL_RGBA format, preventing the BGRA, creating a confusing inconsistency and preventing true BGRA readback. This change modifies GLHelperReadbackSupport to provide the canonical source of mapping information from SkColorType to GL format, type and also bytes per pixel, reducing the duplication through GLHelper. The enum returned through the ReadbackConfig method provides information on whether the color type is supported, supported only through an optional accelerated swizzle the caller must do, or is not supported at all. BUG=396002 TEST=content_gl_tests enhanced to test BGRA and RGBA readback where supported Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=285281

Patch Set 1 #

Total comments: 44

Patch Set 2 : Integrate first feedback from piman@ (incomplete - do not review) #

Patch Set 3 : Finish integrating review feedback (including enum move and formatting) #

Total comments: 1

Patch Set 4 : Integrate feedback (comment changes) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+238 lines, -153 lines) Patch
M content/common/gpu/client/gl_helper.cc View 1 2 17 chunks +86 lines, -103 lines 0 comments Download
M content/common/gpu/client/gl_helper_readback_support.h View 1 2 2 chunks +22 lines, -16 lines 0 comments Download
M content/common/gpu/client/gl_helper_readback_support.cc View 1 2 3 6 chunks +88 lines, -24 lines 0 comments Download
M content/common/gpu/client/gl_helper_unittest.cc View 7 chunks +42 lines, -10 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
robert.bradford
6 years, 5 months ago (2014-07-22 11:07:56 UTC) #1
piman
https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper.cc File content/common/gpu/client/gl_helper.cc (left): https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper.cc#oldcode1036 content/common/gpu/client/gl_helper.cc:1036: swizzle_, I would prefer if we didn't query ReadbackConfig ...
6 years, 5 months ago (2014-07-22 19:57:56 UTC) #2
robert.bradford
Hi piman@ please you could take another look at this. I'm aware that there is ...
6 years, 5 months ago (2014-07-23 16:58:46 UTC) #3
piman
lgtm https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper_readback_support.cc File content/common/gpu/client/gl_helper_readback_support.cc (right): https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper_readback_support.cc#newcode140 content/common/gpu/client/gl_helper_readback_support.cc:140: GetAdditionalFormat(format, type, &new_format, &new_type); On 2014/07/23 16:58:45, robert.bradford ...
6 years, 5 months ago (2014-07-23 18:07:38 UTC) #4
robert.bradford
The CQ bit was checked by robert.bradford@intel.com
6 years, 5 months ago (2014-07-24 11:17:35 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/robert.bradford@intel.com/412453002/60001
6 years, 5 months ago (2014-07-24 11:22:14 UTC) #6
commit-bot: I haz the power
Change committed as 285281
6 years, 5 months ago (2014-07-24 15:40:47 UTC) #7
no sievers
https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper_readback_support.cc File content/common/gpu/client/gl_helper_readback_support.cc (right): https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper_readback_support.cc#newcode140 content/common/gpu/client/gl_helper_readback_support.cc:140: GetAdditionalFormat(format, type, &new_format, &new_type); On 2014/07/23 18:07:38, piman (OOO) ...
6 years, 4 months ago (2014-08-21 19:41:08 UTC) #8
piman
https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper_readback_support.cc File content/common/gpu/client/gl_helper_readback_support.cc (right): https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper_readback_support.cc#newcode140 content/common/gpu/client/gl_helper_readback_support.cc:140: GetAdditionalFormat(format, type, &new_format, &new_type); On 2014/08/21 19:41:08, sievers wrote: ...
6 years, 4 months ago (2014-08-21 20:00:02 UTC) #9
no sievers
On 2014/08/21 20:00:02, piman (OOO) wrote: > https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper_readback_support.cc > File content/common/gpu/client/gl_helper_readback_support.cc (right): > > https://codereview.chromium.org/412453002/diff/1/content/common/gpu/client/gl_helper_readback_support.cc#newcode140 ...
6 years, 4 months ago (2014-08-21 20:19:34 UTC) #10
piman
On Thu, Aug 21, 2014 at 1:19 PM, <sievers@chromium.org> wrote: > On 2014/08/21 20:00:02, piman ...
6 years, 4 months ago (2014-08-21 20:32:17 UTC) #11
no sievers
On 2014/08/21 20:32:17, piman (OOO) wrote: > On Thu, Aug 21, 2014 at 1:19 PM, ...
6 years, 4 months ago (2014-08-21 20:34:42 UTC) #12
no sievers
On 2014/08/21 20:34:42, sievers wrote: > On 2014/08/21 20:32:17, piman (OOO) wrote: > > On ...
6 years, 4 months ago (2014-08-21 20:43:21 UTC) #13
piman
6 years, 4 months ago (2014-08-21 21:14:09 UTC) #14
On Thu, Aug 21, 2014 at 1:43 PM, <sievers@chromium.org> wrote:

> On 2014/08/21 20:34:42, sievers wrote:
>
>> On 2014/08/21 20:32:17, piman (OOO) wrote:
>> > On Thu, Aug 21, 2014 at 1:19 PM, <mailto:sievers@chromium.org> wrote:
>> >
>> > > On 2014/08/21 20:00:02, piman (OOO) wrote:
>> > >
>> > > https://codereview.chromium.org/412453002/diff/1/content/
>> > > common/gpu/client/gl_helper_readback_support.cc
>> > >
>> > >> File content/common/gpu/client/gl_helper_readback_support.cc
>> (right):
>> > >>
>> > >
>> > >
>> > > https://codereview.chromium.org/412453002/diff/1/content/
>> > > common/gpu/client/gl_helper_readback_support.cc#newcode140
>> > >
>> > >> content/common/gpu/client/gl_helper_readback_support.cc:140:
>> > >> GetAdditionalFormat(format, type, &new_format, &new_type);
>> > >> On 2014/08/21 19:41:08, sievers wrote:
>> > >> > On 2014/07/23 18:07:38, piman (OOO) wrote:
>> > >> > > On 2014/07/23 16:58:45, robert.bradford wrote:
>> > >> > > > On 2014/07/22 19:57:55, piman (slow to review) wrote:
>> > >> > > > > Why do we need this path, given that we can always readback
>> as
>> > >> RGBA/UB
>> > >> > which
>> > >> > > > > matches kRGBA_8888_SkColorType?
>> > >> > > >
>> > >> > > > This is to handle the case (Intel) where the preferred format
>> for
>> > >>
>> > > readback
>> > >
>> > >> > is
>> > >> > > > BGRA and if swizzling is possible then pre-swizzle. (This is
>> the
>> > >> > > generalisation
>> > >> > > > of the code that was previously in the YUV codepath only.)
>> > >> > >
>> > >> > > Ok, can you add a comment to that effect, that we take the
>> presence
>> > >> of an
>> > >> > > additional format as a hint that we prefer it for performance?
>> > >> >
>> > >> > Just wondering.... why do you assume that the additional format is
>> > >> faster?
>> > >>
>> > > The
>> > >
>> > >> > GLES2 spec seems to request that one other format is supported. But
>> > >> what if
>> > >> it's
>> > >> > actually slower?
>> > >> > On Android we use RGBA as the native skia byte ordering, and I
>> assume
>> > >> the
>> > >> > framebuffer internal byte order is usually also RGBA. Then reading
>> back
>> > >> BGRA
>> > >> > would always force the driver to swizzle somehow. Wouldn't that be
>> more
>> > >>
>> > > likely
>> > >
>> > >> > to be slower?
>> > >>
>> > >
>> > >  Well, the spec doesn't say anything, but the intent of the
>> > >> GL_IMPLEMENTATION_COLOR_READ_{FORMAT,TYPE} is to return the internal
>> > >> native
>> > >> format for the buffer, or at least the faster one. If the buffer is
>> > >> actually
>> > >> GL_RGBA/GL_UNSIGNED_BYTE, that's what GL_IMPLEMENTATION_COLOR_READ_*
>> > >> should
>> > >> return.
>> > >>
>> > >
>> > >  On Intel and ANGLE, the native format is
>> GL_BGRA_EXT/GL_UNSIGNED_BYTE,
>>
> and
>
>> > >> there's no fast path to readback + swizzle in the driver.
>> > >>
>> > >
>> > >  If we find that there are drivers that return
>> > >> GL_BGRA_EXT/GL_UNSIGNED_BYTE for
>> > >>
>> > > a
>> > >
>> > >> RGBA buffer, then we'll need an extra piece of data / workaround
>> entry to
>> > >> indicate whether or not we expect the GL_IMPLEMENTATION_COLOR_READ_*
>> > >> format to
>> > >> be slower.
>> > >>
>> > >
>> > > Ok, yea, I haven't really looked at what drivers actually report but
>> am
>> > > just a
>> > > bit worried because in the GLES2 spec in 4.3.1 it says that drivers
>> must
>> > > support
>> > > RGBA plus one other format which may be queried with
>> > > GL_IMPLEMENTATION_COLOR_READ_FORMAT.
>> > > So it seems that the additional format would always be slower to read
>> back
>> > > (unless the hw internally actually uses BGRA, but then all our texture
>> > > uploads
>> > > would have to end up swizzling internally, meh?).
>> > >
>> >
>> > The *whole* point of the additional format is to allow to be faster (at
>> the
>> > cost of more code / less portability, since you need to figure out if
>> you
>> > can handle the extra format).
>> >
>> > Antoine
>> >
>>
>
>  I guess the main source of confusion for me is then the simultaneous hard
>> requirement for supporting the extra, different format.
>>
>
>
>
> Ok I think I see now... the additional format does not have to be
> different at
> all in GLES2.
>

Right.


> And it has to be from table 3.4 (but not luminance or luminance_alpha).
> And that table does not have BGRA, but has RGBA (and RGB24, 4444, 565 and
> alpha).
>

Right, GL_BGRA_EXT is defined in an extension, not stock GLES2.


> So we should not hit this codepath on GLES2 even?


If EXT_read_format_bgra is supported, it's added to the table.

Antoine


>
>
>  >
>> > >
>> > > https://codereview.chromium.org/412453002/
>> > >
>> >
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an
>> email
>> > to mailto:chromium-reviews+unsubscribe@chromium.org.
>>
>
>
>
> https://codereview.chromium.org/412453002/
>

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