dawn_node: Fixes for GPU.cpp
Check the result of std::getenv() before constructing a std::string. std::string cannot be constructed with nullptr. Fix ambiguous overload resolution of std::tolower(), by wrapping it in a lambda that explicitly takes a 'char' argument. Bug: dawn:1123 Change-Id: I8a44524a6c0e71f7d2a49a5a9f730115c32df577 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65960 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
f71f843944
commit
01c6a44358
|
@ -31,7 +31,10 @@ namespace {
|
|||
}
|
||||
return "";
|
||||
#else
|
||||
return std::getenv(varName);
|
||||
if (auto* val = std::getenv(varName)) {
|
||||
return val;
|
||||
}
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
@ -81,7 +84,8 @@ namespace wgpu { namespace binding {
|
|||
|
||||
// Check for override from env var
|
||||
std::string envVar = getEnvVar("DAWNNODE_BACKEND");
|
||||
std::transform(envVar.begin(), envVar.end(), envVar.begin(), std::tolower);
|
||||
std::transform(envVar.begin(), envVar.end(), envVar.begin(),
|
||||
[](char c) { return std::tolower(c); });
|
||||
if (envVar == "null") {
|
||||
targetBackendType = wgpu::BackendType::Null;
|
||||
} else if (envVar == "webgpu") {
|
||||
|
|
Loading…
Reference in New Issue