summaryrefslogtreecommitdiff
path: root/scripts/convert.py
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2015-03-26 15:21:46 +0000
committerJosé Fonseca <jfonseca@vmware.com>2015-03-26 15:23:04 +0000
commit7b5e68d0fe2eff97b6bd3ea1508cbfa0bfff08bf (patch)
treeb28fc182515989923954779156f6660f30bd529b /scripts/convert.py
parent2eef9ee231a89a9aab74da01dce93584d5f482ee (diff)
convert: Auto-detect API.
Diffstat (limited to 'scripts/convert.py')
-rwxr-xr-xscripts/convert.py40
1 files changed, 36 insertions, 4 deletions
diff --git a/scripts/convert.py b/scripts/convert.py
index 9be7f4bb..0da7bf5d 100755
--- a/scripts/convert.py
+++ b/scripts/convert.py
@@ -96,22 +96,54 @@ def convertToPix(inTrace, outPixrun):
sys.exit(1)
+def detectApiFromCsv(inCsv):
+ import csv
+ csvReader = csv.reader(open(inCsv, 'rt'), )
+ for row in csvReader:
+ print row
+ event = row[2]
+ print event
+ if event.startswith("Direct3DCreate9"):
+ return "d3d9"
+ if event.startswith("CreateDXGIFactory"):
+ return "dxgi"
+ if event.startswith("D3D10CreateDevice"):
+ return "d3d10"
+ if event.startswith("D3D11CreateDevice"):
+ return "d3d11"
+ assert False
+
+
def convertFromPix(inPix, outTrace):
pixExe = getPixExe()
- if False:
- # TODO: Use -exporttocsv option to detect which API to use
+ api = options.api
+
+ if True:
+ # Use -exporttocsv option to detect which API to use
cmd = [
pixExe,
inPix,
- '-exporttocsv', # XXX: output filename is ignored
+ '-exporttocsv',
]
+
+ # XXX: output filename is ignored
+ inPixDir, inPixFileName = os.path.split(inPix)
+ inPixName, inPixExt = os.path.splitext(inPixFileName)
+ outCsv = os.path.join(inPixDir, inPixName + '.csv')
+
+ if os.path.exists(outCsv):
+ os.remove(outCsv)
+
callProcess(cmd)
+ if os.path.isfile(outCsv):
+ api = detectApiFromCsv(outCsv)
+
cmd = [
options.apitrace,
'trace',
- '-a', options.api,
+ '-a', api,
'-o', outTrace,
pixExe,
inPix,