Title: [264535] trunk
Revision
264535
Author
[email protected]
Date
2020-07-17 14:51:16 -0700 (Fri, 17 Jul 2020)

Log Message

[WebGL2] Sync objects
https://bugs.webkit.org/show_bug.cgi?id=126942

Patch by James Darpinian <[email protected]> on 2020-07-17
Reviewed by Dean Jackson.

Source/WebCore:

Passes WebGL conformance tests
webgl/2.0.0/conformance2/sync/sync-webgl-specific.html
and
webgl/2.0.0/deqp/functional/gles3/sync.html

although the latter times out in the layout test harness.

* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::fenceSync):
(WebCore::WebGL2RenderingContext::isSync):
(WebCore::WebGL2RenderingContext::deleteSync):
(WebCore::WebGL2RenderingContext::clientWaitSync):
(WebCore::WebGL2RenderingContext::waitSync):
(WebCore::WebGL2RenderingContext::getSyncParameter):
* html/canvas/WebGLRenderingContextBase.h:
* html/canvas/WebGLSync.cpp:
(WebCore::WebGLSync::WebGLSync):
(WebCore::WebGLSync::deleteObjectImpl):
(WebCore::WebGLSync::updateCache):
(WebCore::WebGLSync::getCachedResult const):
(WebCore::WebGLSync::isSignaled const):
(WebCore::WebGLSync::scheduleAllowCacheUpdate):
* html/canvas/WebGLSync.h:
* platform/graphics/GraphicsContextGL.h:
* platform/graphics/GraphicsTypesGL.h:
* platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLOpenGL::fenceSync):
(WebCore::GraphicsContextGLOpenGL::isSync):
(WebCore::GraphicsContextGLOpenGL::deleteSync):
(WebCore::GraphicsContextGLOpenGL::clientWaitSync):
(WebCore::GraphicsContextGLOpenGL::waitSync):
(WebCore::GraphicsContextGLOpenGL::getSynciv):
* platform/graphics/opengl/GraphicsContextGLOpenGL.h:
* platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp:
(WebCore::GraphicsContextGLOpenGL::fenceSync):
(WebCore::GraphicsContextGLOpenGL::isSync):
(WebCore::GraphicsContextGLOpenGL::deleteSync):
(WebCore::GraphicsContextGLOpenGL::clientWaitSync):
(WebCore::GraphicsContextGLOpenGL::waitSync):
(WebCore::GraphicsContextGLOpenGL::getSynciv):

LayoutTests:

* webgl/TestExpectations:
webgl/2.0.0/deqp/functional/gles3/sync.html times out in the layout test harness, though it passes in MiniBrowser.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (264534 => 264535)


--- trunk/LayoutTests/ChangeLog	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/LayoutTests/ChangeLog	2020-07-17 21:51:16 UTC (rev 264535)
@@ -1,3 +1,13 @@
+2020-07-17  James Darpinian  <[email protected]>
+
+        [WebGL2] Sync objects
+        https://bugs.webkit.org/show_bug.cgi?id=126942
+
+        Reviewed by Dean Jackson.
+
+        * webgl/TestExpectations:
+        webgl/2.0.0/deqp/functional/gles3/sync.html times out in the layout test harness, though it passes in MiniBrowser.
+
 2020-07-17  Truitt Savell  <[email protected]>
 
         Add Failing expectations for Windows and GTK after r264483

Modified: trunk/LayoutTests/webgl/2.0.0/conformance2/state/gl-object-get-calls-expected.txt (264534 => 264535)


--- trunk/LayoutTests/webgl/2.0.0/conformance2/state/gl-object-get-calls-expected.txt	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/LayoutTests/webgl/2.0.0/conformance2/state/gl-object-get-calls-expected.txt	2020-07-17 21:51:16 UTC (rev 264535)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: TypeError: Argument 1 ('sync') to WebGL2RenderingContext.getSyncParameter must be an instance of WebGLSync
 This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
 
 Test: ../../resources/webgl_test_files/conformance2/state/gl-object-get-calls.html
@@ -309,7 +308,61 @@
 [ 305: PASS ] gl.getSamplerParameter(sampler, gl.TEXTURE_WRAP_S) is gl.CLAMP_TO_EDGE
 [ 306: PASS ] gl.getSamplerParameter(sampler, gl.TEXTURE_WRAP_T) is gl.CLAMP_TO_EDGE
 [ 307: PASS ] getSamplerParameter correctly handled invalid pname enums
-[ 308: FAIL ] gl.getSyncParameter(sync, gl.OBJECT_TYPE) should be 37142. Threw exception TypeError: Argument 1 ('sync') to WebGL2RenderingContext.getSyncParameter must be an instance of WebGLSync
-[ 309: FAIL ] successfullyParsed should be true (of type boolean). Was undefined (of type undefined).
-[ FAIL ] 39 failures reported
+[ 308: PASS ] gl.getSyncParameter(sync, gl.OBJECT_TYPE) is gl.SYNC_FENCE
+[ 309: PASS ] gl.getSyncParameter(sync, gl.SYNC_CONDITION) is gl.UNSIGNALED
+[ 310: PASS ] gl.getSyncParameter(sync, gl.SYNC_CONDITION) is gl.SYNC_GPU_COMMANDS_COMPLETE
+[ 311: PASS ] gl.getSyncParameter(sync, gl.SYNC_FLAGS) is 0
+[ 312: PASS ] getSyncParameter correctly handled invalid pname enums
+[ 313: FAIL ] gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE) should be false (of type boolean). Was 0 (of type number).
+[ 314: PASS ] getQueryParameter correctly handled invalid pname enums
+[ 315: PASS ] gl.getShaderParameter(vertShader, gl.COMPILE_STATUS) is true
+[ 316: PASS ] gl.getShaderParameter(fragShader, gl.COMPILE_STATUS) is true
+[ 317: PASS ] gl.getProgramParameter(program, gl.LINK_STATUS) is true
+[ 318: PASS ] gl.getFragDataLocation(program, "vertexColor") is -1
+[ 319: PASS ] gl.getFragDataLocation(program, "modelViewMatrix") is -1
+[ 320: PASS ] gl.getFragDataLocation(program, "projectionMatrix") is -1
+[ 321: PASS ] gl.getFragDataLocation(program, "position") is -1
+[ 322: PASS ] gl.getFragDataLocation(program, "fragColor") is 0
+[ 323: PASS ] gl.getProgramParameter(program, gl.LINK_STATUS) is true
+[ 324: PASS ] gl.getError() is gl.NO_ERROR
+[ 325: PASS ] typeof rowMajors[i] is "boolean"
+[ 326: PASS ] typeof rowMajors[i] is "boolean"
+[ 327: PASS ] typeof rowMajors[i] is "boolean"
+[ 328: PASS ] getActiveUniforms correctly handled invalid pname enums
+[ 329: PASS ] gl.getProgramParameter(program, gl.LINK_STATUS) is true
+[ 330: PASS ] gl.getUniformBlockIndex(program, "Transform") is 0
+[ 331: PASS ] gl.getUniformBlockIndex(program, "u_modelViewMatrix") is gl.INVALID_INDEX
+[ 332: PASS ] gl.getUniformBlockIndex(program, "normal") is gl.INVALID_INDEX
+[ 333: PASS ] gl.getUniformBlockIndex(program, "u_normal") is gl.INVALID_INDEX
+[ 334: PASS ] gl.getProgramParameter(noUniformProgram, gl.LINK_STATUS) is true
+[ 335: PASS ] gl.getUniformBlockIndex(noUniformProgram, "u_modelViewProjMatrix") is gl.INVALID_INDEX
+[ 336: PASS ] gl.getUniformBlockIndex(noUniformProgram, "u_normal") is gl.INVALID_INDEX
+[ 337: PASS ] gl.getProgramParameter(program, gl.LINK_STATUS) is true
+[ 338: PASS ] gl.getActiveUniformBlockName(program, 0) is "Transform"
+[ 339: FAIL ] gl.getActiveUniformBlockName(program, -1) should be null (of type object). Was (of type string).
+[ 340: PASS ] getError was expected value: INVALID_VALUE :
+[ 341: FAIL ] gl.getActiveUniformBlockName(program, 1) should be null (of type object). Was (of type string).
+[ 342: PASS ] getError was expected value: INVALID_VALUE :
+[ 343: FAIL ] gl.getActiveUniformBlockName(program, gl.INVALID_INDEX) should be null (of type object). Was (of type string).
+[ 344: PASS ] getError was expected value: INVALID_VALUE :
+[ 345: PASS ] gl.getProgramParameter(noLinkProgram, gl.LINK_STATUS) is false
+[ 346: FAIL ] getError expected: INVALID_OPERATION. Was INVALID_VALUE : after evaluating: gl.getActiveUniformBlockName(noLinkProgram, 0)
+[ 347: PASS ] gl.getProgramParameter(noUniformProgram, gl.LINK_STATUS) is true
+[ 348: FAIL ] gl.getActiveUniformBlockName(noUniformProgram, -1) should be null (of type object). Was (of type string).
+[ 349: PASS ] getError was expected value: INVALID_VALUE :
+[ 350: FAIL ] gl.getActiveUniformBlockName(noUniformProgram, 0) should be null (of type object). Was (of type string).
+[ 351: PASS ] getError was expected value: INVALID_VALUE :
+[ 352: FAIL ] gl.getActiveUniformBlockName(noUniformProgram, gl.INVALID_INDEX) should be null (of type object). Was (of type string).
+[ 353: PASS ] getError was expected value: INVALID_VALUE :
+[ 354: PASS ] gl.getProgramParameter(program, gl.LINK_STATUS) is true
+[ 355: PASS ] gl.getActiveUniformBlockParameter(program, 0, gl.UNIFORM_BLOCK_BINDING) is 0
+[ 356: PASS ] gl.getActiveUniformBlockParameter(program, 0, gl.UNIFORM_BLOCK_BINDING) is 1
+[ 357: PASS ] gl.getActiveUniformBlockParameter(program, 0, gl.UNIFORM_BLOCK_DATA_SIZE) >= 164 is true
+[ 358: PASS ] gl.getActiveUniformBlockParameter(program, 0, gl.UNIFORM_BLOCK_ACTIVE_UNIFORMS) is 3
+[ 359: PASS ] gl.getActiveUniformBlockParameter(program, 0, gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER) is true
+[ 360: PASS ] gl.getActiveUniformBlockParameter(program, 0, gl.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER) is false
+[ 361: PASS ] getActiveUniformBlockParameter correctly handled invalid pname enums
+[ 362: PASS ] getError was expected value: NO_ERROR :
+[ 363: PASS ] successfullyParsed is true
+[ FAIL ] 45 failures reported
 

Modified: trunk/LayoutTests/webgl/TestExpectations (264534 => 264535)


--- trunk/LayoutTests/webgl/TestExpectations	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/LayoutTests/webgl/TestExpectations	2020-07-17 21:51:16 UTC (rev 264535)
@@ -55,6 +55,7 @@
 webgl/2.0.0/deqp/functional/gles3/builtinprecision/transpose.html [ Skip ]
 webgl/2.0.0/deqp/functional/gles3/clipping.html [ Skip ]
 webgl/2.0.0/deqp/functional/gles3/defaultvertexattribute.html [ Skip ]
+webgl/2.0.0/deqp/functional/gles3/sync.html [ Skip ]
 webgl/2.0.0/deqp/functional/gles3/draw/draw_arrays.html [ Skip ]
 webgl/2.0.0/deqp/functional/gles3/draw/draw_arrays_instanced.html [ Skip ]
 webgl/2.0.0/deqp/functional/gles3/draw/draw_elements.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (264534 => 264535)


--- trunk/Source/WebCore/ChangeLog	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/ChangeLog	2020-07-17 21:51:16 UTC (rev 264535)
@@ -1,3 +1,52 @@
+2020-07-17  James Darpinian  <[email protected]>
+
+        [WebGL2] Sync objects
+        https://bugs.webkit.org/show_bug.cgi?id=126942
+
+        Reviewed by Dean Jackson.
+
+        Passes WebGL conformance tests
+        webgl/2.0.0/conformance2/sync/sync-webgl-specific.html
+        and
+        webgl/2.0.0/deqp/functional/gles3/sync.html
+
+        although the latter times out in the layout test harness.
+
+
+        * html/canvas/WebGL2RenderingContext.cpp:
+        (WebCore::WebGL2RenderingContext::fenceSync):
+        (WebCore::WebGL2RenderingContext::isSync):
+        (WebCore::WebGL2RenderingContext::deleteSync):
+        (WebCore::WebGL2RenderingContext::clientWaitSync):
+        (WebCore::WebGL2RenderingContext::waitSync):
+        (WebCore::WebGL2RenderingContext::getSyncParameter):
+        * html/canvas/WebGLRenderingContextBase.h:
+        * html/canvas/WebGLSync.cpp:
+        (WebCore::WebGLSync::WebGLSync):
+        (WebCore::WebGLSync::deleteObjectImpl):
+        (WebCore::WebGLSync::updateCache):
+        (WebCore::WebGLSync::getCachedResult const):
+        (WebCore::WebGLSync::isSignaled const):
+        (WebCore::WebGLSync::scheduleAllowCacheUpdate):
+        * html/canvas/WebGLSync.h:
+        * platform/graphics/GraphicsContextGL.h:
+        * platform/graphics/GraphicsTypesGL.h:
+        * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+        (WebCore::GraphicsContextGLOpenGL::fenceSync):
+        (WebCore::GraphicsContextGLOpenGL::isSync):
+        (WebCore::GraphicsContextGLOpenGL::deleteSync):
+        (WebCore::GraphicsContextGLOpenGL::clientWaitSync):
+        (WebCore::GraphicsContextGLOpenGL::waitSync):
+        (WebCore::GraphicsContextGLOpenGL::getSynciv):
+        * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
+        * platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp:
+        (WebCore::GraphicsContextGLOpenGL::fenceSync):
+        (WebCore::GraphicsContextGLOpenGL::isSync):
+        (WebCore::GraphicsContextGLOpenGL::deleteSync):
+        (WebCore::GraphicsContextGLOpenGL::clientWaitSync):
+        (WebCore::GraphicsContextGLOpenGL::waitSync):
+        (WebCore::GraphicsContextGLOpenGL::getSynciv):
+
 2020-07-17  Lauro Moura  <[email protected]>
 
         Fix -Wformat= warnings when passing enum to integer specifiers

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (264534 => 264535)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2020-07-17 21:51:16 UTC (rev 264535)
@@ -2032,42 +2032,89 @@
     }
 }
 
-RefPtr<WebGLSync> WebGL2RenderingContext::fenceSync(GCGLenum, GCGLbitfield)
+RefPtr<WebGLSync> WebGL2RenderingContext::fenceSync(GCGLenum condition, GCGLbitfield flags)
 {
-    LOG(WebGL, "[[ NOT IMPLEMENTED ]] fenceSync()");
-    return nullptr;
+    if (isContextLostOrPending())
+        return nullptr;
+
+    if (condition != GraphicsContextGL::SYNC_GPU_COMMANDS_COMPLETE) {
+        synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "fenceSync", "condition must be SYNC_GPU_COMMANDS_COMPLETE");
+        return nullptr;
+    }
+    if (flags) {
+        synthesizeGLError(GraphicsContextGL::INVALID_VALUE, "fenceSync", "flags must be zero");
+        return nullptr;
+    }
+    auto sync = WebGLSync::create(*this);
+    sync->scheduleAllowCacheUpdate(*this);
+    addSharedObject(sync.get());
+    return sync;
 }
 
-GCGLboolean WebGL2RenderingContext::isSync(WebGLSync*)
+GCGLboolean WebGL2RenderingContext::isSync(WebGLSync* sync)
 {
-    LOG(WebGL, "[[ NOT IMPLEMENTED ]] isSync()");
-    return false;
+    return !isContextLostOrPending() && sync && !sync->isDeleted() && validateWebGLObject("isSync", sync);
 }
 
-void WebGL2RenderingContext::deleteSync(WebGLSync*)
+void WebGL2RenderingContext::deleteSync(WebGLSync* sync)
 {
-    LOG(WebGL, "[[ NOT IMPLEMENTED ]] deleteSync()");
+    if (isContextLostOrPending() || !sync || sync->isDeleted() || !validateWebGLObject("deleteSync", sync))
+        return;
+    deleteObject(sync);
 }
 
-GCGLenum WebGL2RenderingContext::clientWaitSync(WebGLSync&, GCGLbitfield, GCGLuint64)
+GCGLenum WebGL2RenderingContext::clientWaitSync(WebGLSync& sync, GCGLbitfield flags, GCGLuint64 timeout)
 {
-    // Note: Do not implement this function without consulting webkit-dev and WebGL
-    // reviewers beforehand. Apple folks, see <rdar://problem/36666458>.
-    LOG(WebGL, "[[ NOT IMPLEMENTED ]] clientWaitSync()");
-    return 0;
+    if (isContextLostOrPending() || !validateWebGLObject("clientWaitSync", &sync))
+        return GraphicsContextGL::WAIT_FAILED;
+
+    if (timeout > MaxClientWaitTimeout) {
+        synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "clientWaitSync", "timeout > MAX_CLIENT_WAIT_TIMEOUT_WEBGL");
+        return GraphicsContextGL::WAIT_FAILED;
+    }
+    
+    if (flags && flags != GraphicsContextGL::SYNC_FLUSH_COMMANDS_BIT) {
+        synthesizeGLError(GraphicsContextGL::INVALID_VALUE, "clientWaitSync", "invalid flags");
+        return GraphicsContextGL::WAIT_FAILED;
+    }
+
+    if (sync.isSignaled())
+        return GraphicsContextGL::ALREADY_SIGNALED;
+    sync.updateCache(*this);
+    if (sync.isSignaled())
+        return GraphicsContextGL::CONDITION_SATISFIED;
+    return GraphicsContextGL::TIMEOUT_EXPIRED;
 }
 
-void WebGL2RenderingContext::waitSync(WebGLSync&, GCGLbitfield, GCGLint64)
+void WebGL2RenderingContext::waitSync(WebGLSync& sync, GCGLbitfield flags, GCGLint64 timeout)
 {
-    LOG(WebGL, "[[ NOT IMPLEMENTED ]] waitSync()");
+    if (isContextLostOrPending() || !validateWebGLObject("waitSync", &sync))
+        return;
+
+    if (flags)
+        synthesizeGLError(GraphicsContextGL::INVALID_VALUE, "waitSync", "flags must be zero");
+    else if (timeout != -1)
+        synthesizeGLError(GraphicsContextGL::INVALID_VALUE, "waitSync", "invalid timeout");
+
+    // This function is a no-op in WebGL 2.
 }
 
-WebGLAny WebGL2RenderingContext::getSyncParameter(WebGLSync&, GCGLenum)
+WebGLAny WebGL2RenderingContext::getSyncParameter(WebGLSync& sync, GCGLenum pname)
 {
-    // Note: Do not implement this function without consulting webkit-dev and WebGL
-    // reviewers beforehand. Apple folks, see <rdar://problem/36666458>.
-    LOG(WebGL, "[[ NOT IMPLEMENTED ]] getSyncParameter()");
-    return nullptr;
+    if (isContextLostOrPending() || !validateWebGLObject("getSyncParameter", &sync))
+        return nullptr;
+
+    switch (pname) {
+    case GraphicsContextGL::OBJECT_TYPE:
+    case GraphicsContextGL::SYNC_STATUS:
+    case GraphicsContextGL::SYNC_CONDITION:
+    case GraphicsContextGL::SYNC_FLAGS:
+        sync.updateCache(*this);
+        return sync.getCachedResult(pname);
+    default:
+        synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "getSyncParameter", "invalid parameter name");
+        return nullptr;
+    }
 }
 
 RefPtr<WebGLTransformFeedback> WebGL2RenderingContext::createTransformFeedback()

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (264534 => 264535)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h	2020-07-17 21:51:16 UTC (rev 264535)
@@ -412,6 +412,7 @@
     friend class WebGLVertexArrayObjectOES;
     friend class WebGLVertexArrayObject;
     friend class WebGLVertexArrayObjectBase;
+    friend class WebGLSync;
 
     // Implementation helpers.
     friend class ScopedUnpackParametersResetRestore;

Modified: trunk/Source/WebCore/html/canvas/WebGLSync.cpp (264534 => 264535)


--- trunk/Source/WebCore/html/canvas/WebGLSync.cpp	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/html/canvas/WebGLSync.cpp	2020-07-17 21:51:16 UTC (rev 264535)
@@ -45,17 +45,63 @@
 
 WebGLSync::WebGLSync(WebGLRenderingContextBase& ctx)
     : WebGLSharedObject(ctx)
+    , m_sync(ctx.graphicsContextGL()->fenceSync(GraphicsContextGL::SYNC_GPU_COMMANDS_COMPLETE, 0))
 {
-    // FIXME: Call fenceSync from GraphicsContextGLOpenGL.
+    // This value is unused because the sync object is a pointer type, but it needs to be non-zero
+    // or other parts of the code will assume the object is invalid.
+    setObject(-1);
 }
 
 void WebGLSync::deleteObjectImpl(GraphicsContextGLOpenGL* context3d, PlatformGLObject object)
 {
-    UNUSED_PARAM(context3d);
     UNUSED_PARAM(object);
-    // FIXME: Call deleteSync from GraphicsContextGLOpenGL.
+    context3d->deleteSync(m_sync);
+    m_sync = nullptr;
 }
 
+void WebGLSync::updateCache(WebGLRenderingContextBase& context)
+{
+    if (m_syncStatus == GraphicsContextGL::SIGNALED || !m_allowCacheUpdate)
+        return;
+
+    m_allowCacheUpdate = false;
+    context.graphicsContextGL()->getSynciv(m_sync, GraphicsContextGL::SYNC_STATUS, sizeof(m_syncStatus), &m_syncStatus);
+    if (m_syncStatus == GraphicsContextGL::UNSIGNALED)
+        scheduleAllowCacheUpdate(context);
 }
 
+GCGLint WebGLSync::getCachedResult(GCGLenum pname) const
+{
+    switch (pname) {
+    case GraphicsContextGL::OBJECT_TYPE:
+        return GraphicsContextGL::SYNC_FENCE;
+    case GraphicsContextGL::SYNC_STATUS:
+        return m_syncStatus;
+    case GraphicsContextGL::SYNC_CONDITION:
+        return GraphicsContextGL::SYNC_GPU_COMMANDS_COMPLETE;
+    case GraphicsContextGL::SYNC_FLAGS:
+        return 0;
+    }
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+bool WebGLSync::isSignaled() const
+{
+    return m_syncStatus == GraphicsContextGL::SIGNALED;
+}
+
+void WebGLSync::scheduleAllowCacheUpdate(WebGLRenderingContextBase& context)
+{
+    auto* canvas = context.htmlCanvas();
+    if (!canvas)
+        return;
+
+    context.queueTaskKeepingObjectAlive(*canvas, TaskSource::WebGL, [protectedThis = makeRef(*this)]() {
+        protectedThis->m_allowCacheUpdate = true;
+    });
+}
+
+}
+
 #endif // ENABLE(WEBGL)

Modified: trunk/Source/WebCore/html/canvas/WebGLSync.h (264534 => 264535)


--- trunk/Source/WebCore/html/canvas/WebGLSync.h	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/html/canvas/WebGLSync.h	2020-07-17 21:51:16 UTC (rev 264535)
@@ -37,9 +37,18 @@
 
     static Ref<WebGLSync> create(WebGLRenderingContextBase&);
 
+    void updateCache(WebGLRenderingContextBase&);
+    GCGLint getCachedResult(GCGLenum pname) const;
+    bool isSignaled() const;
+    void scheduleAllowCacheUpdate(WebGLRenderingContextBase&);
+
 private:
     WebGLSync(WebGLRenderingContextBase&);
 
+    bool m_allowCacheUpdate = { false };
+    GCGLint m_syncStatus = { GraphicsContextGL::UNSIGNALED };
+    GCGLsync m_sync;
+
     void deleteObjectImpl(GraphicsContextGLOpenGL*, PlatformGLObject) override;
 };
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContextGL.h (264534 => 264535)


--- trunk/Source/WebCore/platform/graphics/GraphicsContextGL.h	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContextGL.h	2020-07-17 21:51:16 UTC (rev 264535)
@@ -1216,13 +1216,13 @@
     virtual void getSamplerParameterfv(PlatformGLObject sampler, GCGLenum pname, GCGLfloat* value) = 0;
     virtual void getSamplerParameteriv(PlatformGLObject sampler, GCGLenum pname, GCGLint* value) = 0;
 
-    virtual PlatformGLObject fenceSync(GCGLenum condition, GCGLbitfield flags) = 0;
-    virtual GCGLboolean isSync(PlatformGLObject sync) = 0;
-    virtual void deleteSync(PlatformGLObject sync) = 0;
-    virtual GCGLenum clientWaitSync(PlatformGLObject sync, GCGLbitfield flags, GCGLuint64 timeout) = 0;
-    virtual void waitSync(PlatformGLObject sync, GCGLbitfield flags, GCGLint64 timeout) = 0;
+    virtual GCGLsync fenceSync(GCGLenum condition, GCGLbitfield flags) = 0;
+    virtual GCGLboolean isSync(GCGLsync) = 0;
+    virtual void deleteSync(GCGLsync) = 0;
+    virtual GCGLenum clientWaitSync(GCGLsync, GCGLbitfield flags, GCGLuint64 timeout) = 0;
+    virtual void waitSync(GCGLsync, GCGLbitfield flags, GCGLint64 timeout) = 0;
     // getSyncParameter
-    virtual void getSynciv(PlatformGLObject sync, GCGLenum pname, GCGLsizei bufSize, GCGLint* value) = 0;
+    virtual void getSynciv(GCGLsync, GCGLenum pname, GCGLsizei bufSize, GCGLint* value) = 0;
 
     virtual PlatformGLObject createTransformFeedback() = 0;
     virtual void deleteTransformFeedback(PlatformGLObject id) = 0;

Modified: trunk/Source/WebCore/platform/graphics/GraphicsTypesGL.h (264534 => 264535)


--- trunk/Source/WebCore/platform/graphics/GraphicsTypesGL.h	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/platform/graphics/GraphicsTypesGL.h	2020-07-17 21:51:16 UTC (rev 264535)
@@ -47,6 +47,7 @@
 typedef char GCGLchar;
 typedef long long GCGLint64;
 typedef unsigned long long GCGLuint64;
+typedef struct __GLsync* GCGLsync;
 
 typedef GCGLuint PlatformGLObject;
 

Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (264534 => 264535)


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-07-17 21:51:16 UTC (rev 264535)
@@ -2460,48 +2460,40 @@
     gl::GetSamplerParameteriv(sampler, pname, value);
 }
 
-PlatformGLObject GraphicsContextGLOpenGL::fenceSync(GCGLenum condition, GCGLbitfield flags)
+GCGLsync GraphicsContextGLOpenGL::fenceSync(GCGLenum condition, GCGLbitfield flags)
 {
-    UNUSED_PARAM(condition);
-    UNUSED_PARAM(flags);
-
-    return 0;
+    makeContextCurrent();
+    return gl::FenceSync(condition, flags);
 }
 
-GCGLboolean GraphicsContextGLOpenGL::isSync(PlatformGLObject sync)
+GCGLboolean GraphicsContextGLOpenGL::isSync(GCGLsync sync)
 {
-    UNUSED_PARAM(sync);
-
-    return false;
+    makeContextCurrent();
+    return gl::IsSync(sync);
 }
 
-void GraphicsContextGLOpenGL::deleteSync(PlatformGLObject sync)
+void GraphicsContextGLOpenGL::deleteSync(GCGLsync sync)
 {
-    UNUSED_PARAM(sync);
+    makeContextCurrent();
+    gl::DeleteSync(sync);
 }
 
-GCGLenum GraphicsContextGLOpenGL::clientWaitSync(PlatformGLObject sync, GCGLbitfield flags, GCGLuint64 timeout)
+GCGLenum GraphicsContextGLOpenGL::clientWaitSync(GCGLsync sync, GCGLbitfield flags, GCGLuint64 timeout)
 {
-    UNUSED_PARAM(sync);
-    UNUSED_PARAM(flags);
-    UNUSED_PARAM(timeout);
-
-    return 0;
+    makeContextCurrent();
+    return gl::ClientWaitSync(sync, flags, timeout);
 }
 
-void GraphicsContextGLOpenGL::waitSync(PlatformGLObject sync, GCGLbitfield flags, GCGLint64 timeout)
+void GraphicsContextGLOpenGL::waitSync(GCGLsync sync, GCGLbitfield flags, GCGLint64 timeout)
 {
-    UNUSED_PARAM(sync);
-    UNUSED_PARAM(flags);
-    UNUSED_PARAM(timeout);
+    makeContextCurrent();
+    gl::WaitSync(sync, flags, timeout);
 }
 
-void GraphicsContextGLOpenGL::getSynciv(PlatformGLObject sync, GCGLenum pname, GCGLsizei bufSize, GCGLint *value)
+void GraphicsContextGLOpenGL::getSynciv(GCGLsync sync, GCGLenum pname, GCGLsizei bufSize, GCGLint *value)
 {
-    UNUSED_PARAM(sync);
-    UNUSED_PARAM(pname);
-    UNUSED_PARAM(bufSize);
-    UNUSED_PARAM(value);
+    makeContextCurrent();
+    gl::GetSynciv(sync, pname, bufSize, nullptr, value);
 }
 
 void GraphicsContextGLOpenGL::pauseTransformFeedback()

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h (264534 => 264535)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h	2020-07-17 21:51:16 UTC (rev 264535)
@@ -465,14 +465,14 @@
     void getSamplerParameterfv(PlatformGLObject sampler, GCGLenum pname, GCGLfloat* value) final;
     void getSamplerParameteriv(PlatformGLObject sampler, GCGLenum pname, GCGLint* value) final;
 
-    PlatformGLObject fenceSync(GCGLenum condition, GCGLbitfield flags) final;
-    GCGLboolean isSync(PlatformGLObject sync) final;
-    void deleteSync(PlatformGLObject sync) final;
-    GCGLenum clientWaitSync(PlatformGLObject sync, GCGLbitfield flags, GCGLuint64 timeout) final;
-    void waitSync(PlatformGLObject sync, GCGLbitfield flags, GCGLint64 timeout) final;
+    GCGLsync fenceSync(GCGLenum condition, GCGLbitfield flags) final;
+    GCGLboolean isSync(GCGLsync) final;
+    void deleteSync(GCGLsync) final;
+    GCGLenum clientWaitSync(GCGLsync, GCGLbitfield flags, GCGLuint64 timeout) final;
+    void waitSync(GCGLsync, GCGLbitfield flags, GCGLint64 timeout) final;
     // getSyncParameter
     // FIXME - this can be implemented at the WebGL level if we signal the WebGLSync object.
-    void getSynciv(PlatformGLObject sync, GCGLenum pname, GCGLsizei bufSize, GCGLint *value) final;
+    void getSynciv(GCGLsync, GCGLenum pname, GCGLsizei bufSize, GCGLint *value) final;
 
     PlatformGLObject createTransformFeedback() final;
     void deleteTransformFeedback(PlatformGLObject id) final;

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp (264534 => 264535)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp	2020-07-17 21:28:44 UTC (rev 264534)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLCommon.cpp	2020-07-17 21:51:16 UTC (rev 264535)
@@ -2629,7 +2629,7 @@
     UNUSED_PARAM(value);
 }
 
-PlatformGLObject GraphicsContextGLOpenGL::fenceSync(GCGLenum condition, GCGLbitfield flags)
+GCGLsync GraphicsContextGLOpenGL::fenceSync(GCGLenum condition, GCGLbitfield flags)
 {
     UNUSED_PARAM(condition);
     UNUSED_PARAM(flags);
@@ -2637,7 +2637,7 @@
     return 0;
 }
 
-GCGLboolean GraphicsContextGLOpenGL::isSync(PlatformGLObject sync)
+GCGLboolean GraphicsContextGLOpenGL::isSync(GCGLsync sync)
 {
     UNUSED_PARAM(sync);
 
@@ -2644,12 +2644,12 @@
     return false;
 }
 
-void GraphicsContextGLOpenGL::deleteSync(PlatformGLObject sync)
+void GraphicsContextGLOpenGL::deleteSync(GCGLsync sync)
 {
     UNUSED_PARAM(sync);
 }
 
-GCGLenum GraphicsContextGLOpenGL::clientWaitSync(PlatformGLObject sync, GCGLbitfield flags, GCGLuint64 timeout)
+GCGLenum GraphicsContextGLOpenGL::clientWaitSync(GCGLsync sync, GCGLbitfield flags, GCGLuint64 timeout)
 {
     UNUSED_PARAM(sync);
     UNUSED_PARAM(flags);
@@ -2658,7 +2658,7 @@
     return 0;
 }
 
-void GraphicsContextGLOpenGL::waitSync(PlatformGLObject sync, GCGLbitfield flags, GCGLint64 timeout)
+void GraphicsContextGLOpenGL::waitSync(GCGLsync sync, GCGLbitfield flags, GCGLint64 timeout)
 {
     UNUSED_PARAM(sync);
     UNUSED_PARAM(flags);
@@ -2665,7 +2665,7 @@
     UNUSED_PARAM(timeout);
 }
 
-void GraphicsContextGLOpenGL::getSynciv(PlatformGLObject sync, GCGLenum pname, GCGLsizei bufSize, GCGLint *value)
+void GraphicsContextGLOpenGL::getSynciv(GCGLsync sync, GCGLenum pname, GCGLsizei bufSize, GCGLint *value)
 {
     UNUSED_PARAM(sync);
     UNUSED_PARAM(pname);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to