diff options
| -rw-r--r-- | src/mesa/glapi/glX_XML.py | 65 | ||||
| -rw-r--r-- | src/mesa/glapi/glX_doc.py | 8 | ||||
| -rw-r--r-- | src/mesa/glapi/glX_proto_send.py | 22 | ||||
| -rw-r--r-- | src/mesa/glapi/glX_proto_size.py | 16 | ||||
| -rw-r--r-- | src/mesa/glapi/gl_XML.py | 29 | 
5 files changed, 84 insertions, 56 deletions
| diff --git a/src/mesa/glapi/glX_XML.py b/src/mesa/glapi/glX_XML.py index 9a34111efe..3e749790d8 100644 --- a/src/mesa/glapi/glX_XML.py +++ b/src/mesa/glapi/glX_XML.py @@ -31,7 +31,7 @@ from xml.sax.handler import feature_namespaces  import gl_XML  import license -import sys, getopt +import sys, getopt, string  class glXItemFactory(gl_XML.glItemFactory): @@ -300,7 +300,6 @@ class glXFunction(gl_XML.glFunction):  	def __init__(self, context, name, attrs):  		self.vectorequiv = attrs.get('vectorequiv', None) -		self.count_parameters = None  		self.counter = None  		self.output = None  		self.can_be_large = 0 @@ -400,9 +399,6 @@ class glXFunction(gl_XML.glFunction):  		elif not self.glx_doubles_in_order and p.p_type.size == 8:  			p.order = 0; -		if p.p_count_parameters != None: -			self.count_parameters = p.p_count_parameters -		  		if p.is_counter:  			self.counter = p.name @@ -547,7 +543,8 @@ class glXFunction(gl_XML.glFunction):  		elif self.glx_vendorpriv != 0:  			return "X_GLvop_%s" % (self.name)  		else: -			return "ERROR" +			raise RuntimeError('Function "%s" has no opcode.' % (self.name)) +  	def opcode_real_name(self):  		"""Get the true protocol enum name for the GLX opcode @@ -632,7 +629,34 @@ class glXFunction(gl_XML.glFunction):  					return "woffset"  		return None -		 + +class glXFunctionIterator(gl_XML.glFunctionIterator): +	"""Class to iterate over a list of glXFunctions""" + +	def __init__(self, context): +		self.context = context +		self.keys = context.functions.keys() +		self.keys.sort() + +		for self.index in range(0, len(self.keys)): +			if self.keys[ self.index ] >= 0: break + +		return + + +	def next(self): +		if self.index == len(self.keys): +			raise StopIteration + +		f = self.context.functions[ self.keys[ self.index ] ] +		self.index += 1 + +		if f.ignore: +			return self.next() +		else: +			return f + +  class GlxProto(gl_XML.FilterGLAPISpecBase):  	name = "glX_proto_send.py (from Mesa)" @@ -664,3 +688,30 @@ class GlxProto(gl_XML.FilterGLAPISpecBase):  	def createEnumFunction(self, n):  		return glXEnumFunction(n, self) + + +	def functionIterator(self): +		return glXFunctionIterator(self) + +	 +	def size_call(self, func): +		"""Create C code to calculate 'compsize'. + +		Creates code to calculate 'compsize'.  If the function does +		not need 'compsize' to be calculated, None will be +		returned.""" + +		if not func.image and not func.count_parameter_list: +			return None + +		if not func.image: +			parameters = string.join( func.count_parameter_list, "," ) +			compsize = "__gl%s_size(%s)" % (func.name, parameters) +		else: +			[dim, w, h, d, junk] = func.dimensions() + +			compsize = '__glImageSize(%s, %s, %s, %s, %s, %s)' % (w, h, d, func.image.img_format, func.image.img_type, func.image.img_target) +			if not func.image.img_send_null: +				compsize = '(%s != NULL) ? %s : 0' % (func.image.name, compsize) + +		return compsize diff --git a/src/mesa/glapi/glX_doc.py b/src/mesa/glapi/glX_doc.py index 8a2ecb79e8..dd96a59f55 100644 --- a/src/mesa/glapi/glX_doc.py +++ b/src/mesa/glapi/glX_doc.py @@ -75,11 +75,11 @@ class glXDocParameter(gl_XML.glParameter):  			a_prod = "n"  			b_prod = self.p_type.size -			if self.p_count_parameters == None and self.counter != None: +			if not self.count_parameter_list and self.counter:  				a_prod = self.counter -			elif (self.p_count_parameters != None and self.counter == None) or (self.is_output): +			elif self.count_parameter_list and not self.counter or self.is_output:  				pass -			elif self.p_count_parameters != None and self.counter != None: +			elif self.count_parameter_list and self.counter:  				b_prod = self.counter  			else:  				raise RuntimeError("Parameter '%s' to function '%s' has size 0." % (self.name, self.context.name)) @@ -234,7 +234,7 @@ class PrintGlxProtoText(glX_XML.GlxProto):  		# At some point this should be expanded to support pixel  		# functions, but I'm not going to lose any sleep over it now. -		if f.fn_offset < 0 or f.client_handcode or f.server_handcode or f.ignore or f.vectorequiv or f.image: +		if f.client_handcode or f.server_handcode or f.vectorequiv or f.image:  			return  		print '        %s' % (f.name) diff --git a/src/mesa/glapi/glX_proto_send.py b/src/mesa/glapi/glX_proto_send.py index 949a0c9433..6ee93a5c1e 100644 --- a/src/mesa/glapi/glX_proto_send.py +++ b/src/mesa/glapi/glX_proto_send.py @@ -101,7 +101,7 @@ class glXPixelFunctionUtility(glX_XML.glXFunction):  		self.set_return_type( func.fn_return_type )  		self.glx_rop = ~0  		self.can_be_large = func.can_be_large -		self.count_parameters = func.count_parameters +		self.count_parameter_list = func.count_parameter_list  		self.counter = func.counter  		return @@ -218,7 +218,7 @@ const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };  		return  	def printFunction(self, f): -		if f.fn_offset < 0 or f.client_handcode or f.ignore: return +		if f.client_handcode: return  		if f.glx_rop != 0 or f.vectorequiv != None:  			if f.image: @@ -339,17 +339,10 @@ generic_%u_byte( GLint rop, const void * ptr )  		if f.fn_return_type != 'void':  			print '    %s retval = (%s) 0;' % (f.fn_return_type, f.fn_return_type) -		if f.count_parameters and not f.output_parameter(): -			print '    const GLuint compsize = __gl%s_size(%s);' % (f.name, f.count_parameters) -		elif f.image: -			[dim, w, h, d, junk] = f.dimensions() -			 -			compsize = '__glImageSize(%s, %s, %s, %s, %s, %s)' % (w, h, d, f.image.img_format, f.image.img_type, f.image.img_target) -			if not f.image.img_send_null: -				compsize = '(%s != NULL) ? %s : 0' % (f.image.name, compsize) - -			print '    const GLuint compsize = %s;' % (compsize) - +		if not f.output_parameter(): +			compsize = self.size_call( f ) +			if compsize: +				print '    const GLuint compsize = %s;' % (compsize)  		print '    const GLuint cmdlen = %s;' % (f.command_length()) @@ -740,8 +733,6 @@ __GLapi * __glXNewIndirectAPI( void )  """  	def printFunction(self, f): -		if f.fn_offset < 0 or f.ignore: return -		  		if f.category != self.last_category:  			self.last_category = f.category  			print '' @@ -773,7 +764,6 @@ class PrintGlxProtoInit_h(glX_XML.GlxProto):  	def printFunction(self, f): -		if f.fn_offset < 0 or f.ignore: return  		print 'extern HIDDEN %s __indirect_gl%s(%s);' % (f.fn_return_type, f.name, f.get_parameter_string()) diff --git a/src/mesa/glapi/glX_proto_size.py b/src/mesa/glapi/glX_proto_size.py index 3030e7462b..404b526b85 100644 --- a/src/mesa/glapi/glX_proto_size.py +++ b/src/mesa/glapi/glX_proto_size.py @@ -35,9 +35,9 @@ import license  import sys, getopt, copy -class SizeStubFunctionIterator: +class SizeStubFunctionIterator(glX_XML.glXFunctionIterator):  	"""Iterate over functions that need "size" information. -	 +  	Iterate over the functions that have variable sized data.  First the  	"set"-type functions are iterated followed by the "get"-type  	functions. @@ -52,8 +52,6 @@ class SizeStubFunctionIterator:  		extra_data = []  		for f in gl_XML.glFunctionIterator(context): -			if f.fn_offset < 0: break -  			if context.glx_enum_functions.has_key(f.name):  				ef = context.glx_enum_functions[f.name]  				if ef.is_set(): @@ -80,10 +78,6 @@ class SizeStubFunctionIterator:  		return -	def __iter__(self): -		return self - -  	def next(self):  		if self.index == len(self.data):  			raise StopIteration @@ -132,7 +126,7 @@ class glXServerEnumFunction(glX_XML.glXEnumFunction):  		self.context.common_emit_fixups(fixup)  		print '' -		print '    compsize = __gl%s_size(%s);' % (self.name, f.count_parameters) +		print '    compsize = %s;' % (context.size_call(context, f))  		p = f.variable_length_parameter()  		print '    return __GLX_PAD(%s);' % (p.size_string()) @@ -251,7 +245,7 @@ class PrintGlxReqSize_h(glX_XML.GlxProto):  	def printFunction(self, f): -		if f.glx_rop == 0 or f.ignore: return +		if f.glx_rop == 0: return  		has_counter = 0  		for p in f.parameterIterator(1,2): @@ -310,7 +304,7 @@ class PrintGlxReqSize_c(glX_XML.GlxProto):  	def printFunction(self, f): -		if f.glx_rop == 0 or f.server_handcode or f.ignore: return +		if f.glx_rop == 0 or f.server_handcode: return  		if self.glx_enum_functions.has_key(f.name):  			ef = self.glx_enum_functions[f.name] diff --git a/src/mesa/glapi/gl_XML.py b/src/mesa/glapi/gl_XML.py index 1771975e84..a24a8450a1 100644 --- a/src/mesa/glapi/gl_XML.py +++ b/src/mesa/glapi/gl_XML.py @@ -142,7 +142,6 @@ class glParameter( glItem ):  	p_type = None  	p_type_string = ""  	p_count = 0 -	p_count_parameters = None  	counter = None  	is_output = 0  	is_counter = 0 @@ -151,11 +150,10 @@ class glParameter( glItem ):  	def __init__(self, context, name, attrs):  		p_name = attrs.get('name', None)  		self.p_type_string = attrs.get('type', None) -		self.p_count_parameters = attrs.get('variable_param', None) -		if self.p_count_parameters: -			temp = self.p_count_parameters.replace( ' ', '' ) -			self.count_parameter_list = temp.split( ',' ) +		temp = attrs.get('variable_param', None) +		if temp: +			self.count_parameter_list = temp.replace( ' ', '' ).split( ',' )  		else:  			self.count_parameter_list = [] @@ -225,7 +223,7 @@ class glParameter( glItem ): -		if self.p_count > 0 or self.counter or self.p_count_parameters: +		if self.p_count > 0 or self.counter or self.count_parameter_list:  			has_count = 1  		else:  			has_count = 0 @@ -264,7 +262,7 @@ class glParameter( glItem ):  		to glCallLists, are not variable length arrays in this  		sense.""" -		return self.p_count_parameters or self.counter or self.width +		return self.count_parameter_list or self.counter or self.width  	def is_array(self): @@ -282,7 +280,7 @@ class glParameter( glItem ):  		glDeleteTextures), or a general variable length vector."""  		if self.is_array(): -			if self.p_count_parameters != None: +			if self.count_parameter_list:  				return "compsize"  			elif self.counter != None:  				return self.counter @@ -293,7 +291,7 @@ class glParameter( glItem ):  	def size(self): -		if self.p_count_parameters or self.counter or self.width or self.is_output: +		if self.count_parameter_list or self.counter or self.width or self.is_output:  			return 0  		elif self.p_count == 0:  			return self.p_type.size @@ -311,11 +309,11 @@ class glParameter( glItem ):  			if b_prod == 0:	b_prod = 1 -			if self.p_count_parameters == None and self.counter != None: +			if not self.count_parameter_list and self.counter != None:  				a_prod = self.counter -			elif self.p_count_parameters != None and self.counter == None: +			elif self.count_parameter_list and self.counter == None:  				pass -			elif self.p_count_parameters != None and self.counter != None: +			elif self.count_parameter_list and self.counter != None:  				b_prod = self.counter  			elif self.width:  				return "compsize" @@ -350,17 +348,12 @@ class glParameterIterator:  class glFunction( glItem ): -	real_name = "" -	fn_alias = None -	fn_offset = -1 -	fn_return_type = "void" -	fn_parameters = [] -  	def __init__(self, context, name, attrs):  		self.fn_alias = attrs.get('alias', None)  		self.fn_parameters = []  		self.image = None  		self.count_parameter_list = [] +		self.fn_return_type = "void"  		temp = attrs.get('offset', None)  		if temp == None or temp == "?": | 
