RESOLVED FIXED49355
WebGLRenderingContext needs to zero textures and renderbuffers
https://bugs.webkit.org/show_bug.cgi?id=49355
Summary WebGLRenderingContext needs to zero textures and renderbuffers
Chris Marrin
Reported 2010-11-10 16:58:15 PST
WebGL must not have uninitialized data in any buffer. Currently if you pass 0 for the pixel pointer, the texture will be uninitialized.
Attachments
patch (16.20 KB, patch)
2010-11-16 16:30 PST, Zhenyao Mo
zmo: commit-queue-
revised patch: fix compile issue for webkit (16.21 KB, patch)
2010-11-16 16:39 PST, Zhenyao Mo
kbr: review-
zmo: commit-queue-
revised patch: responding to kbr's review (16.35 KB, patch)
2010-11-17 11:46 PST, Zhenyao Mo
zmo: commit-queue-
revised patch (32.87 KB, patch)
2010-12-06 17:34 PST, Zhenyao Mo
kbr: review-
zmo: commit-queue-
revised patch (34.66 KB, patch)
2010-12-09 12:18 PST, Zhenyao Mo
zmo: commit-queue-
revised patch: fix a tiny issue (34.38 KB, patch)
2010-12-09 12:33 PST, Zhenyao Mo
no flags
Patch (34.38 KB, patch)
2010-12-09 16:09 PST, Zhenyao Mo
no flags
Patch (34.40 KB, patch)
2010-12-09 18:07 PST, Zhenyao Mo
kbr: review+
Zhenyao Mo
Comment 1 2010-11-11 09:33:14 PST
I think should do it in WebGLRenderingContext::texImage2DBase(), because 1) this will take care of all ports, 2) framebuffer initialization also happens at WebGLRenderingContext level. If you don't mind, I can take this bug as we need to remove the duplicated code in Chromium.
Kenneth Russell
Comment 2 2010-11-11 12:30:03 PST
Agreed -- Chris and I discussed this over IRC and we agree that the texture and renderbuffer initialization should be done at levels above GraphicsContext3D, but only if the GC3D implementation doesn't already do it (need to add another method like clearsTexturesAndRenderbuffers()). Reassigning and changing synopsis.
Zhenyao Mo
Comment 3 2010-11-16 16:30:25 PST
Created attachment 74056 [details] patch Test is in sync with khronos.
Eric Seidel (no email)
Comment 4 2010-11-16 16:34:08 PST
Zhenyao Mo
Comment 5 2010-11-16 16:39:23 PST
Created attachment 74058 [details] revised patch: fix compile issue for webkit
Kenneth Russell
Comment 6 2010-11-17 10:54:26 PST
Comment on attachment 74058 [details] revised patch: fix compile issue for webkit View in context: https://bugs.webkit.org/attachment.cgi?id=74058&action=review This mostly looks good. Minor code and formatting issues. > WebCore/html/canvas/WebGLRenderingContext.cpp:2512 > + zero.set(new unsigned char[size]); This should be "zero = adoptArrayPtr(new unsigned char[size]);". > LayoutTests/fast/canvas/webgl/uninitialized-test.html:75 > +if (data.length != expectedDataLength) { > + testFailed("expected data length " + expectedDataLength + " but got " + data.length + " instead."); > +} else { > + var k = 0; > + for (var i = 0; i < data.length; ++i) { > + if (data[i] != 0) { > + k++; > + } > + } > + > + if (k) { > + testFailed("Found " + k + " non-zero bytes"); > + } else { > + testPassed("All data initialized"); > + } > +} Indentation is very messed up.
Zhenyao Mo
Comment 7 2010-11-17 11:46:46 PST
Created attachment 74140 [details] revised patch: responding to kbr's review Fixed the test indent issue on khronos and synced with it.
Kenneth Russell
Comment 8 2010-11-17 11:49:14 PST
Comment on attachment 74140 [details] revised patch: responding to kbr's review Looks good.
Zhenyao Mo
Comment 9 2010-11-17 11:55:35 PST
David Levin
Comment 10 2010-11-17 20:55:33 PST
Rolled out here: http://trac.webkit.org/changeset/72273 It caused many >10 regressions on Win and Linux gpu layout test runs.
David Levin
Comment 11 2010-11-17 22:06:55 PST
Comment on attachment 74140 [details] revised patch: responding to kbr's review Clearing r+ and obsoleting bad patch. After this was rolled out, the gpu layout tests started passing.
Zhenyao Mo
Comment 12 2010-11-18 17:07:13 PST
Comment on attachment 74140 [details] revised patch: responding to kbr's review This patch is actually correct, only that it exposes a bug in DrawingBuffer.cpp:reset(). Will wait until the fix for that lands to ask review again.
David Levin
Comment 13 2010-11-18 17:18:29 PST
(In reply to comment #12) > (From update of attachment 74140 [details]) > This patch is actually correct, only that it exposes a bug in DrawingBuffer.cpp:reset(). Will wait until the fix for that lands to ask review again. Regardless of correctness, the key idea is to run the gpu layout tests (and address failures) OR else you leave the gardener with some odd choices: 1. Try to rebaseline things. (I'm not sure if we have instructions about how to do this for the gpu tests. Also we have to look hard at the results and try to determine if they are correct or there is a bug, etc.) 2. Roll it out. Also, not a trivial decision. Multiply this by lots of patches and then the gardener is having to potentially work 15+ hours days to keep up when tests aren't run :(
Zhenyao Mo
Comment 14 2010-11-18 17:21:41 PST
(In reply to comment #13) > (In reply to comment #12) > > (From update of attachment 74140 [details] [details]) > > This patch is actually correct, only that it exposes a bug in DrawingBuffer.cpp:reset(). Will wait until the fix for that lands to ask review again. > > Regardless of correctness, the key idea is to run the gpu layout tests (and address failures) OR else you leave the gardener with some odd choices: > > 1. Try to rebaseline things. (I'm not sure if we have instructions about how to do this for the gpu tests. Also we have to look hard at the results and try to determine if they are correct or there is a bug, etc.) > > 2. Roll it out. Also, not a trivial decision. > > Multiply this by lots of patches and then the gardener is having to potentially work 15+ hours days to keep up when tests aren't run :( I am sorry to put you through this. I didn't realize my change will effect something other than WebGL. Otherwise I will definitely run the gpu tests before committing.
Zhenyao Mo
Comment 15 2010-12-06 17:34:12 PST
Created attachment 75761 [details] revised patch Removing all the cases where pixels==null is passed to GraphicsContext3D::texImagde2D(). Per discussion with kbr, now an INVALID_VALUE is generated in GraphicsContext3D::texImagde2D if pixels==null. Tested in linux with --platform chromium-gpu and it's no longer crashing.
Kenneth Russell
Comment 16 2010-12-08 15:10:43 PST
Comment on attachment 75761 [details] revised patch View in context: https://bugs.webkit.org/attachment.cgi?id=75761&action=review > WebCore/html/canvas/WebGLRenderingContext.cpp:2534 > + zero = adoptArrayPtr(new unsigned char[size]); > + memset(zero.get(), 0, size); This construct is repeated many times throughout this code. It would be cleaner to use OwnFastMallocPtr<T> in conjunction with fastZeroedMalloc. The only issue is that OwnFastMallocPtr doesn't have a default constructor or assignment operator. Please go ahead and add them, and use them instead. (I don't think it's necessary to add a PassOwnFastMallocPtr class, just an assignment operator taking T*.)
Zhenyao Mo
Comment 17 2010-12-09 12:18:46 PST
Created attachment 76106 [details] revised patch Per discussion offline with kbr, a helper function texImage2DResourceSafe is added to GraphicsContext3D and used in various places in this patch.
Zhenyao Mo
Comment 18 2010-12-09 12:33:43 PST
Created attachment 76112 [details] revised patch: fix a tiny issue
Zhenyao Mo
Comment 19 2010-12-09 16:09:24 PST
Kenneth Russell
Comment 20 2010-12-09 16:30:18 PST
Comment on attachment 76130 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=76130&action=review The refactoring looks good but please clean up this one issue. > WebCore/platform/graphics/GraphicsContext3D.h:477 > + int texImage2DResourceSafe(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type); Returning int is gross. Please make this return bool.
Zhenyao Mo
Comment 21 2010-12-09 18:07:28 PST
Kenneth Russell
Comment 22 2010-12-13 09:33:03 PST
Comment on attachment 76148 [details] Patch Looks good. Thanks for persisting with this fix.
Zhenyao Mo
Comment 23 2010-12-21 17:15:33 PST
I think it landed, not sure why this hasn't been updated. Committed r74440: <http://trac.webkit.org/changeset/74440> The patch was tested on linux with --platform chromium-gpu, but not on Mac as my Mac is snowleopard. Will watch the bots.
Eric Seidel (no email)
Comment 24 2010-12-21 17:23:39 PST
Landed by you or by the commit-queue? (Wondering if I need to go look at the commit-queue logs for failures.)
Zhenyao Mo
Comment 25 2010-12-21 17:26:41 PST
Landed by me using webkit-patch land --ignore-builders
Eric Seidel (no email)
Comment 26 2010-12-21 18:01:46 PST
Hmm... If you saw an error message from webkit-patch land, I'd love to see it. :) Also, I don't think --ignore-builders even exists anymore. We certainly don't block lands on them. :)
Zhenyao Mo
Comment 27 2010-12-21 18:03:42 PST
(In reply to comment #26) > Hmm... If you saw an error message from webkit-patch land, I'd love to see it. :) > > Also, I don't think --ignore-builders even exists anymore. We certainly don't block lands on them. :) Unfortunately I didn't see any error messages.
Note You need to log in before you can comment on or make changes to this bug.