Bug 62618 - [chromium] Compositor shader initialization is inefficient
Summary: [chromium] Compositor shader initialization is inefficient
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: James Robinson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-13 19:58 PDT by James Robinson
Modified: 2011-06-14 11:32 PDT (History)
8 users (show)

See Also:


Attachments
Patch (28.05 KB, patch)
2011-06-13 20:12 PDT, James Robinson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Robinson 2011-06-13 19:58:27 PDT
[chromium] Compositor shader initialization is inefficient
Comment 1 James Robinson 2011-06-13 20:12:24 PDT
Created attachment 97061 [details]
Patch
Comment 2 James Robinson 2011-06-13 20:39:55 PDT
On my linux z600 this reduces the time from start of compositor initialization to first swapbuffers on the gpu process from 125ms->73ms for a nearly empty page and from 240ms->190ms for maps.google.com.
Comment 3 Vangelis Kokkevis 2011-06-14 00:24:13 PDT
Comment on attachment 97061 [details]
Patch

Looks good!
Comment 4 James Robinson 2011-06-14 10:36:30 PDT
Ken or Stephen, mind do an official WebKit review?
Comment 5 Vangelis Kokkevis 2011-06-14 10:49:53 PDT
Comment on attachment 97061 [details]
Patch

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

> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:1106
> +    if (!m_borderProgram->initialized()) {

This just in:  Is there a reason why you don't call initialize() when the program first gets created?
Comment 6 James Robinson 2011-06-14 10:55:24 PDT
(In reply to comment #5)
> (From update of attachment 97061 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=97061&action=review
> 
> > Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:1106
> > +    if (!m_borderProgram->initialized()) {
> 
> This just in:  Is there a reason why you don't call initialize() when the program first gets created?

Yes, definitely.  initialize() queries uniform locations, which is synchronous and flushes the command queue.  Calling initialize() when the program is first created will block the renderer until the shader is compiled and linked.  By creating the commonly used shaders at compositor startup but not calling initialize() until draw time the GPU process has a reasonable chance to compile the shader while the compositor is doing software painting and uploading.  The benefit is easiest to see by comparing traces.
Comment 7 Stephen White 2011-06-14 10:57:10 PDT
Comment on attachment 97061 [details]
Patch

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

> Source/WebCore/ChangeLog:19
> +        release builds and force synchronous compilation/linking.

Just out of curiosity:  What about bad drivers or machines where we might accidentally exceed hardware limits?  Do we want to catch those in release builds in the wild and try to fall back to non-composited mode?  Or is this too hard to do gracefully now that they're lazily initialized, and we just rely on the blacklist?
Comment 8 James Robinson 2011-06-14 11:12:31 PDT
If we want to check for failures then we should do it once at the end of initializing the shaders we want instead of after each program.  I kind of doubt that's necessary, though - we should be blacklisting cards that can't handle the compositor's shaders.
Comment 9 Stephen White 2011-06-14 11:13:40 PDT
OK, looks good.  R=me
Comment 10 WebKit Review Bot 2011-06-14 11:32:48 PDT
Comment on attachment 97061 [details]
Patch

Clearing flags on attachment: 97061

Committed r88835: <http://trac.webkit.org/changeset/88835>
Comment 11 WebKit Review Bot 2011-06-14 11:32:53 PDT
All reviewed patches have been landed.  Closing bug.