glapi: pass pointer size to python for glthread from meson
glthread (the python generator) needs to know the pointer size at compile time to sort structure fields of calls for optimal structure packing based on the CPU. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27350>
This commit is contained in:
@@ -37,6 +37,8 @@ project(
|
||||
cc = meson.get_compiler('c')
|
||||
cpp = meson.get_compiler('cpp')
|
||||
|
||||
sizeof_pointer = meson.get_compiler('c', native : true).sizeof('void*').to_string()
|
||||
|
||||
null_dep = dependency('', required : false)
|
||||
|
||||
if get_option('layout') != 'mirror'
|
||||
|
@@ -38,8 +38,8 @@ class glx_item_factory(gl_XML.gl_item_factory):
|
||||
def create_enum(self, element, context, category):
|
||||
return glx_enum(element, context, category)
|
||||
|
||||
def create_api(self):
|
||||
return glx_api(self)
|
||||
def create_api(self, pointer_type):
|
||||
return glx_api(self, pointer_type)
|
||||
|
||||
|
||||
class glx_enum(gl_XML.gl_enum):
|
||||
|
@@ -33,13 +33,13 @@ import typeexpr
|
||||
import static_data
|
||||
|
||||
|
||||
def parse_GL_API( file_name, factory = None ):
|
||||
def parse_GL_API(file_name, factory=None, pointer_size=0):
|
||||
|
||||
if not factory:
|
||||
factory = gl_item_factory()
|
||||
|
||||
api = factory.create_api()
|
||||
api.parse_file( file_name )
|
||||
api = factory.create_api(pointer_size)
|
||||
api.parse_file(file_name)
|
||||
|
||||
# After the XML has been processed, we need to go back and assign
|
||||
# dispatch offsets to the functions that request that their offsets
|
||||
@@ -855,12 +855,12 @@ class gl_item_factory(object):
|
||||
def create_parameter(self, element, context):
|
||||
return gl_parameter(element, context)
|
||||
|
||||
def create_api(self):
|
||||
return gl_api(self)
|
||||
def create_api(self, pointer_size):
|
||||
return gl_api(self, pointer_size)
|
||||
|
||||
|
||||
class gl_api(object):
|
||||
def __init__(self, factory):
|
||||
def __init__(self, factory, pointer_size):
|
||||
self.functions_by_name = OrderedDict()
|
||||
self.enums_by_name = {}
|
||||
self.types_by_name = {}
|
||||
@@ -871,6 +871,7 @@ class gl_api(object):
|
||||
self.factory = factory
|
||||
|
||||
self.next_offset = 0
|
||||
self.pointer_size = pointer_size
|
||||
|
||||
typeexpr.create_initial_types()
|
||||
return
|
||||
|
@@ -341,10 +341,12 @@ if __name__ == '__main__':
|
||||
file_name = sys.argv[1]
|
||||
file_index = int(sys.argv[2])
|
||||
file_count = int(sys.argv[3])
|
||||
pointer_size = int(sys.argv[4])
|
||||
except Exception:
|
||||
show_usage()
|
||||
|
||||
printer = PrintCode()
|
||||
|
||||
api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory())
|
||||
assert pointer_size != 0
|
||||
api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory(), pointer_size)
|
||||
printer.Print(api)
|
||||
|
@@ -86,18 +86,14 @@ def show_usage():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
file_name = 'gl_API.xml'
|
||||
|
||||
try:
|
||||
(args, trail) = getopt.getopt(sys.argv[1:], 'm:f:')
|
||||
file_name = sys.argv[1]
|
||||
pointer_size = int(sys.argv[2])
|
||||
except Exception:
|
||||
show_usage()
|
||||
|
||||
for (arg,val) in args:
|
||||
if arg == '-f':
|
||||
file_name = val
|
||||
|
||||
printer = PrintCode()
|
||||
|
||||
api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory())
|
||||
assert pointer_size != 0
|
||||
api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory(), pointer_size)
|
||||
printer.Print(api)
|
||||
|
@@ -89,10 +89,12 @@ def show_usage():
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
file_name = sys.argv[1]
|
||||
pointer_size = int(sys.argv[2])
|
||||
except Exception:
|
||||
show_usage()
|
||||
|
||||
printer = PrintCode()
|
||||
|
||||
api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory())
|
||||
assert pointer_size != 0
|
||||
api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory(), pointer_size)
|
||||
printer.Print(api)
|
||||
|
@@ -92,15 +92,15 @@ class marshal_function(gl_XML.gl_function):
|
||||
'GLhandleARB': 4,
|
||||
'int': 4,
|
||||
'float': 4,
|
||||
'GLintptr': self.context.pointer_size,
|
||||
'GLsizeiptr': self.context.pointer_size,
|
||||
'GLsync': self.context.pointer_size,
|
||||
'GLDEBUGPROC': self.context.pointer_size,
|
||||
'GLdouble': 8,
|
||||
'GLclampd': 8,
|
||||
'GLintptr': 8,
|
||||
'GLsizeiptr': 8,
|
||||
'GLint64': 8,
|
||||
'GLuint64': 8,
|
||||
'GLuint64EXT': 8,
|
||||
'GLsync': 8,
|
||||
'GLDEBUGPROC': 8,
|
||||
}
|
||||
val = mapping.get(type, 9999)
|
||||
if val == 9999:
|
||||
|
@@ -275,7 +275,7 @@ main_unmarshal_table_c = custom_target(
|
||||
'unmarshal_table.c',
|
||||
input : ['gl_unmarshal_table.py', 'gl_and_es_API.xml'],
|
||||
output : 'unmarshal_table.c',
|
||||
command : [prog_python, '@INPUT0@', '@INPUT1@'],
|
||||
command : [prog_python, '@INPUT0@', '@INPUT1@', sizeof_pointer],
|
||||
depend_files : files('marshal_XML.py') + glapi_gen_depends,
|
||||
capture : true,
|
||||
)
|
||||
@@ -286,7 +286,7 @@ foreach x : ['0', '1', '2', '3', '4', '5', '6', '7']
|
||||
'marshal_generated' + x + '.c',
|
||||
input : ['gl_marshal.py', 'gl_and_es_API.xml'],
|
||||
output : 'marshal_generated' + x + '.c',
|
||||
command : [prog_python, '@INPUT0@', '@INPUT1@', x, '8'],
|
||||
command : [prog_python, '@INPUT0@', '@INPUT1@', x, '8', sizeof_pointer],
|
||||
depend_files : files('marshal_XML.py') + glapi_gen_depends,
|
||||
capture : true,
|
||||
)
|
||||
|
@@ -31,7 +31,7 @@ main_marshal_generated_h = custom_target(
|
||||
'marshal_generated.h',
|
||||
input : [files('../../mapi/glapi/gen/gl_marshal_h.py'), gl_and_es_api_files],
|
||||
output : 'marshal_generated.h',
|
||||
command : [prog_python, '@INPUT0@', '-f', '@INPUT1@'],
|
||||
command : [prog_python, '@INPUT0@', '@INPUT1@', sizeof_pointer],
|
||||
depend_files : files('../../mapi/glapi/gen/marshal_XML.py') + glapi_gen_depends,
|
||||
capture : true,
|
||||
)
|
||||
|
Reference in New Issue
Block a user