Bug 1324626 - Pick a MAX_CLIENT_WAIT_TIMEOUT_WEBGL. - r=lenzak800. a=gchang
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 19 Dec 2016 19:31:18 -0800
changeset 353138 a38cb48ceb9d53e10eb383847e6d1e99c19c0506
parent 353137 06c0d166c9b74d4929f98ba6cbae425c48dc7a05
child 353139 eb81172cbbbb6042a28106c576433747785d6084
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslenzak800, gchang
bugs1324626
milestone52.0a2
Bug 1324626 - Pick a MAX_CLIENT_WAIT_TIMEOUT_WEBGL. - r=lenzak800. a=gchang MozReview-Commit-ID: L4gaasXZYFb
dom/canvas/WebGL2Context.h
dom/canvas/WebGL2ContextState.cpp
dom/canvas/WebGL2ContextSync.cpp
--- a/dom/canvas/WebGL2Context.h
+++ b/dom/canvas/WebGL2Context.h
@@ -326,16 +326,18 @@ public:
     void SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param);
     void GetSamplerParameter(JSContext*, const WebGLSampler& sampler, GLenum pname,
                              JS::MutableHandleValue retval);
 
 
     // -------------------------------------------------------------------------
     // Sync objects - WebGL2ContextSync.cpp
 
+    const GLuint64 kMaxClientWaitSyncTimeoutNS = 1000 * 1000 * 1000; // 1000ms in ns.
+
     already_AddRefed<WebGLSync> FenceSync(GLenum condition, GLbitfield flags);
     bool IsSync(const WebGLSync* sync);
     void DeleteSync(WebGLSync* sync);
     GLenum ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64 timeout);
     void WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout);
     void GetSyncParameter(JSContext*, const WebGLSync& sync, GLenum pname,
                           JS::MutableHandleValue retval);
 
--- a/dom/canvas/WebGL2ContextState.cpp
+++ b/dom/canvas/WebGL2ContextState.cpp
@@ -107,17 +107,17 @@ WebGL2Context::GetParameter(JSContext* c
       // value is 4 * GL_MAX_VARYING_VECTORS
       GLint val;
       gl->fGetIntegerv(LOCAL_GL_MAX_VARYING_VECTORS, &val);
       return JS::Int32Value(4*val);
     }
 
     /* GLint64 */
     case LOCAL_GL_MAX_CLIENT_WAIT_TIMEOUT_WEBGL:
-      return JS::NumberValue(0); // TODO
+      return JS::NumberValue(kMaxClientWaitSyncTimeoutNS);
 
     case LOCAL_GL_MAX_ELEMENT_INDEX:
       // GL_MAX_ELEMENT_INDEX becomes available in GL 4.3 or via ES3
       // compatibility
       if (!gl->IsSupported(gl::GLFeature::ES3_compatibility))
         return JS::NumberValue(UINT32_MAX);
 
       /*** fall through to fGetInteger64v ***/
--- a/dom/canvas/WebGL2ContextSync.cpp
+++ b/dom/canvas/WebGL2ContextSync.cpp
@@ -62,16 +62,22 @@ WebGL2Context::ClientWaitSync(const WebG
     if (!ValidateObject(funcName, sync))
         return LOCAL_GL_WAIT_FAILED;
 
     if (flags != 0 && flags != LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT) {
         ErrorInvalidValue("%s: `flags` must be SYNC_FLUSH_COMMANDS_BIT or 0.", funcName);
         return LOCAL_GL_WAIT_FAILED;
     }
 
+    if (timeout > kMaxClientWaitSyncTimeoutNS) {
+        ErrorInvalidOperation("%s: `timeout` must not exceed %s nanoseconds.", funcName,
+                              "MAX_CLIENT_WAIT_TIMEOUT_WEBGL");
+        return LOCAL_GL_WAIT_FAILED;
+    }
+
     MakeContextCurrent();
     return gl->fClientWaitSync(sync.mGLName, flags, timeout);
 }
 
 void
 WebGL2Context::WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout)
 {
     const char funcName[] = "waitSync";