RESOLVED FIXED 56476
Canvas2D GPU acceleration should support shadows
https://bugs.webkit.org/show_bug.cgi?id=56476
Summary Canvas2D GPU acceleration should support shadows
Stephen White
Reported 2011-03-16 11:50:19 PDT
We should support hard and soft shadows in canvas 2D GPU acceleration, as in the software path.
Attachments
Patch (59.39 KB, patch)
2011-03-16 12:00 PDT, Stephen White
no flags
Patch (59.04 KB, patch)
2011-03-16 14:47 PDT, Stephen White
kbr: review+
Stephen White
Comment 1 2011-03-16 12:00:36 PDT
Kenneth Russell
Comment 2 2011-03-16 13:40:47 PDT
Comment on attachment 85951 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=85951&action=review Overall this looks excellent. It's great that your algorithm for this is finally getting incorporated. A couple of questions and comments. > Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp:754 > + scissorClear(rect.x(), rect.y() - width, rect.width() + width, width); Should this be rect.x() - width? > Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp:756 > + scissorClear(rect.x(), rect.maxY(), width, rect.height() + width); Should this be rect.y() instead of rect.maxY()? And possibly rect.x() - width? > Source/WebCore/platform/graphics/gpu/BicubicShader.cpp:125 > + m_context->uniform1i(m_imageLocation, 0); It seems pretty magic to assume that the input texture comes in on texture unit 0. Is this common in the other shaders? If so, it's fine, but otherwise, at least a comment in the header about the conventions would help. > Source/WebCore/platform/graphics/gpu/ConvolutionShader.cpp:110 > + m_context->uniform1i(m_imageLocation, 0); Same comment here about texture unit 0. > Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h:167 > +const float kMaxSigma = 4.0f; > +const int kMaxKernelWidth = 25; WebKit style actually doesn't use the "k" prefix for constants.
Stephen White
Comment 3 2011-03-16 14:10:37 PDT
(In reply to comment #2) > (From update of attachment 85951 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=85951&action=review > > Overall this looks excellent. It's great that your algorithm for this is finally getting incorporated. A couple of questions and comments. > > > Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp:754 > > + scissorClear(rect.x(), rect.y() - width, rect.width() + width, width); > > Should this be rect.x() - width? This is what I was attempting to do: 31111 3 4 3 4 3 4 22224 So the first one starts at x, y - width. I think that one's correct. > > Source/WebCore/platform/graphics/chromium/GLES2Canvas.cpp:756 > > + scissorClear(rect.x(), rect.maxY(), width, rect.height() + width); > > Should this be rect.y() instead of rect.maxY()? And possibly rect.x() - width? This is supposed to be doing section 3 above, but it looks wrong to me now. Will fix. > > Source/WebCore/platform/graphics/gpu/BicubicShader.cpp:125 > > + m_context->uniform1i(m_imageLocation, 0); > > It seems pretty magic to assume that the input texture comes in on texture unit 0. Is this common in the other shaders? If so, it's fine, but otherwise, at least a comment in the header about the conventions would help. I didn't see a point in exposing it from the shaders, since the only call to glActiveTexture() in the canvas context is one that sets it to unit zero (which could probably be removed). I'll add a comment, though, thanks. > > Source/WebCore/platform/graphics/gpu/ConvolutionShader.cpp:110 > > + m_context->uniform1i(m_imageLocation, 0); > > Same comment here about texture unit 0. > > > Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h:167 > > +const float kMaxSigma = 4.0f; > > +const int kMaxKernelWidth = 25; > > WebKit style actually doesn't use the "k" prefix for constants. Thanks. I can't see anything in the coding style docs, but it seems cFoo is often used in headers, so I'll use that.
Kenneth Russell
Comment 4 2011-03-16 14:19:08 PDT
(In reply to comment #3) > Thanks. I can't see anything in the coding style docs, but it seems cFoo is often used in headers, so I'll use that. Actually from discussions I've seen on IRC I think the conventional wisdom is to just use a capitalized first letter -- no "k" or "c" prefix.
Stephen White
Comment 5 2011-03-16 14:47:43 PDT
Stephen White
Comment 6 2011-03-16 14:49:40 PDT
(In reply to comment #4) > (In reply to comment #3) > > Thanks. I can't see anything in the coding style docs, but it seems cFoo is often used in headers, so I'll use that. > > Actually from discussions I've seen on IRC I think the conventional wisdom is to just use a capitalized first letter -- no "k" or "c" prefix. Really? That looks a little strange for things that are in the WebCore namespace -- looks a lot like a class name. I think I'll use cFoo for now, since there's precedent.
Kenneth Russell
Comment 7 2011-03-16 15:49:21 PDT
Comment on attachment 85981 [details] Patch Looks great. clearBorders looks better now.
Stephen White
Comment 8 2011-03-17 06:57:58 PDT
Alexander Pavlov (apavlov)
Comment 9 2011-03-17 08:04:50 PDT
Stephen White
Comment 10 2011-03-17 13:34:55 PDT
I have no idea why these tests are timing out on the canaries. I can't repro these timeouts on my local machine, in Debug or Release. I tried passing the same run_webkit_tests command line that the bots use (modulo directory names), but no luck. This is much more than the shadow tests: it seems to be every canvas test in GPU mode. That suggests it's part of the initialization code in SharedGraphicsContext3D. Other than changes for shadows (which should only affect the tests with shadows, and not the large number of tests which are timing out), the main thing that affects all tests in this CL is that it compiles 2 more shaders, but one of them it compiles in 25 variants, with different loop bounds in the fragment shader. I thought it might be the shader validator, but it doesn't seem like that would run differently on/off bot hardware. Could it be OSMesa is doing something weird on a machine without a GPU? Or on Windows, but not Linux? I'm perplexed.
Kenneth Russell
Comment 11 2011-03-17 13:57:30 PDT
(In reply to comment #10) > I have no idea why these tests are timing out on the canaries. I can't repro these timeouts on my local machine, in Debug or Release. I tried passing the same run_webkit_tests command line that the bots use (modulo directory names), but no luck. This is much more than the shadow tests: it seems to be every canvas test in GPU mode. That suggests it's part of the initialization code in SharedGraphicsContext3D. > > Other than changes for shadows (which should only affect the tests with shadows, and not the large number of tests which are timing out), the main thing that affects all tests in this CL is that it compiles 2 more shaders, but one of them it compiles in 25 variants, with different loop bounds in the fragment shader. I thought it might be the shader validator, but it doesn't seem like that would run differently on/off bot hardware. Could it be OSMesa is doing something weird on a machine without a GPU? Or on Windows, but not Linux? I'm perplexed. When you run these tests locally, are you running DRT with Mesa? If so, it really should behave the same as on the bots regardless of the kind of GPU (or lack thereof) on the system. BTW, it could certainly be Mesa doing something wrong or bad. Earlier versions of Mesa than the one we currently use (7.9) had terrible bugs in the shader compiler including infinite loops during compilation.
Stephen White
Comment 12 2011-03-17 13:58:55 PDT
Interestingly, it seems only the WinXP bots were affected. Not only is Linux unaffected, but so were Vista and Win7 (test times went up by about 15 sec overall, but that's to be expected due to the shadow algorithm). So it seems to be an XP problem.
Stephen White
Comment 13 2011-03-17 14:02:19 PDT
(In reply to comment #11) > When you run these tests locally, are you running DRT with Mesa? If so, it really should behave the same as on the bots regardless of the kind of GPU (or lack thereof) on the system. Yes, DRT with Mesa. Seems like XP is doing something weird (see previous). > BTW, it could certainly be Mesa doing something wrong or bad. Earlier versions of Mesa than the one we currently use (7.9) had terrible bugs in the shader compiler including infinite loops during compilation. Good to know. It seems ok on other OS'es, though, and they're all running the same version of Mesa, AFAIK.
Kenneth Russell
Comment 14 2011-03-17 14:12:14 PDT
(In reply to comment #13) > (In reply to comment #11) > > When you run these tests locally, are you running DRT with Mesa? If so, it really should behave the same as on the bots regardless of the kind of GPU (or lack thereof) on the system. > > Yes, DRT with Mesa. Seems like XP is doing something weird (see previous). That's strange. I can't imagine why there would be different behavior. Is there any chance you can test on XP locally? > > BTW, it could certainly be Mesa doing something wrong or bad. Earlier versions of Mesa than the one we currently use (7.9) had terrible bugs in the shader compiler including infinite loops during compilation. > > Good to know. It seems ok on other OS'es, though, and they're all running the same version of Mesa, AFAIK.
Stephen White
Comment 15 2011-03-17 15:56:19 PDT
(In reply to comment #14) > (In reply to comment #13) > > (In reply to comment #11) > > > When you run these tests locally, are you running DRT with Mesa? If so, it really should behave the same as on the bots regardless of the kind of GPU (or lack thereof) on the system. > > > > Yes, DRT with Mesa. Seems like XP is doing something weird (see previous). > > That's strange. I can't imagine why there would be different behavior. Is there any chance you can test on XP locally? I just installed "Windows XP Mode", a VM for Win7, and I can repro the slowdown there. Still investigating.
Stephen White
Comment 16 2011-03-18 07:40:00 PDT
(In reply to comment #15) > I just installed "Windows XP Mode", a VM for Win7, and I can repro the slowdown there. Still investigating. Seems to be a bug in talloc (or a bug in MSVC's vsnprintf implementation, depending on how you look at it). Fix up for review at http://codereview.chromium.org/6711035/.
Stephen White
Comment 17 2011-03-18 14:03:57 PDT
Note You need to log in before you can comment on or make changes to this bug.