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
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
22 from __future__
import (
23 absolute_import
, division
, print_function
, unicode_literals
33 class DriverClassifier(object):
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.
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.
58 output
= subprocess
.check_output(
59 ['glxinfo'], stderr
=subprocess
.STDOUT
).decode('utf-8')
61 if e
.errno
not in [errno
.ENOENT
, errno
.EACCES
]:
64 except subprocess
.CalledProcessError
:
67 for line
in output
.splitlines():
68 m
= re
.match('OpenGL renderer string: (.*)', line
)
70 self
.renderer
= m
.group(1)
74 def find_categories(self
):
75 """Parses the vendor/renderer strings to decide what categories
77 the driver falls under.
79 if self
.renderer
.startswith(('Mesa ', 'Gallium ')):
80 self
.categories
.append('mesa')
82 m
= re
.match('.* VC4(.*)', self
.renderer
)
84 self
.categories
.append('vc4')
85 m
= re
.match(' V3D ([0-9])+\.([0-9])+', m
.group(1))
87 self
.categories
.append('vc4-{}.{}'.format(m
.group(1),
90 m
= re
.match('Mesa DRI R200 ', self
.renderer
)
92 self
.categories
.append('r200')
94 m
= re
.match('Mesa DRI Intel[^ ]* (.*)', self
.renderer
)
101 '.*[GQ]4[35]': 'g4x',
103 'Sandybridge': 'snb',
109 'HD Graphics .* \(Skylake': 'skl',
111 '.*Cherryview': 'chv',
115 for chip
, abbrev
in i965_chipdict
.items():
116 m
= re
.match(chip
, tail
)
118 self
.categories
.append('i965')
119 self
.categories
.append('i965-{}'.format(abbrev
))
122 self
.categories
.reverse()