Skip to content

Commit

Permalink
Display GL window system binding information in about:gpu
Browse files Browse the repository at this point in the history
This patch adds information about the GL window system binding layer
implementation to about:gpu. Depending on which binding layer is used,
the following information is displayed:

- EGL: vendor, version, extension string
- GLX: vendor, version, extension string
- WGL: extension string

TEST=Check that the above shows up in about:gpu

Review URL: https://chromiumcodereview.appspot.com/15890002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203167 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
skyostil@chromium.org committed May 30, 2013
1 parent 76a1c58 commit 4589503
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 0 deletions.
6 changes: 6 additions & 0 deletions content/browser/gpu/gpu_internals_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ base::DictionaryValue* GpuInfoAsDictionaryValue() {
gpu_info.gl_version_string));
basic_info->Append(NewDescriptionValuePair("GL_EXTENSIONS",
gpu_info.gl_extensions));
basic_info->Append(NewDescriptionValuePair("Window system binding vendor",
gpu_info.gl_ws_vendor));
basic_info->Append(NewDescriptionValuePair("Window system binding version",
gpu_info.gl_ws_version));
basic_info->Append(NewDescriptionValuePair("Window system binding extensions",
gpu_info.gl_ws_extensions));

base::DictionaryValue* info = new base::DictionaryValue();
info->Set("basic_info", basic_info);
Expand Down
3 changes: 3 additions & 0 deletions content/common/gpu/gpu_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::GPUInfo)
IPC_STRUCT_TRAITS_MEMBER(gl_vendor)
IPC_STRUCT_TRAITS_MEMBER(gl_renderer)
IPC_STRUCT_TRAITS_MEMBER(gl_extensions)
IPC_STRUCT_TRAITS_MEMBER(gl_ws_vendor)
IPC_STRUCT_TRAITS_MEMBER(gl_ws_version)
IPC_STRUCT_TRAITS_MEMBER(gl_ws_extensions)
IPC_STRUCT_TRAITS_MEMBER(can_lose_context)
IPC_STRUCT_TRAITS_MEMBER(gpu_accessible)
IPC_STRUCT_TRAITS_MEMBER(performance_stats)
Expand Down
9 changes: 9 additions & 0 deletions gpu/config/gpu_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ struct GPU_EXPORT GPUInfo {
// The GL_EXTENSIONS string. "" if we are not using OpenGL.
std::string gl_extensions;

// GL window system binding vendor. "" if not available.
std::string gl_ws_vendor;

// GL window system binding version. "" if not available.
std::string gl_ws_version;

// GL window system binding extensions. "" if not available.
std::string gl_ws_extensions;

// The device semantics, i.e. whether the Vista and Windows 7 specific
// semantics are available.
bool can_lose_context;
Expand Down
12 changes: 12 additions & 0 deletions gpu/config/gpu_info_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/strings/string_split.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"

namespace {
Expand Down Expand Up @@ -99,6 +100,14 @@ bool CollectGraphicsInfoGL(GPUInfo* gpu_info) {
gpu_info->gl_extensions = GetGLString(GL_EXTENSIONS);
gpu_info->gl_version_string = GetGLString(GL_VERSION);
std::string glsl_version_string = GetGLString(GL_SHADING_LANGUAGE_VERSION);

gfx::GLWindowSystemBindingInfo window_system_binding_info;
if (GetGLWindowSystemBindingInfo(&window_system_binding_info)) {
gpu_info->gl_ws_vendor = window_system_binding_info.vendor;
gpu_info->gl_ws_version = window_system_binding_info.version;
gpu_info->gl_ws_extensions = window_system_binding_info.extensions;
}

// TODO(kbr): remove once the destruction of a current context automatically
// clears the current context.
context->ReleaseCurrent(surface.get());
Expand All @@ -123,6 +132,9 @@ void MergeGPUInfoGL(GPUInfo* basic_gpu_info,
context_gpu_info.pixel_shader_version;
basic_gpu_info->vertex_shader_version =
context_gpu_info.vertex_shader_version;
basic_gpu_info->gl_ws_vendor = context_gpu_info.gl_ws_vendor;
basic_gpu_info->gl_ws_version = context_gpu_info.gl_ws_version;
basic_gpu_info->gl_ws_extensions = context_gpu_info.gl_ws_extensions;

if (!context_gpu_info.driver_vendor.empty())
basic_gpu_info->driver_vendor = context_gpu_info.driver_vendor;
Expand Down
3 changes: 3 additions & 0 deletions gpu/config/gpu_info_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ TEST(GPUInfoBasicTest, EmptyGPUInfo) {
EXPECT_EQ(gpu_info.gl_vendor, "");
EXPECT_EQ(gpu_info.gl_renderer, "");
EXPECT_EQ(gpu_info.gl_extensions, "");
EXPECT_EQ(gpu_info.gl_ws_vendor, "");
EXPECT_EQ(gpu_info.gl_ws_version, "");
EXPECT_EQ(gpu_info.gl_ws_extensions, "");
EXPECT_EQ(gpu_info.can_lose_context, false);
}

Expand Down
16 changes: 16 additions & 0 deletions ui/gl/gl_egl_api_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "ui/gl/gl_egl_api_implementation.h"
#include "ui/gl/gl_implementation.h"

namespace gfx {

Expand Down Expand Up @@ -64,6 +65,21 @@ void RealEGLApi::Initialize(DriverEGL* driver) {
TraceEGLApi::~TraceEGLApi() {
}

bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) {
EGLDisplay display = eglGetCurrentDisplay();
const char* vendor = eglQueryString(display, EGL_VENDOR);
const char* version = eglQueryString(display, EGL_VERSION);
const char* extensions = eglQueryString(display, EGL_EXTENSIONS);
*info = GLWindowSystemBindingInfo();
if (vendor)
info->vendor = vendor;
if (version)
info->version = version;
if (extensions)
info->extensions = extensions;
return true;
}

} // namespace gfx


2 changes: 2 additions & 0 deletions ui/gl/gl_egl_api_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
namespace gfx {

class GLContext;
struct GLWindowSystemBindingInfo;

void InitializeGLBindingsEGL();
void InitializeGLExtensionBindingsEGL(GLContext* context);
void InitializeDebugGLBindingsEGL();
void ClearGLBindingsEGL();
bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info);

class GL_EXPORT EGLApiBase : public EGLApi {
public:
Expand Down
20 changes: 20 additions & 0 deletions ui/gl/gl_glx_api_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "ui/gl/gl_glx_api_implementation.h"
#include "ui/gl/gl_implementation.h"

namespace gfx {

Expand Down Expand Up @@ -64,6 +65,25 @@ void RealGLXApi::Initialize(DriverGLX* driver) {
TraceGLXApi::~TraceGLXApi() {
}

bool GetGLWindowSystemBindingInfoGLX(GLWindowSystemBindingInfo* info) {
Display* display = glXGetCurrentDisplay();
const int kDefaultScreen = 0;
const char* vendor =
glXQueryServerString(display, kDefaultScreen, GLX_VENDOR);
const char* version =
glXQueryServerString(display, kDefaultScreen, GLX_VERSION);
const char* extensions =
glXQueryServerString(display, kDefaultScreen, GLX_EXTENSIONS);
*info = GLWindowSystemBindingInfo();
if (vendor)
info->vendor = vendor;
if (version)
info->version = version;
if (extensions)
info->extensions = extensions;
return true;
}

} // namespace gfx


2 changes: 2 additions & 0 deletions ui/gl/gl_glx_api_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
namespace gfx {

class GLContext;
struct GLWindowSystemBindingInfo;

void InitializeGLBindingsGLX();
void InitializeGLExtensionBindingsGLX(GLContext* context);
void InitializeDebugGLBindingsGLX();
void ClearGLBindingsGLX();
bool GetGLWindowSystemBindingInfoGLX(GLWindowSystemBindingInfo* info);

class GL_EXPORT GLXApiBase : public GLXApi {
public:
Expand Down
10 changes: 10 additions & 0 deletions ui/gl/gl_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ enum GLImplementation {
kGLImplementationMockGL
};

struct GLWindowSystemBindingInfo {
std::string vendor;
std::string version;
std::string extensions;
};

void GetAllowedGLImplementations(std::vector<GLImplementation>* impls);

#if defined(OS_WIN)
Expand Down Expand Up @@ -80,6 +86,10 @@ void* GetGLCoreProcAddress(const char* name);
// Find an entry point in the current GL implementation.
void* GetGLProcAddress(const char* name);

// Return information about the GL window system binding implementation (e.g.,
// EGL, GLX, WGL). Returns true if the information was retrieved successfully.
GL_EXPORT bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info);

} // namespace gfx

#endif // UI_GL_GL_IMPLEMENTATION_H_
10 changes: 10 additions & 0 deletions ui/gl/gl_implementation_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,14 @@ void ClearGLBindings() {
UnloadGLNativeLibraries();
}

bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2:
return GetGLWindowSystemBindingInfoEGL(info);
default:
return false;
}
return false;
}

} // namespace gfx
4 changes: 4 additions & 0 deletions ui/gl/gl_implementation_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,8 @@ void ClearGLBindings() {
UnloadGLNativeLibraries();
}

bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
return false;
}

} // namespace gfx
12 changes: 12 additions & 0 deletions ui/gl/gl_implementation_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,16 @@ void ClearGLBindings() {
UnloadGLNativeLibraries();
}

bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL:
return GetGLWindowSystemBindingInfoWGL(info);
case kGLImplementationEGLGLES2:
return GetGLWindowSystemBindingInfoEGL(info);
default:
return false;
}
return false;
}

} // namespace gfx
12 changes: 12 additions & 0 deletions ui/gl/gl_implementation_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,16 @@ void ClearGLBindings() {
UnloadGLNativeLibraries();
}

bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL:
return GetGLWindowSystemBindingInfoGLX(info);
case kGLImplementationEGLGLES2:
return GetGLWindowSystemBindingInfoEGL(info);
default:
return false;
}
return false;
}

} // namespace gfx
9 changes: 9 additions & 0 deletions ui/gl/gl_wgl_api_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "ui/gl/gl_wgl_api_implementation.h"
#include "ui/gl/gl_implementation.h"

namespace gfx {

Expand Down Expand Up @@ -64,6 +65,14 @@ void RealWGLApi::Initialize(DriverWGL* driver) {
TraceWGLApi::~TraceWGLApi() {
}

bool GetGLWindowSystemBindingInfoWGL(GLWindowSystemBindingInfo* info) {
const char* extensions = wglGetExtensionsStringEXT();
*info = GLWindowSystemBindingInfo();
if (extensions)
info->extensions = extensions;
return true;
}

} // namespace gfx


2 changes: 2 additions & 0 deletions ui/gl/gl_wgl_api_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
namespace gfx {

class GLContext;
struct GLWindowSystemBindingInfo;

void InitializeGLBindingsWGL();
void InitializeGLExtensionBindingsWGL(GLContext* context);
void InitializeDebugGLBindingsWGL();
void ClearGLBindingsWGL();
bool GetGLWindowSystemBindingInfoWGL(GLWindowSystemBindingInfo* info);

class GL_EXPORT WGLApiBase : public WGLApi {
public:
Expand Down

0 comments on commit 4589503

Please sign in to comment.