Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from gpu_tests import test_expectations | 5 from gpu_tests import test_expectations |
| 6 | 6 |
| 7 ANGLE_CONDITIONS = ['d3d9', 'd3d11', 'opengl'] | 7 ANGLE_CONDITIONS = ['d3d9', 'd3d11', 'opengl', 'no_angle'] |
| 8 | 8 |
| 9 GPU_CONDITIONS = ['amd', 'arm', 'broadcom', 'hisilicon', 'intel', 'imagination', | 9 GPU_CONDITIONS = ['amd', 'arm', 'broadcom', 'hisilicon', 'intel', 'imagination', |
| 10 'nvidia', 'qualcomm', 'vivante'] | 10 'nvidia', 'qualcomm', 'vivante'] |
| 11 | 11 |
| 12 class GpuExpectation(test_expectations.Expectation): | 12 class GpuExpectation(test_expectations.Expectation): |
| 13 def __init__(self, expectation, pattern, conditions=None, bug=None, | 13 def __init__(self, expectation, pattern, conditions=None, bug=None, |
| 14 max_num_retries=0): | 14 max_num_retries=0): |
| 15 self.gpu_conditions = [] | 15 self.gpu_conditions = [] |
| 16 self.device_id_conditions = [] | 16 self.device_id_conditions = [] |
| 17 self.angle_conditions = [] | 17 self.angle_conditions = [] |
| 18 self.max_num_retries = max_num_retries | 18 self.max_num_retries = max_num_retries |
| 19 assert self.max_num_retries == 0 or expectation == 'flaky' | 19 assert self.max_num_retries == 0 or expectation == 'flaky' |
| 20 super(GpuExpectation, self).__init__( | 20 super(GpuExpectation, self).__init__( |
| 21 expectation, pattern, conditions=conditions, bug=bug) | 21 expectation, pattern, conditions=conditions, bug=bug) |
| 22 | 22 |
| 23 def ParseCondition(self, condition): | 23 def ParseCondition(self, condition): |
| 24 """Adds support for GPU, device ID, and ANGLE conditions. | 24 """Adds support for GPU, device ID, and ANGLE conditions. |
| 25 | 25 |
| 26 GPU vendors: | 26 GPU vendors: |
| 27 amd, arm, broadcom, hisilicon, intel, imagination, nvidia, | 27 amd, arm, broadcom, hisilicon, intel, imagination, nvidia, |
| 28 qualcomm, vivante | 28 qualcomm, vivante |
| 29 | 29 |
| 30 ANGLE renderer: | 30 ANGLE renderer: |
| 31 d3d9, d3d11, opengl | 31 d3d9, d3d11, opengl, no_angle |
| 32 no_angle can be used to avoid conflicts between expectations for | |
| 33 ANGLE and expectations not for ANGLE | |
| 32 | 34 |
| 33 Specific GPUs can be listed as a tuple with vendor name and device ID. | 35 Specific GPUs can be listed as a tuple with vendor name and device ID. |
| 34 Examples: ('nvidia', 0x1234), ('arm', 'Mali-T604') | 36 Examples: ('nvidia', 0x1234), ('arm', 'Mali-T604') |
| 35 Device IDs must be paired with a GPU vendor. | 37 Device IDs must be paired with a GPU vendor. |
| 36 | 38 |
| 37 Sample usage in SetExpectations in subclasses: | 39 Sample usage in SetExpectations in subclasses: |
| 38 self.Fail('gl-enable-vertex-attrib.html', | 40 self.Fail('gl-enable-vertex-attrib.html', |
| 39 ['mac', 'amd', ('nvidia', 0x1234)], bug=123) | 41 ['mac', 'amd', ('nvidia', 0x1234)], bug=123) |
| 40 """ | 42 """ |
| 41 if isinstance(condition, tuple): | 43 if isinstance(condition, tuple): |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 gpu_info = browser.GetSystemInfo().gpu | 86 gpu_info = browser.GetSystemInfo().gpu |
| 85 gpu_vendor = self._GetGpuVendorString(gpu_info) | 87 gpu_vendor = self._GetGpuVendorString(gpu_info) |
| 86 gpu_device_id = self._GetGpuDeviceId(gpu_info) | 88 gpu_device_id = self._GetGpuDeviceId(gpu_info) |
| 87 gpu_matches = ((not expectation.gpu_conditions and | 89 gpu_matches = ((not expectation.gpu_conditions and |
| 88 not expectation.device_id_conditions) or | 90 not expectation.device_id_conditions) or |
| 89 gpu_vendor in expectation.gpu_conditions or | 91 gpu_vendor in expectation.gpu_conditions or |
| 90 (gpu_vendor, gpu_device_id) in expectation.device_id_conditions) | 92 (gpu_vendor, gpu_device_id) in expectation.device_id_conditions) |
| 91 angle_renderer = self._GetANGLERenderer(gpu_info) | 93 angle_renderer = self._GetANGLERenderer(gpu_info) |
| 92 angle_matches = ( | 94 angle_matches = ( |
| 93 (not expectation.angle_conditions) or | 95 (not expectation.angle_conditions) or |
| 94 angle_renderer in expectation.angle_conditions) | 96 angle_renderer in expectation.angle_conditions) |
|
Ken Russell (switch to Gerrit)
2016/05/12 21:03:01
Per comment on the other CL:
I think this logic n
| |
| 95 | 97 |
| 96 return gpu_matches and angle_matches | 98 return gpu_matches and angle_matches |
| 97 | 99 |
| 98 def _GetGpuVendorString(self, gpu_info): | 100 def _GetGpuVendorString(self, gpu_info): |
| 99 if gpu_info: | 101 if gpu_info: |
| 100 primary_gpu = gpu_info.devices[0] | 102 primary_gpu = gpu_info.devices[0] |
| 101 if primary_gpu: | 103 if primary_gpu: |
| 102 vendor_string = primary_gpu.vendor_string.lower() | 104 vendor_string = primary_gpu.vendor_string.lower() |
| 103 vendor_id = primary_gpu.vendor_id | 105 vendor_id = primary_gpu.vendor_id |
| 104 if vendor_id == 0x10DE: | 106 if vendor_id == 0x10DE: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 121 def _GetANGLERenderer(self, gpu_info): | 123 def _GetANGLERenderer(self, gpu_info): |
| 122 if gpu_info and gpu_info.aux_attributes: | 124 if gpu_info and gpu_info.aux_attributes: |
| 123 gl_renderer = gpu_info.aux_attributes.get('gl_renderer') | 125 gl_renderer = gpu_info.aux_attributes.get('gl_renderer') |
| 124 if gl_renderer: | 126 if gl_renderer: |
| 125 if 'Direct3D11' in gl_renderer: | 127 if 'Direct3D11' in gl_renderer: |
| 126 return 'd3d11' | 128 return 'd3d11' |
| 127 elif 'Direct3D9' in gl_renderer: | 129 elif 'Direct3D9' in gl_renderer: |
| 128 return 'd3d9' | 130 return 'd3d9' |
| 129 elif 'OpenGL' in gl_renderer: | 131 elif 'OpenGL' in gl_renderer: |
| 130 return 'opengl' | 132 return 'opengl' |
| 131 return '' | 133 return 'no_angle' |
| OLD | NEW |