Bug 1260599 - Enable EXT_disjoint_timer_query extension on ANGLE. r=jgilbert
☠☠ backed out by b3eb53d8f4be ☠ ☠
authorEthan Lin <ethlin@mozilla.com>
Tue, 26 Jul 2016 12:51:32 +0800
changeset 349233 d50028181044d7ae0bba5ee407991b07162fec3f
parent 349232 182cfbd9715f4a2d761943c6fae9adf5aa7123a2
child 349234 4e066314768c2002bd3dc699542f44c908aed7ab
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1260599
milestone50.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 1260599 - Enable EXT_disjoint_timer_query extension on ANGLE. r=jgilbert
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextState.cpp
dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1621,16 +1621,23 @@ WebGLContext::DummyReadFramebufferOperat
             errorText += ": ";
             errorText += fbStatusInfo;
         }
 
         ErrorInvalidFramebufferOperation("%s: %s.", funcName, errorText.BeginReading());
     }
 }
 
+bool
+WebGLContext::HasTimestampBits() const
+{
+    // 'sync' provides glGetInteger64v either by supporting ARB_sync, GL3+, or GLES3+.
+    return gl->IsSupported(GLFeature::sync);
+}
+
 static bool
 CheckContextLost(GLContext* gl, bool* const out_isGuilty)
 {
     MOZ_ASSERT(gl);
     MOZ_ASSERT(out_isGuilty);
 
     bool isEGL = gl->GetContextType() == gl::GLContextType::EGL;
 
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1468,16 +1468,18 @@ protected:
 
     uint64_t mLastUseIndex;
 
     bool mNeedsFakeNoAlpha;
     bool mNeedsFakeNoDepth;
     bool mNeedsFakeNoStencil;
     bool mNeedsEmulatedLoneDepthStencil;
 
+    bool HasTimestampBits() const;
+
     struct ScopedMaskWorkaround {
         WebGLContext& mWebGL;
         const bool mFakeNoAlpha;
         const bool mFakeNoDepth;
         const bool mFakeNoStencil;
 
         static bool ShouldFakeNoAlpha(WebGLContext& webgl) {
             // We should only be doing this if we're about to draw to the backbuffer, but
--- a/dom/canvas/WebGLContextState.cpp
+++ b/dom/canvas/WebGLContextState.cpp
@@ -262,17 +262,21 @@ WebGLContext::GetParameter(JSContext* cx
                 (mBoundVertexArray != mDefaultVertexArray) ? mBoundVertexArray.get() : nullptr;
             return WebGLObjectAsJSValue(cx, vao, rv);
         }
     }
 
     if (IsWebGL2() || IsExtensionEnabled(WebGLExtensionID::EXT_disjoint_timer_query)) {
         if (pname == LOCAL_GL_TIMESTAMP_EXT) {
             GLuint64 iv = 0;
-            gl->fGetInteger64v(pname, (GLint64*) &iv);
+            if (HasTimestampBits()) {
+                gl->fGetInteger64v(pname, (GLint64*)&iv);
+            } else {
+                GenerateWarning("QUERY_COUNTER_BITS_EXT for TIMESTAMP_EXT is 0.");
+            }
             // TODO: JS doesn't support 64-bit integers. Be lossy and
             // cast to double (53 bits)
             return JS::NumberValue(static_cast<double>(iv));
         } else if (pname == LOCAL_GL_GPU_DISJOINT_EXT) {
             // When disjoint isn't supported, leave as false.
             realGLboolean disjoint = LOCAL_GL_FALSE;
             if (gl->IsExtensionSupported(gl::GLContext::EXT_disjoint_timer_query)) {
                 gl->fGetBooleanv(pname, &disjoint);
--- a/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
+++ b/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
@@ -172,17 +172,19 @@ WebGLExtensionDisjointTimerQuery::GetQue
   case LOCAL_GL_QUERY_COUNTER_BITS_EXT: {
     if (target != LOCAL_GL_TIME_ELAPSED_EXT &&
         target != LOCAL_GL_TIMESTAMP_EXT) {
       mContext->ErrorInvalidEnumInfo("getQueryEXT: Invalid query target.",
                                      target);
       return;
     }
     GLint bits = 0;
-    mContext->GL()->fGetQueryiv(target, pname, &bits);
+    if (mContext->HasTimestampBits()) {
+      mContext->GL()->fGetQueryiv(target, pname, &bits);
+    }
     retval.set(JS::Int32Value(int32_t(bits)));
     break;
   }
   default:
     mContext->ErrorInvalidEnumInfo("getQueryEXT: Invalid query property.",
                                    pname);
     break;
   }
@@ -237,21 +239,17 @@ WebGLExtensionDisjointTimerQuery::GetQue
 
 bool
 WebGLExtensionDisjointTimerQuery::IsSupported(const WebGLContext* webgl)
 {
   webgl->MakeContextCurrent();
   gl::GLContext* gl = webgl->GL();
   return gl->IsSupported(gl::GLFeature::query_objects) &&
          gl->IsSupported(gl::GLFeature::get_query_object_i64v) &&
-         gl->IsSupported(gl::GLFeature::query_counter) && // provides GL_TIMESTAMP
-         gl->IsSupported(gl::GLFeature::sync); // provides glGetInteger64v
-  // 'sync' provides glGetInteger64v either by supporting ARB_sync, GL3+, or GLES3+.
-  // Since there are no differences between support for glGetInteger64v and support for
-  // 'sync', we just piggy-back off of 'sync'.
+         gl->IsSupported(gl::GLFeature::query_counter); // provides GL_TIMESTAMP
 }
 
 void
 WebGLExtensionDisjointTimerQuery::OnMarkLost()
 {
   mActiveQuery = nullptr;
 }