Implement a --backend= flag for DawnTest.
This version renames HasBackendType() -> HasBackendTypeFilter() and adds a test, similar to HasVendorIdFilter(). Bug: dawn:687 Change-Id: I444d3cb668eb7402ba45f14aaec290390f4c3944 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41900 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
2ad837b2d2
commit
eb71aaf689
|
@ -329,11 +329,37 @@ void DawnTestEnvironment::ParseArgs(int argc, char** argv) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr const char kBackendArg[] = "--backend=";
|
||||||
|
argLen = sizeof(kBackendArg) - 1;
|
||||||
|
if (strncmp(argv[i], kBackendArg, argLen) == 0) {
|
||||||
|
const char* param = argv[i] + argLen;
|
||||||
|
if (strcmp("d3d12", param) == 0) {
|
||||||
|
mBackendTypeFilter = wgpu::BackendType::D3D12;
|
||||||
|
} else if (strcmp("metal", param) == 0) {
|
||||||
|
mBackendTypeFilter = wgpu::BackendType::Metal;
|
||||||
|
} else if (strcmp("null", param) == 0) {
|
||||||
|
mBackendTypeFilter = wgpu::BackendType::Null;
|
||||||
|
} else if (strcmp("opengl", param) == 0) {
|
||||||
|
mBackendTypeFilter = wgpu::BackendType::OpenGL;
|
||||||
|
} else if (strcmp("opengles", param) == 0) {
|
||||||
|
mBackendTypeFilter = wgpu::BackendType::OpenGLES;
|
||||||
|
} else if (strcmp("vulkan", param) == 0) {
|
||||||
|
mBackendTypeFilter = wgpu::BackendType::Vulkan;
|
||||||
|
} else {
|
||||||
|
dawn::ErrorLog()
|
||||||
|
<< "Invalid backend \"" << param
|
||||||
|
<< "\". Valid backends are: d3d12, metal, null, opengl, opengles, vulkan.";
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
mHasBackendTypeFilter = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
|
if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
|
||||||
dawn::InfoLog()
|
dawn::InfoLog()
|
||||||
<< "\n\nUsage: " << argv[0]
|
<< "\n\nUsage: " << argv[0]
|
||||||
<< " [GTEST_FLAGS...] [-w] [-c]\n"
|
<< " [GTEST_FLAGS...] [-w] [-c]\n"
|
||||||
" [--enable-toggles=toggles] [--disable-toggles=toggles]\n"
|
" [--enable-toggles=toggles] [--disable-toggles=toggles]\n"
|
||||||
|
" [--backend=x]\n"
|
||||||
" [--adapter-vendor-id=x] "
|
" [--adapter-vendor-id=x] "
|
||||||
"[--enable-backend-validation[=full,partial,disabled]]\n"
|
"[--enable-backend-validation[=full,partial,disabled]]\n"
|
||||||
" [--exclusive-device-type-preference=integrated,cpu,discrete]\n\n"
|
" [--exclusive-device-type-preference=integrated,cpu,discrete]\n\n"
|
||||||
|
@ -349,6 +375,8 @@ void DawnTestEnvironment::ParseArgs(int argc, char** argv) {
|
||||||
" --disable-toggles: Comma-delimited list of Dawn toggles to disable\n"
|
" --disable-toggles: Comma-delimited list of Dawn toggles to disable\n"
|
||||||
" --adapter-vendor-id: Select adapter by vendor id to run end2end tests"
|
" --adapter-vendor-id: Select adapter by vendor id to run end2end tests"
|
||||||
"on multi-GPU systems \n"
|
"on multi-GPU systems \n"
|
||||||
|
" --backend: Select adapter by backend type. Valid backends are: d3d12, metal, "
|
||||||
|
"null, opengl, opengles, vulkan\n"
|
||||||
" --exclusive-device-type-preference: Comma-delimited list of preferred device "
|
" --exclusive-device-type-preference: Comma-delimited list of preferred device "
|
||||||
"types. For each backend, tests will run only on adapters that match the first "
|
"types. For each backend, tests will run only on adapters that match the first "
|
||||||
"available device type\n";
|
"available device type\n";
|
||||||
|
@ -437,20 +465,26 @@ void DawnTestEnvironment::SelectPreferredAdapterProperties(const dawn_native::In
|
||||||
wgpu::AdapterProperties properties;
|
wgpu::AdapterProperties properties;
|
||||||
adapter.GetProperties(&properties);
|
adapter.GetProperties(&properties);
|
||||||
|
|
||||||
// The adapter is selected if:
|
// All adapters are selected by default.
|
||||||
bool selected = false;
|
bool selected = true;
|
||||||
|
// The adapter is deselected if:
|
||||||
|
if (mHasBackendTypeFilter) {
|
||||||
|
// It doesn't match the backend type, if present.
|
||||||
|
selected &= properties.backendType == mBackendTypeFilter;
|
||||||
|
}
|
||||||
if (mHasVendorIdFilter) {
|
if (mHasVendorIdFilter) {
|
||||||
// It matches the vendor id, if present.
|
// It doesn't match the vendor id, if present.
|
||||||
selected = mVendorIdFilter == properties.vendorID;
|
selected &= mVendorIdFilter == properties.vendorID;
|
||||||
|
|
||||||
if (!mDevicePreferences.empty()) {
|
if (!mDevicePreferences.empty()) {
|
||||||
dawn::WarningLog() << "Vendor ID filter provided. Ignoring device type preference.";
|
dawn::WarningLog() << "Vendor ID filter provided. Ignoring device type preference.";
|
||||||
}
|
}
|
||||||
} else if (hasDevicePreference) {
|
}
|
||||||
|
if (hasDevicePreference) {
|
||||||
// There is a device preference and:
|
// There is a device preference and:
|
||||||
selected =
|
selected &=
|
||||||
// The device type matches the first available preferred type for that backend, if
|
// The device type doesn't match the first available preferred type for that
|
||||||
// present.
|
// backend, if present.
|
||||||
(adapter.GetDeviceType() == preferredDeviceType) ||
|
(adapter.GetDeviceType() == preferredDeviceType) ||
|
||||||
// Always select Unknown OpenGL adapters if we don't want a CPU adapter.
|
// Always select Unknown OpenGL adapters if we don't want a CPU adapter.
|
||||||
// OpenGL will usually be unknown because we can't query the device type.
|
// OpenGL will usually be unknown because we can't query the device type.
|
||||||
|
@ -463,9 +497,6 @@ void DawnTestEnvironment::SelectPreferredAdapterProperties(const dawn_native::In
|
||||||
// quickly. This is temporary as to not lose coverage. We can group it with
|
// quickly. This is temporary as to not lose coverage. We can group it with
|
||||||
// Swiftshader as a CPU adapter when we have Swiftshader tests.
|
// Swiftshader as a CPU adapter when we have Swiftshader tests.
|
||||||
(properties.backendType == wgpu::BackendType::Null);
|
(properties.backendType == wgpu::BackendType::Null);
|
||||||
} else {
|
|
||||||
// No vendor id or device preference was provided (select all).
|
|
||||||
selected = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In Windows Remote Desktop sessions we may be able to discover multiple adapters that
|
// In Windows Remote Desktop sessions we may be able to discover multiple adapters that
|
||||||
|
@ -610,6 +641,14 @@ uint32_t DawnTestEnvironment::GetVendorIdFilter() const {
|
||||||
return mVendorIdFilter;
|
return mVendorIdFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DawnTestEnvironment::HasBackendTypeFilter() const {
|
||||||
|
return mHasBackendTypeFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
wgpu::BackendType DawnTestEnvironment::GetBackendTypeFilter() const {
|
||||||
|
return mBackendTypeFilter;
|
||||||
|
}
|
||||||
|
|
||||||
const char* DawnTestEnvironment::GetWireTraceDir() const {
|
const char* DawnTestEnvironment::GetWireTraceDir() const {
|
||||||
if (mWireTraceDir.length() == 0) {
|
if (mWireTraceDir.length() == 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -765,6 +804,14 @@ uint32_t DawnTestBase::GetVendorIdFilter() const {
|
||||||
return gTestEnv->GetVendorIdFilter();
|
return gTestEnv->GetVendorIdFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DawnTestBase::HasBackendTypeFilter() const {
|
||||||
|
return gTestEnv->HasBackendTypeFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
wgpu::BackendType DawnTestBase::GetBackendTypeFilter() const {
|
||||||
|
return gTestEnv->GetBackendTypeFilter();
|
||||||
|
}
|
||||||
|
|
||||||
wgpu::Instance DawnTestBase::GetInstance() const {
|
wgpu::Instance DawnTestBase::GetInstance() const {
|
||||||
return gTestEnv->GetInstance()->Get();
|
return gTestEnv->GetInstance()->Get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,8 @@ class DawnTestEnvironment : public testing::Environment {
|
||||||
dawn_native::Instance* GetInstance() const;
|
dawn_native::Instance* GetInstance() const;
|
||||||
bool HasVendorIdFilter() const;
|
bool HasVendorIdFilter() const;
|
||||||
uint32_t GetVendorIdFilter() const;
|
uint32_t GetVendorIdFilter() const;
|
||||||
|
bool HasBackendTypeFilter() const;
|
||||||
|
wgpu::BackendType GetBackendTypeFilter() const;
|
||||||
const char* GetWireTraceDir() const;
|
const char* GetWireTraceDir() const;
|
||||||
GLFWwindow* GetOpenGLWindow() const;
|
GLFWwindow* GetOpenGLWindow() const;
|
||||||
GLFWwindow* GetOpenGLESWindow() const;
|
GLFWwindow* GetOpenGLESWindow() const;
|
||||||
|
@ -232,6 +234,8 @@ class DawnTestEnvironment : public testing::Environment {
|
||||||
bool mBeginCaptureOnStartup = false;
|
bool mBeginCaptureOnStartup = false;
|
||||||
bool mHasVendorIdFilter = false;
|
bool mHasVendorIdFilter = false;
|
||||||
uint32_t mVendorIdFilter = 0;
|
uint32_t mVendorIdFilter = 0;
|
||||||
|
bool mHasBackendTypeFilter = false;
|
||||||
|
wgpu::BackendType mBackendTypeFilter;
|
||||||
std::string mWireTraceDir;
|
std::string mWireTraceDir;
|
||||||
|
|
||||||
std::vector<std::string> mEnabledToggles;
|
std::vector<std::string> mEnabledToggles;
|
||||||
|
@ -289,6 +293,9 @@ class DawnTestBase {
|
||||||
bool HasVendorIdFilter() const;
|
bool HasVendorIdFilter() const;
|
||||||
uint32_t GetVendorIdFilter() const;
|
uint32_t GetVendorIdFilter() const;
|
||||||
|
|
||||||
|
bool HasBackendTypeFilter() const;
|
||||||
|
wgpu::BackendType GetBackendTypeFilter() const;
|
||||||
|
|
||||||
wgpu::Instance GetInstance() const;
|
wgpu::Instance GetInstance() const;
|
||||||
dawn_native::Adapter GetAdapter() const;
|
dawn_native::Adapter GetAdapter() const;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,13 @@ TEST_P(BasicTests, VendorIdFilter) {
|
||||||
ASSERT_EQ(GetAdapterProperties().vendorID, GetVendorIdFilter());
|
ASSERT_EQ(GetAdapterProperties().vendorID, GetVendorIdFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test adapter filter by backend type.
|
||||||
|
TEST_P(BasicTests, BackendType) {
|
||||||
|
DAWN_SKIP_TEST_IF(!HasBackendTypeFilter());
|
||||||
|
|
||||||
|
ASSERT_EQ(GetAdapterProperties().backendType, GetBackendTypeFilter());
|
||||||
|
}
|
||||||
|
|
||||||
// Test Queue::WriteBuffer changes the content of the buffer, but really this is the most
|
// Test Queue::WriteBuffer changes the content of the buffer, but really this is the most
|
||||||
// basic test possible, and tests the test harness
|
// basic test possible, and tests the test harness
|
||||||
TEST_P(BasicTests, QueueWriteBuffer) {
|
TEST_P(BasicTests, QueueWriteBuffer) {
|
||||||
|
|
Loading…
Reference in New Issue