$OpenBSD: patch-gpu_config_gpu_info_collector_x11_cc,v 1.2 2015/04/27 16:38:25 robert Exp $
--- gpu/config/gpu_info_collector_x11.cc.orig.port	Wed Apr 15 00:18:55 2015
+++ gpu/config/gpu_info_collector_x11.cc	Wed Apr 15 15:34:00 2015
@@ -8,8 +8,17 @@
 #include "gpu/config/gpu_info_collector_linux.h"
 #include "third_party/libXNVCtrl/NVCtrl.h"
 #include "third_party/libXNVCtrl/NVCtrlLib.h"
+#include "ui/gl/gl_bindings.h"
+#include "ui/gl/gl_context.h"
+#include "ui/gl/gl_implementation.h"
+#include "ui/gl/gl_surface.h"
 #include "ui/gfx/x/x11_types.h"
 
+typedef bool (*PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display *dpy, int screen, int renderer, int attribute, unsigned int *value);
+
+#define GLX_RENDERER_VENDOR_ID_MESA     0x8183
+#define GLX_RENDERER_DEVICE_ID_MESA     0x8184
+
 namespace gpu {
 
 // Use NVCtrl extention to query NV driver version.
@@ -39,5 +48,42 @@ std::string CollectDriverVersionNVidia() {
   }
   return std::string();
 }
+
+CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
+  unsigned int vid[3], did[3];
+
+  Display* display = gfx::GetXDisplay();
+  if (!display) {
+    LOG(ERROR) << "XOpenDisplay failed.";
+    return kCollectInfoNonFatalFailure;
+  }
+
+  bool initialized =
+      gfx::InitializeStaticGLBindings(gfx::kGLImplementationDesktopGL);
+
+  if (!initialized)
+    return kCollectInfoNonFatalFailure;
+
+  PFNGLXQUERYRENDERERINTEGERMESAPROC queryInteger =
+      (PFNGLXQUERYRENDERERINTEGERMESAPROC) glXGetProcAddressARB((const GLubyte *)
+      "glXQueryRendererIntegerMESA");
+
+  bool vendor_ret =
+      queryInteger(display, 0, 0, GLX_RENDERER_VENDOR_ID_MESA, vid);
+  bool device_ret =
+      queryInteger(display, 0, 0, GLX_RENDERER_DEVICE_ID_MESA, did);
+
+  if (vendor_ret && device_ret) {
+    GPUInfo::GPUDevice gpu;
+    gpu.vendor_id = vid[0];
+    gpu.device_id = did[0];
+    gpu_info->gpu = gpu;
+  }
+
+  if (initialized)
+    gfx::ClearGLBindings();
+
+  return kCollectInfoSuccess;
+ }
 
 }  // namespace gpu
