DawnTest: only choose one adapter from those with same name and backendType

When running Dawn end2end tests on latest Windows 10 (20H2) in a Remote
Desktop session there can be multiple adapters with same name and type,
which will cause the crash of Dawn end2end tests as the GTest framework
doesn't allow two cases having the same name.

This patch fixes this issue by only choosing one adapter from the ones
with same name and backendType in DawnTests.

BUG=dawn:396
TEST=dawn_end2end_tests

Change-Id: I42de7fc1f3e9f8919af251c047cd873ba84d7190
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31583
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Jiawei Shao 2020-11-05 08:38:46 +00:00 committed by Commit Bot service account
parent 6564890116
commit e87a8c466f
1 changed files with 10 additions and 1 deletions

View File

@ -352,6 +352,7 @@ void DawnTestEnvironment::SelectPreferredAdapterProperties(const dawn_native::In
} }
} }
std::set<std::pair<wgpu::BackendType, std::string>> adapterNameSet;
for (const dawn_native::Adapter& adapter : instance->GetAdapters()) { for (const dawn_native::Adapter& adapter : instance->GetAdapters()) {
wgpu::AdapterProperties properties; wgpu::AdapterProperties properties;
adapter.GetProperties(&properties); adapter.GetProperties(&properties);
@ -386,8 +387,16 @@ void DawnTestEnvironment::SelectPreferredAdapterProperties(const dawn_native::In
selected = true; selected = true;
} }
// In Windows Remote Desktop sessions we may be able to discover multiple adapters that
// have the same name and backend type. We will just choose one adapter from them in our
// tests.
const auto adapterTypeAndName =
std::make_pair(properties.backendType, std::string(properties.name));
if (adapterNameSet.find(adapterTypeAndName) == adapterNameSet.end()) {
adapterNameSet.insert(adapterTypeAndName);
mAdapterProperties.emplace_back(properties, selected); mAdapterProperties.emplace_back(properties, selected);
} }
}
} }
std::vector<AdapterTestParam> DawnTestEnvironment::GetAvailableAdapterTestParamsForBackends( std::vector<AdapterTestParam> DawnTestEnvironment::GetAvailableAdapterTestParamsForBackends(