Bug 70454 - [chromium] Batch up texture uploads so that they can be updated incrementally
Summary: [chromium] Batch up texture uploads so that they can be updated incrementally
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: Adrienne Walker
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-19 16:52 PDT by Adrienne Walker
Modified: 2011-10-25 10:44 PDT (History)
7 users (show)

See Also:


Attachments
Patch (21.97 KB, patch)
2011-10-19 16:53 PDT, Adrienne Walker
no flags Details | Formatted Diff | Diff
Patch (27.14 KB, patch)
2011-10-20 11:21 PDT, Adrienne Walker
no flags Details | Formatted Diff | Diff
Patch (27.58 KB, patch)
2011-10-20 16:48 PDT, Adrienne Walker
no flags Details | Formatted Diff | Diff
Patch (28.10 KB, patch)
2011-10-21 12:22 PDT, Adrienne Walker
no flags Details | Formatted Diff | Diff
fold allocator into updater (28.80 KB, patch)
2011-10-24 15:05 PDT, Adrienne Walker
jamesr: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adrienne Walker 2011-10-19 16:52:28 PDT
[chromium] Batch up texture uploads so that they can be updated incrementally
Comment 1 Adrienne Walker 2011-10-19 16:53:35 PDT
Created attachment 111695 [details]
Patch
Comment 2 Adrienne Walker 2011-10-19 17:07:07 PDT
Comment on attachment 111695 [details]
Patch

Work in progress patch.

If we want to interleave input and drawing during a commit, we probably need something like this.  I figure a class than can collect all the rects will have a better chance of estimating upload times in the GPU process, if we assume that it's proportional to pixels uploaded.  Insert lots of hand-waving here.

Right now CCTextureUpdater just has an updateAllTextures function, but it'd be easy enough to expose a way to partially iterate through them when needed.

One concern is that maybe this is the wrong architectural approach to upload textures while still having the compositor thread be responsive.  James suggested something like using multiple contexts, but I'm not totally sure I trust the driver to handle that responsibly on all platforms.
Comment 3 WebKit Review Bot 2011-10-19 17:45:30 PDT
Comment on attachment 111695 [details]
Patch

Attachment 111695 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10181072
Comment 4 James Robinson 2011-10-19 22:18:24 PDT
Comment on attachment 111695 [details]
Patch

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

> Source/WebCore/WebCore.gypi:3547
> +            'platform/graphics/chromium/cc/CCTextureUpdater.cpp',
> +            'platform/graphics/chromium/cc/CCTextureUpdater.h',

i think you forgot to git add these files, they aren't showing up in the patch.
Comment 5 Adrienne Walker 2011-10-20 11:21:18 PDT
Created attachment 111809 [details]
Patch
Comment 6 Adrienne Walker 2011-10-20 11:21:47 PDT
(In reply to comment #5)
> Created an attachment (id=111809) [details]
> Patch

Haha, whoops.  Not that the missing class was very interesting.
Comment 7 Adrienne Walker 2011-10-20 16:48:51 PDT
Created attachment 111873 [details]
Patch
Comment 8 Nat Duca 2011-10-20 17:59:44 PDT
Comment on attachment 111873 [details]
Patch

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

> Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:156
> +        m_layerTreeHost->beginCommitOnCCThread(m_layerTreeHostImpl.get());

Random aside: I just renamed the OnCCThread suffixes to onImplThread for clarity.

> Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp:421
> +    m_layerTreeHost->updateCompositorResources(m_layerTreeHostImpl->context(), m_layerTreeHostImpl->contentsTextureAllocator(), updater);

updateCompositorResources really just gets the list of resources to update, right?

> Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp:422
> +    updater.updateAllTextures(m_layerTreeHostImpl->context(), m_layerTreeHostImpl->contentsTextureAllocator());

I guess your next step is to factor this to be something like updater.hasMore() { updater.updateMoreTextures(..., 6); }?
Comment 9 Adrienne Walker 2011-10-21 09:14:41 PDT
(In reply to comment #8)
> (From update of attachment 111873 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=111873&action=review
> 
> > Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:156
> > +        m_layerTreeHost->beginCommitOnCCThread(m_layerTreeHostImpl.get());
> 
> Random aside: I just renamed the OnCCThread suffixes to onImplThread for clarity.

Thanks for the heads up.  I'll rename them.  It looks like this patch doesn't apply to ToT anyway.

> > Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp:421
> > +    m_layerTreeHost->updateCompositorResources(m_layerTreeHostImpl->context(), m_layerTreeHostImpl->contentsTextureAllocator(), updater);
> 
> updateCompositorResources really just gets the list of resources to update, right?

Is this a "so it shouldn't be called update" suggestion? ;)

Unfortunately, VideoLayerChromium still does the upload in updateCompositorResources.  I considering converting VideoLayerChromium to use a texture updater and the tex map sub image class.  That class is also a little bit weird because you have to tell the video frame provider when you're done copying bits out of the frame, so there's this additional post-upload cleanup step that none of the other texture updaters have to deal with.  On top of that, on platforms where you have hardware video acceleration, this path gets skipped anyway.

In short, I punted, updateCompositorResources now updates some resources and collects others for deferred updating.

> > Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp:422
> > +    updater.updateAllTextures(m_layerTreeHostImpl->context(), m_layerTreeHostImpl->contentsTextureAllocator());
> 
> I guess your next step is to factor this to be something like updater.hasMore() { updater.updateMoreTextures(..., 6); }?

Would it be helpful for you if I just landed that change now with this patch?
Comment 10 Adrienne Walker 2011-10-21 12:22:41 PDT
Created attachment 112001 [details]
Patch
Comment 11 Alexandre Elias 2011-10-21 13:21:36 PDT
LGTM.  Seems like a useful initial refactoring.
Comment 12 James Robinson 2011-10-24 13:13:03 PDT
Comment on attachment 112001 [details]
Patch

Could you fold the TextureAllocator into the CCTextureUpdater?
Comment 13 Adrienne Walker 2011-10-24 15:05:20 PDT
Created attachment 112258 [details]
fold allocator into updater
Comment 14 James Robinson 2011-10-24 16:45:42 PDT
Comment on attachment 112258 [details]
fold allocator into updater

R=me
Comment 15 Adrienne Walker 2011-10-25 10:44:01 PDT
Committed r98360: <http://trac.webkit.org/changeset/98360>