Bug 1325500 (flattened) - Fix DrawRangeElements impl and require size=4 for packed int types. - r=daoshengmu
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 22 Dec 2016 15:59:45 -0800
changeset 374606 2b152e51f03e9e7ab92f762a047d3b9ea5e91d76
parent 374605 e7dd70acbc2322f41830933c0204d92450412bb3
child 374607 5a10fa45d8eac53a005130946302c3fb2471d9e2
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaoshengmu
bugs1325500
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1325500 (flattened) - Fix DrawRangeElements impl and require size=4 for packed int types. - r=daoshengmu MozReview-Commit-ID: B3YpgZn48Nl
dom/canvas/WebGL2Context.h
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextDraw.cpp
dom/canvas/WebGLContextValidate.cpp
--- a/dom/canvas/WebGL2Context.h
+++ b/dom/canvas/WebGL2Context.h
@@ -271,17 +271,26 @@ public:
     void VertexAttribDivisor(GLuint index, GLuint divisor);
     void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount);
     void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, GLintptr offset, GLsizei instanceCount);
     */
 
     void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
                            GLenum type, WebGLintptr byteOffset)
     {
-        DrawElements(mode, count, type, byteOffset);
+        const char funcName[] = "drawRangeElements";
+        if (IsContextLost())
+            return;
+
+        if (end < start) {
+            ErrorInvalidValue("%s: end must be >= start.", funcName);
+            return;
+        }
+
+        DrawElements(mode, count, type, byteOffset, funcName);
     }
 
     // ------------------------------------------------------------------------
     // Multiple Render Targets - WebGL2ContextMRTs.cpp
     /* Implemented in WebGLContext
     void DrawBuffers(const dom::Sequence<GLenum>& buffers);
     */
 
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1255,17 +1255,17 @@ protected:
 // Vertices Feature (WebGLContextVertices.cpp)
     GLenum mPrimRestartTypeBytes;
 
 public:
     void DrawArrays(GLenum mode, GLint first, GLsizei count);
     void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
                              GLsizei primcount);
     void DrawElements(GLenum mode, GLsizei count, GLenum type,
-                      WebGLintptr byteOffset);
+                      WebGLintptr byteOffset, const char* funcName = nullptr);
     void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
                                WebGLintptr byteOffset, GLsizei primcount);
 
     void EnableVertexAttribArray(GLuint index);
     void DisableVertexAttribArray(GLuint index);
 
     JS::Value GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
                               ErrorResult& rv);
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -691,19 +691,22 @@ WebGLContext::DrawElements_check(const c
                         funcName, WebGLContext::EnumName(type));
     }
 
     return true;
 }
 
 void
 WebGLContext::DrawElements(GLenum mode, GLsizei vertCount, GLenum type,
-                           WebGLintptr byteOffset)
+                           WebGLintptr byteOffset, const char* funcName)
 {
-    const char funcName[] = "drawElements";
+    if (!funcName) {
+        funcName = "drawElements";
+    }
+
     if (IsContextLost())
         return;
 
     MakeContextCurrent();
 
     bool error = false;
     ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
     if (error)
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -357,16 +357,26 @@ WebGLContext::ValidateAttribPointer(bool
     MOZ_ASSERT(IsPowerOfTwo(requiredAlignment));
     GLsizei requiredAlignmentMask = requiredAlignment - 1;
 
     if (size < 1 || size > 4) {
         ErrorInvalidValue("%s: invalid element size", info);
         return false;
     }
 
+    switch (type) {
+    case LOCAL_GL_INT_2_10_10_10_REV:
+    case LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV:
+        if (size != 4) {
+            ErrorInvalidOperation("%s: size must be 4 for this type.", info);
+            return false;
+        }
+        break;
+    }
+
     // see WebGL spec section 6.6 "Vertex Attribute Data Stride"
     if (stride < 0 || stride > 255) {
         ErrorInvalidValue("%s: negative or too large stride", info);
         return false;
     }
 
     if (byteOffset < 0) {
         ErrorInvalidValue("%s: negative offset", info);