Changeset 264807 in webkit


Ignore:
Timestamp:
Jul 23, 2020 5:50:29 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by James Darpinian <James Darpinian> 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:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r264802 r264807  
     12020-07-23  James Darpinian  <jdarpinian@chromium.org>
     2
     3        [WebGL2] Query Objects
     4        https://bugs.webkit.org/show_bug.cgi?id=126940
     5
     6        Reviewed by Dean Jackson.
     7
     8        * webgl/2.0.0/conformance2/query/query-expected.txt:
     9        * webgl/2.0.0/conformance2/state/gl-object-get-calls-expected.txt:
     10
    1112020-07-23  Yusuke Suzuki  <ysuzuki@apple.com>
    212
  • trunk/LayoutTests/webgl/2.0.0/conformance2/misc/expando-loss-2-expected.txt

    r263281 r264807  
    1 CONSOLE MESSAGE: TypeError: null is not an object (evaluating 'instance.expando1')
    21This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
    32
     
    328327[ 324: PASS ] getIndexedParameter(UNIFORM_BUFFER_BINDING, 47): Expect extra expando to survive despite GC.
    329328[ 325: PASS ] [object WebGLBuffer] is an instance of WebGLBuffer
    330 [ 326: FAIL ] CURRENT_QUERY returns instance that was bound.
    331 [ 327: FAIL ] CURRENT_QUERY returns instance that was bound.
    332 [ 328: FAIL ] successfullyParsed should be true (of type boolean). Was undefined (of type undefined).
    333 [ FAIL ] 179 failures reported
     329[ 326: PASS ] CURRENT_QUERY returns instance that was bound.
     330[ 327: PASS ] CURRENT_QUERY returns instance that was bound.
     331[ 328: FAIL ] Query: Expect basic expando to survive despite GC.
     332[ 329: FAIL ] Query: Expect subobject expando to survive despite GC.
     333[ 330: PASS ] Query: Expect extra expando to survive despite GC.
     334[ 331: PASS ] [object WebGLQuery] is an instance of WebGLQuery
     335[ 332: FAIL ] Query: Expect basic expando to survive despite GC.
     336[ 333: FAIL ] Query: Expect subobject expando to survive despite GC.
     337[ 334: PASS ] Query: Expect extra expando to survive despite GC.
     338[ 335: PASS ] [object WebGLQuery] is an instance of WebGLQuery
     339[ 336: PASS ] successfullyParsed is true
     340[ FAIL ] 180 failures reported
    334341
  • trunk/LayoutTests/webgl/2.0.0/conformance2/query/query-expected.txt

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

    r264662 r264807  
    314314[ 311: PASS ] gl.getSyncParameter(sync, gl.SYNC_FLAGS) is 0
    315315[ 312: PASS ] getSyncParameter correctly handled invalid pname enums
    316 [ 313: FAIL ] gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE) should be false (of type boolean). Was 0 (of type number).
     316[ 313: PASS ] gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE) is false
    317317[ 314: PASS ] getQueryParameter correctly handled invalid pname enums
    318318[ 315: PASS ] gl.getShaderParameter(vertShader, gl.COMPILE_STATUS) is true
     
    365365[ 362: PASS ] getError was expected value: NO_ERROR :
    366366[ 363: PASS ] successfullyParsed is true
    367 [ FAIL ] 38 failures reported
     367[ FAIL ] 37 failures reported
    368368
  • trunk/Source/WebCore/ChangeLog

    r264805 r264807  
     12020-07-23  James Darpinian  <jdarpinian@chromium.org>
     2
     3        [WebGL2] Query Objects
     4        https://bugs.webkit.org/show_bug.cgi?id=126940
     5
     6        Reviewed by Dean Jackson.
     7
     8        Passes conformance tests webgl/2.0.0/conformance2/query/*
     9
     10        * html/canvas/WebGL2RenderingContext.cpp:
     11        (WebCore::WebGL2RenderingContext::deleteQuery):
     12        (WebCore::WebGL2RenderingContext::isQuery):
     13        (WebCore::WebGL2RenderingContext::validateQueryTarget):
     14        (WebCore::WebGL2RenderingContext::beginQuery):
     15        (WebCore::WebGL2RenderingContext::endQuery):
     16        (WebCore::WebGL2RenderingContext::getQuery):
     17        (WebCore::WebGL2RenderingContext::getQueryParameter):
     18        * html/canvas/WebGL2RenderingContext.h:
     19        * html/canvas/WebGLQuery.cpp:
     20        (WebCore::WebGLQuery::deleteObjectImpl):
     21        * html/canvas/WebGLQuery.h:
     22        * html/canvas/WebGLRenderingContextBase.cpp:
     23        (WebCore::WebGLRenderingContextBase::validateWebGLObject):
     24        * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
     25        (WebCore::GraphicsContextGLOpenGL::deleteQuery):
     26        (WebCore::GraphicsContextGLOpenGL::isQuery):
     27        (WebCore::GraphicsContextGLOpenGL::getQuery):
     28
    1292020-07-23  Guowei Yang  <guowei_yang@apple.com>
    230
  • trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp

    r264733 r264807  
    18311831}
    18321832
    1833 void WebGL2RenderingContext::deleteQuery(WebGLQuery*)
    1834 {
    1835     LOG(WebGL, "[[ NOT IMPLEMENTED ]] deleteQuery()");
    1836 }
    1837 
    1838 GCGLboolean WebGL2RenderingContext::isQuery(WebGLQuery*)
    1839 {
    1840     LOG(WebGL, "[[ NOT IMPLEMENTED ]] isQuery()");
    1841     return false;
     1833void WebGL2RenderingContext::deleteQuery(WebGLQuery* query)
     1834{
     1835    if (isContextLostOrPending() || !query || !query->object() || !validateWebGLObject("deleteQuery", query))
     1836        return;
     1837    if (query->target() && query == m_activeQueries.get(query->target())) {
     1838        m_context->endQuery(query->target());
     1839        m_activeQueries.remove(query->target());
     1840    }
     1841    deleteObject(query);
     1842}
     1843
     1844GCGLboolean WebGL2RenderingContext::isQuery(WebGLQuery* query)
     1845{
     1846    if (isContextLostOrPending() || !query || !query->object() || !validateWebGLObject("isQuery", query))
     1847        return false;
     1848    return m_context->isQuery(query->object());
     1849}
     1850
     1851bool WebGL2RenderingContext::validateQueryTarget(const char* functionName, GCGLenum target, GCGLenum* targetKey)
     1852{
     1853    if (target != GraphicsContextGL::ANY_SAMPLES_PASSED && target != GraphicsContextGL::ANY_SAMPLES_PASSED_CONSERVATIVE && target != GraphicsContextGL::TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) {
     1854        synthesizeGLError(GraphicsContextGL::INVALID_ENUM, functionName, "invalid target");
     1855        return false;
     1856    }
     1857    if (targetKey)
     1858        *targetKey = (target == GraphicsContextGL::ANY_SAMPLES_PASSED_CONSERVATIVE) ? GraphicsContextGL::ANY_SAMPLES_PASSED : target;
     1859    return true;
    18421860}
    18431861
    18441862void WebGL2RenderingContext::beginQuery(GCGLenum target, WebGLQuery& query)
    18451863{
    1846     if (isContextLostOrPending())
    1847         return;
    1848 
    1849     // FIXME: Add validation to prevent bad caching.
     1864    GCGLenum targetKey;
     1865    if (isContextLostOrPending() || !validateWebGLObject("beginQuery", &query) || !validateQueryTarget("beginQuery", target, &targetKey))
     1866        return;
     1867
     1868    if (query.target() && query.target() != target) {
     1869        synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "beginQuery", "query type does not match target");
     1870        return;
     1871    }
     1872
     1873    auto addResult = m_activeQueries.add(targetKey, makeRefPtr(&query));
    18501874
    18511875    // Only one query object can be active per target.
    1852     auto targetKey = (target == GraphicsContextGL::ANY_SAMPLES_PASSED_CONSERVATIVE) ? GraphicsContextGL::ANY_SAMPLES_PASSED : target;
    1853 
    1854     auto addResult = m_activeQueries.add(targetKey, makeRefPtr(&query));
    1855 
    18561876    if (!addResult.isNewEntry) {
    18571877        synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "beginQuery", "Query object of target is already active");
     
    18601880
    18611881    m_context->beginQuery(target, query.object());
     1882    query.setTarget(target);
    18621883}
    18631884
    18641885void WebGL2RenderingContext::endQuery(GCGLenum target)
    18651886{
    1866     if (isContextLostOrPending() || !scriptExecutionContext())
    1867         return;
    1868 
    1869     auto targetKey = (target == GraphicsContextGL::ANY_SAMPLES_PASSED_CONSERVATIVE) ? GraphicsContextGL::ANY_SAMPLES_PASSED : target;
     1887    GCGLenum targetKey;
     1888    if (isContextLostOrPending() || !scriptExecutionContext() || !validateQueryTarget("beginQuery", target, &targetKey))
     1889        return;
    18701890
    18711891    auto query = m_activeQueries.take(targetKey);
     
    18831903}
    18841904
    1885 RefPtr<WebGLQuery> WebGL2RenderingContext::getQuery(GCGLenum, GCGLenum)
    1886 {
    1887     LOG(WebGL, "[[ NOT IMPLEMENTED ]] getquery()");
    1888     return nullptr;
     1905RefPtr<WebGLQuery> WebGL2RenderingContext::getQuery(GCGLenum target, GCGLenum pname)
     1906{
     1907    GCGLenum targetKey;
     1908    if (isContextLostOrPending() || !scriptExecutionContext() || !validateQueryTarget("beginQuery", target, &targetKey))
     1909        return nullptr;
     1910
     1911    if (pname != GraphicsContextGL::CURRENT_QUERY) {
     1912        synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "getQuery", "invalid parameter name");
     1913        return nullptr;
     1914    }
     1915
     1916    auto query = m_activeQueries.get(targetKey);
     1917    if (!query || query->target() != target)
     1918        return nullptr;
     1919    return query;
    18891920}
    18901921
    18911922WebGLAny WebGL2RenderingContext::getQueryParameter(WebGLQuery& query, GCGLenum pname)
    18921923{
    1893     if (isContextLostOrPending())
     1924    if (isContextLostOrPending() || !validateWebGLObject("getQueryParameter", &query))
    18941925        return nullptr;
    18951926
    18961927    switch (pname) {
    18971928    case GraphicsContextGL::QUERY_RESULT:
     1929        if (!query.isResultAvailable())
     1930            return false;
     1931        break;
    18981932    case GraphicsContextGL::QUERY_RESULT_AVAILABLE:
    18991933        if (!query.isResultAvailable())
    1900             return 0;
     1934            return false;
    19011935        break;
    19021936    default:
  • trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h

    r264733 r264807  
    298298    void restoreCurrentFramebuffer() final;
    299299    bool validateNonDefaultFramebufferAttachment(const char* functionName, GCGLenum attachment);
     300    bool validateQueryTarget(const char* functionName, GCGLenum target, GCGLenum* targetKey);
    300301
    301302    GCGLenum baseInternalFormatFromInternalFormat(GCGLenum internalformat);
  • trunk/Source/WebCore/html/canvas/WebGLQuery.cpp

    r254481 r264807  
    5252void WebGLQuery::deleteObjectImpl(GraphicsContextGLOpenGL* context3d, PlatformGLObject object)
    5353{
    54     UNUSED_PARAM(context3d);
    55     UNUSED_PARAM(object);
    56     // FIXME: Call deleteQuery from GraphicsContextGLOpenGL.
     54    context3d->deleteQuery(object);
    5755}
    5856
  • trunk/Source/WebCore/html/canvas/WebGLQuery.h

    r260415 r264807  
    4141    void makeResultAvailable() { m_isResultAvailable = true; }
    4242
     43    void setTarget(GCGLenum target) { m_target = target; }
     44    GCGLenum target() const { return m_target; }
     45
    4346private:
    4447    explicit WebGLQuery(WebGLRenderingContextBase&);
     
    4649
    4750    bool m_isResultAvailable { false };
     51    GCGLenum m_target { 0 };
    4852};
    4953
  • trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp

    r264733 r264807  
    23362336void GraphicsContextGLOpenGL::deleteQuery(PlatformGLObject query)
    23372337{
    2338     UNUSED_PARAM(query);
     2338    makeContextCurrent();
     2339    gl::DeleteQueries(1, &query);
    23392340}
    23402341
    23412342GCGLboolean GraphicsContextGLOpenGL::isQuery(PlatformGLObject query)
    23422343{
    2343     UNUSED_PARAM(query);
    2344 
    2345     return false;
     2344    makeContextCurrent();
     2345    return gl::IsQuery(query);
    23462346}
    23472347
    23482348PlatformGLObject GraphicsContextGLOpenGL::getQuery(GCGLenum target, GCGLenum pname)
    23492349{
    2350     UNUSED_PARAM(target);
    2351     UNUSED_PARAM(pname);
    2352 
    2353     return 0;
     2350    makeContextCurrent();
     2351    GLint value;
     2352    gl::GetQueryiv(target, pname, &value);
     2353    return static_cast<PlatformGLObject>(value);
    23542354}
    23552355
Note: See TracChangeset for help on using the changeset viewer.