import os
import sys
from typing import Any
import unittest
from gpu_tests import gpu_integration_test
from gpu_tests import webgpu_cts_integration_test_base
from gpu_tests.util import host_information
import gpu_path_util
EXPECTATIONS_FILE = os.path.join(gpu_path_util.CHROMIUM_SRC_DIR, 'third_party',
'dawn', 'webgpu-cts', 'expectations.txt')
ERROR_SCOPE_TESTS = 'webgpu:api,validation,error_scope'
OOM_ERROR_TEST_PREFIXES = [
ERROR_SCOPE_TESTS + ':current_scope:errorFilter="out-of-memory";',
ERROR_SCOPE_TESTS + ':parent_scope:errorFilter="out-of-memory";',
ERROR_SCOPE_TESTS + ':simple:errorType="out-of-memory";',
]
WEBCAM_TEST_PREFIXES = [
'webgpu:web_platform,external_texture,video:importExternalTexture,camera',
]
class WebGpuCtsIntegrationTest(
webgpu_cts_integration_test_base.WebGpuCtsIntegrationTestBase):
@classmethod
def UseWebGpuCompatMode(cls) -> bool:
return False
@classmethod
def Name(cls) -> str:
return 'webgpu_cts'
def _GetSerialGlobs(self) -> set[str]:
globs = super()._GetSerialGlobs()
globs |= {
'*:api,operation,rendering,basic:large_draw:*',
}
if host_information.IsMac() and host_information.IsIntelGpu():
FORMATS_WITH_16_BYTE_BLOCKS = [
'rgba32uint',
'rgba32sint',
'rgba32float',
'bc2-rgba-unorm',
'bc2-rgba-unorm-srgb',
'bc3-rgba-unorm',
'bc3-rgba-unorm-srgb',
'bc5-rg-unorm',
'bc5-rg-snorm',
'bc6h-rgb-ufloat',
'bc6h-rgb-float',
'bc7-rgba-unorm',
'bc7-rgba-unorm-srgb',
'etc2-rgba8unorm',
'etc2-rgba8unorm-srgb',
'eac-rg11unorm',
'eac-rg11snorm',
'astc-4x4-unorm',
'astc-4x4-unorm-srgb',
'astc-5x4-unorm',
'astc-5x4-unorm-srgb',
'astc-5x5-unorm',
'astc-5x5-unorm-srgb',
'astc-6x5-unorm',
'astc-6x5-unorm-srgb',
'astc-6x6-unorm',
'astc-6x6-unorm-srgb',
'astc-8x5-unorm',
'astc-8x5-unorm-srgb',
'astc-8x6-unorm',
'astc-8x6-unorm-srgb',
'astc-8x8-unorm',
'astc-8x8-unorm-srgb',
'astc-10x5-unorm',
'astc-10x5-unorm-srgb',
'astc-10x6-unorm',
'astc-10x6-unorm-srgb',
'astc-10x8-unorm',
'astc-10x8-unorm-srgb',
'astc-10x10-unorm',
'astc-10x10-unorm-srgb',
'astc-12x10-unorm',
'astc-12x10-unorm-srgb',
'astc-12x12-unorm',
'astc-12x12-unorm-srgb'
]
for f in FORMATS_WITH_16_BYTE_BLOCKS:
globs.add(
(f'*:api,operation,command_buffer,image_copy:origins_and_extents:'
f'initMethod="WriteTexture";checkMethod="PartialCopyT2B";'
f'format="{f}";*'))
if host_information.IsMac():
globs.add('webgpu:shader,execution*')
if host_information.IsWindows() and self._enable_dawn_backend_validation:
globs.add('webgpu:api,validation,capability_checks,limits*')
globs.add('webgpu:api,validation,state,device_lost*')
return globs
def _GetSerialTests(self) -> set[str]:
serial_tests = super()._GetSerialTests()
return serial_tests
@classmethod
def _GetAdditionalBrowserArgsForQuery(cls, query: str) -> list[str] | None:
if any(query.startswith(prefix) for prefix in OOM_ERROR_TEST_PREFIXES):
return ['--disable-dawn-features=tiered_adapter_limits']
if any(query.startswith(prefix) for prefix in WEBCAM_TEST_PREFIXES):
return [
'--use-fake-device-for-media-stream',
'--auto-accept-camera-and-microphone-capture'
]
return None
@classmethod
def ExpectationsFiles(cls) -> list[str]:
return [EXPECTATIONS_FILE]
def load_tests(_loader: unittest.TestLoader, _tests: Any,
_pattern: Any) -> unittest.TestSuite:
return gpu_integration_test.LoadAllTestsInModule(sys.modules[__name__])