summaryrefslogtreecommitdiffstats
path: root/ui/gl
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 05:21:12 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 05:21:12 +0000
commitb8f1d48cde7936b0de0ddd73393beea9cce6c353 (patch)
tree9596d3f14a7c2d98e1da1d2f150951f204cd9d7e /ui/gl
parent128ef148febd3ffe1a2100a0fe07a68e8f4b3b1c (diff)
downloadchromium_src-b8f1d48cde7936b0de0ddd73393beea9cce6c353.zip
chromium_src-b8f1d48cde7936b0de0ddd73393beea9cce6c353.tar.gz
chromium_src-b8f1d48cde7936b0de0ddd73393beea9cce6c353.tar.bz2
Add TRACE calls for all gpu driver calls
Adds a switch --enable-gpu-service-tracing that calls TRACE on every gpu-process call into the GL driver. BUG=none Review URL: https://chromiumcodereview.appspot.com/12207003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181212 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gl')
-rwxr-xr-xui/gl/generate_bindings.py27
-rw-r--r--ui/gl/gl_egl_api_implementation.cc3
-rw-r--r--ui/gl/gl_egl_api_implementation.h16
-rw-r--r--ui/gl/gl_gl_api_implementation.cc25
-rw-r--r--ui/gl/gl_gl_api_implementation.h15
-rw-r--r--ui/gl/gl_glx_api_implementation.cc3
-rw-r--r--ui/gl/gl_glx_api_implementation.h15
-rw-r--r--ui/gl/gl_osmesa_api_implementation.cc3
-rw-r--r--ui/gl/gl_osmesa_api_implementation.h15
-rw-r--r--ui/gl/gl_switches.cc17
-rw-r--r--ui/gl/gl_switches.h4
-rw-r--r--ui/gl/gl_wgl_api_implementation.cc3
-rw-r--r--ui/gl/gl_wgl_api_implementation.h15
13 files changed, 158 insertions, 3 deletions
diff --git a/ui/gl/generate_bindings.py b/ui/gl/generate_bindings.py
index d8e6866..8818c87 100755
--- a/ui/gl/generate_bindings.py
+++ b/ui/gl/generate_bindings.py
@@ -1347,6 +1347,7 @@ def GenerateSource(file, functions, set_name, used_extension_functions):
// This file is automatically generated.
#include <string>
+#include "base/debug/trace_event.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
@@ -1510,7 +1511,7 @@ namespace gfx {
}
""" % set_name.upper())
- # Write RealGLApi functions
+ # Write GLApiBase functions
for func in functions:
names = func['names']
return_type = func['return_type']
@@ -1533,6 +1534,30 @@ namespace gfx {
(function_name, argument_names))
file.write('}\n')
+ # Write TraceGLApi functions
+ for func in functions:
+ names = func['names']
+ return_type = func['return_type']
+ arguments = func['arguments']
+ file.write('\n')
+ file.write('%s Trace%sApi::%sFn(%s) {\n' %
+ (return_type, set_name.upper(), names[0], arguments))
+ argument_names = re.sub(
+ r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments)
+ argument_names = re.sub(
+ r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names)
+ if argument_names == 'void' or argument_names == '':
+ argument_names = ''
+ function_name = names[0]
+ file.write(' TRACE_EVENT0("gpu", "TraceGLAPI::%s")\n' % function_name)
+ if return_type == 'void':
+ file.write(' %s_api_->%sFn(%s);\n' %
+ (set_name.lower(), function_name, argument_names))
+ else:
+ file.write(' return %s_api_->%sFn(%s);\n' %
+ (set_name.lower(), function_name, argument_names))
+ file.write('}\n')
+
file.write('\n')
file.write('} // namespace gfx\n')
diff --git a/ui/gl/gl_egl_api_implementation.cc b/ui/gl/gl_egl_api_implementation.cc
index 35994d6..ba3e9cf 100644
--- a/ui/gl/gl_egl_api_implementation.cc
+++ b/ui/gl/gl_egl_api_implementation.cc
@@ -61,6 +61,9 @@ void RealEGLApi::Initialize(DriverEGL* driver) {
InitializeBase(driver);
}
+TraceEGLApi::~TraceEGLApi() {
+}
+
} // namespace gfx
diff --git a/ui/gl/gl_egl_api_implementation.h b/ui/gl/gl_egl_api_implementation.h
index 457f60e..cbc92e5 100644
--- a/ui/gl/gl_egl_api_implementation.h
+++ b/ui/gl/gl_egl_api_implementation.h
@@ -40,6 +40,22 @@ class GL_EXPORT RealEGLApi : public EGLApiBase {
void Initialize(DriverEGL* driver);
};
+
+// Inserts a TRACE for every EGL call.
+class GL_EXPORT TraceEGLApi : public EGLApi {
+ public:
+ TraceEGLApi(EGLApi* egl_api) : egl_api_(egl_api) { }
+ virtual ~TraceEGLApi();
+
+ // Include the auto-generated part of this class. We split this because
+ // it means we can easily edit the non-auto generated parts right here in
+ // this file instead of having to edit some template or the code generator.
+ #include "gl_bindings_api_autogen_egl.h"
+
+ private:
+ EGLApi* egl_api_;
+};
+
} // namespace gfx
#endif // UI_GL_EGL_API_IMPLEMENTATION_H_
diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc
index 672f1ea..303ae1d 100644
--- a/ui/gl/gl_gl_api_implementation.cc
+++ b/ui/gl/gl_gl_api_implementation.cc
@@ -7,21 +7,34 @@
#include <algorithm>
#include <vector>
+#include "base/command_line.h"
#include "base/string_util.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_state_restorer.h"
#include "ui/gl/gl_surface.h"
+#include "ui/gl/gl_switches.h"
namespace gfx {
-RealGLApi* g_real_gl;
+// The GL Api being used. This could be g_real_gl or gl_trace_gl
+static GLApi* g_gl;
+// A GL Api that calls directly into the driver.
+static RealGLApi* g_real_gl;
+// A GL Api that calls TRACE and then calls another GL api.
+static TraceGLApi* g_trace_gl;
void InitializeGLBindingsGL() {
g_driver_gl.InitializeBindings();
if (!g_real_gl) {
g_real_gl = new RealGLApi();
+ g_trace_gl = new TraceGLApi(g_real_gl);
}
g_real_gl->Initialize(&g_driver_gl);
+ g_gl = g_real_gl;
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableGPUServiceTracing)) {
+ g_gl = g_trace_gl;
+ }
SetGLToRealGLApi();
}
@@ -34,7 +47,7 @@ void SetGLApi(GLApi* api) {
}
void SetGLToRealGLApi() {
- SetGLApi(g_real_gl);
+ SetGLApi(g_gl);
}
void InitializeGLExtensionBindingsGL(GLContext* context) {
@@ -50,6 +63,11 @@ void ClearGLBindingsGL() {
delete g_real_gl;
g_real_gl = NULL;
}
+ if (g_trace_gl) {
+ delete g_trace_gl;
+ g_trace_gl = NULL;
+ }
+ g_gl = NULL;
g_current_gl_context = NULL;
g_driver_gl.ClearBindings();
}
@@ -81,6 +99,9 @@ void RealGLApi::Initialize(DriverGL* driver) {
InitializeBase(driver);
}
+TraceGLApi::~TraceGLApi() {
+}
+
VirtualGLApi::VirtualGLApi()
: real_context_(NULL),
current_context_(NULL) {
diff --git a/ui/gl/gl_gl_api_implementation.h b/ui/gl/gl_gl_api_implementation.h
index 8226f89..579739e 100644
--- a/ui/gl/gl_gl_api_implementation.h
+++ b/ui/gl/gl_gl_api_implementation.h
@@ -49,6 +49,21 @@ class GL_EXPORT RealGLApi : public GLApiBase {
void Initialize(DriverGL* driver);
};
+// Inserts a TRACE for every GL call.
+class GL_EXPORT TraceGLApi : public GLApi {
+ public:
+ TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { }
+ virtual ~TraceGLApi();
+
+ // Include the auto-generated part of this class. We split this because
+ // it means we can easily edit the non-auto generated parts right here in
+ // this file instead of having to edit some template or the code generator.
+ #include "gl_bindings_api_autogen_gl.h"
+
+ private:
+ GLApi* gl_api_;
+};
+
// Implementents the GL API using co-operative state restoring.
// Assumes there is only one real GL context and that multiple virtual contexts
// are implemented above it. Restores the needed state from the current context.
diff --git a/ui/gl/gl_glx_api_implementation.cc b/ui/gl/gl_glx_api_implementation.cc
index dc145ad..f8e75a2 100644
--- a/ui/gl/gl_glx_api_implementation.cc
+++ b/ui/gl/gl_glx_api_implementation.cc
@@ -61,6 +61,9 @@ void RealGLXApi::Initialize(DriverGLX* driver) {
InitializeBase(driver);
}
+TraceGLXApi::~TraceGLXApi() {
+}
+
} // namespace gfx
diff --git a/ui/gl/gl_glx_api_implementation.h b/ui/gl/gl_glx_api_implementation.h
index 4ce4fdc..04249f3 100644
--- a/ui/gl/gl_glx_api_implementation.h
+++ b/ui/gl/gl_glx_api_implementation.h
@@ -40,6 +40,21 @@ class GL_EXPORT RealGLXApi : public GLXApiBase {
void Initialize(DriverGLX* driver);
};
+// Inserts a TRACE for every GLX call.
+class GL_EXPORT TraceGLXApi : public GLXApi {
+ public:
+ TraceGLXApi(GLXApi* glx_api) : glx_api_(glx_api) { }
+ virtual ~TraceGLXApi();
+
+ // Include the auto-generated part of this class. We split this because
+ // it means we can easily edit the non-auto generated parts right here in
+ // this file instead of having to edit some template or the code generator.
+ #include "gl_bindings_api_autogen_glx.h"
+
+ private:
+ GLXApi* glx_api_;
+};
+
} // namespace gfx
#endif // UI_GL_GLX_API_IMPLEMENTATION_H_
diff --git a/ui/gl/gl_osmesa_api_implementation.cc b/ui/gl/gl_osmesa_api_implementation.cc
index 4d8fc2a..5b32d22 100644
--- a/ui/gl/gl_osmesa_api_implementation.cc
+++ b/ui/gl/gl_osmesa_api_implementation.cc
@@ -61,6 +61,9 @@ void RealOSMESAApi::Initialize(DriverOSMESA* driver) {
InitializeBase(driver);
}
+TraceOSMESAApi::~TraceOSMESAApi() {
+}
+
} // namespace gfx
diff --git a/ui/gl/gl_osmesa_api_implementation.h b/ui/gl/gl_osmesa_api_implementation.h
index 6d7681c..9d00b12 100644
--- a/ui/gl/gl_osmesa_api_implementation.h
+++ b/ui/gl/gl_osmesa_api_implementation.h
@@ -40,6 +40,21 @@ class GL_EXPORT RealOSMESAApi : public OSMESAApiBase {
void Initialize(DriverOSMESA* driver);
};
+// Inserts a TRACE for every OSMESA call.
+class GL_EXPORT TraceOSMESAApi : public OSMESAApi {
+ public:
+ TraceOSMESAApi(OSMESAApi* osmesa_api) : osmesa_api_(osmesa_api) { }
+ virtual ~TraceOSMESAApi();
+
+ // Include the auto-generated part of this class. We split this because
+ // it means we can easily edit the non-auto generated parts right here in
+ // this file instead of having to edit some template or the code generator.
+ #include "gl_bindings_api_autogen_osmesa.h"
+
+ private:
+ OSMESAApi* osmesa_api_;
+};
+
} // namespace gfx
#endif // UI_GL_OSMESA_API_IMPLEMENTATION_H_
diff --git a/ui/gl/gl_switches.cc b/ui/gl/gl_switches.cc
index c197cf7..eec3bb8 100644
--- a/ui/gl/gl_switches.cc
+++ b/ui/gl/gl_switches.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "ui/gl/gl_switches.h"
+#include "base/basictypes.h"
namespace gfx {
@@ -24,6 +25,9 @@ const char kDisableGpuVsync[] = "disable-gpu-vsync";
const char kEnableGPUServiceLogging[] = "enable-gpu-service-logging";
const char kEnableGPUClientLogging[] = "enable-gpu-client-logging";
+// Turns on calling TRACE for every GL call.
+const char kEnableGPUServiceTracing[] = "enable-gpu-service-tracing";
+
// Select which implementation of GL the GPU process should use. Options are:
// desktop: whatever desktop OpenGL the user has installed (Linux and Mac
// default).
@@ -58,5 +62,18 @@ const char kGpuSwitchingOptionNameAutomatic[] = "automatic";
// library first, but fall back to regular library if loading fails.
const char kTestGLLib[] = "test-gl-lib";
+// This is the list of switches passed from this file that are passed from the
+// GpuProcessHost to the GPU Process. Add your switch to this list if you need
+// to read it in the GPU process, else don't add it.
+const char* kGLSwitchesCopiedFromGpuProcessHost[] = {
+ kDisableGpuVsync,
+ kEnableGPUServiceLogging,
+ kEnableGPUServiceTracing,
+ kGpuNoContextLost,
+ kGpuSwitching,
+};
+const int kGLSwitchesCopiedFromGpuProcessHostNumSwitches =
+ arraysize(kGLSwitchesCopiedFromGpuProcessHost);
+
} // namespace switches
diff --git a/ui/gl/gl_switches.h b/ui/gl/gl_switches.h
index 4e73a15..688b62d 100644
--- a/ui/gl/gl_switches.h
+++ b/ui/gl/gl_switches.h
@@ -26,6 +26,7 @@ namespace switches {
GL_EXPORT extern const char kDisableGpuVsync[];
GL_EXPORT extern const char kEnableGPUServiceLogging[];
GL_EXPORT extern const char kEnableGPUClientLogging[];
+GL_EXPORT extern const char kEnableGPUServiceTracing[];
GL_EXPORT extern const char kGpuNoContextLost[];
GL_EXPORT extern const char kGpuSwapDelay[];
@@ -42,6 +43,9 @@ GL_EXPORT extern const char kUseGL[];
GL_EXPORT extern const char kSwiftShaderPath[];
GL_EXPORT extern const char kTestGLLib[];
+GL_EXPORT extern const char* kGLSwitchesCopiedFromGpuProcessHost[];
+GL_EXPORT extern const int kGLSwitchesCopiedFromGpuProcessHostNumSwitches;
+
} // namespace switches
#endif // UI_GL_GL_SWITCHES_H_
diff --git a/ui/gl/gl_wgl_api_implementation.cc b/ui/gl/gl_wgl_api_implementation.cc
index 2fba6d2..063916a 100644
--- a/ui/gl/gl_wgl_api_implementation.cc
+++ b/ui/gl/gl_wgl_api_implementation.cc
@@ -61,6 +61,9 @@ void RealWGLApi::Initialize(DriverWGL* driver) {
InitializeBase(driver);
}
+TraceWGLApi::~TraceWGLApi() {
+}
+
} // namespace gfx
diff --git a/ui/gl/gl_wgl_api_implementation.h b/ui/gl/gl_wgl_api_implementation.h
index 8af846c..6f0421f 100644
--- a/ui/gl/gl_wgl_api_implementation.h
+++ b/ui/gl/gl_wgl_api_implementation.h
@@ -40,6 +40,21 @@ class GL_EXPORT RealWGLApi : public WGLApiBase {
void Initialize(DriverWGL* driver);
};
+// Inserts a TRACE for every WGL call.
+class GL_EXPORT TraceWGLApi : public WGLApi {
+ public:
+ TraceWGLApi(WGLApi* wgl_api) : wgl_api_(wgl_api) { }
+ virtual ~TraceWGLApi();
+
+ // Include the auto-generated part of this class. We split this because
+ // it means we can easily edit the non-auto generated parts right here in
+ // this file instead of having to edit some template or the code generator.
+ #include "gl_bindings_api_autogen_wgl.h"
+
+ private:
+ WGLApi* wgl_api_;
+};
+
} // namespace gfx
#endif // UI_GL_WGL_API_IMPLEMENTATION_H_