Bug 51559 - copyTexSubImage2D shouldn't have undefined pixels
Summary: copyTexSubImage2D shouldn't have undefined pixels
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Zhenyao Mo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-23 13:21 PST by Zhenyao Mo
Modified: 2011-01-07 10:55 PST (History)
6 users (show)

See Also:


Attachments
Patch (15.30 KB, patch)
2011-01-06 11:26 PST, Zhenyao Mo
no flags Details | Formatted Diff | Diff
Patch (17.47 KB, patch)
2011-01-06 14:50 PST, Zhenyao Mo
no flags Details | Formatted Diff | Diff
Patch (17.70 KB, patch)
2011-01-07 09:36 PST, Zhenyao Mo
kbr: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhenyao Mo 2010-12-23 13:21:48 PST
if the region is beyond the currently bound fbo's bounds, we need to either clean undefined pixels to 0 or make sure they stay unchanged.  Undefined leads to potential leaking.
Comment 1 Zhenyao Mo 2011-01-06 09:23:15 PST
After discussing it on public_webgl email list, we are going to set the undefined pixels to 0.
Comment 2 Zhenyao Mo 2011-01-06 11:26:23 PST
Created attachment 78134 [details]
Patch
Comment 3 Zhenyao Mo 2011-01-06 11:26:59 PST
(In reply to comment #2)
> Created an attachment (id=78134) [details]
> Patch

Will commit the test changes to khronos once reviewed.
Comment 4 WebKit Review Bot 2011-01-06 11:53:49 PST
Attachment 78134 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/7374010
Comment 5 Eric Seidel (no email) 2011-01-06 12:11:35 PST
Comment on attachment 78134 [details]
Patch

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

> WebCore/html/canvas/WebGLRenderingContext.cpp:725
> +        long clippedX, clippedY, clippedWidth, clippedHeight;
> +        clip(x, width, getBoundFramebufferWidth(), &clippedX, &clippedWidth);
> +        clip(y, height, getBoundFramebufferHeight(), &clippedY, &clippedHeight);
> +        if (clippedX != x || clippedY != y || clippedWidth != width || clippedHeight != height) {
> +            unsigned long format = tex->getInternalFormat(target, level);

Shouldn't this huge block be a new helper function?  It could (should!) even be just static to the file.
Comment 6 WebKit Review Bot 2011-01-06 12:30:25 PST
Attachment 78134 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/7401013
Comment 7 Kenneth Russell 2011-01-06 14:49:17 PST
(In reply to comment #5)
> (From update of attachment 78134 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=78134&action=review
> 
> > WebCore/html/canvas/WebGLRenderingContext.cpp:725
> > +        long clippedX, clippedY, clippedWidth, clippedHeight;
> > +        clip(x, width, getBoundFramebufferWidth(), &clippedX, &clippedWidth);
> > +        clip(y, height, getBoundFramebufferHeight(), &clippedY, &clippedHeight);
> > +        if (clippedX != x || clippedY != y || clippedWidth != width || clippedHeight != height) {
> > +            unsigned long format = tex->getInternalFormat(target, level);
> 
> Shouldn't this huge block be a new helper function?  It could (should!) even be just static to the file.

I think it's fine in its current form. It isn't duplicated code, and accesses members several times (m_context, getBoundFramebufferWidth/Height) making it inconvenient to write as anything but a method.
Comment 8 Zhenyao Mo 2011-01-06 14:50:53 PST
Created attachment 78166 [details]
Patch
Comment 9 Zhenyao Mo 2011-01-06 14:53:23 PST
(In reply to comment #8)
> Created an attachment (id=78166) [details]
> Patch

This patch fixes the build failure on chromium.  Also, I refactor the code a little bit, adding a new function clip2D and call it in both copyTexImage2D and copyTexSubImage2D.
Comment 10 Kenneth Russell 2011-01-06 15:02:41 PST
Comment on attachment 78166 [details]
Patch

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

This basically looks good. One issue needing a revision.

> WebCore/html/canvas/WebGLRenderingContext.cpp:752
> +            m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, zero.get());

The unpack alignment needs to be set to 1 before this call and restored afterward. See the various WebGLRenderingContext::texSubImage2D variants in this file.
Comment 11 Zhenyao Mo 2011-01-07 09:36:49 PST
Created attachment 78243 [details]
Patch
Comment 12 Kenneth Russell 2011-01-07 10:05:53 PST
Comment on attachment 78243 [details]
Patch

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

Looks good - one minor issue with the new code which can be fixed upon landing.

> WebCore/html/canvas/WebGLRenderingContext.cpp:752
> +            if (zero.get())

This can just be if (zero). These pointer types have an operator which converts to boolean type.

> WebCore/html/canvas/WebGLRenderingContext.cpp:755
> +            if (zero.get())

Here too.
Comment 13 Zhenyao Mo 2011-01-07 10:20:22 PST
Committed r75252: <http://trac.webkit.org/changeset/75252>
Comment 14 Stephen White 2011-01-07 10:37:53 PST
This may have caused a build fail on the canary:

http://build.chromium.org/p/chromium.webkit/builders/Webkit%20Linux/builds/5595/steps/compile/logs/stdio
Comment 15 Zhenyao Mo 2011-01-07 10:43:58 PST
(In reply to comment #14)
> This may have caused a build fail on the canary:
> 
> http://build.chromium.org/p/chromium.webkit/builders/Webkit%20Linux/builds/5595/steps/compile/logs/stdio

I am on it.  Just a sec.
Comment 16 Zhenyao Mo 2011-01-07 10:53:53 PST
This should fix it: r75254: <http://trac.webkit.org/changeset/75254>
Comment 17 Stephen White 2011-01-07 10:55:37 PST
(In reply to comment #16)
> This should fix it: r75254: <http://trac.webkit.org/changeset/75254>

Thanks!