#include "dawn/tests/DawnTest.h"
#include <algorithm>
#include <atomic>
#include <fstream>
#include <iomanip>
#include <regex>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include "dawn/common/Assert.h"
#include "dawn/common/GPUInfo.h"
#include "dawn/common/Log.h"
#include "dawn/common/Math.h"
#include "dawn/common/Platform.h"
#include "dawn/common/SystemUtils.h"
#include "dawn/dawn_proc.h"
#include "dawn/native/Device.h"
#include "dawn/native/Instance.h"
#include "dawn/native/dawn_platform.h"
#include "dawn/tests/MockCallback.h"
#include "dawn/tests/PartitionAllocSupport.h"
#include "dawn/utils/ComboRenderPipelineDescriptor.h"
#include "dawn/utils/PlatformDebugLogger.h"
#include "dawn/utils/SystemUtils.h"
#include "dawn/utils/TerribleCommandBuffer.h"
#include "dawn/utils/TestUtils.h"
#include "dawn/utils/WGPUHelpers.h"
#include "dawn/utils/WireHelper.h"
#include "dawn/wire/WireClient.h"
#include "dawn/wire/WireServer.h"
#include "partition_alloc/pointers/raw_ptr.h"
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
#include "dawn/native/OpenGLBackend.h"
#endif
namespace dawn {
namespace {
_;
AtMost;
MockCppCallback;
DawnTestEnvironment* gTestEnv = …;
DawnTestBase* gCurrentTest = …;
template <typename T>
void printBuffer(testing::AssertionResult& result, const T* buffer, const size_t count) { … }
struct ParamTogglesHelper { … };
}
DawnTestBase::PrintToStringParamName::PrintToStringParamName(const char* test) : … { … }
std::string DawnTestBase::PrintToStringParamName::SanitizeParamName(
std::string paramName,
const TestAdapterProperties& properties,
size_t index) const { … }
}
void InitDawnEnd2EndTestEnvironment(int argc, char** argv) { … }
namespace dawn {
void DawnTestEnvironment::SetEnvironment(DawnTestEnvironment* env) { … }
DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) { … }
DawnTestEnvironment::~DawnTestEnvironment() = default;
void DawnTestEnvironment::ParseArgs(int argc, char** argv) { … }
std::unique_ptr<native::Instance> DawnTestEnvironment::CreateInstance(
platform::Platform* platform) { … }
void DawnTestEnvironment::SelectPreferredAdapterProperties(const native::Instance* instance) { … }
std::vector<AdapterTestParam> DawnTestEnvironment::GetAvailableAdapterTestParamsForBackends(
const BackendTestConfig* params,
size_t numParams) { … }
bool DawnTestEnvironment::ValidateToggles(native::Instance* instance) const { … }
void DawnTestEnvironment::PrintTestConfigurationAndAdapterInfo(native::Instance* instance) const { … }
void DawnTestEnvironment::SetUp() { … }
void DawnTestEnvironment::TearDown() { … }
bool DawnTestEnvironment::UsesWire() const { … }
bool DawnTestEnvironment::IsImplicitDeviceSyncEnabled() const { … }
bool DawnTestEnvironment::RunSuppressedTests() const { … }
native::BackendValidationLevel DawnTestEnvironment::GetBackendValidationLevel() const { … }
native::Instance* DawnTestEnvironment::GetInstance() const { … }
bool DawnTestEnvironment::HasVendorIdFilter() const { … }
uint32_t DawnTestEnvironment::GetVendorIdFilter() const { … }
bool DawnTestEnvironment::HasBackendTypeFilter() const { … }
wgpu::BackendType DawnTestEnvironment::GetBackendTypeFilter() const { … }
const char* DawnTestEnvironment::GetWireTraceDir() const { … }
const std::vector<std::string>& DawnTestEnvironment::GetEnabledToggles() const { … }
const std::vector<std::string>& DawnTestEnvironment::GetDisabledToggles() const { … }
DawnTestBase::DawnTestBase(const AdapterTestParam& param) : … { … }
DawnTestBase::~DawnTestBase() { … }
bool DawnTestBase::IsD3D11() const { … }
bool DawnTestBase::IsD3D12() const { … }
bool DawnTestBase::IsMetal() const { … }
bool DawnTestBase::IsNull() const { … }
bool DawnTestBase::IsOpenGL() const { … }
bool DawnTestBase::IsOpenGLES() const { … }
bool DawnTestBase::IsVulkan() const { … }
bool DawnTestBase::IsAMD() const { … }
bool DawnTestBase::IsApple() const { … }
bool DawnTestBase::IsARM() const { … }
bool DawnTestBase::IsImgTec() const { … }
bool DawnTestBase::IsIntel() const { … }
bool DawnTestBase::IsNvidia() const { … }
bool DawnTestBase::IsQualcomm() const { … }
bool DawnTestBase::IsSwiftshader() const { … }
bool DawnTestBase::IsANGLE() const { … }
bool DawnTestBase::IsANGLESwiftShader() const { … }
bool DawnTestBase::IsANGLED3D11() const { … }
bool DawnTestBase::IsWARP() const { … }
bool DawnTestBase::IsMesaSoftware() const { … }
bool DawnTestBase::IsIntelGen9() const { … }
bool DawnTestBase::IsIntelGen12() const { … }
bool DawnTestBase::IsWindows() const { … }
bool DawnTestBase::IsLinux() const { … }
bool DawnTestBase::IsMacOS(int32_t majorVersion, int32_t minorVersion) const { … }
bool DawnTestBase::IsAndroid() const { … }
bool DawnTestBase::IsChromeOS() const { … }
bool DawnTestBase::IsMesa(const std::string& mesaVersion) const { … }
bool DawnTestBase::UsesWire() const { … }
bool DawnTestBase::IsImplicitDeviceSyncEnabled() const { … }
bool DawnTestBase::IsBackendValidationEnabled() const { … }
bool DawnTestBase::IsFullBackendValidationEnabled() const { … }
bool DawnTestBase::IsCompatibilityMode() const { … }
bool DawnTestBase::RunSuppressedTests() const { … }
bool DawnTestBase::IsDXC() const { … }
bool DawnTestBase::IsAsan() { … }
bool DawnTestBase::IsTsan() { … }
bool DawnTestBase::HasToggleEnabled(const char* toggle) const { … }
bool DawnTestBase::HasVendorIdFilter() const { … }
uint32_t DawnTestBase::GetVendorIdFilter() const { … }
bool DawnTestBase::HasBackendTypeFilter() const { … }
wgpu::BackendType DawnTestBase::GetBackendTypeFilter() const { … }
const wgpu::Instance& DawnTestBase::GetInstance() const { … }
native::Adapter DawnTestBase::GetAdapter() const { … }
std::vector<wgpu::FeatureName> DawnTestBase::GetRequiredFeatures() { … }
wgpu::RequiredLimits DawnTestBase::GetRequiredLimits(const wgpu::SupportedLimits&) { … }
const TestAdapterProperties& DawnTestBase::GetAdapterProperties() const { … }
wgpu::SupportedLimits DawnTestBase::GetAdapterLimits() { … }
wgpu::SupportedLimits DawnTestBase::GetSupportedLimits() { … }
bool DawnTestBase::SupportsFeatures(const std::vector<wgpu::FeatureName>& features) { … }
uint64_t DawnTestBase::GetDeprecationWarningCountForTesting() const { … }
void* DawnTestBase::GetUniqueUserdata() { … }
uint32_t DawnTestBase::GetDeviceCreationDeprecationWarningExpectation(
const wgpu::DeviceDescriptor& descriptor) { … }
WGPUDevice DawnTestBase::CreateDeviceImpl(std::string isolationKey,
const WGPUDeviceDescriptor* descriptor) { … }
wgpu::Device DawnTestBase::CreateDevice(std::string isolationKey) { … }
void DawnTestBase::SetUp() { … }
void DawnTestBase::TearDown() { … }
void DawnTestBase::DestroyDevice(wgpu::Device deviceToDestroy) { … }
void DawnTestBase::LoseDeviceForTesting(wgpu::Device deviceToLose) { … }
std::ostringstream& DawnTestBase::AddBufferExpectation(const char* file,
int line,
const wgpu::Buffer& buffer,
uint64_t offset,
uint64_t size,
detail::Expectation* expectation) { … }
std::ostringstream& DawnTestBase::AddTextureExpectationImpl(const char* file,
int line,
wgpu::Device targetDevice,
detail::Expectation* expectation,
const wgpu::Texture& texture,
wgpu::Origin3D origin,
wgpu::Extent3D extent,
uint32_t level,
wgpu::TextureAspect aspect,
uint32_t dataSize,
uint32_t bytesPerRow) { … }
std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::Texture texture,
uint32_t width,
uint32_t height,
uint32_t componentCount,
uint32_t sampleCount,
uint32_t arrayLayer,
uint32_t mipLevel,
wgpu::TextureAspect aspect,
detail::Expectation* expectation) { … }
std::ostringstream& DawnTestBase::ExpectSampledFloatData(wgpu::Texture texture,
uint32_t width,
uint32_t height,
uint32_t componentCount,
uint32_t arrayLayer,
uint32_t mipLevel,
detail::Expectation* expectation) { … }
std::ostringstream& DawnTestBase::ExpectMultisampledFloatData(wgpu::Texture texture,
uint32_t width,
uint32_t height,
uint32_t componentCount,
uint32_t sampleCount,
uint32_t arrayLayer,
uint32_t mipLevel,
detail::Expectation* expectation) { … }
std::ostringstream& DawnTestBase::ExpectSampledDepthData(wgpu::Texture texture,
uint32_t width,
uint32_t height,
uint32_t arrayLayer,
uint32_t mipLevel,
detail::Expectation* expectation) { … }
std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
wgpu::Texture texture,
wgpu::TextureFormat format,
uint32_t width,
uint32_t height,
uint32_t arrayLayer,
uint32_t mipLevel,
std::vector<float> expectedDepth,
uint8_t* expectedStencil) { … }
void DawnTestBase::MapAsyncAndWait(const wgpu::Buffer& buffer,
wgpu::MapMode mapMode,
uint64_t offset,
uint64_t size) { … }
void DawnTestBase::WaitABit(wgpu::Instance targetInstance) { … }
void DawnTestBase::FlushWire() { … }
void DawnTestBase::WaitForAllOperations() { … }
DawnTestBase::ReadbackReservation DawnTestBase::ReserveReadback(wgpu::Device targetDevice,
uint64_t readbackSize) { … }
void DawnTestBase::MapSlotsSynchronously() { … }
void DawnTestBase::ResolveExpectations() { … }
std::unique_ptr<platform::Platform> DawnTestBase::CreateTestPlatform() { … }
void DawnTestBase::ResolveDeferredExpectationsNow() { … }
bool utils::RGBA8::operator==(const utils::RGBA8& other) const { … }
bool utils::RGBA8::operator!=(const utils::RGBA8& other) const { … }
bool utils::RGBA8::operator<=(const utils::RGBA8& other) const { … }
bool utils::RGBA8::operator>=(const utils::RGBA8& other) const { … }
namespace detail {
std::vector<AdapterTestParam> GetAvailableAdapterTestParamsForBackends(
const BackendTestConfig* params,
size_t numParams) { … }
template <typename T, typename U>
ExpectEq<T, U>::ExpectEq(T singleValue, T tolerance) : … { … }
template <typename T, typename U>
ExpectEq<T, U>::ExpectEq(const T* values, const unsigned int count, T tolerance)
: … { … }
namespace {
template <typename T, typename U = T>
testing::AssertionResult CheckImpl(const T& expected, const U& actual, const T& tolerance) { … }
template <>
testing::AssertionResult CheckImpl<utils::RGBA8>(const utils::RGBA8& expected,
const utils::RGBA8& actual,
const utils::RGBA8& tolerance) { … }
template <>
testing::AssertionResult CheckImpl<float>(const float& expected,
const float& actual,
const float& tolerance) { … }
template <>
testing::AssertionResult CheckImpl<uint16_t>(const uint16_t& expected,
const uint16_t& actual,
const uint16_t& tolerance) { … }
template <>
testing::AssertionResult CheckImpl<float, uint16_t>(const float& expected,
const uint16_t& actual,
const float& tolerance) { … }
}
template <typename T>
ExpectConstant<T>::ExpectConstant(T constant) : … { … }
template <typename T>
uint32_t ExpectConstant<T>::DataSize() { … }
template <typename T>
testing::AssertionResult ExpectConstant<T>::Check(const void* data, size_t size) { … }
template class ExpectConstant<float>;
template <typename T, typename U>
testing::AssertionResult ExpectEq<T, U>::Check(const void* data, size_t size) { … }
template class ExpectEq<uint8_t>;
template class ExpectEq<uint16_t>;
template class ExpectEq<uint32_t>;
template class ExpectEq<uint64_t>;
template class ExpectEq<int32_t>;
template class ExpectEq<utils::RGBA8>;
template class ExpectEq<float>;
template class ExpectEq<float, uint16_t>;
template <typename T>
ExpectBetweenColors<T>::ExpectBetweenColors(T value0, T value1) { … }
template <typename T>
testing::AssertionResult ExpectBetweenColors<T>::Check(const void* data, size_t size) { … }
template class ExpectBetweenColors<utils::RGBA8>;
}
}