blob: 9433f67e66c11e113088952405d09a670f0c4505 [file]
# Copyright 2019 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.
import re
def _ParseANGLEGpuVendorString(device_string):
if not device_string:
return None
# ANGLE's device (renderer) string is of the form:
# "ANGLE (vendor_string, renderer_string, gl_version profile)"
# This function will be used to get the first value in the tuple
match = re.search(r'ANGLE \((.*), .*, .*\)', device_string)
if match:
return match.group(1)
else:
return None
def _GetANGLEGpuDeviceId(device_string):
if not device_string:
return None
# ANGLE's device (renderer) string is of the form:
# "ANGLE (vendor_string, renderer_string, gl_version profile)"
# This function will be used to get the second value in the tuple
match = re.search(r'ANGLE \(.*, (.*), .*\)', device_string)
if match:
return match.group(1)
else:
return None
def GetGpuVendorString(gpu_info):
if gpu_info:
primary_gpu = gpu_info.devices[0]
if primary_gpu:
vendor_string = primary_gpu.vendor_string
angle_vendor_string = _ParseANGLEGpuVendorString(
primary_gpu.device_string)
vendor_id = primary_gpu.vendor_id
if vendor_id == 0x10DE:
return 'nvidia'
elif vendor_id == 0x1002:
return 'amd'
elif vendor_id == 0x8086:
return 'intel'
elif angle_vendor_string:
return angle_vendor_string.lower()
elif vendor_string:
return vendor_string.split(' ')[0].lower()
return 'unknown_gpu'
def GetGpuDeviceId(gpu_info):
if gpu_info:
primary_gpu = gpu_info.devices[0]
if primary_gpu:
return (
primary_gpu.device_id
or _GetANGLEGpuDeviceId(
primary_gpu.device_string)
or primary_gpu.device_string)
return 0
def GetANGLERenderer(gpu_info):
if gpu_info and gpu_info.aux_attributes:
gl_renderer = gpu_info.aux_attributes.get('gl_renderer')
if gl_renderer and 'ANGLE' in gl_renderer:
if 'Direct3D11' in gl_renderer:
return 'd3d11'
elif 'Direct3D9' in gl_renderer:
return 'd3d9'
elif 'OpenGL ES' in gl_renderer:
return 'opengles'
elif 'OpenGL' in gl_renderer:
return 'opengl'
elif 'Vulkan' in gl_renderer:
return 'vulkan'
return 'no_angle'
def GetCommandDecoder(gpu_info):
if gpu_info and gpu_info.aux_attributes and \
gpu_info.aux_attributes.get('passthrough_cmd_decoder', False):
return 'passthrough'
return 'no_passthrough'