Bug 38700

Summary: drawElements/drawArrays should validate input parameters according to GLES2 spec
Product: WebKit Reporter: Kenneth Russell <kbr>
Component: WebGLAssignee: Zhenyao Mo <zmo>
Status: RESOLVED FIXED    
Severity: Normal CC: cmarrin, commit-queue, oliver, zmo
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
patch
none
revised patch: responding to kbr's review none

Kenneth Russell
Reported 2010-05-06 15:43:31 PDT
Gregg Tavares points out that WebGLRenderingContext::drawElements currently generates an INVALID_OPERATION error if the UNSIGNED_INT type is passed in, because the index validation code catches the invalid enum but always causes INVALID_OPERATION to be generated. Per the OpenGL ES 2.0 spec, INVALID_ENUM should be generated in this case.
Attachments
patch (44.34 KB, patch)
2010-06-09 17:41 PDT, Zhenyao Mo
no flags
revised patch: responding to kbr's review (44.53 KB, patch)
2010-06-10 16:12 PDT, Zhenyao Mo
no flags
Zhenyao Mo
Comment 1 2010-06-09 17:35:50 PDT
Several cases should return INVALID_VALUE instead of INVALID_OPERATION.
Zhenyao Mo
Comment 2 2010-06-09 17:41:11 PDT
Kenneth Russell
Comment 3 2010-06-10 15:39:19 PDT
Comment on attachment 58315 [details] patch Mostly looks good. A few issues. WebCore/html/canvas/WebGLRenderingContext.cpp:824 + if (!validateDrawMode(mode)) From recent emails on the public-webgl mailing list it sounds like they may want to strictly specify the order in which errors are returned if the inputs would generate multiple errors. For example, INVALID_ENUM would be preferred over INVALID_VALUE. Because of this, even though it may mean doing some redundant validation, I think we should remove the isGLES2Compliant() check here and always validate the draw mode. LayoutTests/fast/canvas/webgl/resources/webgl-test.js:110 + testFailed(evalStr + " expected: " + getGLErrorAsString(ctx, glError) + ". Was " + getGLErrorAsString(ctx, err) + "."); Can you say here "expected GL error:" and ". Generated: " for clarity? LayoutTests/fast/canvas/webgl/resources/webgl-test.js:112 + testPassed(evalStr + " was expected value: " + getGLErrorAsString(ctx, glError) + "."); Can you say here " generated expected GL error: " for clarity? LayoutTests/fast/canvas/webgl/draw-elements-out-of-bounds.html:44 + shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawElements(0x0009, 3, context.UNSIGNED_INT, 0)"); // GL_POLYGON You should use UNSIGNED_BYTE here to make sure you're producing the error for the first enum error and not the second.
Zhenyao Mo
Comment 4 2010-06-10 16:12:30 PDT
Created attachment 58421 [details] revised patch: responding to kbr's review
Kenneth Russell
Comment 5 2010-06-10 17:08:41 PDT
Comment on attachment 58421 [details] revised patch: responding to kbr's review Looks good.
Dimitri Glazkov (Google)
Comment 6 2010-06-10 21:31:30 PDT
Comment on attachment 58421 [details] revised patch: responding to kbr's review ok.
WebKit Commit Bot
Comment 7 2010-06-11 07:38:53 PDT
Comment on attachment 58421 [details] revised patch: responding to kbr's review Clearing flags on attachment: 58421 Committed r61017: <http://trac.webkit.org/changeset/61017>
WebKit Commit Bot
Comment 8 2010-06-11 07:38:59 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.