Commit 0449a902 by Jonah Ryan-Davis Committed by Commit Bot

Move gpu_test_expectations from third_party into ANGLE.

1. Copy the code from src/tests/third_party/gpu_test_expectations to src/test/test_expectations, rename .cc files to .cpp. Put these in a new static library and update dEQP to link against it in src/tests/BUILD.gn. 2. Merge the code in angle_config.h into the rest of the expectations parser, this code was added so that the rest of the parser would compile in ANGLE's tree with minimal modification. Still need to follow up with the third step to close the issue. Bug: angleproject:2677 Change-Id: Icf09b4eeed83a6d09b1964ad2adcfa85cabb4b63 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1536312 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 4ae2c12f
...@@ -659,26 +659,34 @@ if (build_angle_deqp_tests && !is_fuchsia) { ...@@ -659,26 +659,34 @@ if (build_angle_deqp_tests && !is_fuchsia) {
} }
} }
config("angle_deqp_gtest_support_config") { config("angle_deqp_test_expectations_config") {
include_dirs = [ "third_party/gpu_test_expectations" ] include_dirs = [ "${angle_root}:angle_common" ]
}
angle_static_library("angle_deqp_test_expectations") {
public_configs += [ ":angle_deqp_test_expectations_config" ]
public_deps = [
"${angle_root}:angle_common",
"${angle_root}:angle_util",
]
sources = deqp_test_expectations_sources
if (is_mac) {
sources += deqp_test_expectations_sources_mac
libs = [ "Cocoa.framework" ]
}
} }
angle_source_set("angle_deqp_gtest_support") { angle_source_set("angle_deqp_gtest_support") {
testonly = true testonly = true
public_deps = [ public_deps = [
":angle_deqp_test_expectations",
":angle_deqp_tests_main", ":angle_deqp_tests_main",
"${angle_root}:angle_common", "${angle_root}:angle_common",
"${angle_root}:angle_util", "${angle_root}:angle_util",
] ]
public_configs += [ ":angle_deqp_gtest_support_config" ] libs = []
sources = deqp_gpu_test_expectations_sources
if (is_mac) {
sources += deqp_gpu_test_expectations_sources_mac
libs = [ "Cocoa.framework" ]
}
if (!is_android) { if (!is_android) {
public_deps += [ "${angle_root}:angle_gpu_info_util" ] public_deps += [ "${angle_root}:angle_gpu_info_util" ]
......
...@@ -1143,15 +1143,15 @@ deqp_libtester_sources_android = [ ...@@ -1143,15 +1143,15 @@ deqp_libtester_sources_android = [
"$_deqp_path/framework/platform/android/tcuAndroidInternals.cpp", "$_deqp_path/framework/platform/android/tcuAndroidInternals.cpp",
"$_deqp_path/framework/platform/android/tcuAndroidInternals.hpp", "$_deqp_path/framework/platform/android/tcuAndroidInternals.hpp",
] ]
deqp_gpu_test_expectations_sources = [ deqp_test_expectations_sources = [
"third_party/gpu_test_expectations/gpu_info.cc", "test_expectations/gpu_info.cpp",
"third_party/gpu_test_expectations/gpu_info.h", "test_expectations/gpu_info.h",
"third_party/gpu_test_expectations/gpu_test_config.cc", "test_expectations/gpu_test_config.cpp",
"third_party/gpu_test_expectations/gpu_test_config.h", "test_expectations/gpu_test_config.h",
"third_party/gpu_test_expectations/gpu_test_expectations_parser.cc", "test_expectations/gpu_test_expectations_parser.cpp",
"third_party/gpu_test_expectations/gpu_test_expectations_parser.h", "test_expectations/gpu_test_expectations_parser.h",
] ]
deqp_gpu_test_expectations_sources_mac = [ deqp_test_expectations_sources_mac = [
"third_party/gpu_test_expectations/gpu_test_config_mac.mm", "test_expectations/gpu_test_config_mac.mm",
"third_party/gpu_test_expectations/gpu_test_config_mac.h", "test_expectations/gpu_test_config_mac.h",
] ]
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include "common/debug.h" #include "common/debug.h"
#include "common/platform.h" #include "common/platform.h"
#include "common/string_utils.h" #include "common/string_utils.h"
#include "gpu_test_expectations_parser.h"
#include "platform/Platform.h" #include "platform/Platform.h"
#include "tests/test_expectations/gpu_test_expectations_parser.h"
#include "util/system_utils.h" #include "util/system_utils.h"
namespace namespace
......
...@@ -6,10 +6,11 @@ ...@@ -6,10 +6,11 @@
#include "gpu_info.h" #include "gpu_info.h"
namespace { namespace
{
void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice& device, void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice &device, gpu::GPUInfo::Enumerator *enumerator)
gpu::GPUInfo::Enumerator* enumerator) { {
enumerator->BeginGPUDevice(); enumerator->BeginGPUDevice();
enumerator->AddInt("vendorId", device.vendor_id); enumerator->AddInt("vendorId", device.vendor_id);
enumerator->AddInt("deviceId", device.device_id); enumerator->AddInt("deviceId", device.device_id);
...@@ -19,14 +20,14 @@ void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice& device, ...@@ -19,14 +20,14 @@ void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice& device,
enumerator->AddString("driverVendor", device.driver_vendor); enumerator->AddString("driverVendor", device.driver_vendor);
enumerator->AddString("driverVersion", device.driver_version); enumerator->AddString("driverVersion", device.driver_version);
enumerator->AddString("driverDate", device.driver_date); enumerator->AddString("driverDate", device.driver_date);
enumerator->AddInt("cudaComputeCapabilityMajor", enumerator->AddInt("cudaComputeCapabilityMajor", device.cuda_compute_capability_major);
device.cuda_compute_capability_major);
enumerator->EndGPUDevice(); enumerator->EndGPUDevice();
} }
void EnumerateVideoDecodeAcceleratorSupportedProfile( void EnumerateVideoDecodeAcceleratorSupportedProfile(
const gpu::VideoDecodeAcceleratorSupportedProfile& profile, const gpu::VideoDecodeAcceleratorSupportedProfile &profile,
gpu::GPUInfo::Enumerator* enumerator) { gpu::GPUInfo::Enumerator *enumerator)
{
enumerator->BeginVideoDecodeAcceleratorSupportedProfile(); enumerator->BeginVideoDecodeAcceleratorSupportedProfile();
enumerator->AddInt("profile", profile.profile); enumerator->AddInt("profile", profile.profile);
enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width()); enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
...@@ -38,21 +39,22 @@ void EnumerateVideoDecodeAcceleratorSupportedProfile( ...@@ -38,21 +39,22 @@ void EnumerateVideoDecodeAcceleratorSupportedProfile(
} }
void EnumerateVideoEncodeAcceleratorSupportedProfile( void EnumerateVideoEncodeAcceleratorSupportedProfile(
const gpu::VideoEncodeAcceleratorSupportedProfile& profile, const gpu::VideoEncodeAcceleratorSupportedProfile &profile,
gpu::GPUInfo::Enumerator* enumerator) { gpu::GPUInfo::Enumerator *enumerator)
{
enumerator->BeginVideoEncodeAcceleratorSupportedProfile(); enumerator->BeginVideoEncodeAcceleratorSupportedProfile();
enumerator->AddInt("profile", profile.profile); enumerator->AddInt("profile", profile.profile);
enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width()); enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height()); enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height());
enumerator->AddInt("maxFramerateNumerator", profile.max_framerate_numerator); enumerator->AddInt("maxFramerateNumerator", profile.max_framerate_numerator);
enumerator->AddInt("maxFramerateDenominator", enumerator->AddInt("maxFramerateDenominator", profile.max_framerate_denominator);
profile.max_framerate_denominator);
enumerator->EndVideoEncodeAcceleratorSupportedProfile(); enumerator->EndVideoEncodeAcceleratorSupportedProfile();
} }
const char* ImageDecodeAcceleratorTypeToString( const char *ImageDecodeAcceleratorTypeToString(gpu::ImageDecodeAcceleratorType type)
gpu::ImageDecodeAcceleratorType type) { {
switch (type) { switch (type)
{
case gpu::ImageDecodeAcceleratorType::kJpeg: case gpu::ImageDecodeAcceleratorType::kJpeg:
return "JPEG"; return "JPEG";
case gpu::ImageDecodeAcceleratorType::kUnknown: case gpu::ImageDecodeAcceleratorType::kUnknown:
...@@ -60,9 +62,11 @@ const char* ImageDecodeAcceleratorTypeToString( ...@@ -60,9 +62,11 @@ const char* ImageDecodeAcceleratorTypeToString(
} }
} }
const char* ImageDecodeAcceleratorSubsamplingToString( const char *ImageDecodeAcceleratorSubsamplingToString(
gpu::ImageDecodeAcceleratorSubsampling subsampling) { gpu::ImageDecodeAcceleratorSubsampling subsampling)
switch (subsampling) { {
switch (subsampling)
{
case gpu::ImageDecodeAcceleratorSubsampling::k420: case gpu::ImageDecodeAcceleratorSubsampling::k420:
return "4:2:0"; return "4:2:0";
case gpu::ImageDecodeAcceleratorSubsampling::k422: case gpu::ImageDecodeAcceleratorSubsampling::k422:
...@@ -71,44 +75,42 @@ const char* ImageDecodeAcceleratorSubsamplingToString( ...@@ -71,44 +75,42 @@ const char* ImageDecodeAcceleratorSubsamplingToString(
} }
void EnumerateImageDecodeAcceleratorSupportedProfile( void EnumerateImageDecodeAcceleratorSupportedProfile(
const gpu::ImageDecodeAcceleratorSupportedProfile& profile, const gpu::ImageDecodeAcceleratorSupportedProfile &profile,
gpu::GPUInfo::Enumerator* enumerator) { gpu::GPUInfo::Enumerator *enumerator)
{
enumerator->BeginImageDecodeAcceleratorSupportedProfile(); enumerator->BeginImageDecodeAcceleratorSupportedProfile();
enumerator->AddString("imageType", enumerator->AddString("imageType", ImageDecodeAcceleratorTypeToString(profile.image_type));
ImageDecodeAcceleratorTypeToString(profile.image_type)); enumerator->AddString("minEncodedDimensions", profile.min_encoded_dimensions.ToString());
enumerator->AddString("minEncodedDimensions", enumerator->AddString("maxEncodedDimensions", profile.max_encoded_dimensions.ToString());
profile.min_encoded_dimensions.ToString());
enumerator->AddString("maxEncodedDimensions",
profile.max_encoded_dimensions.ToString());
std::string subsamplings; std::string subsamplings;
for (size_t i = 0; i < profile.subsamplings.size(); i++) { for (size_t i = 0; i < profile.subsamplings.size(); i++)
{
if (i > 0) if (i > 0)
subsamplings += ", "; subsamplings += ", ";
subsamplings += subsamplings += ImageDecodeAcceleratorSubsamplingToString(profile.subsamplings[i]);
ImageDecodeAcceleratorSubsamplingToString(profile.subsamplings[i]);
} }
enumerator->AddString("subsamplings", subsamplings); enumerator->AddString("subsamplings", subsamplings);
enumerator->EndImageDecodeAcceleratorSupportedProfile(); enumerator->EndImageDecodeAcceleratorSupportedProfile();
} }
#if defined(OS_WIN) #if defined(OS_WIN)
void EnumerateOverlayCapability(const gpu::OverlayCapability& cap, void EnumerateOverlayCapability(const gpu::OverlayCapability &cap,
gpu::GPUInfo::Enumerator* enumerator) { gpu::GPUInfo::Enumerator *enumerator)
{
std::string key_string = "overlayCap"; std::string key_string = "overlayCap";
key_string += OverlayFormatToString(cap.format); key_string += OverlayFormatToString(cap.format);
enumerator->BeginOverlayCapability(); enumerator->BeginOverlayCapability();
enumerator->AddString(key_string.c_str(), enumerator->AddString(key_string.c_str(), cap.is_scaling_supported ? "SCALING" : "DIRECT");
cap.is_scaling_supported ? "SCALING" : "DIRECT");
enumerator->EndOverlayCapability(); enumerator->EndOverlayCapability();
} }
void EnumerateDx12VulkanVersionInfo(const gpu::Dx12VulkanVersionInfo& info, void EnumerateDx12VulkanVersionInfo(const gpu::Dx12VulkanVersionInfo &info,
gpu::GPUInfo::Enumerator* enumerator) { gpu::GPUInfo::Enumerator *enumerator)
{
enumerator->BeginDx12VulkanVersionInfo(); enumerator->BeginDx12VulkanVersionInfo();
enumerator->AddBool("supportsDx12", info.supports_dx12); enumerator->AddBool("supportsDx12", info.supports_dx12);
enumerator->AddBool("supportsVulkan", info.supports_vulkan); enumerator->AddBool("supportsVulkan", info.supports_vulkan);
enumerator->AddInt("dx12FeatureLevel", enumerator->AddInt("dx12FeatureLevel", static_cast<int>(info.d3d12_feature_level));
static_cast<int>(info.d3d12_feature_level));
enumerator->AddInt("vulkanVersion", static_cast<int>(info.vulkan_version)); enumerator->AddInt("vulkanVersion", static_cast<int>(info.vulkan_version));
enumerator->EndDx12VulkanVersionInfo(); enumerator->EndDx12VulkanVersionInfo();
} }
...@@ -116,11 +118,14 @@ void EnumerateDx12VulkanVersionInfo(const gpu::Dx12VulkanVersionInfo& info, ...@@ -116,11 +118,14 @@ void EnumerateDx12VulkanVersionInfo(const gpu::Dx12VulkanVersionInfo& info,
} // namespace } // namespace
namespace gpu { namespace gpu
{
#if defined(OS_WIN) #if defined(OS_WIN)
const char* OverlayFormatToString(OverlayFormat format) { const char *OverlayFormatToString(OverlayFormat format)
switch (format) { {
switch (format)
{
case OverlayFormat::kBGRA: case OverlayFormat::kBGRA:
return "BGRA"; return "BGRA";
case OverlayFormat::kYUY2: case OverlayFormat::kYUY2:
...@@ -130,56 +135,50 @@ const char* OverlayFormatToString(OverlayFormat format) { ...@@ -130,56 +135,50 @@ const char* OverlayFormatToString(OverlayFormat format) {
} }
} }
bool OverlayCapability::operator==(const OverlayCapability& other) const { bool OverlayCapability::operator==(const OverlayCapability &other) const
return format == other.format && {
is_scaling_supported == other.is_scaling_supported; return format == other.format && is_scaling_supported == other.is_scaling_supported;
} }
#endif #endif
VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities() VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities() : flags(0) {}
: flags(0) {}
VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities( VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities(
const VideoDecodeAcceleratorCapabilities& other) = default; const VideoDecodeAcceleratorCapabilities &other) = default;
VideoDecodeAcceleratorCapabilities::~VideoDecodeAcceleratorCapabilities() = VideoDecodeAcceleratorCapabilities::~VideoDecodeAcceleratorCapabilities() = default;
default;
ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile() ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile()
: image_type(ImageDecodeAcceleratorType::kUnknown) {} : image_type(ImageDecodeAcceleratorType::kUnknown)
{}
ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile( ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile(
const ImageDecodeAcceleratorSupportedProfile& other) = default; const ImageDecodeAcceleratorSupportedProfile &other) = default;
ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile( ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile(
ImageDecodeAcceleratorSupportedProfile&& other) = default; ImageDecodeAcceleratorSupportedProfile &&other) = default;
ImageDecodeAcceleratorSupportedProfile:: ImageDecodeAcceleratorSupportedProfile::~ImageDecodeAcceleratorSupportedProfile() = default;
~ImageDecodeAcceleratorSupportedProfile() = default;
ImageDecodeAcceleratorSupportedProfile& ImageDecodeAcceleratorSupportedProfile:: ImageDecodeAcceleratorSupportedProfile &ImageDecodeAcceleratorSupportedProfile::operator=(
operator=(const ImageDecodeAcceleratorSupportedProfile& other) = default; const ImageDecodeAcceleratorSupportedProfile &other) = default;
ImageDecodeAcceleratorSupportedProfile& ImageDecodeAcceleratorSupportedProfile:: ImageDecodeAcceleratorSupportedProfile &ImageDecodeAcceleratorSupportedProfile::operator=(
operator=(ImageDecodeAcceleratorSupportedProfile&& other) = default; ImageDecodeAcceleratorSupportedProfile &&other) = default;
GPUInfo::GPUDevice::GPUDevice() GPUInfo::GPUDevice::GPUDevice()
: vendor_id(0), : vendor_id(0), device_id(0), active(false), cuda_compute_capability_major(0)
device_id(0), {}
active(false),
cuda_compute_capability_major(0) {}
GPUInfo::GPUDevice::GPUDevice(const GPUInfo::GPUDevice& other) = default; GPUInfo::GPUDevice::GPUDevice(const GPUInfo::GPUDevice &other) = default;
GPUInfo::GPUDevice::GPUDevice(GPUInfo::GPUDevice&& other) noexcept = default; GPUInfo::GPUDevice::GPUDevice(GPUInfo::GPUDevice &&other) noexcept = default;
GPUInfo::GPUDevice::~GPUDevice() noexcept = default; GPUInfo::GPUDevice::~GPUDevice() noexcept = default;
GPUInfo::GPUDevice& GPUInfo::GPUDevice::operator=( GPUInfo::GPUDevice &GPUInfo::GPUDevice::operator=(const GPUInfo::GPUDevice &other) = default;
const GPUInfo::GPUDevice& other) = default;
GPUInfo::GPUDevice& GPUInfo::GPUDevice::operator=( GPUInfo::GPUDevice &GPUInfo::GPUDevice::operator=(GPUInfo::GPUDevice &&other) noexcept = default;
GPUInfo::GPUDevice&& other) noexcept = default;
GPUInfo::GPUInfo() GPUInfo::GPUInfo()
: optimus(false), : optimus(false),
...@@ -195,22 +194,24 @@ GPUInfo::GPUInfo() ...@@ -195,22 +194,24 @@ GPUInfo::GPUInfo()
system_visual(0), system_visual(0),
rgba_visual(0), rgba_visual(0),
#endif #endif
oop_rasterization_supported(false) { oop_rasterization_supported(false)
} {}
GPUInfo::GPUInfo(const GPUInfo& other) = default; GPUInfo::GPUInfo(const GPUInfo &other) = default;
GPUInfo::~GPUInfo() = default; GPUInfo::~GPUInfo() = default;
GPUInfo::GPUDevice& GPUInfo::active_gpu() { GPUInfo::GPUDevice &GPUInfo::active_gpu()
return const_cast<GPUInfo::GPUDevice&>( {
const_cast<const GPUInfo&>(*this).active_gpu()); return const_cast<GPUInfo::GPUDevice &>(const_cast<const GPUInfo &>(*this).active_gpu());
} }
const GPUInfo::GPUDevice& GPUInfo::active_gpu() const { const GPUInfo::GPUDevice &GPUInfo::active_gpu() const
{
if (gpu.active || secondary_gpus.empty()) if (gpu.active || secondary_gpus.empty())
return gpu; return gpu;
for (const auto& secondary_gpu : secondary_gpus) { for (const auto &secondary_gpu : secondary_gpus)
{
if (secondary_gpu.active) if (secondary_gpu.active)
return secondary_gpu; return secondary_gpu;
} }
...@@ -218,12 +219,15 @@ const GPUInfo::GPUDevice& GPUInfo::active_gpu() const { ...@@ -218,12 +219,15 @@ const GPUInfo::GPUDevice& GPUInfo::active_gpu() const {
return gpu; return gpu;
} }
bool GPUInfo::IsInitialized() const { bool GPUInfo::IsInitialized() const
{
return gpu.vendor_id != 0 || !gl_vendor.empty(); return gpu.vendor_id != 0 || !gl_vendor.empty();
} }
void GPUInfo::EnumerateFields(Enumerator* enumerator) const { void GPUInfo::EnumerateFields(Enumerator *enumerator) const
struct GPUInfoKnownFields { {
struct GPUInfoKnownFields
{
base::TimeDelta initialization_time; base::TimeDelta initialization_time;
bool optimus; bool optimus;
bool amd_switchable; bool amd_switchable;
...@@ -257,12 +261,10 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { ...@@ -257,12 +261,10 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
#endif #endif
VideoDecodeAcceleratorCapabilities video_decode_accelerator_capabilities; VideoDecodeAcceleratorCapabilities video_decode_accelerator_capabilities;
VideoEncodeAcceleratorSupportedProfiles VideoEncodeAcceleratorSupportedProfiles video_encode_accelerator_supported_profiles;
video_encode_accelerator_supported_profiles;
bool jpeg_decode_accelerator_supported; bool jpeg_decode_accelerator_supported;
ImageDecodeAcceleratorSupportedProfiles ImageDecodeAcceleratorSupportedProfiles image_decode_accelerator_supported_profiles;
image_decode_accelerator_supported_profiles;
#if defined(USE_X11) #if defined(USE_X11)
VisualID system_visual; VisualID system_visual;
...@@ -275,20 +277,18 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { ...@@ -275,20 +277,18 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
// If this assert fails then most likely something below needs to be updated. // If this assert fails then most likely something below needs to be updated.
// Note that this assert is only approximate. If a new field is added to // Note that this assert is only approximate. If a new field is added to
// GPUInfo which fits within the current padding then it will not be caught. // GPUInfo which fits within the current padding then it will not be caught.
static_assert( static_assert(sizeof(GPUInfo) == sizeof(GPUInfoKnownFields),
sizeof(GPUInfo) == sizeof(GPUInfoKnownFields),
"fields have changed in GPUInfo, GPUInfoKnownFields must be updated"); "fields have changed in GPUInfo, GPUInfoKnownFields must be updated");
// Required fields (according to DevTools protocol) first. // Required fields (according to DevTools protocol) first.
enumerator->AddString("machineModelName", machine_model_name); enumerator->AddString("machineModelName", machine_model_name);
enumerator->AddString("machineModelVersion", machine_model_version); enumerator->AddString("machineModelVersion", machine_model_version);
EnumerateGPUDevice(gpu, enumerator); EnumerateGPUDevice(gpu, enumerator);
for (const auto& secondary_gpu : secondary_gpus) for (const auto &secondary_gpu : secondary_gpus)
EnumerateGPUDevice(secondary_gpu, enumerator); EnumerateGPUDevice(secondary_gpu, enumerator);
enumerator->BeginAuxAttributes(); enumerator->BeginAuxAttributes();
enumerator->AddTimeDeltaInSecondsF("initializationTime", enumerator->AddTimeDeltaInSecondsF("initializationTime", initialization_time);
initialization_time);
enumerator->AddBool("optimus", optimus); enumerator->AddBool("optimus", optimus);
enumerator->AddBool("amdSwitchable", amd_switchable); enumerator->AddBool("amdSwitchable", amd_switchable);
enumerator->AddString("pixelShaderVersion", pixel_shader_version); enumerator->AddString("pixelShaderVersion", pixel_shader_version);
...@@ -301,8 +301,7 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { ...@@ -301,8 +301,7 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
enumerator->AddString("glWsVendor", gl_ws_vendor); enumerator->AddString("glWsVendor", gl_ws_vendor);
enumerator->AddString("glWsVersion", gl_ws_version); enumerator->AddString("glWsVersion", gl_ws_version);
enumerator->AddString("glWsExtensions", gl_ws_extensions); enumerator->AddString("glWsExtensions", gl_ws_extensions);
enumerator->AddInt( enumerator->AddInt("glResetNotificationStrategy",
"glResetNotificationStrategy",
static_cast<int>(gl_reset_notification_strategy)); static_cast<int>(gl_reset_notification_strategy));
// TODO(kbr): add performance_stats. // TODO(kbr): add performance_stats.
enumerator->AddBool("softwareRendering", software_rendering); enumerator->AddBool("softwareRendering", software_rendering);
...@@ -310,26 +309,22 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { ...@@ -310,26 +309,22 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
enumerator->AddBool("sandboxed", sandboxed); enumerator->AddBool("sandboxed", sandboxed);
enumerator->AddBool("inProcessGpu", in_process_gpu); enumerator->AddBool("inProcessGpu", in_process_gpu);
enumerator->AddBool("passthroughCmdDecoder", passthrough_cmd_decoder); enumerator->AddBool("passthroughCmdDecoder", passthrough_cmd_decoder);
enumerator->AddBool("canSupportThreadedTextureMailbox", enumerator->AddBool("canSupportThreadedTextureMailbox", can_support_threaded_texture_mailbox);
can_support_threaded_texture_mailbox);
// TODO(kbr): add dx_diagnostics on Windows. // TODO(kbr): add dx_diagnostics on Windows.
#if defined(OS_WIN) #if defined(OS_WIN)
enumerator->AddBool("directComposition", direct_composition); enumerator->AddBool("directComposition", direct_composition);
enumerator->AddBool("supportsOverlays", supports_overlays); enumerator->AddBool("supportsOverlays", supports_overlays);
for (const auto& cap : overlay_capabilities) for (const auto &cap : overlay_capabilities)
EnumerateOverlayCapability(cap, enumerator); EnumerateOverlayCapability(cap, enumerator);
EnumerateDx12VulkanVersionInfo(dx12_vulkan_version_info, enumerator); EnumerateDx12VulkanVersionInfo(dx12_vulkan_version_info, enumerator);
#endif #endif
enumerator->AddInt("videoDecodeAcceleratorFlags", enumerator->AddInt("videoDecodeAcceleratorFlags", video_decode_accelerator_capabilities.flags);
video_decode_accelerator_capabilities.flags); for (const auto &profile : video_decode_accelerator_capabilities.supported_profiles)
for (const auto& profile :
video_decode_accelerator_capabilities.supported_profiles)
EnumerateVideoDecodeAcceleratorSupportedProfile(profile, enumerator); EnumerateVideoDecodeAcceleratorSupportedProfile(profile, enumerator);
for (const auto& profile : video_encode_accelerator_supported_profiles) for (const auto &profile : video_encode_accelerator_supported_profiles)
EnumerateVideoEncodeAcceleratorSupportedProfile(profile, enumerator); EnumerateVideoEncodeAcceleratorSupportedProfile(profile, enumerator);
enumerator->AddBool("jpegDecodeAcceleratorSupported", enumerator->AddBool("jpegDecodeAcceleratorSupported", jpeg_decode_accelerator_supported);
jpeg_decode_accelerator_supported); for (const auto &profile : image_decode_accelerator_supported_profiles)
for (const auto& profile : image_decode_accelerator_supported_profiles)
EnumerateImageDecodeAcceleratorSupportedProfile(profile, enumerator); EnumerateImageDecodeAcceleratorSupportedProfile(profile, enumerator);
#if defined(USE_X11) #if defined(USE_X11)
enumerator->AddInt64("systemVisual", system_visual); enumerator->AddInt64("systemVisual", system_visual);
......
...@@ -13,17 +13,19 @@ ...@@ -13,17 +13,19 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "angle_config.h" #include "gpu_test_config.h"
#if defined(USE_X11) #if defined(USE_X11)
typedef unsigned long VisualID; typedef unsigned long VisualID;
#endif #endif
namespace gpu { namespace gpu
{
// These values are persisted to logs. Entries should not be renumbered and // These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused. // numeric values should never be reused.
enum class GpuSeriesType { enum class GpuSeriesType
{
kUnknown = 0, kUnknown = 0,
// Intel 6th gen // Intel 6th gen
kIntelSandyBridge = 1, kIntelSandyBridge = 1,
...@@ -45,7 +47,8 @@ enum class GpuSeriesType { ...@@ -45,7 +47,8 @@ enum class GpuSeriesType {
}; };
// Video profile. This *must* match media::VideoCodecProfile. // Video profile. This *must* match media::VideoCodecProfile.
enum VideoCodecProfile { enum VideoCodecProfile
{
VIDEO_CODEC_PROFILE_UNKNOWN = -1, VIDEO_CODEC_PROFILE_UNKNOWN = -1,
VIDEO_CODEC_PROFILE_MIN = VIDEO_CODEC_PROFILE_UNKNOWN, VIDEO_CODEC_PROFILE_MIN = VIDEO_CODEC_PROFILE_UNKNOWN,
H264PROFILE_BASELINE = 0, H264PROFILE_BASELINE = 0,
...@@ -79,59 +82,60 @@ enum VideoCodecProfile { ...@@ -79,59 +82,60 @@ enum VideoCodecProfile {
}; };
// Specification of a decoding profile supported by a hardware decoder. // Specification of a decoding profile supported by a hardware decoder.
struct GPU_EXPORT VideoDecodeAcceleratorSupportedProfile { struct GPU_EXPORT VideoDecodeAcceleratorSupportedProfile
{
VideoCodecProfile profile; VideoCodecProfile profile;
gfx::Size max_resolution; gfx::Size max_resolution;
gfx::Size min_resolution; gfx::Size min_resolution;
bool encrypted_only; bool encrypted_only;
}; };
using VideoDecodeAcceleratorSupportedProfiles = using VideoDecodeAcceleratorSupportedProfiles = std::vector<VideoDecodeAcceleratorSupportedProfile>;
std::vector<VideoDecodeAcceleratorSupportedProfile>;
struct GPU_EXPORT VideoDecodeAcceleratorCapabilities { struct GPU_EXPORT VideoDecodeAcceleratorCapabilities
{
VideoDecodeAcceleratorCapabilities(); VideoDecodeAcceleratorCapabilities();
VideoDecodeAcceleratorCapabilities( VideoDecodeAcceleratorCapabilities(const VideoDecodeAcceleratorCapabilities &other);
const VideoDecodeAcceleratorCapabilities& other);
~VideoDecodeAcceleratorCapabilities(); ~VideoDecodeAcceleratorCapabilities();
VideoDecodeAcceleratorSupportedProfiles supported_profiles; VideoDecodeAcceleratorSupportedProfiles supported_profiles;
uint32_t flags; uint32_t flags;
}; };
// Specification of an encoding profile supported by a hardware encoder. // Specification of an encoding profile supported by a hardware encoder.
struct GPU_EXPORT VideoEncodeAcceleratorSupportedProfile { struct GPU_EXPORT VideoEncodeAcceleratorSupportedProfile
{
VideoCodecProfile profile; VideoCodecProfile profile;
gfx::Size max_resolution; gfx::Size max_resolution;
uint32_t max_framerate_numerator; uint32_t max_framerate_numerator;
uint32_t max_framerate_denominator; uint32_t max_framerate_denominator;
}; };
using VideoEncodeAcceleratorSupportedProfiles = using VideoEncodeAcceleratorSupportedProfiles = std::vector<VideoEncodeAcceleratorSupportedProfile>;
std::vector<VideoEncodeAcceleratorSupportedProfile>;
enum class ImageDecodeAcceleratorType { enum class ImageDecodeAcceleratorType
{
kJpeg = 0, kJpeg = 0,
kUnknown = 1, kUnknown = 1,
kMaxValue = kUnknown, kMaxValue = kUnknown,
}; };
enum class ImageDecodeAcceleratorSubsampling { enum class ImageDecodeAcceleratorSubsampling
{
k420 = 0, k420 = 0,
k422 = 1, k422 = 1,
kMaxValue = k422, kMaxValue = k422,
}; };
// Specification of an image decoding profile supported by a hardware decoder. // Specification of an image decoding profile supported by a hardware decoder.
struct GPU_EXPORT ImageDecodeAcceleratorSupportedProfile { struct GPU_EXPORT ImageDecodeAcceleratorSupportedProfile
{
ImageDecodeAcceleratorSupportedProfile(); ImageDecodeAcceleratorSupportedProfile();
ImageDecodeAcceleratorSupportedProfile( ImageDecodeAcceleratorSupportedProfile(const ImageDecodeAcceleratorSupportedProfile &other);
const ImageDecodeAcceleratorSupportedProfile& other); ImageDecodeAcceleratorSupportedProfile(ImageDecodeAcceleratorSupportedProfile &&other);
ImageDecodeAcceleratorSupportedProfile(
ImageDecodeAcceleratorSupportedProfile&& other);
~ImageDecodeAcceleratorSupportedProfile(); ~ImageDecodeAcceleratorSupportedProfile();
ImageDecodeAcceleratorSupportedProfile& operator=( ImageDecodeAcceleratorSupportedProfile &operator=(
const ImageDecodeAcceleratorSupportedProfile& other); const ImageDecodeAcceleratorSupportedProfile &other);
ImageDecodeAcceleratorSupportedProfile& operator=( ImageDecodeAcceleratorSupportedProfile &operator=(
ImageDecodeAcceleratorSupportedProfile&& other); ImageDecodeAcceleratorSupportedProfile &&other);
// Fields common to all image types. // Fields common to all image types.
// Type of image to which this profile applies, e.g., JPEG. // Type of image to which this profile applies, e.g., JPEG.
...@@ -144,25 +148,32 @@ struct GPU_EXPORT ImageDecodeAcceleratorSupportedProfile { ...@@ -144,25 +148,32 @@ struct GPU_EXPORT ImageDecodeAcceleratorSupportedProfile {
// The supported chroma subsampling formats, e.g. 4:2:0. // The supported chroma subsampling formats, e.g. 4:2:0.
std::vector<ImageDecodeAcceleratorSubsampling> subsamplings; std::vector<ImageDecodeAcceleratorSubsampling> subsamplings;
}; };
using ImageDecodeAcceleratorSupportedProfiles = using ImageDecodeAcceleratorSupportedProfiles = std::vector<ImageDecodeAcceleratorSupportedProfile>;
std::vector<ImageDecodeAcceleratorSupportedProfile>;
#if defined(OS_WIN) #if defined(OS_WIN)
// Common overlay formats that we're interested in. Must match the OverlayFormat // Common overlay formats that we're interested in. Must match the OverlayFormat
// enum in //tools/metrics/histograms/enums.xml. Mapped to corresponding DXGI // enum in //tools/metrics/histograms/enums.xml. Mapped to corresponding DXGI
// formats in DirectCompositionSurfaceWin. // formats in DirectCompositionSurfaceWin.
enum class OverlayFormat { kBGRA = 0, kYUY2 = 1, kNV12 = 2, kMaxValue = kNV12 }; enum class OverlayFormat
{
kBGRA = 0,
kYUY2 = 1,
kNV12 = 2,
kMaxValue = kNV12
};
GPU_EXPORT const char* OverlayFormatToString(OverlayFormat format); GPU_EXPORT const char *OverlayFormatToString(OverlayFormat format);
struct GPU_EXPORT OverlayCapability { struct GPU_EXPORT OverlayCapability
{
OverlayFormat format; OverlayFormat format;
bool is_scaling_supported; bool is_scaling_supported;
bool operator==(const OverlayCapability& other) const; bool operator==(const OverlayCapability &other) const;
}; };
using OverlayCapabilities = std::vector<OverlayCapability>; using OverlayCapabilities = std::vector<OverlayCapability>;
struct GPU_EXPORT Dx12VulkanVersionInfo { struct GPU_EXPORT Dx12VulkanVersionInfo
{
bool IsEmpty() const { return !d3d12_feature_level && !vulkan_version; } bool IsEmpty() const { return !d3d12_feature_level && !vulkan_version; }
// True if the GPU driver supports DX12. // True if the GPU driver supports DX12.
...@@ -179,14 +190,16 @@ struct GPU_EXPORT Dx12VulkanVersionInfo { ...@@ -179,14 +190,16 @@ struct GPU_EXPORT Dx12VulkanVersionInfo {
}; };
#endif #endif
struct GPU_EXPORT GPUInfo { struct GPU_EXPORT GPUInfo
struct GPU_EXPORT GPUDevice { {
struct GPU_EXPORT GPUDevice
{
GPUDevice(); GPUDevice();
GPUDevice(const GPUDevice& other); GPUDevice(const GPUDevice &other);
GPUDevice(GPUDevice&& other) noexcept; GPUDevice(GPUDevice &&other) noexcept;
~GPUDevice() noexcept; ~GPUDevice() noexcept;
GPUDevice& operator=(const GPUDevice& other); GPUDevice &operator=(const GPUDevice &other);
GPUDevice& operator=(GPUDevice&& other) noexcept; GPUDevice &operator=(GPUDevice &&other) noexcept;
// The DWORD (uint32_t) representing the graphics card vendor id. // The DWORD (uint32_t) representing the graphics card vendor id.
uint32_t vendor_id; uint32_t vendor_id;
...@@ -216,12 +229,12 @@ struct GPU_EXPORT GPUInfo { ...@@ -216,12 +229,12 @@ struct GPU_EXPORT GPUInfo {
}; };
GPUInfo(); GPUInfo();
GPUInfo(const GPUInfo& other); GPUInfo(const GPUInfo &other);
~GPUInfo(); ~GPUInfo();
// The currently active gpu. // The currently active gpu.
GPUDevice& active_gpu(); GPUDevice &active_gpu();
const GPUDevice& active_gpu() const; const GPUDevice &active_gpu() const;
bool IsInitialized() const; bool IsInitialized() const;
...@@ -324,12 +337,10 @@ struct GPU_EXPORT GPUInfo { ...@@ -324,12 +337,10 @@ struct GPU_EXPORT GPUInfo {
#endif #endif
VideoDecodeAcceleratorCapabilities video_decode_accelerator_capabilities; VideoDecodeAcceleratorCapabilities video_decode_accelerator_capabilities;
VideoEncodeAcceleratorSupportedProfiles VideoEncodeAcceleratorSupportedProfiles video_encode_accelerator_supported_profiles;
video_encode_accelerator_supported_profiles;
bool jpeg_decode_accelerator_supported; bool jpeg_decode_accelerator_supported;
ImageDecodeAcceleratorSupportedProfiles ImageDecodeAcceleratorSupportedProfiles image_decode_accelerator_supported_profiles;
image_decode_accelerator_supported_profiles;
#if defined(USE_X11) #if defined(USE_X11)
VisualID system_visual; VisualID system_visual;
...@@ -345,18 +356,18 @@ struct GPU_EXPORT GPUInfo { ...@@ -345,18 +356,18 @@ struct GPU_EXPORT GPUInfo {
// enumerate the values in this structure without having to embed // enumerate the values in this structure without having to embed
// references to its specific member variables. This simplifies the // references to its specific member variables. This simplifies the
// addition of new fields to this type. // addition of new fields to this type.
class Enumerator { class Enumerator
{
public: public:
// The following methods apply to the "current" object. Initially this // The following methods apply to the "current" object. Initially this
// is the root object, but calls to BeginGPUDevice/EndGPUDevice and // is the root object, but calls to BeginGPUDevice/EndGPUDevice and
// BeginAuxAttributes/EndAuxAttributes change the object to which these // BeginAuxAttributes/EndAuxAttributes change the object to which these
// calls should apply. // calls should apply.
virtual void AddInt64(const char* name, int64_t value) = 0; virtual void AddInt64(const char *name, int64_t value) = 0;
virtual void AddInt(const char* name, int value) = 0; virtual void AddInt(const char *name, int value) = 0;
virtual void AddString(const char* name, const std::string& value) = 0; virtual void AddString(const char *name, const std::string &value) = 0;
virtual void AddBool(const char* name, bool value) = 0; virtual void AddBool(const char *name, bool value) = 0;
virtual void AddTimeDeltaInSecondsF(const char* name, virtual void AddTimeDeltaInSecondsF(const char *name, const base::TimeDelta &value) = 0;
const base::TimeDelta& value) = 0;
// Markers indicating that a GPUDevice is being described. // Markers indicating that a GPUDevice is being described.
virtual void BeginGPUDevice() = 0; virtual void BeginGPUDevice() = 0;
...@@ -393,7 +404,7 @@ struct GPU_EXPORT GPUInfo { ...@@ -393,7 +404,7 @@ struct GPU_EXPORT GPUInfo {
}; };
// Outputs the fields in this structure to the provided enumerator. // Outputs the fields in this structure to the provided enumerator.
void EnumerateFields(Enumerator* enumerator) const; void EnumerateFields(Enumerator *enumerator) const;
}; };
} // namespace gpu } // namespace gpu
......
...@@ -11,34 +11,38 @@ ...@@ -11,34 +11,38 @@
#include "gpu_test_expectations_parser.h" #include "gpu_test_expectations_parser.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "gpu_test_config_mac.h" # include "gpu_test_config_mac.h"
#endif #endif
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
#include "gpu_info_util/SystemInfo.h" # include "gpu_info_util/SystemInfo.h"
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
namespace base { namespace base
namespace { {
namespace
{
// Disable the deprecated function warning for GetVersionEx // Disable the deprecated function warning for GetVersionEx
#pragma warning(disable: 4996) # pragma warning(disable : 4996)
class SysInfo class SysInfo
{ {
public: public:
static void OperatingSystemVersionNumbers( static void OperatingSystemVersionNumbers(int32_t *major_version,
int32_t *major_version, int32_t *minor_version, int32_t *bugfix_version); int32_t *minor_version,
int32_t *bugfix_version);
}; };
// static // static
void SysInfo::OperatingSystemVersionNumbers( void SysInfo::OperatingSystemVersionNumbers(int32_t *major_version,
int32_t *major_version, int32_t *minor_version, int32_t *bugfix_version) int32_t *minor_version,
int32_t *bugfix_version)
{ {
OSVERSIONINFOEX version_info = { sizeof version_info }; OSVERSIONINFOEX version_info = {sizeof version_info};
::GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&version_info)); ::GetVersionEx(reinterpret_cast<OSVERSIONINFO *>(&version_info));
*major_version = version_info.dwMajorVersion; *major_version = version_info.dwMajorVersion;
*minor_version = version_info.dwMinorVersion; *minor_version = version_info.dwMinorVersion;
*bugfix_version = version_info.dwBuildNumber; *bugfix_version = version_info.dwBuildNumber;
...@@ -49,11 +53,14 @@ void SysInfo::OperatingSystemVersionNumbers( ...@@ -49,11 +53,14 @@ void SysInfo::OperatingSystemVersionNumbers(
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
namespace gpu { namespace gpu
{
namespace { namespace
{
GPUTestConfig::OS GetCurrentOS() { GPUTestConfig::OS GetCurrentOS()
{
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
return GPUTestConfig::kOsChromeOS; return GPUTestConfig::kOsChromeOS;
#elif defined(OS_LINUX) || defined(OS_OPENBSD) #elif defined(OS_LINUX) || defined(OS_OPENBSD)
...@@ -62,8 +69,7 @@ GPUTestConfig::OS GetCurrentOS() { ...@@ -62,8 +69,7 @@ GPUTestConfig::OS GetCurrentOS() {
int32_t major_version = 0; int32_t major_version = 0;
int32_t minor_version = 0; int32_t minor_version = 0;
int32_t bugfix_version = 0; int32_t bugfix_version = 0;
base::SysInfo::OperatingSystemVersionNumbers( base::SysInfo::OperatingSystemVersionNumbers(&major_version, &minor_version, &bugfix_version);
&major_version, &minor_version, &bugfix_version);
if (major_version == 5) if (major_version == 5)
return GPUTestConfig::kOsWinXP; return GPUTestConfig::kOsWinXP;
if (major_version == 6 && minor_version == 0) if (major_version == 6 && minor_version == 0)
...@@ -79,8 +85,10 @@ GPUTestConfig::OS GetCurrentOS() { ...@@ -79,8 +85,10 @@ GPUTestConfig::OS GetCurrentOS() {
int32_t minor_version = 0; int32_t minor_version = 0;
int32_t bugfix_version = 0; int32_t bugfix_version = 0;
angle::GetOperatingSystemVersionNumbers(&major_version, &minor_version, &bugfix_version); angle::GetOperatingSystemVersionNumbers(&major_version, &minor_version, &bugfix_version);
if (major_version == 10) { if (major_version == 10)
switch (minor_version) { {
switch (minor_version)
{
case 5: case 5:
return GPUTestConfig::kOsMacLeopard; return GPUTestConfig::kOsMacLeopard;
case 6: case 6:
...@@ -112,66 +120,75 @@ GPUTestConfig::OS GetCurrentOS() { ...@@ -112,66 +120,75 @@ GPUTestConfig::OS GetCurrentOS() {
} }
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
bool CollectBasicGraphicsInfo(GPUInfo* gpu_info) { bool CollectBasicGraphicsInfo(GPUInfo *gpu_info)
{
angle::SystemInfo info; angle::SystemInfo info;
if (!angle::GetSystemInfo(&info)) { if (!angle::GetSystemInfo(&info))
{
return false; return false;
} }
const angle::GPUDeviceInfo& gpu = info.gpus[info.primaryGPUIndex]; const angle::GPUDeviceInfo &gpu = info.gpus[info.primaryGPUIndex];
gpu_info->gpu.vendor_id = gpu.vendorId; gpu_info->gpu.vendor_id = gpu.vendorId;
gpu_info->gpu.device_id = gpu.deviceId; gpu_info->gpu.device_id = gpu.deviceId;
gpu_info->gpu.active = true; gpu_info->gpu.active = true;
return true; return true;
} }
#else #else
bool CollectBasicGraphicsInfo(GPUInfo* gpu_info) { bool CollectBasicGraphicsInfo(GPUInfo *gpu_info)
{
gpu_info->gpu.vendor_id = 0; gpu_info->gpu.vendor_id = 0;
gpu_info->gpu.device_id = 0; gpu_info->gpu.device_id = 0;
gpu_info->gpu.active = true; gpu_info->gpu.active = true;
return false; return false;
} }
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
} // namespace anonymous } // namespace
GPUTestConfig::GPUTestConfig() GPUTestConfig::GPUTestConfig()
: validate_gpu_info_(true), : validate_gpu_info_(true),
os_(kOsUnknown), os_(kOsUnknown),
gpu_device_id_(0), gpu_device_id_(0),
build_type_(kBuildTypeUnknown), build_type_(kBuildTypeUnknown),
api_(kAPIUnknown) {} api_(kAPIUnknown)
{}
GPUTestConfig::GPUTestConfig(const GPUTestConfig& other) = default; GPUTestConfig::GPUTestConfig(const GPUTestConfig &other) = default;
GPUTestConfig::~GPUTestConfig() = default; GPUTestConfig::~GPUTestConfig() = default;
void GPUTestConfig::set_os(int32_t os) { void GPUTestConfig::set_os(int32_t os)
DCHECK_EQ(0, os & ~(kOsAndroid | kOsWin | kOsMac | kOsLinux | kOsChromeOS | {
kOsFuchsia)); DCHECK_EQ(0, os & ~(kOsAndroid | kOsWin | kOsMac | kOsLinux | kOsChromeOS | kOsFuchsia));
os_ = os; os_ = os;
} }
void GPUTestConfig::AddGPUVendor(uint32_t gpu_vendor) { void GPUTestConfig::AddGPUVendor(uint32_t gpu_vendor)
{
DCHECK_NE(0u, gpu_vendor); DCHECK_NE(0u, gpu_vendor);
for (size_t i = 0; i < gpu_vendor_.size(); ++i) for (size_t i = 0; i < gpu_vendor_.size(); ++i)
DCHECK_NE(gpu_vendor_[i], gpu_vendor); DCHECK_NE(gpu_vendor_[i], gpu_vendor);
gpu_vendor_.push_back(gpu_vendor); gpu_vendor_.push_back(gpu_vendor);
} }
void GPUTestConfig::set_gpu_device_id(uint32_t id) { void GPUTestConfig::set_gpu_device_id(uint32_t id)
{
gpu_device_id_ = id; gpu_device_id_ = id;
} }
void GPUTestConfig::set_build_type(int32_t build_type) { void GPUTestConfig::set_build_type(int32_t build_type)
{
DCHECK_EQ(0, build_type & ~(kBuildTypeRelease | kBuildTypeDebug)); DCHECK_EQ(0, build_type & ~(kBuildTypeRelease | kBuildTypeDebug));
build_type_ = build_type; build_type_ = build_type;
} }
void GPUTestConfig::set_api(int32_t api) { void GPUTestConfig::set_api(int32_t api)
{
DCHECK_EQ(0, api & ~(kAPID3D9 | kAPID3D11 | kAPIGLDesktop | kAPIGLES | kAPIVulkan)); DCHECK_EQ(0, api & ~(kAPID3D9 | kAPID3D11 | kAPIGLDesktop | kAPIGLES | kAPIVulkan));
api_ = api; api_ = api;
} }
bool GPUTestConfig::IsValid() const { bool GPUTestConfig::IsValid() const
{
if (!validate_gpu_info_) if (!validate_gpu_info_)
return true; return true;
if (gpu_device_id_ != 0 && (gpu_vendor_.size() != 1 || gpu_vendor_[0] == 0)) if (gpu_device_id_ != 0 && (gpu_vendor_.size() != 1 || gpu_vendor_[0] == 0))
...@@ -179,17 +196,21 @@ bool GPUTestConfig::IsValid() const { ...@@ -179,17 +196,21 @@ bool GPUTestConfig::IsValid() const {
return true; return true;
} }
bool GPUTestConfig::OverlapsWith(const GPUTestConfig& config) const { bool GPUTestConfig::OverlapsWith(const GPUTestConfig &config) const
{
DCHECK(IsValid()); DCHECK(IsValid());
DCHECK(config.IsValid()); DCHECK(config.IsValid());
if (config.os_ != kOsUnknown && os_ != kOsUnknown && if (config.os_ != kOsUnknown && os_ != kOsUnknown && (os_ & config.os_) == 0)
(os_ & config.os_) == 0)
return false; return false;
if (config.gpu_vendor_.size() > 0 && gpu_vendor_.size() > 0) { if (config.gpu_vendor_.size() > 0 && gpu_vendor_.size() > 0)
{
bool shared = false; bool shared = false;
for (size_t i = 0; i < config.gpu_vendor_.size() && !shared; ++i) { for (size_t i = 0; i < config.gpu_vendor_.size() && !shared; ++i)
for (size_t j = 0; j < gpu_vendor_.size(); ++j) { {
if (config.gpu_vendor_[i] == gpu_vendor_[j]) { for (size_t j = 0; j < gpu_vendor_.size(); ++j)
{
if (config.gpu_vendor_[i] == gpu_vendor_[j])
{
shared = true; shared = true;
break; break;
} }
...@@ -201,8 +222,7 @@ bool GPUTestConfig::OverlapsWith(const GPUTestConfig& config) const { ...@@ -201,8 +222,7 @@ bool GPUTestConfig::OverlapsWith(const GPUTestConfig& config) const {
if (config.gpu_device_id_ != 0 && gpu_device_id_ != 0 && if (config.gpu_device_id_ != 0 && gpu_device_id_ != 0 &&
gpu_device_id_ != config.gpu_device_id_) gpu_device_id_ != config.gpu_device_id_)
return false; return false;
if (config.build_type_ != kBuildTypeUnknown && if (config.build_type_ != kBuildTypeUnknown && build_type_ != kBuildTypeUnknown &&
build_type_ != kBuildTypeUnknown &&
(build_type_ & config.build_type_) == 0) (build_type_ & config.build_type_) == 0)
return false; return false;
if (config.api() != kAPIUnknown && api_ != kAPIUnknown && api_ != config.api_) if (config.api() != kAPIUnknown && api_ != kAPIUnknown && api_ != config.api_)
...@@ -210,22 +230,26 @@ bool GPUTestConfig::OverlapsWith(const GPUTestConfig& config) const { ...@@ -210,22 +230,26 @@ bool GPUTestConfig::OverlapsWith(const GPUTestConfig& config) const {
return true; return true;
} }
void GPUTestConfig::DisableGPUInfoValidation() { void GPUTestConfig::DisableGPUInfoValidation()
{
validate_gpu_info_ = false; validate_gpu_info_ = false;
} }
void GPUTestConfig::ClearGPUVendor() { void GPUTestConfig::ClearGPUVendor()
{
gpu_vendor_.clear(); gpu_vendor_.clear();
} }
GPUTestBotConfig::~GPUTestBotConfig() = default; GPUTestBotConfig::~GPUTestBotConfig() = default;
void GPUTestBotConfig::AddGPUVendor(uint32_t gpu_vendor) { void GPUTestBotConfig::AddGPUVendor(uint32_t gpu_vendor)
{
DCHECK_EQ(0u, GPUTestConfig::gpu_vendor().size()); DCHECK_EQ(0u, GPUTestConfig::gpu_vendor().size());
GPUTestConfig::AddGPUVendor(gpu_vendor); GPUTestConfig::AddGPUVendor(gpu_vendor);
} }
bool GPUTestBotConfig::SetGPUInfo(const GPUInfo& gpu_info) { bool GPUTestBotConfig::SetGPUInfo(const GPUInfo &gpu_info)
{
DCHECK(validate_gpu_info_); DCHECK(validate_gpu_info_);
if (gpu_info.gpu.device_id == 0 || gpu_info.gpu.vendor_id == 0) if (gpu_info.gpu.device_id == 0 || gpu_info.gpu.vendor_id == 0)
return false; return false;
...@@ -235,8 +259,10 @@ bool GPUTestBotConfig::SetGPUInfo(const GPUInfo& gpu_info) { ...@@ -235,8 +259,10 @@ bool GPUTestBotConfig::SetGPUInfo(const GPUInfo& gpu_info) {
return true; return true;
} }
bool GPUTestBotConfig::IsValid() const { bool GPUTestBotConfig::IsValid() const
switch (os()) { {
switch (os())
{
case kOsWinXP: case kOsWinXP:
case kOsWinVista: case kOsWinVista:
case kOsWin7: case kOsWin7:
...@@ -260,13 +286,15 @@ bool GPUTestBotConfig::IsValid() const { ...@@ -260,13 +286,15 @@ bool GPUTestBotConfig::IsValid() const {
default: default:
return false; return false;
} }
if (validate_gpu_info_) { if (validate_gpu_info_)
{
if (gpu_vendor().size() != 1 || gpu_vendor()[0] == 0) if (gpu_vendor().size() != 1 || gpu_vendor()[0] == 0)
return false; return false;
if (gpu_device_id() == 0) if (gpu_device_id() == 0)
return false; return false;
} }
switch (build_type()) { switch (build_type())
{
case kBuildTypeRelease: case kBuildTypeRelease:
case kBuildTypeDebug: case kBuildTypeDebug:
break; break;
...@@ -276,15 +304,19 @@ bool GPUTestBotConfig::IsValid() const { ...@@ -276,15 +304,19 @@ bool GPUTestBotConfig::IsValid() const {
return true; return true;
} }
bool GPUTestBotConfig::Matches(const GPUTestConfig& config) const { bool GPUTestBotConfig::Matches(const GPUTestConfig &config) const
{
DCHECK(IsValid()); DCHECK(IsValid());
DCHECK(config.IsValid()); DCHECK(config.IsValid());
if (config.os() != kOsUnknown && (os() & config.os()) == 0) if (config.os() != kOsUnknown && (os() & config.os()) == 0)
return false; return false;
if (config.gpu_vendor().size() > 0) { if (config.gpu_vendor().size() > 0)
{
bool contained = false; bool contained = false;
for (size_t i = 0; i < config.gpu_vendor().size(); ++i) { for (size_t i = 0; i < config.gpu_vendor().size(); ++i)
if (!gpu_vendor().empty() && config.gpu_vendor()[i] == gpu_vendor()[0]) { {
if (!gpu_vendor().empty() && config.gpu_vendor()[i] == gpu_vendor()[0])
{
contained = true; contained = true;
break; break;
} }
...@@ -292,18 +324,17 @@ bool GPUTestBotConfig::Matches(const GPUTestConfig& config) const { ...@@ -292,18 +324,17 @@ bool GPUTestBotConfig::Matches(const GPUTestConfig& config) const {
if (!contained) if (!contained)
return false; return false;
} }
if (config.gpu_device_id() != 0 && if (config.gpu_device_id() != 0 && gpu_device_id() != config.gpu_device_id())
gpu_device_id() != config.gpu_device_id())
return false; return false;
if (config.build_type() != kBuildTypeUnknown && if (config.build_type() != kBuildTypeUnknown && (build_type() & config.build_type()) == 0)
(build_type() & config.build_type()) == 0)
return false; return false;
if (config.api() != 0 && (api() & config.api()) == 0) if (config.api() != 0 && (api() & config.api()) == 0)
return false; return false;
return true; return true;
} }
bool GPUTestBotConfig::Matches(const std::string& config_data) const { bool GPUTestBotConfig::Matches(const std::string &config_data) const
{
GPUTestExpectationsParser parser; GPUTestExpectationsParser parser;
GPUTestConfig config; GPUTestConfig config;
...@@ -312,22 +343,30 @@ bool GPUTestBotConfig::Matches(const std::string& config_data) const { ...@@ -312,22 +343,30 @@ bool GPUTestBotConfig::Matches(const std::string& config_data) const {
return Matches(config); return Matches(config);
} }
bool GPUTestBotConfig::LoadCurrentConfig(const GPUInfo* gpu_info) { bool GPUTestBotConfig::LoadCurrentConfig(const GPUInfo *gpu_info)
{
bool rt; bool rt;
if (!gpu_info) { if (!gpu_info)
{
GPUInfo my_gpu_info; GPUInfo my_gpu_info;
if (!CollectBasicGraphicsInfo(&my_gpu_info)) { if (!CollectBasicGraphicsInfo(&my_gpu_info))
{
LOG(ERROR) << "Fail to identify GPU\n"; LOG(ERROR) << "Fail to identify GPU\n";
DisableGPUInfoValidation(); DisableGPUInfoValidation();
rt = true; rt = true;
} else { }
else
{
rt = SetGPUInfo(my_gpu_info); rt = SetGPUInfo(my_gpu_info);
} }
} else { }
else
{
rt = SetGPUInfo(*gpu_info); rt = SetGPUInfo(*gpu_info);
} }
set_os(GetCurrentOS()); set_os(GetCurrentOS());
if (os() == kOsUnknown) { if (os() == kOsUnknown)
{
LOG(ERROR) << "Unknown OS\n"; LOG(ERROR) << "Unknown OS\n";
rt = false; rt = false;
} }
...@@ -340,7 +379,8 @@ bool GPUTestBotConfig::LoadCurrentConfig(const GPUInfo* gpu_info) { ...@@ -340,7 +379,8 @@ bool GPUTestBotConfig::LoadCurrentConfig(const GPUInfo* gpu_info) {
} }
// static // static
bool GPUTestBotConfig::CurrentConfigMatches(const std::string& config_data) { bool GPUTestBotConfig::CurrentConfigMatches(const std::string &config_data)
{
GPUTestBotConfig my_config; GPUTestBotConfig my_config;
if (!my_config.LoadCurrentConfig(nullptr)) if (!my_config.LoadCurrentConfig(nullptr))
return false; return false;
...@@ -348,12 +388,13 @@ bool GPUTestBotConfig::CurrentConfigMatches(const std::string& config_data) { ...@@ -348,12 +388,13 @@ bool GPUTestBotConfig::CurrentConfigMatches(const std::string& config_data) {
} }
// static // static
bool GPUTestBotConfig::CurrentConfigMatches( bool GPUTestBotConfig::CurrentConfigMatches(const std::vector<std::string> &configs)
const std::vector<std::string>& configs) { {
GPUTestBotConfig my_config; GPUTestBotConfig my_config;
if (!my_config.LoadCurrentConfig(nullptr)) if (!my_config.LoadCurrentConfig(nullptr))
return false; return false;
for (size_t i = 0 ; i < configs.size(); ++i) { for (size_t i = 0; i < configs.size(); ++i)
{
if (my_config.Matches(configs[i])) if (my_config.Matches(configs[i]))
return true; return true;
} }
...@@ -361,7 +402,8 @@ bool GPUTestBotConfig::CurrentConfigMatches( ...@@ -361,7 +402,8 @@ bool GPUTestBotConfig::CurrentConfigMatches(
} }
// static // static
bool GPUTestBotConfig::GpuBlacklistedOnBot() { bool GPUTestBotConfig::GpuBlacklistedOnBot()
{
return false; return false;
} }
......
// // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
//
// angle_config.h:
// Helpers for importing the gpu test expectations package from Chrome.
//
#ifndef ANGLE_GPU_TEST_EXPECTATIONS_ANGLE_CONFIG_H_ #ifndef ANGLE_GPU_CONFIG_GPU_TEST_CONFIG_H_
#define ANGLE_GPU_TEST_EXPECTATIONS_ANGLE_CONFIG_H_ #define ANGLE_GPU_CONFIG_GPU_TEST_CONFIG_H_
#include <stdint.h> #include <stdint.h>
#include <iostream> #include <iostream>
#include <string>
#include <vector>
#include "common/debug.h" #include "common/debug.h"
#include "common/string_utils.h" #include "common/string_utils.h"
...@@ -73,4 +69,145 @@ struct DxDiagNode ...@@ -73,4 +69,145 @@ struct DxDiagNode
#endif #endif
// clang-format on // clang-format on
#endif namespace gpu
{
struct GPUInfo;
class GPU_EXPORT GPUTestConfig
{
public:
enum OS
{
kOsUnknown = 0,
kOsWinXP = 1 << 0,
kOsWinVista = 1 << 1,
kOsWin7 = 1 << 2,
kOsWin8 = 1 << 3,
kOsMacLeopard = 1 << 4,
kOsMacSnowLeopard = 1 << 5,
kOsMacLion = 1 << 6,
kOsMacMountainLion = 1 << 7,
kOsMacMavericks = 1 << 8,
kOsMacYosemite = 1 << 9,
kOsMacElCapitan = 1 << 10,
kOsMacSierra = 1 << 11,
kOsMacHighSierra = 1 << 12,
kOsMacMojave = 1 << 13,
kOsMac = kOsMacLeopard | kOsMacSnowLeopard | kOsMacLion | kOsMacMountainLion |
kOsMacMavericks | kOsMacYosemite | kOsMacElCapitan | kOsMacSierra |
kOsMacHighSierra | kOsMacMojave,
kOsLinux = 1 << 14,
kOsChromeOS = 1 << 15,
kOsAndroid = 1 << 16,
kOsWin10 = 1 << 17,
kOsWin = kOsWinXP | kOsWinVista | kOsWin7 | kOsWin8 | kOsWin10,
kOsFuchsia = 1 << 18,
};
enum BuildType
{
kBuildTypeUnknown = 0,
kBuildTypeRelease = 1 << 0,
kBuildTypeDebug = 1 << 1,
};
enum API
{
kAPIUnknown = 0,
kAPID3D9 = 1 << 0,
kAPID3D11 = 1 << 1,
kAPIGLDesktop = 1 << 2,
kAPIGLES = 1 << 3,
kAPIVulkan = 1 << 4,
};
GPUTestConfig();
GPUTestConfig(const GPUTestConfig &other);
virtual ~GPUTestConfig();
void set_os(int32_t os);
void set_gpu_device_id(uint32_t id);
void set_build_type(int32_t build_type);
void set_api(int32_t api);
virtual void AddGPUVendor(uint32_t gpu_vendor);
int32_t os() const { return os_; }
const std::vector<uint32_t> &gpu_vendor() const { return gpu_vendor_; }
uint32_t gpu_device_id() const { return gpu_device_id_; }
int32_t build_type() const { return build_type_; }
int32_t api() const { return api_; }
// Check if the config is valid. For example, if gpu_device_id_ is set, but
// gpu_vendor_ is unknown, then it's invalid.
virtual bool IsValid() const;
// Check if two configs overlap, i.e., if there exists a config that matches
// both configs.
bool OverlapsWith(const GPUTestConfig &config) const;
// Disable validation of GPU vendor and device ids.
void DisableGPUInfoValidation();
protected:
void ClearGPUVendor();
// Indicates that the OS has the notion of a numeric GPU vendor and device id
// and this data should be validated.
bool validate_gpu_info_;
private:
// operating system.
int32_t os_;
// GPU vendor.
std::vector<uint32_t> gpu_vendor_;
// GPU device id (unique to each vendor).
uint32_t gpu_device_id_;
// Release or Debug.
int32_t build_type_;
// Back-end rendering APIs.
int32_t api_;
};
class GPU_EXPORT GPUTestBotConfig : public GPUTestConfig
{
public:
GPUTestBotConfig() = default;
~GPUTestBotConfig() override;
// This should only be called when no gpu_vendor is added.
void AddGPUVendor(uint32_t gpu_vendor) override;
// Return false if gpu_info does not have valid vendor_id and device_id.
bool SetGPUInfo(const GPUInfo &gpu_info);
// Check if the bot config is valid, i.e., if it is one valid test-bot
// environment. For example, if a field is unknown, or if OS is not one
// fully defined OS, then it's valid.
bool IsValid() const override;
// Check if a bot config matches a test config, i.e., the test config is a
// superset of the bot config.
bool Matches(const GPUTestConfig &config) const;
bool Matches(const std::string &config_data) const;
// Setup the config with the current gpu testing environment.
// If gpu_info is nullptr, collect GPUInfo first.
bool LoadCurrentConfig(const GPUInfo *gpu_info);
// Check if this bot's config matches |config_data| or any of the |configs|.
static bool CurrentConfigMatches(const std::string &config_data);
static bool CurrentConfigMatches(const std::vector<std::string> &configs);
// Check if the bot has blacklisted all GPU features.
static bool GpuBlacklistedOnBot();
};
} // namespace gpu
#endif // ANGLE_GPU_CONFIG_GPU_TEST_CONFIG_H_
...@@ -7,36 +7,39 @@ ...@@ -7,36 +7,39 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "angle_config.h"
#include "common/angleutils.h" #include "common/angleutils.h"
namespace base { namespace base
{
namespace { namespace
{
bool StartsWithASCII(const std::string& str, bool StartsWithASCII(const std::string &str, const std::string &search, bool case_sensitive)
const std::string& search, {
bool case_sensitive) {
ASSERT(!case_sensitive); ASSERT(!case_sensitive);
return str.compare(0, search.length(), search) == 0; return str.compare(0, search.length(), search) == 0;
} }
template <class Char> inline Char ToLowerASCII(Char c) { template <class Char>
inline Char ToLowerASCII(Char c)
{
return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c;
} }
template<typename Iter> template <typename Iter>
static inline bool DoLowerCaseEqualsASCII(Iter a_begin, static inline bool DoLowerCaseEqualsASCII(Iter a_begin, Iter a_end, const char *b)
Iter a_end, {
const char* b) { for (Iter it = a_begin; it != a_end; ++it, ++b)
for (Iter it = a_begin; it != a_end; ++it, ++b) { {
if (!*b || base::ToLowerASCII(*it) != *b) if (!*b || base::ToLowerASCII(*it) != *b)
return false; return false;
} }
return *b == 0; return *b == 0;
} }
bool LowerCaseEqualsASCII(const std::string& a, const char* b) { bool LowerCaseEqualsASCII(const std::string &a, const char *b)
{
return DoLowerCaseEqualsASCII(a.begin(), a.end(), b); return DoLowerCaseEqualsASCII(a.begin(), a.end(), b);
} }
...@@ -44,11 +47,14 @@ bool LowerCaseEqualsASCII(const std::string& a, const char* b) { ...@@ -44,11 +47,14 @@ bool LowerCaseEqualsASCII(const std::string& a, const char* b) {
} // namespace base } // namespace base
namespace gpu { namespace gpu
{
namespace { namespace
{
enum LineParserStage { enum LineParserStage
{
kLineParserBegin = 0, kLineParserBegin = 0,
kLineParserBugID, kLineParserBugID,
kLineParserConfigs, kLineParserConfigs,
...@@ -58,7 +64,8 @@ enum LineParserStage { ...@@ -58,7 +64,8 @@ enum LineParserStage {
kLineParserExpectations, kLineParserExpectations,
}; };
enum Token { enum Token
{
// os // os
kConfigWinXP = 0, kConfigWinXP = 0,
kConfigWinVista, kConfigWinVista,
...@@ -112,8 +119,9 @@ enum Token { ...@@ -112,8 +119,9 @@ enum Token {
kTokenWord, kTokenWord,
}; };
struct TokenInfo { struct TokenInfo
const char* name; {
const char *name;
int32_t flag; int32_t flag;
}; };
...@@ -158,7 +166,8 @@ const TokenInfo kTokenData[] = { ...@@ -158,7 +166,8 @@ const TokenInfo kTokenData[] = {
{"=", 0}, {"=", 0},
}; };
enum ErrorType { enum ErrorType
{
kErrorFileIO = 0, kErrorFileIO = 0,
kErrorIllegalEntry, kErrorIllegalEntry,
kErrorInvalidEntry, kErrorInvalidEntry,
...@@ -173,7 +182,7 @@ enum ErrorType { ...@@ -173,7 +182,7 @@ enum ErrorType {
kNumberOfErrors, kNumberOfErrors,
}; };
const char* kErrorMessage[] = { const char *kErrorMessage[] = {
"file IO failed", "file IO failed",
"entry with wrong format", "entry with wrong format",
"entry invalid, likely wrong modifiers combination", "entry invalid, likely wrong modifiers combination",
...@@ -186,13 +195,15 @@ const char* kErrorMessage[] = { ...@@ -186,13 +195,15 @@ const char* kErrorMessage[] = {
"two entries' configs overlap", "two entries' configs overlap",
}; };
Token ParseToken(const std::string& word) { Token ParseToken(const std::string &word)
{
if (base::StartsWithASCII(word, "//", false)) if (base::StartsWithASCII(word, "//", false))
return kTokenComment; return kTokenComment;
if (base::StartsWithASCII(word, "0x", false)) if (base::StartsWithASCII(word, "0x", false))
return kConfigGPUDeviceID; return kConfigGPUDeviceID;
for (int32_t i = 0; i < kNumberOfExactMatchTokens; ++i) { for (int32_t i = 0; i < kNumberOfExactMatchTokens; ++i)
{
if (base::LowerCaseEqualsASCII(word, kTokenData[i].name)) if (base::LowerCaseEqualsASCII(word, kTokenData[i].name))
return static_cast<Token>(i); return static_cast<Token>(i);
} }
...@@ -200,22 +211,24 @@ Token ParseToken(const std::string& word) { ...@@ -200,22 +211,24 @@ Token ParseToken(const std::string& word) {
} }
// reference name can have the last character as *. // reference name can have the last character as *.
bool NamesMatching(const std::string& ref, const std::string& test_name) { bool NamesMatching(const std::string &ref, const std::string &test_name)
{
size_t len = ref.length(); size_t len = ref.length();
if (len == 0) if (len == 0)
return false; return false;
if (ref[len - 1] == '*') { if (ref[len - 1] == '*')
if (test_name.length() > len -1 && {
ref.compare(0, len - 1, test_name, 0, len - 1) == 0) if (test_name.length() > len - 1 && ref.compare(0, len - 1, test_name, 0, len - 1) == 0)
return true; return true;
return false; return false;
} }
return (ref == test_name); return (ref == test_name);
} }
} // namespace anonymous } // namespace
GPUTestExpectationsParser::GPUTestExpectationsParser() { GPUTestExpectationsParser::GPUTestExpectationsParser()
{
// Some sanity check. // Some sanity check.
DCHECK_EQ(static_cast<unsigned int>(kNumberOfExactMatchTokens), DCHECK_EQ(static_cast<unsigned int>(kNumberOfExactMatchTokens),
sizeof(kTokenData) / sizeof(kTokenData[0])); sizeof(kTokenData) / sizeof(kTokenData[0]));
...@@ -225,18 +238,21 @@ GPUTestExpectationsParser::GPUTestExpectationsParser() { ...@@ -225,18 +238,21 @@ GPUTestExpectationsParser::GPUTestExpectationsParser() {
GPUTestExpectationsParser::~GPUTestExpectationsParser() = default; GPUTestExpectationsParser::~GPUTestExpectationsParser() = default;
bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) { bool GPUTestExpectationsParser::LoadTestExpectations(const std::string &data)
{
entries_.clear(); entries_.clear();
error_messages_.clear(); error_messages_.clear();
std::vector<std::string> lines = base::SplitString( std::vector<std::string> lines =
data, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); base::SplitString(data, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
bool rt = true; bool rt = true;
for (size_t i = 0; i < lines.size(); ++i) { for (size_t i = 0; i < lines.size(); ++i)
{
if (!ParseLine(lines[i], i + 1)) if (!ParseLine(lines[i], i + 1))
rt = false; rt = false;
} }
if (DetectConflictsBetweenEntries()) { if (DetectConflictsBetweenEntries())
{
entries_.clear(); entries_.clear();
rt = false; rt = false;
} }
...@@ -244,23 +260,25 @@ bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) { ...@@ -244,23 +260,25 @@ bool GPUTestExpectationsParser::LoadTestExpectations(const std::string& data) {
return rt; return rt;
} }
bool GPUTestExpectationsParser::LoadTestExpectationsFromFile( bool GPUTestExpectationsParser::LoadTestExpectationsFromFile(const std::string &path)
const std::string& path) { {
entries_.clear(); entries_.clear();
error_messages_.clear(); error_messages_.clear();
std::string data; std::string data;
if (!base::ReadFileToString(path, &data)) { if (!base::ReadFileToString(path, &data))
{
error_messages_.push_back(kErrorMessage[kErrorFileIO]); error_messages_.push_back(kErrorMessage[kErrorFileIO]);
return false; return false;
} }
return LoadTestExpectations(data); return LoadTestExpectations(data);
} }
int32_t GPUTestExpectationsParser::GetTestExpectation( int32_t GPUTestExpectationsParser::GetTestExpectation(const std::string &test_name,
const std::string& test_name, const GPUTestBotConfig &bot_config) const
const GPUTestBotConfig& bot_config) const { {
for (size_t i = 0; i < entries_.size(); ++i) { for (size_t i = 0; i < entries_.size(); ++i)
{
if (NamesMatching(entries_[i].test_name, test_name) && if (NamesMatching(entries_[i].test_name, test_name) &&
bot_config.Matches(entries_[i].test_config)) bot_config.Matches(entries_[i].test_config))
return entries_[i].test_expectation; return entries_[i].test_expectation;
...@@ -268,21 +286,22 @@ int32_t GPUTestExpectationsParser::GetTestExpectation( ...@@ -268,21 +286,22 @@ int32_t GPUTestExpectationsParser::GetTestExpectation(
return kGpuTestPass; return kGpuTestPass;
} }
const std::vector<std::string>& const std::vector<std::string> &GPUTestExpectationsParser::GetErrorMessages() const
GPUTestExpectationsParser::GetErrorMessages() const { {
return error_messages_; return error_messages_;
} }
bool GPUTestExpectationsParser::ParseConfig( bool GPUTestExpectationsParser::ParseConfig(const std::string &config_data, GPUTestConfig *config)
const std::string& config_data, GPUTestConfig* config) { {
DCHECK(config); DCHECK(config);
std::vector<std::string> tokens = base::SplitString( std::vector<std::string> tokens = base::SplitString(
config_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, config_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
base::SPLIT_WANT_NONEMPTY);
for (size_t i = 0; i < tokens.size(); ++i) { for (size_t i = 0; i < tokens.size(); ++i)
{
Token token = ParseToken(tokens[i]); Token token = ParseToken(tokens[i]);
switch (token) { switch (token)
{
case kConfigWinXP: case kConfigWinXP:
case kConfigWinVista: case kConfigWinVista:
case kConfigWin7: case kConfigWin7:
...@@ -315,10 +334,13 @@ bool GPUTestExpectationsParser::ParseConfig( ...@@ -315,10 +334,13 @@ bool GPUTestExpectationsParser::ParseConfig(
case kConfigGLES: case kConfigGLES:
case kConfigVulkan: case kConfigVulkan:
case kConfigGPUDeviceID: case kConfigGPUDeviceID:
if (token == kConfigGPUDeviceID) { if (token == kConfigGPUDeviceID)
{
if (!UpdateTestConfig(config, tokens[i], 0)) if (!UpdateTestConfig(config, tokens[i], 0))
return false; return false;
} else { }
else
{
if (!UpdateTestConfig(config, token, 0)) if (!UpdateTestConfig(config, token, 0))
return false; return false;
} }
...@@ -330,19 +352,20 @@ bool GPUTestExpectationsParser::ParseConfig( ...@@ -330,19 +352,20 @@ bool GPUTestExpectationsParser::ParseConfig(
return true; return true;
} }
bool GPUTestExpectationsParser::ParseLine( bool GPUTestExpectationsParser::ParseLine(const std::string &line_data, size_t line_number)
const std::string& line_data, size_t line_number) { {
std::vector<std::string> tokens = base::SplitString( std::vector<std::string> tokens = base::SplitString(
line_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, line_data, base::kWhitespaceASCII, base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
base::SPLIT_WANT_NONEMPTY);
int32_t stage = kLineParserBegin; int32_t stage = kLineParserBegin;
GPUTestExpectationEntry entry; GPUTestExpectationEntry entry;
entry.line_number = line_number; entry.line_number = line_number;
GPUTestConfig& config = entry.test_config; GPUTestConfig &config = entry.test_config;
bool comments_encountered = false; bool comments_encountered = false;
for (size_t i = 0; i < tokens.size() && !comments_encountered; ++i) { for (size_t i = 0; i < tokens.size() && !comments_encountered; ++i)
{
Token token = ParseToken(tokens[i]); Token token = ParseToken(tokens[i]);
switch (token) { switch (token)
{
case kTokenComment: case kTokenComment:
comments_encountered = true; comments_encountered = true;
break; break;
...@@ -379,15 +402,18 @@ bool GPUTestExpectationsParser::ParseLine( ...@@ -379,15 +402,18 @@ bool GPUTestExpectationsParser::ParseLine(
case kConfigVulkan: case kConfigVulkan:
case kConfigGPUDeviceID: case kConfigGPUDeviceID:
// MODIFIERS, could be in any order, need at least one. // MODIFIERS, could be in any order, need at least one.
if (stage != kLineParserConfigs && stage != kLineParserBugID) { if (stage != kLineParserConfigs && stage != kLineParserBugID)
PushErrorMessage(kErrorMessage[kErrorIllegalEntry], {
line_number); PushErrorMessage(kErrorMessage[kErrorIllegalEntry], line_number);
return false; return false;
} }
if (token == kConfigGPUDeviceID) { if (token == kConfigGPUDeviceID)
{
if (!UpdateTestConfig(&config, tokens[i], line_number)) if (!UpdateTestConfig(&config, tokens[i], line_number))
return false; return false;
} else { }
else
{
if (!UpdateTestConfig(&config, token, line_number)) if (!UpdateTestConfig(&config, token, line_number))
return false; return false;
} }
...@@ -396,31 +422,35 @@ bool GPUTestExpectationsParser::ParseLine( ...@@ -396,31 +422,35 @@ bool GPUTestExpectationsParser::ParseLine(
break; break;
case kSeparatorColon: case kSeparatorColon:
// : // :
if (stage != kLineParserConfigs) { if (stage != kLineParserConfigs)
PushErrorMessage(kErrorMessage[kErrorIllegalEntry], {
line_number); PushErrorMessage(kErrorMessage[kErrorIllegalEntry], line_number);
return false; return false;
} }
stage++; stage++;
break; break;
case kSeparatorEqual: case kSeparatorEqual:
// = // =
if (stage != kLineParserTestName) { if (stage != kLineParserTestName)
PushErrorMessage(kErrorMessage[kErrorIllegalEntry], {
line_number); PushErrorMessage(kErrorMessage[kErrorIllegalEntry], line_number);
return false; return false;
} }
stage++; stage++;
break; break;
case kTokenWord: case kTokenWord:
// BUG_ID or TEST_NAME // BUG_ID or TEST_NAME
if (stage == kLineParserBegin) { if (stage == kLineParserBegin)
{
// Bug ID is not used for anything; ignore it. // Bug ID is not used for anything; ignore it.
} else if (stage == kLineParserColon) { }
else if (stage == kLineParserColon)
{
entry.test_name = tokens[i]; entry.test_name = tokens[i];
} else { }
PushErrorMessage(kErrorMessage[kErrorIllegalEntry], else
line_number); {
PushErrorMessage(kErrorMessage[kErrorIllegalEntry], line_number);
return false; return false;
} }
stage++; stage++;
...@@ -431,18 +461,18 @@ bool GPUTestExpectationsParser::ParseLine( ...@@ -431,18 +461,18 @@ bool GPUTestExpectationsParser::ParseLine(
case kExpectationTimeout: case kExpectationTimeout:
case kExpectationSkip: case kExpectationSkip:
// TEST_EXPECTATIONS // TEST_EXPECTATIONS
if (stage != kLineParserEqual && stage != kLineParserExpectations) { if (stage != kLineParserEqual && stage != kLineParserExpectations)
PushErrorMessage(kErrorMessage[kErrorIllegalEntry], {
line_number); PushErrorMessage(kErrorMessage[kErrorIllegalEntry], line_number);
return false; return false;
} }
if ((kTokenData[token].flag & entry.test_expectation) != 0) { if ((kTokenData[token].flag & entry.test_expectation) != 0)
{
PushErrorMessage(kErrorMessage[kErrorEntryWithExpectationConflicts], PushErrorMessage(kErrorMessage[kErrorEntryWithExpectationConflicts],
line_number); line_number);
return false; return false;
} }
entry.test_expectation = entry.test_expectation = (kTokenData[token].flag | entry.test_expectation);
(kTokenData[token].flag | entry.test_expectation);
if (stage == kLineParserEqual) if (stage == kLineParserEqual)
stage++; stage++;
break; break;
...@@ -451,12 +481,15 @@ bool GPUTestExpectationsParser::ParseLine( ...@@ -451,12 +481,15 @@ bool GPUTestExpectationsParser::ParseLine(
break; break;
} }
} }
if (stage == kLineParserBegin) { if (stage == kLineParserBegin)
{
// The whole line is empty or all comments // The whole line is empty or all comments
return true; return true;
} }
if (stage == kLineParserExpectations) { if (stage == kLineParserExpectations)
if (!config.IsValid()) { {
if (!config.IsValid())
{
PushErrorMessage(kErrorMessage[kErrorInvalidEntry], line_number); PushErrorMessage(kErrorMessage[kErrorInvalidEntry], line_number);
return false; return false;
} }
...@@ -467,11 +500,13 @@ bool GPUTestExpectationsParser::ParseLine( ...@@ -467,11 +500,13 @@ bool GPUTestExpectationsParser::ParseLine(
return false; return false;
} }
bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig* config, bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig *config,
int32_t token, int32_t token,
size_t line_number) { size_t line_number)
{
DCHECK(config); DCHECK(config);
switch (token) { switch (token)
{
case kConfigWinXP: case kConfigWinXP:
case kConfigWinVista: case kConfigWinVista:
case kConfigWin7: case kConfigWin7:
...@@ -492,9 +527,9 @@ bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig* config, ...@@ -492,9 +527,9 @@ bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig* config,
case kConfigLinux: case kConfigLinux:
case kConfigChromeOS: case kConfigChromeOS:
case kConfigAndroid: case kConfigAndroid:
if ((config->os() & kTokenData[token].flag) != 0) { if ((config->os() & kTokenData[token].flag) != 0)
PushErrorMessage(kErrorMessage[kErrorEntryWithOsConflicts], {
line_number); PushErrorMessage(kErrorMessage[kErrorEntryWithOsConflicts], line_number);
return false; return false;
} }
config->set_os(config->os() | kTokenData[token].flag); config->set_os(config->os() | kTokenData[token].flag);
...@@ -505,11 +540,11 @@ bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig* config, ...@@ -505,11 +540,11 @@ bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig* config,
case kConfigVMWare: case kConfigVMWare:
{ {
uint32_t gpu_vendor = static_cast<uint32_t>(kTokenData[token].flag); uint32_t gpu_vendor = static_cast<uint32_t>(kTokenData[token].flag);
for (size_t i = 0; i < config->gpu_vendor().size(); ++i) { for (size_t i = 0; i < config->gpu_vendor().size(); ++i)
if (config->gpu_vendor()[i] == gpu_vendor) { {
PushErrorMessage( if (config->gpu_vendor()[i] == gpu_vendor)
kErrorMessage[kErrorEntryWithGpuVendorConflicts], {
line_number); PushErrorMessage(kErrorMessage[kErrorEntryWithGpuVendorConflicts], line_number);
return false; return false;
} }
} }
...@@ -518,23 +553,21 @@ bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig* config, ...@@ -518,23 +553,21 @@ bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig* config,
break; break;
case kConfigRelease: case kConfigRelease:
case kConfigDebug: case kConfigDebug:
if ((config->build_type() & kTokenData[token].flag) != 0) { if ((config->build_type() & kTokenData[token].flag) != 0)
PushErrorMessage( {
kErrorMessage[kErrorEntryWithBuildTypeConflicts], PushErrorMessage(kErrorMessage[kErrorEntryWithBuildTypeConflicts], line_number);
line_number);
return false; return false;
} }
config->set_build_type( config->set_build_type(config->build_type() | kTokenData[token].flag);
config->build_type() | kTokenData[token].flag);
break; break;
case kConfigD3D9: case kConfigD3D9:
case kConfigD3D11: case kConfigD3D11:
case kConfigGLDesktop: case kConfigGLDesktop:
case kConfigGLES: case kConfigGLES:
case kConfigVulkan: case kConfigVulkan:
if ((config->api() & kTokenData[token].flag) != 0) { if ((config->api() & kTokenData[token].flag) != 0)
PushErrorMessage(kErrorMessage[kErrorEntryWithAPIConflicts], {
line_number); PushErrorMessage(kErrorMessage[kErrorEntryWithAPIConflicts], line_number);
return false; return false;
} }
config->set_api(config->api() | kTokenData[token].flag); config->set_api(config->api() | kTokenData[token].flag);
...@@ -546,31 +579,33 @@ bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig* config, ...@@ -546,31 +579,33 @@ bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig* config,
return true; return true;
} }
bool GPUTestExpectationsParser::UpdateTestConfig( bool GPUTestExpectationsParser::UpdateTestConfig(GPUTestConfig *config,
GPUTestConfig* config, const std::string &gpu_device_id,
const std::string& gpu_device_id, size_t line_number)
size_t line_number) { {
DCHECK(config); DCHECK(config);
uint32_t device_id = 0; uint32_t device_id = 0;
if (config->gpu_device_id() != 0 || if (config->gpu_device_id() != 0 || !base::HexStringToUInt(gpu_device_id, &device_id) ||
!base::HexStringToUInt(gpu_device_id, &device_id) || device_id == 0)
device_id == 0) { {
PushErrorMessage(kErrorMessage[kErrorEntryWithGpuDeviceIdConflicts], PushErrorMessage(kErrorMessage[kErrorEntryWithGpuDeviceIdConflicts], line_number);
line_number);
return false; return false;
} }
config->set_gpu_device_id(device_id); config->set_gpu_device_id(device_id);
return true; return true;
} }
bool GPUTestExpectationsParser::DetectConflictsBetweenEntries() { bool GPUTestExpectationsParser::DetectConflictsBetweenEntries()
{
bool rt = false; bool rt = false;
for (size_t i = 0; i < entries_.size(); ++i) { for (size_t i = 0; i < entries_.size(); ++i)
for (size_t j = i + 1; j < entries_.size(); ++j) { {
for (size_t j = i + 1; j < entries_.size(); ++j)
{
if (entries_[i].test_name == entries_[j].test_name && if (entries_[i].test_name == entries_[j].test_name &&
entries_[i].test_config.OverlapsWith(entries_[j].test_config)) { entries_[i].test_config.OverlapsWith(entries_[j].test_config))
PushErrorMessage(kErrorMessage[kErrorEntriesOverlap], {
entries_[i].line_number, PushErrorMessage(kErrorMessage[kErrorEntriesOverlap], entries_[i].line_number,
entries_[j].line_number); entries_[j].line_number);
rt = true; rt = true;
} }
...@@ -579,25 +614,21 @@ bool GPUTestExpectationsParser::DetectConflictsBetweenEntries() { ...@@ -579,25 +614,21 @@ bool GPUTestExpectationsParser::DetectConflictsBetweenEntries() {
return rt; return rt;
} }
void GPUTestExpectationsParser::PushErrorMessage( void GPUTestExpectationsParser::PushErrorMessage(const std::string &message, size_t line_number)
const std::string& message, size_t line_number) { {
error_messages_.push_back("Line " + ToString(line_number) + error_messages_.push_back("Line " + ToString(line_number) + " : " + message.c_str());
" : " + message.c_str());
} }
void GPUTestExpectationsParser::PushErrorMessage( void GPUTestExpectationsParser::PushErrorMessage(const std::string &message,
const std::string& message,
size_t entry1_line_number, size_t entry1_line_number,
size_t entry2_line_number) { size_t entry2_line_number)
error_messages_.push_back("Line " + ToString(entry1_line_number) + {
" and " + ToString(entry2_line_number) + error_messages_.push_back("Line " + ToString(entry1_line_number) + " and " +
" : " + message.c_str()); ToString(entry2_line_number) + " : " + message.c_str());
} }
GPUTestExpectationsParser:: GPUTestExpectationEntry::GPUTestExpectationEntry() GPUTestExpectationsParser::GPUTestExpectationEntry::GPUTestExpectationEntry()
: test_expectation(0), : test_expectation(0), line_number(0)
line_number(0) { {}
}
} // namespace gpu } // namespace gpu
...@@ -11,14 +11,16 @@ ...@@ -11,14 +11,16 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "angle_config.h"
#include "gpu_test_config.h" #include "gpu_test_config.h"
namespace gpu { namespace gpu
{
class GPU_EXPORT GPUTestExpectationsParser { class GPU_EXPORT GPUTestExpectationsParser
{
public: public:
enum GPUTestExpectation { enum GPUTestExpectation
{
kGpuTestPass = 1 << 0, kGpuTestPass = 1 << 0,
kGpuTestFail = 1 << 1, kGpuTestFail = 1 << 1,
kGpuTestFlaky = 1 << 2, kGpuTestFlaky = 1 << 2,
...@@ -32,22 +34,23 @@ class GPU_EXPORT GPUTestExpectationsParser { ...@@ -32,22 +34,23 @@ class GPU_EXPORT GPUTestExpectationsParser {
// Parse the text expectations, and if no error is encountered, // Parse the text expectations, and if no error is encountered,
// save all the entries. Otherwise, generate error messages. // save all the entries. Otherwise, generate error messages.
// Return true if parsing succeeds. // Return true if parsing succeeds.
bool LoadTestExpectations(const std::string& data); bool LoadTestExpectations(const std::string &data);
bool LoadTestExpectationsFromFile(const std::string& path); bool LoadTestExpectationsFromFile(const std::string &path);
// Query error messages from the last LoadTestExpectations() call. // Query error messages from the last LoadTestExpectations() call.
const std::vector<std::string>& GetErrorMessages() const; const std::vector<std::string> &GetErrorMessages() const;
// Get the test expectation of a given test on a given bot. // Get the test expectation of a given test on a given bot.
int32_t GetTestExpectation(const std::string& test_name, int32_t GetTestExpectation(const std::string &test_name,
const GPUTestBotConfig& bot_config) const; const GPUTestBotConfig &bot_config) const;
// Parse a list of config modifiers. If we have a valid entry with no // Parse a list of config modifiers. If we have a valid entry with no
// conflicts, | config | stores it, and the function returns true. // conflicts, | config | stores it, and the function returns true.
bool ParseConfig(const std::string& config_data, GPUTestConfig* config); bool ParseConfig(const std::string &config_data, GPUTestConfig *config);
private: private:
struct GPUTestExpectationEntry { struct GPUTestExpectationEntry
{
GPUTestExpectationEntry(); GPUTestExpectationEntry();
std::string test_name; std::string test_name;
...@@ -58,16 +61,14 @@ class GPU_EXPORT GPUTestExpectationsParser { ...@@ -58,16 +61,14 @@ class GPU_EXPORT GPUTestExpectationsParser {
// Parse a line of text. If we have a valid entry, save it; otherwise, // Parse a line of text. If we have a valid entry, save it; otherwise,
// generate error messages. // generate error messages.
bool ParseLine(const std::string& line_data, size_t line_number); bool ParseLine(const std::string &line_data, size_t line_number);
// Update OS/GPUVendor/BuildType modifiers. May generate an error message. // Update OS/GPUVendor/BuildType modifiers. May generate an error message.
bool UpdateTestConfig(GPUTestConfig* config, bool UpdateTestConfig(GPUTestConfig *config, int32_t token, size_t line_number);
int32_t token,
size_t line_number);
// Update GPUDeviceID modifier. May generate an error message. // Update GPUDeviceID modifier. May generate an error message.
bool UpdateTestConfig(GPUTestConfig* config, bool UpdateTestConfig(GPUTestConfig *config,
const std::string & gpu_device_id, const std::string &gpu_device_id,
size_t line_number); size_t line_number);
// Check if two entries' config overlap with each other. May generate an // Check if two entries' config overlap with each other. May generate an
...@@ -75,8 +76,8 @@ class GPU_EXPORT GPUTestExpectationsParser { ...@@ -75,8 +76,8 @@ class GPU_EXPORT GPUTestExpectationsParser {
bool DetectConflictsBetweenEntries(); bool DetectConflictsBetweenEntries();
// Save an error message, which can be queried later. // Save an error message, which can be queried later.
void PushErrorMessage(const std::string& message, size_t line_number); void PushErrorMessage(const std::string &message, size_t line_number);
void PushErrorMessage(const std::string& message, void PushErrorMessage(const std::string &message,
size_t entry1_line_number, size_t entry1_line_number,
size_t entry2_line_number); size_t entry2_line_number);
...@@ -87,4 +88,3 @@ class GPU_EXPORT GPUTestExpectationsParser { ...@@ -87,4 +88,3 @@ class GPU_EXPORT GPUTestExpectationsParser {
} // namespace gpu } // namespace gpu
#endif // ANGLE_GPU_CONFIG_GPU_TEST_EXPECTATIONS_PARSER_H_ #endif // ANGLE_GPU_CONFIG_GPU_TEST_EXPECTATIONS_PARSER_H_
// Copyright (c) 2012 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.
#ifndef ANGLE_GPU_CONFIG_GPU_TEST_CONFIG_H_
#define ANGLE_GPU_CONFIG_GPU_TEST_CONFIG_H_
#include <stdint.h>
#include <string>
#include <vector>
#include "angle_config.h"
namespace gpu {
struct GPUInfo;
class GPU_EXPORT GPUTestConfig {
public:
enum OS {
kOsUnknown = 0,
kOsWinXP = 1 << 0,
kOsWinVista = 1 << 1,
kOsWin7 = 1 << 2,
kOsWin8 = 1 << 3,
kOsMacLeopard = 1 << 4,
kOsMacSnowLeopard = 1 << 5,
kOsMacLion = 1 << 6,
kOsMacMountainLion = 1 << 7,
kOsMacMavericks = 1 << 8,
kOsMacYosemite = 1 << 9,
kOsMacElCapitan = 1 << 10,
kOsMacSierra = 1 << 11,
kOsMacHighSierra = 1 << 12,
kOsMacMojave = 1 << 13,
kOsMac = kOsMacLeopard | kOsMacSnowLeopard | kOsMacLion |
kOsMacMountainLion | kOsMacMavericks | kOsMacYosemite |
kOsMacElCapitan | kOsMacSierra | kOsMacHighSierra | kOsMacMojave,
kOsLinux = 1 << 14,
kOsChromeOS = 1 << 15,
kOsAndroid = 1 << 16,
kOsWin10 = 1 << 17,
kOsWin = kOsWinXP | kOsWinVista | kOsWin7 | kOsWin8 | kOsWin10,
kOsFuchsia = 1 << 18,
};
enum BuildType {
kBuildTypeUnknown = 0,
kBuildTypeRelease = 1 << 0,
kBuildTypeDebug = 1 << 1,
};
enum API {
kAPIUnknown = 0,
kAPID3D9 = 1 << 0,
kAPID3D11 = 1 << 1,
kAPIGLDesktop = 1 << 2,
kAPIGLES = 1 << 3,
kAPIVulkan = 1 << 4,
};
GPUTestConfig();
GPUTestConfig(const GPUTestConfig& other);
virtual ~GPUTestConfig();
void set_os(int32_t os);
void set_gpu_device_id(uint32_t id);
void set_build_type(int32_t build_type);
void set_api(int32_t api);
virtual void AddGPUVendor(uint32_t gpu_vendor);
int32_t os() const { return os_; }
const std::vector<uint32_t>& gpu_vendor() const { return gpu_vendor_; }
uint32_t gpu_device_id() const { return gpu_device_id_; }
int32_t build_type() const { return build_type_; }
int32_t api() const { return api_; }
// Check if the config is valid. For example, if gpu_device_id_ is set, but
// gpu_vendor_ is unknown, then it's invalid.
virtual bool IsValid() const;
// Check if two configs overlap, i.e., if there exists a config that matches
// both configs.
bool OverlapsWith(const GPUTestConfig& config) const;
// Disable validation of GPU vendor and device ids.
void DisableGPUInfoValidation();
protected:
void ClearGPUVendor();
// Indicates that the OS has the notion of a numeric GPU vendor and device id
// and this data should be validated.
bool validate_gpu_info_;
private:
// operating system.
int32_t os_;
// GPU vendor.
std::vector<uint32_t> gpu_vendor_;
// GPU device id (unique to each vendor).
uint32_t gpu_device_id_;
// Release or Debug.
int32_t build_type_;
// Back-end rendering APIs.
int32_t api_;
};
class GPU_EXPORT GPUTestBotConfig : public GPUTestConfig {
public:
GPUTestBotConfig() = default;
~GPUTestBotConfig() override;
// This should only be called when no gpu_vendor is added.
void AddGPUVendor(uint32_t gpu_vendor) override;
// Return false if gpu_info does not have valid vendor_id and device_id.
bool SetGPUInfo(const GPUInfo& gpu_info);
// Check if the bot config is valid, i.e., if it is one valid test-bot
// environment. For example, if a field is unknown, or if OS is not one
// fully defined OS, then it's valid.
bool IsValid() const override;
// Check if a bot config matches a test config, i.e., the test config is a
// superset of the bot config.
bool Matches(const GPUTestConfig& config) const;
bool Matches(const std::string& config_data) const;
// Setup the config with the current gpu testing environment.
// If gpu_info is nullptr, collect GPUInfo first.
bool LoadCurrentConfig(const GPUInfo* gpu_info);
// Check if this bot's config matches |config_data| or any of the |configs|.
static bool CurrentConfigMatches(const std::string& config_data);
static bool CurrentConfigMatches(const std::vector<std::string>& configs);
// Check if the bot has blacklisted all GPU features.
static bool GpuBlacklistedOnBot();
};
} // namespace gpu
#endif // ANGLE_GPU_CONFIG_GPU_TEST_CONFIG_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment