15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    AMD_occlusion_query_event
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_AMD_occlusion_query_event
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Graham Sellers (graham.sellers 'at' amd.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Graham Sellers, AMD
165bd8deadSopenharmony_ci    Daniel Rakos, AMD
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciStatus
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    SHIPPING
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ciVersion
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ci    Last Modified Date:         11/20/2013
255bd8deadSopenharmony_ci    Author Revision:            3
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ciNumber
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ci    OpenGL Extension #442
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ciDependencies
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ci    OpenGL 1.5 is required.
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    This extension is written against the OpenGL 4.4 (core) specification.
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ci    This extension depends on the definition of OpenGL 3.3 and
385bd8deadSopenharmony_ci    GL_ARB_occlusion_query2.
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ci    This extension depends on the definition of OpenGL 4.3 and
415bd8deadSopenharmony_ci    GL_ARB_ES3_compatibility.
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    This extension depends on the definition of GL_EXT_depth_bounds_test.
445bd8deadSopenharmony_ci
455bd8deadSopenharmony_ciOverview
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ci    Occlusion queries provide a means to count the number of fragments that
485bd8deadSopenharmony_ci    pass the depth and stencil tests and that may contribute to a rendered
495bd8deadSopenharmony_ci    image. In unextended OpenGL, an occlusion query increments its
505bd8deadSopenharmony_ci    samples-passed count whenever a sample passes both the stencil test and
515bd8deadSopenharmony_ci    the depth test (if enabled). However, there is no way to count fragments
525bd8deadSopenharmony_ci    that fail the stencil test, or pass the stencil test and then subsequently
535bd8deadSopenharmony_ci    fail the depth test.
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ci    This extension introduces the concept of occlusion query events and changes
565bd8deadSopenharmony_ci    the concept of an occlusion query from counting passed fragments to counting
575bd8deadSopenharmony_ci    fragments that generate any of a user-selectable set of events. Provided
585bd8deadSopenharmony_ci    events include passing the depth test, and passing or failing the stencil
595bd8deadSopenharmony_ci    test. For a given occlusion query object, counting of these events may be
605bd8deadSopenharmony_ci    enabled or disabled, allowing any combination to be counted.
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ciNew Procedures and Functions
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ci        void QueryObjectParameteruiAMD(enum target,
655bd8deadSopenharmony_ci                                       uint id,
665bd8deadSopenharmony_ci                                       enum pname,
675bd8deadSopenharmony_ci                                       uint param);
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ciNew Tokens
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci    Accepted by the <pname> argument to QueryObejctParameteruiAMD,
725bd8deadSopenharmony_ci    GetQueryObjectiv, GetQueryObjectuiv, GetQueryObjecti64v, and
735bd8deadSopenharmony_ci    GetQueryObjectui64v:
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci        OCCLUSION_QUERY_EVENT_MASK_AMD                      0x874F
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci    Accepted by the <param> argument to QueryObjectParameteruiAMD:
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ci        QUERY_DEPTH_PASS_EVENT_BIT_AMD                      0x00000001
805bd8deadSopenharmony_ci        QUERY_DEPTH_FAIL_EVENT_BIT_AMD                      0x00000002
815bd8deadSopenharmony_ci        QUERY_STENCIL_FAIL_EVENT_BIT_AMD                    0x00000004
825bd8deadSopenharmony_ci        QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD               0x00000008
835bd8deadSopenharmony_ci        QUERY_ALL_EVENT_BITS_AMD                            0xFFFFFFFF
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 4.4 (core) Specification (Event Model)
865bd8deadSopenharmony_ci
875bd8deadSopenharmony_ci    Insert Section 4.2.1, "Query Object Parameters", p.42. Renumber subsequent
885bd8deadSopenharmony_ci    sections.
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci    Query object parameters control the behavior of the query object. Changing
915bd8deadSopenharmony_ci    the value of a query object parameter is done by calling
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci        void QueryObjectParameteruiAMD(enum target,
945bd8deadSopenharmony_ci                                       uint id,
955bd8deadSopenharmony_ci                                       enum pname,
965bd8deadSopenharmony_ci                                       uint param);
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ci    with <target> set to a valid query target, <id> set to a value returned
995bd8deadSopenharmony_ci    from a previous call to GenQueries. <pname> specifies the parameter to
1005bd8deadSopenharmony_ci    modify and <param> contains its new value. If <id> is an unused query object
1015bd8deadSopenharmony_ci    name then the name is marked as used and associated with a new query object
1025bd8deadSopenharmony_ci    of the type specified by <target>. Otherwise, <id> must be the name of an
1035bd8deadSopenharmony_ci    existing query object of that type.
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ciAdditions to Chapter 17 of the OpenGL 4.3 (core) Specification (Writing Fragments
1065bd8deadSopenharmony_ciand Samples to the Framebuffer)
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci    Modify the first paragraph of Subection 17.3.7, "Occlusion Queries" as
1095bd8deadSopenharmony_ci    follows:
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ci    Occlusion queries use query objects to track fragments as they pass through
1125bd8deadSopenharmony_ci    the depth bounds test, stencil test and depth test, in that order. Each
1135bd8deadSopenharmony_ci    stage may generate an event. An event is generated if a fragment fails
1145bd8deadSopenharmony_ci    the depth bounds test. If a fragment passes the depth bounds test, it then
1155bd8deadSopenharmony_ci    undergoes the stencil test and generates an event should it fail that.
1165bd8deadSopenharmony_ci    Should it pass the stencil test, it undergoes the depth test, upon which
1175bd8deadSopenharmony_ci    it will generate an event indicating whether it passed or failed the depth
1185bd8deadSopenharmony_ci    test. An occlusion query can be started and finished by calling BeginQuery
1195bd8deadSopenharmony_ci    and EndQuery, respectively, with a <target> of SAMPLES_PASSED,
1205bd8deadSopenharmony_ci    ANY_SAMPLES_PASSED, or ANY_SAMPLES_PASSED_CONSERVATIVE.
1215bd8deadSopenharmony_ci
1225bd8deadSopenharmony_ci    In the remainder of the Subsection, replace any occurrence of "passes the
1235bd8deadSopenharmony_ci    depth test" with "generates an enabled event". Add the following to the end
1245bd8deadSopenharmony_ci    of the subsection:
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci    Counting of occlusion query events are enabled and disabled for a query
1275bd8deadSopenharmony_ci    object by calling QueryObjectParameteruiAMD with <target> set to
1285bd8deadSopenharmony_ci    SAMPLES_PASSED, ANY_SAMPLES_PASSED or ANY_SAMPLES_PASSED_CONSERVATIVE, with
1295bd8deadSopenharmony_ci    <id> set to the name of an existing query object of the appropriate type, or
1305bd8deadSopenharmony_ci    to a name returned from a call to GenQueries but not yet associated with a
1315bd8deadSopenharmony_ci    query object, with <pname> set to OCCLUSION_QUERY_EVENT_MASK_AMD and with
1325bd8deadSopenharmony_ci    <param> set to the bitwise or of the set of the following flags:
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci      +---------------------------------------+---------------------------------------------------------+
1355bd8deadSopenharmony_ci      | QUERY_DEPTH_PASS_EVENT_BIT_AMD        | Indicates that the fragment passed all tests.           |
1365bd8deadSopenharmony_ci      | QUERY_DEPTH_FAIL_EVENT_BIT_AMD        | Indicates that the fragment passed the depth bounds and |
1375bd8deadSopenharmony_ci      |                                       | stencil tests, but failed the depth test.               |
1385bd8deadSopenharmony_ci      | QUERY_STENCIL_FAIL_EVENT_BIT_AMD      | Indicates that the fragment passed the depth bounds     |
1395bd8deadSopenharmony_ci      |                                       | test but failed the stencil test.                       |
1405bd8deadSopenharmony_ci      | QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD | Indicates that the fragment failed the depth bounds     |
1415bd8deadSopenharmony_ci      |                                       | test.                                                   |
1425bd8deadSopenharmony_ci      | QUERY_ALL_EVENT_BITS_AMD              | Indicates that any event generated by the fragment      |
1435bd8deadSopenharmony_ci      |                                       | should be counted.                                      |
1445bd8deadSopenharmony_ci      +---------------------------------------+---------------------------------------------------------+
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ci    By default, the value of OCCLUSION_QUERY_EVENT_MASK_AMD for a newly created
1475bd8deadSopenharmony_ci    occlusion query object is QUERY_DEPTH_PASS_EVENT_BIT_AMD.
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci    None.
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ciGLX Protocol
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci    None.
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ciErrors
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ci    INVALID_OPERATION is generated by GetQueryObjectiv, GetQueryObjectuiv,
1605bd8deadSopenharmony_ci    GetQueryObjecti64v, and GetQueryObjectui64v if <pname> is
1615bd8deadSopenharmony_ci    OCCLUSION_QUERY_EVENT_MASK_AMD and the target of the query object
1625bd8deadSopenharmony_ci    specified by <id> is not SAMPLES_PASSED, ANY_SAMPLES_PASSED, or
1635bd8deadSopenharmony_ci    ANY_SAMPLES_PASSED_CONSERVATIVE.
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ci    INVALID_ENUM is generated by QueryObjectParameteruiAMD if <target> is not
1665bd8deadSopenharmony_ci    an accepted query target.
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ci    INVALID_ENUM is generated by QueryObjectParameteruiAMD if <pname> is not
1695bd8deadSopenharmony_ci    OCCLUSION_QUERY_EVENT_MASK_AMD.
1705bd8deadSopenharmony_ci
1715bd8deadSopenharmony_ci    INVALID_VALUE is generated by QueryObjectParameteruiAMD if <id> is not a
1725bd8deadSopenharmony_ci    name returned from a previous call to GenQueries, or if such a name has
1735bd8deadSopenharmony_ci    since been deleted with DeleteQueries.
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci    INVALID_OPERATION is generated by QueryObjectParameteruiAMD if <id> is the
1765bd8deadSopenharmony_ci    name of an existing query object whose target does not match <target>, or
1775bd8deadSopenharmony_ci    an active query object name for <target>.
1785bd8deadSopenharmony_ci
1795bd8deadSopenharmony_ci    INVALID_OPERATION is generated by QueryObjectParameteruiAMD if <pname> is
1805bd8deadSopenharmony_ci    OCCLUSION_QUERY_EVENT_MASK_AMD and <target> is not SAMPLES_PASSED,
1815bd8deadSopenharmony_ci    ANY_SAMPLES_PASSED, or ANY_SAMPLES_PASSED_CONSERVATIVE.
1825bd8deadSopenharmony_ci
1835bd8deadSopenharmony_ci    INVALID_VALUE is generated by QueryObjectParameteruiAMD if <pname> is
1845bd8deadSopenharmony_ci    OCCLUSION_QUERY_EVENT_MASK_AMD and <param> contains any unsupported bits,
1855bd8deadSopenharmony_ci    except in the case when <param> is equal to the special value,
1865bd8deadSopenharmony_ci    QUERY_ALL_EVENT_BITS_AMD.
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ciNew State
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci    Append to Table 23.44, "Query Object State"
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci    +-----------------------------------+-------+--------------------+--------------------------------+------------------------------------+--------+
1935bd8deadSopenharmony_ci    | Get Value                         | Type  | Get Command        | Initial Value                  | Description                        | Sec.   |
1945bd8deadSopenharmony_ci    +-----------------------------------+-------+--------------------+--------------------------------+------------------------------------+--------+
1955bd8deadSopenharmony_ci    | OCCLUSION_QUERY_EVENT_MASK_AMD    | Z+    | GetQueryObjectuiv  | QUERY_DEPTH_PASS_EVENT_BIT_AMD | Bitmask of events to count in an   | 17.3.7 |
1965bd8deadSopenharmony_ci    |                                   |       |                    |                                | occlusion query                    |        |
1975bd8deadSopenharmony_ci    +-----------------------------------+-------+--------------------+--------------------------------+------------------------------------+--------+
1985bd8deadSopenharmony_ci
1995bd8deadSopenharmony_ciNew Implementation Dependent State
2005bd8deadSopenharmony_ci
2015bd8deadSopenharmony_ci    None.
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ciUsage Examples
2045bd8deadSopenharmony_ci
2055bd8deadSopenharmony_ci    TBD
2065bd8deadSopenharmony_ci
2075bd8deadSopenharmony_ciDependencies on GL_EXT_depth_bounds_test
2085bd8deadSopenharmony_ci
2095bd8deadSopenharmony_ci    If GL_EXT_depth_bounds_test is not supported, remove any reference to
2105bd8deadSopenharmony_ci    the depth bounds test and the QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD token.
2115bd8deadSopenharmony_ci    The value of the QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD remains reserved, however.
2125bd8deadSopenharmony_ci    This extension shall behave as if all fragments pass the depth bounds
2135bd8deadSopenharmony_ci    test.
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ciDependencies on OpenGL 3.3 and GL_ARB_occlusion_query2
2165bd8deadSopenharmony_ci
2175bd8deadSopenharmony_ci    If GL_ARB_occlusion_query2 is not present, and the GL version is less than
2185bd8deadSopenharmony_ci    3.3, then remove any reference to the ANY_SAMPLES_PASSED target.
2195bd8deadSopenharmony_ci
2205bd8deadSopenharmony_ciDependencies on OpenGL 4.3 and GL_ARB_ES3_compatibility
2215bd8deadSopenharmony_ci
2225bd8deadSopenharmony_ci    If GL_ARB_ES3_compatility is not present, and the GL version is less than
2235bd8deadSopenharmony_ci    4.3, then remove any reference to the ANY_SAMPLES_PASSED_CONSERVATIVE
2245bd8deadSopenharmony_ci    target.
2255bd8deadSopenharmony_ci
2265bd8deadSopenharmony_ciIssues
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci    1) Why is there no QUERY_STENCIL_PASS_BIT_AMD or
2295bd8deadSopenharmony_ci       QUERY_DEPTH_BOUNDS_PASS_BIT_AMD?
2305bd8deadSopenharmony_ci
2315bd8deadSopenharmony_ci       Fragments that pass the depth bounds test proceed to the stencil test
2325bd8deadSopenharmony_ci       and subsequently to the depth test. The sum of depth pass, depth fail
2335bd8deadSopenharmony_ci       and stencil fail is, by definition, the number of fragments that pass
2345bd8deadSopenharmony_ci       the depth bounds test. Likewise, the sum of depth pass and depth fail
2355bd8deadSopenharmony_ci       is the number of fragments that pass the stencil test. Thus, setting
2365bd8deadSopenharmony_ci       the event mask to (QUERY_DEPTH_PASS_EVENT_BIT_AMD |
2375bd8deadSopenharmony_ci       QUERY_DEPTH_FAIL_EVENT_BIT_AMD | QUERY_STENCIL_FAIL_EVENT_BIT_AMD)
2385bd8deadSopenharmony_ci       allows counting of fragments that pass the depth bounds test. Similarly,
2395bd8deadSopenharmony_ci       setting the event mask to (QUERY_DEPTH_PASS_EVENT_BIT_AMD |
2405bd8deadSopenharmony_ci       QUERY_DEPTH_FAIL_EVENT_BIT_AMD) provides the count of fragments that pass
2415bd8deadSopenharmony_ci       the stencil test.
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ci    2) Will fragments that fail the stencil test generate a depth pass or fail
2445bd8deadSopenharmony_ci       event as if they were depth tested? Will fragments that fail the depth
2455bd8deadSopenharmony_ci       bounds test generate stencil fail events?
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci       RESOLVED: No. Once a fragment fails testing at a particular stage, it
2485bd8deadSopenharmony_ci       is discarded and cannot generate any more events.
2495bd8deadSopenharmony_ci
2505bd8deadSopenharmony_ci    3) What happens if the implementation doesn't support EXT_depth_bounds.
2515bd8deadSopenharmony_ci
2525bd8deadSopenharmony_ci       RESOLVED: It is as if all fragments pass the depth bounds test. No
2535bd8deadSopenharmony_ci       depth bounds failed events are generated.
2545bd8deadSopenharmony_ci
2555bd8deadSopenharmony_ci    4) What is the purpose of QUERY_ALL_EVENT_BITS_AMD?
2565bd8deadSopenharmony_ci
2575bd8deadSopenharmony_ci       RESOLVED: It allows the counting of all fragments that are subjected to
2585bd8deadSopenharmony_ci       any test regardless of the outcome of those tests.
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci    5) What should the new query state setter function be called?
2615bd8deadSopenharmony_ci
2625bd8deadSopenharmony_ci       DISCUSSION: Unfortunately, the query object API doesn't really follow
2635bd8deadSopenharmony_ci       the naming conventions of object state getters already, as
2645bd8deadSopenharmony_ci       GetQueryObject should have been rather called GetQueryParameter.
2655bd8deadSopenharmony_ci       We considered the following options:
2665bd8deadSopenharmony_ci
2675bd8deadSopenharmony_ci        (a) QueryObjectuiAMD
2685bd8deadSopenharmony_ci        (b) QueryParameteruiAMD
2695bd8deadSopenharmony_ci        (c) QueryObjectParameteruiAMD
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci       Option (a) follows the existing naming convention of the query object
2725bd8deadSopenharmony_ci       API, but is too general.
2735bd8deadSopenharmony_ci       Option (b) follows the naming convention of other object types, but
2745bd8deadSopenharmony_ci       because the getter of existing query states is called GetQueryObject,
2755bd8deadSopenharmony_ci       while there is also a GetQuery getter that returns context state,
2765bd8deadSopenharmony_ci       not per-query object state.
2775bd8deadSopenharmony_ci       Option (c) doesn't follow either the naming convention of the query
2785bd8deadSopenharmony_ci       object API or any other object type's, but rather a mixture of the two,
2795bd8deadSopenharmony_ci       however, it makes explicit both the fact that the setter operates
2805bd8deadSopenharmony_ci       on a query object and that it modifies its parameter.
2815bd8deadSopenharmony_ci
2825bd8deadSopenharmony_ci       RESOLVED: QueryObjectParameteruiAMD, because the function modifies
2835bd8deadSopenharmony_ci       a state/parameter of a query object.
2845bd8deadSopenharmony_ci
2855bd8deadSopenharmony_ci    6) Should there be also a GetQueryObjectParameteruiAMD?
2865bd8deadSopenharmony_ci
2875bd8deadSopenharmony_ci       RESOLVED: No. GetQueryObject is already defined to query the state of
2885bd8deadSopenharmony_ci       a query object (see also issue #5).
2895bd8deadSopenharmony_ci
2905bd8deadSopenharmony_ciRevision History
2915bd8deadSopenharmony_ci
2925bd8deadSopenharmony_ci    Rev.    Date      Author    Changes
2935bd8deadSopenharmony_ci    ----  --------    --------  ---------------------------------------------
2945bd8deadSopenharmony_ci      3   11/20/2013  gsellers  Make ready for posting
2955bd8deadSopenharmony_ci      2   08/20/2013  drakos    Internal revision
2965bd8deadSopenharmony_ci      1   10/08/2012  gsellers  Initial revision
297