ci: Don't call renderdoc's ReplayController.Shutdown()
[mesa.git] / .gitlab-ci / tracie / renderdoc_dump_images.py
index 689ee2d0a87e0f87f64f70d4eb39507569906dde..a89b5fda7947d76baacb10801502520d84e37b96 100755 (executable)
 #
 # SPDX-License-Identifier: MIT
 
+import atexit
+import os
+import shutil
 import sys
+import tempfile
 from pathlib import Path
 
+def cleanup(dirpath):
+        shutil.rmtree(dirpath)
+
+dirpath = tempfile.mkdtemp()
+atexit.register(cleanup, dirpath)
+RENDERDOC_DEBUG_FILE = dirpath + "/renderdoc.log"
+
+# Needs to be in the environment before importing the module
+os.environ['RENDERDOC_DEBUG_LOG_FILE'] = RENDERDOC_DEBUG_FILE
 import renderdoc as rd
 
 def findDrawWithEventId(controller, eventId):
@@ -75,11 +88,16 @@ def loadCapture(filename):
     if not cap.LocalReplaySupport():
         raise RuntimeError("Capture cannot be replayed")
 
-    status,controller = cap.OpenCapture(rd.ReplayOptions(), None)
+    status, controller = cap.OpenCapture(rd.ReplayOptions(), None)
 
     if status != rd.ReplayStatus.Succeeded:
+        if os.path.exists(RENDERDOC_DEBUG_FILE):
+            print(open(RENDERDOC_DEBUG_FILE, "r").read())
         raise RuntimeError("Couldn't initialise replay: " + str(status))
 
+    if os.path.exists(RENDERDOC_DEBUG_FILE):
+        open(RENDERDOC_DEBUG_FILE, "w").write("")
+
     return (cap, controller)
 
 def renderdoc_dump_images(filename, eventIds, outputDir):
@@ -94,7 +112,6 @@ def renderdoc_dump_images(filename, eventIds, outputDir):
    for eventId in eventIds:
       dumpImage(controller, eventId, outputDir, tracefile)
 
-   controller.Shutdown()
    cap.Shutdown()
 
    rd.ShutdownReplay()