rd_depthpass.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import os, traceback, renderdoc as rd
  2. # depth-only draws (shadow passes): rasterizer, depth state and viewports; env CAP, OUT
  3. out=open(os.environ['OUT'],'w')
  4. cap=rd.OpenCaptureFile(); cap.OpenFile(os.environ['CAP'],'',None)
  5. st,ctl=cap.OpenCapture(rd.ReplayOptions(),None)
  6. texs={t.resourceId:t for t in ctl.GetTextures()}
  7. draws=[]
  8. def walk(a):
  9. for c in a:
  10. if c.flags & rd.ActionFlags.Drawcall: draws.append(c)
  11. walk(c.children)
  12. walk(ctl.GetRootActions())
  13. def fields(o):
  14. return {k: str(getattr(o, k)) for k in dir(o) if not k.startswith('_') and not callable(getattr(o, k))}
  15. try:
  16. n = 0
  17. for c in draws:
  18. ctl.SetFrameEvent(c.eventId, True)
  19. vk = ctl.GetVulkanPipelineState()
  20. p = ctl.GetPipelineState()
  21. depth = p.GetDepthTarget()
  22. outs = [o for o in p.GetOutputTargets() if o.resource != rd.ResourceId.Null()]
  23. if depth.resource == rd.ResourceId.Null() or outs:
  24. continue
  25. t = texs.get(depth.resource)
  26. out.write('eid %d idx %d inst %d depth %s %dx%d fmt %s\n' % (c.eventId, c.numIndices, c.numInstances, depth.resource, t.width, t.height, t.format.Name()))
  27. out.write(' rast %s\n' % fields(vk.rasterizer))
  28. out.write(' ds %s\n' % fields(vk.depthStencil))
  29. out.write(' vps %s\n' % [(v.vp.x, v.vp.y, v.vp.width, v.vp.height) for v in vk.viewportScissor.viewportScissors][:6])
  30. n += 1
  31. if n > 8:
  32. break
  33. except Exception:
  34. out.write(traceback.format_exc())
  35. ctl.Shutdown(); cap.Shutdown(); out.close(); os._exit(0)