Bug 66884 - Speed up texImage from BGRA
Summary: Speed up texImage from BGRA
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: John Bauman
URL:
Keywords:
Depends on:
Blocks: 86515
  Show dependency treegraph
 
Reported: 2011-08-24 13:14 PDT by John Bauman
Modified: 2012-05-16 20:42 PDT (History)
4 users (show)

See Also:


Attachments
Patch (3.83 KB, patch)
2011-08-24 13:21 PDT, John Bauman
no flags Details | Formatted Diff | Diff
Patch (3.83 KB, patch)
2011-08-24 13:39 PDT, John Bauman
no flags Details | Formatted Diff | Diff
Patch (5.30 KB, patch)
2011-08-25 09:41 PDT, John Bauman
no flags Details | Formatted Diff | Diff
Patch (5.91 KB, patch)
2011-08-25 10:19 PDT, John Bauman
no flags Details | Formatted Diff | Diff
fix big endian (6.09 KB, patch)
2011-08-29 12:27 PDT, John Bauman
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Bauman 2011-08-24 13:14:53 PDT
Speed up texImage from BGRA
Comment 1 John Bauman 2011-08-24 13:21:22 PDT
Created attachment 105056 [details]
Patch
Comment 2 WebKit Review Bot 2011-08-24 13:28:42 PDT
Comment on attachment 105056 [details]
Patch

Attachment 105056 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9488247
Comment 3 John Bauman 2011-08-24 13:39:57 PDT
Created attachment 105059 [details]
Patch
Comment 4 Nat Duca 2011-08-24 18:00:06 PDT
Comment on attachment 105059 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=105059&action=review

Wheee! What kind of speed gains does this get (not fps, but for the actual pack fn)?

> Source/WebCore/platform/graphics/GraphicsContext3D.cpp:1152
> +    if (reinterpret_cast<void*>(rowPackingFunc) == reinterpret_cast<void*>(packOneRowOfRGBA8ToRGBA8)) {

As a bystander to this code, it took me a while to figure out what this check was really doing --- might want to preceed this with a comment saying "skip unpacking step if does nothing and unpack directly to the destination"?
Comment 5 John Bauman 2011-08-24 19:43:38 PDT
(In reply to comment #4)
> (From update of attachment 105059 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=105059&action=review
> 
> Wheee! What kind of speed gains does this get (not fps, but for the actual pack fn)?
I'm not sure, as the benchmark I was using increased the amount of work that it had this do when I made it faster, but it maybe takes 1/2 to 1/3 of its old time. I know the benchmark scored about 1.5x what it was without the patch.
> 
> > Source/WebCore/platform/graphics/GraphicsContext3D.cpp:1152
> > +    if (reinterpret_cast<void*>(rowPackingFunc) == reinterpret_cast<void*>(packOneRowOfRGBA8ToRGBA8)) {
> 
> As a bystander to this code, it took me a while to figure out what this check was really doing --- might want to preceed this with a comment saying "skip unpacking step if does nothing and unpack directly to the destination"?

Good idea.
Comment 6 John Bauman 2011-08-25 09:41:13 PDT
Created attachment 105201 [details]
Patch
Comment 7 WebKit Review Bot 2011-08-25 10:04:50 PDT
Comment on attachment 105201 [details]
Patch

Attachment 105201 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/9495512

New failing tests:
fast/canvas/webgl/tex-image-and-sub-image-2d-with-array-buffer-view.html
Comment 8 John Bauman 2011-08-25 10:19:08 PDT
Created attachment 105207 [details]
Patch
Comment 9 Kenneth Russell 2011-08-25 11:47:10 PDT
Comment on attachment 105207 [details]
Patch

Looks good to me. Did you run the texture-related WebGL conformance tests and layout tests to ensure no accidental regressions?
Comment 10 John Bauman 2011-08-29 11:58:16 PDT
Yeah, they all seem to work.
Comment 11 Kenneth Russell 2011-08-29 12:06:04 PDT
Comment on attachment 105207 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=105207&action=review

> Source/WebCore/platform/graphics/GraphicsContext3D.cpp:481
> +        uint32_t rgba = (((bgra >> 16) | (bgra << 16)) & 0x00ff00ff) | (bgra & 0xff00ff00);

Sorry, I just realized that this won't work correctly on big-endian hardware. You can use #if CPU(BIG_ENDIAN) to gate the code (see html/canvas/DataView.cpp); could you please add another arm?
Comment 12 John Bauman 2011-08-29 12:27:13 PDT
Created attachment 105510 [details]
fix big endian
Comment 13 Kenneth Russell 2011-08-29 14:52:14 PDT
Comment on attachment 105510 [details]
fix big endian

Great, thanks. r=me
Comment 14 WebKit Review Bot 2011-08-29 15:54:19 PDT
Comment on attachment 105510 [details]
fix big endian

Clearing flags on attachment: 105510

Committed r94026: <http://trac.webkit.org/changeset/94026>
Comment 15 WebKit Review Bot 2011-08-29 15:54:24 PDT
All reviewed patches have been landed.  Closing bug.