ext_gpu_shader4: add compiler tests for everything
[piglit.git] / framework / driver_classifier.py
blobc36b353967c7badf6bc891bd8ac22cce1713d956
1 # coding=utf-8
2 # Copyright (c) 2016 Broadcom
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the "Software"),
6 # to deal in the Software without restriction, including without limitation
7 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 # and/or sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice (including the next
12 # paragraph) shall be included in all copies or substantial portions of the
13 # Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 # IN THE SOFTWARE.
23 from __future__ import (
24 absolute_import, division, print_function, unicode_literals
26 import errno
27 import re
28 import subprocess
30 __all__ = [
31 'DriverClassifier',
34 class DriverClassifier(object):
35 def __init__(self):
36 self.categories = []
38 self.collect_driver_info()
39 self.find_categories()
42 def collect_driver_info(self):
43 """Method for collecting the GL driver renderer string.
45 Currently only glxinfo is used.
46 """
47 self.renderer = ''
49 self.collect_glxinfo()
52 def collect_glxinfo(self):
53 """Calls glxinfo and parses the output to find the GL driver
55 vendor/renderer strings.
56 """
58 try:
59 output = subprocess.check_output(
60 ['glxinfo'], stderr=subprocess.STDOUT).decode('utf-8')
61 except OSError as e:
62 if e.errno not in [errno.ENOENT, errno.EACCES]:
63 raise
64 return
65 except subprocess.CalledProcessError:
66 return
68 for line in output.splitlines():
69 m = re.match('OpenGL renderer string: (.*)', line)
70 if m is not None:
71 self.renderer = m.group(1)
72 break
75 def find_categories(self):
76 """Parses the vendor/renderer strings to decide what categories
78 the driver falls under.
79 """
80 if self.renderer.startswith(('Mesa ', 'Gallium ')):
81 self.categories.append('mesa')
83 m = re.match('.* VC4(.*)', self.renderer)
84 if m is not None:
85 self.categories.append('vc4')
86 m = re.match(' V3D ([0-9])+\.([0-9])+', m.group(1))
87 if m is not None:
88 self.categories.append('vc4-{}.{}'.format(m.group(1),
89 m.group(2)))
91 m = re.match('Mesa DRI R200 ', self.renderer)
92 if m is not None:
93 self.categories.append('r200')
95 m = re.match('Mesa DRI Intel[^ ]* (.*)', self.renderer)
96 if m is not None:
97 tail = m.group(1)
99 i965_chipdict = {
100 '965': 'brw',
101 '946': 'brw',
102 '.*[GQ]4[35]': 'g4x',
103 'Ironlake': 'ilk',
104 'Sandybridge': 'snb',
105 'Ivybridge': 'ivb',
106 'Haswell': 'hsw',
107 'Baytrail': 'byt',
108 'Broadwell': 'bdw',
109 'Skylake': 'skl',
110 'HD Graphics .* \(Skylake': 'skl',
111 'Kabylake': 'kbl',
112 '.*Cherryview': 'chv',
113 '.*Broxton': 'bxt',
116 for chip, abbrev in i965_chipdict.items():
117 m = re.match(chip, tail)
118 if m is not None:
119 self.categories.append('i965')
120 self.categories.append('i965-{}'.format(abbrev))
121 break
123 self.categories.reverse()