mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
OpenGL: use vendor name to get PCI vendor id
OpenGL doesn't allow to query PCI information, but we can get vendor name through glGetString(GL_VENDOR), then match it with vendor id. BUG=dawn:184 Change-Id: Icdcdc6bfdb5cd561b5057e8b2eab06df2dd5cea1 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8940 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Hao Li <hao.x.li@intel.com>
This commit is contained in:
committed by
Commit Bot service account
parent
5580970f59
commit
1ffb0d6a02
@@ -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 <cstring>
|
||||
|
||||
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<const char*>(mFunctions.GetString(GL_RENDERER));
|
||||
|
||||
// Workaroud to find vendor id from vendor name
|
||||
const char* vendor = reinterpret_cast<const char*>(mFunctions.GetString(GL_VENDOR));
|
||||
mPCIInfo.vendorId = GetVendorIdFromVendors(vendor);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user