rd_trigger.py 977 B

1234567891011121314151617181920212223242526272829
  1. # qrenderdoc --python rd_trigger.py: one-frame capture of the RenderDoc-hooked process RD_PID, path written to RD_TRIGGER_OUT
  2. import os, time, renderdoc as rd
  3. log = open(os.environ['RD_TRIGGER_OUT'], 'w', buffering=1)
  4. pid = int(os.environ['RD_PID'])
  5. ident = 0
  6. while True:
  7. ident = rd.EnumerateRemoteTargets('localhost', ident)
  8. if ident == 0:
  9. break
  10. tc = rd.CreateTargetControl('localhost', ident, 'we_live', True)
  11. if tc is None:
  12. continue
  13. if tc.GetPID() != pid:
  14. tc.Shutdown()
  15. continue
  16. tc.TriggerCapture(1)
  17. deadline = time.time() + 40
  18. while time.time() < deadline:
  19. msg = tc.ReceiveMessage(None)
  20. if msg.type == rd.TargetControlMessageType.NewCapture:
  21. log.write(msg.newCapture.path + '\n')
  22. break
  23. if msg.type == rd.TargetControlMessageType.Disconnected:
  24. log.write('disconnected\n')
  25. break
  26. tc.Shutdown()
  27. break
  28. log.write('done\n')
  29. os._exit(0)