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