+ run_logged_command(cmd, None, log_path)
+
+def dump_with_gfxreconstruct(trace_path, calls, device_name):
+ from PIL import Image
+ outputdir_path = trace_path.parent / "test" / device_name
+ outputdir_path.mkdir(parents=True, exist_ok=True)
+ outputprefix = str(outputdir_path / trace_path.name) + "-"
+ if len(calls) == 0:
+ # FIXME: The VK_LAYER_LUNARG_screenshot numbers the calls from
+ # 0 to (total-num-calls - 1) while gfxreconstruct does it from
+ # 1 to total-num-calls:
+ # https://github.com/LunarG/gfxreconstruct/issues/284
+ calls = [str(get_last_gfxreconstruct_frame_call(trace_path) - 1)]
+ cmd = ["gfxrecon-replay", str(trace_path)]
+ log_path = outputdir_path / (trace_path.name + ".log")
+ env = os.environ.copy()
+ env["VK_INSTANCE_LAYERS"] = "VK_LAYER_LUNARG_screenshot"
+ env["VK_SCREENSHOT_FRAMES"] = ",".join(calls)
+ env["VK_SCREENSHOT_DIR"] = str(outputdir_path)
+ run_logged_command(cmd, env, log_path)
+ for c in calls:
+ ppm = str(outputdir_path / c) + ".ppm"
+ outputfile = outputprefix + c + ".png"
+ with log_path.open(mode='w') as log:
+ log.write("Writing: %s to %s" % (ppm, outputfile))
+ Image.open(ppm).save(outputfile)
+ os.remove(ppm)