rd_draws.py 979 B

1234567891011121314151617181920
  1. import os, renderdoc as rd
  2. # every draw with its index count, render targets and fragment textures (id WxH format)
  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. def desc(r):
  8. t=texs.get(r)
  9. return '%s(%dx%d %s)'%(int(r),t.width,t.height,t.format.Name()) if t else str(int(r))
  10. def walk(a):
  11. for c in a:
  12. if c.flags & rd.ActionFlags.Drawcall:
  13. ctl.SetFrameEvent(c.eventId,True)
  14. s=ctl.GetPipelineState()
  15. ro=[desc(x.descriptor.resource) for x in s.GetReadOnlyResources(rd.ShaderStage.Fragment)]
  16. outs=[desc(o) for o in c.outputs if o!=rd.ResourceId.Null()]
  17. out.write('%d n=%d inst=%d outs=%s tex=%s\n'%(c.eventId,c.numIndices,c.numInstances,outs,ro))
  18. walk(c.children)
  19. walk(ctl.GetRootActions())
  20. ctl.Shutdown(); cap.Shutdown(); out.close(); os._exit(0)