Prioritize discrete GPU in end2end tests

- Prefer discrete GPU on multi-GPU systems, otherwise get
integrated GPU.
- Add a test to check adapter filter.

BUG=dawn:184

Change-Id: Ib1c3e81e20a15aeaf18746892324ce5144b7fda1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9320
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Li, Hao 2019-10-16 09:24:55 +00:00 committed by Commit Bot service account
parent fd90d767ba
commit c7d535bd72
3 changed files with 24 additions and 10 deletions

View File

@ -378,22 +378,23 @@ void DawnTestBase::SetUp() {
for (const dawn_native::Adapter& adapter : adapters) { for (const dawn_native::Adapter& adapter : adapters) {
if (adapter.GetBackendType() == backendType) { if (adapter.GetBackendType() == backendType) {
if (adapter.GetDeviceType() == dawn_native::DeviceType::CPU) {
continue;
}
// Filter adapter by vendor id
if (HasVendorIdFilter()) { if (HasVendorIdFilter()) {
if (adapter.GetPCIInfo().vendorId == GetVendorIdFilter()) { if (adapter.GetPCIInfo().vendorId == GetVendorIdFilter()) {
mBackendAdapter = adapter; mBackendAdapter = adapter;
break; break;
} }
} else { continue;
mBackendAdapter = adapter;
// On Metal, select the last adapter so that the discrete GPU is tested on
// multi-GPU systems.
// TODO(cwallez@chromium.org): Replace this with command line arguments
// requesting a specific device / vendor ID once the macOS 10.13 SDK is rolled
// and correct PCI info collection is implemented on Metal.
if (backendType != dawn_native::BackendType::Metal) {
break;
} }
// Prefer discrete GPU on multi-GPU systems, otherwise get integrated GPU.
mBackendAdapter = adapter;
if (mBackendAdapter.GetDeviceType() == dawn_native::DeviceType::DiscreteGPU) {
break;
} }
} }
} }
@ -484,6 +485,10 @@ bool DawnTestBase::EndExpectDeviceError() {
return mError; return mError;
} }
dawn_native::PCIInfo DawnTestBase::GetPCIInfo() const {
return mPCIInfo;
}
// static // static
void DawnTestBase::OnDeviceError(DawnErrorType type, const char* message, void* userdata) { void DawnTestBase::OnDeviceError(DawnErrorType type, const char* message, void* userdata) {
ASSERT(type != DAWN_ERROR_TYPE_NO_ERROR); ASSERT(type != DAWN_ERROR_TYPE_NO_ERROR);

View File

@ -175,6 +175,8 @@ class DawnTestBase {
bool HasVendorIdFilter() const; bool HasVendorIdFilter() const;
uint32_t GetVendorIdFilter() const; uint32_t GetVendorIdFilter() const;
dawn_native::PCIInfo GetPCIInfo() const;
protected: protected:
dawn::Device device; dawn::Device device;
dawn::Queue queue; dawn::Queue queue;

View File

@ -19,6 +19,13 @@
class BasicTests : public DawnTest { class BasicTests : public DawnTest {
}; };
// Test adapter filter by vendor id.
TEST_P(BasicTests, VendorIdFilter) {
DAWN_SKIP_TEST_IF(!HasVendorIdFilter());
ASSERT_EQ(GetPCIInfo().vendorId, GetVendorIdFilter());
}
// Test Buffer::SetSubData changes the content of the buffer, but really this is the most // Test Buffer::SetSubData 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, BufferSetSubData) { TEST_P(BasicTests, BufferSetSubData) {