rd_cbraw.py 1.3 KB

1234567891011121314151617181920212223
  1. import os, struct, renderdoc as rd
  2. # raw float dump of every constant buffer bound to VS/GS/PS for EIDS (names are stripped in WE's DXBC)
  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. for eid in [int(x) for x in os.environ['EIDS'].split(',')]:
  7. ctl.SetFrameEvent(eid,True)
  8. s=ctl.GetPipelineState()
  9. out.write('== %d\n'%eid)
  10. for stage in (rd.ShaderStage.Vertex, rd.ShaderStage.Geometry, rd.ShaderStage.Pixel):
  11. refl=s.GetShaderReflection(stage)
  12. if refl is None: continue
  13. for i,cb in enumerate(refl.constantBlocks):
  14. d=s.GetConstantBlock(stage,i,0).descriptor
  15. if d.resource==rd.ResourceId.Null(): continue
  16. data=ctl.GetBufferData(d.resource,d.byteOffset,min(d.byteSize,1024))
  17. fl=struct.unpack('<%df'%(len(data)//4),data[:len(data)//4*4])
  18. out.write(' %s cb%d %s size=%d\n'%(stage,i,cb.name,d.byteSize))
  19. for r in range(0,len(fl),4): out.write(' [%2d] %s\n'%(r//4,' '.join('%.6g'%x for x in fl[r:r+4])))
  20. if os.environ.get('DIS') and stage==getattr(rd.ShaderStage,os.environ.get('DIS')):
  21. t=ctl.DisassembleShader(s.GetGraphicsPipelineObject(),refl,'')
  22. out.write(t[:6000]+'\n')
  23. ctl.Shutdown(); cap.Shutdown(); out.close(); os._exit(0)