mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
intel/genxml: Only handle instructions meant for render engine when generating
headers v2: Fixed the check for engine v3: Changed engine into an argument given to the scripts Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
parent
ce6faa57ae
commit
b6f7b40d81
2 changed files with 59 additions and 7 deletions
|
|
@ -266,6 +266,10 @@ class XmlParser(object):
|
|||
if name == 'genxml':
|
||||
self.gen = Gen(attrs['gen'])
|
||||
elif name in ('instruction', 'struct', 'register'):
|
||||
if name == 'instruction' and 'engine' in attrs:
|
||||
engines = set(attrs['engine'].split('|'))
|
||||
if not engines & self.engines:
|
||||
return
|
||||
self.start_container(attrs)
|
||||
elif name == 'field':
|
||||
self.start_field(attrs)
|
||||
|
|
@ -304,6 +308,8 @@ def parse_args():
|
|||
help="If OUTPUT is unset or '-', then it defaults to '/dev/stdout'")
|
||||
p.add_argument('--cpp-guard', type=str,
|
||||
help='If unset, then CPP_GUARD is derived from OUTPUT.')
|
||||
p.add_argument('--engines', nargs='?', type=str, default='render',
|
||||
help="Comma-separated list of engines whose instructions should be parsed (default: %(default)s)")
|
||||
p.add_argument('xml_sources', metavar='XML_SOURCE', nargs='+')
|
||||
|
||||
pargs = p.parse_args()
|
||||
|
|
@ -319,11 +325,21 @@ def parse_args():
|
|||
def main():
|
||||
pargs = parse_args()
|
||||
|
||||
engines = pargs.engines.split(',')
|
||||
valid_engines = [ 'render', 'blitter', 'video' ]
|
||||
if set(engines) - set(valid_engines):
|
||||
print("Invalid engine specified, valid engines are:\n")
|
||||
for e in valid_engines:
|
||||
print("\t%s" % e)
|
||||
sys.exit(1)
|
||||
|
||||
# Maps name => Container
|
||||
containers = {}
|
||||
|
||||
for source in pargs.xml_sources:
|
||||
XmlParser(containers).parse(source)
|
||||
p = XmlParser(containers)
|
||||
p.engines = set(engines)
|
||||
p.parse(source)
|
||||
|
||||
with open(pargs.output, 'wb') as f:
|
||||
f.write(TEMPLATE.render(containers=containers, guard=pargs.cpp_guard))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
from __future__ import (
|
||||
absolute_import, division, print_function, unicode_literals
|
||||
)
|
||||
import argparse
|
||||
import ast
|
||||
import xml.parsers.expat
|
||||
import re
|
||||
|
|
@ -545,6 +546,13 @@ class Parser(object):
|
|||
if name == "instruction":
|
||||
self.instruction = safe_name(attrs["name"])
|
||||
self.length_bias = int(attrs["bias"])
|
||||
if "engine" in attrs:
|
||||
self.instruction_engines = set(attrs["engine"].split('|'))
|
||||
else:
|
||||
# When an instruction doesn't have the engine specified,
|
||||
# it is considered to be for all engines, so 'None' is used
|
||||
# to signify that the instruction belongs to all engines.
|
||||
self.instruction_engines = None
|
||||
elif name == "struct":
|
||||
self.struct = safe_name(attrs["name"])
|
||||
self.structs[attrs["name"]] = 1
|
||||
|
|
@ -628,6 +636,9 @@ class Parser(object):
|
|||
|
||||
def emit_instruction(self):
|
||||
name = self.instruction
|
||||
if self.instruction_engines and not self.instruction_engines & self.engines:
|
||||
return
|
||||
|
||||
if not self.length is None:
|
||||
print('#define %-33s %6d' %
|
||||
(self.gen_prefix(name + "_length"), self.length))
|
||||
|
|
@ -688,11 +699,36 @@ class Parser(object):
|
|||
self.parser.ParseFile(file)
|
||||
file.close()
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("No input xml file specified")
|
||||
sys.exit(1)
|
||||
def parse_args():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('xml_source', metavar='XML_SOURCE',
|
||||
help="Input xml file")
|
||||
p.add_argument('--engines', nargs='?', type=str, default='render',
|
||||
help="Comma-separated list of engines whose instructions should be parsed (default: %(default)s)")
|
||||
|
||||
input_file = sys.argv[1]
|
||||
pargs = p.parse_args()
|
||||
|
||||
p = Parser()
|
||||
p.parse(input_file)
|
||||
if pargs.engines is None:
|
||||
print("No engines specified")
|
||||
sys.exit(1)
|
||||
|
||||
return pargs
|
||||
|
||||
def main():
|
||||
pargs = parse_args()
|
||||
|
||||
input_file = pargs.xml_source
|
||||
engines = pargs.engines.split(',')
|
||||
valid_engines = [ 'render', 'blitter', 'video' ]
|
||||
if set(engines) - set(valid_engines):
|
||||
print("Invalid engine specified, valid engines are:\n")
|
||||
for e in valid_engines:
|
||||
print("\t%s" % e)
|
||||
sys.exit(1)
|
||||
|
||||
p = Parser()
|
||||
p.engines = set(engines)
|
||||
p.parse(input_file)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue