Debian Codegraph @

api_webgl/extensions/EXT_disjoint_timer_query_webgl2/extension.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2 <extension href="EXT_disjoint_timer_query_webgl2/">
3 <name>EXT_disjoint_timer_query_webgl2</name>
4
5 <contact> <a href="https://www.khronos.org/webgl/public-mailing-list/">WebGL
6 working group</a> (public_webgl 'at' khronos.org) </contact>
7
8 <contributors>
9 <contributor>Contributors to ARB_occlusion_query</contributor>
10 <contributor>Contributors to EXT_timer_query</contributor>
11 <contributor>Contributors to ARB_timer_query</contributor>
12 <contributor>Ben Vanik, Google Inc.</contributor>
13 <contributor>Daniel Koch, TransGaming Inc.</contributor>
14 <contributor>Florian Boesch (pyalot 'at' gmail.com)</contributor>
15 <contributor>Members of the WebGL working group</contributor>
16 </contributors>
17
18 <number>33</number>
19
20 <depends>
21 <api version="2.0"/>
22 </depends>
23
24 <overview>
25 <mirrors href="http://www.khronos.org/registry/gles/extensions/EXT/EXT_disjoint_timer_query.txt"
26 name="EXT_disjoint_timer_query">
27 <addendum>
28 Specifies that queries' results only become available at certain well-defined times.
29 </addendum>
30 </mirrors>
31
32 <features>
33 <feature>
34 This extension provides the same functionality as <a
35 href="../EXT_disjoint_timer_query/">EXT_disjoint_timer_query</a>. The IDL, description, and
36 extension name are specialized for WebGL 2.0, which incorporates query objects into the core
37 specification.
38 </feature>
39 </features>
40 </overview>
41
42 <idl xml:space="preserve">
43 typedef unsigned long long GLuint64EXT;
44
45 [NoInterfaceObject]
46 interface EXT_disjoint_timer_query_webgl2 {
47 const GLenum QUERY_COUNTER_BITS_EXT = 0x8864;
48 const GLenum TIME_ELAPSED_EXT = 0x88BF;
49 const GLenum TIMESTAMP_EXT = 0x8E28;
50 const GLenum GPU_DISJOINT_EXT = 0x8FBB;
51
52 void queryCounterEXT(WebGLQuery query, GLenum target);
53 };
54 </idl>
55
56 <newtok>
57 <function name="beginQuery" type="">
58 <param name="target" type="GLenum"/>
59 <param name="query" type="WebGLQuery?"/>
60 <code>target</code> accepts <code>TIME_ELAPSED_EXT</code>.
61 </function>
62 </newtok>
63
64 <newtok>
65 <function name="endQuery" type="void">
66 <param name="target" type="GLenum"/>
67 <code>target</code> accepts <code>TIME_ELAPSED_EXT</code>.
68 </function>
69 </newtok>
70
71 <newfun>
72 <function name="queryCounterEXT" type="void">
73 <param name="query" type="WebGLQuery"/>
74 <param name="target" type="GLenum"/>
75 <code>target</code> accepts <code>TIMESTAMP_EXT</code>.
76 </function>
77 </newfun>
78
79 <newtok>
80 <function name="getQuery" type="any">
81 <param name="target" type="GLenum"/>
82 <param name="pname" type="GLenum"/>
83 <code>target</code> and <code>pname</code> accept the following combinations of
84 parameters. The return type of this method now depends on the parameter queried.
85 <br/>
86 <table width="30%">
87 <tr><th>target</th><th>pname</th><th>returned type</th></tr>
88 <tr><td>TIME_ELAPSED_EXT</td><td>CURRENT_QUERY</td><td>WebGLQuery?</td></tr>
89 <tr><td>TIMESTAMP_EXT</td><td>CURRENT_QUERY</td><td>null</td></tr>
90 <tr><td>TIME_ELAPSED_EXT</td><td>QUERY_COUNTER_BITS_EXT</td><td>GLint</td></tr>
91 <tr><td>TIMESTAMP_EXT</td><td>QUERY_COUNTER_BITS_EXT</td><td>GLint</td></tr>
92 </table>
93 </function>
94 </newtok>
95
96 <newtok>
97 <function name="getParameter" type="any">
98 <param name="pname" type="GLenum"/>
99 <code>pname</code> accepts <code>TIMESTAMP_EXT</code> or <code>GPU_DISJOINT_EXT</code>.
100 <br/>
101
102 The return type depends on the parameter queried:
103 <table width="30%">
104 <tr><th>pname</th><th>returned type</th></tr>
105 <tr><td>TIMESTAMP_EXT</td><td>GLuint64EXT</td></tr>
106 <tr><td>GPU_DISJOINT_EXT</td><td>boolean</td></tr>
107 </table>
108 </function>
109 </newtok>
110
111 <samplecode xml:space="preserve">
112 <pre>
113 // Example (1) -- uses beginQuery/endQuery.
114 var ext = gl.getExtension('EXT_disjoint_timer_query_webgl2');
115 var query = gl.createQuery();
116 gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
117
118 // Draw object
119 gl.drawElements(...);
120
121 gl.endQuery(ext.TIME_ELAPSED_EXT);
122
123 // ...at some point in the future, after returning control to the browser and being called again:
124 var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
125 var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
126
127 if (available &amp;&amp; !disjoint) {
128 // See how much time the rendering of the object took in nanoseconds.
129 var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT);
130
131 // Do something useful with the time. Note that care should be
132 // taken to use all significant bits of the result, not just the
133 // least significant 32 bits.
134 adjustObjectLODBasedOnDrawTime(timeElapsed);
135 }
136
137 //----------------------------------------------------------------------
138
139 // Example (2) -- same as the example above, but uses queryCounterEXT instead.
140 var ext = gl.getExtension('EXT_disjoint_timer_query_webgl2');
141 var startQuery = gl.createQuery();
142 var endQuery = gl.createQuery();
143 ext.queryCounterEXT(startQuery, ext.TIMESTAMP_EXT);
144
145 // Draw object
146 gl.drawElements(...);
147
148 ext.queryCounterEXT(endQuery, ext.TIMESTAMP_EXT);
149
150 // ...at some point in the future, after returning control to the browser and being called again:
151 var available = gl.getQueryParameter(endQuery, gl.QUERY_RESULT_AVAILABLE);
152 var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
153
154 if (available &amp;&amp; !disjoint) {
155 // See how much time the rendering of the object took in nanoseconds.
156 var timeStart = gl.getQueryParameter(startQuery, gl.QUERY_RESULT);
157 var timeEnd = gl.getQueryParameter(endQuery, gl.QUERY_RESULT);
158
159 // Do something useful with the time. Note that care should be
160 // taken to use all significant bits of the result, not just the
161 // least significant 32 bits.
162 adjustObjectLODBasedOnDrawTime(timeEnd - timeStart);
163 }
164
165 //----------------------------------------------------------------------
166
167 // Example (3) -- check the number of timestamp bits to determine how to best
168 // measure elapsed time.
169 var ext = gl.getExtension('EXT_disjoint_timer_query_webgl2');
170 var timeElapsedQuery;
171 var startQuery;
172 var endQuery;
173
174 var useTimestamps = false;
175
176 if (gl.getQuery(ext.TIMESTAMP_EXT, ext.QUERY_COUNTER_BITS_EXT) > 0) {
177 useTimestamps = true;
178 }
179
180 // Clear the disjoint state before starting to work with queries to increase
181 // the chances that the results will be valid.
182 gl.getParameter(ext.GPU_DISJOINT_EXT);
183
184 if (useTimestamps) {
185 startQuery = gl.createQuery();
186 endQuery = gl.createQuery();
187 ext.queryCounterEXT(startQuery, ext.TIMESTAMP_EXT);
188 } else {
189 timeElapsedQuery = gl.createQuery();
190 gl.beginQuery(ext.TIME_ELAPSED_EXT, timeElapsedQuery);
191 }
192
193 // Draw object
194 gl.drawElements(...);
195
196 if (useTimestamps) {
197 ext.queryCounterEXT(endQuery, ext.TIMESTAMP_EXT);
198 } else {
199 gl.endQuery(ext.TIME_ELAPSED_EXT);
200 }
201
202 // ...at some point in the future, after returning control to the browser and being called again:
203 var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
204 if (disjoint) {
205 // Have to redo all of the measurements.
206 } else {
207 var available;
208 if (useTimestamps) {
209 available = gl.getQueryParameter(endQuery, gl.QUERY_RESULT_AVAILABLE);
210 } else {
211 available = gl.getQueryParameter(timeElapsedQuery, gl.QUERY_RESULT_AVAILABLE);
212 }
213
214 if (available) {
215 var timeElapsed;
216 if (useTimestamps) {
217 // See how much time the rendering of the object took in nanoseconds.
218 var timeStart = gl.getQueryParameter(startQuery, gl.QUERY_RESULT);
219 var timeEnd = gl.getQueryParameter(endQuery, gl.QUERY_RESULT);
220 timeElapsed = timeEnd - timeStart;
221 } else {
222 timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT);
223 }
224
225 // Do something useful with the time. Note that care should be
226 // taken to use all significant bits of the result, not just the
227 // least significant 32 bits.
228 adjustObjectLODBasedOnDrawTime(timeElapsed);
229 }
230 }
231 </pre>
232 </samplecode>
233
234 <history>
235 <revision date="2016/09/30">
236 <change>Split WebGL 2.0 specification of this extension into its own file
237 for better comprehensibility.</change>
238 </revision>
239 <revision date="2016/10/11">
240 <change>Fixed errors in sample code pointed out by @juj.</change>
241 </revision>
242 </history>
243 </extension>