mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-17 09:21:45 +00:00
This allows them to be fully defined before being referenced, which fixes compile errors in C++20. Bug: chromium:1284275 Change-Id: I3c0f874406247c04d53710431931f82c3deaff3c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99080 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Peter Kasting <pkasting@google.com> Auto-Submit: Peter Kasting <pkasting@google.com>
131 lines
5.4 KiB
C++
131 lines
5.4 KiB
C++
// Copyright 2022 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "dawn/tests/AdapterTestConfig.h"
|
|
|
|
#include <initializer_list>
|
|
#include <ostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "dawn/common/Assert.h"
|
|
#include "dawn/webgpu_cpp.h"
|
|
|
|
BackendTestConfig::BackendTestConfig(wgpu::BackendType backendType,
|
|
std::initializer_list<const char*> forceEnabledWorkarounds,
|
|
std::initializer_list<const char*> forceDisabledWorkarounds)
|
|
: backendType(backendType),
|
|
forceEnabledWorkarounds(forceEnabledWorkarounds),
|
|
forceDisabledWorkarounds(forceDisabledWorkarounds) {}
|
|
|
|
BackendTestConfig D3D12Backend(std::initializer_list<const char*> forceEnabledWorkarounds,
|
|
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
|
return BackendTestConfig(wgpu::BackendType::D3D12, forceEnabledWorkarounds,
|
|
forceDisabledWorkarounds);
|
|
}
|
|
|
|
BackendTestConfig MetalBackend(std::initializer_list<const char*> forceEnabledWorkarounds,
|
|
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
|
return BackendTestConfig(wgpu::BackendType::Metal, forceEnabledWorkarounds,
|
|
forceDisabledWorkarounds);
|
|
}
|
|
|
|
BackendTestConfig NullBackend(std::initializer_list<const char*> forceEnabledWorkarounds,
|
|
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
|
return BackendTestConfig(wgpu::BackendType::Null, forceEnabledWorkarounds,
|
|
forceDisabledWorkarounds);
|
|
}
|
|
|
|
BackendTestConfig OpenGLBackend(std::initializer_list<const char*> forceEnabledWorkarounds,
|
|
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
|
return BackendTestConfig(wgpu::BackendType::OpenGL, forceEnabledWorkarounds,
|
|
forceDisabledWorkarounds);
|
|
}
|
|
|
|
BackendTestConfig OpenGLESBackend(std::initializer_list<const char*> forceEnabledWorkarounds,
|
|
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
|
return BackendTestConfig(wgpu::BackendType::OpenGLES, forceEnabledWorkarounds,
|
|
forceDisabledWorkarounds);
|
|
}
|
|
|
|
BackendTestConfig VulkanBackend(std::initializer_list<const char*> forceEnabledWorkarounds,
|
|
std::initializer_list<const char*> forceDisabledWorkarounds) {
|
|
return BackendTestConfig(wgpu::BackendType::Vulkan, forceEnabledWorkarounds,
|
|
forceDisabledWorkarounds);
|
|
}
|
|
|
|
TestAdapterProperties::TestAdapterProperties(const wgpu::AdapterProperties& properties,
|
|
bool selected)
|
|
: wgpu::AdapterProperties(properties), adapterName(properties.name), selected(selected) {}
|
|
|
|
std::string TestAdapterProperties::ParamName() const {
|
|
switch (backendType) {
|
|
case wgpu::BackendType::D3D12:
|
|
return "D3D12";
|
|
case wgpu::BackendType::Metal:
|
|
return "Metal";
|
|
case wgpu::BackendType::Null:
|
|
return "Null";
|
|
case wgpu::BackendType::OpenGL:
|
|
return "OpenGL";
|
|
case wgpu::BackendType::OpenGLES:
|
|
return "OpenGLES";
|
|
case wgpu::BackendType::Vulkan:
|
|
return "Vulkan";
|
|
default:
|
|
UNREACHABLE();
|
|
}
|
|
}
|
|
|
|
std::string TestAdapterProperties::AdapterTypeName() const {
|
|
switch (adapterType) {
|
|
case wgpu::AdapterType::DiscreteGPU:
|
|
return "Discrete GPU";
|
|
case wgpu::AdapterType::IntegratedGPU:
|
|
return "Integrated GPU";
|
|
case wgpu::AdapterType::CPU:
|
|
return "CPU";
|
|
case wgpu::AdapterType::Unknown:
|
|
return "Unknown";
|
|
default:
|
|
UNREACHABLE();
|
|
}
|
|
}
|
|
|
|
AdapterTestParam::AdapterTestParam(const BackendTestConfig& config,
|
|
const TestAdapterProperties& adapterProperties)
|
|
: adapterProperties(adapterProperties),
|
|
forceEnabledWorkarounds(config.forceEnabledWorkarounds),
|
|
forceDisabledWorkarounds(config.forceDisabledWorkarounds) {}
|
|
|
|
std::ostream& operator<<(std::ostream& os, const AdapterTestParam& param) {
|
|
os << param.adapterProperties.ParamName() << " " << param.adapterProperties.adapterName;
|
|
|
|
// In a Windows Remote Desktop session there are two adapters named "Microsoft Basic Render
|
|
// Driver" with different adapter types. We must differentiate them to avoid any tests using the
|
|
// same name.
|
|
if (param.adapterProperties.deviceID == 0x008C) {
|
|
std::string adapterType = param.adapterProperties.AdapterTypeName();
|
|
os << " " << adapterType;
|
|
}
|
|
|
|
for (const char* forceEnabledWorkaround : param.forceEnabledWorkarounds) {
|
|
os << "; e:" << forceEnabledWorkaround;
|
|
}
|
|
for (const char* forceDisabledWorkaround : param.forceDisabledWorkarounds) {
|
|
os << "; d:" << forceDisabledWorkaround;
|
|
}
|
|
return os;
|
|
}
|