15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_query_buffer_object
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_query_buffer_object
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Daniel Rakos (daniel.rakos 'at' amd.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciContributors
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Daniel Rakos, AMD
165bd8deadSopenharmony_ci    Graham Sellers, AMD
175bd8deadSopenharmony_ci    Christophe Riccio, AMD
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ciNotice
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ci    Copyright (c) 2013 The Khronos Group Inc. Copyright terms at
225bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ciSpecification Update Policy
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
275bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
285bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
295bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
305bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
315bd8deadSopenharmony_ci    described in more detail at
325bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ciStatus
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ci    Complete. Approved by the ARB on June 3, 2013.
375bd8deadSopenharmony_ci    Ratified by the Khronos Board of Promoters on July 19, 2013.
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ciVersion
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ci    Last Modified Date: 7 March 2016
425bd8deadSopenharmony_ci    Author Revision: 3
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ciNumber
455bd8deadSopenharmony_ci
465bd8deadSopenharmony_ci    ARB Extension #148
475bd8deadSopenharmony_ci
485bd8deadSopenharmony_ciDependencies
495bd8deadSopenharmony_ci
505bd8deadSopenharmony_ci    OpenGL 1.5 is required.
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    This extension is written against the OpenGL 4.3 (core) specification.
535bd8deadSopenharmony_ci
545bd8deadSopenharmony_ciOverview
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    Statistics about the operation of the OpenGL pipeline, such as the number
575bd8deadSopenharmony_ci    of samples that passed the depth test, the elapsed time between two events
585bd8deadSopenharmony_ci    or the number of vertices written by transform feedback can be retrieved
595bd8deadSopenharmony_ci    from the GL through query objects. The result of a query object is
605bd8deadSopenharmony_ci    acquired by the application through the OpenGL API into a client provided
615bd8deadSopenharmony_ci    memory location. Should the result returned by the API be required for use
625bd8deadSopenharmony_ci    in a shader, it must be passed back to the GL via a program uniform or
635bd8deadSopenharmony_ci    some other mechanism. This requires a round-trip from the GPU to the CPU
645bd8deadSopenharmony_ci    and back.
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    This extension introduces a mechanism whereby the result of a query object
675bd8deadSopenharmony_ci    may be retrieved into a buffer object instead of client memory. This allows
685bd8deadSopenharmony_ci    the query rsult to be made available to a shader without a round-trip to
695bd8deadSopenharmony_ci    the CPU for example by subsequently using the buffer object as a uniform
705bd8deadSopenharmony_ci    buffer, texture buffer or other data store visible to the shader. This
715bd8deadSopenharmony_ci    functionality may also be used to place the results of many query objects
725bd8deadSopenharmony_ci    into a single, large buffer and then map or otherwise read back the entire
735bd8deadSopenharmony_ci    buffer at a later point in time, avoiding a per-query object CPU-GPU
745bd8deadSopenharmony_ci    synchronization event.
755bd8deadSopenharmony_ci
765bd8deadSopenharmony_ci    The extension allows acquiring the result of any query object type
775bd8deadSopenharmony_ci    supported by the GL implementation into a buffer object. The implementation
785bd8deadSopenharmony_ci    will determine the most efficient method of copying the query result to the
795bd8deadSopenharmony_ci    buffer.
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ciNew Procedures and Functions
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ci    None.
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ciNew Tokens
865bd8deadSopenharmony_ci
875bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetQueryObjectiv, GetQueryObjectuiv,
885bd8deadSopenharmony_ci    GetQueryObjecti64v and GetQueryObjectui64v:
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci        QUERY_RESULT_NO_WAIT                            0x9194
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ci    Accepted by the <target> parameter of BindBuffer, BufferData,
935bd8deadSopenharmony_ci    BufferSubData, MapBuffer, UnmapBuffer, MapBufferRange, GetBufferSubData,
945bd8deadSopenharmony_ci    GetBufferParameteriv, GetBufferParameteri64v, GetBufferPointerv,
955bd8deadSopenharmony_ci    ClearBufferSubData, and the <readtarget> and <writetarget> parameters of
965bd8deadSopenharmony_ci    CopyBufferSubData:
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ci        QUERY_BUFFER                                    0x9192
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv,
1015bd8deadSopenharmony_ci    and GetDoublev:
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci        QUERY_BUFFER_BINDING                            0x9193
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ci    Accepted in the <barriers> bitfield in MemoryBarrier:
1065bd8deadSopenharmony_ci
1075bd8deadSopenharmony_ci        QUERY_BUFFER_BARRIER_BIT                        0x00008000
1085bd8deadSopenharmony_ci
1095bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL Core Profile Specification, Version 4.3,
1105bd8deadSopenharmony_ci"Event Model"
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci    Modify Section 4.2.1, "Query Object Queries"
1135bd8deadSopenharmony_ci
1145bd8deadSopenharmony_ci    Add new paragraph after the fist paragraph on p. 44 ending with
1155bd8deadSopenharmony_ci    "... <id> is the name of a query object."
1165bd8deadSopenharmony_ci
1175bd8deadSopenharmony_ci        Initially, zero is bound to the QUERY_BUFFER binding point, indicating
1185bd8deadSopenharmony_ci    that <params> is a pointer into client memory. However, if a non-zero
1195bd8deadSopenharmony_ci    buffer object is bound as the current query result buffer (see section
1205bd8deadSopenharmony_ci    6.1), then <params> is treated as an offset into the designated buffer
1215bd8deadSopenharmony_ci    object.
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ci    Add new paragraph after the third paragraph on p. 44 ending with
1245bd8deadSopenharmony_ci    "... finite amount of time."
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci        If <pname> is QUERY_RESULT_NO_WAIT, then the query object's result
1275bd8deadSopenharmony_ci    value is returned as a single integer in <params> if the result is
1285bd8deadSopenharmony_ci    available at the time of the state query. If the result is not available
1295bd8deadSopenharmony_ci    then the destination memory location is not overwritten.
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL Core Profile Specification, Version 4.3,
1325bd8deadSopenharmony_ci"Buffer Objects"
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci    Modify Section 6.1, "Creating and Binding Buffer Objects"
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci    Add to Table 6.1: "Buffer object binding targets"
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    +--------------------+--------------------------+-------------------------+
1395bd8deadSopenharmony_ci    | Target name        | Purpose                  | Described in section(s) |
1405bd8deadSopenharmony_ci    +--------------------+--------------------------+-------------------------+
1415bd8deadSopenharmony_ci    | QUERY_BUFFER       | Query result buffer      | 4.2.1                   |
1425bd8deadSopenharmony_ci    +--------------------+--------------------------+-------------------------+
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ciAdditions to Chapter 7 of the OpenGL Core Profile Specification, Version 4.3,
1455bd8deadSopenharmony_ci"Programs and Shaders"
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci    Modify Section 7.12, "Shader Memory Access"
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci    Add to the list of MemoryBarrier <barriers> bullets, p. 138
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci      * QUERY_BUFFER_BARRIER_BIT: Writes of buffer objects via the QUERY_BUFFER
1525bd8deadSopenharmony_ci        binding (see section 4.2.1) after the barrier will reflect data written
1535bd8deadSopenharmony_ci        by shaders prior to the barrier. Additionally, buffer object writes
1545bd8deadSopenharmony_ci        issued after the barrier will wait on the completion of all shader
1555bd8deadSopenharmony_ci        writes initiated prior to the barrier.
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
1585bd8deadSopenharmony_ci
1595bd8deadSopenharmony_ci    None.
1605bd8deadSopenharmony_ci
1615bd8deadSopenharmony_ciGLX Protocol
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci    None.
1645bd8deadSopenharmony_ci
1655bd8deadSopenharmony_ciErrors
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ci  Replace second error case for QueryObject* with the following:
1685bd8deadSopenharmony_ci
1695bd8deadSopenharmony_ci    An INVALID_ENUM error is generated if <pname> is not QUERY_RESULT,
1705bd8deadSopenharmony_ci    QUERY_RESULT_NO_WAIT or QUERY_RESULT_AVAILABLE.
1715bd8deadSopenharmony_ci
1725bd8deadSopenharmony_ci  Add error case for QueryObject* as follows:
1735bd8deadSopenharmony_ci
1745bd8deadSopenharmony_ci    An INVALID_OPERATION error is generated if the command would cause data
1755bd8deadSopenharmony_ci    to be written beyond the bounds of the buffer currently bound to the
1765bd8deadSopenharmony_ci    QUERY_BUFFER target.
1775bd8deadSopenharmony_ci
1785bd8deadSopenharmony_ciNew State
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ci    Append to Table 23.73, "Miscellaneous"
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci    +----------------------+------+--------------+---------------+------------------------------+-------+
1835bd8deadSopenharmony_ci    | Get Value            | Type | Get Command  | Initial Value | Description                  | Sec.  |
1845bd8deadSopenharmony_ci    +----------------------+------+--------------+---------------+------------------------------+-------+
1855bd8deadSopenharmony_ci    | QUERY_BUFFER_BINDING | Z+   | GetIntegeriv | 0             | Query result buffer binding. | 4.2.1 |
1865bd8deadSopenharmony_ci    +----------------------+------+--------------+---------------+------------------------------+-------+
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ciNew Implementation Dependent State
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci    None.
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ciUsage Examples
1935bd8deadSopenharmony_ci
1945bd8deadSopenharmony_ci    Convenient macro definition for specifying buffer offsets:
1955bd8deadSopenharmony_ci
1965bd8deadSopenharmony_ci        #define BUFFER_OFFSET(i)    ((void*)NULL + (i))
1975bd8deadSopenharmony_ci
1985bd8deadSopenharmony_ci    Example 1: Using occlusion query result in shader
1995bd8deadSopenharmony_ci
2005bd8deadSopenharmony_ci        // Create a buffer object for the query result
2015bd8deadSopenharmony_ci        glGenBuffers(1, &queryBuffer);
2025bd8deadSopenharmony_ci        glBindBuffer(GL_QUERY_BUFFER, queryBuffer);
2035bd8deadSopenharmony_ci        glBufferData(GL_QUERY_BUFFER, sizeof(GLuint),
2045bd8deadSopenharmony_ci                     NULL, GL_DYNAMIC_COPY);
2055bd8deadSopenharmony_ci
2065bd8deadSopenharmony_ci        // Perform occlusion query
2075bd8deadSopenharmony_ci        glBeginQuery(GL_SAMPLES_PASSED, queryId)
2085bd8deadSopenharmony_ci        ...
2095bd8deadSopenharmony_ci        glEndQuery(GL_SAMPLES_PASSED);
2105bd8deadSopenharmony_ci
2115bd8deadSopenharmony_ci        // Get query results to buffer object
2125bd8deadSopenharmony_ci        glBindBuffer(GL_QUERY_BUFFER, queryBuffer);
2135bd8deadSopenharmony_ci        glGetQueryObjectuiv(queryId, GL_QUERY_RESULT, BUFFER_OFFSET(0));
2145bd8deadSopenharmony_ci
2155bd8deadSopenharmony_ci        // Bind query result buffer as uniform buffer
2165bd8deadSopenharmony_ci        glBindBufferBase(GL_UNIFORM_BUFFER, 0, queryBuffer);
2175bd8deadSopenharmony_ci        ...
2185bd8deadSopenharmony_ci
2195bd8deadSopenharmony_ci        --- Shader ---
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci        ...
2225bd8deadSopenharmony_ci        uniform queryResult {
2235bd8deadSopenharmony_ci            uint samplesPassed;
2245bd8deadSopenharmony_ci        };
2255bd8deadSopenharmony_ci        ...
2265bd8deadSopenharmony_ci        void main() {
2275bd8deadSopenharmony_ci            ...
2285bd8deadSopenharmony_ci            if (samplesPassed > threshold) {
2295bd8deadSopenharmony_ci                // complex processing
2305bd8deadSopenharmony_ci                ...
2315bd8deadSopenharmony_ci            } else {
2325bd8deadSopenharmony_ci                // simplified processing
2335bd8deadSopenharmony_ci                ...
2345bd8deadSopenharmony_ci            }
2355bd8deadSopenharmony_ci            ...
2365bd8deadSopenharmony_ci        }
2375bd8deadSopenharmony_ci
2385bd8deadSopenharmony_ci    Example 2: Using occlusion query result in shader only if result is available
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ci        // Create a buffer object for the query result
2415bd8deadSopenharmony_ci        glGenBuffers(1, &queryBuffer);
2425bd8deadSopenharmony_ci        glBindBuffer(GL_QUERY_BUFFER, queryBuffer);
2435bd8deadSopenharmony_ci        glBufferData(GL_QUERY_BUFFER, 2 * sizeof(GLuint),
2445bd8deadSopenharmony_ci                     NULL, GL_DYNAMIC_COPY);
2455bd8deadSopenharmony_ci
2465bd8deadSopenharmony_ci        // Perform occlusion query
2475bd8deadSopenharmony_ci        glBeginQuery(GL_SAMPLES_PASSED, queryId)
2485bd8deadSopenharmony_ci        ...
2495bd8deadSopenharmony_ci        glEndQuery(GL_SAMPLES_PASSED);
2505bd8deadSopenharmony_ci
2515bd8deadSopenharmony_ci        // Get query availability and result (if available) to buffer object
2525bd8deadSopenharmony_ci        glBindBuffer(GL_QUERY_BUFFER, queryBuffer);
2535bd8deadSopenharmony_ci        glGetQueryObjectuiv(queryId, GL_QUERY_RESULT_AVAILABLE, BUFFER_OFFSET(0));
2545bd8deadSopenharmony_ci        glGetQueryObjectuiv(queryId, GL_QUERY_RESULT_NO_WAIT, BUFFER_OFFSET(4));
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci        // Bind query result buffer as uniform buffer
2575bd8deadSopenharmony_ci        glBindBufferBase(GL_UNIFORM_BUFFER, 0, queryBuffer);
2585bd8deadSopenharmony_ci        ...
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci        --- Shader ---
2615bd8deadSopenharmony_ci        
2625bd8deadSopenharmony_ci        ...
2635bd8deadSopenharmony_ci        uniform queryResult {
2645bd8deadSopenharmony_ci            uint resultAvailable;
2655bd8deadSopenharmony_ci            uint samplesPassed;
2665bd8deadSopenharmony_ci        };
2675bd8deadSopenharmony_ci        ...
2685bd8deadSopenharmony_ci        void main() {
2695bd8deadSopenharmony_ci            ...
2705bd8deadSopenharmony_ci            if (resultAvailable) {
2715bd8deadSopenharmony_ci                if (samplesPassed > threshold) {
2725bd8deadSopenharmony_ci                    // complex processing
2735bd8deadSopenharmony_ci                    ...
2745bd8deadSopenharmony_ci                } else {
2755bd8deadSopenharmony_ci                    // simplified processing
2765bd8deadSopenharmony_ci                    ...
2775bd8deadSopenharmony_ci                }
2785bd8deadSopenharmony_ci            } else {
2795bd8deadSopenharmony_ci                // default processing if no query result is available
2805bd8deadSopenharmony_ci                ...
2815bd8deadSopenharmony_ci            }
2825bd8deadSopenharmony_ci            ...
2835bd8deadSopenharmony_ci        }
2845bd8deadSopenharmony_ci        
2855bd8deadSopenharmony_ci    Example 3: Using a default value and QUERY_RESULT_NO_WAIT
2865bd8deadSopenharmony_ci
2875bd8deadSopenharmony_ci        // Create a buffer object for the query result        
2885bd8deadSopenharmony_ci        // Store a default value in the buffer that will be used
2895bd8deadSopenharmony_ci        // if the query results are not available
2905bd8deadSopenharmony_ci        glGenBuffers(1, &queryBuffer);
2915bd8deadSopenharmony_ci        glBindBuffer(GL_QUERY_BUFFER, queryBuffer);
2925bd8deadSopenharmony_ci        GLuint defaultValue = 42;
2935bd8deadSopenharmony_ci        glBufferData(GL_QUERY_BUFFER, sizeof(GLuint),
2945bd8deadSopenharmony_ci                     &defaultValue, GL_DYNAMIC_COPY);
2955bd8deadSopenharmony_ci        
2965bd8deadSopenharmony_ci        // Perform occlusion query
2975bd8deadSopenharmony_ci        glBeginQuery(GL_SAMPLES_PASSED, queryId)
2985bd8deadSopenharmony_ci        ...
2995bd8deadSopenharmony_ci        glEndQuery(GL_SAMPLES_PASSED);
3005bd8deadSopenharmony_ci
3015bd8deadSopenharmony_ci        // Get query results to buffer object with no wait
3025bd8deadSopenharmony_ci        // Default value remains untouched if results are not available
3035bd8deadSopenharmony_ci        glBindBuffer(GL_QUERY_BUFFER, queryBuffer);
3045bd8deadSopenharmony_ci        glGetQueryObjectuiv(queryId, GL_QUERY_RESULT_NO_WAIT, BUFFER_OFFSET(0));
3055bd8deadSopenharmony_ci        ...
3065bd8deadSopenharmony_ci
3075bd8deadSopenharmony_ci    Example 4: Using transform feedback query result to fill indirect draw buffer
3085bd8deadSopenharmony_ci
3095bd8deadSopenharmony_ci        // Create a buffer object for the indirect draw command        
3105bd8deadSopenharmony_ci        glGenBuffers(1, &drawIndirectBuffer);
3115bd8deadSopenharmony_ci
3125bd8deadSopenharmony_ci        // Initialize draw command
3135bd8deadSopenharmony_ci        DrawArraysIndirectCommand cmd = { ... };
3145bd8deadSopenharmony_ci        glBindBuffer(GL_DRAW_INDIRECT_BUFFER, drawIndirectBuffer);
3155bd8deadSopenharmony_ci        glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(DrawArraysIndirectCommand),
3165bd8deadSopenharmony_ci                     &cmd, GL_DYNAMIC_COPY);
3175bd8deadSopenharmony_ci        
3185bd8deadSopenharmony_ci        // Perform transform feedback query
3195bd8deadSopenharmony_ci        glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queryId)
3205bd8deadSopenharmony_ci        ...
3215bd8deadSopenharmony_ci        glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
3225bd8deadSopenharmony_ci
3235bd8deadSopenharmony_ci        // Write query result to the primCount field of the indirect draw command
3245bd8deadSopenharmony_ci        glBindBuffer(GL_QUERY_BUFFER, drawIndirectBuffer);
3255bd8deadSopenharmony_ci        glGetQueryObjectuiv(queryId, GL_QUERY_RESULT,
3265bd8deadSopenharmony_ci                            BUFFER_OFFSET(offsetof(DrawArraysIndirectCommand, primCount)));
3275bd8deadSopenharmony_ci
3285bd8deadSopenharmony_ci        // Execute the indirect draw command
3295bd8deadSopenharmony_ci        glDrawArraysIndirect(GL_TRIANGLES, BUFFER_OFFSET(0));
3305bd8deadSopenharmony_ci        ...
3315bd8deadSopenharmony_ci
3325bd8deadSopenharmony_ciIssues
3335bd8deadSopenharmony_ci
3345bd8deadSopenharmony_ci    1) What is QUERY_RESULT_NO_WAIT useful for?
3355bd8deadSopenharmony_ci
3365bd8deadSopenharmony_ci    RESOLVED: The application may decide that it does not want to wait for the
3375bd8deadSopenharmony_ci    result of the query object if it's not available at the time. This is not
3385bd8deadSopenharmony_ci    a problem without this extension as the application can always query the
3395bd8deadSopenharmony_ci    availability using QUERY_RESULT_AVAILABLE and decide to actually get the
3405bd8deadSopenharmony_ci    results using QUERY_RESULT only if the result is available. However, when
3415bd8deadSopenharmony_ci    using query buffers, QUERY_RESULT_AVAILABLE and QUERY_RESULT alone cannot
3425bd8deadSopenharmony_ci    provide the same flexibility for shader based decision making as the
3435bd8deadSopenharmony_ci    results are either always available (if QUERY_RESULT was used) or never.
3445bd8deadSopenharmony_ci    QUERY_RESULT_NO_WAIT provides a way to query the result only if it's
3455bd8deadSopenharmony_ci    available. Combined with QUERY_RESULT_AVAILABLE, the shader can decide
3465bd8deadSopenharmony_ci    to use the result or not based on the availability (see usage example 2).
3475bd8deadSopenharmony_ci
3485bd8deadSopenharmony_ci    2) Should QUERY_RESULT_NO_WAIT be accepted by GetQueryObject* in case
3495bd8deadSopenharmony_ci    there is no buffer bound to QUERY_BUFFER?
3505bd8deadSopenharmony_ci
3515bd8deadSopenharmony_ci    RESOLVED: YES, for completeness.
3525bd8deadSopenharmony_ci
3535bd8deadSopenharmony_ci    3) Is there any guarantee that GetQueryObject* will not wait for the
3545bd8deadSopenharmony_ci    query results to become available if <pname> is QUERY_RESULT_NO_WAIT?
3555bd8deadSopenharmony_ci
3565bd8deadSopenharmony_ci    RESOLVED: There is no need to have such guarantee. An implementation may
3575bd8deadSopenharmony_ci    choose to wait for the results even in case of QUERY_RESULT_NO_WAIT,
3585bd8deadSopenharmony_ci    however, that may incur a potential performance hit in case the
3595bd8deadSopenharmony_ci    application expects it to not wait.
3605bd8deadSopenharmony_ci
3615bd8deadSopenharmony_ci    4) Should the INVALID_OPERATION error be generated if a GetQueryObject*
3625bd8deadSopenharmony_ci    command would access data outside the range of the bound query buffer?
3635bd8deadSopenharmony_ci
3645bd8deadSopenharmony_ci    RESOLVED: YES. This requires considering the value of <params> and the
3655bd8deadSopenharmony_ci    size of the type of the written value to determine the maximum addressed
3665bd8deadSopenharmony_ci    byte for the state query command.
3675bd8deadSopenharmony_ci
3685bd8deadSopenharmony_ci    Note: This follows the precedence of the language introduced by
3695bd8deadSopenharmony_ci    ARB_pixel_buffer_object.
3705bd8deadSopenharmony_ci
3715bd8deadSopenharmony_ci    5) Should we support 64 bit versions of the state query commands
3725bd8deadSopenharmony_ci    (GetQueryObjecti64v and GetQueryObjectui64v)?
3735bd8deadSopenharmony_ci
3745bd8deadSopenharmony_ci    RESOLVED: YES, both for completeness and to support timer queries. In this
3755bd8deadSopenharmony_ci    case a 64 bit integer value is written to the buffer.
3765bd8deadSopenharmony_ci
3775bd8deadSopenharmony_ci    6) Should the extension support all query types supported by the current
3785bd8deadSopenharmony_ci    GL implementation?
3795bd8deadSopenharmony_ci
3805bd8deadSopenharmony_ci    RESOLVED: YES. There is not much value in providing additional capability
3815bd8deadSopenharmony_ci    queries that would allow the application to find out which query object
3825bd8deadSopenharmony_ci    types are supported. Also, the GL implementation can always choose to
3835bd8deadSopenharmony_ci    implement the functionality through a GPU-CPU rount-trip for query types
3845bd8deadSopenharmony_ci    that cannot be resolved to a buffer by the hardware.
3855bd8deadSopenharmony_ci
3865bd8deadSopenharmony_ci    7) Is there any precedence that the pointer parameter of a glGet* command
3875bd8deadSopenharmony_ci    is treated as an offset into a bound buffer object?
3885bd8deadSopenharmony_ci
3895bd8deadSopenharmony_ci    RESOLVED: YES, glGetTexImage accepts an offset into the pixel pack buffer
3905bd8deadSopenharmony_ci    in case a pixel pack buffer is bound. As pixel buffer objects are part of
3915bd8deadSopenharmony_ci    the core specification since version 2.1, no precedence is introduced by
3925bd8deadSopenharmony_ci    this extension.
3935bd8deadSopenharmony_ci
3945bd8deadSopenharmony_ci    8) What should be written to the query buffer when QUERY_RESULT_NO_WAIT
3955bd8deadSopenharmony_ci    is used but the results are not available?
3965bd8deadSopenharmony_ci
3975bd8deadSopenharmony_ci    DISCUSSION: Leaving the written value undefined is an option, however
3985bd8deadSopenharmony_ci    in many cases the application can benefit from having a defined value in
3995bd8deadSopenharmony_ci    the query buffer if the results are not available. The following options
4005bd8deadSopenharmony_ci    were considered to support such use cases:
4015bd8deadSopenharmony_ci
4025bd8deadSopenharmony_ci        a. Write a predefined fixed value to the buffer.
4035bd8deadSopenharmony_ci        b. Write a user specified value to the buffer.
4045bd8deadSopenharmony_ci        c. Don't write anything to the buffer.
4055bd8deadSopenharmony_ci
4065bd8deadSopenharmony_ci    The problem with option a. is that it may be difficult to select such
4075bd8deadSopenharmony_ci    a predefined value that would not potentially conflict with a valid
4085bd8deadSopenharmony_ci    value. Option b. could be fine, however it requires new API to specify
4095bd8deadSopenharmony_ci    this default value. Thus, option c. is considered to most preferable.
4105bd8deadSopenharmony_ci
4115bd8deadSopenharmony_ci    RESOLVED: Nothing, the current value in the specified offset of the
4125bd8deadSopenharmony_ci    query buffer is left untouched.
4135bd8deadSopenharmony_ci
4145bd8deadSopenharmony_ci    9) How does ARB_query_buffer_object differ from AMD_query_buffer_object?
4155bd8deadSopenharmony_ci
4165bd8deadSopenharmony_ci    RESOLVED: This extension introduced a new barrier bit accepted by
4175bd8deadSopenharmony_ci    MemoryBarrier that controls the relative ordering of shader buffer writes
4185bd8deadSopenharmony_ci    and query buffer writes.
4195bd8deadSopenharmony_ci
4205bd8deadSopenharmony_ciRevision History
4215bd8deadSopenharmony_ci
4225bd8deadSopenharmony_ci    Rev.    Date      Author    Changes
4235bd8deadSopenharmony_ci    ----  --------    --------  ----------------------------------------------
4245bd8deadSopenharmony_ci
4255bd8deadSopenharmony_ci      3   03/07/2016  drakos    Fixed typo in example #4
4265bd8deadSopenharmony_ci      2   04/02/2013  drakos    Added missing function names to the list of
4275bd8deadSopenharmony_ci                                functions accepting QUERY_BUFFER as parameter
4285bd8deadSopenharmony_ci      1   03/08/2013  drakos    Initial draft based on AMD_query_buffer_object
4295bd8deadSopenharmony_ci                                Removed suffixes
4305bd8deadSopenharmony_ci                                Updated spec language to GL 4.3
4315bd8deadSopenharmony_ci                                Added QUERY_BUFFER_BARRIER_BIT
432