aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2015-01-05 12:56:13 +0800
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-02-04 17:58:04 -0700
commitaf4c1e1f5504eb70f546ad1ee9bc265c42d7e4bc (patch)
tree0c9bc28d34cc3e68ce14572ac3c3555b6327db11
parent1f3f8a061a1da872b066c84841b552eee33e2ea2 (diff)
downloadusermoji-af4c1e1f5504eb70f546ad1ee9bc265c42d7e4bc.tar.xz
xgl-generate.py: add LayerGetProcAddrHelperSubcommand()
It generates layer_intercept_proc() to intercept all but xglInitAndEnumerateGpus(). It is possible to extend the subcommand to get the list of functions to intercept from command arguments or layer spec files. But we do not have the needs yet.
-rwxr-xr-xxgl-generate.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/xgl-generate.py b/xgl-generate.py
index eecf71b5..75a22313 100755
--- a/xgl-generate.py
+++ b/xgl-generate.py
@@ -321,12 +321,55 @@ class IcdGetProcAddrSubcommand(IcdDummyEntrypointsSubcommand):
return "\n".join(body)
+class LayerInterceptProcSubcommand(Subcommand):
+ def run(self):
+ self.prefix = "xgl"
+
+ # we could get the list from argv if wanted
+ self.intercepted = [proto.name for proto in self.protos
+ if proto.name not in ["InitAndEnumerateGpus"]]
+
+ for proto in self.protos:
+ if proto.name == "GetProcAddr":
+ self.gpa = proto
+
+ super().run()
+
+ def generate_header(self):
+ return "\n".join(["#include <string.h>", "#include \"xglLayer.h\""])
+
+ def generate_body(self):
+ lookups = []
+ for proto in self.protos:
+ if proto.name not in self.intercepted:
+ lookups.append("/* no %s%s */" % (self.prefix, proto.name))
+ continue
+
+ lookups.append("if (!strcmp(name, \"%s\"))" % proto.name)
+ lookups.append(" return (%s) %s%s;" %
+ (self.gpa.ret, self.prefix, proto.name))
+
+ body = []
+ body.append("static inline %s layer_intercept_proc(const char *name)" %
+ self.gpa.ret)
+ body.append("{")
+ body.append(generate_get_proc_addr_check("name"))
+ body.append("")
+ body.append(" name += 3;")
+ body.append(" %s" % "\n ".join(lookups))
+ body.append("")
+ body.append(" return NULL;")
+ body.append("}")
+
+ return "\n".join(body)
+
def main():
subcommands = {
"loader-entrypoints": LoaderEntrypointsSubcommand,
"dispatch-table-ops": DispatchTableOpsSubcommand,
"icd-dummy-entrypoints": IcdDummyEntrypointsSubcommand,
"icd-get-proc-addr": IcdGetProcAddrSubcommand,
+ "layer-intercept-proc": LayerInterceptProcSubcommand,
}
if len(sys.argv) < 2 or sys.argv[1] not in subcommands: