Bug 1376039 - WebGL Conformance Failure: deqp/functional/gles3/integerstatequery.html. r=jgilbert
authorSamuel Vargas <svargas@mozilla.com>
Fri, 23 Jun 2017 16:19:49 -0700
changeset 419912 a5cf326ec71fb60712b5e71e7806a7bd42eedaa8
parent 419911 3090d33a19ebedcb995ddf465993d84d1c62f921
child 419913 91ad989f575a06790a03b891633fdbdde2bd0f59
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1376039
milestone56.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 1376039 - WebGL Conformance Failure: deqp/functional/gles3/integerstatequery.html. r=jgilbert
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLContextValidate.cpp
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1575,16 +1575,17 @@ public:
         FailureReason() { }
 
         template<typename A, typename B>
         FailureReason(const A& _key, const B& _info)
             : key(nsCString(_key))
             , info(nsCString(_info))
         { }
     };
+    bool ValidateBlendFuncEnum(GLenum factor, const char *funcName, const char* varName);
 protected:
     bool InitWebGL2(FailureReason* const out_failReason);
 
     bool CreateAndInitGL(bool forceEnabled,
                          std::vector<FailureReason>* const out_failReasons);
 
     bool ResizeBackbuffer(uint32_t width, uint32_t height);
 
@@ -1599,18 +1600,16 @@ protected:
 
     void ThrowEvent_WebGLContextCreationError(const nsACString& text);
 
     // -------------------------------------------------------------------------
     // Validation functions (implemented in WebGLContextValidate.cpp)
     bool InitAndValidateGL(FailureReason* const out_failReason);
 
     bool ValidateBlendEquationEnum(GLenum cap, const char* info);
-    bool ValidateBlendFuncDstEnum(GLenum mode, const char* info);
-    bool ValidateBlendFuncSrcEnum(GLenum mode, const char* info);
     bool ValidateBlendFuncEnumsCompatibility(GLenum sfactor, GLenum dfactor,
                                              const char* info);
     bool ValidateComparisonEnum(GLenum target, const char* info);
     bool ValidateStencilOpEnum(GLenum action, const char* info);
     bool ValidateFaceEnum(GLenum face, const char* info);
     bool ValidateTexInputData(GLenum type, js::Scalar::Type jsArrayType,
                               WebGLTexImageFunc func, WebGLTexDimensions dims);
     bool ValidateDrawModeEnum(GLenum mode, const char* info);
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -210,44 +210,66 @@ void WebGLContext::BlendEquationSeparate
     if (!ValidateBlendEquationEnum(modeRGB, "blendEquationSeparate: modeRGB") ||
         !ValidateBlendEquationEnum(modeAlpha, "blendEquationSeparate: modeAlpha"))
         return;
 
     MakeContextCurrent();
     gl->fBlendEquationSeparate(modeRGB, modeAlpha);
 }
 
+static bool
+ValidateBlendFuncEnums(WebGLContext* webgl, GLenum srcRGB, GLenum srcAlpha,
+                       GLenum dstRGB, GLenum dstAlpha, const char* funcName)
+{
+    if (!webgl->IsWebGL2()) {
+       if (dstRGB == LOCAL_GL_SRC_ALPHA_SATURATE || dstAlpha == LOCAL_GL_SRC_ALPHA_SATURATE) {
+          const nsPrintfCString err("%s: LOCAL_GL_SRC_ALPHA_SATURATE as a destination"
+                                    " blend function is disallowed in WebGL 1 (dstRGB ="
+                                    " 0x%04x, dstAlpha = 0x%04x).",
+                                    funcName, dstRGB, dstAlpha);
+          webgl->ErrorInvalidEnum("%s", err.get());
+          return false;
+       }
+    }
+
+    if (!webgl->ValidateBlendFuncEnum(srcRGB, funcName, "srcRGB") ||
+        !webgl->ValidateBlendFuncEnum(srcAlpha, funcName, "srcAlpha") ||
+        !webgl->ValidateBlendFuncEnum(dstRGB, funcName, "dstRGB") ||
+        !webgl->ValidateBlendFuncEnum(dstAlpha, funcName, "dstAlpha"))
+    {
+       return false;
+    }
+
+    return true;
+}
+
 void WebGLContext::BlendFunc(GLenum sfactor, GLenum dfactor)
 {
     if (IsContextLost())
         return;
 
-    if (!ValidateBlendFuncSrcEnum(sfactor, "blendFunc: sfactor") ||
-        !ValidateBlendFuncDstEnum(dfactor, "blendFunc: dfactor"))
-        return;
+    if (!ValidateBlendFuncEnums(this, sfactor, sfactor, dfactor, dfactor, "blendFunc"))
+       return;
 
     if (!ValidateBlendFuncEnumsCompatibility(sfactor, dfactor, "blendFuncSeparate: srcRGB and dstRGB"))
         return;
 
     MakeContextCurrent();
     gl->fBlendFunc(sfactor, dfactor);
 }
 
 void
 WebGLContext::BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
                                 GLenum srcAlpha, GLenum dstAlpha)
 {
     if (IsContextLost())
         return;
 
-    if (!ValidateBlendFuncSrcEnum(srcRGB, "blendFuncSeparate: srcRGB") ||
-        !ValidateBlendFuncSrcEnum(srcAlpha, "blendFuncSeparate: srcAlpha") ||
-        !ValidateBlendFuncDstEnum(dstRGB, "blendFuncSeparate: dstRGB") ||
-        !ValidateBlendFuncDstEnum(dstAlpha, "blendFuncSeparate: dstAlpha"))
-        return;
+    if (!ValidateBlendFuncEnums(this, srcRGB, srcAlpha, dstRGB, dstAlpha, "blendFuncSeparate"))
+       return;
 
     // note that we only check compatibity for the RGB enums, no need to for the Alpha enums, see
     // "Section 6.8 forgetting to mention alpha factors?" thread on the public_webgl mailing list
     if (!ValidateBlendFuncEnumsCompatibility(srcRGB, dstRGB, "blendFuncSeparate: srcRGB and dstRGB"))
         return;
 
     MakeContextCurrent();
     gl->fBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -59,51 +59,44 @@ WebGLContext::ValidateBlendEquationEnum(
         break;
     }
 
     ErrorInvalidEnumInfo(info, mode);
     return false;
 }
 
 bool
-WebGLContext::ValidateBlendFuncDstEnum(GLenum factor, const char* info)
+WebGLContext::ValidateBlendFuncEnum(GLenum factor, const char *funcName, const char* varName)
 {
     switch (factor) {
     case LOCAL_GL_ZERO:
     case LOCAL_GL_ONE:
     case LOCAL_GL_SRC_COLOR:
     case LOCAL_GL_ONE_MINUS_SRC_COLOR:
     case LOCAL_GL_DST_COLOR:
     case LOCAL_GL_ONE_MINUS_DST_COLOR:
     case LOCAL_GL_SRC_ALPHA:
     case LOCAL_GL_ONE_MINUS_SRC_ALPHA:
     case LOCAL_GL_DST_ALPHA:
     case LOCAL_GL_ONE_MINUS_DST_ALPHA:
     case LOCAL_GL_CONSTANT_COLOR:
     case LOCAL_GL_ONE_MINUS_CONSTANT_COLOR:
     case LOCAL_GL_CONSTANT_ALPHA:
     case LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA:
+    case LOCAL_GL_SRC_ALPHA_SATURATE:
         return true;
 
     default:
-        ErrorInvalidEnumInfo(info, factor);
+        const nsPrintfCString err("%s: %s", funcName, varName);
+        ErrorInvalidEnumInfo(err.get(), factor);
         return false;
     }
 }
 
 bool
-WebGLContext::ValidateBlendFuncSrcEnum(GLenum factor, const char* info)
-{
-    if (factor == LOCAL_GL_SRC_ALPHA_SATURATE)
-        return true;
-
-    return ValidateBlendFuncDstEnum(factor, info);
-}
-
-bool
 WebGLContext::ValidateBlendFuncEnumsCompatibility(GLenum sfactor,
                                                   GLenum dfactor,
                                                   const char* info)
 {
     bool sfactorIsConstantColor = sfactor == LOCAL_GL_CONSTANT_COLOR ||
                                   sfactor == LOCAL_GL_ONE_MINUS_CONSTANT_COLOR;
     bool sfactorIsConstantAlpha = sfactor == LOCAL_GL_CONSTANT_ALPHA ||
                                   sfactor == LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA;