blob: 56a2113f0507a446b770a568d1ae5d75a0232aab [file] [log] [blame]
Ian Romanick74764062004-12-03 20:31:59 +00001#!/usr/bin/python2
2
Ian Romanick5f1f2292005-01-07 02:39:09 +00003# (C) Copyright IBM Corporation 2004, 2005
Ian Romanick74764062004-12-03 20:31:59 +00004# All Rights Reserved.
5#
6# Permission is hereby granted, free of charge, to any person obtaining a
7# copy of this software and associated documentation files (the "Software"),
8# to deal in the Software without restriction, including without limitation
9# on the rights to use, copy, modify, merge, publish, distribute, sub
10# license, and/or sell copies of the Software, and to permit persons to whom
11# the Software is furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice (including the next
14# paragraph) shall be included in all copies or substantial portions of the
15# Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23# IN THE SOFTWARE.
24#
25# Authors:
26# Ian Romanick <idr@us.ibm.com>
27
28from xml.sax import saxutils
29from xml.sax import make_parser
30from xml.sax.handler import feature_namespaces
31
32import gl_XML
33import license
34import sys, getopt
35
36
37def printPure():
38 print """# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
39# define PURE __attribute__((pure))
40# else
41# define PURE
42# endif"""
43
44def printFastcall():
45 print """# if defined(__i386__) && defined(__GNUC__)
46# define FASTCALL __attribute__((fastcall))
47# else
48# define FASTCALL
49# endif"""
50
51def printVisibility(S, s):
52 print """# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
53# define %s __attribute__((visibility("%s")))
54# else
55# define %s
56# endif""" % (S, s, S)
57
58def printNoinline():
59 print """# if defined(__GNUC__)
60# define NOINLINE __attribute__((noinline))
61# else
62# define NOINLINE
63# endif"""
64
Ian Romanick7f958e92005-01-24 20:08:28 +000065def printHaveAlias():
66 print """# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
67# define HAVE_ALIAS
68# endif"""
Ian Romanick74764062004-12-03 20:31:59 +000069
70class glXItemFactory(gl_XML.glItemFactory):
71 """Factory to create GLX protocol oriented objects derived from glItem."""
72
73 def create(self, context, name, attrs):
74 if name == "function":
75 return glXFunction(context, name, attrs)
76 elif name == "enum":
77 return glXEnum(context, name, attrs)
78 elif name == "param":
79 return glXParameter(context, name, attrs)
80 else:
81 return gl_XML.glItemFactory.create(self, context, name, attrs)
82
83class glXEnumFunction:
Ian Romanickba09c192005-02-01 00:13:04 +000084 def __init__(self, name, context):
Ian Romanick74764062004-12-03 20:31:59 +000085 self.name = name
Ian Romanickba09c192005-02-01 00:13:04 +000086 self.context = context
Ian Romanick5aa6dc322005-01-27 01:08:48 +000087 self.mode = 0
88 self.sig = None
89
Ian Romanick74764062004-12-03 20:31:59 +000090 # "enums" is a set of lists. The element in the set is the
91 # value of the enum. The list is the list of names for that
92 # value. For example, [0x8126] = {"POINT_SIZE_MIN",
93 # "POINT_SIZE_MIN_ARB", "POINT_SIZE_MIN_EXT",
94 # "POINT_SIZE_MIN_SGIS"}.
95
96 self.enums = {}
97
98 # "count" is indexed by count values. Each element of count
99 # is a list of index to "enums" that have that number of
100 # associated data elements. For example, [4] =
101 # {GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_EMISSION,
102 # GL_AMBIENT_AND_DIFFUSE} (the enum names are used here,
103 # but the actual hexadecimal values would be in the array).
104
105 self.count = {}
106
107
108 def append(self, count, value, name):
109 if self.enums.has_key( value ):
110 self.enums[value].append(name)
111 else:
112 if not self.count.has_key(count):
113 self.count[count] = []
114
115 self.enums[value] = []
116 self.enums[value].append(name)
117 self.count[count].append(value)
118
119
120 def signature( self ):
Ian Romanick5aa6dc322005-01-27 01:08:48 +0000121 if self.sig == None:
122 self.sig = ""
123 for i in self.count:
Ian Romanick82e22f52005-01-27 19:39:16 +0000124 self.count[i].sort()
Ian Romanick5aa6dc322005-01-27 01:08:48 +0000125 for e in self.count[i]:
126 self.sig += "%04x,%u," % (e, i)
Ian Romanick74764062004-12-03 20:31:59 +0000127
Ian Romanick5aa6dc322005-01-27 01:08:48 +0000128 return self.sig
129
130
131 def set_mode( self, mode ):
132 """Mark an enum-function as a 'set' function."""
133
134 self.mode = mode
135
136
137 def is_set( self ):
138 return self.mode
Ian Romanick74764062004-12-03 20:31:59 +0000139
140
141 def PrintUsingTable(self):
142 """Emit the body of the __gl*_size function using a pair
143 of look-up tables and a mask. The mask is calculated such
144 that (e & mask) is unique for all the valid values of e for
145 this function. The result of (e & mask) is used as an index
146 into the first look-up table. If it matches e, then the
147 same entry of the second table is returned. Otherwise zero
148 is returned.
149
150 It seems like this should cause better code to be generated.
151 However, on x86 at least, the resulting .o file is about 20%
152 larger then the switch-statment version. I am leaving this
153 code in because the results may be different on other
154 platforms (e.g., PowerPC or x86-64)."""
155
156 return 0
157 count = 0
158 for a in self.enums:
159 count += 1
160
161 # Determine if there is some mask M, such that M = (2^N) - 1,
162 # that will generate unique values for all of the enums.
163
164 mask = 0
165 for i in [1, 2, 3, 4, 5, 6, 7, 8]:
166 mask = (1 << i) - 1
167
168 fail = 0;
169 for a in self.enums:
170 for b in self.enums:
171 if a != b:
172 if (a & mask) == (b & mask):
173 fail = 1;
174
175 if not fail:
176 break;
177 else:
178 mask = 0
179
180 if (mask != 0) and (mask < (2 * count)):
181 masked_enums = {}
182 masked_count = {}
183
184 for i in range(0, mask + 1):
185 masked_enums[i] = "0";
186 masked_count[i] = 0;
187
188 for c in self.count:
189 for e in self.count[c]:
190 i = e & mask
191 masked_enums[i] = '0x%04x /* %s */' % (e, self.enums[e][0])
192 masked_count[i] = c
193
194
195 print ' static const GLushort a[%u] = {' % (mask + 1)
196 for e in masked_enums:
197 print ' %s, ' % (masked_enums[e])
198 print ' };'
199
200 print ' static const GLubyte b[%u] = {' % (mask + 1)
201 for c in masked_count:
202 print ' %u, ' % (masked_count[c])
203 print ' };'
204
205 print ' const unsigned idx = (e & 0x%02xU);' % (mask)
206 print ''
207 print ' return (e == a[idx]) ? (GLint) b[idx] : 0;'
208 return 1;
209 else:
210 return 0;
211
212 def PrintUsingSwitch(self):
213 """Emit the body of the __gl*_size function using a
214 switch-statement."""
215
216 print ' switch( e ) {'
217
218 for c in self.count:
219 for e in self.count[c]:
220 first = 1
221
222 # There may be multiple enums with the same
223 # value. This happens has extensions are
224 # promoted from vendor-specific or EXT to
225 # ARB and to the core. Emit the first one as
226 # a case label, and emit the others as
227 # commented-out case labels.
228
229 for j in self.enums[e]:
230 if first:
231 print ' case %s:' % (j)
232 first = 0
233 else:
234 print '/* case %s:*/' % (j)
235
236 print ' return %u;' % (c)
237
238 print ' default: return 0;'
239 print ' }'
240
241
242 def Print(self, name):
243 print 'INTERNAL PURE FASTCALL GLint'
244 print '__gl%s_size( GLenum e )' % (name)
245 print '{'
246
247 if not self.PrintUsingTable():
248 self.PrintUsingSwitch()
249
250 print '}'
251 print ''
252
253
254
255class glXEnum(gl_XML.glEnum):
256 def __init__(self, context, name, attrs):
257 gl_XML.glEnum.__init__(self, context, name, attrs)
Ian Romanick0246b2a2005-01-24 20:59:32 +0000258
Ian Romanick74764062004-12-03 20:31:59 +0000259
260 def startElement(self, name, attrs):
261 if name == "size":
Ian Romanick85f0fa32005-01-25 01:20:11 +0000262 [n, c, mode] = self.process_attributes(attrs)
Ian Romanick5ff2b942005-01-24 21:29:13 +0000263
Ian Romanick74764062004-12-03 20:31:59 +0000264 if not self.context.glx_enum_functions.has_key( n ):
Ian Romanickba09c192005-02-01 00:13:04 +0000265 f = self.context.createEnumFunction( n )
Ian Romanick5aa6dc322005-01-27 01:08:48 +0000266 f.set_mode( mode )
Ian Romanick74764062004-12-03 20:31:59 +0000267 self.context.glx_enum_functions[ f.name ] = f
268
Ian Romanick74764062004-12-03 20:31:59 +0000269 self.context.glx_enum_functions[ n ].append( c, self.value, self.name )
270 else:
271 gl_XML.glEnum.startElement(self, context, name, attrs)
272 return
273
274
275class glXParameter(gl_XML.glParameter):
276 def __init__(self, context, name, attrs):
277 self.order = 1;
278 gl_XML.glParameter.__init__(self, context, name, attrs);
279
280
Ian Romanick1d270842004-12-21 21:26:36 +0000281class glXParameterIterator:
282 """Class to iterate over a list of glXParameters.
283
284 Objects of this class are returned by the parameterIterator method of
285 the glXFunction class. They are used to iterate over the list of
286 parameters to the function."""
287
288 def __init__(self, data, skip_output, max_order):
289 self.data = data
290 self.index = 0
291 self.order = 0
292 self.skip_output = skip_output
293 self.max_order = max_order
294
295 def __iter__(self):
296 return self
297
298 def next(self):
299 if len( self.data ) == 0:
300 raise StopIteration
301
302 while 1:
303 if self.index == len( self.data ):
304 if self.order == self.max_order:
305 raise StopIteration
306 else:
307 self.order += 1
308 self.index = 0
309
310 i = self.index
311 self.index += 1
312
313 if self.data[i].order == self.order and not (self.data[i].is_output and self.skip_output):
314 return self.data[i]
315
316
Ian Romanick74764062004-12-03 20:31:59 +0000317class glXFunction(gl_XML.glFunction):
318 glx_rop = 0
319 glx_sop = 0
320 glx_vendorpriv = 0
321
322 # If this is set to true, it means that GLdouble parameters should be
323 # written to the GLX protocol packet in the order they appear in the
324 # prototype. This is different from the "classic" ordering. In the
325 # classic ordering GLdoubles are written to the protocol packet first,
326 # followed by non-doubles. NV_vertex_program was the first extension
327 # to break with this tradition.
328
329 glx_doubles_in_order = 0
330
331 vectorequiv = None
Ian Romanick74764062004-12-03 20:31:59 +0000332 can_be_large = 0
333
334 def __init__(self, context, name, attrs):
335 self.vectorequiv = attrs.get('vectorequiv', None)
336 self.count_parameters = None
337 self.counter = None
338 self.output = None
339 self.can_be_large = 0
340 self.reply_always_array = 0
341
Ian Romanickfdb05272005-01-28 17:30:25 +0000342 self.server_handcode = 0
343 self.client_handcode = 0
344 self.ignore = 0
345
Ian Romanick74764062004-12-03 20:31:59 +0000346 gl_XML.glFunction.__init__(self, context, name, attrs)
347 return
348
Ian Romanick1d270842004-12-21 21:26:36 +0000349
350 def parameterIterator(self, skip_output, max_order):
351 return glXParameterIterator(self.fn_parameters, skip_output, max_order)
352
353
Ian Romanick74764062004-12-03 20:31:59 +0000354 def startElement(self, name, attrs):
355 """Process elements within a function that are specific to GLX."""
356
357 if name == "glx":
358 self.glx_rop = int(attrs.get('rop', "0"))
359 self.glx_sop = int(attrs.get('sop', "0"))
360 self.glx_vendorpriv = int(attrs.get('vendorpriv', "0"))
361
Ian Romanickfdb05272005-01-28 17:30:25 +0000362 # The 'handcode' attribute can be one of 'true',
363 # 'false', 'client', or 'server'.
364
365 handcode = attrs.get('handcode', "false")
366 if handcode == "false":
367 self.server_handcode = 0
368 self.client_handcode = 0
369 elif handcode == "true":
370 self.server_handcode = 1
371 self.client_handcode = 1
372 elif handcode == "client":
373 self.server_handcode = 0
374 self.client_handcode = 1
375 elif handcode == "server":
376 self.server_handcode = 1
377 self.client_handcode = 0
Ian Romanick74764062004-12-03 20:31:59 +0000378 else:
Ian Romanickfdb05272005-01-28 17:30:25 +0000379 raise RuntimeError('Invalid handcode mode "%s" in function "%s".' % (handcode, self.name))
380
Ian Romanick74764062004-12-03 20:31:59 +0000381
382 if attrs.get('ignore', "false") == "true":
383 self.ignore = 1
384 else:
385 self.ignore = 0
386
387 if attrs.get('large', "false") == "true":
388 self.can_be_large = 1
389 else:
390 self.can_be_large = 0
391
392 if attrs.get('doubles_in_order', "false") == "true":
393 self.glx_doubles_in_order = 1
394 else:
395 self.glx_doubles_in_order = 0
396
397 if attrs.get('always_array', "false") == "true":
398 self.reply_always_array = 1
399 else:
400 self.reply_always_array = 0
401
402 else:
403 gl_XML.glFunction.startElement(self, name, attrs)
404
405
Ian Romanick7f958e92005-01-24 20:08:28 +0000406 def endElement(self, name):
407 if name == "function":
408 # Mark any function that does not have GLX protocol
409 # defined as "ignore". This prevents bad things from
410 # happening when people add new functions to the GL
411 # API XML without adding any GLX section.
412 #
413 # This will also mark functions that don't have a
414 # dispatch offset at ignored.
415
Ian Romanickfdb05272005-01-28 17:30:25 +0000416 if (self.fn_offset == -1 and not self.fn_alias) or not (self.client_handcode or self.server_handcode or self.glx_rop or self.glx_sop or self.glx_vendorpriv or self.vectorequiv or self.fn_alias):
Ian Romanick7f958e92005-01-24 20:08:28 +0000417 #if not self.ignore:
418 # if self.fn_offset == -1:
419 # print '/* %s ignored becuase no offset assigned. */' % (self.name)
420 # else:
421 # print '/* %s ignored becuase no GLX opcode assigned. */' % (self.name)
422
423 self.ignore = 1
424
425 return gl_XML.glFunction.endElement(self, name)
426
427
Ian Romanick74764062004-12-03 20:31:59 +0000428 def append(self, tag_name, p):
429 gl_XML.glFunction.append(self, tag_name, p)
430
431 if p.is_variable_length_array():
432 p.order = 2;
433 elif not self.glx_doubles_in_order and p.p_type.size == 8:
434 p.order = 0;
435
436 if p.p_count_parameters != None:
437 self.count_parameters = p.p_count_parameters
438
439 if p.is_counter:
440 self.counter = p.name
441
442 if p.is_output:
443 self.output = p
444
445 return
446
Ian Romanick0246b2a2005-01-24 20:59:32 +0000447
Ian Romanick74764062004-12-03 20:31:59 +0000448 def variable_length_parameter(self):
449 for param in self.fn_parameters:
450 if param.is_variable_length_array():
451 return param
452
453 return None
454
455
Ian Romanick54584df2005-01-28 18:20:43 +0000456 def output_parameter(self):
457 for param in self.fn_parameters:
458 if param.is_output:
459 return param
460
461 return None
462
463
Ian Romanick0246b2a2005-01-24 20:59:32 +0000464 def offset_of_first_parameter(self):
465 """Get the offset of the first parameter in the command.
466
467 Gets the offset of the first function parameter in the GLX
468 command packet. This byte offset is measured from the end
469 of the Render / RenderLarge header. The offset for all non-
470 pixel commends is zero. The offset for pixel commands depends
471 on the number of dimensions of the pixel data."""
Ian Romanick5f1f2292005-01-07 02:39:09 +0000472
473 if self.image:
474 [dim, junk, junk, junk, junk] = self.dimensions()
Ian Romanick0246b2a2005-01-24 20:59:32 +0000475
Ian Romanick5f1f2292005-01-07 02:39:09 +0000476 # The base size is the size of the pixel pack info
477 # header used by images with the specified number
478 # of dimensions.
479
480 if dim <= 2:
Ian Romanick0246b2a2005-01-24 20:59:32 +0000481 return 20
Ian Romanick5f1f2292005-01-07 02:39:09 +0000482 elif dim <= 4:
Ian Romanick0246b2a2005-01-24 20:59:32 +0000483 return 36
Ian Romanick5f1f2292005-01-07 02:39:09 +0000484 else:
485 raise RuntimeError('Invalid number of dimensions %u for parameter "%s" in function "%s".' % (dim, self.image.name, self.name))
Ian Romanick0246b2a2005-01-24 20:59:32 +0000486 else:
487 return 0
Ian Romanick5f1f2292005-01-07 02:39:09 +0000488
Ian Romanick5f1f2292005-01-07 02:39:09 +0000489
Ian Romanick0246b2a2005-01-24 20:59:32 +0000490 def command_fixed_length(self):
491 """Return the length, in bytes as an integer, of the
492 fixed-size portion of the command."""
Ian Romanick5f1f2292005-01-07 02:39:09 +0000493
Ian Romanick0246b2a2005-01-24 20:59:32 +0000494 size = self.offset_of_first_parameter()
Ian Romanick5f1f2292005-01-07 02:39:09 +0000495
Ian Romanick0246b2a2005-01-24 20:59:32 +0000496 for p in gl_XML.glFunction.parameterIterator(self):
497 if not p.is_output:
498 size += p.size()
499 if self.pad_after(p):
500 size += 4
501
502 if self.image and self.image.img_null_flag:
503 size += 4
504
505 return size
506
507
508 def command_variable_length(self):
509 """Return the length, as a string, of the variable-sized
510 portion of the command."""
511
Ian Romanick74764062004-12-03 20:31:59 +0000512 size_string = ""
Ian Romanick1d270842004-12-21 21:26:36 +0000513 for p in gl_XML.glFunction.parameterIterator(self):
Ian Romanick0246b2a2005-01-24 20:59:32 +0000514 if (not p.is_output) and (p.size() == 0):
515 size_string = size_string + " + __GLX_PAD(%s)" % (p.size_string())
Ian Romanick74764062004-12-03 20:31:59 +0000516
Ian Romanick0246b2a2005-01-24 20:59:32 +0000517 return size_string
518
Ian Romanick74764062004-12-03 20:31:59 +0000519
520 def command_length(self):
Ian Romanick0246b2a2005-01-24 20:59:32 +0000521 size = self.command_fixed_length()
Ian Romanick74764062004-12-03 20:31:59 +0000522
523 if self.glx_rop != 0:
524 size += 4
525
526 size = ((size + 3) & ~3)
Ian Romanick0246b2a2005-01-24 20:59:32 +0000527 return "%u%s" % (size, self.command_variable_length())
Ian Romanick74764062004-12-03 20:31:59 +0000528
529
530 def opcode_real_value(self):
Ian Romanick1d270842004-12-21 21:26:36 +0000531 """Get the true numeric value of the GLX opcode
532
533 Behaves similarly to opcode_value, except for
534 X_GLXVendorPrivate and X_GLXVendorPrivateWithReply commands.
535 In these cases the value for the GLX opcode field (i.e.,
536 16 for X_GLXVendorPrivate or 17 for
537 X_GLXVendorPrivateWithReply) is returned. For other 'single'
538 commands, the opcode for the command (e.g., 101 for
539 X_GLsop_NewList) is returned."""
540
Ian Romanick74764062004-12-03 20:31:59 +0000541 if self.glx_vendorpriv != 0:
542 if self.needs_reply():
543 return 17
544 else:
545 return 16
546 else:
547 return self.opcode_value()
548
549 def opcode_value(self):
Ian Romanick1d270842004-12-21 21:26:36 +0000550 """Get the unique protocol opcode for the glXFunction"""
551
Ian Romanick74764062004-12-03 20:31:59 +0000552 if self.glx_rop != 0:
553 return self.glx_rop
554 elif self.glx_sop != 0:
555 return self.glx_sop
556 elif self.glx_vendorpriv != 0:
557 return self.glx_vendorpriv
558 else:
559 return -1
560
561 def opcode_rop_basename(self):
Ian Romanick1d270842004-12-21 21:26:36 +0000562 """Return either the name to be used for GLX protocol enum.
563
564 Returns either the name of the function or the name of the
565 name of the equivalent vector (e.g., glVertex3fv for
566 glVertex3f) function."""
567
Ian Romanick74764062004-12-03 20:31:59 +0000568 if self.vectorequiv == None:
569 return self.name
570 else:
571 return self.vectorequiv
572
573 def opcode_name(self):
Ian Romanick1d270842004-12-21 21:26:36 +0000574 """Get the unique protocol enum name for the glXFunction"""
575
Ian Romanick74764062004-12-03 20:31:59 +0000576 if self.glx_rop != 0:
577 return "X_GLrop_%s" % (self.opcode_rop_basename())
578 elif self.glx_sop != 0:
579 return "X_GLsop_%s" % (self.name)
580 elif self.glx_vendorpriv != 0:
581 return "X_GLvop_%s" % (self.name)
582 else:
583 return "ERROR"
584
585 def opcode_real_name(self):
Ian Romanick1d270842004-12-21 21:26:36 +0000586 """Get the true protocol enum name for the GLX opcode
587
588 Behaves similarly to opcode_name, except for
589 X_GLXVendorPrivate and X_GLXVendorPrivateWithReply commands.
590 In these cases the string 'X_GLXVendorPrivate' or
591 'X_GLXVendorPrivateWithReply' is returned. For other
592 single or render commands 'X_GLsop' or 'X_GLrop' plus the
593 name of the function returned."""
594
Ian Romanick74764062004-12-03 20:31:59 +0000595 if self.glx_vendorpriv != 0:
596 if self.needs_reply():
597 return "X_GLXVendorPrivateWithReply"
598 else:
599 return "X_GLXVendorPrivate"
600 else:
601 return self.opcode_name()
602
603
604 def return_string(self):
605 if self.fn_return_type != 'void':
606 return "return retval;"
607 else:
608 return "return;"
609
610
611 def needs_reply(self):
612 return self.fn_return_type != 'void' or self.output != None
613
614
Ian Romanick5f1f2292005-01-07 02:39:09 +0000615 def dimensions(self):
616 """Determine the dimensions of an image.
617
618 Returns a tuple representing the number of dimensions and the
619 string name of each of the dimensions of an image, If the
620 function is not a pixel function, the number of dimensions
621 will be zero."""
622
623 if not self.image:
624 return [0, "0", "0", "0", "0"]
625 else:
626 dim = 1
627 w = self.image.width
628
629 if self.image.height:
630 dim = 2
631 h = self.image.height
632 else:
633 h = "1"
634
635 if self.image.depth:
636 dim = 3
637 d = self.image.depth
638 else:
639 d = "1"
640
641 if self.image.extent:
642 dim = 4
643 e = self.image.extent
644 else:
645 e = "1"
646
647 return [dim, w, h, d, e]
648
649
650 def pad_after(self, p):
651 """Returns the name of the field inserted after the
652 specified field to pad out the command header."""
653
654 if self.image and self.image.img_pad_dimensions:
655 if not self.image.height:
656 if p.name == self.image.width:
657 return "height"
658 elif p.name == self.image.img_xoff:
659 return "yoffset"
660 elif not self.image.extent:
661 if p.name == self.image.depth:
662 # Should this be "size4d"?
663 return "extent"
664 elif p.name == self.image.img_zoff:
665 return "woffset"
666 return None
667
668
Ian Romanick74764062004-12-03 20:31:59 +0000669class GlxProto(gl_XML.FilterGLAPISpecBase):
670 name = "glX_proto_send.py (from Mesa)"
671
672 def __init__(self):
673 gl_XML.FilterGLAPISpecBase.__init__(self)
674 self.factory = glXItemFactory()
675 self.glx_enum_functions = {}
676
677
678 def endElement(self, name):
679 if name == 'OpenGLAPI':
680 # Once all the parsing is done, we have to go back and
681 # fix-up some cross references between different
682 # functions.
683
684 for k in self.functions:
685 f = self.functions[k]
686 if f.vectorequiv != None:
687 equiv = self.find_function(f.vectorequiv)
688 if equiv != None:
689 f.glx_doubles_in_order = equiv.glx_doubles_in_order
690 f.glx_rop = equiv.glx_rop
691 else:
692 raise RuntimeError("Could not find the vector equiv. function %s for %s!" % (f.name, f.vectorequiv))
693 else:
694 gl_XML.FilterGLAPISpecBase.endElement(self, name)
695 return
Ian Romanickba09c192005-02-01 00:13:04 +0000696
697
698 def createEnumFunction(self, n):
699 return glXEnumFunction(n, self)