diff options
| author | Chia-I Wu <olv@lunarg.com> | 2015-01-02 00:21:24 +0800 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-02-04 17:58:02 -0700 |
| commit | acf299cb4386742ca71c12aed9e2cd040c79454e (patch) | |
| tree | 8865b006f92fa8049a7fa0a59468c4037de3f25e | |
| parent | e0c2c068d6a514becfa36d057d3b13b33aa6b37c (diff) | |
| download | usermoji-acf299cb4386742ca71c12aed9e2cd040c79454e.tar.xz | |
xgl-generate.py: fork _generate_dispatch_entrypoints()
Both LoaderSubcommand and IcdDispatchEntrypointsSubcommand called
_generate_dispatch_entrypoints() yet they have very different needs. Rename
the function to _generate_loader_dispatch_entrypoints() and make it
LoaderSubcommand specific. Add a new entrypoint generating function for
IcdDispatchEntrypointsSubcommand.
| -rwxr-xr-x | xgl-generate.py | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/xgl-generate.py b/xgl-generate.py index 585bff7e..99bd5047 100755 --- a/xgl-generate.py +++ b/xgl-generate.py @@ -92,7 +92,11 @@ class Subcommand(object): def generate_footer(self): pass - def _generate_dispatch_entrypoints(self, qual=""): +class LoaderSubcommand(Subcommand): + def generate_header(self): + return "#include \"loader.h\"" + + def _generate_loader_dispatch_entrypoints(self, qual=""): if qual: qual += " " @@ -102,7 +106,7 @@ class Subcommand(object): continue decl = proto.c_func(prefix="xgl", attr="XGLAPI") stmt = "(*disp)->%s" % proto.c_call() - if proto.name == "CreateDevice" and qual == "LOADER_EXPORT ": + if proto.name == "CreateDevice": funcs.append("%s%s\n" "{\n" " loader_activate_layers(%s, %s);\n" @@ -125,7 +129,7 @@ class Subcommand(object): " *(const XGL_LAYER_DISPATCH_TABLE **) (*%s) = *disp;\n" " return res;\n" "}" % (qual, decl, proto.params[0].name, stmt, proto.params[-1].name)) - elif proto.name == "GetMultiGpuCompatibility" and qual == "LOADER_EXPORT ": + elif proto.name == "GetMultiGpuCompatibility": funcs.append("%s%s\n" "{\n" " XGL_BASE_LAYER_OBJECT* wrapped_obj0 = (XGL_BASE_LAYER_OBJECT*)%s;\n" @@ -137,7 +141,7 @@ class Subcommand(object): " return %s;\n" "}" % (qual, decl, proto.params[0].name, proto.params[1].name, proto.params[0].name, proto.params[1].name, stmt)) - elif proto.params[0].ty != "XGL_PHYSICAL_GPU" or qual != "LOADER_EXPORT ": + elif proto.params[0].ty != "XGL_PHYSICAL_GPU": if proto.ret != "XGL_VOID": stmt = "return " + stmt funcs.append("%s%s\n" @@ -160,12 +164,8 @@ class Subcommand(object): return "\n\n".join(funcs) -class LoaderSubcommand(Subcommand): - def generate_header(self): - return "#include \"loader.h\"" - def generate_body(self): - body = [self._generate_dispatch_entrypoints("LOADER_EXPORT")] + body = [self._generate_loader_dispatch_entrypoints("LOADER_EXPORT")] return "\n\n".join(body) @@ -173,8 +173,31 @@ class IcdDispatchEntrypointsSubcommand(Subcommand): def generate_header(self): return "#include \"icd.h\"" + def _generate_icd_dispatch_entrypoints(self, qual=""): + if qual: + qual += " " + + funcs = [] + for proto in self.protos: + if not xgl.is_dispatchable(proto): + continue + + decl = proto.c_func(prefix="xgl", attr="XGLAPI") + stmt = "(*disp)->%s" % proto.c_call() + if proto.ret != "XGL_VOID": + stmt = "return " + stmt + + funcs.append("%s%s\n" + "{\n" + " const XGL_LAYER_DISPATCH_TABLE * const *disp =\n" + " (const XGL_LAYER_DISPATCH_TABLE * const *) %s;\n" + " %s;\n" + "}" % (qual, decl, proto.params[0].name, stmt)) + + return "\n\n".join(funcs) + def generate_body(self): - return self._generate_dispatch_entrypoints("ICD_EXPORT") + return self._generate_icd_dispatch_entrypoints("ICD_EXPORT") class IcdDispatchDummyImplSubcommand(Subcommand): def run(self): |
