| 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', 'no_angle'] | 7 ANGLE_CONDITIONS = ['d3d9', 'd3d11', 'opengl', 'no_angle'] |
| 8 | 8 CMD_DECODER_CONDITIONS = ['passthrough', 'no_passthrough'] |
| 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.cmd_decoder_conditions = [] |
| 18 self.max_num_retries = max_num_retries | 19 self.max_num_retries = max_num_retries |
| 19 assert self.max_num_retries == 0 or expectation == 'flaky' | 20 assert self.max_num_retries == 0 or expectation == 'flaky' |
| 20 super(GpuExpectation, self).__init__( | 21 super(GpuExpectation, self).__init__( |
| 21 expectation, pattern, conditions=conditions, bug=bug) | 22 expectation, pattern, conditions=conditions, bug=bug) |
| 22 | 23 |
| 23 def ParseCondition(self, condition): | 24 def ParseCondition(self, condition): |
| 24 """Adds support for GPU, device ID, and ANGLE conditions. | 25 """Adds support for GPU, device ID, and ANGLE conditions. |
| 25 | 26 |
| 26 GPU vendors: | 27 GPU vendors: |
| 27 amd, arm, broadcom, hisilicon, intel, imagination, nvidia, | 28 amd, arm, broadcom, hisilicon, intel, imagination, nvidia, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 condition[1]) | 61 condition[1]) |
| 61 self.device_id_conditions.append((c0, device)) | 62 self.device_id_conditions.append((c0, device)) |
| 62 else: | 63 else: |
| 63 raise ValueError('Unknown expectation condition: "%s"' % c0) | 64 raise ValueError('Unknown expectation condition: "%s"' % c0) |
| 64 else: | 65 else: |
| 65 cl = condition.lower() | 66 cl = condition.lower() |
| 66 if cl in GPU_CONDITIONS: | 67 if cl in GPU_CONDITIONS: |
| 67 self.gpu_conditions.append(cl) | 68 self.gpu_conditions.append(cl) |
| 68 elif cl in ANGLE_CONDITIONS: | 69 elif cl in ANGLE_CONDITIONS: |
| 69 self.angle_conditions.append(cl) | 70 self.angle_conditions.append(cl) |
| 71 elif cl in CMD_DECODER_CONDITIONS: |
| 72 self.cmd_decoder_conditions.append(cl) |
| 70 else: | 73 else: |
| 71 # Delegate to superclass. | 74 # Delegate to superclass. |
| 72 super(GpuExpectation, self).ParseCondition(condition) | 75 super(GpuExpectation, self).ParseCondition(condition) |
| 73 | 76 |
| 74 | 77 |
| 75 class GpuTestExpectations(test_expectations.TestExpectations): | 78 class GpuTestExpectations(test_expectations.TestExpectations): |
| 76 def __init__(self, url_prefixes=None): | 79 def __init__(self, url_prefixes=None): |
| 77 super(GpuTestExpectations, self).__init__(url_prefixes=url_prefixes) | 80 super(GpuTestExpectations, self).__init__(url_prefixes=url_prefixes) |
| 78 | 81 |
| 79 def CreateExpectation(self, expectation, pattern, conditions=None, | 82 def CreateExpectation(self, expectation, pattern, conditions=None, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 105 gpu_vendor = self._GetGpuVendorString(gpu_info) | 108 gpu_vendor = self._GetGpuVendorString(gpu_info) |
| 106 gpu_device_id = self._GetGpuDeviceId(gpu_info) | 109 gpu_device_id = self._GetGpuDeviceId(gpu_info) |
| 107 gpu_matches = ((not expectation.gpu_conditions and | 110 gpu_matches = ((not expectation.gpu_conditions and |
| 108 not expectation.device_id_conditions) or | 111 not expectation.device_id_conditions) or |
| 109 gpu_vendor in expectation.gpu_conditions or | 112 gpu_vendor in expectation.gpu_conditions or |
| 110 (gpu_vendor, gpu_device_id) in expectation.device_id_conditions) | 113 (gpu_vendor, gpu_device_id) in expectation.device_id_conditions) |
| 111 angle_renderer = self._GetANGLERenderer(gpu_info) | 114 angle_renderer = self._GetANGLERenderer(gpu_info) |
| 112 angle_matches = ( | 115 angle_matches = ( |
| 113 (not expectation.angle_conditions) or | 116 (not expectation.angle_conditions) or |
| 114 angle_renderer in expectation.angle_conditions) | 117 angle_renderer in expectation.angle_conditions) |
| 118 cmd_decoder = self._GetCommandDecoder(gpu_info) |
| 119 cmd_decoder_matches = ( |
| 120 (not expectation.cmd_decoder_conditions) or |
| 121 cmd_decoder in expectation.cmd_decoder_conditions) |
| 115 | 122 |
| 116 return gpu_matches and angle_matches | 123 return gpu_matches and angle_matches and cmd_decoder_matches |
| 117 | 124 |
| 118 def _GetGpuVendorString(self, gpu_info): | 125 def _GetGpuVendorString(self, gpu_info): |
| 119 if gpu_info: | 126 if gpu_info: |
| 120 primary_gpu = gpu_info.devices[0] | 127 primary_gpu = gpu_info.devices[0] |
| 121 if primary_gpu: | 128 if primary_gpu: |
| 122 vendor_string = primary_gpu.vendor_string.lower() | 129 vendor_string = primary_gpu.vendor_string.lower() |
| 123 vendor_id = primary_gpu.vendor_id | 130 vendor_id = primary_gpu.vendor_id |
| 124 if vendor_id == 0x10DE: | 131 if vendor_id == 0x10DE: |
| 125 return 'nvidia' | 132 return 'nvidia' |
| 126 elif vendor_id == 0x1002: | 133 elif vendor_id == 0x1002: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 142 if gpu_info and gpu_info.aux_attributes: | 149 if gpu_info and gpu_info.aux_attributes: |
| 143 gl_renderer = gpu_info.aux_attributes.get('gl_renderer') | 150 gl_renderer = gpu_info.aux_attributes.get('gl_renderer') |
| 144 if gl_renderer and 'ANGLE' in gl_renderer: | 151 if gl_renderer and 'ANGLE' in gl_renderer: |
| 145 if 'Direct3D11' in gl_renderer: | 152 if 'Direct3D11' in gl_renderer: |
| 146 return 'd3d11' | 153 return 'd3d11' |
| 147 elif 'Direct3D9' in gl_renderer: | 154 elif 'Direct3D9' in gl_renderer: |
| 148 return 'd3d9' | 155 return 'd3d9' |
| 149 elif 'OpenGL' in gl_renderer: | 156 elif 'OpenGL' in gl_renderer: |
| 150 return 'opengl' | 157 return 'opengl' |
| 151 return 'no_angle' | 158 return 'no_angle' |
| 159 |
| 160 def _GetCommandDecoder(self, gpu_info): |
| 161 if gpu_info and gpu_info.aux_attributes and \ |
| 162 gpu_info.aux_attributes.get('passthrough_cmd_decoder', False): |
| 163 return 'passthrough' |
| 164 return 'no_passthrough' |
| OLD | NEW |