| 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN" |
| 3 | "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd"> |
| 4 | <refentry id="glBeginQuery"> |
| 5 | <refmeta> |
| 6 | <refmetainfo> |
| 7 | <copyright> |
| 8 | <year>2005</year> |
| 9 | <holder>Sams Publishing</holder> |
| 10 | </copyright> |
| 11 | </refmetainfo> |
| 12 | <refentrytitle>glBeginQuery</refentrytitle> |
| 13 | <manvolnum>3G</manvolnum> |
| 14 | </refmeta> |
| 15 | <refnamediv> |
| 16 | <refname>glBeginQuery</refname> |
| 17 | <refpurpose>delimit the boundaries of a query object</refpurpose> |
| 18 | </refnamediv> |
| 19 | <refsynopsisdiv><title>C Specification</title> |
| 20 | <funcsynopsis> |
| 21 | <funcprototype> |
| 22 | <funcdef>void <function>glBeginQuery</function></funcdef> |
| 23 | <paramdef>GLenum <parameter>target</parameter></paramdef> |
| 24 | <paramdef>GLuint <parameter>id</parameter></paramdef> |
| 25 | </funcprototype> |
| 26 | </funcsynopsis> |
| 27 | </refsynopsisdiv> |
| 28 | <!-- eqn: ignoring delim $$ --> |
| 29 | <refsect1 id="parameters"><title>Parameters</title> |
| 30 | <variablelist> |
| 31 | <varlistentry> |
| 32 | <term><parameter>target</parameter></term> |
| 33 | <listitem> |
| 34 | <para> |
| 35 | Specifies the target type of query object established between |
| 36 | <function>glBeginQuery</function> and the subsequent <citerefentry><refentrytitle>glEndQuery</refentrytitle></citerefentry>. |
| 37 | The symbolic constant must be one of <constant>GL_SAMPLES_PASSED</constant>, <constant>GL_ANY_SAMPLES_PASSED</constant>, |
| 38 | <constant>GL_PRIMITIVES_GENERATED</constant>, <constant>GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN</constant>, or |
| 39 | <constant>GL_TIME_ELAPSED</constant>. |
| 40 | </para> |
| 41 | </listitem> |
| 42 | </varlistentry> |
| 43 | <varlistentry> |
| 44 | <term><parameter>id</parameter></term> |
| 45 | <listitem> |
| 46 | <para> |
| 47 | Specifies the name of a query object. |
| 48 | </para> |
| 49 | </listitem> |
| 50 | </varlistentry> |
| 51 | </variablelist> |
| 52 | </refsect1> |
| 53 | <refsynopsisdiv><title>C Specification</title> |
| 54 | <funcsynopsis> |
| 55 | <funcprototype> |
| 56 | <funcdef>void <function>glEndQuery</function></funcdef> |
| 57 | <paramdef>GLenum <parameter>target</parameter></paramdef> |
| 58 | </funcprototype> |
| 59 | </funcsynopsis> |
| 60 | </refsynopsisdiv> |
| 61 | <!-- eqn: ignoring delim $$ --> |
| 62 | <refsect1 id="parameters2"><title>Parameters</title> |
| 63 | <variablelist> |
| 64 | <varlistentry> |
| 65 | <term><parameter>target</parameter></term> |
| 66 | <listitem> |
| 67 | <para> |
| 68 | Specifies the target type of query object to be concluded. |
| 69 | The symbolic constant must be one of <constant>GL_SAMPLES_PASSED</constant>, <constant>GL_ANY_SAMPLES_PASSED</constant>, |
| 70 | <constant>GL_PRIMITIVES_GENERATED</constant>, <constant>GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN</constant>, or |
| 71 | <constant>GL_TIME_ELAPSED</constant>. |
| 72 | </para> |
| 73 | </listitem> |
| 74 | </varlistentry> |
| 75 | </variablelist> |
| 76 | </refsect1> |
| 77 | <refsect1 id="description"><title>Description</title> |
| 78 | <para> |
| 79 | <function>glBeginQuery</function> and <citerefentry><refentrytitle>glEndQuery</refentrytitle></citerefentry> delimit the |
| 80 | boundaries of a query object. <parameter>query</parameter> must be a name previously returned from a call to |
| 81 | <citerefentry><refentrytitle>glGenQueries</refentrytitle></citerefentry>. If a query object with name <parameter>id</parameter> |
| 82 | does not yet exist it is created with the type determined by <parameter>target</parameter>. <parameter>target</parameter> must |
| 83 | be one of <constant>GL_SAMPLES_PASSED</constant>, <constant>GL_ANY_SAMPLES_PASSED</constant>, <constant>GL_PRIMITIVES_GENERATED</constant>, |
| 84 | <constant>GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN</constant>, or <constant>GL_TIME_ELAPSED</constant>. The behavior of the query |
| 85 | object depends on its type and is as follows. |
| 86 | </para> |
| 87 | <para> |
| 88 | If <parameter>target</parameter> is <constant>GL_SAMPLES_PASSED</constant>, <parameter>id</parameter> must be an unused name, |
| 89 | or the name of an existing occlusion query object. |
| 90 | When <function>glBeginQuery</function> is executed, the query object's samples-passed counter is reset to 0. Subsequent |
| 91 | rendering will increment the counter for every sample that passes the depth test. If the value of <constant>GL_SAMPLE_BUFFERS</constant> |
| 92 | is 0, then the samples-passed count is incremented by 1 for each fragment. If the value of <constant>GL_SAMPLE_BUFFERS</constant> |
| 93 | is 1, then the samples-passed count is incremented by the number of samples whose coverage bit is set. However, implementations, at their |
| 94 | discression may instead increase the samples-passed count by the value of <constant>GL_SAMPLES</constant> if any sample in the fragment |
| 95 | is covered. When <function>glEndQuery</function> |
| 96 | is executed, the samples-passed counter is assigned to the query object's result value. This value can be queried by |
| 97 | calling <citerefentry><refentrytitle>glGetQueryObject</refentrytitle></citerefentry> with <parameter>pname</parameter> |
| 98 | <constant>GL_QUERY_RESULT</constant>. |
| 99 | </para> |
| 100 | <para> |
| 101 | If <parameter>target</parameter> is <constant>GL_ANY_SAMPLES_PASSED</constant>, <parameter>id</parameter> must be an unused name, |
| 102 | or the name of an existing boolean occlusion query object. |
| 103 | When <function>glBeginQuery</function> is executed, the query object's samples-passed flag is reset to <constant>GL_FALSE</constant>. |
| 104 | Subsequent rendering causes the flag to be set to <constant>GL_TRUE</constant> if any sample passes the depth test. When |
| 105 | <function>glEndQuery</function> is executed, the samples-passed flag is assigned to the query object's result value. This value can |
| 106 | be queried by calling <citerefentry><refentrytitle>glGetQueryObject</refentrytitle></citerefentry> with <parameter>pname</parameter> |
| 107 | <constant>GL_QUERY_RESULT</constant>. |
| 108 | </para> |
| 109 | <para> |
| 110 | If <parameter>target</parameter> is <constant>GL_PRIMITIVES_GENERATED</constant>, <parameter>id</parameter> must be an unused |
| 111 | name, or the name of an existing primitive query object previously bound to the <constant>GL_PRIMITIVES_GENERATED</constant> query binding. |
| 112 | When <function>glBeginQuery</function> is executed, the query object's primitives-generated counter is reset to 0. Subsequent |
| 113 | rendering will increment the counter once for every vertex that is emitted from the geometry shader, or from the vertex shader if |
| 114 | no geometry shader is present. When <function>glEndQuery</function> is executed, the primitives-generated counter is assigned to |
| 115 | the query object's result value. This value can be queried by calling <citerefentry><refentrytitle>glGetQueryObject</refentrytitle></citerefentry> with <parameter>pname</parameter> |
| 116 | <constant>GL_QUERY_RESULT</constant>. |
| 117 | </para> |
| 118 | <para> |
| 119 | If <parameter>target</parameter> is <constant>GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN</constant>, <parameter>id</parameter> must be |
| 120 | an unused name, or the name of an existing primitive query object previously bound to the <constant>GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN</constant> |
| 121 | query binding. When <function>glBeginQuery</function> is executed, the query object's primitives-written counter is reset to 0. Subsequent |
| 122 | rendering will increment the counter once for every vertex that is written into the bound transform feedback buffer(s). If transform feedback |
| 123 | mode is not activated between the call to <function>glBeginQuery</function> and <function>glEndQuery</function>, the counter will not be |
| 124 | incremented. When <function>glEndQuery</function> is executed, the primitives-written counter is assigned to |
| 125 | the query object's result value. This value can be queried by calling <citerefentry><refentrytitle>glGetQueryObject</refentrytitle></citerefentry> with <parameter>pname</parameter> |
| 126 | <constant>GL_QUERY_RESULT</constant>. |
| 127 | </para> |
| 128 | <para> |
| 129 | If <parameter>target</parameter> is <constant>GL_TIME_ELAPSED</constant>, <parameter>id</parameter> must be |
| 130 | an unused name, or the name of an existing timer query object previously bound to the <constant>GL_TIME_ELAPSED</constant> |
| 131 | query binding. When <function>glBeginQuery</function> is executed, the query object's time counter is reset to 0. When <function>glEndQuery</function> |
| 132 | is executed, the elapsed server time that has passed since the call to <function>glBeginQuery</function> is written into the query object's |
| 133 | time counter. This value can be queried by calling <citerefentry><refentrytitle>glGetQueryObject</refentrytitle></citerefentry> with <parameter>pname</parameter> |
| 134 | <constant>GL_QUERY_RESULT</constant>. |
| 135 | </para> |
| 136 | <para> |
| 137 | Querying the <constant>GL_QUERY_RESULT</constant> implicitly flushes the GL pipeline until the rendering delimited by the |
| 138 | query object has completed and the result is available. <constant>GL_QUERY_RESULT_AVAILABLE</constant> can be queried to |
| 139 | determine if the result is immediately available or if the rendering is not yet complete. |
| 140 | </para> |
| 141 | </refsect1> |
| 142 | <refsect1 id="notes"><title>Notes</title> |
| 143 | <para> |
| 144 | If the query target's count exceeds the maximum value representable in the number of available bits, as reported by |
| 145 | <citerefentry><refentrytitle>glGetQueryiv</refentrytitle></citerefentry> with <parameter>target</parameter> set to the |
| 146 | appropriate query target and <parameter>pname</parameter> |
| 147 | <constant>GL_QUERY_COUNTER_BITS</constant>, the count becomes undefined. |
| 148 | </para> |
| 149 | <para> |
| 150 | An implementation may support 0 bits in its counter, in which case query results are always undefined |
| 151 | and essentially useless. |
| 152 | </para> |
| 153 | <para> |
| 154 | When <constant>GL_SAMPLE_BUFFERS</constant> is 0, the samples-passed counter of an occlusion query will increment once for each |
| 155 | fragment that passes the depth test. When <constant>GL_SAMPLE_BUFFERS</constant> is 1, an implementation may either increment |
| 156 | the samples-passed counter individually for each sample of a fragment that passes the depth test, or it may choose to increment |
| 157 | the counter for all samples of a fragment if any one of them passes the depth test. |
| 158 | </para> |
| 159 | <para> |
| 160 | The query targets <constant>GL_ANY_SAMPLES_PASSED</constant>, and <constant>GL_TIME_ELAPSED</constant> are availale only if |
| 161 | the GL version is 3.3 or higher. |
| 162 | </para> |
| 163 | </refsect1> |
| 164 | <refsect1 id="errors"><title>Errors</title> |
| 165 | <para> |
| 166 | <constant>GL_INVALID_ENUM</constant> is generated if <parameter>target</parameter> is not one of the accepted tokens. |
| 167 | </para> |
| 168 | <para> |
| 169 | <constant>GL_INVALID_OPERATION</constant> is generated if <function>glBeginQuery</function> is executed while |
| 170 | a query object of the same <parameter>target</parameter> is already active. |
| 171 | </para> |
| 172 | <para> |
| 173 | <constant>GL_INVALID_OPERATION</constant> is generated if <citerefentry><refentrytitle>glEndQuery</refentrytitle></citerefentry> |
| 174 | is executed when a query object of the same <parameter>target</parameter> is not active. |
| 175 | </para> |
| 176 | <para> |
| 177 | <constant>GL_INVALID_OPERATION</constant> is generated if <parameter>id</parameter> is 0. |
| 178 | </para> |
| 179 | <para> |
| 180 | <constant>GL_INVALID_OPERATION</constant> is generated if <parameter>id</parameter> is the name of an already active query object. |
| 181 | </para> |
| 182 | <para> |
| 183 | <constant>GL_INVALID_OPERATION</constant> is generated if <parameter>id</parameter> refers to an existing query object whose type |
| 184 | does not does not match <parameter>target</parameter>. |
| 185 | </para> |
| 186 | </refsect1> |
| 187 | <refsect1 id="seealso"><title>See Also</title> |
| 188 | <para> |
| 189 | <citerefentry><refentrytitle>glDeleteQueries</refentrytitle></citerefentry>, |
| 190 | <citerefentry><refentrytitle>glGenQueries</refentrytitle></citerefentry>, |
| 191 | <citerefentry><refentrytitle>glGetQueryiv</refentrytitle></citerefentry>, |
| 192 | <citerefentry><refentrytitle>glGetQueryObject</refentrytitle></citerefentry>, |
| 193 | <citerefentry><refentrytitle>glIsQuery</refentrytitle></citerefentry> |
| 194 | </para> |
| 195 | </refsect1> |
| 196 | <refsect1 id="Copyright"><title>Copyright</title> |
| 197 | <para> |
| 198 | Copyright <trademark class="copyright"></trademark> 2005 Addison-Wesley. |
| 199 | This material may be distributed subject to the terms and conditions set forth in |
| 200 | the Open Publication License, v 1.0, 8 June 1999. |
| 201 | <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>. |
| 202 | </para> |
| 203 | </refsect1> |
| 204 | </refentry> |