dawn_node: Error if the specified backend is not found
Defaulting to the 0'th adapter can silently use the Null adapter, which is no fun for anyone. Bug tint:1354 Change-Id: I14e2379175cb90a48753bd81d096391d15d2dc22 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75070 Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
85b7e50c52
commit
76ff65f694
|
@ -112,6 +112,9 @@ namespace wgpu { namespace binding {
|
||||||
std::transform(forceBackend.begin(), forceBackend.end(), forceBackend.begin(),
|
std::transform(forceBackend.begin(), forceBackend.end(), forceBackend.begin(),
|
||||||
[](char c) { return std::tolower(c); });
|
[](char c) { return std::tolower(c); });
|
||||||
|
|
||||||
|
// Default to first adapter if a backend is not specified
|
||||||
|
size_t adapterIndex = 0;
|
||||||
|
|
||||||
if (!forceBackend.empty()) {
|
if (!forceBackend.empty()) {
|
||||||
if (forceBackend == "null") {
|
if (forceBackend == "null") {
|
||||||
targetBackendType = wgpu::BackendType::Null;
|
targetBackendType = wgpu::BackendType::Null;
|
||||||
|
@ -129,17 +132,24 @@ namespace wgpu { namespace binding {
|
||||||
targetBackendType = wgpu::BackendType::OpenGL;
|
targetBackendType = wgpu::BackendType::OpenGL;
|
||||||
} else if (forceBackend == "opengles" || forceBackend == "gles") {
|
} else if (forceBackend == "opengles" || forceBackend == "gles") {
|
||||||
targetBackendType = wgpu::BackendType::OpenGLES;
|
targetBackendType = wgpu::BackendType::OpenGLES;
|
||||||
|
} else {
|
||||||
|
promise.Reject("unknown backend '" + forceBackend + "'");
|
||||||
|
return promise;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Default to first adapter if we don't find a match
|
bool found = false;
|
||||||
size_t adapterIndex = 0;
|
for (size_t i = 0; i < adapters.size(); ++i) {
|
||||||
for (size_t i = 0; i < adapters.size(); ++i) {
|
wgpu::AdapterProperties props;
|
||||||
wgpu::AdapterProperties props;
|
adapters[i].GetProperties(&props);
|
||||||
adapters[i].GetProperties(&props);
|
if (props.backendType == targetBackendType) {
|
||||||
if (props.backendType == targetBackendType) {
|
adapterIndex = i;
|
||||||
adapterIndex = i;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
promise.Reject("backend '" + forceBackend + "' not found");
|
||||||
|
return promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue