Update Dawn tests and fuzzers to create adapters/devices on the wire
Previously, the device/adapter were all created on the service-side of a test, and then injected into the client side. Injected devices and adapters do not support querying limits and features. This CL changes setup so that adapter and device creation is always initiated by the client - and the implementation on the service side may be overridden for test fixture-specific behavior. It also adds more fuzzing coverage since the fuzzers can now also create adapters and devices. Bug: dawn:689 Change-Id: Ief7faa1908ceae973dcb2f600bf4dd1cf5417704 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91680 Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
8fa07c6470
commit
81b97656bc
|
@ -25,21 +25,11 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
return DawnWireServerFuzzer::Run(
|
return DawnWireServerFuzzer::Run(
|
||||||
data, size,
|
data, size,
|
||||||
[](dawn::native::Instance* instance) {
|
[](const dawn::native::Adapter& adapter) {
|
||||||
std::vector<dawn::native::Adapter> adapters = instance->GetAdapters();
|
wgpu::AdapterProperties properties;
|
||||||
|
adapter.GetProperties(&properties);
|
||||||
wgpu::Device device;
|
return properties.backendType == wgpu::BackendType::D3D12 &&
|
||||||
for (dawn::native::Adapter adapter : adapters) {
|
properties.adapterType == wgpu::AdapterType::CPU;
|
||||||
wgpu::AdapterProperties properties;
|
|
||||||
adapter.GetProperties(&properties);
|
|
||||||
|
|
||||||
if (properties.backendType == wgpu::BackendType::D3D12 &&
|
|
||||||
properties.adapterType == wgpu::AdapterType::CPU) {
|
|
||||||
device = wgpu::Device::Acquire(adapter.CreateDevice());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return device;
|
|
||||||
},
|
},
|
||||||
true /* supportsErrorInjection */);
|
true /* supportsErrorInjection */);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,22 +26,10 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
return DawnWireServerFuzzer::Run(
|
return DawnWireServerFuzzer::Run(
|
||||||
data, size,
|
data, size,
|
||||||
[](dawn::native::Instance* instance) {
|
[](const dawn::native::Adapter& adapter) {
|
||||||
std::vector<dawn::native::Adapter> adapters = instance->GetAdapters();
|
wgpu::AdapterProperties properties;
|
||||||
|
adapter.GetProperties(&properties);
|
||||||
wgpu::Device nullDevice;
|
return properties.backendType == wgpu::BackendType::Null;
|
||||||
for (dawn::native::Adapter adapter : adapters) {
|
|
||||||
wgpu::AdapterProperties properties;
|
|
||||||
adapter.GetProperties(&properties);
|
|
||||||
|
|
||||||
if (properties.backendType == wgpu::BackendType::Null) {
|
|
||||||
nullDevice = wgpu::Device::Acquire(adapter.CreateDevice());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(nullDevice.Get() != nullptr);
|
|
||||||
return nullDevice;
|
|
||||||
},
|
},
|
||||||
false /* supportsErrorInjection */);
|
false /* supportsErrorInjection */);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,21 +25,12 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
return DawnWireServerFuzzer::Run(
|
return DawnWireServerFuzzer::Run(
|
||||||
data, size,
|
data, size,
|
||||||
[](dawn::native::Instance* instance) {
|
[](const dawn::native::Adapter& adapter) {
|
||||||
std::vector<dawn::native::Adapter> adapters = instance->GetAdapters();
|
wgpu::AdapterProperties properties;
|
||||||
|
adapter.GetProperties(&properties);
|
||||||
|
|
||||||
wgpu::Device device;
|
return properties.backendType == wgpu::BackendType::Vulkan &&
|
||||||
for (dawn::native::Adapter adapter : adapters) {
|
properties.adapterType == wgpu::AdapterType::CPU;
|
||||||
wgpu::AdapterProperties properties;
|
|
||||||
adapter.GetProperties(&properties);
|
|
||||||
|
|
||||||
if (properties.backendType == wgpu::BackendType::Vulkan &&
|
|
||||||
properties.adapterType == wgpu::AdapterType::CPU) {
|
|
||||||
device = wgpu::Device::Acquire(adapter.CreateDevice());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return device;
|
|
||||||
},
|
},
|
||||||
true /* supportsErrorInjection */);
|
true /* supportsErrorInjection */);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,7 @@ class DevNull : public dawn::wire::CommandSerializer {
|
||||||
|
|
||||||
std::unique_ptr<dawn::native::Instance> sInstance;
|
std::unique_ptr<dawn::native::Instance> sInstance;
|
||||||
WGPUProcDeviceCreateSwapChain sOriginalDeviceCreateSwapChain = nullptr;
|
WGPUProcDeviceCreateSwapChain sOriginalDeviceCreateSwapChain = nullptr;
|
||||||
|
static bool (*sAdapterSupported)(const dawn::native::Adapter&) = nullptr;
|
||||||
bool sCommandsComplete = false;
|
|
||||||
|
|
||||||
WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device,
|
WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device,
|
||||||
WGPUSurface surface,
|
WGPUSurface surface,
|
||||||
|
@ -75,7 +74,7 @@ int DawnWireServerFuzzer::Initialize(int* argc, char*** argv) {
|
||||||
|
|
||||||
int DawnWireServerFuzzer::Run(const uint8_t* data,
|
int DawnWireServerFuzzer::Run(const uint8_t* data,
|
||||||
size_t size,
|
size_t size,
|
||||||
MakeDeviceFn MakeDevice,
|
bool (*AdapterSupported)(const dawn::native::Adapter&),
|
||||||
bool supportsErrorInjection) {
|
bool supportsErrorInjection) {
|
||||||
// We require at least the injected error index.
|
// We require at least the injected error index.
|
||||||
if (size < sizeof(uint64_t)) {
|
if (size < sizeof(uint64_t)) {
|
||||||
|
@ -96,6 +95,8 @@ int DawnWireServerFuzzer::Run(const uint8_t* data,
|
||||||
dawn::native::InjectErrorAt(injectedErrorIndex);
|
dawn::native::InjectErrorAt(injectedErrorIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sAdapterSupported = AdapterSupported;
|
||||||
|
|
||||||
DawnProcTable procs = dawn::native::GetProcs();
|
DawnProcTable procs = dawn::native::GetProcs();
|
||||||
|
|
||||||
// Swapchains receive a pointer to an implementation. The fuzzer will pass garbage in so we
|
// Swapchains receive a pointer to an implementation. The fuzzer will pass garbage in so we
|
||||||
|
@ -105,14 +106,23 @@ int DawnWireServerFuzzer::Run(const uint8_t* data,
|
||||||
sOriginalDeviceCreateSwapChain = procs.deviceCreateSwapChain;
|
sOriginalDeviceCreateSwapChain = procs.deviceCreateSwapChain;
|
||||||
procs.deviceCreateSwapChain = ErrorDeviceCreateSwapChain;
|
procs.deviceCreateSwapChain = ErrorDeviceCreateSwapChain;
|
||||||
|
|
||||||
dawnProcSetProcs(&procs);
|
// Override requestAdapter to find an adapter that the fuzzer supports.
|
||||||
|
procs.instanceRequestAdapter = [](WGPUInstance cInstance,
|
||||||
|
const WGPURequestAdapterOptions* options,
|
||||||
|
WGPURequestAdapterCallback callback, void* userdata) {
|
||||||
|
std::vector<dawn::native::Adapter> adapters = sInstance->GetAdapters();
|
||||||
|
for (dawn::native::Adapter adapter : adapters) {
|
||||||
|
if (sAdapterSupported(adapter)) {
|
||||||
|
WGPUAdapter cAdapter = adapter.Get();
|
||||||
|
dawn::native::GetProcs().adapterReference(cAdapter);
|
||||||
|
callback(WGPURequestAdapterStatus_Success, cAdapter, nullptr, userdata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback(WGPURequestAdapterStatus_Unavailable, nullptr, "No supported adapter.", userdata);
|
||||||
|
};
|
||||||
|
|
||||||
wgpu::Device device = MakeDevice(sInstance.get());
|
dawnProcSetProcs(&procs);
|
||||||
if (!device) {
|
|
||||||
// We should only ever fail device creation if an error was injected.
|
|
||||||
ASSERT(supportsErrorInjection);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DevNull devNull;
|
DevNull devNull;
|
||||||
dawn::wire::WireServerDescriptor serverDesc = {};
|
dawn::wire::WireServerDescriptor serverDesc = {};
|
||||||
|
@ -120,21 +130,11 @@ int DawnWireServerFuzzer::Run(const uint8_t* data,
|
||||||
serverDesc.serializer = &devNull;
|
serverDesc.serializer = &devNull;
|
||||||
|
|
||||||
std::unique_ptr<dawn::wire::WireServer> wireServer(new dawn_wire::WireServer(serverDesc));
|
std::unique_ptr<dawn::wire::WireServer> wireServer(new dawn_wire::WireServer(serverDesc));
|
||||||
wireServer->InjectDevice(device.Get(), 1, 0);
|
wireServer->InjectInstance(sInstance->Get(), 1, 0);
|
||||||
|
|
||||||
wireServer->HandleCommands(reinterpret_cast<const char*>(data), size);
|
wireServer->HandleCommands(reinterpret_cast<const char*>(data), size);
|
||||||
|
|
||||||
// Wait for all previous commands before destroying the server.
|
// Note: Deleting the server will release all created objects.
|
||||||
// TODO(enga): Improve this when we improve/finalize how processing events happens.
|
// Deleted devices will wait for idle on destruction.
|
||||||
{
|
|
||||||
device.GetQueue().OnSubmittedWorkDone(
|
|
||||||
0u, [](WGPUQueueWorkDoneStatus, void*) { sCommandsComplete = true; }, nullptr);
|
|
||||||
while (!sCommandsComplete) {
|
|
||||||
device.Tick();
|
|
||||||
utils::USleep(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wireServer = nullptr;
|
wireServer = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,18 @@
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
||||||
class Instance;
|
class Adapter;
|
||||||
|
|
||||||
} // namespace dawn::native
|
} // namespace dawn::native
|
||||||
|
|
||||||
namespace DawnWireServerFuzzer {
|
namespace DawnWireServerFuzzer {
|
||||||
|
|
||||||
using MakeDeviceFn = std::function<wgpu::Device(dawn::native::Instance*)>;
|
|
||||||
|
|
||||||
int Initialize(int* argc, char*** argv);
|
int Initialize(int* argc, char*** argv);
|
||||||
|
|
||||||
int Run(const uint8_t* data, size_t size, MakeDeviceFn MakeDevice, bool supportsErrorInjection);
|
int Run(const uint8_t* data,
|
||||||
|
size_t size,
|
||||||
|
bool (*AdapterSupported)(const dawn::native::Adapter&),
|
||||||
|
bool supportsErrorInjection);
|
||||||
|
|
||||||
} // namespace DawnWireServerFuzzer
|
} // namespace DawnWireServerFuzzer
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ struct MapReadUserdata {
|
||||||
};
|
};
|
||||||
|
|
||||||
DawnTestEnvironment* gTestEnv = nullptr;
|
DawnTestEnvironment* gTestEnv = nullptr;
|
||||||
|
DawnTestBase* gCurrentTest = nullptr;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void printBuffer(testing::AssertionResult& result, const T* buffer, const size_t count) {
|
void printBuffer(testing::AssertionResult& result, const T* buffer, const size_t count) {
|
||||||
|
@ -711,14 +712,68 @@ const std::vector<std::string>& DawnTestEnvironment::GetDisabledToggles() const
|
||||||
|
|
||||||
// Implementation of DawnTest
|
// Implementation of DawnTest
|
||||||
|
|
||||||
DawnTestBase::DawnTestBase(const AdapterTestParam& param)
|
DawnTestBase::DawnTestBase(const AdapterTestParam& param) : mParam(param) {
|
||||||
: mParam(param),
|
gCurrentTest = this;
|
||||||
mWireHelper(utils::CreateWireHelper(gTestEnv->UsesWire(), gTestEnv->GetWireTraceDir())) {}
|
|
||||||
|
DawnProcTable procs = dawn::native::GetProcs();
|
||||||
|
// Override procs to provide harness-specific behavior to always select the null adapter,
|
||||||
|
// and to allow fixture-specific overriding of the test device with CreateDeviceImpl.
|
||||||
|
procs.instanceRequestAdapter = [](WGPUInstance instance, const WGPURequestAdapterOptions*,
|
||||||
|
WGPURequestAdapterCallback callback, void* userdata) {
|
||||||
|
ASSERT(gCurrentTest);
|
||||||
|
|
||||||
|
// Find the adapter that exactly matches our adapter properties.
|
||||||
|
const auto& adapters = gTestEnv->GetInstance()->GetAdapters();
|
||||||
|
const auto& it = std::find_if(
|
||||||
|
adapters.begin(), adapters.end(), [&](const dawn::native::Adapter& adapter) {
|
||||||
|
wgpu::AdapterProperties properties;
|
||||||
|
adapter.GetProperties(&properties);
|
||||||
|
|
||||||
|
const auto& param = gCurrentTest->mParam;
|
||||||
|
return (param.adapterProperties.selected &&
|
||||||
|
properties.deviceID == param.adapterProperties.deviceID &&
|
||||||
|
properties.vendorID == param.adapterProperties.vendorID &&
|
||||||
|
properties.adapterType == param.adapterProperties.adapterType &&
|
||||||
|
properties.backendType == param.adapterProperties.backendType &&
|
||||||
|
strcmp(properties.name, param.adapterProperties.adapterName.c_str()) == 0);
|
||||||
|
});
|
||||||
|
ASSERT(it != adapters.end());
|
||||||
|
gCurrentTest->mBackendAdapter = *it;
|
||||||
|
|
||||||
|
WGPUAdapter cAdapter = it->Get();
|
||||||
|
ASSERT(cAdapter);
|
||||||
|
dawn::native::GetProcs().adapterReference(cAdapter);
|
||||||
|
callback(WGPURequestAdapterStatus_Success, cAdapter, nullptr, userdata);
|
||||||
|
};
|
||||||
|
|
||||||
|
procs.adapterRequestDevice = [](WGPUAdapter adapter, const WGPUDeviceDescriptor*,
|
||||||
|
WGPURequestDeviceCallback callback, void* userdata) {
|
||||||
|
ASSERT(gCurrentTest);
|
||||||
|
|
||||||
|
// Isolation keys may be enqueued by CreateDevice(std::string isolationKey).
|
||||||
|
// CreateDevice calls requestAdapter, so consume them there and forward them
|
||||||
|
// to CreateDeviceImpl.
|
||||||
|
std::string isolationKey;
|
||||||
|
if (!gCurrentTest->mNextIsolationKeyQueue.empty()) {
|
||||||
|
isolationKey = std::move(gCurrentTest->mNextIsolationKeyQueue.front());
|
||||||
|
gCurrentTest->mNextIsolationKeyQueue.pop();
|
||||||
|
}
|
||||||
|
WGPUDevice cDevice = gCurrentTest->CreateDeviceImpl(std::move(isolationKey));
|
||||||
|
ASSERT(cDevice != nullptr);
|
||||||
|
|
||||||
|
gCurrentTest->mLastCreatedBackendDevice = cDevice;
|
||||||
|
callback(WGPURequestDeviceStatus_Success, cDevice, nullptr, userdata);
|
||||||
|
};
|
||||||
|
|
||||||
|
mWireHelper = utils::CreateWireHelper(procs, gTestEnv->UsesWire(), gTestEnv->GetWireTraceDir());
|
||||||
|
}
|
||||||
|
|
||||||
DawnTestBase::~DawnTestBase() {
|
DawnTestBase::~DawnTestBase() {
|
||||||
mReadbackSlots.clear();
|
mReadbackSlots.clear();
|
||||||
queue = wgpu::Queue();
|
queue = nullptr;
|
||||||
device = wgpu::Device();
|
device = nullptr;
|
||||||
|
mAdapter = nullptr;
|
||||||
|
mInstance = nullptr;
|
||||||
|
|
||||||
// D3D12's GPU-based validation will accumulate objects over time if the backend device is not
|
// D3D12's GPU-based validation will accumulate objects over time if the backend device is not
|
||||||
// destroyed and recreated, so we reset it here.
|
// destroyed and recreated, so we reset it here.
|
||||||
|
@ -729,6 +784,8 @@ DawnTestBase::~DawnTestBase() {
|
||||||
|
|
||||||
// Check that all devices were destructed.
|
// Check that all devices were destructed.
|
||||||
EXPECT_EQ(gTestEnv->GetInstance()->GetDeviceCountForTesting(), 0u);
|
EXPECT_EQ(gTestEnv->GetInstance()->GetDeviceCountForTesting(), 0u);
|
||||||
|
|
||||||
|
gCurrentTest = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::IsD3D12() const {
|
bool DawnTestBase::IsD3D12() const {
|
||||||
|
@ -895,10 +952,9 @@ const wgpu::AdapterProperties& DawnTestBase::GetAdapterProperties() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::SupportedLimits DawnTestBase::GetSupportedLimits() {
|
wgpu::SupportedLimits DawnTestBase::GetSupportedLimits() {
|
||||||
WGPUSupportedLimits supportedLimits;
|
wgpu::SupportedLimits supportedLimits = {};
|
||||||
supportedLimits.nextInChain = nullptr;
|
device.GetLimits(&supportedLimits);
|
||||||
dawn::native::GetProcs().deviceGetLimits(backendDevice, &supportedLimits);
|
return supportedLimits;
|
||||||
return *reinterpret_cast<wgpu::SupportedLimits*>(&supportedLimits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DawnTestBase::SupportsFeatures(const std::vector<wgpu::FeatureName>& features) {
|
bool DawnTestBase::SupportsFeatures(const std::vector<wgpu::FeatureName>& features) {
|
||||||
|
@ -923,10 +979,7 @@ bool DawnTestBase::SupportsFeatures(const std::vector<wgpu::FeatureName>& featur
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<wgpu::Device, WGPUDevice> DawnTestBase::CreateDeviceImpl(std::string isolationKey) {
|
WGPUDevice DawnTestBase::CreateDeviceImpl(std::string isolationKey) {
|
||||||
// TODO(dawn:1399) Always flush wire before creating to avoid reuse of the same handle.
|
|
||||||
FlushWire();
|
|
||||||
|
|
||||||
// Create the device from the adapter
|
// Create the device from the adapter
|
||||||
for (const char* forceEnabledWorkaround : mParam.forceEnabledWorkarounds) {
|
for (const char* forceEnabledWorkaround : mParam.forceEnabledWorkarounds) {
|
||||||
ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr);
|
ASSERT(gTestEnv->GetInstance()->GetToggleInfo(forceEnabledWorkaround) != nullptr);
|
||||||
|
@ -977,19 +1030,38 @@ std::pair<wgpu::Device, WGPUDevice> DawnTestBase::CreateDeviceImpl(std::string i
|
||||||
togglesDesc.nextInChain = &cacheDesc;
|
togglesDesc.nextInChain = &cacheDesc;
|
||||||
cacheDesc.isolationKey = isolationKey.c_str();
|
cacheDesc.isolationKey = isolationKey.c_str();
|
||||||
|
|
||||||
auto devices = mWireHelper->RegisterDevice(mBackendAdapter.CreateDevice(&deviceDescriptor));
|
return mBackendAdapter.CreateDevice(&deviceDescriptor);
|
||||||
wgpu::Device device = devices.first;
|
}
|
||||||
|
|
||||||
|
wgpu::Device DawnTestBase::CreateDevice(std::string isolationKey) {
|
||||||
|
wgpu::Device apiDevice;
|
||||||
|
|
||||||
|
// The isolation key will be consumed inside adapterRequestDevice and passed
|
||||||
|
// to CreateDeviceImpl.
|
||||||
|
mNextIsolationKeyQueue.push(std::move(isolationKey));
|
||||||
|
|
||||||
|
// This descriptor doesn't matter since device selection is overriden by CreateDeviceImpl.
|
||||||
|
wgpu::DeviceDescriptor deviceDesc = {};
|
||||||
|
mAdapter.RequestDevice(
|
||||||
|
&deviceDesc,
|
||||||
|
[](WGPURequestDeviceStatus, WGPUDevice cDevice, const char*, void* userdata) {
|
||||||
|
*static_cast<wgpu::Device*>(userdata) = wgpu::Device::Acquire(cDevice);
|
||||||
|
},
|
||||||
|
&apiDevice);
|
||||||
|
FlushWire();
|
||||||
|
ASSERT(apiDevice);
|
||||||
|
|
||||||
// Set up the mocks for uncaptured errors and device loss. The loss of the device is expected
|
// Set up the mocks for uncaptured errors and device loss. The loss of the device is expected
|
||||||
// to happen at the end of the test so at it directly.
|
// to happen at the end of the test so at it directly.
|
||||||
device.SetUncapturedErrorCallback(mDeviceErrorCallback.Callback(),
|
apiDevice.SetUncapturedErrorCallback(mDeviceErrorCallback.Callback(),
|
||||||
mDeviceErrorCallback.MakeUserdata(device.Get()));
|
mDeviceErrorCallback.MakeUserdata(apiDevice.Get()));
|
||||||
device.SetDeviceLostCallback(mDeviceLostCallback.Callback(),
|
apiDevice.SetDeviceLostCallback(mDeviceLostCallback.Callback(),
|
||||||
mDeviceLostCallback.MakeUserdata(device.Get()));
|
mDeviceLostCallback.MakeUserdata(apiDevice.Get()));
|
||||||
EXPECT_CALL(mDeviceLostCallback, Call(WGPUDeviceLostReason_Destroyed, testing::_, device.Get()))
|
EXPECT_CALL(mDeviceLostCallback,
|
||||||
|
Call(WGPUDeviceLostReason_Destroyed, testing::_, apiDevice.Get()))
|
||||||
.Times(testing::AtMost(1));
|
.Times(testing::AtMost(1));
|
||||||
|
|
||||||
device.SetLoggingCallback(
|
apiDevice.SetLoggingCallback(
|
||||||
[](WGPULoggingType type, char const* message, void*) {
|
[](WGPULoggingType type, char const* message, void*) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WGPULoggingType_Verbose:
|
case WGPULoggingType_Verbose:
|
||||||
|
@ -1008,47 +1080,38 @@ std::pair<wgpu::Device, WGPUDevice> DawnTestBase::CreateDeviceImpl(std::string i
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
return devices;
|
return apiDevice;
|
||||||
}
|
|
||||||
|
|
||||||
wgpu::Device DawnTestBase::CreateDevice(std::string isolationKey) {
|
|
||||||
return CreateDeviceImpl(isolationKey).first;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DawnTestBase::SetUp() {
|
void DawnTestBase::SetUp() {
|
||||||
{
|
|
||||||
// Find the adapter that exactly matches our adapter properties.
|
|
||||||
const auto& adapters = gTestEnv->GetInstance()->GetAdapters();
|
|
||||||
const auto& it = std::find_if(
|
|
||||||
adapters.begin(), adapters.end(), [&](const dawn::native::Adapter& adapter) {
|
|
||||||
wgpu::AdapterProperties properties;
|
|
||||||
adapter.GetProperties(&properties);
|
|
||||||
|
|
||||||
return (mParam.adapterProperties.selected &&
|
|
||||||
properties.deviceID == mParam.adapterProperties.deviceID &&
|
|
||||||
properties.vendorID == mParam.adapterProperties.vendorID &&
|
|
||||||
properties.adapterType == mParam.adapterProperties.adapterType &&
|
|
||||||
properties.backendType == mParam.adapterProperties.backendType &&
|
|
||||||
strcmp(properties.name, mParam.adapterProperties.adapterName.c_str()) == 0);
|
|
||||||
});
|
|
||||||
ASSERT(it != adapters.end());
|
|
||||||
mBackendAdapter = *it;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup the per-test platform. Tests can provide one by overloading CreateTestPlatform. This is
|
// Setup the per-test platform. Tests can provide one by overloading CreateTestPlatform. This is
|
||||||
// NOT a thread-safe operation and is allowed here for testing only.
|
// NOT a thread-safe operation and is allowed here for testing only.
|
||||||
mTestPlatform = CreateTestPlatform();
|
mTestPlatform = CreateTestPlatform();
|
||||||
dawn::native::FromAPI(gTestEnv->GetInstance()->Get())
|
dawn::native::FromAPI(gTestEnv->GetInstance()->Get())
|
||||||
->SetPlatformForTesting(mTestPlatform.get());
|
->SetPlatformForTesting(mTestPlatform.get());
|
||||||
|
|
||||||
|
mInstance = mWireHelper->RegisterInstance(gTestEnv->GetInstance()->Get());
|
||||||
|
|
||||||
std::string traceName =
|
std::string traceName =
|
||||||
std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) +
|
std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) +
|
||||||
"_" + ::testing::UnitTest::GetInstance()->current_test_info()->name();
|
"_" + ::testing::UnitTest::GetInstance()->current_test_info()->name();
|
||||||
mWireHelper->BeginWireTrace(traceName.c_str());
|
mWireHelper->BeginWireTrace(traceName.c_str());
|
||||||
|
|
||||||
// Create the device from the adapter
|
// These options are unused since adapter selection is overriden to use the test params
|
||||||
std::tie(device, backendDevice) = CreateDeviceImpl();
|
wgpu::RequestAdapterOptions options = {};
|
||||||
ASSERT_NE(nullptr, backendDevice);
|
mInstance.RequestAdapter(
|
||||||
|
&options,
|
||||||
|
[](WGPURequestAdapterStatus, WGPUAdapter cAdapter, const char*, void* userdata) {
|
||||||
|
*static_cast<wgpu::Adapter*>(userdata) = wgpu::Adapter::Acquire(cAdapter);
|
||||||
|
},
|
||||||
|
&mAdapter);
|
||||||
|
FlushWire();
|
||||||
|
ASSERT(mAdapter);
|
||||||
|
|
||||||
|
device = CreateDevice();
|
||||||
|
backendDevice = mLastCreatedBackendDevice;
|
||||||
|
ASSERT(backendDevice);
|
||||||
|
ASSERT(device);
|
||||||
|
|
||||||
queue = device.GetQueue();
|
queue = device.GetQueue();
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define SRC_DAWN_TESTS_DAWNTEST_H_
|
#define SRC_DAWN_TESTS_DAWNTEST_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <queue>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -536,18 +537,21 @@ class DawnTestBase {
|
||||||
|
|
||||||
const wgpu::AdapterProperties& GetAdapterProperties() const;
|
const wgpu::AdapterProperties& GetAdapterProperties() const;
|
||||||
|
|
||||||
// TODO(crbug.com/dawn/689): Use limits returned from the wire
|
|
||||||
// This is implemented here because tests need to always query
|
|
||||||
// the |backendDevice| since limits are not implemented in the wire.
|
|
||||||
wgpu::SupportedLimits GetSupportedLimits();
|
wgpu::SupportedLimits GetSupportedLimits();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
utils::ScopedAutoreleasePool mObjCAutoreleasePool;
|
utils::ScopedAutoreleasePool mObjCAutoreleasePool;
|
||||||
AdapterTestParam mParam;
|
AdapterTestParam mParam;
|
||||||
std::unique_ptr<utils::WireHelper> mWireHelper;
|
std::unique_ptr<utils::WireHelper> mWireHelper;
|
||||||
|
wgpu::Instance mInstance;
|
||||||
|
wgpu::Adapter mAdapter;
|
||||||
|
|
||||||
|
// Isolation keys are not exposed to the wire client. Device creation in the tests from
|
||||||
|
// the client first push the key into this queue, which is then consumed by the server.
|
||||||
|
std::queue<std::string> mNextIsolationKeyQueue;
|
||||||
|
|
||||||
// Internal device creation function for default device creation with some optional overrides.
|
// Internal device creation function for default device creation with some optional overrides.
|
||||||
std::pair<wgpu::Device, WGPUDevice> CreateDeviceImpl(std::string isolationKey = "");
|
WGPUDevice CreateDeviceImpl(std::string isolationKey);
|
||||||
|
|
||||||
std::ostringstream& AddTextureExpectationImpl(const char* file,
|
std::ostringstream& AddTextureExpectationImpl(const char* file,
|
||||||
int line,
|
int line,
|
||||||
|
@ -608,6 +612,7 @@ class DawnTestBase {
|
||||||
void ResolveExpectations();
|
void ResolveExpectations();
|
||||||
|
|
||||||
dawn::native::Adapter mBackendAdapter;
|
dawn::native::Adapter mBackendAdapter;
|
||||||
|
WGPUDevice mLastCreatedBackendDevice;
|
||||||
|
|
||||||
std::unique_ptr<dawn::platform::Platform> mTestPlatform;
|
std::unique_ptr<dawn::platform::Platform> mTestPlatform;
|
||||||
};
|
};
|
||||||
|
|
|
@ -420,13 +420,13 @@ TEST_F(CopyCommandTest_B2B, CopyWithinSameBuffer) {
|
||||||
|
|
||||||
class CopyCommandTest_B2T : public CopyCommandTest {
|
class CopyCommandTest_B2T : public CopyCommandTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
|
wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
|
||||||
wgpu::FeatureName::Depth32FloatStencil8};
|
wgpu::FeatureName::Depth32FloatStencil8};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 2;
|
descriptor.requiredFeaturesCount = 2;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1029,13 +1029,13 @@ TEST_F(CopyCommandTest_B2T, RequiredBytesInCopyOverflow) {
|
||||||
|
|
||||||
class CopyCommandTest_T2B : public CopyCommandTest {
|
class CopyCommandTest_T2B : public CopyCommandTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
|
wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
|
||||||
wgpu::FeatureName::Depth32FloatStencil8};
|
wgpu::FeatureName::Depth32FloatStencil8};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 2;
|
descriptor.requiredFeaturesCount = 2;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1667,13 +1667,13 @@ TEST_F(CopyCommandTest_T2B, RequiredBytesInCopyOverflow) {
|
||||||
|
|
||||||
class CopyCommandTest_T2T : public CopyCommandTest {
|
class CopyCommandTest_T2T : public CopyCommandTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
|
wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::Depth24UnormStencil8,
|
||||||
wgpu::FeatureName::Depth32FloatStencil8};
|
wgpu::FeatureName::Depth32FloatStencil8};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 2;
|
descriptor.requiredFeaturesCount = 2;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::TextureFormat GetCopyCompatibleFormat(wgpu::TextureFormat format) {
|
wgpu::TextureFormat GetCopyCompatibleFormat(wgpu::TextureFormat format) {
|
||||||
|
@ -2145,14 +2145,14 @@ TEST_F(CopyCommandTest_T2T, CopyWithinSameTexture) {
|
||||||
|
|
||||||
class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest {
|
class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
|
wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
|
||||||
wgpu::FeatureName::TextureCompressionETC2,
|
wgpu::FeatureName::TextureCompressionETC2,
|
||||||
wgpu::FeatureName::TextureCompressionASTC};
|
wgpu::FeatureName::TextureCompressionASTC};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 3;
|
descriptor.requiredFeaturesCount = 3;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::Texture Create2DTexture(wgpu::TextureFormat format,
|
wgpu::Texture Create2DTexture(wgpu::TextureFormat format,
|
||||||
|
|
|
@ -65,13 +65,13 @@ class RequestDeviceValidationTest : public ValidationTest {
|
||||||
// Test that requesting a device without specifying limits is valid.
|
// Test that requesting a device without specifying limits is valid.
|
||||||
TEST_F(RequestDeviceValidationTest, NoRequiredLimits) {
|
TEST_F(RequestDeviceValidationTest, NoRequiredLimits) {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
|
GetBackendAdapter().RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
|
||||||
CheckDevice([](wgpu::Device device) {
|
CheckDevice([](wgpu::Device device) {
|
||||||
// Check one of the default limits.
|
// Check one of the default limits.
|
||||||
wgpu::SupportedLimits limits;
|
wgpu::SupportedLimits limits;
|
||||||
device.GetLimits(&limits);
|
device.GetLimits(&limits);
|
||||||
EXPECT_EQ(limits.limits.maxBindGroups, 4u);
|
EXPECT_EQ(limits.limits.maxBindGroups, 4u);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that requesting a device with the default limits is valid.
|
// Test that requesting a device with the default limits is valid.
|
||||||
|
@ -79,13 +79,13 @@ TEST_F(RequestDeviceValidationTest, DefaultLimits) {
|
||||||
wgpu::RequiredLimits limits = {};
|
wgpu::RequiredLimits limits = {};
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
descriptor.requiredLimits = &limits;
|
descriptor.requiredLimits = &limits;
|
||||||
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
|
GetBackendAdapter().RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
|
||||||
CheckDevice([](wgpu::Device device) {
|
CheckDevice([](wgpu::Device device) {
|
||||||
// Check one of the default limits.
|
// Check one of the default limits.
|
||||||
wgpu::SupportedLimits limits;
|
wgpu::SupportedLimits limits;
|
||||||
device.GetLimits(&limits);
|
device.GetLimits(&limits);
|
||||||
EXPECT_EQ(limits.limits.maxTextureArrayLayers, 256u);
|
EXPECT_EQ(limits.limits.maxTextureArrayLayers, 256u);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that requesting a device where a required limit is above the maximum value.
|
// Test that requesting a device where a required limit is above the maximum value.
|
||||||
|
@ -95,12 +95,12 @@ TEST_F(RequestDeviceValidationTest, HigherIsBetter) {
|
||||||
descriptor.requiredLimits = &limits;
|
descriptor.requiredLimits = &limits;
|
||||||
|
|
||||||
wgpu::SupportedLimits supportedLimits;
|
wgpu::SupportedLimits supportedLimits;
|
||||||
EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits)));
|
EXPECT_TRUE(adapter.GetLimits(&supportedLimits));
|
||||||
|
|
||||||
// If we can support better than the default, test below the max.
|
// If we can support better than the default, test below the max.
|
||||||
if (supportedLimits.limits.maxBindGroups > 4u) {
|
if (supportedLimits.limits.maxBindGroups > 4u) {
|
||||||
limits.limits.maxBindGroups = supportedLimits.limits.maxBindGroups - 1;
|
limits.limits.maxBindGroups = supportedLimits.limits.maxBindGroups - 1;
|
||||||
adapter.RequestDevice(
|
GetBackendAdapter().RequestDevice(
|
||||||
&descriptor, ExpectRequestDeviceSuccess, CheckDevice([&](wgpu::Device device) {
|
&descriptor, ExpectRequestDeviceSuccess, CheckDevice([&](wgpu::Device device) {
|
||||||
wgpu::SupportedLimits limits;
|
wgpu::SupportedLimits limits;
|
||||||
device.GetLimits(&limits);
|
device.GetLimits(&limits);
|
||||||
|
@ -114,7 +114,7 @@ TEST_F(RequestDeviceValidationTest, HigherIsBetter) {
|
||||||
|
|
||||||
// Test the max.
|
// Test the max.
|
||||||
limits.limits.maxBindGroups = supportedLimits.limits.maxBindGroups;
|
limits.limits.maxBindGroups = supportedLimits.limits.maxBindGroups;
|
||||||
adapter.RequestDevice(
|
GetBackendAdapter().RequestDevice(
|
||||||
&descriptor, ExpectRequestDeviceSuccess, CheckDevice([&](wgpu::Device device) {
|
&descriptor, ExpectRequestDeviceSuccess, CheckDevice([&](wgpu::Device device) {
|
||||||
wgpu::SupportedLimits limits;
|
wgpu::SupportedLimits limits;
|
||||||
device.GetLimits(&limits);
|
device.GetLimits(&limits);
|
||||||
|
@ -127,18 +127,18 @@ TEST_F(RequestDeviceValidationTest, HigherIsBetter) {
|
||||||
|
|
||||||
// Test above the max.
|
// Test above the max.
|
||||||
limits.limits.maxBindGroups = supportedLimits.limits.maxBindGroups + 1;
|
limits.limits.maxBindGroups = supportedLimits.limits.maxBindGroups + 1;
|
||||||
adapter.RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
|
GetBackendAdapter().RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
|
||||||
|
|
||||||
// Test worse than the default
|
// Test worse than the default
|
||||||
limits.limits.maxBindGroups = 3u;
|
limits.limits.maxBindGroups = 3u;
|
||||||
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
|
GetBackendAdapter().RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
|
||||||
CheckDevice([&](wgpu::Device device) {
|
CheckDevice([&](wgpu::Device device) {
|
||||||
wgpu::SupportedLimits limits;
|
wgpu::SupportedLimits limits;
|
||||||
device.GetLimits(&limits);
|
device.GetLimits(&limits);
|
||||||
|
|
||||||
// Check we got the default.
|
// Check we got the default.
|
||||||
EXPECT_EQ(limits.limits.maxBindGroups, 4u);
|
EXPECT_EQ(limits.limits.maxBindGroups, 4u);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that requesting a device where a required limit is below the minimum value.
|
// Test that requesting a device where a required limit is below the minimum value.
|
||||||
|
@ -148,33 +148,33 @@ TEST_F(RequestDeviceValidationTest, LowerIsBetter) {
|
||||||
descriptor.requiredLimits = &limits;
|
descriptor.requiredLimits = &limits;
|
||||||
|
|
||||||
wgpu::SupportedLimits supportedLimits;
|
wgpu::SupportedLimits supportedLimits;
|
||||||
EXPECT_TRUE(adapter.GetLimits(reinterpret_cast<WGPUSupportedLimits*>(&supportedLimits)));
|
EXPECT_TRUE(adapter.GetLimits(&supportedLimits));
|
||||||
|
|
||||||
// Test below the min.
|
// Test below the min.
|
||||||
limits.limits.minUniformBufferOffsetAlignment =
|
limits.limits.minUniformBufferOffsetAlignment =
|
||||||
supportedLimits.limits.minUniformBufferOffsetAlignment / 2;
|
supportedLimits.limits.minUniformBufferOffsetAlignment / 2;
|
||||||
adapter.RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
|
GetBackendAdapter().RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
|
||||||
|
|
||||||
// Test the min.
|
// Test the min.
|
||||||
limits.limits.minUniformBufferOffsetAlignment =
|
limits.limits.minUniformBufferOffsetAlignment =
|
||||||
supportedLimits.limits.minUniformBufferOffsetAlignment;
|
supportedLimits.limits.minUniformBufferOffsetAlignment;
|
||||||
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
|
GetBackendAdapter().RequestDevice(
|
||||||
CheckDevice([&](wgpu::Device device) {
|
&descriptor, ExpectRequestDeviceSuccess, CheckDevice([&](wgpu::Device device) {
|
||||||
wgpu::SupportedLimits limits;
|
wgpu::SupportedLimits limits;
|
||||||
device.GetLimits(&limits);
|
device.GetLimits(&limits);
|
||||||
|
|
||||||
// Check we got exactly the request.
|
// Check we got exactly the request.
|
||||||
EXPECT_EQ(limits.limits.minUniformBufferOffsetAlignment,
|
EXPECT_EQ(limits.limits.minUniformBufferOffsetAlignment,
|
||||||
supportedLimits.limits.minUniformBufferOffsetAlignment);
|
supportedLimits.limits.minUniformBufferOffsetAlignment);
|
||||||
// Check another default limit.
|
// Check another default limit.
|
||||||
EXPECT_EQ(limits.limits.maxTextureArrayLayers, 256u);
|
EXPECT_EQ(limits.limits.maxTextureArrayLayers, 256u);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// IF we can support better than the default, test above the min.
|
// IF we can support better than the default, test above the min.
|
||||||
if (supportedLimits.limits.minUniformBufferOffsetAlignment > 256u) {
|
if (supportedLimits.limits.minUniformBufferOffsetAlignment > 256u) {
|
||||||
limits.limits.minUniformBufferOffsetAlignment =
|
limits.limits.minUniformBufferOffsetAlignment =
|
||||||
supportedLimits.limits.minUniformBufferOffsetAlignment * 2;
|
supportedLimits.limits.minUniformBufferOffsetAlignment * 2;
|
||||||
adapter.RequestDevice(
|
GetBackendAdapter().RequestDevice(
|
||||||
&descriptor, ExpectRequestDeviceSuccess, CheckDevice([&](wgpu::Device device) {
|
&descriptor, ExpectRequestDeviceSuccess, CheckDevice([&](wgpu::Device device) {
|
||||||
wgpu::SupportedLimits limits;
|
wgpu::SupportedLimits limits;
|
||||||
device.GetLimits(&limits);
|
device.GetLimits(&limits);
|
||||||
|
@ -189,14 +189,14 @@ TEST_F(RequestDeviceValidationTest, LowerIsBetter) {
|
||||||
|
|
||||||
// Test worse than the default
|
// Test worse than the default
|
||||||
limits.limits.minUniformBufferOffsetAlignment = 2u * 256u;
|
limits.limits.minUniformBufferOffsetAlignment = 2u * 256u;
|
||||||
adapter.RequestDevice(&descriptor, ExpectRequestDeviceSuccess,
|
GetBackendAdapter().RequestDevice(
|
||||||
CheckDevice([&](wgpu::Device device) {
|
&descriptor, ExpectRequestDeviceSuccess, CheckDevice([&](wgpu::Device device) {
|
||||||
wgpu::SupportedLimits limits;
|
wgpu::SupportedLimits limits;
|
||||||
device.GetLimits(&limits);
|
device.GetLimits(&limits);
|
||||||
|
|
||||||
// Check we got the default.
|
// Check we got the default.
|
||||||
EXPECT_EQ(limits.limits.minUniformBufferOffsetAlignment, 256u);
|
EXPECT_EQ(limits.limits.minUniformBufferOffsetAlignment, 256u);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that it is an error to request limits with an invalid chained struct
|
// Test that it is an error to request limits with an invalid chained struct
|
||||||
|
@ -207,7 +207,7 @@ TEST_F(RequestDeviceValidationTest, InvalidChainedStruct) {
|
||||||
|
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
descriptor.requiredLimits = &limits;
|
descriptor.requiredLimits = &limits;
|
||||||
adapter.RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
|
GetBackendAdapter().RequestDevice(&descriptor, ExpectRequestDeviceError, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeviceTickValidationTest : public ValidationTest {};
|
class DeviceTickValidationTest : public ValidationTest {};
|
||||||
|
|
|
@ -64,12 +64,12 @@ TEST_F(InternalUsageValidationDisabledTest, CommandEncoderDescriptorRequiresFeat
|
||||||
}
|
}
|
||||||
|
|
||||||
class TextureInternalUsageValidationTest : public ValidationTest {
|
class TextureInternalUsageValidationTest : public ValidationTest {
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnInternalUsages};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnInternalUsages};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 1;
|
descriptor.requiredFeaturesCount = 1;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,14 @@
|
||||||
#include "dawn/utils/ComboRenderPipelineDescriptor.h"
|
#include "dawn/utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "dawn/utils/WGPUHelpers.h"
|
#include "dawn/utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class LabelTest : public ValidationTest {};
|
class LabelTest : public ValidationTest {
|
||||||
|
void SetUp() override {
|
||||||
|
ValidationTest::SetUp();
|
||||||
|
DAWN_SKIP_TEST_IF(UsesWire());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
TEST_F(LabelTest, BindGroup) {
|
TEST_F(LabelTest, BindGroup) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
|
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
|
||||||
|
|
||||||
|
@ -55,7 +59,6 @@ TEST_F(LabelTest, BindGroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, BindGroupLayout) {
|
TEST_F(LabelTest, BindGroupLayout) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
|
|
||||||
wgpu::BindGroupLayoutDescriptor descriptor = {};
|
wgpu::BindGroupLayoutDescriptor descriptor = {};
|
||||||
|
@ -87,7 +90,6 @@ TEST_F(LabelTest, BindGroupLayout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, Buffer) {
|
TEST_F(LabelTest, Buffer) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::BufferDescriptor descriptor;
|
wgpu::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
|
@ -118,7 +120,6 @@ TEST_F(LabelTest, Buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, CommandBuffer) {
|
TEST_F(LabelTest, CommandBuffer) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::CommandBufferDescriptor descriptor;
|
wgpu::CommandBufferDescriptor descriptor;
|
||||||
|
|
||||||
|
@ -150,7 +151,6 @@ TEST_F(LabelTest, CommandBuffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, CommandEncoder) {
|
TEST_F(LabelTest, CommandEncoder) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::CommandEncoderDescriptor descriptor;
|
wgpu::CommandEncoderDescriptor descriptor;
|
||||||
|
|
||||||
|
@ -179,7 +179,6 @@ TEST_F(LabelTest, CommandEncoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, ComputePassEncoder) {
|
TEST_F(LabelTest, ComputePassEncoder) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
||||||
|
|
||||||
|
@ -213,7 +212,6 @@ TEST_F(LabelTest, ComputePassEncoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, ExternalTexture) {
|
TEST_F(LabelTest, ExternalTexture) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::TextureDescriptor textureDescriptor;
|
wgpu::TextureDescriptor textureDescriptor;
|
||||||
textureDescriptor.size.width = 1;
|
textureDescriptor.size.width = 1;
|
||||||
|
@ -260,7 +258,6 @@ TEST_F(LabelTest, ExternalTexture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, PipelineLayout) {
|
TEST_F(LabelTest, PipelineLayout) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
|
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(device, {});
|
||||||
|
|
||||||
|
@ -324,13 +321,13 @@ TEST_F(LabelTest, QuerySet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, Queue) {
|
TEST_F(LabelTest, Queue) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
|
|
||||||
// The label should be empty if one was not set.
|
// The label should be empty if one was not set.
|
||||||
{
|
{
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::Device labelDevice = wgpu::Device::Acquire(adapter.CreateDevice(&descriptor));
|
wgpu::Device labelDevice =
|
||||||
|
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
||||||
std::string readbackLabel =
|
std::string readbackLabel =
|
||||||
dawn::native::GetObjectLabelForTesting(labelDevice.GetQueue().Get());
|
dawn::native::GetObjectLabelForTesting(labelDevice.GetQueue().Get());
|
||||||
ASSERT_TRUE(readbackLabel.empty());
|
ASSERT_TRUE(readbackLabel.empty());
|
||||||
|
@ -339,7 +336,8 @@ TEST_F(LabelTest, Queue) {
|
||||||
// Test setting a label through API
|
// Test setting a label through API
|
||||||
{
|
{
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::Device labelDevice = wgpu::Device::Acquire(adapter.CreateDevice(&descriptor));
|
wgpu::Device labelDevice =
|
||||||
|
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
||||||
labelDevice.GetQueue().SetLabel(label.c_str());
|
labelDevice.GetQueue().SetLabel(label.c_str());
|
||||||
std::string readbackLabel =
|
std::string readbackLabel =
|
||||||
dawn::native::GetObjectLabelForTesting(labelDevice.GetQueue().Get());
|
dawn::native::GetObjectLabelForTesting(labelDevice.GetQueue().Get());
|
||||||
|
@ -350,7 +348,8 @@ TEST_F(LabelTest, Queue) {
|
||||||
{
|
{
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
descriptor.defaultQueue.label = label.c_str();
|
descriptor.defaultQueue.label = label.c_str();
|
||||||
wgpu::Device labelDevice = wgpu::Device::Acquire(adapter.CreateDevice(&descriptor));
|
wgpu::Device labelDevice =
|
||||||
|
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
||||||
std::string readbackLabel =
|
std::string readbackLabel =
|
||||||
dawn::native::GetObjectLabelForTesting(labelDevice.GetQueue().Get());
|
dawn::native::GetObjectLabelForTesting(labelDevice.GetQueue().Get());
|
||||||
ASSERT_EQ(label, readbackLabel);
|
ASSERT_EQ(label, readbackLabel);
|
||||||
|
@ -358,7 +357,6 @@ TEST_F(LabelTest, Queue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, RenderBundleEncoder) {
|
TEST_F(LabelTest, RenderBundleEncoder) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
|
|
||||||
utils::ComboRenderBundleEncoderDescriptor descriptor = {};
|
utils::ComboRenderBundleEncoderDescriptor descriptor = {};
|
||||||
|
@ -390,7 +388,6 @@ TEST_F(LabelTest, RenderBundleEncoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, RenderPassEncoder) {
|
TEST_F(LabelTest, RenderPassEncoder) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
||||||
|
|
||||||
|
@ -430,7 +427,6 @@ TEST_F(LabelTest, RenderPassEncoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, Sampler) {
|
TEST_F(LabelTest, Sampler) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::SamplerDescriptor descriptor;
|
wgpu::SamplerDescriptor descriptor;
|
||||||
|
|
||||||
|
@ -459,7 +455,6 @@ TEST_F(LabelTest, Sampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, Texture) {
|
TEST_F(LabelTest, Texture) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::TextureDescriptor descriptor;
|
wgpu::TextureDescriptor descriptor;
|
||||||
descriptor.size.width = 1;
|
descriptor.size.width = 1;
|
||||||
|
@ -496,7 +491,6 @@ TEST_F(LabelTest, Texture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, TextureView) {
|
TEST_F(LabelTest, TextureView) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
wgpu::TextureDescriptor descriptor;
|
wgpu::TextureDescriptor descriptor;
|
||||||
descriptor.size.width = 1;
|
descriptor.size.width = 1;
|
||||||
|
@ -536,7 +530,6 @@ TEST_F(LabelTest, TextureView) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, RenderPipeline) {
|
TEST_F(LabelTest, RenderPipeline) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
|
|
||||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||||
|
@ -578,7 +571,6 @@ TEST_F(LabelTest, RenderPipeline) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, ComputePipeline) {
|
TEST_F(LabelTest, ComputePipeline) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
|
|
||||||
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
|
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
|
||||||
|
@ -615,7 +607,6 @@ TEST_F(LabelTest, ComputePipeline) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LabelTest, ShaderModule) {
|
TEST_F(LabelTest, ShaderModule) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
|
||||||
std::string label = "test";
|
std::string label = "test";
|
||||||
|
|
||||||
const char* source = R"(
|
const char* source = R"(
|
||||||
|
|
|
@ -27,7 +27,7 @@ class MultipleDeviceTest : public ValidationTest {};
|
||||||
|
|
||||||
// Test that it is invalid to submit a command buffer created on a different device.
|
// Test that it is invalid to submit a command buffer created on a different device.
|
||||||
TEST_F(MultipleDeviceTest, ValidatesSameDevice) {
|
TEST_F(MultipleDeviceTest, ValidatesSameDevice) {
|
||||||
wgpu::Device device2 = RegisterDevice(CreateTestDevice());
|
wgpu::Device device2 = RequestDeviceSync(wgpu::DeviceDescriptor{});
|
||||||
wgpu::CommandBuffer commandBuffer = device2.CreateCommandEncoder().Finish();
|
wgpu::CommandBuffer commandBuffer = device2.CreateCommandEncoder().Finish();
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(device.GetQueue().Submit(1, &commandBuffer));
|
ASSERT_DEVICE_ERROR(device.GetQueue().Submit(1, &commandBuffer));
|
||||||
|
@ -66,7 +66,7 @@ TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreatePipelineAsync) {
|
||||||
|
|
||||||
// CreateComputePipelineAsync errors if the shader module is created on a different device.
|
// CreateComputePipelineAsync errors if the shader module is created on a different device.
|
||||||
{
|
{
|
||||||
wgpu::Device device2 = RegisterDevice(CreateTestDevice());
|
wgpu::Device device2 = RequestDeviceSync(wgpu::DeviceDescriptor{});
|
||||||
wgpu::ShaderModule shaderModule = device2.CreateShaderModule(&shaderModuleDesc);
|
wgpu::ShaderModule shaderModule = device2.CreateShaderModule(&shaderModuleDesc);
|
||||||
|
|
||||||
wgpu::ComputePipelineDescriptor pipelineDesc = {};
|
wgpu::ComputePipelineDescriptor pipelineDesc = {};
|
||||||
|
|
|
@ -111,7 +111,7 @@ TEST_F(OcclusionQueryValidationTest, InvalidOcclusionQuerySet) {
|
||||||
|
|
||||||
// Fail to begin render pass if the occlusionQuerySet is created from other device
|
// Fail to begin render pass if the occlusionQuerySet is created from other device
|
||||||
{
|
{
|
||||||
wgpu::Device otherDevice = RegisterDevice(adapter.CreateDevice());
|
wgpu::Device otherDevice = RequestDeviceSync(wgpu::DeviceDescriptor{});
|
||||||
wgpu::QuerySet occlusionQuerySetOnOther =
|
wgpu::QuerySet occlusionQuerySetOnOther =
|
||||||
CreateQuerySet(otherDevice, wgpu::QueryType::Occlusion, 2);
|
CreateQuerySet(otherDevice, wgpu::QueryType::Occlusion, 2);
|
||||||
renderPass.occlusionQuerySet = occlusionQuerySetOnOther;
|
renderPass.occlusionQuerySet = occlusionQuerySetOnOther;
|
||||||
|
@ -225,7 +225,7 @@ TEST_F(OcclusionQueryValidationTest, InvalidBeginAndEnd) {
|
||||||
|
|
||||||
class TimestampQueryValidationTest : public QuerySetValidationTest {
|
class TimestampQueryValidationTest : public QuerySetValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::TimestampQuery};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::TimestampQuery};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
|
@ -237,7 +237,7 @@ class TimestampQueryValidationTest : public QuerySetValidationTest {
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggles;
|
togglesDesc.forceDisabledToggles = forceDisabledToggles;
|
||||||
togglesDesc.forceDisabledTogglesCount = 1;
|
togglesDesc.forceDisabledTogglesCount = 1;
|
||||||
|
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodeRenderPassWithTimestampWrites(
|
void EncodeRenderPassWithTimestampWrites(
|
||||||
|
@ -324,7 +324,7 @@ TEST_F(TimestampQueryValidationTest, TimestampWritesOnComputePass) {
|
||||||
|
|
||||||
// Fail to write timestamps to a query set created from another device
|
// Fail to write timestamps to a query set created from another device
|
||||||
{
|
{
|
||||||
wgpu::Device otherDevice = RegisterDevice(adapter.CreateDevice());
|
wgpu::Device otherDevice = RequestDeviceSync(wgpu::DeviceDescriptor{});
|
||||||
wgpu::QuerySet querySetFromOtherDevice =
|
wgpu::QuerySet querySetFromOtherDevice =
|
||||||
CreateQuerySet(otherDevice, wgpu::QueryType::Timestamp, 2);
|
CreateQuerySet(otherDevice, wgpu::QueryType::Timestamp, 2);
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ TEST_F(TimestampQueryValidationTest, TimestampWritesOnRenderPass) {
|
||||||
|
|
||||||
// Fail to write timestamps to a query set created from another device
|
// Fail to write timestamps to a query set created from another device
|
||||||
{
|
{
|
||||||
wgpu::Device otherDevice = RegisterDevice(adapter.CreateDevice());
|
wgpu::Device otherDevice = RequestDeviceSync(wgpu::DeviceDescriptor{});
|
||||||
wgpu::QuerySet querySetFromOtherDevice =
|
wgpu::QuerySet querySetFromOtherDevice =
|
||||||
CreateQuerySet(otherDevice, wgpu::QueryType::Timestamp, 2);
|
CreateQuerySet(otherDevice, wgpu::QueryType::Timestamp, 2);
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ TEST_F(TimestampQueryValidationTest, WriteTimestampOnRenderPassEncoder) {
|
||||||
|
|
||||||
class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
|
class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::PipelineStatisticsQuery};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::PipelineStatisticsQuery};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
|
@ -654,7 +654,7 @@ class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggles;
|
togglesDesc.forceDisabledToggles = forceDisabledToggles;
|
||||||
togglesDesc.forceDisabledTogglesCount = 1;
|
togglesDesc.forceDisabledTogglesCount = 1;
|
||||||
|
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -793,7 +793,7 @@ TEST_F(ResolveQuerySetValidationTest, ResolveToInvalidBufferAndOffset) {
|
||||||
|
|
||||||
// Fail to resolve query set to a buffer created from another device
|
// Fail to resolve query set to a buffer created from another device
|
||||||
{
|
{
|
||||||
wgpu::Device otherDevice = RegisterDevice(adapter.CreateDevice());
|
wgpu::Device otherDevice = RequestDeviceSync(wgpu::DeviceDescriptor{});
|
||||||
wgpu::Buffer bufferOnOther =
|
wgpu::Buffer bufferOnOther =
|
||||||
CreateBuffer(otherDevice, kBufferSize, wgpu::BufferUsage::QueryResolve);
|
CreateBuffer(otherDevice, kBufferSize, wgpu::BufferUsage::QueryResolve);
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
|
|
@ -535,14 +535,14 @@ TEST_F(QueueWriteTextureValidationTest, WriteToStencilAspect) {
|
||||||
|
|
||||||
class WriteTextureTest_CompressedTextureFormats : public QueueWriteTextureValidationTest {
|
class WriteTextureTest_CompressedTextureFormats : public QueueWriteTextureValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
|
wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
|
||||||
wgpu::FeatureName::TextureCompressionETC2,
|
wgpu::FeatureName::TextureCompressionETC2,
|
||||||
wgpu::FeatureName::TextureCompressionASTC};
|
wgpu::FeatureName::TextureCompressionASTC};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 3;
|
descriptor.requiredFeaturesCount = 3;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::Texture Create2DTexture(wgpu::TextureFormat format,
|
wgpu::Texture Create2DTexture(wgpu::TextureFormat format,
|
||||||
|
|
|
@ -1267,12 +1267,12 @@ TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) {
|
||||||
|
|
||||||
class DepthClampingValidationTest : public RenderPipelineValidationTest {
|
class DepthClampingValidationTest : public RenderPipelineValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DepthClamping};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DepthClamping};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 1;
|
descriptor.requiredFeaturesCount = 1;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -698,12 +698,12 @@ TEST_F(TextureValidationTest, UseASTCFormatWithoutEnablingFeature) {
|
||||||
|
|
||||||
class D24S8TextureFormatsValidationTests : public TextureValidationTest {
|
class D24S8TextureFormatsValidationTests : public TextureValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth24UnormStencil8};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth24UnormStencil8};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 1;
|
descriptor.requiredFeaturesCount = 1;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -720,12 +720,12 @@ TEST_F(D24S8TextureFormatsValidationTests, DepthStencilFormatsFor3D) {
|
||||||
|
|
||||||
class D32S8TextureFormatsValidationTests : public TextureValidationTest {
|
class D32S8TextureFormatsValidationTests : public TextureValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 1;
|
descriptor.requiredFeaturesCount = 1;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ TEST_F(D32S8TextureFormatsValidationTests, DepthStencilFormatsFor3D) {
|
||||||
|
|
||||||
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
|
wgpu::FeatureName requiredFeatures[3] = {wgpu::FeatureName::TextureCompressionBC,
|
||||||
wgpu::FeatureName::TextureCompressionETC2,
|
wgpu::FeatureName::TextureCompressionETC2,
|
||||||
|
@ -758,7 +758,7 @@ class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||||
|
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &togglesDesc;
|
||||||
|
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::TextureDescriptor CreateDefaultTextureDescriptor() {
|
wgpu::TextureDescriptor CreateDefaultTextureDescriptor() {
|
||||||
|
|
|
@ -925,12 +925,12 @@ TEST_F(TextureViewValidationTest, AspectMustExist) {
|
||||||
|
|
||||||
class D24S8TextureViewValidationTests : public ValidationTest {
|
class D24S8TextureViewValidationTests : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth24UnormStencil8};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth24UnormStencil8};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 1;
|
descriptor.requiredFeaturesCount = 1;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -971,12 +971,12 @@ TEST_F(D24S8TextureViewValidationTests, TextureViewFormatCompatibility) {
|
||||||
|
|
||||||
class D32S8TextureViewValidationTests : public ValidationTest {
|
class D32S8TextureViewValidationTests : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Depth32FloatStencil8};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 1;
|
descriptor.requiredFeaturesCount = 1;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ TEST_F(ToggleValidationTest, QueryToggleInfo) {
|
||||||
// Query with a valid toggle name
|
// Query with a valid toggle name
|
||||||
{
|
{
|
||||||
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
||||||
const dawn::native::ToggleInfo* toggleInfo = instance->GetToggleInfo(kValidToggleName);
|
const dawn::native::ToggleInfo* toggleInfo = GetToggleInfo(kValidToggleName);
|
||||||
ASSERT_NE(nullptr, toggleInfo);
|
ASSERT_NE(nullptr, toggleInfo);
|
||||||
ASSERT_NE(nullptr, toggleInfo->name);
|
ASSERT_NE(nullptr, toggleInfo->name);
|
||||||
ASSERT_NE(nullptr, toggleInfo->description);
|
ASSERT_NE(nullptr, toggleInfo->description);
|
||||||
|
@ -40,7 +40,7 @@ TEST_F(ToggleValidationTest, QueryToggleInfo) {
|
||||||
// Query with an invalid toggle name
|
// Query with an invalid toggle name
|
||||||
{
|
{
|
||||||
const char* kInvalidToggleName = "!@#$%^&*";
|
const char* kInvalidToggleName = "!@#$%^&*";
|
||||||
const dawn::native::ToggleInfo* toggleInfo = instance->GetToggleInfo(kInvalidToggleName);
|
const dawn::native::ToggleInfo* toggleInfo = GetToggleInfo(kInvalidToggleName);
|
||||||
ASSERT_EQ(nullptr, toggleInfo);
|
ASSERT_EQ(nullptr, toggleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,8 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
||||||
togglesDesc.forceEnabledToggles = &kValidToggleName;
|
togglesDesc.forceEnabledToggles = &kValidToggleName;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
togglesDesc.forceEnabledTogglesCount = 1;
|
||||||
|
|
||||||
wgpu::Device deviceWithToggle = wgpu::Device::Acquire(adapter.CreateDevice(&descriptor));
|
wgpu::Device deviceWithToggle =
|
||||||
|
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
||||||
std::vector<const char*> toggleNames = dawn::native::GetTogglesUsed(deviceWithToggle.Get());
|
std::vector<const char*> toggleNames = dawn::native::GetTogglesUsed(deviceWithToggle.Get());
|
||||||
bool validToggleExists = false;
|
bool validToggleExists = false;
|
||||||
for (const char* toggle : toggleNames) {
|
for (const char* toggle : toggleNames) {
|
||||||
|
@ -76,7 +77,8 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
||||||
togglesDesc.forceEnabledToggles = &kInvalidToggleName;
|
togglesDesc.forceEnabledToggles = &kInvalidToggleName;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
togglesDesc.forceEnabledTogglesCount = 1;
|
||||||
|
|
||||||
wgpu::Device deviceWithToggle = wgpu::Device::Acquire(adapter.CreateDevice(&descriptor));
|
wgpu::Device deviceWithToggle =
|
||||||
|
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
||||||
std::vector<const char*> toggleNames = dawn::native::GetTogglesUsed(deviceWithToggle.Get());
|
std::vector<const char*> toggleNames = dawn::native::GetTogglesUsed(deviceWithToggle.Get());
|
||||||
bool InvalidToggleExists = false;
|
bool InvalidToggleExists = false;
|
||||||
for (const char* toggle : toggleNames) {
|
for (const char* toggle : toggleNames) {
|
||||||
|
@ -96,7 +98,8 @@ TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
|
||||||
togglesDesc.forceEnabledToggles = &kValidToggleName;
|
togglesDesc.forceEnabledToggles = &kValidToggleName;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
togglesDesc.forceEnabledTogglesCount = 1;
|
||||||
|
|
||||||
wgpu::Device deviceWithToggle = wgpu::Device::Acquire(adapter.CreateDevice(&descriptor));
|
wgpu::Device deviceWithToggle =
|
||||||
|
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
||||||
std::vector<const char*> toggleNames = dawn::native::GetTogglesUsed(deviceWithToggle.Get());
|
std::vector<const char*> toggleNames = dawn::native::GetTogglesUsed(deviceWithToggle.Get());
|
||||||
bool validToggleExists = false;
|
bool validToggleExists = false;
|
||||||
for (const char* toggle : toggleNames) {
|
for (const char* toggle : toggleNames) {
|
||||||
|
|
|
@ -26,14 +26,14 @@ using testing::HasSubstr;
|
||||||
|
|
||||||
class UnsafeAPIValidationTest : public ValidationTest {
|
class UnsafeAPIValidationTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &togglesDesc;
|
||||||
const char* toggle = "disallow_unsafe_apis";
|
const char* toggle = "disallow_unsafe_apis";
|
||||||
togglesDesc.forceEnabledToggles = &toggle;
|
togglesDesc.forceEnabledToggles = &toggle;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
togglesDesc.forceEnabledTogglesCount = 1;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
|
||||||
|
|
||||||
class UnsafeQueryAPIValidationTest : public ValidationTest {
|
class UnsafeQueryAPIValidationTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::PipelineStatisticsQuery,
|
wgpu::FeatureName requiredFeatures[2] = {wgpu::FeatureName::PipelineStatisticsQuery,
|
||||||
wgpu::FeatureName::TimestampQuery};
|
wgpu::FeatureName::TimestampQuery};
|
||||||
|
@ -92,7 +92,7 @@ class UnsafeQueryAPIValidationTest : public ValidationTest {
|
||||||
togglesDesc.forceEnabledToggles = &toggle;
|
togglesDesc.forceEnabledToggles = &toggle;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
togglesDesc.forceEnabledTogglesCount = 1;
|
||||||
|
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ bool gUseWire = false;
|
||||||
// NOLINTNEXTLINE(runtime/string)
|
// NOLINTNEXTLINE(runtime/string)
|
||||||
std::string gWireTraceDir = "";
|
std::string gWireTraceDir = "";
|
||||||
std::unique_ptr<ToggleParser> gToggleParser = nullptr;
|
std::unique_ptr<ToggleParser> gToggleParser = nullptr;
|
||||||
|
static ValidationTest* gCurrentTest = nullptr;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -79,48 +80,86 @@ void InitDawnValidationTestEnvironment(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidationTest::ValidationTest()
|
ValidationTest::ValidationTest() {
|
||||||
: mWireHelper(utils::CreateWireHelper(gUseWire, gWireTraceDir.c_str())) {}
|
gCurrentTest = this;
|
||||||
|
|
||||||
|
DawnProcTable procs = dawn::native::GetProcs();
|
||||||
|
// Override procs to provide harness-specific behavior to always select the null adapter,
|
||||||
|
// and to allow fixture-specific overriding of the test device with CreateTestDevice.
|
||||||
|
procs.instanceRequestAdapter = [](WGPUInstance instance, const WGPURequestAdapterOptions*,
|
||||||
|
WGPURequestAdapterCallback callback, void* userdata) {
|
||||||
|
ASSERT(gCurrentTest);
|
||||||
|
std::vector<dawn::native::Adapter> adapters = gCurrentTest->mDawnInstance->GetAdapters();
|
||||||
|
// Validation tests run against the null backend, find the corresponding adapter
|
||||||
|
for (auto& adapter : adapters) {
|
||||||
|
wgpu::AdapterProperties adapterProperties;
|
||||||
|
adapter.GetProperties(&adapterProperties);
|
||||||
|
|
||||||
|
if (adapterProperties.backendType == wgpu::BackendType::Null) {
|
||||||
|
gCurrentTest->mBackendAdapter = adapter;
|
||||||
|
WGPUAdapter cAdapter = adapter.Get();
|
||||||
|
ASSERT(cAdapter);
|
||||||
|
dawn::native::GetProcs().adapterReference(cAdapter);
|
||||||
|
callback(WGPURequestAdapterStatus_Success, cAdapter, nullptr, userdata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UNREACHABLE();
|
||||||
|
};
|
||||||
|
|
||||||
|
procs.adapterRequestDevice = [](WGPUAdapter adapter, const WGPUDeviceDescriptor*,
|
||||||
|
WGPURequestDeviceCallback callback, void* userdata) {
|
||||||
|
ASSERT(gCurrentTest);
|
||||||
|
WGPUDevice cDevice = gCurrentTest->CreateTestDevice(
|
||||||
|
dawn::native::Adapter(reinterpret_cast<dawn::native::AdapterBase*>(adapter)));
|
||||||
|
ASSERT(cDevice != nullptr);
|
||||||
|
gCurrentTest->mLastCreatedBackendDevice = cDevice;
|
||||||
|
callback(WGPURequestDeviceStatus_Success, cDevice, nullptr, userdata);
|
||||||
|
};
|
||||||
|
|
||||||
|
mWireHelper = utils::CreateWireHelper(procs, gUseWire, gWireTraceDir.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void ValidationTest::SetUp() {
|
void ValidationTest::SetUp() {
|
||||||
instance = std::make_unique<dawn::native::Instance>();
|
mDawnInstance = std::make_unique<dawn::native::Instance>();
|
||||||
instance->DiscoverDefaultAdapters();
|
mDawnInstance->DiscoverDefaultAdapters();
|
||||||
|
mInstance = mWireHelper->RegisterInstance(mDawnInstance->Get());
|
||||||
std::vector<dawn::native::Adapter> adapters = instance->GetAdapters();
|
|
||||||
|
|
||||||
// Validation tests run against the null backend, find the corresponding adapter
|
|
||||||
bool foundNullAdapter = false;
|
|
||||||
for (auto& currentAdapter : adapters) {
|
|
||||||
wgpu::AdapterProperties adapterProperties;
|
|
||||||
currentAdapter.GetProperties(&adapterProperties);
|
|
||||||
|
|
||||||
if (adapterProperties.backendType == wgpu::BackendType::Null) {
|
|
||||||
adapter = currentAdapter;
|
|
||||||
foundNullAdapter = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(foundNullAdapter);
|
|
||||||
|
|
||||||
std::tie(device, backendDevice) = mWireHelper->RegisterDevice(CreateTestDevice());
|
|
||||||
device.SetUncapturedErrorCallback(ValidationTest::OnDeviceError, this);
|
|
||||||
device.SetDeviceLostCallback(ValidationTest::OnDeviceLost, this);
|
|
||||||
|
|
||||||
std::string traceName =
|
std::string traceName =
|
||||||
std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) +
|
std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) +
|
||||||
"_" + ::testing::UnitTest::GetInstance()->current_test_info()->name();
|
"_" + ::testing::UnitTest::GetInstance()->current_test_info()->name();
|
||||||
mWireHelper->BeginWireTrace(traceName.c_str());
|
mWireHelper->BeginWireTrace(traceName.c_str());
|
||||||
|
|
||||||
|
// These options are unused since validation tests always select the null adapter
|
||||||
|
wgpu::RequestAdapterOptions options = {};
|
||||||
|
mInstance.RequestAdapter(
|
||||||
|
&options,
|
||||||
|
[](WGPURequestAdapterStatus, WGPUAdapter cAdapter, const char*, void* userdata) {
|
||||||
|
*static_cast<wgpu::Adapter*>(userdata) = wgpu::Adapter::Acquire(cAdapter);
|
||||||
|
},
|
||||||
|
&adapter);
|
||||||
|
FlushWire();
|
||||||
|
ASSERT(adapter);
|
||||||
|
|
||||||
|
device = RequestDeviceSync(wgpu::DeviceDescriptor{});
|
||||||
|
backendDevice = mLastCreatedBackendDevice;
|
||||||
|
|
||||||
|
device.SetUncapturedErrorCallback(ValidationTest::OnDeviceError, this);
|
||||||
|
device.SetDeviceLostCallback(ValidationTest::OnDeviceLost, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidationTest::~ValidationTest() {
|
ValidationTest::~ValidationTest() {
|
||||||
// We need to destroy Dawn objects before setting the procs to null otherwise the dawn*Release
|
// We need to destroy Dawn objects before the wire helper which sets procs to null otherwise the
|
||||||
// will call a nullptr
|
// dawn*Release will call a nullptr
|
||||||
device = wgpu::Device();
|
device = nullptr;
|
||||||
|
adapter = nullptr;
|
||||||
|
mInstance = nullptr;
|
||||||
mWireHelper.reset();
|
mWireHelper.reset();
|
||||||
|
|
||||||
// Check that all devices were destructed.
|
// Check that all devices were destructed.
|
||||||
EXPECT_EQ(instance->GetDeviceCountForTesting(), 0u);
|
EXPECT_EQ(mDawnInstance->GetDeviceCountForTesting(), 0u);
|
||||||
|
|
||||||
|
gCurrentTest = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValidationTest::TearDown() {
|
void ValidationTest::TearDown() {
|
||||||
|
@ -159,10 +198,6 @@ void ValidationTest::ExpectDeviceDestruction() {
|
||||||
mExpectDestruction = true;
|
mExpectDestruction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::Device ValidationTest::RegisterDevice(WGPUDevice backendDevice) {
|
|
||||||
return mWireHelper->RegisterDevice(backendDevice).first;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValidationTest::UsesWire() const {
|
bool ValidationTest::UsesWire() const {
|
||||||
return gUseWire;
|
return gUseWire;
|
||||||
}
|
}
|
||||||
|
@ -190,6 +225,10 @@ void ValidationTest::WaitForAllOperations(const wgpu::Device& device) {
|
||||||
FlushWire();
|
FlushWire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dawn::native::ToggleInfo* ValidationTest::GetToggleInfo(const char* name) const {
|
||||||
|
return mDawnInstance->GetToggleInfo(name);
|
||||||
|
}
|
||||||
|
|
||||||
bool ValidationTest::HasToggleEnabled(const char* toggle) const {
|
bool ValidationTest::HasToggleEnabled(const char* toggle) const {
|
||||||
auto toggles = dawn::native::GetTogglesUsed(backendDevice);
|
auto toggles = dawn::native::GetTogglesUsed(backendDevice);
|
||||||
return std::find_if(toggles.begin(), toggles.end(), [toggle](const char* name) {
|
return std::find_if(toggles.begin(), toggles.end(), [toggle](const char* name) {
|
||||||
|
@ -197,14 +236,33 @@ bool ValidationTest::HasToggleEnabled(const char* toggle) const {
|
||||||
}) != toggles.end();
|
}) != toggles.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::SupportedLimits ValidationTest::GetSupportedLimits() {
|
wgpu::SupportedLimits ValidationTest::GetSupportedLimits() const {
|
||||||
WGPUSupportedLimits supportedLimits;
|
wgpu::SupportedLimits supportedLimits = {};
|
||||||
supportedLimits.nextInChain = nullptr;
|
device.GetLimits(&supportedLimits);
|
||||||
dawn::native::GetProcs().deviceGetLimits(backendDevice, &supportedLimits);
|
return supportedLimits;
|
||||||
return *reinterpret_cast<wgpu::SupportedLimits*>(&supportedLimits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WGPUDevice ValidationTest::CreateTestDevice() {
|
wgpu::Device ValidationTest::RequestDeviceSync(const wgpu::DeviceDescriptor& deviceDesc) {
|
||||||
|
ASSERT(adapter);
|
||||||
|
|
||||||
|
wgpu::Device apiDevice;
|
||||||
|
adapter.RequestDevice(
|
||||||
|
&deviceDesc,
|
||||||
|
[](WGPURequestDeviceStatus, WGPUDevice cDevice, const char*, void* userdata) {
|
||||||
|
*static_cast<wgpu::Device*>(userdata) = wgpu::Device::Acquire(cDevice);
|
||||||
|
},
|
||||||
|
&apiDevice);
|
||||||
|
FlushWire();
|
||||||
|
|
||||||
|
ASSERT(apiDevice);
|
||||||
|
return apiDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
dawn::native::Adapter& ValidationTest::GetBackendAdapter() {
|
||||||
|
return mBackendAdapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
WGPUDevice ValidationTest::CreateTestDevice(dawn::native::Adapter dawnAdapter) {
|
||||||
// Disabled disallowing unsafe APIs so we can test them.
|
// Disabled disallowing unsafe APIs so we can test them.
|
||||||
std::vector<const char*> forceEnabledToggles;
|
std::vector<const char*> forceEnabledToggles;
|
||||||
std::vector<const char*> forceDisabledToggles = {"disallow_unsafe_apis"};
|
std::vector<const char*> forceDisabledToggles = {"disallow_unsafe_apis"};
|
||||||
|
@ -226,7 +284,7 @@ WGPUDevice ValidationTest::CreateTestDevice() {
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
|
togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
|
||||||
togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
|
togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
|
||||||
|
|
||||||
return adapter.CreateDevice(&deviceDescriptor);
|
return dawnAdapter.CreateDevice(&deviceDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -108,8 +108,6 @@ class ValidationTest : public testing::Test {
|
||||||
|
|
||||||
void ExpectDeviceDestruction();
|
void ExpectDeviceDestruction();
|
||||||
|
|
||||||
wgpu::Device RegisterDevice(WGPUDevice backendDevice);
|
|
||||||
|
|
||||||
bool UsesWire() const;
|
bool UsesWire() const;
|
||||||
|
|
||||||
void FlushWire();
|
void FlushWire();
|
||||||
|
@ -129,25 +127,28 @@ class ValidationTest : public testing::Test {
|
||||||
wgpu::RenderPassColorAttachment mColorAttachment;
|
wgpu::RenderPassColorAttachment mColorAttachment;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const dawn::native::ToggleInfo* GetToggleInfo(const char* name) const;
|
||||||
bool HasToggleEnabled(const char* toggle) const;
|
bool HasToggleEnabled(const char* toggle) const;
|
||||||
|
wgpu::SupportedLimits GetSupportedLimits() const;
|
||||||
// TODO(crbug.com/dawn/689): Use limits returned from the wire
|
|
||||||
// This is implemented here because tests need to always query
|
|
||||||
// the |backendDevice| since limits are not implemented in the wire.
|
|
||||||
wgpu::SupportedLimits GetSupportedLimits();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual WGPUDevice CreateTestDevice();
|
dawn::native::Adapter& GetBackendAdapter();
|
||||||
|
virtual WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter);
|
||||||
|
|
||||||
|
wgpu::Device RequestDeviceSync(const wgpu::DeviceDescriptor& deviceDesc);
|
||||||
|
|
||||||
std::unique_ptr<dawn::native::Instance> instance;
|
|
||||||
dawn::native::Adapter adapter;
|
|
||||||
wgpu::Device device;
|
wgpu::Device device;
|
||||||
|
wgpu::Adapter adapter;
|
||||||
WGPUDevice backendDevice;
|
WGPUDevice backendDevice;
|
||||||
|
|
||||||
size_t mLastWarningCount = 0;
|
size_t mLastWarningCount = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::unique_ptr<dawn::native::Instance> mDawnInstance;
|
||||||
|
wgpu::Instance mInstance;
|
||||||
|
dawn::native::Adapter mBackendAdapter;
|
||||||
std::unique_ptr<utils::WireHelper> mWireHelper;
|
std::unique_ptr<utils::WireHelper> mWireHelper;
|
||||||
|
WGPUDevice mLastCreatedBackendDevice;
|
||||||
|
|
||||||
static void OnDeviceError(WGPUErrorType type, const char* message, void* userdata);
|
static void OnDeviceError(WGPUErrorType type, const char* message, void* userdata);
|
||||||
static void OnDeviceLost(WGPUDeviceLostReason reason, const char* message, void* userdata);
|
static void OnDeviceLost(WGPUDeviceLostReason reason, const char* message, void* userdata);
|
||||||
|
|
|
@ -21,12 +21,12 @@ namespace {
|
||||||
|
|
||||||
class VideoViewsValidation : public ValidationTest {
|
class VideoViewsValidation : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnMultiPlanarFormats};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::DawnMultiPlanarFormats};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 1;
|
descriptor.requiredFeaturesCount = 1;
|
||||||
return adapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::Texture CreateVideoTextureForTest(wgpu::TextureFormat format, wgpu::TextureUsage usage) {
|
wgpu::Texture CreateVideoTextureForTest(wgpu::TextureFormat format, wgpu::TextureUsage usage) {
|
||||||
|
|
|
@ -78,11 +78,11 @@ class WireServerTraceLayer : public dawn::wire::CommandHandler {
|
||||||
|
|
||||||
class WireHelperDirect : public WireHelper {
|
class WireHelperDirect : public WireHelper {
|
||||||
public:
|
public:
|
||||||
WireHelperDirect() { dawnProcSetProcs(&dawn::native::GetProcs()); }
|
explicit WireHelperDirect(const DawnProcTable& procs) { dawnProcSetProcs(&procs); }
|
||||||
|
|
||||||
std::pair<wgpu::Device, WGPUDevice> RegisterDevice(WGPUDevice backendDevice) override {
|
wgpu::Instance RegisterInstance(WGPUInstance backendInstance) override {
|
||||||
ASSERT(backendDevice != nullptr);
|
ASSERT(backendInstance != nullptr);
|
||||||
return std::make_pair(wgpu::Device::Acquire(backendDevice), backendDevice);
|
return wgpu::Instance(backendInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeginWireTrace(const char* name) override {}
|
void BeginWireTrace(const char* name) override {}
|
||||||
|
@ -94,12 +94,12 @@ class WireHelperDirect : public WireHelper {
|
||||||
|
|
||||||
class WireHelperProxy : public WireHelper {
|
class WireHelperProxy : public WireHelper {
|
||||||
public:
|
public:
|
||||||
explicit WireHelperProxy(const char* wireTraceDir) {
|
explicit WireHelperProxy(const char* wireTraceDir, const DawnProcTable& procs) {
|
||||||
mC2sBuf = std::make_unique<utils::TerribleCommandBuffer>();
|
mC2sBuf = std::make_unique<utils::TerribleCommandBuffer>();
|
||||||
mS2cBuf = std::make_unique<utils::TerribleCommandBuffer>();
|
mS2cBuf = std::make_unique<utils::TerribleCommandBuffer>();
|
||||||
|
|
||||||
dawn::wire::WireServerDescriptor serverDesc = {};
|
dawn::wire::WireServerDescriptor serverDesc = {};
|
||||||
serverDesc.procs = &dawn::native::GetProcs();
|
serverDesc.procs = &procs;
|
||||||
serverDesc.serializer = mS2cBuf.get();
|
serverDesc.serializer = mS2cBuf.get();
|
||||||
|
|
||||||
mWireServer.reset(new dawn::wire::WireServer(serverDesc));
|
mWireServer.reset(new dawn::wire::WireServer(serverDesc));
|
||||||
|
@ -118,14 +118,13 @@ class WireHelperProxy : public WireHelper {
|
||||||
dawnProcSetProcs(&dawn::wire::client::GetProcs());
|
dawnProcSetProcs(&dawn::wire::client::GetProcs());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<wgpu::Device, WGPUDevice> RegisterDevice(WGPUDevice backendDevice) override {
|
wgpu::Instance RegisterInstance(WGPUInstance backendInstance) override {
|
||||||
ASSERT(backendDevice != nullptr);
|
ASSERT(backendInstance != nullptr);
|
||||||
|
|
||||||
auto reservation = mWireClient->ReserveDevice();
|
auto reservation = mWireClient->ReserveInstance();
|
||||||
mWireServer->InjectDevice(backendDevice, reservation.id, reservation.generation);
|
mWireServer->InjectInstance(backendInstance, reservation.id, reservation.generation);
|
||||||
dawn::native::GetProcs().deviceRelease(backendDevice);
|
|
||||||
|
|
||||||
return std::make_pair(wgpu::Device::Acquire(reservation.device), backendDevice);
|
return wgpu::Instance::Acquire(reservation.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeginWireTrace(const char* name) override {
|
void BeginWireTrace(const char* name) override {
|
||||||
|
@ -148,11 +147,13 @@ class WireHelperProxy : public WireHelper {
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
std::unique_ptr<WireHelper> CreateWireHelper(bool useWire, const char* wireTraceDir) {
|
std::unique_ptr<WireHelper> CreateWireHelper(const DawnProcTable& procs,
|
||||||
|
bool useWire,
|
||||||
|
const char* wireTraceDir) {
|
||||||
if (useWire) {
|
if (useWire) {
|
||||||
return std::unique_ptr<WireHelper>(new WireHelperProxy(wireTraceDir));
|
return std::unique_ptr<WireHelper>(new WireHelperProxy(wireTraceDir, procs));
|
||||||
} else {
|
} else {
|
||||||
return std::unique_ptr<WireHelper>(new WireHelperDirect());
|
return std::unique_ptr<WireHelper>(new WireHelperDirect(procs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,11 @@ class WireHelper {
|
||||||
public:
|
public:
|
||||||
virtual ~WireHelper();
|
virtual ~WireHelper();
|
||||||
|
|
||||||
// Registers the device on the wire, if present.
|
// Registers the instance on the wire, if present.
|
||||||
// Returns a pair of the client device and backend device.
|
// Returns the wgpu::Instance which is the client instance on the wire, and
|
||||||
// The function should take ownership of |backendDevice|.
|
// the backend instance without the wire.
|
||||||
virtual std::pair<wgpu::Device, WGPUDevice> RegisterDevice(WGPUDevice backendDevice) = 0;
|
// The function should not take ownership of |backendInstance|.
|
||||||
|
virtual wgpu::Instance RegisterInstance(WGPUInstance backendInstance) = 0;
|
||||||
|
|
||||||
virtual void BeginWireTrace(const char* name) = 0;
|
virtual void BeginWireTrace(const char* name) = 0;
|
||||||
|
|
||||||
|
@ -38,7 +39,9 @@ class WireHelper {
|
||||||
virtual bool FlushServer() = 0;
|
virtual bool FlushServer() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<WireHelper> CreateWireHelper(bool useWire, const char* wireTraceDir = nullptr);
|
std::unique_ptr<WireHelper> CreateWireHelper(const DawnProcTable& procs,
|
||||||
|
bool useWire,
|
||||||
|
const char* wireTraceDir = nullptr);
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue