use GLX_MESA_query_renderer in chromium

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

use GLX_MESA_query_renderer in chromium

Jonathan Gray-11
The GPU blacklist in chromium does not work correctly because the pci
vendor/device ids are not set.

The following diff uses GLX_MESA_query_renderer to get the numbers.
This is made harder than it otherwise would be as chromium has old
copies of the gl/glx headers with a python script/layers around them
and libGL is linked dynamically not statically so everything has to be
done via function pointers.

So this stomps over layers in the interest of something that works
without having to deal with python/multiple c++ classes etc.

While here use the correct library names for libEGL and libGLESv2.
These don't seem to be dlopen'd unless asked for on the command line?
The names in the ozone directory are unchanged as that doesn't
seem to be built.

diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/Makefile ./Makefile
--- /tmp/ports/www/chromium/Makefile Thu Feb 12 18:38:09 2015
+++ ./Makefile Tue Feb 17 04:46:10 2015
@@ -7,6 +7,7 @@ COMMENT= Chromium browser
 
 V= 40.0.2214.114
 DISTNAME= chromium-${V}
+REVISION= 0
 
 CATEGORIES= www
 
diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc ./patches/patch-gpu_config_gpu_info_collector_linux_cc
--- /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc Thu Jan  1 10:00:00 1970
+++ ./patches/patch-gpu_config_gpu_info_collector_linux_cc Tue Feb 17 21:46:24 2015
@@ -0,0 +1,14 @@
+$OpenBSD$
+--- gpu/config/gpu_info_collector_linux.cc.orig.port Tue Feb 17 16:32:33 2015
++++ gpu/config/gpu_info_collector_linux.cc Tue Feb 17 19:40:03 2015
+@@ -75,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
+ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
+   DCHECK(gpu_info);
+
++#if defined(OS_OPENBSD)
++  return (CollectMesaCardInfo(gpu_info));
++#endif
++
+ #if !defined(USE_LIBPCI)
+   return kCollectInfoNonFatalFailure;
+ #else
diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_h ./patches/patch-gpu_config_gpu_info_collector_linux_h
--- /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_h Thu Jan  1 10:00:00 1970
+++ ./patches/patch-gpu_config_gpu_info_collector_linux_h Tue Feb 17 16:34:43 2015
@@ -0,0 +1,18 @@
+$OpenBSD$
+--- gpu/config/gpu_info_collector_linux.h.orig.port Tue Feb 17 16:32:33 2015
++++ gpu/config/gpu_info_collector_linux.h Tue Feb 17 16:32:33 2015
+@@ -6,11 +6,14 @@
+ #define GPU_CONFIG_GPU_INFO_COLLECTOR_LINUX_H_
+
+ #include <string>
++#include "gpu/config/gpu_info_collector.h"
+
+ namespace gpu {
+
+ // Queries for the driver version. Returns an empty string on failure.
+ std::string CollectDriverVersionNVidia();
++
++CollectInfoResult CollectMesaCardInfo(GPUInfo*);
+
+ }  // namespace gpu
+
diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_x11_cc ./patches/patch-gpu_config_gpu_info_collector_x11_cc
--- /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_x11_cc Thu Jan  1 10:00:00 1970
+++ ./patches/patch-gpu_config_gpu_info_collector_x11_cc Tue Feb 17 21:49:22 2015
@@ -0,0 +1,120 @@
+$OpenBSD$
+--- gpu/config/gpu_info_collector_x11.cc.orig.port Tue Feb 17 16:32:33 2015
++++ gpu/config/gpu_info_collector_x11.cc Tue Feb 17 21:47:18 2015
+@@ -2,14 +2,50 @@
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+
++#define GLX_GLXEXT_PROTOTYPES
++
+ #include <X11/Xlib.h>
++#include <X11/Xutil.h>
++#include <GL/gl.h>
++#include <GL/glx.h>
+
+ #include "base/logging.h"
++#include "base/files/file_path.h"
++#include "base/native_library.h"
+ #include "gpu/config/gpu_info_collector_linux.h"
+ #include "third_party/libXNVCtrl/NVCtrl.h"
+ #include "third_party/libXNVCtrl/NVCtrlLib.h"
+ #include "ui/gfx/x/x11_types.h"
++#include "ui/gl/gl_implementation.h"
+
++/* chromium doesn't use system gl headers... */
++#ifndef GLX_MESA_query_renderer
++#define GLX_MESA_query_renderer 1
++
++#define GLX_RENDERER_VENDOR_ID_MESA                      0x8183
++#define GLX_RENDERER_DEVICE_ID_MESA                      0x8184
++#define GLX_RENDERER_VERSION_MESA                        0x8185
++#define GLX_RENDERER_ACCELERATED_MESA                    0x8186
++#define GLX_RENDERER_VIDEO_MEMORY_MESA                   0x8187
++#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA    0x8188
++#define GLX_RENDERER_PREFERRED_PROFILE_MESA              0x8189
++#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA    0x818A
++#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA    0x818B
++#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA      0x818C
++#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA     0x818D
++#define GLX_RENDERER_ID_MESA                             0x818E
++
++Bool glXQueryRendererIntegerMESA(Display *dpy, int screen, int renderer, int attribute, unsigned int *value);
++Bool glXQueryCurrentRendererIntegerMESA(int attribute, unsigned int *value);
++const char *glXQueryRendererStringMESA(Display *dpy, int screen, int renderer, int attribute);
++const char *glXQueryCurrentRendererStringMESA(int attribute);
++
++typedef Bool (*PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display *dpy, int screen, int renderer, int attribute, unsigned int *value);
++typedef Bool (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
++typedef const char *(*PFNGLXQUERYRENDERERSTRINGMESAPROC) (Display *dpy, int screen, int renderer, int attribute);
++typedef const char *(*PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute);
++#endif /* GLX_MESA_query_renderer */
++
+ namespace gpu {
+
+ // Use NVCtrl extention to query NV driver version.
+@@ -38,6 +74,65 @@ std::string CollectDriverVersionNVidia() {
+     }
+   }
+   return std::string();
++}
++
++CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
++  PFNGLXQUERYRENDERERINTEGERMESAPROC queryRendererInteger;
++  unsigned int v[3];
++  PFNGLXGETPROCADDRESSPROC procAddressARB;
++  const char *(*queryExtensionsString)(Display *, int);
++  uint32_t vendor_id, device_id;
++  Display* display = gfx::GetXDisplay();
++  if (!display) {
++    LOG(ERROR) << "XOpenDisplay failed.";
++    return kCollectInfoNonFatalFailure;
++  }
++
++  base::NativeLibrary libGL = base::LoadNativeLibrary(base::FilePath("libGL.so"), NULL);
++  if (libGL == NULL) {
++    LOG(ERROR) << "libGL open failed.";
++    return kCollectInfoNonFatalFailure;
++  }
++
++  procAddressARB = (PFNGLXGETPROCADDRESSPROC)
++    base::GetFunctionPointerFromNativeLibrary(libGL, "glXGetProcAddressARB");
++  if (procAddressARB == NULL) {
++    LOG(ERROR) << "couldn't find glXGetProcAddressARB in libGL.";
++    return kCollectInfoNonFatalFailure;
++  }
++
++  queryExtensionsString = (const char *(*)(Display *, int))
++    procAddressARB((const GLubyte *)"glXQueryExtensionsString");
++  if (queryExtensionsString == NULL) {
++    LOG(ERROR) << "couldn't find glXQueryExtensionsString in libGL.";
++    return kCollectInfoNonFatalFailure;
++  }
++
++  std::string glx_extensions = queryExtensionsString(display, 0);
++  bool glx_query_render =
++    glx_extensions.find("GLX_MESA_query_renderer") != std::string::npos;
++
++  if (glx_query_render == false)
++    return kCollectInfoNonFatalFailure;
++
++  queryRendererInteger = (PFNGLXQUERYRENDERERINTEGERMESAPROC)
++    procAddressARB((const GLubyte *)"glXQueryRendererIntegerMESA");
++  if (queryRendererInteger == NULL) {
++    LOG(ERROR) << "couldn't find glXQueryRendererIntegerMESA in libGL.";
++    return kCollectInfoNonFatalFailure;
++  }
++
++  queryRendererInteger(display, 0, 0, GLX_RENDERER_VENDOR_ID_MESA, v);
++  vendor_id = v[0];
++  queryRendererInteger(display, 0, 0, GLX_RENDERER_DEVICE_ID_MESA, v);
++  device_id = v[0];
++
++  GPUInfo::GPUDevice gpu;
++  gpu.vendor_id = vendor_id;
++  gpu.device_id = device_id;
++  gpu_info->gpu = gpu;
++
++  return kCollectInfoSuccess;
+ }
+
+ }  // namespace gpu
diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/patches/patch-ui_gl_gl_implementation_x11_cc ./patches/patch-ui_gl_gl_implementation_x11_cc
--- /tmp/ports/www/chromium/patches/patch-ui_gl_gl_implementation_x11_cc Thu Jan  1 10:00:00 1970
+++ ./patches/patch-ui_gl_gl_implementation_x11_cc Tue Feb 17 04:36:27 2015
@@ -0,0 +1,19 @@
+$OpenBSD$
+--- ui/gl/gl_implementation_x11.cc.orig.port Tue Feb 17 04:17:44 2015
++++ ui/gl/gl_implementation_x11.cc Tue Feb 17 04:19:00 2015
+@@ -33,12 +33,13 @@ void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GL
+
+ #if defined(OS_OPENBSD)
+ const char kGLLibraryName[] = "libGL.so";
++const char kGLESv2LibraryName[] = "libGLESv2.so";
++const char kEGLLibraryName[] = "libEGL.so";
+ #else
+ const char kGLLibraryName[] = "libGL.so.1";
+-#endif
+-
+ const char kGLESv2LibraryName[] = "libGLESv2.so.2";
+ const char kEGLLibraryName[] = "libEGL.so.1";
++#endif
+
+ }  // namespace
+

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Robert Nagy
I implemented this in a different way already and commited it a coupe of
days ago without too much patching to chrome itself.

On (2015-02-17 22:12), Jonathan Gray wrote:

> The GPU blacklist in chromium does not work correctly because the pci
> vendor/device ids are not set.
>
> The following diff uses GLX_MESA_query_renderer to get the numbers.
> This is made harder than it otherwise would be as chromium has old
> copies of the gl/glx headers with a python script/layers around them
> and libGL is linked dynamically not statically so everything has to be
> done via function pointers.
>
> So this stomps over layers in the interest of something that works
> without having to deal with python/multiple c++ classes etc.
>
> While here use the correct library names for libEGL and libGLESv2.
> These don't seem to be dlopen'd unless asked for on the command line?
> The names in the ozone directory are unchanged as that doesn't
> seem to be built.
>
> diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/Makefile ./Makefile
> --- /tmp/ports/www/chromium/Makefile Thu Feb 12 18:38:09 2015
> +++ ./Makefile Tue Feb 17 04:46:10 2015
> @@ -7,6 +7,7 @@ COMMENT= Chromium browser
>  
>  V= 40.0.2214.114
>  DISTNAME= chromium-${V}
> +REVISION= 0
>  
>  CATEGORIES= www
>  
> diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc ./patches/patch-gpu_config_gpu_info_collector_linux_cc
> --- /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc Thu Jan  1 10:00:00 1970
> +++ ./patches/patch-gpu_config_gpu_info_collector_linux_cc Tue Feb 17 21:46:24 2015
> @@ -0,0 +1,14 @@
> +$OpenBSD$
> +--- gpu/config/gpu_info_collector_linux.cc.orig.port Tue Feb 17 16:32:33 2015
> ++++ gpu/config/gpu_info_collector_linux.cc Tue Feb 17 19:40:03 2015
> +@@ -75,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
> + CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
> +   DCHECK(gpu_info);
> +
> ++#if defined(OS_OPENBSD)
> ++  return (CollectMesaCardInfo(gpu_info));
> ++#endif
> ++
> + #if !defined(USE_LIBPCI)
> +   return kCollectInfoNonFatalFailure;
> + #else
> diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_h ./patches/patch-gpu_config_gpu_info_collector_linux_h
> --- /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_h Thu Jan  1 10:00:00 1970
> +++ ./patches/patch-gpu_config_gpu_info_collector_linux_h Tue Feb 17 16:34:43 2015
> @@ -0,0 +1,18 @@
> +$OpenBSD$
> +--- gpu/config/gpu_info_collector_linux.h.orig.port Tue Feb 17 16:32:33 2015
> ++++ gpu/config/gpu_info_collector_linux.h Tue Feb 17 16:32:33 2015
> +@@ -6,11 +6,14 @@
> + #define GPU_CONFIG_GPU_INFO_COLLECTOR_LINUX_H_
> +
> + #include <string>
> ++#include "gpu/config/gpu_info_collector.h"
> +
> + namespace gpu {
> +
> + // Queries for the driver version. Returns an empty string on failure.
> + std::string CollectDriverVersionNVidia();
> ++
> ++CollectInfoResult CollectMesaCardInfo(GPUInfo*);
> +
> + }  // namespace gpu
> +
> diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_x11_cc ./patches/patch-gpu_config_gpu_info_collector_x11_cc
> --- /tmp/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_x11_cc Thu Jan  1 10:00:00 1970
> +++ ./patches/patch-gpu_config_gpu_info_collector_x11_cc Tue Feb 17 21:49:22 2015
> @@ -0,0 +1,120 @@
> +$OpenBSD$
> +--- gpu/config/gpu_info_collector_x11.cc.orig.port Tue Feb 17 16:32:33 2015
> ++++ gpu/config/gpu_info_collector_x11.cc Tue Feb 17 21:47:18 2015
> +@@ -2,14 +2,50 @@
> + // Use of this source code is governed by a BSD-style license that can be
> + // found in the LICENSE file.
> +
> ++#define GLX_GLXEXT_PROTOTYPES
> ++
> + #include <X11/Xlib.h>
> ++#include <X11/Xutil.h>
> ++#include <GL/gl.h>
> ++#include <GL/glx.h>
> +
> + #include "base/logging.h"
> ++#include "base/files/file_path.h"
> ++#include "base/native_library.h"
> + #include "gpu/config/gpu_info_collector_linux.h"
> + #include "third_party/libXNVCtrl/NVCtrl.h"
> + #include "third_party/libXNVCtrl/NVCtrlLib.h"
> + #include "ui/gfx/x/x11_types.h"
> ++#include "ui/gl/gl_implementation.h"
> +
> ++/* chromium doesn't use system gl headers... */
> ++#ifndef GLX_MESA_query_renderer
> ++#define GLX_MESA_query_renderer 1
> ++
> ++#define GLX_RENDERER_VENDOR_ID_MESA                      0x8183
> ++#define GLX_RENDERER_DEVICE_ID_MESA                      0x8184
> ++#define GLX_RENDERER_VERSION_MESA                        0x8185
> ++#define GLX_RENDERER_ACCELERATED_MESA                    0x8186
> ++#define GLX_RENDERER_VIDEO_MEMORY_MESA                   0x8187
> ++#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA    0x8188
> ++#define GLX_RENDERER_PREFERRED_PROFILE_MESA              0x8189
> ++#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA    0x818A
> ++#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA    0x818B
> ++#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA      0x818C
> ++#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA     0x818D
> ++#define GLX_RENDERER_ID_MESA                             0x818E
> ++
> ++Bool glXQueryRendererIntegerMESA(Display *dpy, int screen, int renderer, int attribute, unsigned int *value);
> ++Bool glXQueryCurrentRendererIntegerMESA(int attribute, unsigned int *value);
> ++const char *glXQueryRendererStringMESA(Display *dpy, int screen, int renderer, int attribute);
> ++const char *glXQueryCurrentRendererStringMESA(int attribute);
> ++
> ++typedef Bool (*PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display *dpy, int screen, int renderer, int attribute, unsigned int *value);
> ++typedef Bool (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
> ++typedef const char *(*PFNGLXQUERYRENDERERSTRINGMESAPROC) (Display *dpy, int screen, int renderer, int attribute);
> ++typedef const char *(*PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute);
> ++#endif /* GLX_MESA_query_renderer */
> ++
> + namespace gpu {
> +
> + // Use NVCtrl extention to query NV driver version.
> +@@ -38,6 +74,65 @@ std::string CollectDriverVersionNVidia() {
> +     }
> +   }
> +   return std::string();
> ++}
> ++
> ++CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
> ++  PFNGLXQUERYRENDERERINTEGERMESAPROC queryRendererInteger;
> ++  unsigned int v[3];
> ++  PFNGLXGETPROCADDRESSPROC procAddressARB;
> ++  const char *(*queryExtensionsString)(Display *, int);
> ++  uint32_t vendor_id, device_id;
> ++  Display* display = gfx::GetXDisplay();
> ++  if (!display) {
> ++    LOG(ERROR) << "XOpenDisplay failed.";
> ++    return kCollectInfoNonFatalFailure;
> ++  }
> ++
> ++  base::NativeLibrary libGL = base::LoadNativeLibrary(base::FilePath("libGL.so"), NULL);
> ++  if (libGL == NULL) {
> ++    LOG(ERROR) << "libGL open failed.";
> ++    return kCollectInfoNonFatalFailure;
> ++  }
> ++
> ++  procAddressARB = (PFNGLXGETPROCADDRESSPROC)
> ++    base::GetFunctionPointerFromNativeLibrary(libGL, "glXGetProcAddressARB");
> ++  if (procAddressARB == NULL) {
> ++    LOG(ERROR) << "couldn't find glXGetProcAddressARB in libGL.";
> ++    return kCollectInfoNonFatalFailure;
> ++  }
> ++
> ++  queryExtensionsString = (const char *(*)(Display *, int))
> ++    procAddressARB((const GLubyte *)"glXQueryExtensionsString");
> ++  if (queryExtensionsString == NULL) {
> ++    LOG(ERROR) << "couldn't find glXQueryExtensionsString in libGL.";
> ++    return kCollectInfoNonFatalFailure;
> ++  }
> ++
> ++  std::string glx_extensions = queryExtensionsString(display, 0);
> ++  bool glx_query_render =
> ++    glx_extensions.find("GLX_MESA_query_renderer") != std::string::npos;
> ++
> ++  if (glx_query_render == false)
> ++    return kCollectInfoNonFatalFailure;
> ++
> ++  queryRendererInteger = (PFNGLXQUERYRENDERERINTEGERMESAPROC)
> ++    procAddressARB((const GLubyte *)"glXQueryRendererIntegerMESA");
> ++  if (queryRendererInteger == NULL) {
> ++    LOG(ERROR) << "couldn't find glXQueryRendererIntegerMESA in libGL.";
> ++    return kCollectInfoNonFatalFailure;
> ++  }
> ++
> ++  queryRendererInteger(display, 0, 0, GLX_RENDERER_VENDOR_ID_MESA, v);
> ++  vendor_id = v[0];
> ++  queryRendererInteger(display, 0, 0, GLX_RENDERER_DEVICE_ID_MESA, v);
> ++  device_id = v[0];
> ++
> ++  GPUInfo::GPUDevice gpu;
> ++  gpu.vendor_id = vendor_id;
> ++  gpu.device_id = device_id;
> ++  gpu_info->gpu = gpu;
> ++
> ++  return kCollectInfoSuccess;
> + }
> +
> + }  // namespace gpu
> diff -uprN -x CVS -x *.orig /tmp/ports/www/chromium/patches/patch-ui_gl_gl_implementation_x11_cc ./patches/patch-ui_gl_gl_implementation_x11_cc
> --- /tmp/ports/www/chromium/patches/patch-ui_gl_gl_implementation_x11_cc Thu Jan  1 10:00:00 1970
> +++ ./patches/patch-ui_gl_gl_implementation_x11_cc Tue Feb 17 04:36:27 2015
> @@ -0,0 +1,19 @@
> +$OpenBSD$
> +--- ui/gl/gl_implementation_x11.cc.orig.port Tue Feb 17 04:17:44 2015
> ++++ ui/gl/gl_implementation_x11.cc Tue Feb 17 04:19:00 2015
> +@@ -33,12 +33,13 @@ void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GL
> +
> + #if defined(OS_OPENBSD)
> + const char kGLLibraryName[] = "libGL.so";
> ++const char kGLESv2LibraryName[] = "libGLESv2.so";
> ++const char kEGLLibraryName[] = "libEGL.so";
> + #else
> + const char kGLLibraryName[] = "libGL.so.1";
> +-#endif
> +-
> + const char kGLESv2LibraryName[] = "libGLESv2.so.2";
> + const char kEGLLibraryName[] = "libEGL.so.1";
> ++#endif
> +
> + }  // namespace
> +
>

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Robert Nagy
In reply to this post by Jonathan Gray-11
Hi

I've reworked what you did, because I like this method better than
what I did and commited earlier. I am currently running with this
without issues. As you can see I am using the python generated
bindings and instead of opening libGL I rely on what chrome has
already.

Index: Makefile
===================================================================
RCS file: /cvs/ports/www/chromium/Makefile,v
retrieving revision 1.201
diff -u -r1.201 Makefile
--- Makefile 15 Feb 2015 19:51:28 -0000 1.201
+++ Makefile 18 Feb 2015 20:23:24 -0000
@@ -7,7 +7,7 @@
 
 V= 40.0.2214.114
 DISTNAME= chromium-${V}
-REVISION= 0
+REVISION= 1
 
 CATEGORIES= www
 
@@ -90,6 +90,7 @@
  GYP_GENERATORS=ninja
 
 ALL_TARGET= chrome
+#ALL_TARGET= gpu_unittests
 
 BUILDDIR= ${WRKSRC}/out/${BUILDTYPE}
 
@@ -158,8 +159,6 @@
 do-build:
  @cd ${WRKSRC} && env -i ${MAKE_ENV} ninja \
  -j ${MAKE_JOBS} -C out/${BUILDTYPE} ${ALL_TARGET}
- ${CC} ${CLAGS} -o ${BUILDDIR}/gpuid -I${X11BASE}/include \
- -L${X11BASE}/lib ${FILESDIR}/gpuid.c -lGL
 
 do-install:
  ${INSTALL_DATA_DIR} ${PREFIX}/chrome
Index: files/chrome
===================================================================
RCS file: /cvs/ports/www/chromium/files/chrome,v
retrieving revision 1.12
diff -u -r1.12 chrome
--- files/chrome 15 Feb 2015 19:51:28 -0000 1.12
+++ files/chrome 18 Feb 2015 20:23:24 -0000
@@ -40,6 +40,4 @@
 #
 [ -z ${LANG} ] && _l=en_US.UTF-8 || _l=${LANG}
 
-eval `/usr/local/chrome/gpuid`
-
 LANG=${_l} exec "/usr/local/chrome/chrome" "${@}"
Index: files/gpuid.c
===================================================================
RCS file: files/gpuid.c
diff -N files/gpuid.c
--- files/gpuid.c 15 Feb 2015 19:51:28 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,86 +0,0 @@
-#include <GL/glx.h>
-#include <stdio.h>
-#include <string.h>
-
-int
-main(int argc, char *argv[])
-{
- Display        *dpy;
- int scrnum = 0;
- Window win;
- XSetWindowAttributes attr;
- Window root;
- GLXContext ctx = NULL;
- XVisualInfo    *visinfo;
- unsigned int vendor_id = 0x0000;
- unsigned int device_id = 0x0000;
- int attribSingle[] = {
-    GLX_RGBA,
-    GLX_RED_SIZE, 1,
-    GLX_GREEN_SIZE, 1,
-    GLX_BLUE_SIZE, 1,
-    None };
- int attribDouble[] = {
-    GLX_RGBA,
-    GLX_RED_SIZE, 1,
-    GLX_GREEN_SIZE, 1,
-    GLX_BLUE_SIZE, 1,
-    GLX_DOUBLEBUFFER,
-    None };
-
- dpy = XOpenDisplay(NULL);
- if (!dpy)
- goto exit;
-
- root = RootWindow(dpy, scrnum);
-
- visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
- if (!visinfo)
- visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
- if (visinfo)
- ctx = glXCreateContext(dpy, visinfo, NULL, False);
-
- if (!ctx)
- goto exit0;
-
- attr.background_pixel = attr.border_pixel = 0;
- attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
- attr.event_mask = StructureNotifyMask | ExposureMask;
- win = XCreateWindow(dpy, root, 0, 0, 100, 100,
-    0, visinfo->depth, InputOutput,
-    visinfo->visual, CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
-    &attr);
-
- if (glXMakeCurrent(dpy, win, ctx)) {
- const char     *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
- unsigned int v [3];
- PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger;
- queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
- glXGetProcAddressARB((const GLubyte *)
-      "glXQueryCurrentRendererIntegerMESA");
-
- if (!glXQueryVersion(dpy, NULL, NULL)) {
- goto exit1;
- }
- if (strstr(glxExtensions, "GLX_MESA_query_renderer")) {
- queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
- vendor_id = *v;
- queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
- device_id = *v;
- }
- }
-exit1:
- XDestroyWindow(dpy, win);
- glXDestroyContext(dpy, ctx);
-exit0:
- XFree(visinfo);
- XSync(dpy, 1);
-exit:
- printf("OPENBSD_GPU_VENDOR='0x%04x';\n", vendor_id);
- printf("export OPENBSD_GPU_VENDOR;\n");
- printf("OPENBSD_GPU_DEVICE='0x%04x';\n", device_id);
- printf("export OPENBSD_GPU_DEVICE;\n");
-
- XCloseDisplay(dpy);
- return 0;
-}
Index: patches/patch-gpu_config_gpu_info_collector_linux_cc
===================================================================
RCS file: /cvs/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc,v
retrieving revision 1.1
diff -u -r1.1 patch-gpu_config_gpu_info_collector_linux_cc
--- patches/patch-gpu_config_gpu_info_collector_linux_cc 15 Feb 2015 19:51:28 -0000 1.1
+++ patches/patch-gpu_config_gpu_info_collector_linux_cc 18 Feb 2015 20:23:24 -0000
@@ -1,45 +1,14 @@
 $OpenBSD: patch-gpu_config_gpu_info_collector_linux_cc,v 1.1 2015/02/15 19:51:28 robert Exp $
 --- gpu/config/gpu_info_collector_linux.cc.orig.port Sun Feb 15 15:25:13 2015
-+++ gpu/config/gpu_info_collector_linux.cc Sun Feb 15 18:39:58 2015
-@@ -31,6 +31,7 @@ namespace gpu {
++++ gpu/config/gpu_info_collector_linux.cc Wed Feb 18 20:23:51 2015
+@@ -75,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
+ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
+   DCHECK(gpu_info);
 
- namespace {
-
-+#if !defined(OS_BSD)
- // This checks if a system supports PCI bus.
- // We check the existence of /sys/bus/pci or /sys/bug/pci_express.
- bool IsPciSupported() {
-@@ -39,6 +40,7 @@ bool IsPciSupported() {
-   return (base::PathExists(pci_path) ||
-           base::PathExists(pcie_path));
- }
++#if defined(OS_BSD)
++  return (CollectMesaCardInfo(gpu_info));
 +#endif
-
- // Scan /etc/ati/amdpcsdb.default for "ReleaseVersion".
- // Return empty string on failing.
-@@ -79,6 +81,7 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
++
+ #if !defined(USE_LIBPCI)
    return kCollectInfoNonFatalFailure;
  #else
-
-+#if !defined(OS_BSD)
-   if (IsPciSupported() == false) {
-     VLOG(1) << "PCI bus scanning is not supported";
-     return kCollectInfoNonFatalFailure;
-@@ -148,6 +151,17 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
-   }
-
-   (libpci_loader.pci_cleanup)(access);
-+#else
-+  unsigned int vendor_id = 0x0000, device_id = 0x0000;
-+  char *vid, *did;
-+  if ((vid = getenv("OPENBSD_GPU_VENDOR")) != NULL)
-+    vendor_id = strtol(vid, NULL, 16);
-+  if ((did = getenv("OPENBSD_GPU_DEVICE")) != NULL)
-+    device_id = strtol(did, NULL, 16);
-+  bool primary_gpu_identified = true;
-+  gpu_info->gpu.vendor_id = vendor_id;
-+  gpu_info->gpu.device_id = device_id;
-+#endif
-   if (!primary_gpu_identified)
-     return kCollectInfoNonFatalFailure;
-   return kCollectInfoSuccess;
Index: patches/patch-gpu_config_gpu_info_collector_linux_h
===================================================================
RCS file: patches/patch-gpu_config_gpu_info_collector_linux_h
diff -N patches/patch-gpu_config_gpu_info_collector_linux_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gpu_config_gpu_info_collector_linux_h 18 Feb 2015 20:23:24 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+--- gpu/config/gpu_info_collector_linux.h.orig.port Wed Feb 18 17:58:41 2015
++++ gpu/config/gpu_info_collector_linux.h Wed Feb 18 17:59:22 2015
+@@ -6,11 +6,14 @@
+ #define GPU_CONFIG_GPU_INFO_COLLECTOR_LINUX_H_
+
+ #include <string>
++#include "gpu/config/gpu_info_collector.h"
+
+ namespace gpu {
+
+ // Queries for the driver version. Returns an empty string on failure.
+ std::string CollectDriverVersionNVidia();
++
++CollectInfoResult CollectMesaCardInfo(GPUInfo *);
+
+ }  // namespace gpu
+
Index: patches/patch-gpu_config_gpu_info_collector_x11_cc
===================================================================
RCS file: patches/patch-gpu_config_gpu_info_collector_x11_cc
diff -N patches/patch-gpu_config_gpu_info_collector_x11_cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gpu_config_gpu_info_collector_x11_cc 18 Feb 2015 20:23:24 -0000
@@ -0,0 +1,121 @@
+$OpenBSD$
+--- gpu/config/gpu_info_collector_x11.cc.orig.port Wed Feb 18 17:59:41 2015
++++ gpu/config/gpu_info_collector_x11.cc Wed Feb 18 20:52:18 2015
+@@ -4,14 +4,54 @@
+
+ #include <X11/Xlib.h>
+
++#include "base/debug/trace_event.h"
+ #include "base/logging.h"
+ #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 (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
++
++#define GLX_RENDERER_VENDOR_ID_MESA     0x8183
++#define GLX_RENDERER_DEVICE_ID_MESA     0x8184
++
+ namespace gpu {
+
++scoped_refptr<gfx::GLSurface> InitializeGLSurface() {
++  scoped_refptr<gfx::GLSurface> surface(
++      gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()));
++  if (!surface.get()) {
++    LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
++    return NULL;
++  }
++
++  return surface;
++}
++
++scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) {
++
++  scoped_refptr<gfx::GLContext> context(
++      gfx::GLContext::CreateGLContext(NULL,
++                                      surface,
++                                      gfx::PreferIntegratedGpu));
++  if (!context.get()) {
++    LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
++    return NULL;
++  }
++
++  if (!context->MakeCurrent(surface)) {
++    LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed";
++    return NULL;
++  }
++
++  return context;
++}
++
+ // Use NVCtrl extention to query NV driver version.
+ // Return empty string on failing.
+ std::string CollectDriverVersionNVidia() {
+@@ -39,5 +79,62 @@ std::string CollectDriverVersionNVidia() {
+   }
+   return std::string();
+ }
++
++CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
++  TRACE_EVENT0("startup", "gpu_info_collector_x11::CollectMesaCardInfo");
++  DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
++
++  unsigned int v[3];
++
++  Display* display = gfx::GetXDisplay();
++  if (!display) {
++    LOG(ERROR) << "XOpenDisplay failed.";
++    return kCollectInfoNonFatalFailure;
++  }
++
++  if (!gfx::GLSurface::InitializeOneOff()) {
++    LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
++    return kCollectInfoNonFatalFailure;
++  }
++
++  if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
++    return kCollectInfoNonFatalFailure;
++
++  scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface());
++  if (!surface.get()) {
++    LOG(ERROR) << "Could not create surface for info collection.";
++    return kCollectInfoFatalFailure;
++  }
++
++  scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
++  if (!context.get()) {
++    LOG(ERROR) << "Could not create context for info collection.";
++    return kCollectInfoFatalFailure;
++  }
++
++  std::string glx_extensions = glXQueryExtensionsString(display, 0);
++  bool glx_query_render =
++    glx_extensions.find("GLX_MESA_query_renderer") != std::string::npos;
++  if (glx_query_render == false)
++    return kCollectInfoNonFatalFailure;
++
++  PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
++    glXGetProcAddressARB((const GLubyte *)
++      "glXQueryCurrentRendererIntegerMESA");
++
++  GPUInfo::GPUDevice gpu;
++
++  queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
++  gpu.vendor_id = v[0];
++
++  queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
++  gpu.device_id = v[0];
++
++  gpu_info->gpu = gpu;
++
++  context->ReleaseCurrent(surface.get());
++
++  return kCollectInfoSuccess;
++ }
+
+ }  // namespace gpu
Index: patches/patch-ui_gl_generate_bindings_py
===================================================================
RCS file: patches/patch-ui_gl_generate_bindings_py
diff -N patches/patch-ui_gl_generate_bindings_py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-ui_gl_generate_bindings_py 18 Feb 2015 20:23:25 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+--- ui/gl/generate_bindings.py.orig.port Wed Feb 18 18:20:42 2015
++++ ui/gl/generate_bindings.py Wed Feb 18 18:23:06 2015
+@@ -1245,6 +1245,9 @@ GLX_FUNCTIONS = [
+   'arguments':
+       'Display* dpy, GLXDrawable drawable, int32* numerator, '
+       'int32* denominator' },
++{ 'return_type': '__GLXextFuncPtr',
++  'names': ['glXGetProcAddressARB'],
++  'arguments': 'const GLubyte* procName', },
+ { 'return_type': 'void',
+   'names': ['glXGetSelectedEvent'],
+   'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', },
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/www/chromium/pkg/PLIST,v
retrieving revision 1.45
diff -u -r1.45 PLIST
--- pkg/PLIST 15 Feb 2015 19:51:28 -0000 1.45
+++ pkg/PLIST 18 Feb 2015 20:23:25 -0000
@@ -5,7 +5,6 @@
 @bin chrome/chrome
 chrome/chrome_100_percent.pak
 chrome/content_resources.pak
-@bin chrome/gpuid
 chrome/icudtl.dat
 chrome/keyboard_resources.pak
 chrome/libexif.so

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Jonathan Gray-11
I think the entire block from the glx header should
be kept especially the #ifndef otherwise the build
will break when the headers in chromium are synced with Mesa.

It would also make it easier to use the other parts for
adding additional information later if needed.

You seem to be missing a
context->ReleaseCurrent(surface.get())
in one of the error paths as well.

On Wed, Feb 18, 2015 at 09:25:28PM +0100, Robert Nagy wrote:

> Hi
>
> I've reworked what you did, because I like this method better than
> what I did and commited earlier. I am currently running with this
> without issues. As you can see I am using the python generated
> bindings and instead of opening libGL I rely on what chrome has
> already.
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/www/chromium/Makefile,v
> retrieving revision 1.201
> diff -u -r1.201 Makefile
> --- Makefile 15 Feb 2015 19:51:28 -0000 1.201
> +++ Makefile 18 Feb 2015 20:23:24 -0000
> @@ -7,7 +7,7 @@
>  
>  V= 40.0.2214.114
>  DISTNAME= chromium-${V}
> -REVISION= 0
> +REVISION= 1
>  
>  CATEGORIES= www
>  
> @@ -90,6 +90,7 @@
>   GYP_GENERATORS=ninja
>  
>  ALL_TARGET= chrome
> +#ALL_TARGET= gpu_unittests
>  
>  BUILDDIR= ${WRKSRC}/out/${BUILDTYPE}
>  
> @@ -158,8 +159,6 @@
>  do-build:
>   @cd ${WRKSRC} && env -i ${MAKE_ENV} ninja \
>   -j ${MAKE_JOBS} -C out/${BUILDTYPE} ${ALL_TARGET}
> - ${CC} ${CLAGS} -o ${BUILDDIR}/gpuid -I${X11BASE}/include \
> - -L${X11BASE}/lib ${FILESDIR}/gpuid.c -lGL
>  
>  do-install:
>   ${INSTALL_DATA_DIR} ${PREFIX}/chrome
> Index: files/chrome
> ===================================================================
> RCS file: /cvs/ports/www/chromium/files/chrome,v
> retrieving revision 1.12
> diff -u -r1.12 chrome
> --- files/chrome 15 Feb 2015 19:51:28 -0000 1.12
> +++ files/chrome 18 Feb 2015 20:23:24 -0000
> @@ -40,6 +40,4 @@
>  #
>  [ -z ${LANG} ] && _l=en_US.UTF-8 || _l=${LANG}
>  
> -eval `/usr/local/chrome/gpuid`
> -
>  LANG=${_l} exec "/usr/local/chrome/chrome" "${@}"
> Index: files/gpuid.c
> ===================================================================
> RCS file: files/gpuid.c
> diff -N files/gpuid.c
> --- files/gpuid.c 15 Feb 2015 19:51:28 -0000 1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,86 +0,0 @@
> -#include <GL/glx.h>
> -#include <stdio.h>
> -#include <string.h>
> -
> -int
> -main(int argc, char *argv[])
> -{
> - Display        *dpy;
> - int scrnum = 0;
> - Window win;
> - XSetWindowAttributes attr;
> - Window root;
> - GLXContext ctx = NULL;
> - XVisualInfo    *visinfo;
> - unsigned int vendor_id = 0x0000;
> - unsigned int device_id = 0x0000;
> - int attribSingle[] = {
> -    GLX_RGBA,
> -    GLX_RED_SIZE, 1,
> -    GLX_GREEN_SIZE, 1,
> -    GLX_BLUE_SIZE, 1,
> -    None };
> - int attribDouble[] = {
> -    GLX_RGBA,
> -    GLX_RED_SIZE, 1,
> -    GLX_GREEN_SIZE, 1,
> -    GLX_BLUE_SIZE, 1,
> -    GLX_DOUBLEBUFFER,
> -    None };
> -
> - dpy = XOpenDisplay(NULL);
> - if (!dpy)
> - goto exit;
> -
> - root = RootWindow(dpy, scrnum);
> -
> - visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
> - if (!visinfo)
> - visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
> - if (visinfo)
> - ctx = glXCreateContext(dpy, visinfo, NULL, False);
> -
> - if (!ctx)
> - goto exit0;
> -
> - attr.background_pixel = attr.border_pixel = 0;
> - attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
> - attr.event_mask = StructureNotifyMask | ExposureMask;
> - win = XCreateWindow(dpy, root, 0, 0, 100, 100,
> -    0, visinfo->depth, InputOutput,
> -    visinfo->visual, CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
> -    &attr);
> -
> - if (glXMakeCurrent(dpy, win, ctx)) {
> - const char     *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
> - unsigned int v [3];
> - PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger;
> - queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> - glXGetProcAddressARB((const GLubyte *)
> -      "glXQueryCurrentRendererIntegerMESA");
> -
> - if (!glXQueryVersion(dpy, NULL, NULL)) {
> - goto exit1;
> - }
> - if (strstr(glxExtensions, "GLX_MESA_query_renderer")) {
> - queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> - vendor_id = *v;
> - queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> - device_id = *v;
> - }
> - }
> -exit1:
> - XDestroyWindow(dpy, win);
> - glXDestroyContext(dpy, ctx);
> -exit0:
> - XFree(visinfo);
> - XSync(dpy, 1);
> -exit:
> - printf("OPENBSD_GPU_VENDOR='0x%04x';\n", vendor_id);
> - printf("export OPENBSD_GPU_VENDOR;\n");
> - printf("OPENBSD_GPU_DEVICE='0x%04x';\n", device_id);
> - printf("export OPENBSD_GPU_DEVICE;\n");
> -
> - XCloseDisplay(dpy);
> - return 0;
> -}
> Index: patches/patch-gpu_config_gpu_info_collector_linux_cc
> ===================================================================
> RCS file: /cvs/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc,v
> retrieving revision 1.1
> diff -u -r1.1 patch-gpu_config_gpu_info_collector_linux_cc
> --- patches/patch-gpu_config_gpu_info_collector_linux_cc 15 Feb 2015 19:51:28 -0000 1.1
> +++ patches/patch-gpu_config_gpu_info_collector_linux_cc 18 Feb 2015 20:23:24 -0000
> @@ -1,45 +1,14 @@
>  $OpenBSD: patch-gpu_config_gpu_info_collector_linux_cc,v 1.1 2015/02/15 19:51:28 robert Exp $
>  --- gpu/config/gpu_info_collector_linux.cc.orig.port Sun Feb 15 15:25:13 2015
> -+++ gpu/config/gpu_info_collector_linux.cc Sun Feb 15 18:39:58 2015
> -@@ -31,6 +31,7 @@ namespace gpu {
> ++++ gpu/config/gpu_info_collector_linux.cc Wed Feb 18 20:23:51 2015
> +@@ -75,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
> + CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
> +   DCHECK(gpu_info);
>  
> - namespace {
> -
> -+#if !defined(OS_BSD)
> - // This checks if a system supports PCI bus.
> - // We check the existence of /sys/bus/pci or /sys/bug/pci_express.
> - bool IsPciSupported() {
> -@@ -39,6 +40,7 @@ bool IsPciSupported() {
> -   return (base::PathExists(pci_path) ||
> -           base::PathExists(pcie_path));
> - }
> ++#if defined(OS_BSD)
> ++  return (CollectMesaCardInfo(gpu_info));
>  +#endif
> -
> - // Scan /etc/ati/amdpcsdb.default for "ReleaseVersion".
> - // Return empty string on failing.
> -@@ -79,6 +81,7 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> ++
> + #if !defined(USE_LIBPCI)
>     return kCollectInfoNonFatalFailure;
>   #else
> -
> -+#if !defined(OS_BSD)
> -   if (IsPciSupported() == false) {
> -     VLOG(1) << "PCI bus scanning is not supported";
> -     return kCollectInfoNonFatalFailure;
> -@@ -148,6 +151,17 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> -   }
> -
> -   (libpci_loader.pci_cleanup)(access);
> -+#else
> -+  unsigned int vendor_id = 0x0000, device_id = 0x0000;
> -+  char *vid, *did;
> -+  if ((vid = getenv("OPENBSD_GPU_VENDOR")) != NULL)
> -+    vendor_id = strtol(vid, NULL, 16);
> -+  if ((did = getenv("OPENBSD_GPU_DEVICE")) != NULL)
> -+    device_id = strtol(did, NULL, 16);
> -+  bool primary_gpu_identified = true;
> -+  gpu_info->gpu.vendor_id = vendor_id;
> -+  gpu_info->gpu.device_id = device_id;
> -+#endif
> -   if (!primary_gpu_identified)
> -     return kCollectInfoNonFatalFailure;
> -   return kCollectInfoSuccess;
> Index: patches/patch-gpu_config_gpu_info_collector_linux_h
> ===================================================================
> RCS file: patches/patch-gpu_config_gpu_info_collector_linux_h
> diff -N patches/patch-gpu_config_gpu_info_collector_linux_h
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-gpu_config_gpu_info_collector_linux_h 18 Feb 2015 20:23:24 -0000
> @@ -0,0 +1,18 @@
> +$OpenBSD$
> +--- gpu/config/gpu_info_collector_linux.h.orig.port Wed Feb 18 17:58:41 2015
> ++++ gpu/config/gpu_info_collector_linux.h Wed Feb 18 17:59:22 2015
> +@@ -6,11 +6,14 @@
> + #define GPU_CONFIG_GPU_INFO_COLLECTOR_LINUX_H_
> +
> + #include <string>
> ++#include "gpu/config/gpu_info_collector.h"
> +
> + namespace gpu {
> +
> + // Queries for the driver version. Returns an empty string on failure.
> + std::string CollectDriverVersionNVidia();
> ++
> ++CollectInfoResult CollectMesaCardInfo(GPUInfo *);
> +
> + }  // namespace gpu
> +
> Index: patches/patch-gpu_config_gpu_info_collector_x11_cc
> ===================================================================
> RCS file: patches/patch-gpu_config_gpu_info_collector_x11_cc
> diff -N patches/patch-gpu_config_gpu_info_collector_x11_cc
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-gpu_config_gpu_info_collector_x11_cc 18 Feb 2015 20:23:24 -0000
> @@ -0,0 +1,121 @@
> +$OpenBSD$
> +--- gpu/config/gpu_info_collector_x11.cc.orig.port Wed Feb 18 17:59:41 2015
> ++++ gpu/config/gpu_info_collector_x11.cc Wed Feb 18 20:52:18 2015
> +@@ -4,14 +4,54 @@
> +
> + #include <X11/Xlib.h>
> +
> ++#include "base/debug/trace_event.h"
> + #include "base/logging.h"
> + #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 (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
> ++
> ++#define GLX_RENDERER_VENDOR_ID_MESA     0x8183
> ++#define GLX_RENDERER_DEVICE_ID_MESA     0x8184
> ++
> + namespace gpu {
> +
> ++scoped_refptr<gfx::GLSurface> InitializeGLSurface() {
> ++  scoped_refptr<gfx::GLSurface> surface(
> ++      gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()));
> ++  if (!surface.get()) {
> ++    LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
> ++    return NULL;
> ++  }
> ++
> ++  return surface;
> ++}
> ++
> ++scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) {
> ++
> ++  scoped_refptr<gfx::GLContext> context(
> ++      gfx::GLContext::CreateGLContext(NULL,
> ++                                      surface,
> ++                                      gfx::PreferIntegratedGpu));
> ++  if (!context.get()) {
> ++    LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
> ++    return NULL;
> ++  }
> ++
> ++  if (!context->MakeCurrent(surface)) {
> ++    LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed";
> ++    return NULL;
> ++  }
> ++
> ++  return context;
> ++}
> ++
> + // Use NVCtrl extention to query NV driver version.
> + // Return empty string on failing.
> + std::string CollectDriverVersionNVidia() {
> +@@ -39,5 +79,62 @@ std::string CollectDriverVersionNVidia() {
> +   }
> +   return std::string();
> + }
> ++
> ++CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
> ++  TRACE_EVENT0("startup", "gpu_info_collector_x11::CollectMesaCardInfo");
> ++  DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
> ++
> ++  unsigned int v[3];
> ++
> ++  Display* display = gfx::GetXDisplay();
> ++  if (!display) {
> ++    LOG(ERROR) << "XOpenDisplay failed.";
> ++    return kCollectInfoNonFatalFailure;
> ++  }
> ++
> ++  if (!gfx::GLSurface::InitializeOneOff()) {
> ++    LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
> ++    return kCollectInfoNonFatalFailure;
> ++  }
> ++
> ++  if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
> ++    return kCollectInfoNonFatalFailure;
> ++
> ++  scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface());
> ++  if (!surface.get()) {
> ++    LOG(ERROR) << "Could not create surface for info collection.";
> ++    return kCollectInfoFatalFailure;
> ++  }
> ++
> ++  scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
> ++  if (!context.get()) {
> ++    LOG(ERROR) << "Could not create context for info collection.";
> ++    return kCollectInfoFatalFailure;
> ++  }
> ++
> ++  std::string glx_extensions = glXQueryExtensionsString(display, 0);
> ++  bool glx_query_render =
> ++    glx_extensions.find("GLX_MESA_query_renderer") != std::string::npos;
> ++  if (glx_query_render == false)
> ++    return kCollectInfoNonFatalFailure;
> ++
> ++  PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> ++    glXGetProcAddressARB((const GLubyte *)
> ++      "glXQueryCurrentRendererIntegerMESA");
> ++
> ++  GPUInfo::GPUDevice gpu;
> ++
> ++  queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> ++  gpu.vendor_id = v[0];
> ++
> ++  queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> ++  gpu.device_id = v[0];
> ++
> ++  gpu_info->gpu = gpu;
> ++
> ++  context->ReleaseCurrent(surface.get());
> ++
> ++  return kCollectInfoSuccess;
> ++ }
> +
> + }  // namespace gpu
> Index: patches/patch-ui_gl_generate_bindings_py
> ===================================================================
> RCS file: patches/patch-ui_gl_generate_bindings_py
> diff -N patches/patch-ui_gl_generate_bindings_py
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-ui_gl_generate_bindings_py 18 Feb 2015 20:23:25 -0000
> @@ -0,0 +1,13 @@
> +$OpenBSD$
> +--- ui/gl/generate_bindings.py.orig.port Wed Feb 18 18:20:42 2015
> ++++ ui/gl/generate_bindings.py Wed Feb 18 18:23:06 2015
> +@@ -1245,6 +1245,9 @@ GLX_FUNCTIONS = [
> +   'arguments':
> +       'Display* dpy, GLXDrawable drawable, int32* numerator, '
> +       'int32* denominator' },
> ++{ 'return_type': '__GLXextFuncPtr',
> ++  'names': ['glXGetProcAddressARB'],
> ++  'arguments': 'const GLubyte* procName', },
> + { 'return_type': 'void',
> +   'names': ['glXGetSelectedEvent'],
> +   'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', },
> Index: pkg/PLIST
> ===================================================================
> RCS file: /cvs/ports/www/chromium/pkg/PLIST,v
> retrieving revision 1.45
> diff -u -r1.45 PLIST
> --- pkg/PLIST 15 Feb 2015 19:51:28 -0000 1.45
> +++ pkg/PLIST 18 Feb 2015 20:23:25 -0000
> @@ -5,7 +5,6 @@
>  @bin chrome/chrome
>  chrome/chrome_100_percent.pak
>  chrome/content_resources.pak
> -@bin chrome/gpuid
>  chrome/icudtl.dat
>  chrome/keyboard_resources.pak
>  chrome/libexif.so

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Robert Nagy
If the build breaks, I will notice right away, I don't
want to have extra defines if not necessary.
Yeah there are other problems as well, like crashing
when opening a system dialog like printing, save file, etc.

On (2015-02-19 11:15), Jonathan Gray wrote:

> I think the entire block from the glx header should
> be kept especially the #ifndef otherwise the build
> will break when the headers in chromium are synced with Mesa.
>
> It would also make it easier to use the other parts for
> adding additional information later if needed.
>
> You seem to be missing a
> context->ReleaseCurrent(surface.get())
> in one of the error paths as well.
>
> On Wed, Feb 18, 2015 at 09:25:28PM +0100, Robert Nagy wrote:
> > Hi
> >
> > I've reworked what you did, because I like this method better than
> > what I did and commited earlier. I am currently running with this
> > without issues. As you can see I am using the python generated
> > bindings and instead of opening libGL I rely on what chrome has
> > already.
> >
> > Index: Makefile
> > ===================================================================
> > RCS file: /cvs/ports/www/chromium/Makefile,v
> > retrieving revision 1.201
> > diff -u -r1.201 Makefile
> > --- Makefile 15 Feb 2015 19:51:28 -0000 1.201
> > +++ Makefile 18 Feb 2015 20:23:24 -0000
> > @@ -7,7 +7,7 @@
> >  
> >  V= 40.0.2214.114
> >  DISTNAME= chromium-${V}
> > -REVISION= 0
> > +REVISION= 1
> >  
> >  CATEGORIES= www
> >  
> > @@ -90,6 +90,7 @@
> >   GYP_GENERATORS=ninja
> >  
> >  ALL_TARGET= chrome
> > +#ALL_TARGET= gpu_unittests
> >  
> >  BUILDDIR= ${WRKSRC}/out/${BUILDTYPE}
> >  
> > @@ -158,8 +159,6 @@
> >  do-build:
> >   @cd ${WRKSRC} && env -i ${MAKE_ENV} ninja \
> >   -j ${MAKE_JOBS} -C out/${BUILDTYPE} ${ALL_TARGET}
> > - ${CC} ${CLAGS} -o ${BUILDDIR}/gpuid -I${X11BASE}/include \
> > - -L${X11BASE}/lib ${FILESDIR}/gpuid.c -lGL
> >  
> >  do-install:
> >   ${INSTALL_DATA_DIR} ${PREFIX}/chrome
> > Index: files/chrome
> > ===================================================================
> > RCS file: /cvs/ports/www/chromium/files/chrome,v
> > retrieving revision 1.12
> > diff -u -r1.12 chrome
> > --- files/chrome 15 Feb 2015 19:51:28 -0000 1.12
> > +++ files/chrome 18 Feb 2015 20:23:24 -0000
> > @@ -40,6 +40,4 @@
> >  #
> >  [ -z ${LANG} ] && _l=en_US.UTF-8 || _l=${LANG}
> >  
> > -eval `/usr/local/chrome/gpuid`
> > -
> >  LANG=${_l} exec "/usr/local/chrome/chrome" "${@}"
> > Index: files/gpuid.c
> > ===================================================================
> > RCS file: files/gpuid.c
> > diff -N files/gpuid.c
> > --- files/gpuid.c 15 Feb 2015 19:51:28 -0000 1.1
> > +++ /dev/null 1 Jan 1970 00:00:00 -0000
> > @@ -1,86 +0,0 @@
> > -#include <GL/glx.h>
> > -#include <stdio.h>
> > -#include <string.h>
> > -
> > -int
> > -main(int argc, char *argv[])
> > -{
> > - Display        *dpy;
> > - int scrnum = 0;
> > - Window win;
> > - XSetWindowAttributes attr;
> > - Window root;
> > - GLXContext ctx = NULL;
> > - XVisualInfo    *visinfo;
> > - unsigned int vendor_id = 0x0000;
> > - unsigned int device_id = 0x0000;
> > - int attribSingle[] = {
> > -    GLX_RGBA,
> > -    GLX_RED_SIZE, 1,
> > -    GLX_GREEN_SIZE, 1,
> > -    GLX_BLUE_SIZE, 1,
> > -    None };
> > - int attribDouble[] = {
> > -    GLX_RGBA,
> > -    GLX_RED_SIZE, 1,
> > -    GLX_GREEN_SIZE, 1,
> > -    GLX_BLUE_SIZE, 1,
> > -    GLX_DOUBLEBUFFER,
> > -    None };
> > -
> > - dpy = XOpenDisplay(NULL);
> > - if (!dpy)
> > - goto exit;
> > -
> > - root = RootWindow(dpy, scrnum);
> > -
> > - visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
> > - if (!visinfo)
> > - visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
> > - if (visinfo)
> > - ctx = glXCreateContext(dpy, visinfo, NULL, False);
> > -
> > - if (!ctx)
> > - goto exit0;
> > -
> > - attr.background_pixel = attr.border_pixel = 0;
> > - attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
> > - attr.event_mask = StructureNotifyMask | ExposureMask;
> > - win = XCreateWindow(dpy, root, 0, 0, 100, 100,
> > -    0, visinfo->depth, InputOutput,
> > -    visinfo->visual, CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
> > -    &attr);
> > -
> > - if (glXMakeCurrent(dpy, win, ctx)) {
> > - const char     *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
> > - unsigned int v [3];
> > - PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger;
> > - queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > - glXGetProcAddressARB((const GLubyte *)
> > -      "glXQueryCurrentRendererIntegerMESA");
> > -
> > - if (!glXQueryVersion(dpy, NULL, NULL)) {
> > - goto exit1;
> > - }
> > - if (strstr(glxExtensions, "GLX_MESA_query_renderer")) {
> > - queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > - vendor_id = *v;
> > - queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > - device_id = *v;
> > - }
> > - }
> > -exit1:
> > - XDestroyWindow(dpy, win);
> > - glXDestroyContext(dpy, ctx);
> > -exit0:
> > - XFree(visinfo);
> > - XSync(dpy, 1);
> > -exit:
> > - printf("OPENBSD_GPU_VENDOR='0x%04x';\n", vendor_id);
> > - printf("export OPENBSD_GPU_VENDOR;\n");
> > - printf("OPENBSD_GPU_DEVICE='0x%04x';\n", device_id);
> > - printf("export OPENBSD_GPU_DEVICE;\n");
> > -
> > - XCloseDisplay(dpy);
> > - return 0;
> > -}
> > Index: patches/patch-gpu_config_gpu_info_collector_linux_cc
> > ===================================================================
> > RCS file: /cvs/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc,v
> > retrieving revision 1.1
> > diff -u -r1.1 patch-gpu_config_gpu_info_collector_linux_cc
> > --- patches/patch-gpu_config_gpu_info_collector_linux_cc 15 Feb 2015 19:51:28 -0000 1.1
> > +++ patches/patch-gpu_config_gpu_info_collector_linux_cc 18 Feb 2015 20:23:24 -0000
> > @@ -1,45 +1,14 @@
> >  $OpenBSD: patch-gpu_config_gpu_info_collector_linux_cc,v 1.1 2015/02/15 19:51:28 robert Exp $
> >  --- gpu/config/gpu_info_collector_linux.cc.orig.port Sun Feb 15 15:25:13 2015
> > -+++ gpu/config/gpu_info_collector_linux.cc Sun Feb 15 18:39:58 2015
> > -@@ -31,6 +31,7 @@ namespace gpu {
> > ++++ gpu/config/gpu_info_collector_linux.cc Wed Feb 18 20:23:51 2015
> > +@@ -75,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
> > + CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
> > +   DCHECK(gpu_info);
> >  
> > - namespace {
> > -
> > -+#if !defined(OS_BSD)
> > - // This checks if a system supports PCI bus.
> > - // We check the existence of /sys/bus/pci or /sys/bug/pci_express.
> > - bool IsPciSupported() {
> > -@@ -39,6 +40,7 @@ bool IsPciSupported() {
> > -   return (base::PathExists(pci_path) ||
> > -           base::PathExists(pcie_path));
> > - }
> > ++#if defined(OS_BSD)
> > ++  return (CollectMesaCardInfo(gpu_info));
> >  +#endif
> > -
> > - // Scan /etc/ati/amdpcsdb.default for "ReleaseVersion".
> > - // Return empty string on failing.
> > -@@ -79,6 +81,7 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > ++
> > + #if !defined(USE_LIBPCI)
> >     return kCollectInfoNonFatalFailure;
> >   #else
> > -
> > -+#if !defined(OS_BSD)
> > -   if (IsPciSupported() == false) {
> > -     VLOG(1) << "PCI bus scanning is not supported";
> > -     return kCollectInfoNonFatalFailure;
> > -@@ -148,6 +151,17 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > -   }
> > -
> > -   (libpci_loader.pci_cleanup)(access);
> > -+#else
> > -+  unsigned int vendor_id = 0x0000, device_id = 0x0000;
> > -+  char *vid, *did;
> > -+  if ((vid = getenv("OPENBSD_GPU_VENDOR")) != NULL)
> > -+    vendor_id = strtol(vid, NULL, 16);
> > -+  if ((did = getenv("OPENBSD_GPU_DEVICE")) != NULL)
> > -+    device_id = strtol(did, NULL, 16);
> > -+  bool primary_gpu_identified = true;
> > -+  gpu_info->gpu.vendor_id = vendor_id;
> > -+  gpu_info->gpu.device_id = device_id;
> > -+#endif
> > -   if (!primary_gpu_identified)
> > -     return kCollectInfoNonFatalFailure;
> > -   return kCollectInfoSuccess;
> > Index: patches/patch-gpu_config_gpu_info_collector_linux_h
> > ===================================================================
> > RCS file: patches/patch-gpu_config_gpu_info_collector_linux_h
> > diff -N patches/patch-gpu_config_gpu_info_collector_linux_h
> > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > +++ patches/patch-gpu_config_gpu_info_collector_linux_h 18 Feb 2015 20:23:24 -0000
> > @@ -0,0 +1,18 @@
> > +$OpenBSD$
> > +--- gpu/config/gpu_info_collector_linux.h.orig.port Wed Feb 18 17:58:41 2015
> > ++++ gpu/config/gpu_info_collector_linux.h Wed Feb 18 17:59:22 2015
> > +@@ -6,11 +6,14 @@
> > + #define GPU_CONFIG_GPU_INFO_COLLECTOR_LINUX_H_
> > +
> > + #include <string>
> > ++#include "gpu/config/gpu_info_collector.h"
> > +
> > + namespace gpu {
> > +
> > + // Queries for the driver version. Returns an empty string on failure.
> > + std::string CollectDriverVersionNVidia();
> > ++
> > ++CollectInfoResult CollectMesaCardInfo(GPUInfo *);
> > +
> > + }  // namespace gpu
> > +
> > Index: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > ===================================================================
> > RCS file: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > diff -N patches/patch-gpu_config_gpu_info_collector_x11_cc
> > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > +++ patches/patch-gpu_config_gpu_info_collector_x11_cc 18 Feb 2015 20:23:24 -0000
> > @@ -0,0 +1,121 @@
> > +$OpenBSD$
> > +--- gpu/config/gpu_info_collector_x11.cc.orig.port Wed Feb 18 17:59:41 2015
> > ++++ gpu/config/gpu_info_collector_x11.cc Wed Feb 18 20:52:18 2015
> > +@@ -4,14 +4,54 @@
> > +
> > + #include <X11/Xlib.h>
> > +
> > ++#include "base/debug/trace_event.h"
> > + #include "base/logging.h"
> > + #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 (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
> > ++
> > ++#define GLX_RENDERER_VENDOR_ID_MESA     0x8183
> > ++#define GLX_RENDERER_DEVICE_ID_MESA     0x8184
> > ++
> > + namespace gpu {
> > +
> > ++scoped_refptr<gfx::GLSurface> InitializeGLSurface() {
> > ++  scoped_refptr<gfx::GLSurface> surface(
> > ++      gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()));
> > ++  if (!surface.get()) {
> > ++    LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
> > ++    return NULL;
> > ++  }
> > ++
> > ++  return surface;
> > ++}
> > ++
> > ++scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) {
> > ++
> > ++  scoped_refptr<gfx::GLContext> context(
> > ++      gfx::GLContext::CreateGLContext(NULL,
> > ++                                      surface,
> > ++                                      gfx::PreferIntegratedGpu));
> > ++  if (!context.get()) {
> > ++    LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
> > ++    return NULL;
> > ++  }
> > ++
> > ++  if (!context->MakeCurrent(surface)) {
> > ++    LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed";
> > ++    return NULL;
> > ++  }
> > ++
> > ++  return context;
> > ++}
> > ++
> > + // Use NVCtrl extention to query NV driver version.
> > + // Return empty string on failing.
> > + std::string CollectDriverVersionNVidia() {
> > +@@ -39,5 +79,62 @@ std::string CollectDriverVersionNVidia() {
> > +   }
> > +   return std::string();
> > + }
> > ++
> > ++CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
> > ++  TRACE_EVENT0("startup", "gpu_info_collector_x11::CollectMesaCardInfo");
> > ++  DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
> > ++
> > ++  unsigned int v[3];
> > ++
> > ++  Display* display = gfx::GetXDisplay();
> > ++  if (!display) {
> > ++    LOG(ERROR) << "XOpenDisplay failed.";
> > ++    return kCollectInfoNonFatalFailure;
> > ++  }
> > ++
> > ++  if (!gfx::GLSurface::InitializeOneOff()) {
> > ++    LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
> > ++    return kCollectInfoNonFatalFailure;
> > ++  }
> > ++
> > ++  if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
> > ++    return kCollectInfoNonFatalFailure;
> > ++
> > ++  scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface());
> > ++  if (!surface.get()) {
> > ++    LOG(ERROR) << "Could not create surface for info collection.";
> > ++    return kCollectInfoFatalFailure;
> > ++  }
> > ++
> > ++  scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
> > ++  if (!context.get()) {
> > ++    LOG(ERROR) << "Could not create context for info collection.";
> > ++    return kCollectInfoFatalFailure;
> > ++  }
> > ++
> > ++  std::string glx_extensions = glXQueryExtensionsString(display, 0);
> > ++  bool glx_query_render =
> > ++    glx_extensions.find("GLX_MESA_query_renderer") != std::string::npos;
> > ++  if (glx_query_render == false)
> > ++    return kCollectInfoNonFatalFailure;
> > ++
> > ++  PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > ++    glXGetProcAddressARB((const GLubyte *)
> > ++      "glXQueryCurrentRendererIntegerMESA");
> > ++
> > ++  GPUInfo::GPUDevice gpu;
> > ++
> > ++  queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > ++  gpu.vendor_id = v[0];
> > ++
> > ++  queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > ++  gpu.device_id = v[0];
> > ++
> > ++  gpu_info->gpu = gpu;
> > ++
> > ++  context->ReleaseCurrent(surface.get());
> > ++
> > ++  return kCollectInfoSuccess;
> > ++ }
> > +
> > + }  // namespace gpu
> > Index: patches/patch-ui_gl_generate_bindings_py
> > ===================================================================
> > RCS file: patches/patch-ui_gl_generate_bindings_py
> > diff -N patches/patch-ui_gl_generate_bindings_py
> > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > +++ patches/patch-ui_gl_generate_bindings_py 18 Feb 2015 20:23:25 -0000
> > @@ -0,0 +1,13 @@
> > +$OpenBSD$
> > +--- ui/gl/generate_bindings.py.orig.port Wed Feb 18 18:20:42 2015
> > ++++ ui/gl/generate_bindings.py Wed Feb 18 18:23:06 2015
> > +@@ -1245,6 +1245,9 @@ GLX_FUNCTIONS = [
> > +   'arguments':
> > +       'Display* dpy, GLXDrawable drawable, int32* numerator, '
> > +       'int32* denominator' },
> > ++{ 'return_type': '__GLXextFuncPtr',
> > ++  'names': ['glXGetProcAddressARB'],
> > ++  'arguments': 'const GLubyte* procName', },
> > + { 'return_type': 'void',
> > +   'names': ['glXGetSelectedEvent'],
> > +   'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', },
> > Index: pkg/PLIST
> > ===================================================================
> > RCS file: /cvs/ports/www/chromium/pkg/PLIST,v
> > retrieving revision 1.45
> > diff -u -r1.45 PLIST
> > --- pkg/PLIST 15 Feb 2015 19:51:28 -0000 1.45
> > +++ pkg/PLIST 18 Feb 2015 20:23:25 -0000
> > @@ -5,7 +5,6 @@
> >  @bin chrome/chrome
> >  chrome/chrome_100_percent.pak
> >  chrome/content_resources.pak
> > -@bin chrome/gpuid
> >  chrome/icudtl.dat
> >  chrome/keyboard_resources.pak
> >  chrome/libexif.so
>

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Guenther Niess-2
In reply to this post by Robert Nagy
On 02/17/15 13:02, Robert Nagy wrote:
> I implemented this in a different way already and commited it a coupe of
> days ago without too much patching to chrome itself.

I'm running the current snapshot with the new chromium package, but with
the "chrome --disable-gpu" Problem, Your first patch didn't work with my
radeon card, I will try your 2nd patch and after that jsg patch...

Thanks for working on the problem.


pkg_info chromium
Information for inst:chromium-40.0.2214.114p0
...

dmesg:
OpenBSD 5.7-beta (GENERIC.MP) #856: Tue Feb 17 12:43:12 MST 2015
    [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 6424297472 (6126MB)
avail mem = 6249369600 (5959MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xf0100 (37 entries)
bios0: vendor Award Software International, Inc. version "F8" date
09/30/2008
bios0: Gigabyte Technology Co., Ltd. EP45-DS3P
acpi0 at bios0: rev 0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP HPET MCFG APIC SSDT
acpi0: wakeup devices PEX0(S5) PEX1(S5) PEX2(S5) PEX3(S5) PEX4(S5)
PEX5(S5) HUB0(S5) UAR1(S3) IGBE(S4) USB0(S3) USB1(S3) USB2(S3) USB3(S3)
US31(S3) USB4(S3) USB5(S3) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimcfg0 at acpi0 addr 0xe0000000, bus 0-63
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2133.69 MHz
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG,LAHF,PERF
cpu0: 4MB 64b/line 16-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 266MHz
cpu0: mwait min=64, max=64, C-substates=0.2.0.0.0, IBE
cpu1 at mainbus0: apid 3 (application processor)
cpu1: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2133.41 MHz
cpu1:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG,LAHF,PERF
cpu1: 4MB 64b/line 16-way L2 cache
cpu1: smt 0, core 3, package 0
cpu2 at mainbus0: apid 1 (application processor)
cpu2: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2133.41 MHz
cpu2:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG,LAHF,PERF
cpu2: 4MB 64b/line 16-way L2 cache
cpu2: smt 0, core 1, package 0
cpu3 at mainbus0: apid 2 (application processor)
cpu3: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2133.41 MHz
cpu3:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG,LAHF,PERF
cpu3: 4MB 64b/line 16-way L2 cache
cpu3: smt 0, core 2, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 2
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 2 (PEX0)
acpiprt2 at acpi0: bus -1 (PEX1)
acpiprt3 at acpi0: bus -1 (PEX2)
acpiprt4 at acpi0: bus -1 (PEX3)
acpiprt5 at acpi0: bus 3 (PEX4)
acpiprt6 at acpi0: bus 4 (PEX5)
acpiprt7 at acpi0: bus 5 (HUB0)
acpicpu0 at acpi0: C3, C2, FVS, 2400, 1600 MHz
acpicpu1 at acpi0: C3, C2, FVS, 2400, 1600 MHz
acpicpu2 at acpi0: C3, C2, FVS, 2400, 1600 MHz
acpicpu3 at acpi0: C3, C2, FVS, 2400, 1600 MHz
acpibtn0 at acpi0: PWRB
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel G45 Host" rev 0x02
ppb0 at pci0 dev 1 function 0 "Intel G45 PCIE" rev 0x02: msi
pci1 at ppb0 bus 1
radeondrm0 at pci1 dev 0 function 0 "ATI Radeon HD 6450" rev 0x00
drm0 at radeondrm0
radeondrm0: msi
azalia0 at pci1 dev 0 function 1 "ATI Radeon HD 6400 Audio" rev 0x00: msi
azalia0: no supported codecs
uhci0 at pci0 dev 26 function 0 "Intel 82801JI USB" rev 0x00: apic 2 int 16
uhci1 at pci0 dev 26 function 1 "Intel 82801JI USB" rev 0x00: apic 2 int 21
uhci2 at pci0 dev 26 function 2 "Intel 82801JI USB" rev 0x00: apic 2 int 18
ehci0 at pci0 dev 26 function 7 "Intel 82801JI USB" rev 0x00: apic 2 int 18
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
azalia1 at pci0 dev 27 function 0 "Intel 82801JI HD Audio" rev 0x00: msi
azalia1: codecs: Realtek ALC885
audio0 at azalia1
ppb1 at pci0 dev 28 function 0 "Intel 82801JI PCIE" rev 0x00: msi
pci2 at ppb1 bus 2
ppb2 at pci0 dev 28 function 4 "Intel 82801JI PCIE" rev 0x00: msi
pci3 at ppb2 bus 3
re0 at pci3 dev 0 function 0 "Realtek 8168" rev 0x02: RTL8168C/8111C
(0x3c00), msi, address 00:1f:d0:23:bc:cd
rgephy0 at re0 phy 7: RTL8169S/8110S PHY, rev. 2
ppb3 at pci0 dev 28 function 5 "Intel 82801JI PCIE" rev 0x00: msi
pci4 at ppb3 bus 4
re1 at pci4 dev 0 function 0 "Realtek 8168" rev 0x02: RTL8168C/8111C
(0x3c00), msi, address 00:1f:d0:23:bd:0c
rgephy1 at re1 phy 7: RTL8169S/8110S PHY, rev. 2
uhci3 at pci0 dev 29 function 0 "Intel 82801JI USB" rev 0x00: apic 2 int 23
uhci4 at pci0 dev 29 function 1 "Intel 82801JI USB" rev 0x00: apic 2 int 19
uhci5 at pci0 dev 29 function 2 "Intel 82801JI USB" rev 0x00: apic 2 int 18
ehci1 at pci0 dev 29 function 7 "Intel 82801JI USB" rev 0x00: apic 2 int 23
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb4 at pci0 dev 30 function 0 "Intel 82801BA Hub-to-PCI" rev 0x90
pci5 at ppb4 bus 5
ath0 at pci5 dev 0 function 0 "Atheros AR5212" rev 0x01: apic 2 int 20
ath0: AR2414 7.9 phy 4.5 rf2413 5.6 eeprom 5.2, FCC2A*, address
00:18:4d:71:74:78
"TI TSB43AB23 FireWire" rev 0x00 at pci5 dev 6 function 0 not configured
pciide0 at pci5 dev 7 function 0 "ITExpress IT8213F" rev 0x00: DMA
(unsupported), channel 0 wired to native-PCI, channel 1 wired to native-PCI
pciide0: using apic 2 int 19 for native-PCI interrupt
pciide0: channel 0 ignored (not responding; disabled or no drives?)
pciide0: channel 1 ignored (not responding; disabled or no drives?)
pcib0 at pci0 dev 31 function 0 "Intel 82801JIR LPC" rev 0x00
ahci0 at pci0 dev 31 function 2 "Intel 82801JI AHCI" rev 0x00: msi, AHCI 1.2
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 0 lun 0: <ATA, ST4000DM000-1F21, CC52> SCSI3
0/direct fixed naa.5000c500651ae773
sd0: 3815447MB, 512 bytes/sector, 7814037168 sectors
sd1 at scsibus1 targ 1 lun 0: <ATA, SAMSUNG HD103UJ, 1AA0> SCSI3
0/direct fixed naa.50000f0008188717
sd1: 953868MB, 512 bytes/sector, 1953523055 sectors
sd2 at scsibus1 targ 2 lun 0: <ATA, WDC WD60EFRX-68M, 82.0> SCSI3
0/direct fixed naa.50014ee20b63d1e6
sd2: 5723166MB, 512 bytes/sector, 11721045168 sectors
sd3 at scsibus1 targ 4 lun 0: <ATA, ST3000DM001-9YN1, CC4H> SCSI3
0/direct fixed naa.5000c50052b9f888
sd3: 2861588MB, 512 bytes/sector, 5860533168 sectors
ichiic0 at pci0 dev 31 function 3 "Intel 82801JI SMBus" rev 0x00: apic 2
int 18
iic0 at ichiic0
iic0: addr 0x4e 03=38 04=38 12=ff 13=0f 20=0f 26=03 28=83 29=12 2a=12
2b=28 words 00=0000 01=0000 02=0038 03=3838 04=3800 05=0000 06=0000 07=0000
spdmem0 at iic0 addr 0x50: 2GB DDR2 SDRAM non-parity PC2-6400CL5
spdmem1 at iic0 addr 0x51: 1GB DDR2 SDRAM non-parity PC2-6400CL6
spdmem2 at iic0 addr 0x52: 2GB DDR2 SDRAM non-parity PC2-6400CL5
spdmem3 at iic0 addr 0x53: 1GB DDR2 SDRAM non-parity PC2-6400CL6
usb2 at uhci0: USB revision 1.0
uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci1: USB revision 1.0
uhub3 at usb3 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb4 at uhci2: USB revision 1.0
uhub4 at usb4 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb5 at uhci3: USB revision 1.0
uhub5 at usb5 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb6 at uhci4: USB revision 1.0
uhub6 at usb6 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb7 at uhci5: USB revision 1.0
uhub7 at usb7 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at pcib0
isadma0 at isa0
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard
pms0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
it0 at isa0 port 0x2e/2: IT8720F rev 5, EC port 0x290
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
sd4 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 005> SCSI2 0/direct fixed
sd4: 3805203MB, 512 bytes/sector, 7793055750 sectors
softraid0: volume sd4 is roaming, it used to be sd2, updating metadata
softraid0: roaming device sd1d -> sd0d
root on sd4a (5c6a87d38fa0ecfb.a) swap on sd4b dump on sd4b
radeondrm0: 1920x1080
wsdisplay0 at radeondrm0 mux 1: console (std, vt100 emulation), using wskbd0
wsdisplay0: screen 1-5 added (std, vt100 emulation)
atascsi_passthru_done, timeout
atascsi_passthru_done, timeout
atascsi_passthru_done, timeout
atascsi_passthru_done, timeout
atascsi_passthru_done, timeout

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Jonathan Gray-11
On Fri, Feb 20, 2015 at 09:04:59AM +0100, Guenther Niess wrote:
> On 02/17/15 13:02, Robert Nagy wrote:
> > I implemented this in a different way already and commited it a coupe of
> > days ago without too much patching to chrome itself.
>
> I'm running the current snapshot with the new chromium package, but with
> the "chrome --disable-gpu" Problem, Your first patch didn't work with my
> radeon card, I will try your 2nd patch and after that jsg patch...
>
> Thanks for working on the problem.

It seems none of the chrome blacklist entries will deal with this.

Mesa will switch back to 10.2 over the weekend which will avoid
the problem.

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Jonathan Gray-11
In reply to this post by Robert Nagy
It might be worth checking that the values are not 0xffffffff before
using them as well.  That is the value the extension will return if the
vendor/device ids are not available or if a software renderer is used.

On Thu, Feb 19, 2015 at 07:07:02AM +0100, Robert Nagy wrote:

> If the build breaks, I will notice right away, I don't
> want to have extra defines if not necessary.
> Yeah there are other problems as well, like crashing
> when opening a system dialog like printing, save file, etc.
>
> On (2015-02-19 11:15), Jonathan Gray wrote:
> > I think the entire block from the glx header should
> > be kept especially the #ifndef otherwise the build
> > will break when the headers in chromium are synced with Mesa.
> >
> > It would also make it easier to use the other parts for
> > adding additional information later if needed.
> >
> > You seem to be missing a
> > context->ReleaseCurrent(surface.get())
> > in one of the error paths as well.
> >
> > On Wed, Feb 18, 2015 at 09:25:28PM +0100, Robert Nagy wrote:
> > > Hi
> > >
> > > I've reworked what you did, because I like this method better than
> > > what I did and commited earlier. I am currently running with this
> > > without issues. As you can see I am using the python generated
> > > bindings and instead of opening libGL I rely on what chrome has
> > > already.
> > >
> > > Index: Makefile
> > > ===================================================================
> > > RCS file: /cvs/ports/www/chromium/Makefile,v
> > > retrieving revision 1.201
> > > diff -u -r1.201 Makefile
> > > --- Makefile 15 Feb 2015 19:51:28 -0000 1.201
> > > +++ Makefile 18 Feb 2015 20:23:24 -0000
> > > @@ -7,7 +7,7 @@
> > >  
> > >  V= 40.0.2214.114
> > >  DISTNAME= chromium-${V}
> > > -REVISION= 0
> > > +REVISION= 1
> > >  
> > >  CATEGORIES= www
> > >  
> > > @@ -90,6 +90,7 @@
> > >   GYP_GENERATORS=ninja
> > >  
> > >  ALL_TARGET= chrome
> > > +#ALL_TARGET= gpu_unittests
> > >  
> > >  BUILDDIR= ${WRKSRC}/out/${BUILDTYPE}
> > >  
> > > @@ -158,8 +159,6 @@
> > >  do-build:
> > >   @cd ${WRKSRC} && env -i ${MAKE_ENV} ninja \
> > >   -j ${MAKE_JOBS} -C out/${BUILDTYPE} ${ALL_TARGET}
> > > - ${CC} ${CLAGS} -o ${BUILDDIR}/gpuid -I${X11BASE}/include \
> > > - -L${X11BASE}/lib ${FILESDIR}/gpuid.c -lGL
> > >  
> > >  do-install:
> > >   ${INSTALL_DATA_DIR} ${PREFIX}/chrome
> > > Index: files/chrome
> > > ===================================================================
> > > RCS file: /cvs/ports/www/chromium/files/chrome,v
> > > retrieving revision 1.12
> > > diff -u -r1.12 chrome
> > > --- files/chrome 15 Feb 2015 19:51:28 -0000 1.12
> > > +++ files/chrome 18 Feb 2015 20:23:24 -0000
> > > @@ -40,6 +40,4 @@
> > >  #
> > >  [ -z ${LANG} ] && _l=en_US.UTF-8 || _l=${LANG}
> > >  
> > > -eval `/usr/local/chrome/gpuid`
> > > -
> > >  LANG=${_l} exec "/usr/local/chrome/chrome" "${@}"
> > > Index: files/gpuid.c
> > > ===================================================================
> > > RCS file: files/gpuid.c
> > > diff -N files/gpuid.c
> > > --- files/gpuid.c 15 Feb 2015 19:51:28 -0000 1.1
> > > +++ /dev/null 1 Jan 1970 00:00:00 -0000
> > > @@ -1,86 +0,0 @@
> > > -#include <GL/glx.h>
> > > -#include <stdio.h>
> > > -#include <string.h>
> > > -
> > > -int
> > > -main(int argc, char *argv[])
> > > -{
> > > - Display        *dpy;
> > > - int scrnum = 0;
> > > - Window win;
> > > - XSetWindowAttributes attr;
> > > - Window root;
> > > - GLXContext ctx = NULL;
> > > - XVisualInfo    *visinfo;
> > > - unsigned int vendor_id = 0x0000;
> > > - unsigned int device_id = 0x0000;
> > > - int attribSingle[] = {
> > > -    GLX_RGBA,
> > > -    GLX_RED_SIZE, 1,
> > > -    GLX_GREEN_SIZE, 1,
> > > -    GLX_BLUE_SIZE, 1,
> > > -    None };
> > > - int attribDouble[] = {
> > > -    GLX_RGBA,
> > > -    GLX_RED_SIZE, 1,
> > > -    GLX_GREEN_SIZE, 1,
> > > -    GLX_BLUE_SIZE, 1,
> > > -    GLX_DOUBLEBUFFER,
> > > -    None };
> > > -
> > > - dpy = XOpenDisplay(NULL);
> > > - if (!dpy)
> > > - goto exit;
> > > -
> > > - root = RootWindow(dpy, scrnum);
> > > -
> > > - visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
> > > - if (!visinfo)
> > > - visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
> > > - if (visinfo)
> > > - ctx = glXCreateContext(dpy, visinfo, NULL, False);
> > > -
> > > - if (!ctx)
> > > - goto exit0;
> > > -
> > > - attr.background_pixel = attr.border_pixel = 0;
> > > - attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
> > > - attr.event_mask = StructureNotifyMask | ExposureMask;
> > > - win = XCreateWindow(dpy, root, 0, 0, 100, 100,
> > > -    0, visinfo->depth, InputOutput,
> > > -    visinfo->visual, CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
> > > -    &attr);
> > > -
> > > - if (glXMakeCurrent(dpy, win, ctx)) {
> > > - const char     *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
> > > - unsigned int v [3];
> > > - PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger;
> > > - queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > > - glXGetProcAddressARB((const GLubyte *)
> > > -      "glXQueryCurrentRendererIntegerMESA");
> > > -
> > > - if (!glXQueryVersion(dpy, NULL, NULL)) {
> > > - goto exit1;
> > > - }
> > > - if (strstr(glxExtensions, "GLX_MESA_query_renderer")) {
> > > - queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > > - vendor_id = *v;
> > > - queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > > - device_id = *v;
> > > - }
> > > - }
> > > -exit1:
> > > - XDestroyWindow(dpy, win);
> > > - glXDestroyContext(dpy, ctx);
> > > -exit0:
> > > - XFree(visinfo);
> > > - XSync(dpy, 1);
> > > -exit:
> > > - printf("OPENBSD_GPU_VENDOR='0x%04x';\n", vendor_id);
> > > - printf("export OPENBSD_GPU_VENDOR;\n");
> > > - printf("OPENBSD_GPU_DEVICE='0x%04x';\n", device_id);
> > > - printf("export OPENBSD_GPU_DEVICE;\n");
> > > -
> > > - XCloseDisplay(dpy);
> > > - return 0;
> > > -}
> > > Index: patches/patch-gpu_config_gpu_info_collector_linux_cc
> > > ===================================================================
> > > RCS file: /cvs/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc,v
> > > retrieving revision 1.1
> > > diff -u -r1.1 patch-gpu_config_gpu_info_collector_linux_cc
> > > --- patches/patch-gpu_config_gpu_info_collector_linux_cc 15 Feb 2015 19:51:28 -0000 1.1
> > > +++ patches/patch-gpu_config_gpu_info_collector_linux_cc 18 Feb 2015 20:23:24 -0000
> > > @@ -1,45 +1,14 @@
> > >  $OpenBSD: patch-gpu_config_gpu_info_collector_linux_cc,v 1.1 2015/02/15 19:51:28 robert Exp $
> > >  --- gpu/config/gpu_info_collector_linux.cc.orig.port Sun Feb 15 15:25:13 2015
> > > -+++ gpu/config/gpu_info_collector_linux.cc Sun Feb 15 18:39:58 2015
> > > -@@ -31,6 +31,7 @@ namespace gpu {
> > > ++++ gpu/config/gpu_info_collector_linux.cc Wed Feb 18 20:23:51 2015
> > > +@@ -75,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
> > > + CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
> > > +   DCHECK(gpu_info);
> > >  
> > > - namespace {
> > > -
> > > -+#if !defined(OS_BSD)
> > > - // This checks if a system supports PCI bus.
> > > - // We check the existence of /sys/bus/pci or /sys/bug/pci_express.
> > > - bool IsPciSupported() {
> > > -@@ -39,6 +40,7 @@ bool IsPciSupported() {
> > > -   return (base::PathExists(pci_path) ||
> > > -           base::PathExists(pcie_path));
> > > - }
> > > ++#if defined(OS_BSD)
> > > ++  return (CollectMesaCardInfo(gpu_info));
> > >  +#endif
> > > -
> > > - // Scan /etc/ati/amdpcsdb.default for "ReleaseVersion".
> > > - // Return empty string on failing.
> > > -@@ -79,6 +81,7 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > > ++
> > > + #if !defined(USE_LIBPCI)
> > >     return kCollectInfoNonFatalFailure;
> > >   #else
> > > -
> > > -+#if !defined(OS_BSD)
> > > -   if (IsPciSupported() == false) {
> > > -     VLOG(1) << "PCI bus scanning is not supported";
> > > -     return kCollectInfoNonFatalFailure;
> > > -@@ -148,6 +151,17 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > > -   }
> > > -
> > > -   (libpci_loader.pci_cleanup)(access);
> > > -+#else
> > > -+  unsigned int vendor_id = 0x0000, device_id = 0x0000;
> > > -+  char *vid, *did;
> > > -+  if ((vid = getenv("OPENBSD_GPU_VENDOR")) != NULL)
> > > -+    vendor_id = strtol(vid, NULL, 16);
> > > -+  if ((did = getenv("OPENBSD_GPU_DEVICE")) != NULL)
> > > -+    device_id = strtol(did, NULL, 16);
> > > -+  bool primary_gpu_identified = true;
> > > -+  gpu_info->gpu.vendor_id = vendor_id;
> > > -+  gpu_info->gpu.device_id = device_id;
> > > -+#endif
> > > -   if (!primary_gpu_identified)
> > > -     return kCollectInfoNonFatalFailure;
> > > -   return kCollectInfoSuccess;
> > > Index: patches/patch-gpu_config_gpu_info_collector_linux_h
> > > ===================================================================
> > > RCS file: patches/patch-gpu_config_gpu_info_collector_linux_h
> > > diff -N patches/patch-gpu_config_gpu_info_collector_linux_h
> > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > +++ patches/patch-gpu_config_gpu_info_collector_linux_h 18 Feb 2015 20:23:24 -0000
> > > @@ -0,0 +1,18 @@
> > > +$OpenBSD$
> > > +--- gpu/config/gpu_info_collector_linux.h.orig.port Wed Feb 18 17:58:41 2015
> > > ++++ gpu/config/gpu_info_collector_linux.h Wed Feb 18 17:59:22 2015
> > > +@@ -6,11 +6,14 @@
> > > + #define GPU_CONFIG_GPU_INFO_COLLECTOR_LINUX_H_
> > > +
> > > + #include <string>
> > > ++#include "gpu/config/gpu_info_collector.h"
> > > +
> > > + namespace gpu {
> > > +
> > > + // Queries for the driver version. Returns an empty string on failure.
> > > + std::string CollectDriverVersionNVidia();
> > > ++
> > > ++CollectInfoResult CollectMesaCardInfo(GPUInfo *);
> > > +
> > > + }  // namespace gpu
> > > +
> > > Index: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > ===================================================================
> > > RCS file: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > diff -N patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > +++ patches/patch-gpu_config_gpu_info_collector_x11_cc 18 Feb 2015 20:23:24 -0000
> > > @@ -0,0 +1,121 @@
> > > +$OpenBSD$
> > > +--- gpu/config/gpu_info_collector_x11.cc.orig.port Wed Feb 18 17:59:41 2015
> > > ++++ gpu/config/gpu_info_collector_x11.cc Wed Feb 18 20:52:18 2015
> > > +@@ -4,14 +4,54 @@
> > > +
> > > + #include <X11/Xlib.h>
> > > +
> > > ++#include "base/debug/trace_event.h"
> > > + #include "base/logging.h"
> > > + #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 (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
> > > ++
> > > ++#define GLX_RENDERER_VENDOR_ID_MESA     0x8183
> > > ++#define GLX_RENDERER_DEVICE_ID_MESA     0x8184
> > > ++
> > > + namespace gpu {
> > > +
> > > ++scoped_refptr<gfx::GLSurface> InitializeGLSurface() {
> > > ++  scoped_refptr<gfx::GLSurface> surface(
> > > ++      gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()));
> > > ++  if (!surface.get()) {
> > > ++    LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
> > > ++    return NULL;
> > > ++  }
> > > ++
> > > ++  return surface;
> > > ++}
> > > ++
> > > ++scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) {
> > > ++
> > > ++  scoped_refptr<gfx::GLContext> context(
> > > ++      gfx::GLContext::CreateGLContext(NULL,
> > > ++                                      surface,
> > > ++                                      gfx::PreferIntegratedGpu));
> > > ++  if (!context.get()) {
> > > ++    LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
> > > ++    return NULL;
> > > ++  }
> > > ++
> > > ++  if (!context->MakeCurrent(surface)) {
> > > ++    LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed";
> > > ++    return NULL;
> > > ++  }
> > > ++
> > > ++  return context;
> > > ++}
> > > ++
> > > + // Use NVCtrl extention to query NV driver version.
> > > + // Return empty string on failing.
> > > + std::string CollectDriverVersionNVidia() {
> > > +@@ -39,5 +79,62 @@ std::string CollectDriverVersionNVidia() {
> > > +   }
> > > +   return std::string();
> > > + }
> > > ++
> > > ++CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
> > > ++  TRACE_EVENT0("startup", "gpu_info_collector_x11::CollectMesaCardInfo");
> > > ++  DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
> > > ++
> > > ++  unsigned int v[3];
> > > ++
> > > ++  Display* display = gfx::GetXDisplay();
> > > ++  if (!display) {
> > > ++    LOG(ERROR) << "XOpenDisplay failed.";
> > > ++    return kCollectInfoNonFatalFailure;
> > > ++  }
> > > ++
> > > ++  if (!gfx::GLSurface::InitializeOneOff()) {
> > > ++    LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
> > > ++    return kCollectInfoNonFatalFailure;
> > > ++  }
> > > ++
> > > ++  if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
> > > ++    return kCollectInfoNonFatalFailure;
> > > ++
> > > ++  scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface());
> > > ++  if (!surface.get()) {
> > > ++    LOG(ERROR) << "Could not create surface for info collection.";
> > > ++    return kCollectInfoFatalFailure;
> > > ++  }
> > > ++
> > > ++  scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
> > > ++  if (!context.get()) {
> > > ++    LOG(ERROR) << "Could not create context for info collection.";
> > > ++    return kCollectInfoFatalFailure;
> > > ++  }
> > > ++
> > > ++  std::string glx_extensions = glXQueryExtensionsString(display, 0);
> > > ++  bool glx_query_render =
> > > ++    glx_extensions.find("GLX_MESA_query_renderer") != std::string::npos;
> > > ++  if (glx_query_render == false)
> > > ++    return kCollectInfoNonFatalFailure;
> > > ++
> > > ++  PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > > ++    glXGetProcAddressARB((const GLubyte *)
> > > ++      "glXQueryCurrentRendererIntegerMESA");
> > > ++
> > > ++  GPUInfo::GPUDevice gpu;
> > > ++
> > > ++  queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > > ++  gpu.vendor_id = v[0];
> > > ++
> > > ++  queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > > ++  gpu.device_id = v[0];
> > > ++
> > > ++  gpu_info->gpu = gpu;
> > > ++
> > > ++  context->ReleaseCurrent(surface.get());
> > > ++
> > > ++  return kCollectInfoSuccess;
> > > ++ }
> > > +
> > > + }  // namespace gpu
> > > Index: patches/patch-ui_gl_generate_bindings_py
> > > ===================================================================
> > > RCS file: patches/patch-ui_gl_generate_bindings_py
> > > diff -N patches/patch-ui_gl_generate_bindings_py
> > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > +++ patches/patch-ui_gl_generate_bindings_py 18 Feb 2015 20:23:25 -0000
> > > @@ -0,0 +1,13 @@
> > > +$OpenBSD$
> > > +--- ui/gl/generate_bindings.py.orig.port Wed Feb 18 18:20:42 2015
> > > ++++ ui/gl/generate_bindings.py Wed Feb 18 18:23:06 2015
> > > +@@ -1245,6 +1245,9 @@ GLX_FUNCTIONS = [
> > > +   'arguments':
> > > +       'Display* dpy, GLXDrawable drawable, int32* numerator, '
> > > +       'int32* denominator' },
> > > ++{ 'return_type': '__GLXextFuncPtr',
> > > ++  'names': ['glXGetProcAddressARB'],
> > > ++  'arguments': 'const GLubyte* procName', },
> > > + { 'return_type': 'void',
> > > +   'names': ['glXGetSelectedEvent'],
> > > +   'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', },
> > > Index: pkg/PLIST
> > > ===================================================================
> > > RCS file: /cvs/ports/www/chromium/pkg/PLIST,v
> > > retrieving revision 1.45
> > > diff -u -r1.45 PLIST
> > > --- pkg/PLIST 15 Feb 2015 19:51:28 -0000 1.45
> > > +++ pkg/PLIST 18 Feb 2015 20:23:25 -0000
> > > @@ -5,7 +5,6 @@
> > >  @bin chrome/chrome
> > >  chrome/chrome_100_percent.pak
> > >  chrome/content_resources.pak
> > > -@bin chrome/gpuid
> > >  chrome/icudtl.dat
> > >  chrome/keyboard_resources.pak
> > >  chrome/libexif.so
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Robert Nagy
Good to know, thanks. I am still fighting the crash, which happens
when you open a dialog (print, save/open file). Something that I can't
find a fix for....

On (2015-02-22 16:35), Jonathan Gray wrote:

> It might be worth checking that the values are not 0xffffffff before
> using them as well.  That is the value the extension will return if the
> vendor/device ids are not available or if a software renderer is used.
>
> On Thu, Feb 19, 2015 at 07:07:02AM +0100, Robert Nagy wrote:
> > If the build breaks, I will notice right away, I don't
> > want to have extra defines if not necessary.
> > Yeah there are other problems as well, like crashing
> > when opening a system dialog like printing, save file, etc.
> >
> > On (2015-02-19 11:15), Jonathan Gray wrote:
> > > I think the entire block from the glx header should
> > > be kept especially the #ifndef otherwise the build
> > > will break when the headers in chromium are synced with Mesa.
> > >
> > > It would also make it easier to use the other parts for
> > > adding additional information later if needed.
> > >
> > > You seem to be missing a
> > > context->ReleaseCurrent(surface.get())
> > > in one of the error paths as well.
> > >
> > > On Wed, Feb 18, 2015 at 09:25:28PM +0100, Robert Nagy wrote:
> > > > Hi
> > > >
> > > > I've reworked what you did, because I like this method better than
> > > > what I did and commited earlier. I am currently running with this
> > > > without issues. As you can see I am using the python generated
> > > > bindings and instead of opening libGL I rely on what chrome has
> > > > already.
> > > >
> > > > Index: Makefile
> > > > ===================================================================
> > > > RCS file: /cvs/ports/www/chromium/Makefile,v
> > > > retrieving revision 1.201
> > > > diff -u -r1.201 Makefile
> > > > --- Makefile 15 Feb 2015 19:51:28 -0000 1.201
> > > > +++ Makefile 18 Feb 2015 20:23:24 -0000
> > > > @@ -7,7 +7,7 @@
> > > >  
> > > >  V= 40.0.2214.114
> > > >  DISTNAME= chromium-${V}
> > > > -REVISION= 0
> > > > +REVISION= 1
> > > >  
> > > >  CATEGORIES= www
> > > >  
> > > > @@ -90,6 +90,7 @@
> > > >   GYP_GENERATORS=ninja
> > > >  
> > > >  ALL_TARGET= chrome
> > > > +#ALL_TARGET= gpu_unittests
> > > >  
> > > >  BUILDDIR= ${WRKSRC}/out/${BUILDTYPE}
> > > >  
> > > > @@ -158,8 +159,6 @@
> > > >  do-build:
> > > >   @cd ${WRKSRC} && env -i ${MAKE_ENV} ninja \
> > > >   -j ${MAKE_JOBS} -C out/${BUILDTYPE} ${ALL_TARGET}
> > > > - ${CC} ${CLAGS} -o ${BUILDDIR}/gpuid -I${X11BASE}/include \
> > > > - -L${X11BASE}/lib ${FILESDIR}/gpuid.c -lGL
> > > >  
> > > >  do-install:
> > > >   ${INSTALL_DATA_DIR} ${PREFIX}/chrome
> > > > Index: files/chrome
> > > > ===================================================================
> > > > RCS file: /cvs/ports/www/chromium/files/chrome,v
> > > > retrieving revision 1.12
> > > > diff -u -r1.12 chrome
> > > > --- files/chrome 15 Feb 2015 19:51:28 -0000 1.12
> > > > +++ files/chrome 18 Feb 2015 20:23:24 -0000
> > > > @@ -40,6 +40,4 @@
> > > >  #
> > > >  [ -z ${LANG} ] && _l=en_US.UTF-8 || _l=${LANG}
> > > >  
> > > > -eval `/usr/local/chrome/gpuid`
> > > > -
> > > >  LANG=${_l} exec "/usr/local/chrome/chrome" "${@}"
> > > > Index: files/gpuid.c
> > > > ===================================================================
> > > > RCS file: files/gpuid.c
> > > > diff -N files/gpuid.c
> > > > --- files/gpuid.c 15 Feb 2015 19:51:28 -0000 1.1
> > > > +++ /dev/null 1 Jan 1970 00:00:00 -0000
> > > > @@ -1,86 +0,0 @@
> > > > -#include <GL/glx.h>
> > > > -#include <stdio.h>
> > > > -#include <string.h>
> > > > -
> > > > -int
> > > > -main(int argc, char *argv[])
> > > > -{
> > > > - Display        *dpy;
> > > > - int scrnum = 0;
> > > > - Window win;
> > > > - XSetWindowAttributes attr;
> > > > - Window root;
> > > > - GLXContext ctx = NULL;
> > > > - XVisualInfo    *visinfo;
> > > > - unsigned int vendor_id = 0x0000;
> > > > - unsigned int device_id = 0x0000;
> > > > - int attribSingle[] = {
> > > > -    GLX_RGBA,
> > > > -    GLX_RED_SIZE, 1,
> > > > -    GLX_GREEN_SIZE, 1,
> > > > -    GLX_BLUE_SIZE, 1,
> > > > -    None };
> > > > - int attribDouble[] = {
> > > > -    GLX_RGBA,
> > > > -    GLX_RED_SIZE, 1,
> > > > -    GLX_GREEN_SIZE, 1,
> > > > -    GLX_BLUE_SIZE, 1,
> > > > -    GLX_DOUBLEBUFFER,
> > > > -    None };
> > > > -
> > > > - dpy = XOpenDisplay(NULL);
> > > > - if (!dpy)
> > > > - goto exit;
> > > > -
> > > > - root = RootWindow(dpy, scrnum);
> > > > -
> > > > - visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
> > > > - if (!visinfo)
> > > > - visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
> > > > - if (visinfo)
> > > > - ctx = glXCreateContext(dpy, visinfo, NULL, False);
> > > > -
> > > > - if (!ctx)
> > > > - goto exit0;
> > > > -
> > > > - attr.background_pixel = attr.border_pixel = 0;
> > > > - attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
> > > > - attr.event_mask = StructureNotifyMask | ExposureMask;
> > > > - win = XCreateWindow(dpy, root, 0, 0, 100, 100,
> > > > -    0, visinfo->depth, InputOutput,
> > > > -    visinfo->visual, CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
> > > > -    &attr);
> > > > -
> > > > - if (glXMakeCurrent(dpy, win, ctx)) {
> > > > - const char     *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
> > > > - unsigned int v [3];
> > > > - PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger;
> > > > - queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > > > - glXGetProcAddressARB((const GLubyte *)
> > > > -      "glXQueryCurrentRendererIntegerMESA");
> > > > -
> > > > - if (!glXQueryVersion(dpy, NULL, NULL)) {
> > > > - goto exit1;
> > > > - }
> > > > - if (strstr(glxExtensions, "GLX_MESA_query_renderer")) {
> > > > - queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > > > - vendor_id = *v;
> > > > - queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > > > - device_id = *v;
> > > > - }
> > > > - }
> > > > -exit1:
> > > > - XDestroyWindow(dpy, win);
> > > > - glXDestroyContext(dpy, ctx);
> > > > -exit0:
> > > > - XFree(visinfo);
> > > > - XSync(dpy, 1);
> > > > -exit:
> > > > - printf("OPENBSD_GPU_VENDOR='0x%04x';\n", vendor_id);
> > > > - printf("export OPENBSD_GPU_VENDOR;\n");
> > > > - printf("OPENBSD_GPU_DEVICE='0x%04x';\n", device_id);
> > > > - printf("export OPENBSD_GPU_DEVICE;\n");
> > > > -
> > > > - XCloseDisplay(dpy);
> > > > - return 0;
> > > > -}
> > > > Index: patches/patch-gpu_config_gpu_info_collector_linux_cc
> > > > ===================================================================
> > > > RCS file: /cvs/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc,v
> > > > retrieving revision 1.1
> > > > diff -u -r1.1 patch-gpu_config_gpu_info_collector_linux_cc
> > > > --- patches/patch-gpu_config_gpu_info_collector_linux_cc 15 Feb 2015 19:51:28 -0000 1.1
> > > > +++ patches/patch-gpu_config_gpu_info_collector_linux_cc 18 Feb 2015 20:23:24 -0000
> > > > @@ -1,45 +1,14 @@
> > > >  $OpenBSD: patch-gpu_config_gpu_info_collector_linux_cc,v 1.1 2015/02/15 19:51:28 robert Exp $
> > > >  --- gpu/config/gpu_info_collector_linux.cc.orig.port Sun Feb 15 15:25:13 2015
> > > > -+++ gpu/config/gpu_info_collector_linux.cc Sun Feb 15 18:39:58 2015
> > > > -@@ -31,6 +31,7 @@ namespace gpu {
> > > > ++++ gpu/config/gpu_info_collector_linux.cc Wed Feb 18 20:23:51 2015
> > > > +@@ -75,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
> > > > + CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
> > > > +   DCHECK(gpu_info);
> > > >  
> > > > - namespace {
> > > > -
> > > > -+#if !defined(OS_BSD)
> > > > - // This checks if a system supports PCI bus.
> > > > - // We check the existence of /sys/bus/pci or /sys/bug/pci_express.
> > > > - bool IsPciSupported() {
> > > > -@@ -39,6 +40,7 @@ bool IsPciSupported() {
> > > > -   return (base::PathExists(pci_path) ||
> > > > -           base::PathExists(pcie_path));
> > > > - }
> > > > ++#if defined(OS_BSD)
> > > > ++  return (CollectMesaCardInfo(gpu_info));
> > > >  +#endif
> > > > -
> > > > - // Scan /etc/ati/amdpcsdb.default for "ReleaseVersion".
> > > > - // Return empty string on failing.
> > > > -@@ -79,6 +81,7 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > > > ++
> > > > + #if !defined(USE_LIBPCI)
> > > >     return kCollectInfoNonFatalFailure;
> > > >   #else
> > > > -
> > > > -+#if !defined(OS_BSD)
> > > > -   if (IsPciSupported() == false) {
> > > > -     VLOG(1) << "PCI bus scanning is not supported";
> > > > -     return kCollectInfoNonFatalFailure;
> > > > -@@ -148,6 +151,17 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > > > -   }
> > > > -
> > > > -   (libpci_loader.pci_cleanup)(access);
> > > > -+#else
> > > > -+  unsigned int vendor_id = 0x0000, device_id = 0x0000;
> > > > -+  char *vid, *did;
> > > > -+  if ((vid = getenv("OPENBSD_GPU_VENDOR")) != NULL)
> > > > -+    vendor_id = strtol(vid, NULL, 16);
> > > > -+  if ((did = getenv("OPENBSD_GPU_DEVICE")) != NULL)
> > > > -+    device_id = strtol(did, NULL, 16);
> > > > -+  bool primary_gpu_identified = true;
> > > > -+  gpu_info->gpu.vendor_id = vendor_id;
> > > > -+  gpu_info->gpu.device_id = device_id;
> > > > -+#endif
> > > > -   if (!primary_gpu_identified)
> > > > -     return kCollectInfoNonFatalFailure;
> > > > -   return kCollectInfoSuccess;
> > > > Index: patches/patch-gpu_config_gpu_info_collector_linux_h
> > > > ===================================================================
> > > > RCS file: patches/patch-gpu_config_gpu_info_collector_linux_h
> > > > diff -N patches/patch-gpu_config_gpu_info_collector_linux_h
> > > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > > +++ patches/patch-gpu_config_gpu_info_collector_linux_h 18 Feb 2015 20:23:24 -0000
> > > > @@ -0,0 +1,18 @@
> > > > +$OpenBSD$
> > > > +--- gpu/config/gpu_info_collector_linux.h.orig.port Wed Feb 18 17:58:41 2015
> > > > ++++ gpu/config/gpu_info_collector_linux.h Wed Feb 18 17:59:22 2015
> > > > +@@ -6,11 +6,14 @@
> > > > + #define GPU_CONFIG_GPU_INFO_COLLECTOR_LINUX_H_
> > > > +
> > > > + #include <string>
> > > > ++#include "gpu/config/gpu_info_collector.h"
> > > > +
> > > > + namespace gpu {
> > > > +
> > > > + // Queries for the driver version. Returns an empty string on failure.
> > > > + std::string CollectDriverVersionNVidia();
> > > > ++
> > > > ++CollectInfoResult CollectMesaCardInfo(GPUInfo *);
> > > > +
> > > > + }  // namespace gpu
> > > > +
> > > > Index: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > > ===================================================================
> > > > RCS file: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > > diff -N patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > > +++ patches/patch-gpu_config_gpu_info_collector_x11_cc 18 Feb 2015 20:23:24 -0000
> > > > @@ -0,0 +1,121 @@
> > > > +$OpenBSD$
> > > > +--- gpu/config/gpu_info_collector_x11.cc.orig.port Wed Feb 18 17:59:41 2015
> > > > ++++ gpu/config/gpu_info_collector_x11.cc Wed Feb 18 20:52:18 2015
> > > > +@@ -4,14 +4,54 @@
> > > > +
> > > > + #include <X11/Xlib.h>
> > > > +
> > > > ++#include "base/debug/trace_event.h"
> > > > + #include "base/logging.h"
> > > > + #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 (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
> > > > ++
> > > > ++#define GLX_RENDERER_VENDOR_ID_MESA     0x8183
> > > > ++#define GLX_RENDERER_DEVICE_ID_MESA     0x8184
> > > > ++
> > > > + namespace gpu {
> > > > +
> > > > ++scoped_refptr<gfx::GLSurface> InitializeGLSurface() {
> > > > ++  scoped_refptr<gfx::GLSurface> surface(
> > > > ++      gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()));
> > > > ++  if (!surface.get()) {
> > > > ++    LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
> > > > ++    return NULL;
> > > > ++  }
> > > > ++
> > > > ++  return surface;
> > > > ++}
> > > > ++
> > > > ++scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) {
> > > > ++
> > > > ++  scoped_refptr<gfx::GLContext> context(
> > > > ++      gfx::GLContext::CreateGLContext(NULL,
> > > > ++                                      surface,
> > > > ++                                      gfx::PreferIntegratedGpu));
> > > > ++  if (!context.get()) {
> > > > ++    LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
> > > > ++    return NULL;
> > > > ++  }
> > > > ++
> > > > ++  if (!context->MakeCurrent(surface)) {
> > > > ++    LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed";
> > > > ++    return NULL;
> > > > ++  }
> > > > ++
> > > > ++  return context;
> > > > ++}
> > > > ++
> > > > + // Use NVCtrl extention to query NV driver version.
> > > > + // Return empty string on failing.
> > > > + std::string CollectDriverVersionNVidia() {
> > > > +@@ -39,5 +79,62 @@ std::string CollectDriverVersionNVidia() {
> > > > +   }
> > > > +   return std::string();
> > > > + }
> > > > ++
> > > > ++CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
> > > > ++  TRACE_EVENT0("startup", "gpu_info_collector_x11::CollectMesaCardInfo");
> > > > ++  DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
> > > > ++
> > > > ++  unsigned int v[3];
> > > > ++
> > > > ++  Display* display = gfx::GetXDisplay();
> > > > ++  if (!display) {
> > > > ++    LOG(ERROR) << "XOpenDisplay failed.";
> > > > ++    return kCollectInfoNonFatalFailure;
> > > > ++  }
> > > > ++
> > > > ++  if (!gfx::GLSurface::InitializeOneOff()) {
> > > > ++    LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
> > > > ++    return kCollectInfoNonFatalFailure;
> > > > ++  }
> > > > ++
> > > > ++  if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
> > > > ++    return kCollectInfoNonFatalFailure;
> > > > ++
> > > > ++  scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface());
> > > > ++  if (!surface.get()) {
> > > > ++    LOG(ERROR) << "Could not create surface for info collection.";
> > > > ++    return kCollectInfoFatalFailure;
> > > > ++  }
> > > > ++
> > > > ++  scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
> > > > ++  if (!context.get()) {
> > > > ++    LOG(ERROR) << "Could not create context for info collection.";
> > > > ++    return kCollectInfoFatalFailure;
> > > > ++  }
> > > > ++
> > > > ++  std::string glx_extensions = glXQueryExtensionsString(display, 0);
> > > > ++  bool glx_query_render =
> > > > ++    glx_extensions.find("GLX_MESA_query_renderer") != std::string::npos;
> > > > ++  if (glx_query_render == false)
> > > > ++    return kCollectInfoNonFatalFailure;
> > > > ++
> > > > ++  PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > > > ++    glXGetProcAddressARB((const GLubyte *)
> > > > ++      "glXQueryCurrentRendererIntegerMESA");
> > > > ++
> > > > ++  GPUInfo::GPUDevice gpu;
> > > > ++
> > > > ++  queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > > > ++  gpu.vendor_id = v[0];
> > > > ++
> > > > ++  queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > > > ++  gpu.device_id = v[0];
> > > > ++
> > > > ++  gpu_info->gpu = gpu;
> > > > ++
> > > > ++  context->ReleaseCurrent(surface.get());
> > > > ++
> > > > ++  return kCollectInfoSuccess;
> > > > ++ }
> > > > +
> > > > + }  // namespace gpu
> > > > Index: patches/patch-ui_gl_generate_bindings_py
> > > > ===================================================================
> > > > RCS file: patches/patch-ui_gl_generate_bindings_py
> > > > diff -N patches/patch-ui_gl_generate_bindings_py
> > > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > > +++ patches/patch-ui_gl_generate_bindings_py 18 Feb 2015 20:23:25 -0000
> > > > @@ -0,0 +1,13 @@
> > > > +$OpenBSD$
> > > > +--- ui/gl/generate_bindings.py.orig.port Wed Feb 18 18:20:42 2015
> > > > ++++ ui/gl/generate_bindings.py Wed Feb 18 18:23:06 2015
> > > > +@@ -1245,6 +1245,9 @@ GLX_FUNCTIONS = [
> > > > +   'arguments':
> > > > +       'Display* dpy, GLXDrawable drawable, int32* numerator, '
> > > > +       'int32* denominator' },
> > > > ++{ 'return_type': '__GLXextFuncPtr',
> > > > ++  'names': ['glXGetProcAddressARB'],
> > > > ++  'arguments': 'const GLubyte* procName', },
> > > > + { 'return_type': 'void',
> > > > +   'names': ['glXGetSelectedEvent'],
> > > > +   'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', },
> > > > Index: pkg/PLIST
> > > > ===================================================================
> > > > RCS file: /cvs/ports/www/chromium/pkg/PLIST,v
> > > > retrieving revision 1.45
> > > > diff -u -r1.45 PLIST
> > > > --- pkg/PLIST 15 Feb 2015 19:51:28 -0000 1.45
> > > > +++ pkg/PLIST 18 Feb 2015 20:23:25 -0000
> > > > @@ -5,7 +5,6 @@
> > > >  @bin chrome/chrome
> > > >  chrome/chrome_100_percent.pak
> > > >  chrome/content_resources.pak
> > > > -@bin chrome/gpuid
> > > >  chrome/icudtl.dat
> > > >  chrome/keyboard_resources.pak
> > > >  chrome/libexif.so
> > >
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Jonathan Gray-11
Due to the patch you mentioned?

You could try the functions that don't require creating
a window/context I had in the initial mail to ports@.

ie use PFNGLXQUERYRENDERERINTEGERMESAPROC instead of
PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC and add the extra
arguments.

On Sun, Feb 22, 2015 at 06:51:33AM +0100, Robert Nagy wrote:

> Good to know, thanks. I am still fighting the crash, which happens
> when you open a dialog (print, save/open file). Something that I can't
> find a fix for....
>
> On (2015-02-22 16:35), Jonathan Gray wrote:
> > It might be worth checking that the values are not 0xffffffff before
> > using them as well.  That is the value the extension will return if the
> > vendor/device ids are not available or if a software renderer is used.
> >
> > On Thu, Feb 19, 2015 at 07:07:02AM +0100, Robert Nagy wrote:
> > > If the build breaks, I will notice right away, I don't
> > > want to have extra defines if not necessary.
> > > Yeah there are other problems as well, like crashing
> > > when opening a system dialog like printing, save file, etc.
> > >
> > > On (2015-02-19 11:15), Jonathan Gray wrote:
> > > > I think the entire block from the glx header should
> > > > be kept especially the #ifndef otherwise the build
> > > > will break when the headers in chromium are synced with Mesa.
> > > >
> > > > It would also make it easier to use the other parts for
> > > > adding additional information later if needed.
> > > >
> > > > You seem to be missing a
> > > > context->ReleaseCurrent(surface.get())
> > > > in one of the error paths as well.
> > > >
> > > > On Wed, Feb 18, 2015 at 09:25:28PM +0100, Robert Nagy wrote:
> > > > > Hi
> > > > >
> > > > > I've reworked what you did, because I like this method better than
> > > > > what I did and commited earlier. I am currently running with this
> > > > > without issues. As you can see I am using the python generated
> > > > > bindings and instead of opening libGL I rely on what chrome has
> > > > > already.
> > > > >
> > > > > Index: Makefile
> > > > > ===================================================================
> > > > > RCS file: /cvs/ports/www/chromium/Makefile,v
> > > > > retrieving revision 1.201
> > > > > diff -u -r1.201 Makefile
> > > > > --- Makefile 15 Feb 2015 19:51:28 -0000 1.201
> > > > > +++ Makefile 18 Feb 2015 20:23:24 -0000
> > > > > @@ -7,7 +7,7 @@
> > > > >  
> > > > >  V= 40.0.2214.114
> > > > >  DISTNAME= chromium-${V}
> > > > > -REVISION= 0
> > > > > +REVISION= 1
> > > > >  
> > > > >  CATEGORIES= www
> > > > >  
> > > > > @@ -90,6 +90,7 @@
> > > > >   GYP_GENERATORS=ninja
> > > > >  
> > > > >  ALL_TARGET= chrome
> > > > > +#ALL_TARGET= gpu_unittests
> > > > >  
> > > > >  BUILDDIR= ${WRKSRC}/out/${BUILDTYPE}
> > > > >  
> > > > > @@ -158,8 +159,6 @@
> > > > >  do-build:
> > > > >   @cd ${WRKSRC} && env -i ${MAKE_ENV} ninja \
> > > > >   -j ${MAKE_JOBS} -C out/${BUILDTYPE} ${ALL_TARGET}
> > > > > - ${CC} ${CLAGS} -o ${BUILDDIR}/gpuid -I${X11BASE}/include \
> > > > > - -L${X11BASE}/lib ${FILESDIR}/gpuid.c -lGL
> > > > >  
> > > > >  do-install:
> > > > >   ${INSTALL_DATA_DIR} ${PREFIX}/chrome
> > > > > Index: files/chrome
> > > > > ===================================================================
> > > > > RCS file: /cvs/ports/www/chromium/files/chrome,v
> > > > > retrieving revision 1.12
> > > > > diff -u -r1.12 chrome
> > > > > --- files/chrome 15 Feb 2015 19:51:28 -0000 1.12
> > > > > +++ files/chrome 18 Feb 2015 20:23:24 -0000
> > > > > @@ -40,6 +40,4 @@
> > > > >  #
> > > > >  [ -z ${LANG} ] && _l=en_US.UTF-8 || _l=${LANG}
> > > > >  
> > > > > -eval `/usr/local/chrome/gpuid`
> > > > > -
> > > > >  LANG=${_l} exec "/usr/local/chrome/chrome" "${@}"
> > > > > Index: files/gpuid.c
> > > > > ===================================================================
> > > > > RCS file: files/gpuid.c
> > > > > diff -N files/gpuid.c
> > > > > --- files/gpuid.c 15 Feb 2015 19:51:28 -0000 1.1
> > > > > +++ /dev/null 1 Jan 1970 00:00:00 -0000
> > > > > @@ -1,86 +0,0 @@
> > > > > -#include <GL/glx.h>
> > > > > -#include <stdio.h>
> > > > > -#include <string.h>
> > > > > -
> > > > > -int
> > > > > -main(int argc, char *argv[])
> > > > > -{
> > > > > - Display        *dpy;
> > > > > - int scrnum = 0;
> > > > > - Window win;
> > > > > - XSetWindowAttributes attr;
> > > > > - Window root;
> > > > > - GLXContext ctx = NULL;
> > > > > - XVisualInfo    *visinfo;
> > > > > - unsigned int vendor_id = 0x0000;
> > > > > - unsigned int device_id = 0x0000;
> > > > > - int attribSingle[] = {
> > > > > -    GLX_RGBA,
> > > > > -    GLX_RED_SIZE, 1,
> > > > > -    GLX_GREEN_SIZE, 1,
> > > > > -    GLX_BLUE_SIZE, 1,
> > > > > -    None };
> > > > > - int attribDouble[] = {
> > > > > -    GLX_RGBA,
> > > > > -    GLX_RED_SIZE, 1,
> > > > > -    GLX_GREEN_SIZE, 1,
> > > > > -    GLX_BLUE_SIZE, 1,
> > > > > -    GLX_DOUBLEBUFFER,
> > > > > -    None };
> > > > > -
> > > > > - dpy = XOpenDisplay(NULL);
> > > > > - if (!dpy)
> > > > > - goto exit;
> > > > > -
> > > > > - root = RootWindow(dpy, scrnum);
> > > > > -
> > > > > - visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
> > > > > - if (!visinfo)
> > > > > - visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
> > > > > - if (visinfo)
> > > > > - ctx = glXCreateContext(dpy, visinfo, NULL, False);
> > > > > -
> > > > > - if (!ctx)
> > > > > - goto exit0;
> > > > > -
> > > > > - attr.background_pixel = attr.border_pixel = 0;
> > > > > - attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
> > > > > - attr.event_mask = StructureNotifyMask | ExposureMask;
> > > > > - win = XCreateWindow(dpy, root, 0, 0, 100, 100,
> > > > > -    0, visinfo->depth, InputOutput,
> > > > > -    visinfo->visual, CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
> > > > > -    &attr);
> > > > > -
> > > > > - if (glXMakeCurrent(dpy, win, ctx)) {
> > > > > - const char     *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
> > > > > - unsigned int v [3];
> > > > > - PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger;
> > > > > - queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > > > > - glXGetProcAddressARB((const GLubyte *)
> > > > > -      "glXQueryCurrentRendererIntegerMESA");
> > > > > -
> > > > > - if (!glXQueryVersion(dpy, NULL, NULL)) {
> > > > > - goto exit1;
> > > > > - }
> > > > > - if (strstr(glxExtensions, "GLX_MESA_query_renderer")) {
> > > > > - queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > > > > - vendor_id = *v;
> > > > > - queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > > > > - device_id = *v;
> > > > > - }
> > > > > - }
> > > > > -exit1:
> > > > > - XDestroyWindow(dpy, win);
> > > > > - glXDestroyContext(dpy, ctx);
> > > > > -exit0:
> > > > > - XFree(visinfo);
> > > > > - XSync(dpy, 1);
> > > > > -exit:
> > > > > - printf("OPENBSD_GPU_VENDOR='0x%04x';\n", vendor_id);
> > > > > - printf("export OPENBSD_GPU_VENDOR;\n");
> > > > > - printf("OPENBSD_GPU_DEVICE='0x%04x';\n", device_id);
> > > > > - printf("export OPENBSD_GPU_DEVICE;\n");
> > > > > -
> > > > > - XCloseDisplay(dpy);
> > > > > - return 0;
> > > > > -}
> > > > > Index: patches/patch-gpu_config_gpu_info_collector_linux_cc
> > > > > ===================================================================
> > > > > RCS file: /cvs/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc,v
> > > > > retrieving revision 1.1
> > > > > diff -u -r1.1 patch-gpu_config_gpu_info_collector_linux_cc
> > > > > --- patches/patch-gpu_config_gpu_info_collector_linux_cc 15 Feb 2015 19:51:28 -0000 1.1
> > > > > +++ patches/patch-gpu_config_gpu_info_collector_linux_cc 18 Feb 2015 20:23:24 -0000
> > > > > @@ -1,45 +1,14 @@
> > > > >  $OpenBSD: patch-gpu_config_gpu_info_collector_linux_cc,v 1.1 2015/02/15 19:51:28 robert Exp $
> > > > >  --- gpu/config/gpu_info_collector_linux.cc.orig.port Sun Feb 15 15:25:13 2015
> > > > > -+++ gpu/config/gpu_info_collector_linux.cc Sun Feb 15 18:39:58 2015
> > > > > -@@ -31,6 +31,7 @@ namespace gpu {
> > > > > ++++ gpu/config/gpu_info_collector_linux.cc Wed Feb 18 20:23:51 2015
> > > > > +@@ -75,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
> > > > > + CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
> > > > > +   DCHECK(gpu_info);
> > > > >  
> > > > > - namespace {
> > > > > -
> > > > > -+#if !defined(OS_BSD)
> > > > > - // This checks if a system supports PCI bus.
> > > > > - // We check the existence of /sys/bus/pci or /sys/bug/pci_express.
> > > > > - bool IsPciSupported() {
> > > > > -@@ -39,6 +40,7 @@ bool IsPciSupported() {
> > > > > -   return (base::PathExists(pci_path) ||
> > > > > -           base::PathExists(pcie_path));
> > > > > - }
> > > > > ++#if defined(OS_BSD)
> > > > > ++  return (CollectMesaCardInfo(gpu_info));
> > > > >  +#endif
> > > > > -
> > > > > - // Scan /etc/ati/amdpcsdb.default for "ReleaseVersion".
> > > > > - // Return empty string on failing.
> > > > > -@@ -79,6 +81,7 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > > > > ++
> > > > > + #if !defined(USE_LIBPCI)
> > > > >     return kCollectInfoNonFatalFailure;
> > > > >   #else
> > > > > -
> > > > > -+#if !defined(OS_BSD)
> > > > > -   if (IsPciSupported() == false) {
> > > > > -     VLOG(1) << "PCI bus scanning is not supported";
> > > > > -     return kCollectInfoNonFatalFailure;
> > > > > -@@ -148,6 +151,17 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > > > > -   }
> > > > > -
> > > > > -   (libpci_loader.pci_cleanup)(access);
> > > > > -+#else
> > > > > -+  unsigned int vendor_id = 0x0000, device_id = 0x0000;
> > > > > -+  char *vid, *did;
> > > > > -+  if ((vid = getenv("OPENBSD_GPU_VENDOR")) != NULL)
> > > > > -+    vendor_id = strtol(vid, NULL, 16);
> > > > > -+  if ((did = getenv("OPENBSD_GPU_DEVICE")) != NULL)
> > > > > -+    device_id = strtol(did, NULL, 16);
> > > > > -+  bool primary_gpu_identified = true;
> > > > > -+  gpu_info->gpu.vendor_id = vendor_id;
> > > > > -+  gpu_info->gpu.device_id = device_id;
> > > > > -+#endif
> > > > > -   if (!primary_gpu_identified)
> > > > > -     return kCollectInfoNonFatalFailure;
> > > > > -   return kCollectInfoSuccess;
> > > > > Index: patches/patch-gpu_config_gpu_info_collector_linux_h
> > > > > ===================================================================
> > > > > RCS file: patches/patch-gpu_config_gpu_info_collector_linux_h
> > > > > diff -N patches/patch-gpu_config_gpu_info_collector_linux_h
> > > > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > > > +++ patches/patch-gpu_config_gpu_info_collector_linux_h 18 Feb 2015 20:23:24 -0000
> > > > > @@ -0,0 +1,18 @@
> > > > > +$OpenBSD$
> > > > > +--- gpu/config/gpu_info_collector_linux.h.orig.port Wed Feb 18 17:58:41 2015
> > > > > ++++ gpu/config/gpu_info_collector_linux.h Wed Feb 18 17:59:22 2015
> > > > > +@@ -6,11 +6,14 @@
> > > > > + #define GPU_CONFIG_GPU_INFO_COLLECTOR_LINUX_H_
> > > > > +
> > > > > + #include <string>
> > > > > ++#include "gpu/config/gpu_info_collector.h"
> > > > > +
> > > > > + namespace gpu {
> > > > > +
> > > > > + // Queries for the driver version. Returns an empty string on failure.
> > > > > + std::string CollectDriverVersionNVidia();
> > > > > ++
> > > > > ++CollectInfoResult CollectMesaCardInfo(GPUInfo *);
> > > > > +
> > > > > + }  // namespace gpu
> > > > > +
> > > > > Index: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > > > ===================================================================
> > > > > RCS file: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > > > diff -N patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > > > +++ patches/patch-gpu_config_gpu_info_collector_x11_cc 18 Feb 2015 20:23:24 -0000
> > > > > @@ -0,0 +1,121 @@
> > > > > +$OpenBSD$
> > > > > +--- gpu/config/gpu_info_collector_x11.cc.orig.port Wed Feb 18 17:59:41 2015
> > > > > ++++ gpu/config/gpu_info_collector_x11.cc Wed Feb 18 20:52:18 2015
> > > > > +@@ -4,14 +4,54 @@
> > > > > +
> > > > > + #include <X11/Xlib.h>
> > > > > +
> > > > > ++#include "base/debug/trace_event.h"
> > > > > + #include "base/logging.h"
> > > > > + #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 (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
> > > > > ++
> > > > > ++#define GLX_RENDERER_VENDOR_ID_MESA     0x8183
> > > > > ++#define GLX_RENDERER_DEVICE_ID_MESA     0x8184
> > > > > ++
> > > > > + namespace gpu {
> > > > > +
> > > > > ++scoped_refptr<gfx::GLSurface> InitializeGLSurface() {
> > > > > ++  scoped_refptr<gfx::GLSurface> surface(
> > > > > ++      gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()));
> > > > > ++  if (!surface.get()) {
> > > > > ++    LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
> > > > > ++    return NULL;
> > > > > ++  }
> > > > > ++
> > > > > ++  return surface;
> > > > > ++}
> > > > > ++
> > > > > ++scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) {
> > > > > ++
> > > > > ++  scoped_refptr<gfx::GLContext> context(
> > > > > ++      gfx::GLContext::CreateGLContext(NULL,
> > > > > ++                                      surface,
> > > > > ++                                      gfx::PreferIntegratedGpu));
> > > > > ++  if (!context.get()) {
> > > > > ++    LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
> > > > > ++    return NULL;
> > > > > ++  }
> > > > > ++
> > > > > ++  if (!context->MakeCurrent(surface)) {
> > > > > ++    LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed";
> > > > > ++    return NULL;
> > > > > ++  }
> > > > > ++
> > > > > ++  return context;
> > > > > ++}
> > > > > ++
> > > > > + // Use NVCtrl extention to query NV driver version.
> > > > > + // Return empty string on failing.
> > > > > + std::string CollectDriverVersionNVidia() {
> > > > > +@@ -39,5 +79,62 @@ std::string CollectDriverVersionNVidia() {
> > > > > +   }
> > > > > +   return std::string();
> > > > > + }
> > > > > ++
> > > > > ++CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
> > > > > ++  TRACE_EVENT0("startup", "gpu_info_collector_x11::CollectMesaCardInfo");
> > > > > ++  DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
> > > > > ++
> > > > > ++  unsigned int v[3];
> > > > > ++
> > > > > ++  Display* display = gfx::GetXDisplay();
> > > > > ++  if (!display) {
> > > > > ++    LOG(ERROR) << "XOpenDisplay failed.";
> > > > > ++    return kCollectInfoNonFatalFailure;
> > > > > ++  }
> > > > > ++
> > > > > ++  if (!gfx::GLSurface::InitializeOneOff()) {
> > > > > ++    LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
> > > > > ++    return kCollectInfoNonFatalFailure;
> > > > > ++  }
> > > > > ++
> > > > > ++  if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
> > > > > ++    return kCollectInfoNonFatalFailure;
> > > > > ++
> > > > > ++  scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface());
> > > > > ++  if (!surface.get()) {
> > > > > ++    LOG(ERROR) << "Could not create surface for info collection.";
> > > > > ++    return kCollectInfoFatalFailure;
> > > > > ++  }
> > > > > ++
> > > > > ++  scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
> > > > > ++  if (!context.get()) {
> > > > > ++    LOG(ERROR) << "Could not create context for info collection.";
> > > > > ++    return kCollectInfoFatalFailure;
> > > > > ++  }
> > > > > ++
> > > > > ++  std::string glx_extensions = glXQueryExtensionsString(display, 0);
> > > > > ++  bool glx_query_render =
> > > > > ++    glx_extensions.find("GLX_MESA_query_renderer") != std::string::npos;
> > > > > ++  if (glx_query_render == false)
> > > > > ++    return kCollectInfoNonFatalFailure;
> > > > > ++
> > > > > ++  PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > > > > ++    glXGetProcAddressARB((const GLubyte *)
> > > > > ++      "glXQueryCurrentRendererIntegerMESA");
> > > > > ++
> > > > > ++  GPUInfo::GPUDevice gpu;
> > > > > ++
> > > > > ++  queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > > > > ++  gpu.vendor_id = v[0];
> > > > > ++
> > > > > ++  queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > > > > ++  gpu.device_id = v[0];
> > > > > ++
> > > > > ++  gpu_info->gpu = gpu;
> > > > > ++
> > > > > ++  context->ReleaseCurrent(surface.get());
> > > > > ++
> > > > > ++  return kCollectInfoSuccess;
> > > > > ++ }
> > > > > +
> > > > > + }  // namespace gpu
> > > > > Index: patches/patch-ui_gl_generate_bindings_py
> > > > > ===================================================================
> > > > > RCS file: patches/patch-ui_gl_generate_bindings_py
> > > > > diff -N patches/patch-ui_gl_generate_bindings_py
> > > > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > > > +++ patches/patch-ui_gl_generate_bindings_py 18 Feb 2015 20:23:25 -0000
> > > > > @@ -0,0 +1,13 @@
> > > > > +$OpenBSD$
> > > > > +--- ui/gl/generate_bindings.py.orig.port Wed Feb 18 18:20:42 2015
> > > > > ++++ ui/gl/generate_bindings.py Wed Feb 18 18:23:06 2015
> > > > > +@@ -1245,6 +1245,9 @@ GLX_FUNCTIONS = [
> > > > > +   'arguments':
> > > > > +       'Display* dpy, GLXDrawable drawable, int32* numerator, '
> > > > > +       'int32* denominator' },
> > > > > ++{ 'return_type': '__GLXextFuncPtr',
> > > > > ++  'names': ['glXGetProcAddressARB'],
> > > > > ++  'arguments': 'const GLubyte* procName', },
> > > > > + { 'return_type': 'void',
> > > > > +   'names': ['glXGetSelectedEvent'],
> > > > > +   'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', },
> > > > > Index: pkg/PLIST
> > > > > ===================================================================
> > > > > RCS file: /cvs/ports/www/chromium/pkg/PLIST,v
> > > > > retrieving revision 1.45
> > > > > diff -u -r1.45 PLIST
> > > > > --- pkg/PLIST 15 Feb 2015 19:51:28 -0000 1.45
> > > > > +++ pkg/PLIST 18 Feb 2015 20:23:25 -0000
> > > > > @@ -5,7 +5,6 @@
> > > > >  @bin chrome/chrome
> > > > >  chrome/chrome_100_percent.pak
> > > > >  chrome/content_resources.pak
> > > > > -@bin chrome/gpuid
> > > > >  chrome/icudtl.dat
> > > > >  chrome/keyboard_resources.pak
> > > > >  chrome/libexif.so
> > > >
> > >
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: use GLX_MESA_query_renderer in chromium

Robert Nagy
Oh I missed that. I'll try.

On (2015-02-22 17:09), Jonathan Gray wrote:

> Due to the patch you mentioned?
>
> You could try the functions that don't require creating
> a window/context I had in the initial mail to ports@.
>
> ie use PFNGLXQUERYRENDERERINTEGERMESAPROC instead of
> PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC and add the extra
> arguments.
>
> On Sun, Feb 22, 2015 at 06:51:33AM +0100, Robert Nagy wrote:
> > Good to know, thanks. I am still fighting the crash, which happens
> > when you open a dialog (print, save/open file). Something that I can't
> > find a fix for....
> >
> > On (2015-02-22 16:35), Jonathan Gray wrote:
> > > It might be worth checking that the values are not 0xffffffff before
> > > using them as well.  That is the value the extension will return if the
> > > vendor/device ids are not available or if a software renderer is used.
> > >
> > > On Thu, Feb 19, 2015 at 07:07:02AM +0100, Robert Nagy wrote:
> > > > If the build breaks, I will notice right away, I don't
> > > > want to have extra defines if not necessary.
> > > > Yeah there are other problems as well, like crashing
> > > > when opening a system dialog like printing, save file, etc.
> > > >
> > > > On (2015-02-19 11:15), Jonathan Gray wrote:
> > > > > I think the entire block from the glx header should
> > > > > be kept especially the #ifndef otherwise the build
> > > > > will break when the headers in chromium are synced with Mesa.
> > > > >
> > > > > It would also make it easier to use the other parts for
> > > > > adding additional information later if needed.
> > > > >
> > > > > You seem to be missing a
> > > > > context->ReleaseCurrent(surface.get())
> > > > > in one of the error paths as well.
> > > > >
> > > > > On Wed, Feb 18, 2015 at 09:25:28PM +0100, Robert Nagy wrote:
> > > > > > Hi
> > > > > >
> > > > > > I've reworked what you did, because I like this method better than
> > > > > > what I did and commited earlier. I am currently running with this
> > > > > > without issues. As you can see I am using the python generated
> > > > > > bindings and instead of opening libGL I rely on what chrome has
> > > > > > already.
> > > > > >
> > > > > > Index: Makefile
> > > > > > ===================================================================
> > > > > > RCS file: /cvs/ports/www/chromium/Makefile,v
> > > > > > retrieving revision 1.201
> > > > > > diff -u -r1.201 Makefile
> > > > > > --- Makefile 15 Feb 2015 19:51:28 -0000 1.201
> > > > > > +++ Makefile 18 Feb 2015 20:23:24 -0000
> > > > > > @@ -7,7 +7,7 @@
> > > > > >  
> > > > > >  V= 40.0.2214.114
> > > > > >  DISTNAME= chromium-${V}
> > > > > > -REVISION= 0
> > > > > > +REVISION= 1
> > > > > >  
> > > > > >  CATEGORIES= www
> > > > > >  
> > > > > > @@ -90,6 +90,7 @@
> > > > > >   GYP_GENERATORS=ninja
> > > > > >  
> > > > > >  ALL_TARGET= chrome
> > > > > > +#ALL_TARGET= gpu_unittests
> > > > > >  
> > > > > >  BUILDDIR= ${WRKSRC}/out/${BUILDTYPE}
> > > > > >  
> > > > > > @@ -158,8 +159,6 @@
> > > > > >  do-build:
> > > > > >   @cd ${WRKSRC} && env -i ${MAKE_ENV} ninja \
> > > > > >   -j ${MAKE_JOBS} -C out/${BUILDTYPE} ${ALL_TARGET}
> > > > > > - ${CC} ${CLAGS} -o ${BUILDDIR}/gpuid -I${X11BASE}/include \
> > > > > > - -L${X11BASE}/lib ${FILESDIR}/gpuid.c -lGL
> > > > > >  
> > > > > >  do-install:
> > > > > >   ${INSTALL_DATA_DIR} ${PREFIX}/chrome
> > > > > > Index: files/chrome
> > > > > > ===================================================================
> > > > > > RCS file: /cvs/ports/www/chromium/files/chrome,v
> > > > > > retrieving revision 1.12
> > > > > > diff -u -r1.12 chrome
> > > > > > --- files/chrome 15 Feb 2015 19:51:28 -0000 1.12
> > > > > > +++ files/chrome 18 Feb 2015 20:23:24 -0000
> > > > > > @@ -40,6 +40,4 @@
> > > > > >  #
> > > > > >  [ -z ${LANG} ] && _l=en_US.UTF-8 || _l=${LANG}
> > > > > >  
> > > > > > -eval `/usr/local/chrome/gpuid`
> > > > > > -
> > > > > >  LANG=${_l} exec "/usr/local/chrome/chrome" "${@}"
> > > > > > Index: files/gpuid.c
> > > > > > ===================================================================
> > > > > > RCS file: files/gpuid.c
> > > > > > diff -N files/gpuid.c
> > > > > > --- files/gpuid.c 15 Feb 2015 19:51:28 -0000 1.1
> > > > > > +++ /dev/null 1 Jan 1970 00:00:00 -0000
> > > > > > @@ -1,86 +0,0 @@
> > > > > > -#include <GL/glx.h>
> > > > > > -#include <stdio.h>
> > > > > > -#include <string.h>
> > > > > > -
> > > > > > -int
> > > > > > -main(int argc, char *argv[])
> > > > > > -{
> > > > > > - Display        *dpy;
> > > > > > - int scrnum = 0;
> > > > > > - Window win;
> > > > > > - XSetWindowAttributes attr;
> > > > > > - Window root;
> > > > > > - GLXContext ctx = NULL;
> > > > > > - XVisualInfo    *visinfo;
> > > > > > - unsigned int vendor_id = 0x0000;
> > > > > > - unsigned int device_id = 0x0000;
> > > > > > - int attribSingle[] = {
> > > > > > -    GLX_RGBA,
> > > > > > -    GLX_RED_SIZE, 1,
> > > > > > -    GLX_GREEN_SIZE, 1,
> > > > > > -    GLX_BLUE_SIZE, 1,
> > > > > > -    None };
> > > > > > - int attribDouble[] = {
> > > > > > -    GLX_RGBA,
> > > > > > -    GLX_RED_SIZE, 1,
> > > > > > -    GLX_GREEN_SIZE, 1,
> > > > > > -    GLX_BLUE_SIZE, 1,
> > > > > > -    GLX_DOUBLEBUFFER,
> > > > > > -    None };
> > > > > > -
> > > > > > - dpy = XOpenDisplay(NULL);
> > > > > > - if (!dpy)
> > > > > > - goto exit;
> > > > > > -
> > > > > > - root = RootWindow(dpy, scrnum);
> > > > > > -
> > > > > > - visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
> > > > > > - if (!visinfo)
> > > > > > - visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
> > > > > > - if (visinfo)
> > > > > > - ctx = glXCreateContext(dpy, visinfo, NULL, False);
> > > > > > -
> > > > > > - if (!ctx)
> > > > > > - goto exit0;
> > > > > > -
> > > > > > - attr.background_pixel = attr.border_pixel = 0;
> > > > > > - attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
> > > > > > - attr.event_mask = StructureNotifyMask | ExposureMask;
> > > > > > - win = XCreateWindow(dpy, root, 0, 0, 100, 100,
> > > > > > -    0, visinfo->depth, InputOutput,
> > > > > > -    visinfo->visual, CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
> > > > > > -    &attr);
> > > > > > -
> > > > > > - if (glXMakeCurrent(dpy, win, ctx)) {
> > > > > > - const char     *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
> > > > > > - unsigned int v [3];
> > > > > > - PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger;
> > > > > > - queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > > > > > - glXGetProcAddressARB((const GLubyte *)
> > > > > > -      "glXQueryCurrentRendererIntegerMESA");
> > > > > > -
> > > > > > - if (!glXQueryVersion(dpy, NULL, NULL)) {
> > > > > > - goto exit1;
> > > > > > - }
> > > > > > - if (strstr(glxExtensions, "GLX_MESA_query_renderer")) {
> > > > > > - queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > > > > > - vendor_id = *v;
> > > > > > - queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > > > > > - device_id = *v;
> > > > > > - }
> > > > > > - }
> > > > > > -exit1:
> > > > > > - XDestroyWindow(dpy, win);
> > > > > > - glXDestroyContext(dpy, ctx);
> > > > > > -exit0:
> > > > > > - XFree(visinfo);
> > > > > > - XSync(dpy, 1);
> > > > > > -exit:
> > > > > > - printf("OPENBSD_GPU_VENDOR='0x%04x';\n", vendor_id);
> > > > > > - printf("export OPENBSD_GPU_VENDOR;\n");
> > > > > > - printf("OPENBSD_GPU_DEVICE='0x%04x';\n", device_id);
> > > > > > - printf("export OPENBSD_GPU_DEVICE;\n");
> > > > > > -
> > > > > > - XCloseDisplay(dpy);
> > > > > > - return 0;
> > > > > > -}
> > > > > > Index: patches/patch-gpu_config_gpu_info_collector_linux_cc
> > > > > > ===================================================================
> > > > > > RCS file: /cvs/ports/www/chromium/patches/patch-gpu_config_gpu_info_collector_linux_cc,v
> > > > > > retrieving revision 1.1
> > > > > > diff -u -r1.1 patch-gpu_config_gpu_info_collector_linux_cc
> > > > > > --- patches/patch-gpu_config_gpu_info_collector_linux_cc 15 Feb 2015 19:51:28 -0000 1.1
> > > > > > +++ patches/patch-gpu_config_gpu_info_collector_linux_cc 18 Feb 2015 20:23:24 -0000
> > > > > > @@ -1,45 +1,14 @@
> > > > > >  $OpenBSD: patch-gpu_config_gpu_info_collector_linux_cc,v 1.1 2015/02/15 19:51:28 robert Exp $
> > > > > >  --- gpu/config/gpu_info_collector_linux.cc.orig.port Sun Feb 15 15:25:13 2015
> > > > > > -+++ gpu/config/gpu_info_collector_linux.cc Sun Feb 15 18:39:58 2015
> > > > > > -@@ -31,6 +31,7 @@ namespace gpu {
> > > > > > ++++ gpu/config/gpu_info_collector_linux.cc Wed Feb 18 20:23:51 2015
> > > > > > +@@ -75,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
> > > > > > + CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
> > > > > > +   DCHECK(gpu_info);
> > > > > >  
> > > > > > - namespace {
> > > > > > -
> > > > > > -+#if !defined(OS_BSD)
> > > > > > - // This checks if a system supports PCI bus.
> > > > > > - // We check the existence of /sys/bus/pci or /sys/bug/pci_express.
> > > > > > - bool IsPciSupported() {
> > > > > > -@@ -39,6 +40,7 @@ bool IsPciSupported() {
> > > > > > -   return (base::PathExists(pci_path) ||
> > > > > > -           base::PathExists(pcie_path));
> > > > > > - }
> > > > > > ++#if defined(OS_BSD)
> > > > > > ++  return (CollectMesaCardInfo(gpu_info));
> > > > > >  +#endif
> > > > > > -
> > > > > > - // Scan /etc/ati/amdpcsdb.default for "ReleaseVersion".
> > > > > > - // Return empty string on failing.
> > > > > > -@@ -79,6 +81,7 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > > > > > ++
> > > > > > + #if !defined(USE_LIBPCI)
> > > > > >     return kCollectInfoNonFatalFailure;
> > > > > >   #else
> > > > > > -
> > > > > > -+#if !defined(OS_BSD)
> > > > > > -   if (IsPciSupported() == false) {
> > > > > > -     VLOG(1) << "PCI bus scanning is not supported";
> > > > > > -     return kCollectInfoNonFatalFailure;
> > > > > > -@@ -148,6 +151,17 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu
> > > > > > -   }
> > > > > > -
> > > > > > -   (libpci_loader.pci_cleanup)(access);
> > > > > > -+#else
> > > > > > -+  unsigned int vendor_id = 0x0000, device_id = 0x0000;
> > > > > > -+  char *vid, *did;
> > > > > > -+  if ((vid = getenv("OPENBSD_GPU_VENDOR")) != NULL)
> > > > > > -+    vendor_id = strtol(vid, NULL, 16);
> > > > > > -+  if ((did = getenv("OPENBSD_GPU_DEVICE")) != NULL)
> > > > > > -+    device_id = strtol(did, NULL, 16);
> > > > > > -+  bool primary_gpu_identified = true;
> > > > > > -+  gpu_info->gpu.vendor_id = vendor_id;
> > > > > > -+  gpu_info->gpu.device_id = device_id;
> > > > > > -+#endif
> > > > > > -   if (!primary_gpu_identified)
> > > > > > -     return kCollectInfoNonFatalFailure;
> > > > > > -   return kCollectInfoSuccess;
> > > > > > Index: patches/patch-gpu_config_gpu_info_collector_linux_h
> > > > > > ===================================================================
> > > > > > RCS file: patches/patch-gpu_config_gpu_info_collector_linux_h
> > > > > > diff -N patches/patch-gpu_config_gpu_info_collector_linux_h
> > > > > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > > > > +++ patches/patch-gpu_config_gpu_info_collector_linux_h 18 Feb 2015 20:23:24 -0000
> > > > > > @@ -0,0 +1,18 @@
> > > > > > +$OpenBSD$
> > > > > > +--- gpu/config/gpu_info_collector_linux.h.orig.port Wed Feb 18 17:58:41 2015
> > > > > > ++++ gpu/config/gpu_info_collector_linux.h Wed Feb 18 17:59:22 2015
> > > > > > +@@ -6,11 +6,14 @@
> > > > > > + #define GPU_CONFIG_GPU_INFO_COLLECTOR_LINUX_H_
> > > > > > +
> > > > > > + #include <string>
> > > > > > ++#include "gpu/config/gpu_info_collector.h"
> > > > > > +
> > > > > > + namespace gpu {
> > > > > > +
> > > > > > + // Queries for the driver version. Returns an empty string on failure.
> > > > > > + std::string CollectDriverVersionNVidia();
> > > > > > ++
> > > > > > ++CollectInfoResult CollectMesaCardInfo(GPUInfo *);
> > > > > > +
> > > > > > + }  // namespace gpu
> > > > > > +
> > > > > > Index: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > > > > ===================================================================
> > > > > > RCS file: patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > > > > diff -N patches/patch-gpu_config_gpu_info_collector_x11_cc
> > > > > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > > > > +++ patches/patch-gpu_config_gpu_info_collector_x11_cc 18 Feb 2015 20:23:24 -0000
> > > > > > @@ -0,0 +1,121 @@
> > > > > > +$OpenBSD$
> > > > > > +--- gpu/config/gpu_info_collector_x11.cc.orig.port Wed Feb 18 17:59:41 2015
> > > > > > ++++ gpu/config/gpu_info_collector_x11.cc Wed Feb 18 20:52:18 2015
> > > > > > +@@ -4,14 +4,54 @@
> > > > > > +
> > > > > > + #include <X11/Xlib.h>
> > > > > > +
> > > > > > ++#include "base/debug/trace_event.h"
> > > > > > + #include "base/logging.h"
> > > > > > + #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 (*PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);
> > > > > > ++
> > > > > > ++#define GLX_RENDERER_VENDOR_ID_MESA     0x8183
> > > > > > ++#define GLX_RENDERER_DEVICE_ID_MESA     0x8184
> > > > > > ++
> > > > > > + namespace gpu {
> > > > > > +
> > > > > > ++scoped_refptr<gfx::GLSurface> InitializeGLSurface() {
> > > > > > ++  scoped_refptr<gfx::GLSurface> surface(
> > > > > > ++      gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()));
> > > > > > ++  if (!surface.get()) {
> > > > > > ++    LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
> > > > > > ++    return NULL;
> > > > > > ++  }
> > > > > > ++
> > > > > > ++  return surface;
> > > > > > ++}
> > > > > > ++
> > > > > > ++scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) {
> > > > > > ++
> > > > > > ++  scoped_refptr<gfx::GLContext> context(
> > > > > > ++      gfx::GLContext::CreateGLContext(NULL,
> > > > > > ++                                      surface,
> > > > > > ++                                      gfx::PreferIntegratedGpu));
> > > > > > ++  if (!context.get()) {
> > > > > > ++    LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
> > > > > > ++    return NULL;
> > > > > > ++  }
> > > > > > ++
> > > > > > ++  if (!context->MakeCurrent(surface)) {
> > > > > > ++    LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed";
> > > > > > ++    return NULL;
> > > > > > ++  }
> > > > > > ++
> > > > > > ++  return context;
> > > > > > ++}
> > > > > > ++
> > > > > > + // Use NVCtrl extention to query NV driver version.
> > > > > > + // Return empty string on failing.
> > > > > > + std::string CollectDriverVersionNVidia() {
> > > > > > +@@ -39,5 +79,62 @@ std::string CollectDriverVersionNVidia() {
> > > > > > +   }
> > > > > > +   return std::string();
> > > > > > + }
> > > > > > ++
> > > > > > ++CollectInfoResult CollectMesaCardInfo(GPUInfo* gpu_info) {
> > > > > > ++  TRACE_EVENT0("startup", "gpu_info_collector_x11::CollectMesaCardInfo");
> > > > > > ++  DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
> > > > > > ++
> > > > > > ++  unsigned int v[3];
> > > > > > ++
> > > > > > ++  Display* display = gfx::GetXDisplay();
> > > > > > ++  if (!display) {
> > > > > > ++    LOG(ERROR) << "XOpenDisplay failed.";
> > > > > > ++    return kCollectInfoNonFatalFailure;
> > > > > > ++  }
> > > > > > ++
> > > > > > ++  if (!gfx::GLSurface::InitializeOneOff()) {
> > > > > > ++    LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
> > > > > > ++    return kCollectInfoNonFatalFailure;
> > > > > > ++  }
> > > > > > ++
> > > > > > ++  if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
> > > > > > ++    return kCollectInfoNonFatalFailure;
> > > > > > ++
> > > > > > ++  scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface());
> > > > > > ++  if (!surface.get()) {
> > > > > > ++    LOG(ERROR) << "Could not create surface for info collection.";
> > > > > > ++    return kCollectInfoFatalFailure;
> > > > > > ++  }
> > > > > > ++
> > > > > > ++  scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
> > > > > > ++  if (!context.get()) {
> > > > > > ++    LOG(ERROR) << "Could not create context for info collection.";
> > > > > > ++    return kCollectInfoFatalFailure;
> > > > > > ++  }
> > > > > > ++
> > > > > > ++  std::string glx_extensions = glXQueryExtensionsString(display, 0);
> > > > > > ++  bool glx_query_render =
> > > > > > ++    glx_extensions.find("GLX_MESA_query_renderer") != std::string::npos;
> > > > > > ++  if (glx_query_render == false)
> > > > > > ++    return kCollectInfoNonFatalFailure;
> > > > > > ++
> > > > > > ++  PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
> > > > > > ++    glXGetProcAddressARB((const GLubyte *)
> > > > > > ++      "glXQueryCurrentRendererIntegerMESA");
> > > > > > ++
> > > > > > ++  GPUInfo::GPUDevice gpu;
> > > > > > ++
> > > > > > ++  queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v);
> > > > > > ++  gpu.vendor_id = v[0];
> > > > > > ++
> > > > > > ++  queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v);
> > > > > > ++  gpu.device_id = v[0];
> > > > > > ++
> > > > > > ++  gpu_info->gpu = gpu;
> > > > > > ++
> > > > > > ++  context->ReleaseCurrent(surface.get());
> > > > > > ++
> > > > > > ++  return kCollectInfoSuccess;
> > > > > > ++ }
> > > > > > +
> > > > > > + }  // namespace gpu
> > > > > > Index: patches/patch-ui_gl_generate_bindings_py
> > > > > > ===================================================================
> > > > > > RCS file: patches/patch-ui_gl_generate_bindings_py
> > > > > > diff -N patches/patch-ui_gl_generate_bindings_py
> > > > > > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > > > > > +++ patches/patch-ui_gl_generate_bindings_py 18 Feb 2015 20:23:25 -0000
> > > > > > @@ -0,0 +1,13 @@
> > > > > > +$OpenBSD$
> > > > > > +--- ui/gl/generate_bindings.py.orig.port Wed Feb 18 18:20:42 2015
> > > > > > ++++ ui/gl/generate_bindings.py Wed Feb 18 18:23:06 2015
> > > > > > +@@ -1245,6 +1245,9 @@ GLX_FUNCTIONS = [
> > > > > > +   'arguments':
> > > > > > +       'Display* dpy, GLXDrawable drawable, int32* numerator, '
> > > > > > +       'int32* denominator' },
> > > > > > ++{ 'return_type': '__GLXextFuncPtr',
> > > > > > ++  'names': ['glXGetProcAddressARB'],
> > > > > > ++  'arguments': 'const GLubyte* procName', },
> > > > > > + { 'return_type': 'void',
> > > > > > +   'names': ['glXGetSelectedEvent'],
> > > > > > +   'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', },
> > > > > > Index: pkg/PLIST
> > > > > > ===================================================================
> > > > > > RCS file: /cvs/ports/www/chromium/pkg/PLIST,v
> > > > > > retrieving revision 1.45
> > > > > > diff -u -r1.45 PLIST
> > > > > > --- pkg/PLIST 15 Feb 2015 19:51:28 -0000 1.45
> > > > > > +++ pkg/PLIST 18 Feb 2015 20:23:25 -0000
> > > > > > @@ -5,7 +5,6 @@
> > > > > >  @bin chrome/chrome
> > > > > >  chrome/chrome_100_percent.pak
> > > > > >  chrome/content_resources.pak
> > > > > > -@bin chrome/gpuid
> > > > > >  chrome/icudtl.dat
> > > > > >  chrome/keyboard_resources.pak
> > > > > >  chrome/libexif.so
> > > > >
> > > >
> > >
> >
>