egl: fix _eglMatchDriver() return type
[mesa.git] / .gitlab-ci / tracie / dump_trace_images.py
index 6a3ed6b18e668af3cea42575bd2cf0617201fa8f..e5cf6489a5c2c99af9cc0d7680d558e4dbcec193 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/python3
 
 # Copyright (c) 2019 Collabora Ltd
-# Copyright © 2019 Valve Corporation.
+# Copyright © 2019-2020 Valve Corporation.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -48,8 +48,8 @@ def run_logged_command(cmd, env, log_path):
             logoutput.decode(errors='replace') +
             "[dump_traces_images] Process failed with error code: %d" % ret.returncode)
 
-def get_last_apitrace_frame_call(trace_path):
-    cmd = ["apitrace", "dump", "--calls=frame", str(trace_path)]
+def get_last_apitrace_frame_call(cmd_wrapper, trace_path):
+    cmd = cmd_wrapper + ["apitrace", "dump", "--calls=frame", str(trace_path)]
     ret = subprocess.run(cmd, stdout=subprocess.PIPE)
     for l in reversed(ret.stdout.decode(errors='replace').splitlines()):
         s = l.split(None, 1)
@@ -58,27 +58,24 @@ def get_last_apitrace_frame_call(trace_path):
     return -1
 
 def get_last_gfxreconstruct_frame_call(trace_path):
-    # FIXME: It would be great to have another way to get the amount of
-    # traces which wouldn't imply replaying the whole trace:
-    # https://github.com/LunarG/gfxreconstruct/issues/329
-    cmd = ["gfxrecon-replay", str(trace_path)]
+    cmd = ["gfxrecon-info", str(trace_path)]
     ret = subprocess.run(cmd, stdout=subprocess.PIPE)
-    for l in reversed(ret.stdout.decode(errors='replace').splitlines()):
-        s = l.split(", ", 2)
-        if len(s) >= 3:
-            c = s[2].split(None, 1)
-            if len(c) >= 1 and c[0].isnumeric():
-                return int(c[0])
+    lines = ret.stdout.decode(errors='replace').splitlines()
+    if len(lines) >= 1:
+        c = lines[0].split(": ", 1)
+        if len(c) >= 2 and c[1].isnumeric():
+            return int(c[1])
     return -1
 
-def dump_with_apitrace(trace_path, calls, device_name):
+def dump_with_apitrace(retrace_cmd, trace_path, calls, device_name):
     outputdir = str(trace_path.parent / "test" / device_name)
     os.makedirs(outputdir, exist_ok=True)
     outputprefix = str(Path(outputdir) / trace_path.name) + "-"
     if len(calls) == 0:
-        calls = [str(get_last_apitrace_frame_call(trace_path))]
-    cmd = ["apitrace", "dump-images", "--calls=" + ','.join(calls),
-           "-o", outputprefix, str(trace_path)]
+        calls = [str(get_last_apitrace_frame_call(retrace_cmd[:-1], trace_path))]
+    cmd = retrace_cmd + ["--headless",
+                         "--snapshot=" + ','.join(calls),
+                         "--snapshot-prefix=" + outputprefix, str(trace_path)]
     log_path = Path(outputdir) / (trace_path.name + ".log")
     run_logged_command(cmd, None, log_path)
 
@@ -137,7 +134,9 @@ def dump_from_trace(trace_path, calls, device_name):
     trace_type = trace_type_from_filename(trace_path.name)
     try:
         if trace_type == TraceType.APITRACE:
-            dump_with_apitrace(trace_path, calls, device_name)
+            dump_with_apitrace(["eglretrace"], trace_path, calls, device_name)
+        elif trace_type == TraceType.APITRACE_DXGI:
+            dump_with_apitrace(["wine", "d3dretrace"], trace_path, calls, device_name)
         elif trace_type == TraceType.RENDERDOC:
             dump_with_renderdoc(trace_path, calls, device_name)
         elif trace_type == TraceType.GFXRECONSTRUCT: