]> git.cworth.org Git - apitrace/blobdiff - scripts/tracecheck.py
Check for ARB_sampler_objects before dumping its state.
[apitrace] / scripts / tracecheck.py
index 28b0720fdd7cad6b3a7b0b2c5d7f63da04ebd57c..3a2ec452192f58dc99a31d524d20c1156ca86f06 100755 (executable)
@@ -39,6 +39,9 @@ import subprocess
 import sys
 import traceback
 
+import snapdiff
+import retracediff
+
 
 def good():
     '''Tell git-bisect that this commit is good.'''
@@ -110,6 +113,14 @@ def main():
         '-r', '--retrace', metavar='PROGRAM',
         type='string', dest='retrace', default='glretrace',
         help='retrace command [default: %default]')
+    optparser.add_option(
+        '-c', '--compare', metavar='PREFIX',
+        type='string', dest='compare_prefix', default=None,
+        help='snapshot comparison prefix')
+    optparser.add_option(
+        '--precision-threshold', metavar='BITS',
+        type='float', dest='precision_threshold', default=8.0,
+        help='precision threshold in bits [default: %default]')
     optparser.add_option(
         '--gl-renderer', metavar='REGEXP',
         type='string', dest='gl_renderer_re', default='^.*$',
@@ -134,9 +145,9 @@ def main():
     # implementation is usable, and is the right one (i.e., we didn't fallback
     # to a different OpenGL implementation due to missing symbols).
     if platform.system() != 'Windows' and which('glxinfo'):
-        p = subprocess.Popen(['glxinfo'], stdout=subprocess.PIPE)
-        stdout, stderr = p.communicate()
-        if p.returncode:
+        glxinfo = subprocess.Popen(['glxinfo'], stdout=subprocess.PIPE)
+        stdout, stderr = glxinfo.communicate()
+        if glxinfo.returncode:
             skip()
 
         # Search for the GL_RENDERER string
@@ -145,6 +156,9 @@ def main():
         for line in stdout.split('\n'):
             if line.startswith(gl_renderer_header):
                 gl_renderer = line[len(gl_renderer_header):]
+            if line.startswith('direct rendering: No'):
+                sys.stderr.write('Indirect rendering.\n')
+                skip()
 
         # and match it against the regular expression specified in the command
         # line.
@@ -153,13 +167,48 @@ def main():
             skip()
 
     # Run glretrace
-    retrace = [options.retrace] + args
-    sys.stdout.write(' '.join(retrace) + '\n')
-    sys.stdout.flush()
-    returncode = subprocess.call(retrace)
-    if returncode:
-        # TODO: allow other criterias here, such as, snapshot comparison or performance threshold
-        bad()
+    
+    retracer = retracediff.Retracer(options.retrace, args)
+
+    if options.compare_prefix:
+        refImages = {}
+        callNos = []
+            
+        images = snapdiff.find_images(options.compare_prefix)
+        images.sort()
+        for image in images:
+            imageName, ext = os.path.splitext(image)
+            try:
+                callNo = int(imageName)
+            except ValueError:
+                continue
+            refImages[callNo] = options.compare_prefix + image
+            callNos.append(callNo)
+
+        run = retracer.snapshot(','.join(map(str, callNos)))
+        while True:
+            srcImage, callNo = run.nextSnapshot()
+            if srcImage is None:
+                break
+
+            refImage = refImages[callNo]
+
+            # Compare the two images
+            comparer = snapdiff.Comparer(refImage, srcImage)
+            precision = comparer.precision()
+
+            mismatch = precision < options.precision_threshold
+            if mismatch:
+                bad()
+        run.process.wait()
+        if run.process.returncode:
+            skip()
+    else:
+        returncode = retracer.retrace('-b')
+        if returncode:
+            bad()
+
+    # TODO: allow more criterias here, such as, performance threshold
 
     # Success
     good()