diff --git a/src/dawn_native/opengl/BackendGL.cpp b/src/dawn_native/opengl/BackendGL.cpp index 1e5c671693..94fc2fa292 100644 --- a/src/dawn_native/opengl/BackendGL.cpp +++ b/src/dawn_native/opengl/BackendGL.cpp @@ -14,11 +14,41 @@ #include "dawn_native/opengl/BackendGL.h" +#include "common/Constants.h" #include "dawn_native/OpenGLBackend.h" #include "dawn_native/opengl/DeviceGL.h" +#include + namespace dawn_native { namespace opengl { + namespace { + + struct Vendor { + const char* vendorName; + uint32_t vendorId; + }; + + const Vendor kVendors[] = {{"ATI", kVendorID_AMD}, + {"ARM", kVendorID_ARM}, + {"Imagination", kVendorID_ImgTec}, + {"Intel", kVendorID_Intel}, + {"NVIDIA", kVendorID_Nvidia}, + {"Qualcomm", kVendorID_Qualcomm}}; + + uint32_t GetVendorIdFromVendors(const char* vendor) { + uint32_t vendorId = 0; + for (const auto& it : kVendors) { + // Matching vendor name with vendor string + if (strstr(vendor, it.vendorName) != nullptr) { + vendorId = it.vendorId; + break; + } + } + return vendorId; + } + } // namespace + // The OpenGL backend's Adapter. class Adapter : public AdapterBase { @@ -38,6 +68,10 @@ namespace dawn_native { namespace opengl { mPCIInfo.name = reinterpret_cast(mFunctions.GetString(GL_RENDERER)); + // Workaroud to find vendor id from vendor name + const char* vendor = reinterpret_cast(mFunctions.GetString(GL_VENDOR)); + mPCIInfo.vendorId = GetVendorIdFromVendors(vendor); + return {}; } diff --git a/src/tests/DawnTest.cpp b/src/tests/DawnTest.cpp index ab5d0dda27..1a665edc19 100644 --- a/src/tests/DawnTest.cpp +++ b/src/tests/DawnTest.cpp @@ -114,7 +114,7 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) { continue; } - if (strstr(argv[i], "--adapter-vendor-id") != 0) { + if (strstr(argv[i], "--adapter-vendor-id") != nullptr) { const char* value = strchr(argv[i], '='); if (value != nullptr) { mVendorIdFilter = strtoul(value + 1, nullptr, 16); @@ -343,9 +343,7 @@ void DawnTest::SetUp() { for (const dawn_native::Adapter& adapter : adapters) { if (adapter.GetBackendType() == backendType) { - // TODO(hao.x.li@intel.com): Filter adapter for OpenGL backend once - // https://bugs.chromium.org/p/dawn/issues/detail?id=184 is resolved. - if (HasVendorIdFilter() && backendType != dawn_native::BackendType::OpenGL) { + if (HasVendorIdFilter()) { if (adapter.GetPCIInfo().vendorId == GetVendorIdFilter()) { backendAdapter = adapter; break;