From 95b1d6db6953859727e3e952c11bfcecbf4fc339 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Tue, 13 Sep 2022 23:34:47 +0000 Subject: [PATCH] Surface target CPU info to GPU telemetry tests Bug: dawn:1401 Change-Id: Ibd2beebe8bda49f3ef2237ecda84c71828370085 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3891837 Reviewed-by: Maggie Chen Commit-Queue: Austin Eng Reviewed-by: Brian Sheedy Cr-Commit-Position: refs/heads/main@{#1046636} --- content/test/gpu/gpu_tests/gpu_helper.py | 4 ++ .../gpu/gpu_tests/gpu_integration_test.py | 1 + .../gpu_integration_test_unittest.py | 54 ++++++++++++++----- gpu/config/gpu_info.cc | 2 + gpu/config/gpu_info.h | 8 +++ 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/content/test/gpu/gpu_tests/gpu_helper.py b/content/test/gpu/gpu_tests/gpu_helper.py index 285b0580cd5a48..83b9cdb569effc 100644 --- a/content/test/gpu/gpu_tests/gpu_helper.py +++ b/content/test/gpu/gpu_tests/gpu_helper.py @@ -179,6 +179,10 @@ def GetAsanStatus(gpu_info: tgi.GPUInfo) -> str: return 'no-asan' +def GetTargetCpuStatus(gpu_info): + return 'target-cpu-%s' % (gpu_info.aux_attributes.get('target_cpu_bits', + 'unknown'), ) + # TODO(rivr): Use GPU feature status for Dawn instead of command line. def HasDawnSkiaRenderer(extra_browser_args: List[str]) -> bool: if extra_browser_args: diff --git a/content/test/gpu/gpu_tests/gpu_integration_test.py b/content/test/gpu/gpu_tests/gpu_integration_test.py index dac39c840933d2..f511d57f74054c 100644 --- a/content/test/gpu/gpu_tests/gpu_integration_test.py +++ b/content/test/gpu/gpu_tests/gpu_integration_test.py @@ -781,6 +781,7 @@ def GetPlatformTags(cls, browser: ct.Browser) -> List[str]: gpu_tags.append(gpu_helper.GetCommandDecoder(gpu_info)) gpu_tags.append(gpu_helper.GetOOPCanvasStatus(gpu_info.feature_status)) gpu_tags.append(gpu_helper.GetAsanStatus(gpu_info)) + gpu_tags.append(gpu_helper.GetTargetCpuStatus(gpu_info)) if gpu_info and gpu_info.devices: for ii in range(0, len(gpu_info.devices)): gpu_vendor = gpu_helper.GetGpuVendorString(gpu_info, ii) diff --git a/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py b/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py index 439bbf932528d9..f6a0fa2fd73e49 100644 --- a/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py +++ b/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py @@ -56,7 +56,8 @@ def _GetSystemInfo( # pylint: disable=too-many-arguments device_string: str = '', passthrough: bool = False, gl_renderer: str = '', - is_asan: bool = False) -> system_info.SystemInfo: + is_asan: bool = False, + target_cpu_bits: int = 64) -> system_info.SystemInfo: sys_info = { 'model_name': '', 'gpu': { @@ -71,6 +72,7 @@ def _GetSystemInfo( # pylint: disable=too-many-arguments 'aux_attributes': { 'passthrough_cmd_decoder': passthrough, 'is_asan': is_asan, + 'target_cpu_bits': target_cpu_bits }, 'feature_status': { 'gpu_compositing': 'enabled', @@ -94,10 +96,12 @@ def _GetTagsToTest(browser: fakes.FakeBrowser, return tags -def _GenerateNvidiaExampleTagsForTestClassAndArgs(test_class: GpuTestClassType, - args: mock.MagicMock, - is_asan: bool = False - ) -> Set[str]: +def _GenerateNvidiaExampleTagsForTestClassAndArgs( + test_class: GpuTestClassType, + args: mock.MagicMock, + is_asan: bool = False, + target_cpu_bits: int = 64, +) -> Set[str]: tags = None with mock.patch.object( test_class, 'ExpectationsFiles', return_value=['exp.txt']): @@ -108,7 +112,8 @@ def _GenerateNvidiaExampleTagsForTestClassAndArgs(test_class: GpuTestClassType, gpu=VENDOR_NVIDIA, device=0x1cb3, gl_renderer='ANGLE Direct3D9', - is_asan=is_asan) + is_asan=is_asan, + target_cpu_bits=target_cpu_bits) tags = _GetTagsToTest(browser, test_class) return tags @@ -187,9 +192,10 @@ def testTestNamePrefixGenerationInRunGpuIntegrationTests(self) -> None: def _TestTagGenerationForMockPlatform(self, test_class: GpuTestClassType, args: mock.MagicMock, - is_asan: bool = False) -> Set[str]: + is_asan: bool = False, + target_cpu_bits: int = 64) -> Set[str]: tag_set = _GenerateNvidiaExampleTagsForTestClassAndArgs( - test_class, args, is_asan) + test_class, args, is_asan, target_cpu_bits) self.assertTrue( set([ 'win', 'win10', 'angle-d3d9', 'release', 'nvidia', 'nvidia-0x1cb3', @@ -215,6 +221,27 @@ def testGenerateContextLostExampleTagsForNoAsan(self) -> None: self.assertIn('no-asan', tag_set) self.assertNotIn('asan', tag_set) + def testGenerateContextLostExampleTagsForTargetCpu(self) -> None: + args = gpu_helper.GetMockArgs() + self.assertIn( + 'target-cpu-64', + self._TestTagGenerationForMockPlatform( + context_lost_integration_test.ContextLostIntegrationTest, + args, + target_cpu_bits=64)) + self.assertIn( + 'target-cpu-32', + self._TestTagGenerationForMockPlatform( + context_lost_integration_test.ContextLostIntegrationTest, + args, + target_cpu_bits=32)) + self.assertIn( + 'target-cpu-31', + self._TestTagGenerationForMockPlatform( + context_lost_integration_test.ContextLostIntegrationTest, + args, + target_cpu_bits=31)) + def testGenerateWebglConformanceExampleTagsForWebglVersion1andAsan(self ) -> None: args = gpu_helper.GetMockArgs(webgl_version='1.0.0') @@ -251,7 +278,8 @@ def testGenerateNvidiaExampleTags(self) -> None: _GetTagsToTest(browser), set([ 'win', 'win10', 'release', 'nvidia', 'nvidia-0x1cb3', 'angle-d3d9', - 'no-passthrough', 'renderer-skia-gl', 'no-oop-c', 'no-asan' + 'no-passthrough', 'renderer-skia-gl', 'no-oop-c', 'no-asan', + 'target-cpu-64' ])) @mock.patch('sys.platform', 'darwin') @@ -267,8 +295,8 @@ def testGenerateVendorTagUsingVendorString(self) -> None: _GetTagsToTest(browser), set([ 'mac', 'mojave', 'release', 'imagination', 'no-asan', - 'imagination-PowerVR-SGX-554', 'angle-opengles', 'passthrough', - 'renderer-skia-gl', 'no-oop-c' + 'target-cpu-64', 'imagination-PowerVR-SGX-554', 'angle-opengles', + 'passthrough', 'renderer-skia-gl', 'no-oop-c' ])) @mock.patch('sys.platform', 'darwin') @@ -282,8 +310,8 @@ def testGenerateVendorTagUsingDeviceString(self) -> None: _GetTagsToTest(browser), set([ 'mac', 'mojave', 'release', 'imagination', 'no-asan', - 'imagination-Triangle-Monster-3000', 'angle-disabled', - 'no-passthrough', 'renderer-skia-gl', 'no-oop-c' + 'target-cpu-64', 'imagination-Triangle-Monster-3000', + 'angle-disabled', 'no-passthrough', 'renderer-skia-gl', 'no-oop-c' ])) @mock.patch.dict(os.environ, clear=True) diff --git a/gpu/config/gpu_info.cc b/gpu/config/gpu_info.cc index 105586e038f4fa..18d8f9c1089d24 100644 --- a/gpu/config/gpu_info.cc +++ b/gpu/config/gpu_info.cc @@ -320,6 +320,7 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { bool in_process_gpu; bool passthrough_cmd_decoder; bool is_asan; + uint32_t target_cpu_bits; bool can_support_threaded_texture_mailbox; #if BUILDFLAG(IS_MAC) uint32_t macos_specific_texture_target; @@ -387,6 +388,7 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { enumerator->AddBool("inProcessGpu", in_process_gpu); enumerator->AddBool("passthroughCmdDecoder", passthrough_cmd_decoder); enumerator->AddBool("isAsan", is_asan); + enumerator->AddInt("targetCpuBits", static_cast(target_cpu_bits)); enumerator->AddBool("canSupportThreadedTextureMailbox", can_support_threaded_texture_mailbox); #if BUILDFLAG(IS_MAC) diff --git a/gpu/config/gpu_info.h b/gpu/config/gpu_info.h index 51c1f30b1127c5..95afa574b51ce9 100644 --- a/gpu/config/gpu_info.h +++ b/gpu/config/gpu_info.h @@ -416,6 +416,14 @@ struct GPU_EXPORT GPUInfo { bool is_asan = false; #endif +#if defined(ARCH_CPU_64_BITS) + uint32_t target_cpu_bits = 64; +#elif defined(ARCH_CPU_32_BITS) + uint32_t target_cpu_bits = 32; +#elif defined(ARCH_CPU_31_BITS) + uint32_t target_cpu_bits = 31; +#endif + #if BUILDFLAG(IS_MAC) // Enum describing which texture target is used for native GpuMemoryBuffers on // MacOS. Valid values are GL_TEXTURE_2D and GL_TEXTURE_RECTANGLE_ARB.