15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_occlusion_query2
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_occlusion_query2
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Aske Simon Christensen
125bd8deadSopenharmony_ci    Bill Licea-Kane
135bd8deadSopenharmony_ci    Cass Everitt
145bd8deadSopenharmony_ci    Jeff Bolz
155bd8deadSopenharmony_ci    Maurice Ribble
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ciContact
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ci    Bill Licea-Kane (bill 'at' amd.com)
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ciNotice
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    Copyright (c) 2010-2013 The Khronos Group Inc. Copyright terms at
245bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ciSpecification Update Policy
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
295bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
305bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
315bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
325bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
335bd8deadSopenharmony_ci    described in more detail at
345bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ciStatus
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ci    Complete. Approved by the ARB at the 2010/01/22 F2F meeting.
395bd8deadSopenharmony_ci    Approved by the Khronos Board of Promoters on March 10, 2010.
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ciVersion
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    Date: March 21, 2010
445bd8deadSopenharmony_ci    Revision: 11
455bd8deadSopenharmony_ci    $Id$
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ciNumber
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ci    ARB Extension #80
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ciDependencies
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ci    Written based on the wording of OpenGL Specification
545bd8deadSopenharmony_ci    Version 3.2 (Core Profile) - July 24, 2009
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    Version 3.2 (Compatibility Profile) interacts with this extension.
575bd8deadSopenharmony_ci
585bd8deadSopenharmony_ci    OpenGL 1.x is required.
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ci    ARB_occlusion_query interacts with this extension.
615bd8deadSopenharmony_ci
625bd8deadSopenharmony_ci    Conditional rendering interacts with this extension.
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ciOverview
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    This extension trivially adds a boolean occlusion query
675bd8deadSopenharmony_ci    to ARB_occlusion_query.
685bd8deadSopenharmony_ci
695bd8deadSopenharmony_ci    While the counter-based occlusion query provided by
705bd8deadSopenharmony_ci    ARB_occlusion_query is flexible, there is still value
715bd8deadSopenharmony_ci    to a simple boolean, which is often sufficient for applications.
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ciIP Status
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ci    There are no known claims.
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci    HP claimed IP to a related extension, ARB_occlusion_query.
785bd8deadSopenharmony_ci    HP committed to releasing rights to this IP to the ARB if the
795bd8deadSopenharmony_ci    functionality is included in OpenGL (April 10, 2003).
805bd8deadSopenharmony_ci    ARB_occlusion_query was promoted to core OpenGL 1.5 (July 29, 2003).
815bd8deadSopenharmony_ci
825bd8deadSopenharmony_ciNew Procedures and Functions
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ci    None
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ciNew Tokens
875bd8deadSopenharmony_ci
885bd8deadSopenharmony_ci    Accepted by the <target> parameter of BeginQuery, EndQuery,
895bd8deadSopenharmony_ci    and GetQueryiv:
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci        ANY_SAMPLES_PASSED                              0x8C2F
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 3.2 Specification
945bd8deadSopenharmony_ci(OpenGL Operation)
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ci2.14
975bd8deadSopenharmony_ciAsynchronous Queries
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_cip. 89-90, replace last sentence of first paragraph
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci   Occlusion queries (see section 4.1.6) count the number of fragments
1025bd8deadSopenharmony_ci   or samples that pass the depth test,
1035bd8deadSopenharmony_ci|  or set a boolean to true when fragments or samples pass the depth
1045bd8deadSopenharmony_ci|  test.
1055bd8deadSopenharmony_ci
1065bd8deadSopenharmony_cip. 90, modify the last paragraph before "The command void EndQuery..."
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci   BeginQuery sets the active query object name for the query type given by
1095bd8deadSopenharmony_ci   target to id. If BeginQuery is called with an id of zero, if the active query object
1105bd8deadSopenharmony_ci   name for target is non-zero
1115bd8deadSopenharmony_ci|  (for the targets SAMPLES_PASSED or ANY_SAMPLES PASSED, if the active query object
1125bd8deadSopenharmony_ci|  for either target is non-zero),
1135bd8deadSopenharmony_ci   if id is the name of an existing query object whose
1145bd8deadSopenharmony_ci   type does not match target, if id is the active query object name for any query type,
1155bd8deadSopenharmony_ci   or if id is the active query object for condtional rendering (see section 2.15), the
1165bd8deadSopenharmony_ci   error INVALID_OPERATION is generated.
1175bd8deadSopenharmony_ci
1185bd8deadSopenharmony_ci2.15
1195bd8deadSopenharmony_ciConditional Rendering
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_cip. 91
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ciAdd clause prior to "all rendering commands between"
1245bd8deadSopenharmony_ci
1255bd8deadSopenharmony_ci   "or if the result (ANY_SAMPLES_PASSED) is false,"
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ciAdd clause prior to "such commands are not discarded."
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ci   "or if the result is true,"
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_cip. 92
1325bd8deadSopenharmony_ci
1335bd8deadSopenharmony_ciChange last sentence of Section 2.15
1345bd8deadSopenharmony_ci
1355bd8deadSopenharmony_ci   The error
1365bd8deadSopenharmony_ci   INVALID_OPERATION is generated if id is the name of a query object with a target
1375bd8deadSopenharmony_ci   other than
1385bd8deadSopenharmony_ci|  SAMPLES_PASSED
1395bd8deadSopenharmony_ci|  or ANY_SAMPLES_PASSED,
1405bd8deadSopenharmony_ci   or id is the name of a query currently in progress.
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 3.2 Specification
1435bd8deadSopenharmony_ci(Per-Fragment Operations and the Frame Buffer)
1445bd8deadSopenharmony_ci
1455bd8deadSopenharmony_cip. 192, Replace 4.1.6
1465bd8deadSopenharmony_ciOcclusion Queries
1475bd8deadSopenharmony_ci
1485bd8deadSopenharmony_ci   Occlusion queries use query objects to track fragments or samples
1495bd8deadSopenharmony_ci   that pass the depth test. An occlusion query can be started and
1505bd8deadSopenharmony_ci   finished by calling BeginQuery and EndQuery, respectively, with a target
1515bd8deadSopenharmony_ci   of
1525bd8deadSopenharmony_ci|  SAMPLES_PASSED or ANY_SAMPLES_PASSED.
1535bd8deadSopenharmony_ci
1545bd8deadSopenharmony_ci   When an occlusion query is started
1555bd8deadSopenharmony_ci|  with the target SAMPLES_PASSED,
1565bd8deadSopenharmony_ci   the samples-passed count maintained by the GL is set to zero. While that
1575bd8deadSopenharmony_ci   occlusion query is active, the samples-passed count is incremented for
1585bd8deadSopenharmony_ci   each fragment that passes the depth test. If the value of SAMPLE_BUFFERS
1595bd8deadSopenharmony_ci   is 0, then the samples-passed count is incremented by 1 for each fragment.
1605bd8deadSopenharmony_ci   If the value of SAMPLE_BUFFERS is 1, then the samples-passed count is
1615bd8deadSopenharmony_ci   incremented by the number of samples whose coverage bit is set. However,
1625bd8deadSopenharmony_ci   implementations, at their discretion, may instead increase the samples-passed
1635bd8deadSopenharmony_ci   count by the value of SAMPLES if any sample in the fragment is covered.
1645bd8deadSopenharmony_ci   When an occlusion query finishes and all fragments generated by commands
1655bd8deadSopenharmony_ci   issued prior to EndQuery have been generated, the samples-passed count is written
1665bd8deadSopenharmony_ci   to the corresponding query object as the query result value, and the query result for
1675bd8deadSopenharmony_ci   that object is marked as available.
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci   If the samples-passed count overflows (exceeds the value 2^n - 1, where n is
1705bd8deadSopenharmony_ci   the number of bits in the samples-passed count), its value becomes undefined. It is
1715bd8deadSopenharmony_ci   recommended, but not required, that implementations handle this overflow case by
1725bd8deadSopenharmony_ci   saturating at 2^n - 1 and incrementing no further.
1735bd8deadSopenharmony_ci
1745bd8deadSopenharmony_ci|  When an occlusion query is started with the target ANY_SAMPLES_PASSED,
1755bd8deadSopenharmony_ci|  the samples-boolean state maintained by the GL is set to FALSE.  While
1765bd8deadSopenharmony_ci|  that occlusion query is active, the samples-boolean state is set to
1775bd8deadSopenharmony_ci|  TRUE if any fragment or sample passes the depth test.  When the
1785bd8deadSopenharmony_ci|  occlusion query finishes, the samples-boolean state of FALSE or TRUE
1795bd8deadSopenharmony_ci|  is written to the corresponding query object as the query result value,
1805bd8deadSopenharmony_ci|  and the query result for that object is marked as available.
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci
1835bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 3.2 Specification
1845bd8deadSopenharmony_ci(State and State Requests)
1855bd8deadSopenharmony_ci
1865bd8deadSopenharmony_ci6.1.6
1875bd8deadSopenharmony_ciAsynchronous Queries
1885bd8deadSopenharmony_cip. 255
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ciModify the Sentence beginning with "Information about the query target can be..."
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci   ...target idendifies the query target, and must be one of
1935bd8deadSopenharmony_ci   | SAMPLES_PASSED or ANY_SAMPLES_PASSED
1945bd8deadSopenharmony_ci   for occlusion queries...
1955bd8deadSopenharmony_ci
1965bd8deadSopenharmony_ciModify the paragraph beginning with "For occlusion queries (SAMPLES_PASSED)..."
1975bd8deadSopenharmony_ci
1985bd8deadSopenharmony_ci   For occlusion queries
1995bd8deadSopenharmony_ci|  (SAMPLES_PASSED and ANY_SAMPLES_PASSED), the number of bits
2005bd8deadSopenharmony_ci|  depends on the target.  For a target of ANY_SAMPLES_PASSED, if
2015bd8deadSopenharmony_ci|  the number of bits is non-zero,  the minimum number of bits is 1.  For a target
2025bd8deadSopenharmony_ci|  of SAMPLES_PASSED,
2035bd8deadSopenharmony_ci   if the number of bits is non-zero, ...
2045bd8deadSopenharmony_ci
2055bd8deadSopenharmony_ci
2065bd8deadSopenharmony_ciDependencies
2075bd8deadSopenharmony_ci
2085bd8deadSopenharmony_ciVersion 3.2 (Compatibility Profile) interacts with this extension.
2095bd8deadSopenharmony_ci
2105bd8deadSopenharmony_ci   Other than adjusting the page numbers referenced in the edits, there are no
2115bd8deadSopenharmony_ci   further changes required for the Compatibility Profile specification.
2125bd8deadSopenharmony_ci
2135bd8deadSopenharmony_ciARB_occlusion_query
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ci   If ARB_occlusion_query is not supported, then delete the enum
2165bd8deadSopenharmony_ci   SAMPLES_PASSED and delete sections of text refering to
2175bd8deadSopenharmony_ci   SAMPLES_PASSED, and incorporate all other enums, entry
2185bd8deadSopenharmony_ci   points and state introduced by ARB_occlusion_query into
2195bd8deadSopenharmony_ci   this extension.
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ciConditional Rendering
2225bd8deadSopenharmony_ci
2235bd8deadSopenharmony_ci   If Conditional Rendering is not supported, delete edits to
2245bd8deadSopenharmony_ci   section on Conditional Rendering.
2255bd8deadSopenharmony_ci
2265bd8deadSopenharmony_ciNew State
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci(table 6.33, p. 298)
2295bd8deadSopenharmony_ci
2305bd8deadSopenharmony_ci    Get Value         Type    Get Command          Initial Value   Description              Sec     Attribute
2315bd8deadSopenharmony_ci    ---------         ----    -----------          -------------   -----------              ------  ---------
2325bd8deadSopenharmony_ci    QUERY_RESULT      Z+      GetQueryObjectuiv    0               samples-passed count     6.1.6   -
2335bd8deadSopenharmony_ci|                                                  FALSE           or any-samples-passed
2345bd8deadSopenharmony_ci|                                                                  boolean value
2355bd8deadSopenharmony_ci
2365bd8deadSopenharmony_ci
2375bd8deadSopenharmony_ciUsage Examples
2385bd8deadSopenharmony_ci
2395bd8deadSopenharmony_ci    Here is some rough sample code that illustrates how this extension
2405bd8deadSopenharmony_ci    can be used.
2415bd8deadSopenharmony_ci
2425bd8deadSopenharmony_ci        GLuint    queries[N];
2435bd8deadSopenharmony_ci        GLint     sampleBoolean;
2445bd8deadSopenharmony_ci        GLint     available;
2455bd8deadSopenharmony_ci
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci        glGenQueries(N, queries);
2485bd8deadSopenharmony_ci        ...
2495bd8deadSopenharmony_ci        // before this point, render major occluders
2505bd8deadSopenharmony_ci        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
2515bd8deadSopenharmony_ci        glDepthMask(GL_FALSE);
2525bd8deadSopenharmony_ci        // also disable texturing and any fancy shaders
2535bd8deadSopenharmony_ci        for (i = 0; i < N; i++) {
2545bd8deadSopenharmony_ci            glBeginQuery(GL_ANY_SAMPLES_PASSED, queries[i]);
2555bd8deadSopenharmony_ci            // render bounding box for object i
2565bd8deadSopenharmony_ci            glEndQuery(GL_ANY_SAMPLES_PASSED);
2575bd8deadSopenharmony_ci        }
2585bd8deadSopenharmony_ci
2595bd8deadSopenharmony_ci        glFlush();
2605bd8deadSopenharmony_ci
2615bd8deadSopenharmony_ci        // Do other work until "most" of the queries are back, to avoid
2625bd8deadSopenharmony_ci        // wasting time spinning
2635bd8deadSopenharmony_ci        i = N*3/4; // instead of N-1, to prevent the GPU from going idle
2645bd8deadSopenharmony_ci        do {
2655bd8deadSopenharmony_ci            DoSomeStuff();
2665bd8deadSopenharmony_ci            glGetQueryObjectiv(queries[i],
2675bd8deadSopenharmony_ci                                  GL_QUERY_RESULT_AVAILABLE,
2685bd8deadSopenharmony_ci                                  &available);
2695bd8deadSopenharmony_ci        } while (!available);
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
2725bd8deadSopenharmony_ci        glDepthMask(GL_TRUE);
2735bd8deadSopenharmony_ci        // reenable other state, such as texturing
2745bd8deadSopenharmony_ci        for (i = 0; i < N; i++) {
2755bd8deadSopenharmony_ci            glGetQueryObjectuiv(queries[i], GL_QUERY_RESULT,
2765bd8deadSopenharmony_ci                                   &sampleBoolean);
2775bd8deadSopenharmony_ci            if (sampleBoolean != 0) {
2785bd8deadSopenharmony_ci                // render object i
2795bd8deadSopenharmony_ci            }
2805bd8deadSopenharmony_ci        }
2815bd8deadSopenharmony_ci
2825bd8deadSopenharmony_ci    Here is some rough sample code for a simple multipass rendering
2835bd8deadSopenharmony_ci    application that does not use occlusion queries.
2845bd8deadSopenharmony_ci
2855bd8deadSopenharmony_ci        for (i = 0; i < N; i++) {
2865bd8deadSopenharmony_ci            // First rendering pass
2875bd8deadSopenharmony_ci            glDisable(GL_BLEND);
2885bd8deadSopenharmony_ci            glDepthFunc(GL_LESS);
2895bd8deadSopenharmony_ci            glDepthMask(GL_TRUE);
2905bd8deadSopenharmony_ci            // configure shader 0
2915bd8deadSopenharmony_ci            // render object i
2925bd8deadSopenharmony_ci
2935bd8deadSopenharmony_ci            // Second rendering pass
2945bd8deadSopenharmony_ci            glEnable(GL_BLEND);
2955bd8deadSopenharmony_ci            glBlendFunc(...);
2965bd8deadSopenharmony_ci            glDepthFunc(GL_EQUAL);
2975bd8deadSopenharmony_ci            glDepthMask(GL_FALSE);
2985bd8deadSopenharmony_ci            // configure shader 1
2995bd8deadSopenharmony_ci            // render object i
3005bd8deadSopenharmony_ci        }
3015bd8deadSopenharmony_ci
3025bd8deadSopenharmony_ci    Here is the previous example, enhanced using occlusion queries.
3035bd8deadSopenharmony_ci
3045bd8deadSopenharmony_ci        GLuint queries[N];
3055bd8deadSopenharmony_ci        GLuint sampleBoolean;
3065bd8deadSopenharmony_ci
3075bd8deadSopenharmony_ci        glGenQueries(N, queries);
3085bd8deadSopenharmony_ci        ...
3095bd8deadSopenharmony_ci        // First rendering pass plus almost-free visibility checks
3105bd8deadSopenharmony_ci        glDisable(GL_BLEND);
3115bd8deadSopenharmony_ci        glDepthFunc(GL_LESS);
3125bd8deadSopenharmony_ci        glDepthMask(GL_TRUE);
3135bd8deadSopenharmony_ci        // configure shader 0
3145bd8deadSopenharmony_ci        for (i = 0; i < N; i++) {
3155bd8deadSopenharmony_ci            glBeginQuery(GL_ANY_SAMPLES_PASSED, queries[i]);
3165bd8deadSopenharmony_ci            // render object i
3175bd8deadSopenharmony_ci            glEndQuery(GL_ANY_SAMPLES_PASSED);
3185bd8deadSopenharmony_ci        }
3195bd8deadSopenharmony_ci
3205bd8deadSopenharmony_ci        // Second pass only on objects that were visible
3215bd8deadSopenharmony_ci        glEnable(GL_BLEND);
3225bd8deadSopenharmony_ci        glBlendFunc(...);
3235bd8deadSopenharmony_ci        glDepthFunc(GL_EQUAL);
3245bd8deadSopenharmony_ci        glDepthMask(GL_FALSE);
3255bd8deadSopenharmony_ci        // configure shader 1
3265bd8deadSopenharmony_ci        for (i = 0; i < N; i++) {
3275bd8deadSopenharmony_ci            glGetQueryObjectuiv(queries[i], GL_QUERY_RESULT,
3285bd8deadSopenharmony_ci                                   &sampleBoolean);
3295bd8deadSopenharmony_ci            if (sampleBoolean != 0) {
3305bd8deadSopenharmony_ci                // render object i
3315bd8deadSopenharmony_ci            }
3325bd8deadSopenharmony_ci        }
3335bd8deadSopenharmony_ci
3345bd8deadSopenharmony_ci
3355bd8deadSopenharmony_ciIssues
3365bd8deadSopenharmony_ci
3375bd8deadSopenharmony_ci    1) Can an occlusion query with a target of SAMPLES_PASSED
3385bd8deadSopenharmony_ci       be active at the same time as an occlusion query with a
3395bd8deadSopenharmony_ci       target of ANY_SAMPLES_PASSED?
3405bd8deadSopenharmony_ci
3415bd8deadSopenharmony_ci       Resolved.  No!  Specifically, it is an error to BeginQuery for
3425bd8deadSopenharmony_ci       the targets SAMPLES_PASSED or ANY_SAMPLES_PASSED if the active
3435bd8deadSopenharmony_ci       query is non-zero for EITHER target.
3445bd8deadSopenharmony_ci
3455bd8deadSopenharmony_ci    2) How many query types are there?
3465bd8deadSopenharmony_ci
3475bd8deadSopenharmony_ci       Unresolved.
3485bd8deadSopenharmony_ci
3495bd8deadSopenharmony_ci       The spec says "There are two query types" (p. 89), and
3505bd8deadSopenharmony_ci       list them as Transform Feedback Queries and Occlusion Queries.
3515bd8deadSopenharmony_ci
3525bd8deadSopenharmony_ci       The spec says "Each type of query supported by the GL has an active
3535bd8deadSopenharmony_ci       query object name."  (p. 90)
3545bd8deadSopenharmony_ci
3555bd8deadSopenharmony_ci       Table 6.47 Miscellaneous (p. 312) says there are
3565bd8deadSopenharmony_ci       CURRENT_QUERY 3 x Z+.
3575bd8deadSopenharmony_ci
3585bd8deadSopenharmony_ci       I believe there are three:
3595bd8deadSopenharmony_ci
3605bd8deadSopenharmony_ci       Primitive Queries (target PRIMITIVES_GENERATED)
3615bd8deadSopenharmony_ci       Transform Feedback Queries (target TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)
3625bd8deadSopenharmony_ci       and
3635bd8deadSopenharmony_ci       Occlusion Queries (target SAMPLES_PASSED or ANY_SAMPLES_PASSED)
3645bd8deadSopenharmony_ci
3655bd8deadSopenharmony_ci       It is probable that the spec should say "There are three query types"
3665bd8deadSopenharmony_ci       and list them as Primitive Queries (section 2.17), Transform Feedback
3675bd8deadSopenharmony_ci       Queries (section 2.16) and Occlusion Queries (section 4.1.6).
3685bd8deadSopenharmony_ci
3695bd8deadSopenharmony_ci       A separate bug will be posted for the core specification to clarify
3705bd8deadSopenharmony_ci       Primitive Queries and Transform Feedback.
3715bd8deadSopenharmony_ci
3725bd8deadSopenharmony_ci       This extension currently assumes that the bug will be resolved and only
3735bd8deadSopenharmony_ci       edits the Occlusion Queries type to expand it to two targets.
3745bd8deadSopenharmony_ci
3755bd8deadSopenharmony_ci    3) Can we limit the number of query objects active?
3765bd8deadSopenharmony_ci
3775bd8deadSopenharmony_ci       Unresolved.  This draft doesn't.
3785bd8deadSopenharmony_ci
3795bd8deadSopenharmony_ci       But, yes, we can limit the number of query objects active.
3805bd8deadSopenharmony_ci       The language to do so would be straightforward, but why?
3815bd8deadSopenharmony_ci
3825bd8deadSopenharmony_ci       There can only be ONE occlusion query active at a time.  The query object
3835bd8deadSopenharmony_ci       created (or re-used) at BeginQuery contains the state to save the
3845bd8deadSopenharmony_ci       boolean.  At EndQuery the boolean for the current query is copied to
3855bd8deadSopenharmony_ci       the query object's state.
3865bd8deadSopenharmony_ci
3875bd8deadSopenharmony_ci       (Clearly, OES can make another choice.  But not sure why right now.)
3885bd8deadSopenharmony_ci
3895bd8deadSopenharmony_ci    4) Currently, if a draw within BeginQuery/EndQuery passes a depth
3905bd8deadSopenharmony_ci       test, and a subsequent draw later covers all the pixels, can an
3915bd8deadSopenharmony_ci       implementation return false (assuming the application queried
3925bd8deadSopenharmony_ci       the result after the subsequent draw)?
3935bd8deadSopenharmony_ci
3945bd8deadSopenharmony_ci       Unresolved.  This draft defers the issue.
3955bd8deadSopenharmony_ci       The language to allow this is non-trivial.
3965bd8deadSopenharmony_ci
3975bd8deadSopenharmony_ci       Please note, the typical application will:
3985bd8deadSopenharmony_ci
3995bd8deadSopenharmony_ci       * set the color/depth masks to true, and blend state
4005bd8deadSopenharmony_ci       * draw the major occluders
4015bd8deadSopenharmony_ci       * draw visible opaque objects (coarsly sorted if possible)
4025bd8deadSopenharmony_ci       * set the color/depth masks to false
4035bd8deadSopenharmony_ci       * draw proxies for geometry which *might* be visible, with occlusion queries
4045bd8deadSopenharmony_ci       * set the color masks to true, and blend state
4055bd8deadSopenharmony_ci       * draw any transparent objects (sorted if possible)
4065bd8deadSopenharmony_ci       * swap
4075bd8deadSopenharmony_ci
4085bd8deadSopenharmony_ci       * set the color/depth masks to true, and blend state
4095bd8deadSopenharmony_ci       * draw the major occluders
4105bd8deadSopenharmony_ci       * test the queries that are available from the prior frame
4115bd8deadSopenharmony_ci       * draw visible and newly visible opaque objects (coarsly sorted if possible)
4125bd8deadSopenharmony_ci       * set the color/depth masks to false
4135bd8deadSopenharmony_ci       * draw proxies for geometry which *might* be visible, with occlusion queries
4145bd8deadSopenharmony_ci       * set the color masks to true, and blend state
4155bd8deadSopenharmony_ci       * draw any transparent objects (sorted if possible)
4165bd8deadSopenharmony_ci       * swap
4175bd8deadSopenharmony_ci
4185bd8deadSopenharmony_ci       This technique has the disadvantage that the newly exposed
4195bd8deadSopenharmony_ci       geometry is one frame late, but this is generally not considered
4205bd8deadSopenharmony_ci       an issue.  The advantage that in general the results are available by
4215bd8deadSopenharmony_ci       the time the query is tested.
4225bd8deadSopenharmony_ci
4235bd8deadSopenharmony_ci       Note that no opaque occluders follow the queries in a frame.
4245bd8deadSopenharmony_ci
4255bd8deadSopenharmony_ci       Another common variation is:
4265bd8deadSopenharmony_ci
4275bd8deadSopenharmony_ci       * set the color/depth masks to true, and blend state
4285bd8deadSopenharmony_ci       * draw the major occluders
4295bd8deadSopenharmony_ci       * draw the visible opaque objects (corsely sorted if possible)
4305bd8deadSopenharmony_ci         with occlusion queries
4315bd8deadSopenharmony_ci       * set the color/depth mask to false
4325bd8deadSopenharmony_ci       * draw proxies for geometry which *might* be visible, with occlusion queries
4335bd8deadSopenharmony_ci       * set the color masks to true, and blend state
4345bd8deadSopenharmony_ci       * draw any transparent objects (sorted if possible)
4355bd8deadSopenharmony_ci       * swap
4365bd8deadSopenharmony_ci
4375bd8deadSopenharmony_ci       * set the color/depth masks to true, and blend state
4385bd8deadSopenharmony_ci       * draw the major occluders
4395bd8deadSopenharmony_ci       * test the queries that are available from the prior frame
4405bd8deadSopenharmony_ci       * draw the still visible and newly visible opaque objects (coarsely sorted if possible)
4415bd8deadSopenharmony_ci         with occlusion queries
4425bd8deadSopenharmony_ci       * set the color/depth mask to false
4435bd8deadSopenharmony_ci       * draw proxies for geometry which *might* be visible, with occlusion queries
4445bd8deadSopenharmony_ci       * set the color masks to true, and blend state
4455bd8deadSopenharmony_ci       * draw any transparent objects (sorted if possible)
4465bd8deadSopenharmony_ci       * swap
4475bd8deadSopenharmony_ci
4485bd8deadSopenharmony_ci       This technique still has the disadvantage that newly exposed
4495bd8deadSopenharmony_ci       geometry is one frame late, but still not considered an issue.
4505bd8deadSopenharmony_ci       The advantage is that in general the results are available by the
4515bd8deadSopenharmony_ci       time the query is tested.
4525bd8deadSopenharmony_ci
4535bd8deadSopenharmony_ci       This technique also culls geometry that was visible as it gets
4545bd8deadSopenharmony_ci       occluded.  (Though there can be some "picket fence" issues
4555bd8deadSopenharmony_ci       and the occlusion query for actual geometry and proxy geometry
4565bd8deadSopenharmony_ci       can cycle between false-true.)
4575bd8deadSopenharmony_ci
4585bd8deadSopenharmony_ci       Note that opaque occluders follow the queries in a frame.
4595bd8deadSopenharmony_ci
4605bd8deadSopenharmony_ci    5) What is this extension called?
4615bd8deadSopenharmony_ci
4625bd8deadSopenharmony_ci       Resolved.
4635bd8deadSopenharmony_ci       Earlier drafts were EXT_occlusion_query2.
4645bd8deadSopenharmony_ci       This draft is ARB_occlusion_query2.
4655bd8deadSopenharmony_ci
4665bd8deadSopenharmony_ci    6) What should the enum be called?
4675bd8deadSopenharmony_ci
4685bd8deadSopenharmony_ci       Resolved.
4695bd8deadSopenharmony_ci       ANY_SAMPLES_PASSED.
4705bd8deadSopenharmony_ci
4715bd8deadSopenharmony_ci    7) Do we need "state required" for occlusion query objects?
4725bd8deadSopenharmony_ci
4735bd8deadSopenharmony_ci       Resolved.  No.
4745bd8deadSopenharmony_ci       That listing of state required had been moved to asynchronous
4755bd8deadSopenharmony_ci       queries Section 2.14.  It has been excised from the occlusion
4765bd8deadSopenharmony_ci       query section.
4775bd8deadSopenharmony_ci
4785bd8deadSopenharmony_ci    8) Can an occlusion query "morph" from SAMPLES_PASSED to
4795bd8deadSopenharmony_ci       ANY_SAMPLES_PASSED?  That is, can the sequence
4805bd8deadSopenharmony_ci       BeginQuery( SAMPLES_PASSED )...EndQuery( ANY_SAMPLES_PASSED )
4815bd8deadSopenharmony_ci       (or vice-versa)?
4825bd8deadSopenharmony_ci
4835bd8deadSopenharmony_ci       Resolved.  No.  Note this falls naturally by leaving the
4845bd8deadSopenharmony_ci       EndQuery error language alone.  ("If the active query object
4855bd8deadSopenharmony_ci       name for target is zero when EndQuery is called, the error
4865bd8deadSopenharmony_ci       INVALID_OPERATION is generated.")
4875bd8deadSopenharmony_ci
4885bd8deadSopenharmony_ciRevision History
4895bd8deadSopenharmony_ci    2010-03-21
4905bd8deadSopenharmony_ci    11, pbrown
4915bd8deadSopenharmony_ci    Minor typo/wording fixes.
4925bd8deadSopenharmony_ci
4935bd8deadSopenharmony_ci    2010-01-26
4945bd8deadSopenharmony_ci    10, pbrown
4955bd8deadSopenharmony_ci    Assign enum value for ANY_SAMPLES_PASSED, using same allocation from
4965bd8deadSopenharmony_ci    OES_occlusion_query.  Enums are functionally equivalent.
4975bd8deadSopenharmony_ci
4985bd8deadSopenharmony_ci    2010-01-21
4995bd8deadSopenharmony_ci    9, wwlk
5005bd8deadSopenharmony_ci    JUST update version, date
5015bd8deadSopenharmony_ci
5025bd8deadSopenharmony_ci    2010-01-20
5035bd8deadSopenharmony_ci    8, wwlk
5045bd8deadSopenharmony_ci    Update issue 1, add issues 7 and 8.
5055bd8deadSopenharmony_ci    Update the spec language to make it clear that you can't
5065bd8deadSopenharmony_ci    start an occlusion query if an occlusion query (of either type) is
5075bd8deadSopenharmony_ci    already active.
5085bd8deadSopenharmony_ci    Update the spec language to trivially clarify conditional rendering.
5095bd8deadSopenharmony_ci
5105bd8deadSopenharmony_ci    2009-12-10
5115bd8deadSopenharmony_ci    7, Jon Leech
5125bd8deadSopenharmony_ci    Remove ARB suffixes for core 3.3 spec inclusion. Fix equation
5135bd8deadSopenharmony_ci    typos.
5145bd8deadSopenharmony_ci
5155bd8deadSopenharmony_ci    2009-11-13
5165bd8deadSopenharmony_ci    6, wwlk
5175bd8deadSopenharmony_ci    Updated name and name strings to match ARB_occlusion_query2
5185bd8deadSopenharmony_ci
5195bd8deadSopenharmony_ci    2009-10-22
5205bd8deadSopenharmony_ci    5, wwlk
5215bd8deadSopenharmony_ci    Renamed to ARB_occlusion_query2 (and changed EXT to ARB)
5225bd8deadSopenharmony_ci    Renamed ENUM (and updated ENUMs throughout) to ANY_SAMPLES_PASSED
5235bd8deadSopenharmony_ci    Misc typos (Synchronos, COmpatibility)
5245bd8deadSopenharmony_ci
5255bd8deadSopenharmony_ci    2009-10-02
5265bd8deadSopenharmony_ci    4, wwlk
5275bd8deadSopenharmony_ci    Updates from comments.
5285bd8deadSopenharmony_ci    Renamed to EXT_occlusion_query_boolean
5295bd8deadSopenharmony_ci    Renamed ENUM(s)
5305bd8deadSopenharmony_ci    Elaborated on issue 4.
5315bd8deadSopenharmony_ci
5325bd8deadSopenharmony_ci    2009-09-29
5335bd8deadSopenharmony_ci    3, wwlk
5345bd8deadSopenharmony_ci    updates from comments.
5355bd8deadSopenharmony_ci    Added issues 4,5,6.
5365bd8deadSopenharmony_ci
5375bd8deadSopenharmony_ci    2009-09-28
5385bd8deadSopenharmony_ci    2, wwlk
5395bd8deadSopenharmony_ci    minor typo, add conditional rendering
5405bd8deadSopenharmony_ci
5415bd8deadSopenharmony_ci    2009-09-28
5425bd8deadSopenharmony_ci    1, wwlk
5435bd8deadSopenharmony_ci    first draft
544