blob: bb88288060f09d968a9303808d92894e17aeef61 [file] [log] [blame]
José Fonseca7e329022010-11-19 17:05:18 +00001##########################################################################
2#
3# Copyright 2010 VMware, Inc.
4# All Rights Reserved.
5#
6# Permission is hereby granted, free of charge, to any person obtaining a copy
7# of this software and associated documentation files (the "Software"), to deal
8# in the Software without restriction, including without limitation the rights
9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10# copies of the Software, and to permit persons to whom the Software is
11# furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice shall be included in
14# all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22# THE SOFTWARE.
23#
24##########################################################################/
25
26
José Fonseca4a826ed2010-11-30 16:58:22 +000027"""GL retracer generator."""
28
29
José Fonsecabd86a222011-09-27 09:21:38 +010030import specs.stdapi as stdapi
31import specs.glapi as glapi
Chia-I Wua8b5b442011-11-07 14:10:46 -070032import specs.glesapi as glesapi
José Fonsecadacd8dd2010-11-25 17:50:26 +000033from retrace import Retracer
José Fonseca7e329022010-11-19 17:05:18 +000034
35
José Fonsecadacd8dd2010-11-25 17:50:26 +000036class GlRetracer(Retracer):
José Fonsecac9edb832010-11-20 09:03:10 +000037
José Fonseca2741ed82011-10-07 23:36:39 +010038 table_name = 'glretrace::gl_callbacks'
39
José Fonseca54f304a2012-01-14 19:33:08 +000040 def retraceFunction(self, function):
41 Retracer.retraceFunction(self, function)
José Fonseca3d245f42010-11-28 00:08:23 +000042
José Fonseca62212972011-03-23 13:22:55 +000043 array_pointer_function_names = set((
44 "glVertexPointer",
45 "glNormalPointer",
46 "glColorPointer",
47 "glIndexPointer",
48 "glTexCoordPointer",
49 "glEdgeFlagPointer",
50 "glFogCoordPointer",
51 "glSecondaryColorPointer",
52
53 "glInterleavedArrays",
54
José Fonsecaac5285b2011-05-04 11:09:08 +010055 "glVertexPointerEXT",
56 "glNormalPointerEXT",
57 "glColorPointerEXT",
58 "glIndexPointerEXT",
59 "glTexCoordPointerEXT",
60 "glEdgeFlagPointerEXT",
61 "glFogCoordPointerEXT",
62 "glSecondaryColorPointerEXT",
José Fonseca62212972011-03-23 13:22:55 +000063
José Fonseca7f5163e2011-03-31 23:37:26 +010064 "glVertexAttribPointer",
65 "glVertexAttribPointerARB",
66 "glVertexAttribPointerNV",
José Fonsecaac5285b2011-05-04 11:09:08 +010067 "glVertexAttribIPointer",
68 "glVertexAttribIPointerEXT",
José Fonseca7f5163e2011-03-31 23:37:26 +010069 "glVertexAttribLPointer",
70 "glVertexAttribLPointerEXT",
José Fonseca62212972011-03-23 13:22:55 +000071
72 #"glMatrixIndexPointerARB",
73 ))
74
José Fonseca8caf2c82010-11-30 12:09:12 +000075 draw_array_function_names = set([
76 "glDrawArrays",
77 "glDrawArraysEXT",
78 "glDrawArraysIndirect",
79 "glDrawArraysInstanced",
80 "glDrawArraysInstancedARB",
81 "glDrawArraysInstancedEXT",
José Fonsecaff8848b2011-10-09 01:04:17 +010082 "glDrawArraysInstancedBaseInstance",
José Fonseca8caf2c82010-11-30 12:09:12 +000083 "glDrawMeshArraysSUN",
84 "glMultiDrawArrays",
85 "glMultiDrawArraysEXT",
86 "glMultiModeDrawArraysIBM",
87 ])
88
89 draw_elements_function_names = set([
90 "glDrawElements",
91 "glDrawElementsBaseVertex",
92 "glDrawElementsIndirect",
93 "glDrawElementsInstanced",
94 "glDrawElementsInstancedARB",
José Fonseca8caf2c82010-11-30 12:09:12 +000095 "glDrawElementsInstancedEXT",
José Fonsecaff8848b2011-10-09 01:04:17 +010096 "glDrawElementsInstancedBaseVertex",
97 "glDrawElementsInstancedBaseInstance",
98 "glDrawElementsInstancedBaseVertexBaseInstance",
José Fonseca8caf2c82010-11-30 12:09:12 +000099 "glDrawRangeElements",
José Fonseca8caf2c82010-11-30 12:09:12 +0000100 "glDrawRangeElementsEXT",
José Fonsecaff8848b2011-10-09 01:04:17 +0100101 "glDrawRangeElementsBaseVertex",
José Fonsecafd34e4e2011-06-03 19:34:29 +0100102 "glMultiDrawElements",
103 "glMultiDrawElementsBaseVertex",
104 "glMultiDrawElementsEXT",
105 "glMultiModeDrawElementsIBM",
José Fonseca8caf2c82010-11-30 12:09:12 +0000106 ])
107
José Fonseca9b126ea2011-09-15 08:15:33 +0100108 draw_indirect_function_names = set([
109 "glDrawArraysIndirect",
110 "glDrawElementsIndirect",
111 ])
112
José Fonseca920bffd2011-06-02 10:04:52 +0100113 misc_draw_function_names = set([
José Fonsecaca925d12012-03-21 06:46:46 +0000114 "glCallList",
115 "glCallLists",
José Fonseca920bffd2011-06-02 10:04:52 +0100116 "glClear",
117 "glEnd",
José Fonsecaf8a99a02011-06-07 20:49:56 +0100118 "glDrawPixels",
119 "glBlitFramebuffer",
120 "glBlitFramebufferEXT",
José Fonseca920bffd2011-06-02 10:04:52 +0100121 ])
122
123 bind_framebuffer_function_names = set([
124 "glBindFramebuffer",
José Fonseca920bffd2011-06-02 10:04:52 +0100125 "glBindFramebufferEXT",
José Fonsecac98ca8d2012-01-19 10:48:09 +0000126 "glBindFramebufferOES",
José Fonseca920bffd2011-06-02 10:04:52 +0100127 ])
128
José Fonsecac29f4f12011-06-11 12:19:05 +0100129 # Names of the functions that can pack into the current pixel buffer
130 # object. See also the ARB_pixel_buffer_object specification.
131 pack_function_names = set([
132 'glGetCompressedTexImage',
133 'glGetConvolutionFilter',
134 'glGetHistogram',
135 'glGetMinmax',
136 'glGetPixelMapfv',
137 'glGetPixelMapuiv',
138 'glGetPixelMapusv',
139 'glGetPolygonStipple',
José Fonseca880d7972011-10-09 09:44:03 +0100140 'glGetSeparableFilter',
José Fonsecac29f4f12011-06-11 12:19:05 +0100141 'glGetTexImage',
142 'glReadPixels',
143 'glGetnCompressedTexImageARB',
144 'glGetnConvolutionFilterARB',
145 'glGetnHistogramARB',
146 'glGetnMinmaxARB',
147 'glGetnPixelMapfvARB',
148 'glGetnPixelMapuivARB',
149 'glGetnPixelMapusvARB',
150 'glGetnPolygonStippleARB',
151 'glGetnSeparableFilterARB',
152 'glGetnTexImageARB',
153 'glReadnPixelsARB',
154 ])
155
José Fonseca46a48392011-10-14 11:34:27 +0100156 map_function_names = set([
157 'glMapBuffer',
158 'glMapBufferARB',
José Fonseca8ee21822012-01-15 13:30:43 +0000159 'glMapBufferOES',
José Fonseca46a48392011-10-14 11:34:27 +0100160 'glMapBufferRange',
161 'glMapNamedBufferEXT',
162 'glMapNamedBufferRangeEXT'
163 ])
164
165 unmap_function_names = set([
166 'glUnmapBuffer',
167 'glUnmapBufferARB',
José Fonseca8ee21822012-01-15 13:30:43 +0000168 'glUnmapBufferOES',
José Fonseca46a48392011-10-14 11:34:27 +0100169 'glUnmapNamedBufferEXT',
170 ])
171
José Fonseca54f304a2012-01-14 19:33:08 +0000172 def retraceFunctionBody(self, function):
José Fonseca62212972011-03-23 13:22:55 +0000173 is_array_pointer = function.name in self.array_pointer_function_names
174 is_draw_array = function.name in self.draw_array_function_names
175 is_draw_elements = function.name in self.draw_elements_function_names
José Fonseca920bffd2011-06-02 10:04:52 +0100176 is_misc_draw = function.name in self.misc_draw_function_names
José Fonseca62212972011-03-23 13:22:55 +0000177
178 if is_array_pointer or is_draw_array or is_draw_elements:
José Fonseca6117e312011-04-15 23:52:58 +0100179 print ' if (glretrace::parser.version < 1) {'
José Fonseca62212972011-03-23 13:22:55 +0000180
181 if is_array_pointer or is_draw_array:
182 print ' GLint __array_buffer = 0;'
183 print ' glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);'
184 print ' if (!__array_buffer) {'
José Fonseca54f304a2012-01-14 19:33:08 +0000185 self.failFunction(function)
José Fonseca62212972011-03-23 13:22:55 +0000186 print ' }'
187
188 if is_draw_elements:
189 print ' GLint __element_array_buffer = 0;'
190 print ' glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &__element_array_buffer);'
191 print ' if (!__element_array_buffer) {'
José Fonseca54f304a2012-01-14 19:33:08 +0000192 self.failFunction(function)
José Fonseca62212972011-03-23 13:22:55 +0000193 print ' }'
194
195 print ' }'
196
José Fonsecac29f4f12011-06-11 12:19:05 +0100197 # When no pack buffer object is bound, the pack functions are no-ops.
198 if function.name in self.pack_function_names:
199 print ' GLint __pack_buffer = 0;'
200 print ' glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &__pack_buffer);'
201 print ' if (!__pack_buffer) {'
202 print ' return;'
203 print ' }'
204
José Fonseca920bffd2011-06-02 10:04:52 +0100205 # Pre-snapshots
206 if function.name in self.bind_framebuffer_function_names:
José Fonsecaa96b7252012-01-19 10:48:38 +0000207 print ' assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);'
José Fonseca439ae3c2011-09-01 17:36:10 +0100208 if function.name == 'glFrameTerminatorGREMEDY':
José Fonseca4c865742011-10-25 09:56:15 +0100209 print ' glretrace::frame_complete(call);'
José Fonseca439ae3c2011-09-01 17:36:10 +0100210 return
José Fonseca920bffd2011-06-02 10:04:52 +0100211
José Fonseca54f304a2012-01-14 19:33:08 +0000212 Retracer.retraceFunctionBody(self, function)
José Fonseca62212972011-03-23 13:22:55 +0000213
José Fonseca920bffd2011-06-02 10:04:52 +0100214 # Post-snapshots
José Fonseca4d7f1fe2011-05-09 20:54:31 +0100215 if function.name in ('glFlush', 'glFinish'):
216 print ' if (!glretrace::double_buffer) {'
José Fonseca4c865742011-10-25 09:56:15 +0100217 print ' glretrace::frame_complete(call);'
José Fonseca4d7f1fe2011-05-09 20:54:31 +0100218 print ' }'
José Fonseca920bffd2011-06-02 10:04:52 +0100219 if is_draw_array or is_draw_elements or is_misc_draw:
José Fonsecaa96b7252012-01-19 10:48:38 +0000220 print ' assert(call.flags & trace::CALL_FLAG_RENDER);'
José Fonseca920bffd2011-06-02 10:04:52 +0100221
José Fonseca4d7f1fe2011-05-09 20:54:31 +0100222
José Fonseca54f304a2012-01-14 19:33:08 +0000223 def invokeFunction(self, function):
José Fonseca757b2b62011-09-19 10:09:53 +0100224 # Infer the drawable size from GL calls
José Fonsecacdb574a2010-11-29 12:23:35 +0000225 if function.name == "glViewport":
José Fonseca757b2b62011-09-19 10:09:53 +0100226 print ' glretrace::updateDrawable(x + width, y + height);'
José Fonsecaea82c3f2012-03-29 08:19:19 +0100227 if function.name == "glViewportArray":
228 # We are concerned about drawables so only care for the first viewport
229 print ' if (first == 0 && count > 0) {'
230 print ' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];'
231 print ' glretrace::updateDrawable(x + w, y + h);'
232 print ' }'
233 if function.name == "glViewportIndexedf":
234 print ' if (index == 0) {'
235 print ' glretrace::updateDrawable(x + w, y + h);'
236 print ' }'
237 if function.name == "glViewportIndexedfv":
238 print ' if (index == 0) {'
239 print ' GLfloat x = v[0], y = v[1], w = v[2], h = v[3];'
240 print ' glretrace::updateDrawable(x + w, y + h);'
241 print ' }'
José Fonseca757b2b62011-09-19 10:09:53 +0100242 if function.name in ('glBlitFramebuffer', 'glBlitFramebufferEXT'):
243 # Some applications do all their rendering in a framebuffer, and
244 # then just blit to the drawable without ever calling glViewport.
245 print ' glretrace::updateDrawable(std::max(dstX0, dstX1), std::max(dstY0, dstY1));'
José Fonsecacdb574a2010-11-29 12:23:35 +0000246
José Fonseca3d245f42010-11-28 00:08:23 +0000247 if function.name == "glEnd":
José Fonseca32871ed2011-04-10 13:40:52 +0100248 print ' glretrace::insideGlBeginEnd = false;'
José Fonsecafea81f92011-05-23 21:20:53 +0100249
José Fonsecaae9c4c12012-02-02 13:59:31 +0000250 if function.name.startswith('gl') and not function.name.startswith('glX'):
251 print r' if (!glretrace::context && !glretrace::benchmark && !retrace::profiling) {'
252 print r' retrace::warning(call) << "no current context\n";'
253 print r' }'
254
José Fonsecafea81f92011-05-23 21:20:53 +0100255 if function.name == 'memcpy':
256 print ' if (!dest || !src || !n) return;'
José Fonseca694dc0b2012-03-01 15:44:07 +0000257
258 # Destroy the buffer mapping
259 if function.name in self.unmap_function_names:
260 print r' GLvoid *ptr = NULL;'
261 if function.name == 'glUnmapBuffer':
262 print r' glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);'
263 elif function.name == 'glUnmapBufferARB':
264 print r' glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);'
265 elif function.name == 'glUnmapBufferOES':
266 print r' glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);'
267 elif function.name == 'glUnmapNamedBufferEXT':
268 print r' glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);'
269 else:
270 assert False
271 print r' if (ptr) {'
272 print r' retrace::delRegionByPointer(ptr);'
273 print r' } else {'
274 print r' retrace::warning(call) << "no current context\n";'
275 print r' }'
José Fonsecacdb574a2010-11-29 12:23:35 +0000276
José Fonseca54f304a2012-01-14 19:33:08 +0000277 Retracer.invokeFunction(self, function)
José Fonsecacdb574a2010-11-29 12:23:35 +0000278
José Fonsecaecf37412011-05-21 01:56:08 +0100279 # Error checking
José Fonseca3d245f42010-11-28 00:08:23 +0000280 if function.name == "glBegin":
José Fonseca32871ed2011-04-10 13:40:52 +0100281 print ' glretrace::insideGlBeginEnd = true;'
José Fonsecab8c56072011-05-05 01:13:04 +0100282 elif function.name.startswith('gl'):
José Fonseca3d245f42010-11-28 00:08:23 +0000283 # glGetError is not allowed inside glBegin/glEnd
Ryan C. Gordon2dad4b42012-01-08 01:32:41 -0500284 print ' if (!glretrace::benchmark && !retrace::profiling && !glretrace::insideGlBeginEnd) {'
José Fonsecaecf37412011-05-21 01:56:08 +0100285 print ' glretrace::checkGlError(call);'
286 if function.name in ('glProgramStringARB', 'glProgramStringNV'):
287 print r' GLint error_position = -1;'
288 print r' glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_position);'
289 print r' if (error_position != -1) {'
290 print r' const char *error_string = (const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB);'
José Fonsecab1bb3c22011-10-08 20:23:18 +0100291 print r' retrace::warning(call) << error_string << "\n";'
José Fonsecaecf37412011-05-21 01:56:08 +0100292 print r' }'
293 if function.name == 'glCompileShader':
294 print r' GLint compile_status = 0;'
295 print r' glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);'
296 print r' if (!compile_status) {'
297 print r' GLint info_log_length = 0;'
298 print r' glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);'
299 print r' GLchar *infoLog = new GLchar[info_log_length];'
300 print r' glGetShaderInfoLog(shader, info_log_length, NULL, infoLog);'
José Fonsecab1bb3c22011-10-08 20:23:18 +0100301 print r' retrace::warning(call) << infoLog << "\n";'
José Fonsecaecf37412011-05-21 01:56:08 +0100302 print r' delete [] infoLog;'
303 print r' }'
304 if function.name == 'glLinkProgram':
305 print r' GLint link_status = 0;'
306 print r' glGetProgramiv(program, GL_LINK_STATUS, &link_status);'
307 print r' if (!link_status) {'
308 print r' GLint info_log_length = 0;'
309 print r' glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);'
310 print r' GLchar *infoLog = new GLchar[info_log_length];'
311 print r' glGetProgramInfoLog(program, info_log_length, NULL, infoLog);'
José Fonsecab1bb3c22011-10-08 20:23:18 +0100312 print r' retrace::warning(call) << infoLog << "\n";'
José Fonsecaecf37412011-05-21 01:56:08 +0100313 print r' delete [] infoLog;'
314 print r' }'
315 if function.name == 'glCompileShaderARB':
316 print r' GLint compile_status = 0;'
317 print r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_COMPILE_STATUS_ARB, &compile_status);'
318 print r' if (!compile_status) {'
319 print r' GLint info_log_length = 0;'
320 print r' glGetObjectParameterivARB(shaderObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);'
321 print r' GLchar *infoLog = new GLchar[info_log_length];'
322 print r' glGetInfoLogARB(shaderObj, info_log_length, NULL, infoLog);'
José Fonsecab1bb3c22011-10-08 20:23:18 +0100323 print r' retrace::warning(call) << infoLog << "\n";'
José Fonsecaecf37412011-05-21 01:56:08 +0100324 print r' delete [] infoLog;'
325 print r' }'
326 if function.name == 'glLinkProgramARB':
327 print r' GLint link_status = 0;'
328 print r' glGetObjectParameterivARB(programObj, GL_OBJECT_LINK_STATUS_ARB, &link_status);'
329 print r' if (!link_status) {'
330 print r' GLint info_log_length = 0;'
331 print r' glGetObjectParameterivARB(programObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);'
332 print r' GLchar *infoLog = new GLchar[info_log_length];'
333 print r' glGetInfoLogARB(programObj, info_log_length, NULL, infoLog);'
José Fonsecab1bb3c22011-10-08 20:23:18 +0100334 print r' retrace::warning(call) << infoLog << "\n";'
José Fonsecaecf37412011-05-21 01:56:08 +0100335 print r' delete [] infoLog;'
336 print r' }'
José Fonseca46a48392011-10-14 11:34:27 +0100337 if function.name in self.map_function_names:
José Fonsecafea81f92011-05-23 21:20:53 +0100338 print r' if (!__result) {'
José Fonsecab1bb3c22011-10-08 20:23:18 +0100339 print r' retrace::warning(call) << "failed to map buffer\n";'
José Fonsecafea81f92011-05-23 21:20:53 +0100340 print r' }'
José Fonseca96a57e72012-03-01 15:44:28 +0000341 if function.name in self.unmap_function_names:
342 print r' if (!__result) {'
343 print r' retrace::warning(call) << "failed to unmap buffer\n";'
344 print r' }'
José Fonseca91492d22011-05-23 21:20:31 +0100345 if function.name in ('glGetAttribLocation', 'glGetAttribLocationARB'):
346 print r' GLint __orig_result = call.ret->toSInt();'
347 print r' if (__result != __orig_result) {'
José Fonsecab1bb3c22011-10-08 20:23:18 +0100348 print r' retrace::warning(call) << "vertex attrib location mismatch " << __orig_result << " -> " << __result << "\n";'
José Fonseca91492d22011-05-23 21:20:31 +0100349 print r' }'
José Fonsecad5377812011-06-07 20:48:55 +0100350 if function.name in ('glCheckFramebufferStatus', 'glCheckFramebufferStatusEXT', 'glCheckNamedFramebufferStatusEXT'):
351 print r' GLint __orig_result = call.ret->toSInt();'
352 print r' if (__orig_result == GL_FRAMEBUFFER_COMPLETE &&'
353 print r' __result != GL_FRAMEBUFFER_COMPLETE) {'
José Fonsecab1bb3c22011-10-08 20:23:18 +0100354 print r' retrace::warning(call) << "incomplete framebuffer (" << glstate::enumToString(__result) << ")\n";'
José Fonsecad5377812011-06-07 20:48:55 +0100355 print r' }'
José Fonsecaecf37412011-05-21 01:56:08 +0100356 print ' }'
José Fonsecae4999b92011-05-05 00:31:01 +0100357
José Fonseca561266b2012-03-21 06:49:41 +0000358 # Query the buffer length for whole buffer mappings
359 if function.name in self.map_function_names:
360 if 'length' in function.argNames():
361 assert 'BufferRange' in function.name
362 else:
363 assert 'BufferRange' not in function.name
364 print r' GLint length = 0;'
365 if function.name in ('glMapBuffer', 'glMapBufferOES'):
366 print r' glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);'
367 elif function.name == 'glMapBufferARB':
368 print r' glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);'
369 elif function.name == 'glMapNamedBufferEXT':
370 print r' glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);'
José Fonseca59ee88e2012-01-15 14:24:10 +0000371 else:
José Fonseca561266b2012-03-21 06:49:41 +0000372 assert False
José Fonseca46a48392011-10-14 11:34:27 +0100373
José Fonseca54f304a2012-01-14 19:33:08 +0000374 def extractArg(self, function, arg, arg_type, lvalue, rvalue):
José Fonseca7f5163e2011-03-31 23:37:26 +0100375 if function.name in self.array_pointer_function_names and arg.name == 'pointer':
José Fonseca46a48392011-10-14 11:34:27 +0100376 print ' %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue)
José Fonseca14c21bc2011-02-20 23:32:22 +0000377 return
378
José Fonseca9b126ea2011-09-15 08:15:33 +0100379 if function.name in self.draw_elements_function_names and arg.name == 'indices' or\
380 function.name in self.draw_indirect_function_names and arg.name == 'indirect':
José Fonseca54f304a2012-01-14 19:33:08 +0000381 self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
José Fonseca8a844ae2010-12-06 18:50:52 +0000382 return
José Fonsecadacd8dd2010-11-25 17:50:26 +0000383
José Fonsecac29f4f12011-06-11 12:19:05 +0100384 # Handle pointer with offsets into the current pack pixel buffer
385 # object.
386 if function.name in self.pack_function_names and arg.output:
José Fonseca54f304a2012-01-14 19:33:08 +0000387 self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
José Fonsecac29f4f12011-06-11 12:19:05 +0100388 return
389
José Fonseca3c1b7ce2011-05-09 11:22:54 +0100390 if arg.type is glapi.GLlocation \
José Fonseca568ecc22012-01-15 13:57:03 +0000391 and 'program' not in function.argNames():
José Fonseca8a844ae2010-12-06 18:50:52 +0000392 print ' GLint program = -1;'
393 print ' glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
José Fonseca3c1b7ce2011-05-09 11:22:54 +0100394
395 if arg.type is glapi.GLlocationARB \
José Fonseca568ecc22012-01-15 13:57:03 +0000396 and 'programObj' not in function.argNames():
José Fonseca3a84b682011-05-09 11:33:47 +0100397 print ' GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'
José Fonseca8a844ae2010-12-06 18:50:52 +0000398
José Fonseca54f304a2012-01-14 19:33:08 +0000399 Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue)
José Fonsecae6a50bd2010-11-24 10:12:22 +0000400
José Fonseca42926462011-05-09 11:32:15 +0100401 # Don't try to use more samples than the implementation supports
402 if arg.name == 'samples':
403 assert arg.type is glapi.GLsizei
404 print ' GLint max_samples = 0;'
405 print ' glGetIntegerv(GL_MAX_SAMPLES, &max_samples);'
406 print ' if (samples > max_samples) {'
407 print ' samples = max_samples;'
408 print ' }'
409
José Fonsecae6a50bd2010-11-24 10:12:22 +0000410
José Fonseca7e329022010-11-19 17:05:18 +0000411if __name__ == '__main__':
José Fonseca796a3042010-11-29 14:21:06 +0000412 print r'''
José Fonseca867b1b72011-04-24 11:58:04 +0100413#include <string.h>
414
José Fonsecadf66a902010-11-29 13:24:20 +0000415#include "glproc.hpp"
José Fonseca32871ed2011-04-10 13:40:52 +0100416#include "glretrace.hpp"
José Fonseca56391262011-09-19 09:30:10 +0100417#include "glstate.hpp"
José Fonseca589082d2011-03-30 09:10:40 +0100418
José Fonsecadf66a902010-11-29 13:24:20 +0000419
José Fonseca3d245f42010-11-28 00:08:23 +0000420'''
José Fonsecae0e61402010-11-25 15:03:23 +0000421 api = glapi.glapi
José Fonseca54f304a2012-01-14 19:33:08 +0000422 api.addApi(glesapi.glesapi)
José Fonsecae0e61402010-11-25 15:03:23 +0000423 retracer = GlRetracer()
José Fonseca54f304a2012-01-14 19:33:08 +0000424 retracer.retraceApi(api)