Title: [264807] trunk
Revision
264807
Author
[email protected]
Date
2020-07-23 17:50:29 -0700 (Thu, 23 Jul 2020)

Log Message

[WebGL2] Query Objects
https://bugs.webkit.org/show_bug.cgi?id=126940

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

Source/WebCore:

Passes conformance tests webgl/2.0.0/conformance2/query/*

* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::deleteQuery):
(WebCore::WebGL2RenderingContext::isQuery):
(WebCore::WebGL2RenderingContext::validateQueryTarget):
(WebCore::WebGL2RenderingContext::beginQuery):
(WebCore::WebGL2RenderingContext::endQuery):
(WebCore::WebGL2RenderingContext::getQuery):
(WebCore::WebGL2RenderingContext::getQueryParameter):
* html/canvas/WebGL2RenderingContext.h:
* html/canvas/WebGLQuery.cpp:
(WebCore::WebGLQuery::deleteObjectImpl):
* html/canvas/WebGLQuery.h:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::validateWebGLObject):
* platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLOpenGL::deleteQuery):
(WebCore::GraphicsContextGLOpenGL::isQuery):
(WebCore::GraphicsContextGLOpenGL::getQuery):

LayoutTests:

* webgl/2.0.0/conformance2/query/query-expected.txt:
* webgl/2.0.0/conformance2/state/gl-object-get-calls-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (264806 => 264807)


--- trunk/LayoutTests/ChangeLog	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/LayoutTests/ChangeLog	2020-07-24 00:50:29 UTC (rev 264807)
@@ -1,3 +1,13 @@
+2020-07-23  James Darpinian  <[email protected]>
+
+        [WebGL2] Query Objects
+        https://bugs.webkit.org/show_bug.cgi?id=126940
+
+        Reviewed by Dean Jackson.
+
+        * webgl/2.0.0/conformance2/query/query-expected.txt:
+        * webgl/2.0.0/conformance2/state/gl-object-get-calls-expected.txt:
+
 2020-07-23  Yusuke Suzuki  <[email protected]>
 
         We should have exception check after promise operation

Modified: trunk/LayoutTests/webgl/2.0.0/conformance2/misc/expando-loss-2-expected.txt (264806 => 264807)


--- trunk/LayoutTests/webgl/2.0.0/conformance2/misc/expando-loss-2-expected.txt	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/LayoutTests/webgl/2.0.0/conformance2/misc/expando-loss-2-expected.txt	2020-07-24 00:50:29 UTC (rev 264807)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: TypeError: null is not an object (evaluating 'instance.expando1')
 This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
 
 Test: ../../resources/webgl_test_files/conformance2/misc/expando-loss-2.html
@@ -327,8 +326,16 @@
 [ 323: PASS ] getIndexedParameter(UNIFORM_BUFFER_BINDING, 47): Expect subobject expando to survive despite GC.
 [ 324: PASS ] getIndexedParameter(UNIFORM_BUFFER_BINDING, 47): Expect extra expando to survive despite GC.
 [ 325: PASS ] [object WebGLBuffer] is an instance of WebGLBuffer
-[ 326: FAIL ] CURRENT_QUERY returns instance that was bound.
-[ 327: FAIL ] CURRENT_QUERY returns instance that was bound.
-[ 328: FAIL ] successfullyParsed should be true (of type boolean). Was undefined (of type undefined).
-[ FAIL ] 179 failures reported
+[ 326: PASS ] CURRENT_QUERY returns instance that was bound.
+[ 327: PASS ] CURRENT_QUERY returns instance that was bound.
+[ 328: FAIL ] Query: Expect basic expando to survive despite GC.
+[ 329: FAIL ] Query: Expect subobject expando to survive despite GC.
+[ 330: PASS ] Query: Expect extra expando to survive despite GC.
+[ 331: PASS ] [object WebGLQuery] is an instance of WebGLQuery
+[ 332: FAIL ] Query: Expect basic expando to survive despite GC.
+[ 333: FAIL ] Query: Expect subobject expando to survive despite GC.
+[ 334: PASS ] Query: Expect extra expando to survive despite GC.
+[ 335: PASS ] [object WebGLQuery] is an instance of WebGLQuery
+[ 336: PASS ] successfullyParsed is true
+[ FAIL ] 180 failures reported
 

Modified: trunk/LayoutTests/webgl/2.0.0/conformance2/query/query-expected.txt (264806 => 264807)


--- trunk/LayoutTests/webgl/2.0.0/conformance2/query/query-expected.txt	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/LayoutTests/webgl/2.0.0/conformance2/query/query-expected.txt	2020-07-24 00:50:29 UTC (rev 264807)
@@ -1,44 +1,5 @@
 This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
 
 Test: ../../resources/webgl_test_files/conformance2/query/query.html
-[ 1: PASS ] WebGL context exists
-[ 2: PASS ] gl.ANY_SAMPLES_PASSED is 0x8C2F
-[ 3: PASS ] gl.ANY_SAMPLES_PASSED_CONSERVATIVE is 0x8D6A
-[ 4: PASS ] gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN is 0x8C88
-[ 5: PASS ] getError was expected value: NO_ERROR : ANY_SAMPLES_PASSED query should succeed
-[ 6: PASS ] getError was expected value: NO_ERROR : ANY_SAMPLES_PASSED query should succeed
-[ 7: PASS ] getError was expected value: NO_ERROR : ANY_SAMPLES_PASSED query should succeed
-[ 8: PASS ] gl.getQuery(gl.ANY_SAMPLES_PASSED, gl.CURRENT_QUERY) is null
-[ 9: PASS ] gl.getQuery(gl.ANY_SAMPLES_PASSED_CONSERVATIVE, gl.CURRENT_QUERY) is null
-[ 10: PASS ] gl.getQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl.CURRENT_QUERY) is null
-[ 11: PASS ] gl.getQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl.CURRENT_QUERY) is null
-[ 12: FAIL ] gl.isQuery(q1) should be true. Was false.
-[ 13: FAIL ] gl.getQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl.CURRENT_QUERY) should be [object WebGLQuery]. Was null.
-[ 14: PASS ] getError was expected value: INVALID_OPERATION : Can't begin a query while one is already active
-[ 15: FAIL ] gl.getQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl.CURRENT_QUERY) should be [object WebGLQuery]. Was null.
-[ 16: PASS ] gl.getQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl.CURRENT_QUERY) is null
-[ 17: PASS ] getError was expected value: INVALID_OPERATION : Can't end a query if one is not active
-[ 18: PASS ] getError was expected value: INVALID_OPERATION : Can't re-use query objects for incompatible targets
-[ 19: PASS ] gl.getQuery(gl.ANY_SAMPLES_PASSED, gl.CURRENT_QUERY) is null
-[ 20: FAIL ] gl.getQuery(gl.ANY_SAMPLES_PASSED, gl.CURRENT_QUERY) should be [object WebGLQuery]. Was null.
-[ 21: PASS ] getError was expected value: INVALID_OPERATION : Can't call beginQuery on an already active query object
-[ 22: PASS ] gl.getQuery(gl.ANY_SAMPLES_PASSED_CONSERVATIVE, gl.CURRENT_QUERY) is null
-[ 23: FAIL ] getError expected: NO_ERROR. Was INVALID_OPERATION : Should be able to have multiple unrelated query types active at once
-[ 24: FAIL ] gl.getQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl.CURRENT_QUERY) should be [object WebGLQuery]. Was null.
-[ 25: PASS ] getError was expected value: NO_ERROR : deleting queries should not produce errors
-[ 26: PASS ] gl.getQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl.CURRENT_QUERY) is null
-[ 27: PASS ] gl.getQuery(gl.ANY_SAMPLES_PASSED_CONSERVATIVE, gl.CURRENT_QUERY) is null
-[ 28: PASS ] getError was expected value: INVALID_OPERATION : beginning a deleted query object
-[ 29: PASS ] gl.getQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl.CURRENT_QUERY) is null
-[ 30: PASS ] getError was expected value: NO_ERROR : should have no previous errors
-[ 31: PASS ] getError was expected value: NO_ERROR : createQuery should not set an error
-[ 32: PASS ] q1 is non-null.
-[ 33: PASS ] gl.isQuery(q1) is false
-[ 34: FAIL ] gl.isQuery(q1) should be true. Was false.
-[ 35: FAIL ] gl.isQuery(q1) should be true. Was false.
-[ 36: PASS ] gl.isQuery(q1) is false
-[ 37: PASS ] gl.isQuery(null) is false
-[ 38: FAIL ] getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no errors
-[ 39: PASS ] successfullyParsed is true
-[ FAIL ] 9 failures reported
+[ PASS ] All tests passed
 

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


--- trunk/LayoutTests/webgl/2.0.0/conformance2/state/gl-object-get-calls-expected.txt	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/LayoutTests/webgl/2.0.0/conformance2/state/gl-object-get-calls-expected.txt	2020-07-24 00:50:29 UTC (rev 264807)
@@ -313,7 +313,7 @@
 [ 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).
+[ 313: PASS ] gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE) is false
 [ 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
@@ -364,5 +364,5 @@
 [ 361: PASS ] getActiveUniformBlockParameter correctly handled invalid pname enums
 [ 362: PASS ] getError was expected value: NO_ERROR :
 [ 363: PASS ] successfullyParsed is true
-[ FAIL ] 38 failures reported
+[ FAIL ] 37 failures reported
 

Modified: trunk/Source/WebCore/ChangeLog (264806 => 264807)


--- trunk/Source/WebCore/ChangeLog	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/Source/WebCore/ChangeLog	2020-07-24 00:50:29 UTC (rev 264807)
@@ -1,3 +1,31 @@
+2020-07-23  James Darpinian  <[email protected]>
+
+        [WebGL2] Query Objects
+        https://bugs.webkit.org/show_bug.cgi?id=126940
+
+        Reviewed by Dean Jackson.
+
+        Passes conformance tests webgl/2.0.0/conformance2/query/*
+
+        * html/canvas/WebGL2RenderingContext.cpp:
+        (WebCore::WebGL2RenderingContext::deleteQuery):
+        (WebCore::WebGL2RenderingContext::isQuery):
+        (WebCore::WebGL2RenderingContext::validateQueryTarget):
+        (WebCore::WebGL2RenderingContext::beginQuery):
+        (WebCore::WebGL2RenderingContext::endQuery):
+        (WebCore::WebGL2RenderingContext::getQuery):
+        (WebCore::WebGL2RenderingContext::getQueryParameter):
+        * html/canvas/WebGL2RenderingContext.h:
+        * html/canvas/WebGLQuery.cpp:
+        (WebCore::WebGLQuery::deleteObjectImpl):
+        * html/canvas/WebGLQuery.h:
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::validateWebGLObject):
+        * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+        (WebCore::GraphicsContextGLOpenGL::deleteQuery):
+        (WebCore::GraphicsContextGLOpenGL::isQuery):
+        (WebCore::GraphicsContextGLOpenGL::getQuery):
+
 2020-07-23  Guowei Yang  <[email protected]>
 
         Infrastructure Work for Integrating CoreImage for Accelerated CSS/SVG Filter Rendering

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (264806 => 264807)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2020-07-24 00:50:29 UTC (rev 264807)
@@ -1830,29 +1830,49 @@
     return query;
 }
 
-void WebGL2RenderingContext::deleteQuery(WebGLQuery*)
+void WebGL2RenderingContext::deleteQuery(WebGLQuery* query)
 {
-    LOG(WebGL, "[[ NOT IMPLEMENTED ]] deleteQuery()");
+    if (isContextLostOrPending() || !query || !query->object() || !validateWebGLObject("deleteQuery", query))
+        return;
+    if (query->target() && query == m_activeQueries.get(query->target())) {
+        m_context->endQuery(query->target());
+        m_activeQueries.remove(query->target());
+    }
+    deleteObject(query);
 }
 
-GCGLboolean WebGL2RenderingContext::isQuery(WebGLQuery*)
+GCGLboolean WebGL2RenderingContext::isQuery(WebGLQuery* query)
 {
-    LOG(WebGL, "[[ NOT IMPLEMENTED ]] isQuery()");
-    return false;
+    if (isContextLostOrPending() || !query || !query->object() || !validateWebGLObject("isQuery", query))
+        return false;
+    return m_context->isQuery(query->object());
 }
 
+bool WebGL2RenderingContext::validateQueryTarget(const char* functionName, GCGLenum target, GCGLenum* targetKey)
+{
+    if (target != GraphicsContextGL::ANY_SAMPLES_PASSED && target != GraphicsContextGL::ANY_SAMPLES_PASSED_CONSERVATIVE && target != GraphicsContextGL::TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) {
+        synthesizeGLError(GraphicsContextGL::INVALID_ENUM, functionName, "invalid target");
+        return false;
+    }
+    if (targetKey)
+        *targetKey = (target == GraphicsContextGL::ANY_SAMPLES_PASSED_CONSERVATIVE) ? GraphicsContextGL::ANY_SAMPLES_PASSED : target;
+    return true;
+}
+
 void WebGL2RenderingContext::beginQuery(GCGLenum target, WebGLQuery& query)
 {
-    if (isContextLostOrPending())
+    GCGLenum targetKey;
+    if (isContextLostOrPending() || !validateWebGLObject("beginQuery", &query) || !validateQueryTarget("beginQuery", target, &targetKey))
         return;
 
-    // FIXME: Add validation to prevent bad caching.
+    if (query.target() && query.target() != target) {
+        synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "beginQuery", "query type does not match target");
+        return;
+    }
 
-    // Only one query object can be active per target.
-    auto targetKey = (target == GraphicsContextGL::ANY_SAMPLES_PASSED_CONSERVATIVE) ? GraphicsContextGL::ANY_SAMPLES_PASSED : target;
-
     auto addResult = m_activeQueries.add(targetKey, makeRefPtr(&query));
 
+    // Only one query object can be active per target.
     if (!addResult.isNewEntry) {
         synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "beginQuery", "Query object of target is already active");
         return;
@@ -1859,15 +1879,15 @@
     }
 
     m_context->beginQuery(target, query.object());
+    query.setTarget(target);
 }
 
 void WebGL2RenderingContext::endQuery(GCGLenum target)
 {
-    if (isContextLostOrPending() || !scriptExecutionContext())
+    GCGLenum targetKey;
+    if (isContextLostOrPending() || !scriptExecutionContext() || !validateQueryTarget("beginQuery", target, &targetKey))
         return;
 
-    auto targetKey = (target == GraphicsContextGL::ANY_SAMPLES_PASSED_CONSERVATIVE) ? GraphicsContextGL::ANY_SAMPLES_PASSED : target;
-
     auto query = m_activeQueries.take(targetKey);
     if (!query) {
         synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "endQuery", "Query object of target is not active");
@@ -1882,22 +1902,36 @@
     });
 }
 
-RefPtr<WebGLQuery> WebGL2RenderingContext::getQuery(GCGLenum, GCGLenum)
+RefPtr<WebGLQuery> WebGL2RenderingContext::getQuery(GCGLenum target, GCGLenum pname)
 {
-    LOG(WebGL, "[[ NOT IMPLEMENTED ]] getquery()");
-    return nullptr;
+    GCGLenum targetKey;
+    if (isContextLostOrPending() || !scriptExecutionContext() || !validateQueryTarget("beginQuery", target, &targetKey))
+        return nullptr;
+
+    if (pname != GraphicsContextGL::CURRENT_QUERY) {
+        synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "getQuery", "invalid parameter name");
+        return nullptr;
+    }
+
+    auto query = m_activeQueries.get(targetKey);
+    if (!query || query->target() != target)
+        return nullptr;
+    return query;
 }
 
 WebGLAny WebGL2RenderingContext::getQueryParameter(WebGLQuery& query, GCGLenum pname)
 {
-    if (isContextLostOrPending())
+    if (isContextLostOrPending() || !validateWebGLObject("getQueryParameter", &query))
         return nullptr;
 
     switch (pname) {
     case GraphicsContextGL::QUERY_RESULT:
+        if (!query.isResultAvailable())
+            return false;
+        break;
     case GraphicsContextGL::QUERY_RESULT_AVAILABLE:
         if (!query.isResultAvailable())
-            return 0;
+            return false;
         break;
     default:
         synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "getQueryParameter", "Invalid pname");

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h (264806 => 264807)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h	2020-07-24 00:50:29 UTC (rev 264807)
@@ -297,6 +297,7 @@
     WebGLFramebuffer* getReadFramebufferBinding() final;
     void restoreCurrentFramebuffer() final;
     bool validateNonDefaultFramebufferAttachment(const char* functionName, GCGLenum attachment);
+    bool validateQueryTarget(const char* functionName, GCGLenum target, GCGLenum* targetKey);
 
     GCGLenum baseInternalFormatFromInternalFormat(GCGLenum internalformat);
     bool isIntegerFormat(GCGLenum internalformat);

Modified: trunk/Source/WebCore/html/canvas/WebGLQuery.cpp (264806 => 264807)


--- trunk/Source/WebCore/html/canvas/WebGLQuery.cpp	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/Source/WebCore/html/canvas/WebGLQuery.cpp	2020-07-24 00:50:29 UTC (rev 264807)
@@ -51,9 +51,7 @@
 
 void WebGLQuery::deleteObjectImpl(GraphicsContextGLOpenGL* context3d, PlatformGLObject object)
 {
-    UNUSED_PARAM(context3d);
-    UNUSED_PARAM(object);
-    // FIXME: Call deleteQuery from GraphicsContextGLOpenGL.
+    context3d->deleteQuery(object);
 }
 
 }

Modified: trunk/Source/WebCore/html/canvas/WebGLQuery.h (264806 => 264807)


--- trunk/Source/WebCore/html/canvas/WebGLQuery.h	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/Source/WebCore/html/canvas/WebGLQuery.h	2020-07-24 00:50:29 UTC (rev 264807)
@@ -40,11 +40,15 @@
 
     void makeResultAvailable() { m_isResultAvailable = true; }
 
+    void setTarget(GCGLenum target) { m_target = target; }
+    GCGLenum target() const { return m_target; }
+
 private:
     explicit WebGLQuery(WebGLRenderingContextBase&);
     void deleteObjectImpl(GraphicsContextGLOpenGL*, PlatformGLObject) override;
 
     bool m_isResultAvailable { false };
+    GCGLenum m_target { 0 };
 };
 
 } // namespace WebCore

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


--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-07-23 23:54:23 UTC (rev 264806)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp	2020-07-24 00:50:29 UTC (rev 264807)
@@ -2335,22 +2335,22 @@
 
 void GraphicsContextGLOpenGL::deleteQuery(PlatformGLObject query)
 {
-    UNUSED_PARAM(query);
+    makeContextCurrent();
+    gl::DeleteQueries(1, &query);
 }
 
 GCGLboolean GraphicsContextGLOpenGL::isQuery(PlatformGLObject query)
 {
-    UNUSED_PARAM(query);
-
-    return false;
+    makeContextCurrent();
+    return gl::IsQuery(query);
 }
 
 PlatformGLObject GraphicsContextGLOpenGL::getQuery(GCGLenum target, GCGLenum pname)
 {
-    UNUSED_PARAM(target);
-    UNUSED_PARAM(pname);
-
-    return 0;
+    makeContextCurrent();
+    GLint value;
+    gl::GetQueryiv(target, pname, &value);
+    return static_cast<PlatformGLObject>(value);
 }
 
 PlatformGLObject GraphicsContextGLOpenGL::createSampler()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to