RESOLVED FIXED 90325
[chromium] Use shallow flushes that don't glFlush
https://bugs.webkit.org/show_bug.cgi?id=90325
Summary [chromium] Use shallow flushes that don't glFlush
Brian Anderson
Reported 2012-06-29 17:11:18 PDT
Shallow flushes that don't glFlush
Attachments
Patch (8.41 KB, patch)
2012-06-29 17:14 PDT, Brian Anderson
no flags
Patch (8.14 KB, patch)
2012-07-03 18:05 PDT, Brian Anderson
no flags
Patch (8.85 KB, patch)
2012-07-13 17:45 PDT, Brian Anderson
no flags
Patch (12.24 KB, patch)
2012-07-18 20:01 PDT, Brian Anderson
no flags
Patch (13.07 KB, patch)
2012-07-19 16:17 PDT, Brian Anderson
no flags
Patch (12.22 KB, patch)
2012-07-20 16:41 PDT, Brian Anderson
no flags
Brian Anderson
Comment 1 2012-06-29 17:14:16 PDT
Brian Anderson
Comment 2 2012-07-03 18:05:17 PDT
Nat Duca
Comment 3 2012-07-10 23:31:47 PDT
Comment on attachment 150702 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=150702&action=review You'll need to rebase so you're ToT. This patch isn't cleanly applying. > Source/Platform/chromium/public/WebGraphicsContext3D.h:266 > + virtual void shallowFlush() { }; Look at the other extensions, I think you'll find that they suffix these methods with CHROMIUM, e.g. texImageIOSurface2DCHROMIUM. They're also supposed to be put down at the bottom of the file, with a // block with the extension name they're part of. > Source/WebCore/platform/graphics/GraphicsContext3D.h:690 > +#if PLATFORM(CHROMIUM) You shouldnt edit gc3d, that's common code. Chrome-specific extensions go on Extensions3DChromium. Look at some of the methods there and grep for their name to see how the plumbing for that is done.
Brian Anderson
Comment 4 2012-07-13 17:45:15 PDT
Nat Duca
Comment 5 2012-07-17 13:17:21 PDT
Comment on attachment 152386 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=152386&action=review +kbr for real review. I'm happy +/- minor nits. > Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h:57 > + void shallowFlushCHROMIUM() What if the flush extension is not supported? I think since this code wraps a GC3D, we could make it probe the context for support of the extension and store that support as a member var. If its not supported, this could degrade to a flush, which I like more. Then you could make this method name just shallowestFlushIfPossible. Or something like that.
Brian Anderson
Comment 6 2012-07-17 13:37:20 PDT
Comment on attachment 152386 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=152386&action=review Rebased patch set incoming. >> Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h:57 >> + void shallowFlushCHROMIUM() > > What if the flush extension is not supported? I think since this code wraps a GC3D, we could make it probe the context for support of the extension and store that support as a member var. If its not supported, this could degrade to a flush, which I like more. Then you could make this method name just shallowestFlushIfPossible. Or something like that. I considered degrading to a glFlush, but I think we want to stay away from the overhead of glFlushes if possible. For example, this extension is not supported by WebGraphicsContext3DInProcessImpl. Do we want to degrade to glFlush in that case? I saw a comment somewhere that if an extension is not supported, calling it on a GC3D should not have any side effects. I could check for it more explicitly though so that it is clear this extension isn't supported by all WGC3D's.
Nat Duca
Comment 7 2012-07-17 15:48:49 PDT
(In reply to comment #6) > (From update of attachment 152386 [details]) > > I considered degrading to a glFlush, but I think we want to stay away from the overhead of glFlushes if possible. For example, this extension is not supported by WebGraphicsContext3DInProcessImpl. Do we want to degrade to glFlush in that case? That's what we're doing now and its a win. But, if you're really worried, then I'd rather that it check for support and not make the call, then have it make a call that inside is assumed to just noop. You don't want to check for an extension every time you call this. So you should add a method to CCGraphicsContext that caches the value for you, maybe. E.g. supportsShallowFlush? > I saw a comment somewhere that if an extension is not supported, calling it on a GC3D should not have any side effects. I could check for it more explicitly though so that it is clear this extension isn't supported by all WGC3D's.
Brian Anderson
Comment 8 2012-07-18 20:01:02 PDT
Brian Anderson
Comment 9 2012-07-18 20:06:34 PDT
Comment on attachment 153165 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=153165&action=review > Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h:86 > + void shallowFlushWithFallbackOnFlush() Ended up going with the glFlush fallback but wanted to double check: Why do we want to glFlush() for the in-thread case but not the command buffer case? > Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:725 > + m_context->initializeOnImplThread(); I was getting crashes if I didn't initialize on the impl thread. Is there a better method to initialize the m_context on the impl thread? > Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp:1723 > + .WillByDefault(Return(WebString(""))); Is there a prettier way of doing this? CCGraphicsContext initialization fails in this test otherwise.
Nat Duca
Comment 10 2012-07-18 20:45:21 PDT
Comment on attachment 153165 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=153165&action=review > Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h:54 > + void initializeOnImplThread() We do this already by calling makeCurrent. How about making the call in LRC to makeCurrent go through CCGraphicsContext instead of the GC3D. This can then do its one-off init code, and then call down to the wgc3d makecurrent. >> Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h:86 >> + void shallowFlushWithFallbackOnFlush() > > Ended up going with the glFlush fallback but wanted to double check: Why do we want to glFlush() for the in-thread case but not the command buffer case? Well, when you put it that way, its a fair point. If we're doing in-process GL, the glFlush is I guess a noop, right? I hadn't really thought that through last night when I was giving you feedback, my apologies. The case I had in mind was downstream folks who use CC for their compositor, e.g. Blackberry used to use Chromium Compositor. For that sort of use case, they dont have all our extensions. When I was thinking about this the other day, i was thinking "gee, they'd still want the flush." But, now I'm sort of realizing that that isn't the case. Suppose we make this shallowFlushIfNeeded, where if its not supported, its a nop as you originally (correctly) suggested. Can land the chromium-side of this change first? If we land this side of the patch first, then we'd have a period of time where the compositor simply stops flushing on texture uploads. That's a complication we would be better off avoiding. >> Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:725 >> + m_context->initializeOnImplThread(); > > I was getting crashes if I didn't initialize on the impl thread. Is there a better method to initialize the m_context on the impl thread? There should be some code in this same function that makes the context current. Hook that if you can? >> Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp:1723 >> + .WillByDefault(Return(WebString(""))); > > Is there a prettier way of doing this? CCGraphicsContext initialization fails in this test otherwise. This seems fine. I'm not sure if we have a best-known-method for this. I might just implement the function if I had tried it. I guess I have no opinion. :)
Brian Anderson
Comment 11 2012-07-19 12:32:57 PDT
Comment on attachment 153165 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=153165&action=review >> Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h:54 >> + void initializeOnImplThread() > > We do this already by calling makeCurrent. How about making the call in LRC to makeCurrent go through CCGraphicsContext instead of the GC3D. This can then do its one-off init code, and then call down to the wgc3d makecurrent. Looks like doing that is going to get ugly. I see four options: 1) Use m_context->context3D() everywhere m_context is used in LRC (139 places). 2) Fill out the implementation of CCGraphicsContext. 3) Keep it as is. 1 and 2 are going to be more invasive than 3, but are also less error prone. I'm going to go with 1.
Brian Anderson
Comment 12 2012-07-19 13:33:13 PDT
Using CCGraphicsContext inside of the LRC is turned out to be more invasive than I thought. I got it working, but I no longer think it's worth it just for CCGraphicsContext initialization - unless we want to use CCGraphicsContext inside the LRC in the future anyway. Nat, are you okay with sticking to the initializeOnImplThread() as it is?
Nat Duca
Comment 13 2012-07-19 13:59:43 PDT
(In reply to comment #12) > Using CCGraphicsContext inside of the LRC is turned out to be more invasive than I thought. I got it working, but I no longer think it's worth it just for CCGraphicsContext initialization - unless we want to use CCGraphicsContext inside the LRC in the future anyway. > > Nat, are you okay with sticking to the initializeOnImplThread() as it is? NO
Brian Anderson
Comment 14 2012-07-19 16:17:45 PDT
Brian Anderson
Comment 15 2012-07-19 16:19:42 PDT
This patch is on top of the patch in bug 91793 and does initialization in the makeContextCurrent method of CCGraphicsContext. I agree with waiting for the chromium patches to land first.
Brian Anderson
Comment 16 2012-07-20 16:41:52 PDT
WebKit Review Bot
Comment 17 2012-07-20 16:43:44 PDT
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Brian Anderson
Comment 18 2012-07-20 16:53:29 PDT
(In reply to comment #17) > Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI. Hmm, I think I may have hit a button I wasn't supposed to hit yet. I was trying to get the sanity checks to run. Assuming they're all green though, I think this patch is good to go after http://codereview.chromium.org/10782005 lands. Note: Bug 91793 is no longer a dependency as there were other commits yesterday that simplified this patch.
Kenneth Russell
Comment 19 2012-07-23 11:55:32 PDT
Comment on attachment 153619 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=153619&action=review Looks fine overall. One question. r=me; please mark cq? if the answer to the question above is "yes". > Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp:105 > + resourceProvider->shallowFlushIfSupported(); Is the change from "flush" to "shallow flush" correct in all cases? In other words, the flushes before were only to "kick" the command processor, and weren't needed for correctness at the OpenGL level?
Nat Duca
Comment 20 2012-07-23 13:22:14 PDT
Comment on attachment 153619 [details] Patch Looks great Brian.
Kenneth Russell
Comment 21 2012-07-23 18:10:35 PDT
OK. Setting cq+ based on Nat's additional feedback.
Brian Anderson
Comment 22 2012-07-23 18:17:49 PDT
Comment on attachment 153619 [details] Patch Thanks Ken. I should have mentioned I was waiting for the chromium side of this patch to land before setting cq+. It already landed earlier today, so we should be good.
WebKit Review Bot
Comment 23 2012-07-23 19:04:13 PDT
Comment on attachment 153619 [details] Patch Clearing flags on attachment: 153619 Committed r123416: <http://trac.webkit.org/changeset/123416>
WebKit Review Bot
Comment 24 2012-07-23 19:04:19 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.