From: José Fonseca Date: Tue, 11 Dec 2012 19:51:26 +0000 (+0000) Subject: scripts: New script to convert to PIX. X-Git-Url: https://git.cworth.org/git?p=apitrace;a=commitdiff_plain;h=2cce1925a7987c009e631cafbc8459be056e229c scripts: New script to convert to PIX. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c4c7748..91f1b87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,6 +358,12 @@ install ( scripts/unpickle.py DESTINATION ${SCRIPTS_INSTALL_DIR} ) +if (WIN32) + install ( + PROGRAMS scripts/convert.py + DESTINATION ${SCRIPTS_INSTALL_DIR} + ) +endif () ############################################################################## # GUI diff --git a/scripts/apitrace.PIXExp b/scripts/apitrace.PIXExp new file mode 100644 index 0000000..c7b031e --- /dev/null +++ b/scripts/apitrace.PIXExp @@ -0,0 +1,2 @@ + +2020001EDID103%dEvent Type203%dEID303%dParent EID403%dChildren1106%dParent1002%dFlags5020x%08XEvent604%sStartTime705%I64iPath1301%sPath21401%sVersion1501%sTimeLastModified1601%sProcessID2303%dSessionStartTimeStamp2405%I64iFrame903%dDuration805%I64iMeasured Est. Draw Duration (ns)2705%I64iFPS1200%0.01fThisEventPos2105%I64iNextSiblingPos2205%I64iUser Event Name1701%sPackedCallPackage1907Object Pointer20020x%08XSession Start111(edid)2CalcOnLoad,Const,13(eid)4CalcOnLoad,Const,-15CalcOnLoad,Const,07CalcOnLoad,Const,08CalcOnLoad,Const,06CalcOnLoad,FormatText,0,Start Session13(expfilepath)14(runfilepath)24(sessionstarttimestamp)Session End221(edid)2CalcOnLoad,Const,23(eid)4CalcOnLoad,Const,-15CalcOnLoad,Const,07(time)8CalcOnLoad,Const,06CalcOnLoad,FormatText,0,End SessionProcess Start331(edid)2CalcOnLoad,Const,33(eid)4CalcOnLoad,Const,-15CalcOnLoad,Const,07CalcOnLoad,Const,08CalcOnLoad,Const,06CalcOnLoad,FormatText,0,Start Process13(processpath)15(processversion)16(processtimelastmodified)23(processid)Process End441(edid)2CalcOnLoad,Const,43(eid)4CalcOnLoad,Const,-15CalcOnLoad,Const,07(time)8CalcOnLoad,Const,06CalcOnLoad,FormatText,0,End Process13(processpath)Frame Begin551(edid)2CalcOnLoad,Const,53(eid)4(parenteid)11CalcOnLoad,Const,05(rowflags)7(time)9(frame)6CalcOnLoad,FormatText,1,Frame %d,3,MemberOf,ThisRow,Frame8Async,(duration)12CalcOnLoad,Divide,Const,1000000000.0,MemberOf,ThisRow,Duration21(frameeventfilepos)22(lastframeeventfilepos)User Event Begin761(edid)2CalcOnLoad,Const,73(eid)4(parenteid)10CalcOnLoad,Const,011CalcOnLoad,Const,05CalcOnLoad,Const,07(time)17(usereventname)6CalcOnLoad,FormatText,1,%s,1,MemberOf,ThisRow,User Event Name8Async,(duration)User Marker971(edid)2CalcOnLoad,Const,93(eid)4(parenteid)10CalcOnLoad,Const,011CalcOnLoad,Const,05CalcOnLoad,Const,07(time)17(usereventname)6CalcOnLoad,FormatText,1,User Marker: %s,1,MemberOf,ThisRow,User Event Name8CalcOnLoad,Const,0D3D Call1081(edid)2CalcOnLoad,Const,103(eid)4(parenteid)11CalcOnLoad,Const,010CalcOnLoad,Const,05CalcOnLoad,Const,07(time)6CalcOnLoad,CallPlusParams,MemberOf,ThisRow,PackedCallPackage19Async,(packedcallpkg)27Async,(drawduration)Object Creation1191(edid)2CalcOnLoad,Const,113(eid)4(parenteid)11CalcOnLoad,Const,010CalcOnLoad,Const,05CalcOnLoad,Const,07(time)6CalcOnLoad,FormatText,0,Object Creation20(objpointer)Object Population12101(edid)2CalcOnLoad,Const,123(eid)4(parenteid)11CalcOnLoad,Const,010CalcOnLoad,Const,05CalcOnLoad,Const,07(time)6CalcOnLoad,FormatText,0,Object Population20(objpointer)D3D Call (Sync)13111(edid)2CalcOnLoad,Const,133(eid)4(parenteid)11CalcOnLoad,Const,010CalcOnLoad,Const,05CalcOnLoad,Const,07(time)6CalcOnLoad,CallPlusParams,MemberOf,ThisRow,PackedCallPackage19(packedcallpkg)1010330 diff --git a/scripts/convert.py b/scripts/convert.py new file mode 100755 index 0000000..dffad3f --- /dev/null +++ b/scripts/convert.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python +########################################################################## +# +# Copyright 2012 VMware Inc. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the 'Software'), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +##########################################################################/ + +'''Convert traces to/from PIX. +''' + + +import optparse +import os.path +import subprocess +import platform +import sys + + +def convert(inTrace, outPixrun): + try: + dxsdkDir = os.environ['DXSDK_DIR'] + except KeyError: + dxsdkDir = os.path.join(programFiles, "Microsoft DirectX SDL (June 2010)") + pix = os.path.join(dxsdkDir, "Utilities", "bin", 'x86', 'PIXwin.exe') + + pixExp = os.path.join(os.path.dirname(__file__), 'apitrace.PIXExp') + + # http://social.msdn.microsoft.com/Forums/sv/devdocs/thread/15addc0c-036d-413a-854a-35637ccbb834 + # http://src.chromium.org/svn/trunk/o3d/tests/test_driver.py + cmd = [ + pix, + pixExp, + '-start', + '-runfile', os.path.abspath(outPixrun), + '-targetpath', os.path.abspath(options.retrace), + #'-targetstartfolder', ..., + '-targetargs', os.path.abspath(inTrace), + ] + + if options.verbose: + sys.stderr.write(' '.join(cmd) + '\n') + + ret = subprocess.call(cmd) + if ret: + sys.stderr.write('error: pix failued with exit code %u\n' % ret) + sys.exit(ret) + if os.path.exists(outPixrun): + sys.stderr.write('info: %s written\n' % outPixrun) + if False: + subprocess.call([pix, os.path.abspath(outPixrun)]) + else: + sys.stderr.write('error: %s not written\n' % outPixrun) + sys.exit(1) + + +def main(): + global options + + # Parse command line options + optparser = optparse.OptionParser( + usage='\n\t%prog [options] ...', + version='%%prog') + optparser.add_option( + '-r', '--retrace', metavar='PROGRAM', + type='string', dest='retrace', default='d3dretrace', + help='retrace command [default: %default]') + optparser.add_option( + '-v', '--verbose', + action='store_true', dest='verbose', default=False, + help='verbose output') + optparser.add_option( + '-o', '--output', metavar='FILE', + type="string", dest="output", + help="output file [default: stdout]") + + (options, args) = optparser.parse_args(sys.argv[1:]) + if not args: + optparser.error("incorrect number of arguments") + + for arg in args: + if options.output: + output = options.output + else: + name, ext = os.path.splitext(os.path.basename(arg)) + output = name + '.PIXRun' + convert(arg, output) + + +if __name__ == '__main__': + main()