aboutsummaryrefslogtreecommitdiff
path: root/catapult/telemetry/telemetry/internal/platform/gpu_info.py
blob: 40a327b2acb2a351e2896c50852635976629be90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from telemetry.internal.platform import gpu_device


class GPUInfo(object):
  """Provides information about the GPUs on the system."""

  def __init__(self, device_array, aux_attributes,
               feature_status, driver_bug_workarounds):
    if device_array == None:
      raise Exception('Missing required "devices" property')
    if len(device_array) == 0:
      raise Exception('Missing at least one GPU in device_array')

    self._devices = [gpu_device.GPUDevice.FromDict(d) for d in device_array]
    self._aux_attributes = aux_attributes
    self._feature_status = feature_status
    self._driver_bug_workarounds = driver_bug_workarounds

  @classmethod
  def FromDict(cls, attrs):
    """Constructs a GPUInfo from a dictionary of attributes.

    Attributes currently required to be present in the dictionary:
      devices (array of dictionaries, each of which contains
          GPUDevice's required attributes)
    """
    return cls(attrs['devices'], attrs.get('aux_attributes'),
               attrs.get('feature_status'),
               attrs.get('driver_bug_workarounds'))

  @property
  def devices(self):
    """An array of GPUDevices. Element 0 is the primary GPU on the system."""
    return self._devices

  @property
  def aux_attributes(self):
    """Returns a dictionary of auxiliary, optional, attributes.

    On the Chrome browser, for example, this dictionary contains:
      optimus (boolean)
      amd_switchable (boolean)
      lenovo_dcute (boolean)
      driver_vendor (string)
      driver_version (string)
      driver_date (string)
      gl_version_string (string)
      gl_vendor (string)
      gl_renderer (string)
      gl_extensions (string)
      display_link_version (string)
    """
    return self._aux_attributes

  @property
  def feature_status(self):
    """Returns an optional dictionary of graphics features and their status."""
    return self._feature_status

  @property
  def driver_bug_workarounds(self):
    """Returns an optional array of driver bug workarounds."""
    return self._driver_bug_workarounds