]> git.cworth.org Git - fips/commitdiff
Aggregate non-shader GPU operations into their own operations
authorCarl Worth <cworth@cworth.org>
Wed, 16 Oct 2013 03:23:08 +0000 (20:23 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 16 Oct 2013 03:23:08 +0000 (20:23 -0700)
These operations are named after representative functions, (glClear,
glReadPixels, etc.). Aggregate time spent in any of these operations
is sorted together with the existing reports for time spent in
particular shader programs.

The shader program times should now be more accurate since time spent
in operations such as glClear will now no longer be accumulated into
the most recently-used shader.

eglwrap.c
glwrap.c
glxwrap.c
metrics.c
metrics.h

index f74ae40bc6abe0843bbb3e683ea64f816b5352a9..9e583895f888cc3c53939ea4f4855b48073b17cd 100644 (file)
--- a/eglwrap.c
+++ b/eglwrap.c
@@ -112,6 +112,7 @@ eglMakeCurrent (EGLDisplay display, EGLSurface draw, EGLSurface read,
 
        EGLWRAP_DEFER_WITH_RETURN (ret, eglMakeCurrent, display, draw, read, context);
 
+       metrics_set_current_op (METRICS_OP_SHADER + 0);
        metrics_counter_start ();
 
        return ret;
index ec03ce79c05bed6ed2e2126a4f317a25276dc353..80c5e36649c7362ba23bef9d730f64bb6326fa01 100644 (file)
--- a/glwrap.c
+++ b/glwrap.c
 
 static void *gl_handle;
 
+#define SWITCH_METRICS_OP(op)                  \
+       metrics_counter_stop ();                \
+       metrics_set_current_op (op);            \
+       metrics_counter_start ();
+
 void
 glwrap_set_gl_handle (void *handle)
 {
@@ -111,11 +116,7 @@ glwrap_lookup (char *name)
 void
 glUseProgram (GLuint program)
 {
-       metrics_counter_stop ();
-
-       metrics_set_current_program (program);
-
-       metrics_counter_start ();
+       SWITCH_METRICS_OP (METRICS_OP_SHADER + program);
 
        GLWRAP_DEFER(glUseProgram, program);
 }
@@ -123,11 +124,1223 @@ glUseProgram (GLuint program)
 void
 glUseProgramObjectARB (GLhandleARB programObj)
 {
-       metrics_counter_stop ();
+       SWITCH_METRICS_OP (METRICS_OP_SHADER + programObj);
 
-       metrics_set_current_program (programObj);
+       GLWRAP_DEFER(glUseProgramObjectARB, programObj);
+}
 
-       metrics_counter_start ();
+/* METRICS_OP_ACCUM */
+void
+glAccum (GLenum op, GLfloat value)
+{
+       SWITCH_METRICS_OP (METRICS_OP_ACCUM);
 
-       GLWRAP_DEFER(glUseProgramObjectARB, programObj);
+       GLWRAP_DEFER (glAccum, op, value);
+}
+
+void
+glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+{
+       SWITCH_METRICS_OP (METRICS_OP_ACCUM);
+
+       GLWRAP_DEFER (glClearAccum, red, green, blue, alpha);
+}
+
+void
+glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+{
+       SWITCH_METRICS_OP (METRICS_OP_ACCUM);
+
+       GLWRAP_DEFER (glClearAccumxOES, red, green, blue, alpha);
+}
+
+/* METRICS_OP_BUFFER_DATA */
+void
+glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER (glBufferData, target, size, data, usage);
+}
+
+void
+glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data,
+                     GLenum usage)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER (glNamedBufferDataEXT, buffer, size, data, usage);
+}
+
+void
+glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size,
+                const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER (glBufferSubData, target, offset, size, data);
+}
+
+void
+glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size,
+                        const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER (glNamedBufferSubDataEXT, buffer, offset, size, data);
+}
+
+void *
+glMapBuffer (GLenum target, GLenum access)
+{
+       void *ret;
+
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER_WITH_RETURN (ret, glMapBuffer, target, access);
+
+       return ret;
+}
+
+void *
+glMapBufferARB (GLenum target, GLenum access)
+{
+       void *ret;
+
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER_WITH_RETURN (ret, glMapBufferARB, target, access);
+
+       return ret;
+}
+
+void *
+glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length,
+                 GLbitfield access)
+{
+       void *ret;
+
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER_WITH_RETURN (ret, glMapBufferRange, target, offset,
+                                 length, access);
+
+       return ret;
+}
+
+GLboolean
+glUnmapBuffer (GLenum target)
+{
+       GLboolean ret;
+
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER_WITH_RETURN (ret, glUnmapBuffer, target);
+
+       return ret;
+}
+
+GLboolean
+glUnmapNamedBufferEXT (GLuint buffer)
+{
+       GLboolean ret;
+
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER_WITH_RETURN (ret, glUnmapNamedBufferEXT, buffer);
+
+       return ret;
+}
+
+GLboolean
+glUnmapBufferARB (GLenum target)
+{
+       GLboolean ret;
+
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER_WITH_RETURN (ret, glUnmapBufferARB, target);
+
+       return ret;
+}
+
+void
+glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER (glFlushMappedBufferRange, target, offset, length);
+}
+
+void
+glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER (glFlushMappedBufferRangeAPPLE, target, offset, size);
+}
+
+void
+glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset,
+                                 GLsizeiptr length)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER (glFlushMappedNamedBufferRangeEXT, buffer, offset, length);
+}
+
+void *
+glMapNamedBufferEXT (GLuint buffer, GLenum access)
+{
+       void *ret;
+
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER_WITH_RETURN (ret, glMapNamedBufferEXT, buffer, access);
+
+       return ret;
+}
+
+void *
+glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length,
+                         GLbitfield access)
+{
+       void *ret;
+
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_DATA);
+
+       GLWRAP_DEFER_WITH_RETURN (ret, glMapNamedBufferRangeEXT, buffer,
+                                 offset, length, access);
+
+       return ret;
+}
+
+/* METRICS_OP_BUFFER_SUB_DATA */
+void
+glCopyBufferSubData (GLenum readTarget, GLenum writeTarget,
+                    GLintptr readOffset, GLintptr writeOffset,
+                    GLsizeiptr size)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_SUB_DATA);
+
+       GLWRAP_DEFER (glCopyBufferSubData, readTarget, writeTarget,
+                     readOffset, writeOffset, size);
+}
+
+void
+glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer,
+                            GLintptr readOffset, GLintptr writeOffset,
+                            GLsizeiptr size)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BUFFER_SUB_DATA);
+
+       GLWRAP_DEFER (glNamedCopyBufferSubDataEXT, readBuffer,
+                     writeBuffer, readOffset, writeOffset, size);
+}
+
+/* METRICS_OP_BITMAP */
+void
+glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig,
+         GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BITMAP);
+
+       GLWRAP_DEFER (glBitmap, width, height, xorig, yorig,
+                     xmove, ymove, bitmap);
+}
+
+void
+glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig,
+             GLfixed xmove, GLfixed ymove, const GLubyte *bitmap)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BITMAP);
+
+       GLWRAP_DEFER (glBitmapxOES, width, height, xorig, yorig,
+                     xmove, ymove, bitmap);
+}
+
+/* METRICS_OP_BLIT_FRAMEBUFFER */
+void
+glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+                  GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+                  GLbitfield mask, GLenum filter)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BLIT_FRAMEBUFFER);
+
+       GLWRAP_DEFER (glBlitFramebuffer, srcX0, srcY0, srcX1, srcY1,
+                     dstX0, dstY0, dstX1, dstY1, mask, filter);
+}
+
+void
+glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+                     GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+                     GLbitfield mask, GLenum filter)
+{
+       SWITCH_METRICS_OP (METRICS_OP_BLIT_FRAMEBUFFER);
+
+       GLWRAP_DEFER (glBlitFramebufferEXT, srcX0, srcY0, srcX1, srcY1,
+                     dstX0, dstY0, dstX1, dstY1, mask, filter);
+}
+
+/* METRICS_OP_CLEAR */
+void 
+glClear (GLbitfield mask)
+{
+       SWITCH_METRICS_OP (METRICS_OP_CLEAR);
+
+       GLWRAP_DEFER (glClear, mask);
+}
+
+void
+glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
+{
+       SWITCH_METRICS_OP (METRICS_OP_CLEAR);
+
+       GLWRAP_DEFER (glClearBufferfi, buffer, drawbuffer, depth, stencil);
+}
+
+void
+glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value)
+{
+       SWITCH_METRICS_OP (METRICS_OP_CLEAR);
+
+       GLWRAP_DEFER (glClearBufferfv, buffer, drawbuffer, value);
+}
+
+void
+glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value)
+{
+       SWITCH_METRICS_OP (METRICS_OP_CLEAR);
+
+       GLWRAP_DEFER (glClearBufferiv, buffer, drawbuffer, value);
+}
+
+void
+glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value)
+{
+       SWITCH_METRICS_OP (METRICS_OP_CLEAR);
+
+       GLWRAP_DEFER (glClearBufferuiv, buffer, drawbuffer, value);
+}
+
+/* METRICS_OP_CLEAR_BUFFER_DATA */
+
+void
+glClearBufferData (GLenum target, GLenum internalformat, GLenum format,
+                  GLenum type, const void *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_CLEAR_BUFFER_DATA);
+
+       GLWRAP_DEFER (glClearBufferData, target, internalformat, format,
+                     type, data);
+}
+
+void
+glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset,
+                     GLsizeiptr size, GLenum format, GLenum type,
+                     const void *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_CLEAR_BUFFER_DATA);
+
+       GLWRAP_DEFER (glClearBufferSubData, target, internalformat,
+                     offset, size, format, type, data);
+}
+
+void
+glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format,
+                          GLenum type, const void *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_CLEAR_BUFFER_DATA);
+
+       GLWRAP_DEFER (glClearNamedBufferDataEXT, buffer, internalformat,
+                     format, type, data);
+}
+
+void
+glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat,
+                             GLenum format, GLenum type, GLsizeiptr offset,
+                             GLsizeiptr size, const void *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_CLEAR_BUFFER_DATA);
+
+       GLWRAP_DEFER (glClearNamedBufferSubDataEXT, buffer,
+                     internalformat, format, type, offset, size, data);
+}
+
+/* METRICS_OP_CLEAR_TEX_IMAGE */
+
+
+/* METRICS_OP_COPY_PIXELS */
+void
+glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type )
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_PIXELS);
+
+       GLWRAP_DEFER (glCopyPixels, x, y, width, height, type);
+}
+
+/* METRICS_OP_COPY_TEX_IMAGE */
+void
+glCopyTexImage1D (GLenum target, GLint level, GLenum internalformat,
+                 GLint x, GLint y, GLsizei width, GLint border)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexImage1D, target, level, internalformat,
+                     x, y, width, border);
+}
+
+void
+glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat,
+                    GLint x, GLint y, GLsizei width, GLint border)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexImage1DEXT, target, level, internalformat,
+                     x, y, width, border);
+}
+
+void
+glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat,
+                 GLint x, GLint y, GLsizei width, GLsizei height,
+                 GLint border)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexImage2D, target, level, internalformat,
+                     x, y, width, height, border);
+}
+
+void
+glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat,
+                    GLint x, GLint y, GLsizei width, GLsizei height,
+                    GLint border)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexImage2DEXT, target, level, internalformat,
+                     x, y, width, height, border);
+}
+
+void
+glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset,
+                    GLint x, GLint y, GLsizei width)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexSubImage1D, target, level, xoffset,
+                     x, y, width);
+}
+
+void
+glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset,
+                       GLint x, GLint y, GLsizei width)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexSubImage1DEXT, target, level, xoffset,
+                     x, y, width);
+}
+
+void
+glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset,
+                    GLint yoffset, GLint x, GLint y, GLsizei width,
+                    GLsizei height)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexSubImage2D, target, level, xoffset, yoffset,
+                     x, y, width, height);
+}
+
+void
+glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset,
+                       GLint yoffset, GLint x, GLint y, GLsizei width,
+                       GLsizei height)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexSubImage2DEXT, target, level, xoffset, yoffset,
+                     x, y, width, height);
+}
+
+void
+glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset,
+                    GLint yoffset, GLint zoffset, GLint x, GLint y,
+                    GLsizei width, GLsizei height)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexSubImage3D, target, level, xoffset, yoffset,
+                     zoffset, x, y, width, height);
+}
+
+void
+glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset,
+                       GLint yoffset, GLint zoffset, GLint x, GLint y,
+                       GLsizei width, GLsizei height)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTexSubImage3DEXT, target, level, xoffset, yoffset,
+                     zoffset, x, y, width, height);
+}
+
+void
+glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level,
+                        GLenum internalformat, GLint x, GLint y,
+                        GLsizei width, GLint border)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTextureImage1DEXT, texture, target, level,
+                     internalformat, x, y, width, border);
+}
+
+void
+glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level,
+                        GLenum internalformat, GLint x, GLint y, GLsizei width,
+                        GLsizei height, GLint border)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTextureImage2DEXT, texture, target,
+                     level, internalformat, x, y, width, height, border);
+}
+
+void
+glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level,
+                           GLint xoffset, GLint x, GLint y, GLsizei width)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTextureSubImage1DEXT, texture, target, level,
+                     xoffset, x, y, width);
+}
+
+void
+glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level,
+                           GLint xoffset, GLint yoffset, GLint x, GLint y,
+                           GLsizei width, GLsizei height)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTextureSubImage2DEXT, texture, target, level,
+                     xoffset, yoffset, x, y, width, height);
+}
+
+void
+glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level,
+                           GLint xoffset, GLint yoffset, GLint zoffset,
+                           GLint x, GLint y, GLsizei width, GLsizei height)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyTextureSubImage3DEXT, texture, target, level,
+                     xoffset, yoffset, zoffset, x, y, width, height);
+}
+
+void
+glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level,
+                         GLenum internalformat, GLint x, GLint y,
+                         GLsizei width, GLint border)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyMultiTexImage1DEXT, texunit, target, level,
+                     internalformat, x, y, width, border);
+}
+
+void
+glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level,
+                         GLenum internalformat, GLint x, GLint y,
+                         GLsizei width, GLsizei height, GLint border)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyMultiTexImage2DEXT, texunit, target, level,
+                     internalformat, x, y, width, height, border);
+}
+
+void
+glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level,
+                            GLint xoffset, GLint x, GLint y, GLsizei width)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyMultiTexSubImage1DEXT, texunit, target, level,
+                     xoffset, x, y, width);
+}
+
+void
+glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level,
+                            GLint xoffset, GLint yoffset, GLint x, GLint y,
+                            GLsizei width, GLsizei height)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyMultiTexSubImage2DEXT, texunit, target, level,
+                     xoffset, yoffset, x, y, width, height);
+}
+
+void
+glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level,
+                            GLint xoffset, GLint yoffset, GLint zoffset,
+                            GLint x, GLint y, GLsizei width, GLsizei height)
+{
+       SWITCH_METRICS_OP (METRICS_OP_COPY_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCopyMultiTexSubImage3DEXT, texunit, target, level,
+                     xoffset, yoffset, zoffset, x, y, width, height);
+}
+
+/* METRICS_OP_DRAW_PIXELS */
+void
+glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type,
+             const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_DRAW_PIXELS);
+
+       GLWRAP_DEFER (glDrawPixels, width, height, format, type, pixels);
+}
+
+/* METRICS_OP_GET_TEX_IMAGE */
+
+void
+glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target,
+                                GLint lod, GLvoid *img)
+{
+       SWITCH_METRICS_OP (METRICS_OP_GET_TEX_IMAGE);
+
+       GLWRAP_DEFER (glGetCompressedMultiTexImageEXT, texunit,
+                     target, lod, img);
+}
+
+void
+glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img)
+{
+       SWITCH_METRICS_OP (METRICS_OP_GET_TEX_IMAGE);
+
+       GLWRAP_DEFER (glGetCompressedTexImage, target, level, img);
+}
+
+void
+glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img)
+{
+       SWITCH_METRICS_OP (METRICS_OP_GET_TEX_IMAGE);
+
+       GLWRAP_DEFER (glGetCompressedTexImageARB, target, level, img);
+}
+
+void
+glGetCompressedTextureImageEXT (GLuint texture, GLenum target,
+                               GLint lod, GLvoid *img)
+{
+       SWITCH_METRICS_OP (METRICS_OP_GET_TEX_IMAGE);
+
+       GLWRAP_DEFER (glGetCompressedTextureImageEXT, texture,
+                     target, lod, img);
+}
+
+void
+glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level,
+                      GLenum format, GLenum type, GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_GET_TEX_IMAGE);
+
+       GLWRAP_DEFER (glGetMultiTexImageEXT, texunit,
+                     target, level, format, type, pixels);
+}
+
+void
+glGetnCompressedTexImageARB (GLenum target, GLint lod,
+                            GLsizei bufSize, GLvoid *img)
+{
+       SWITCH_METRICS_OP (METRICS_OP_GET_TEX_IMAGE);
+
+       GLWRAP_DEFER (glGetnCompressedTexImageARB, target, lod, bufSize, img);
+}
+
+void
+glGetnTexImageARB (GLenum target, GLint level, GLenum format,
+                  GLenum type, GLsizei bufSize, GLvoid *img)
+{
+       SWITCH_METRICS_OP (METRICS_OP_GET_TEX_IMAGE);
+
+       GLWRAP_DEFER (glGetnTexImageARB, target, level,
+                     format, type, bufSize, img);
+}
+
+void
+glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type,
+              GLvoid *pixels )
+{
+       SWITCH_METRICS_OP (METRICS_OP_GET_TEX_IMAGE);
+
+       GLWRAP_DEFER (glGetTexImage, target, level, format, type, pixels);
+}
+
+/* METRICS_OP_READ_PIXELS */
+void
+glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height,
+             GLenum format, GLenum type, GLvoid *pixels )
+{
+       SWITCH_METRICS_OP (METRICS_OP_READ_PIXELS);
+
+       GLWRAP_DEFER (glReadPixels, x, y, width, height, format, type, pixels);
+}
+
+void
+glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height,
+                 GLenum format, GLenum type, GLsizei bufSize, GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_READ_PIXELS);
+
+       GLWRAP_DEFER (glReadnPixelsARB, x, y, width, height,
+                     format, type, bufSize, data);
+}
+
+/* METRICS_OP_TEX_IMAGE */
+void
+glTexImage1D (GLenum target, GLint level, GLint internalFormat,
+             GLsizei width, GLint border, GLenum format, GLenum type,
+             const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexImage1D, target, level, internalFormat, width,
+                     border, format, type, pixels);
+}
+
+void
+glTexImage2D (GLenum target, GLint level, GLint internalFormat,
+             GLsizei width, GLsizei height, GLint border, GLenum format,
+             GLenum type, const GLvoid *pixels )
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexImage2D, target, level, internalFormat,
+                     width, height, border, format, type, pixels);
+}
+
+
+void
+glTexImage2DMultisample (GLenum target, GLsizei samples,
+                        GLint internalformat, GLsizei width, GLsizei height,
+                        GLboolean fixedsamplelocations)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexImage2DMultisample, target, samples,
+                     internalformat, width, height, fixedsamplelocations);
+}
+
+void
+glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples,
+                                  GLsizei colorSamples, GLint internalFormat,
+                                  GLsizei width, GLsizei height,
+                                  GLboolean fixedSampleLocations)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexImage2DMultisampleCoverageNV, target,
+                     coverageSamples, colorSamples, internalFormat,
+                     width, height, fixedSampleLocations);
+}
+
+void
+glTexImage3D (GLenum target, GLint level, GLint internalformat,
+             GLsizei width, GLsizei height, GLsizei depth, GLint border,
+             GLenum format, GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexImage3D, target, level, internalformat,
+                     width, height, depth, border, format, type, pixels);
+}
+
+void
+glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat,
+                GLsizei width, GLsizei height, GLsizei depth, GLint border,
+                GLenum format, GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexImage3DEXT, target, level, internalformat,
+                     width, height, depth, border, format, type, pixels);
+}
+
+void
+glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat,
+                        GLsizei width, GLsizei height, GLsizei depth,
+                        GLboolean fixedsamplelocations)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexImage3DMultisample, target, samples,
+                     internalformat, width, height, depth,
+                     fixedsamplelocations);
+}
+
+void
+glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples,
+                                  GLsizei colorSamples, GLint internalFormat,
+                                  GLsizei width, GLsizei height, GLsizei depth,
+                                  GLboolean fixedSampleLocations)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexImage3DMultisampleCoverageNV, target,
+                     coverageSamples, colorSamples, internalFormat,
+                     width, height, depth, fixedSampleLocations);
+}
+
+void
+glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat,
+                 GLsizei width, GLsizei height, GLsizei depth,
+                 GLsizei size4d, GLint border, GLenum format,
+                 GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexImage4DSGIS, target, level,
+                     internalformat, width, height, depth,
+                     size4d, border, format, type, pixels);
+}
+
+void
+glTexSubImage1D (GLenum target, GLint level, GLint xoffset,
+                GLsizei width, GLenum format, GLenum type,
+                const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexSubImage1D, target, level, xoffset,
+                     width, format, type, pixels);
+}
+
+void
+glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset,
+                   GLsizei width, GLenum format, GLenum type,
+                   const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexSubImage1DEXT, target, level, xoffset,
+                     width, format, type, pixels);
+}
+
+void
+glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                GLsizei width, GLsizei height, GLenum format, GLenum type,
+                const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexSubImage2D, target, level, xoffset, yoffset,
+                     width, height, format, type, pixels);
+}
+
+void
+glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                   GLsizei width, GLsizei height, GLenum format, GLenum type,
+                   const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexSubImage2DEXT, target, level, xoffset, yoffset,
+                     width, height, format, type, pixels);
+}
+
+void
+glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                GLenum format, GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexSubImage3D, target, level, xoffset, yoffset,
+                     zoffset, width, height, depth, format, type, pixels);
+}
+
+void
+glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                   GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
+                   GLenum format, GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexSubImage3DEXT, target, level, xoffset, yoffset,
+                     zoffset, width, height, depth, format, type, pixels);
+}
+
+void
+glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                    GLint zoffset, GLint woffset, GLsizei width,
+                    GLsizei height, GLsizei depth, GLsizei size4d,
+                    GLenum format, GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glTexSubImage4DSGIS, target, level, xoffset,
+                     yoffset, zoffset, woffset, width, height,
+                     depth, size4d, format, type, pixels);
+}
+
+void
+glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level,
+                               GLenum internalformat, GLsizei width,
+                               GLint border, GLsizei imageSize,
+                               const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedMultiTexImage1DEXT, texunit, target,
+                     level, internalformat, width, border, imageSize, bits);
+}
+
+void
+glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level,
+                               GLenum internalformat, GLsizei width,
+                               GLsizei height, GLint border,
+                               GLsizei imageSize, const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedMultiTexImage2DEXT, texunit, target, level,
+                     internalformat, width, height, border, imageSize, bits);
+}
+
+void
+glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level,
+                               GLenum internalformat, GLsizei width,
+                               GLsizei height, GLsizei depth, GLint border,
+                               GLsizei imageSize, const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedMultiTexImage3DEXT, texunit, target,
+                     level, internalformat, width, height, depth,
+                     border, imageSize, bits);
+}
+
+void
+glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level,
+                                  GLint xoffset, GLsizei width, GLenum format,
+                                  GLsizei imageSize, const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedMultiTexSubImage1DEXT, texunit, target,
+                     level, xoffset, width, format, imageSize, bits);
+}
+
+void
+glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level,
+                                  GLint xoffset, GLint yoffset, GLsizei width,
+                                  GLsizei height, GLenum format,
+                                  GLsizei imageSize, const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedMultiTexSubImage2DEXT, texunit, target, level,
+                     xoffset, yoffset, width, height, format, imageSize, bits);
+}
+
+void
+glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level,
+                                  GLint xoffset, GLint yoffset, GLint zoffset,
+                                  GLsizei width, GLsizei height, GLsizei depth,
+                                  GLenum format, GLsizei imageSize,
+                                  const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedMultiTexSubImage3DEXT, texunit, target,
+                     level, xoffset, yoffset, zoffset, width, height,
+                     depth, format, imageSize, bits);
+}
+
+void
+glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat,
+                       GLsizei width, GLint border, GLsizei imageSize,
+                       const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexImage1D, target, level,
+                     internalformat, width, border, imageSize, data);
+}
+
+void
+glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat,
+                          GLsizei width, GLint border, GLsizei imageSize,
+                          const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexImage1DARB, target, level, internalformat,
+                     width, border, imageSize, data);
+}
+
+void
+glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat,
+                       GLsizei width, GLsizei height, GLint border,
+                       GLsizei imageSize, const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexImage2D, target, level, internalformat,
+                     width, height, border, imageSize, data);
+}
+
+void
+glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat,
+                          GLsizei width, GLsizei height, GLint border,
+                          GLsizei imageSize, const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexImage2DARB, target, level, internalformat,
+                     width, height, border, imageSize, data);
+}
+
+void
+glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat,
+                       GLsizei width, GLsizei height, GLsizei depth,
+                       GLint border, GLsizei imageSize, const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexImage3D, target, level, internalformat,
+                     width, height, depth, border, imageSize, data);
+}
+
+void
+glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat,
+                          GLsizei width, GLsizei height, GLsizei depth,
+                          GLint border, GLsizei imageSize, const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexImage3DARB, target, level, internalformat,
+                     width, height, depth, border, imageSize, data);
+}
+
+void
+glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset,
+                          GLsizei width, GLenum format, GLsizei imageSize,
+                          const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexSubImage1D, target, level, xoffset,
+                     width, format, imageSize, data);
+}
+
+void
+glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset,
+                             GLsizei width, GLenum format, GLsizei imageSize,
+                             const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexSubImage1DARB, target, level, xoffset,
+                     width, format, imageSize, data);
+}
+
+void
+glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset,
+                          GLint yoffset, GLsizei width, GLsizei height,
+                          GLenum format, GLsizei imageSize, const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexSubImage2D, target, level, xoffset,
+                     yoffset, width, height, format, imageSize, data);
+}
+
+void
+glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset,
+                             GLint yoffset, GLsizei width, GLsizei height,
+                             GLenum format, GLsizei imageSize,
+                             const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexSubImage2DARB, target, level, xoffset,
+                     yoffset, width, height, format, imageSize, data);
+}
+
+void
+glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset,
+                          GLint yoffset, GLint zoffset, GLsizei width,
+                          GLsizei height, GLsizei depth, GLenum format,
+                          GLsizei imageSize, const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexSubImage3D, target, level, xoffset,
+                     yoffset, zoffset, width, height, depth, format,
+                     imageSize, data);
+}
+
+void
+glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset,
+                             GLint yoffset, GLint zoffset, GLsizei width,
+                             GLsizei height, GLsizei depth, GLenum format,
+                             GLsizei imageSize, const GLvoid *data)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTexSubImage3DARB, target, level, xoffset,
+                     yoffset, zoffset, width, height, depth, format,
+                     imageSize, data);
+}
+
+void
+glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level,
+                              GLenum internalformat, GLsizei width,
+                              GLint border, GLsizei imageSize,
+                              const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTextureImage1DEXT, texture, target, level,
+                     internalformat, width, border, imageSize, bits);
+}
+
+void
+glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level,
+                              GLenum internalformat, GLsizei width,
+                              GLsizei height, GLint border,
+                              GLsizei imageSize, const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTextureImage2DEXT, texture, target, level,
+                     internalformat, width, height, border, imageSize, bits);
+}
+
+void
+glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level,
+                              GLenum internalformat, GLsizei width,
+                              GLsizei height, GLsizei depth, GLint border,
+                              GLsizei imageSize, const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTextureImage3DEXT, texture, target,
+                     level, internalformat, width, height, depth,
+                     border, imageSize, bits);
+}
+
+void
+glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level,
+                                 GLint xoffset, GLsizei width, GLenum format,
+                                 GLsizei imageSize, const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTextureSubImage1DEXT, texture, target,
+                     level, xoffset, width, format, imageSize, bits);
+}
+
+void
+glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level,
+                                 GLint xoffset, GLint yoffset, GLsizei width,
+                                 GLsizei height, GLenum format,
+                                 GLsizei imageSize, const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTextureSubImage2DEXT, texture, target, level,
+                     xoffset, yoffset, width, height, format, imageSize, bits);
+}
+
+void
+glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level,
+                                 GLint xoffset, GLint yoffset, GLint zoffset,
+                                 GLsizei width, GLsizei height, GLsizei depth,
+                                 GLenum format, GLsizei imageSize,
+                                 const GLvoid *bits)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glCompressedTextureSubImage3DEXT, texture, target,
+                     level, xoffset, yoffset, zoffset, width, height,
+                     depth, format, imageSize, bits);
+}
+
+void
+glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level,
+                     GLenum internalformat, GLsizei width, GLint border,
+                     GLenum format, GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glMultiTexImage1DEXT, texunit, target, level,
+                     internalformat, width, border, format, type, pixels);
+}
+
+void
+glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level,
+                     GLenum internalformat, GLsizei width, GLsizei height,
+                     GLint border, GLenum format, GLenum type,
+                     const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glMultiTexImage2DEXT, texunit, target, level,
+                     internalformat, width, height, border, format,
+                     type, pixels);
+}
+
+void
+glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level,
+                     GLenum internalformat, GLsizei width, GLsizei height,
+                     GLsizei depth, GLint border, GLenum format,
+                     GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glMultiTexImage3DEXT, texunit, target, level,
+                     internalformat, width, height, depth, border,
+                     format, type, pixels);
+}
+
+void
+glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level,
+                        GLint xoffset, GLsizei width, GLenum format,
+                        GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glMultiTexSubImage1DEXT, texunit, target, level,
+                     xoffset, width, format, type, pixels);
+}
+
+void
+glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level,
+                        GLint xoffset, GLint yoffset, GLsizei width,
+                        GLsizei height, GLenum format, GLenum type,
+                        const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glMultiTexSubImage2DEXT, texunit, target, level, xoffset,
+                     yoffset, width, height, format, type, pixels);
+}
+
+void
+glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level,
+                        GLint xoffset, GLint yoffset, GLint zoffset,
+                        GLsizei width, GLsizei height, GLsizei depth,
+                        GLenum format, GLenum type, const GLvoid *pixels)
+{
+       SWITCH_METRICS_OP (METRICS_OP_TEX_IMAGE);
+
+       GLWRAP_DEFER (glMultiTexSubImage3DEXT, texunit, target, level,
+                     xoffset, yoffset, zoffset, width, height, depth,
+                     format, type, pixels);
 }
index a57c5579cba444fe40ba45091b072cb0fb2967b7..eda358313dc26b09570547c40987c56526c9306a 100644 (file)
--- a/glxwrap.c
+++ b/glxwrap.c
@@ -88,6 +88,7 @@ glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx)
 
        GLWRAP_DEFER_WITH_RETURN (ret, glXMakeCurrent, dpy, drawable, ctx);
 
+       metrics_set_current_op (METRICS_OP_SHADER + 0);
        metrics_counter_start ();
 
        return ret;
@@ -102,6 +103,7 @@ glXMakeContextCurrent (Display *dpy, GLXDrawable drawable, GLXDrawable read, GLX
 
        GLWRAP_DEFER_WITH_RETURN (ret, glXMakeContextCurrent, dpy, drawable, read, ctx);
 
+       metrics_set_current_op (METRICS_OP_SHADER + 0);
        metrics_counter_start ();
 
        return ret;
index 39c90ad1145547846da59dac480a6e711e4a846c..327c270bd5dc002d9b65a91c223f1b0418cce20c 100644 (file)
--- a/metrics.c
+++ b/metrics.c
 typedef struct counter
 {
        unsigned id;
-       unsigned program;
+
+       metrics_op_t op;
        struct counter *next;
 } counter_t;
 
-typedef struct program_metrics
+typedef struct op_metrics
 {
        /* This happens to also be the index into the
-        * ctx->program_metrics array currently
+        * ctx->op_metrics array currently
         */
-       unsigned id;
+       metrics_op_t op;
        double time_ns;
-} program_metrics_t;
+} op_metrics_t;
 
 typedef struct context
 {
-       unsigned int program;
+       metrics_op_t op;
 
        counter_t *counter_head;
        counter_t *counter_tail;
 
-       unsigned num_program_metrics;
-       program_metrics_t *program_metrics;
+       unsigned num_op_metrics;
+       op_metrics_t *op_metrics;
 } context_t;
 
 /* FIXME: Need a map from integers to context objects and track the
@@ -65,6 +66,51 @@ context_t current_context;
 int frames;
 int verbose;
 
+static const char *
+metrics_op_string (metrics_op_t op)
+{
+       if (op >= METRICS_OP_SHADER)
+               return "Shader program";
+
+       switch (op)
+       {
+       case METRICS_OP_ACCUM:
+               return "glAccum*(+)";
+       case METRICS_OP_BUFFER_DATA:
+               return "glBufferData(+)";
+       case METRICS_OP_BUFFER_SUB_DATA:
+               return "glCopyBufferSubData*";
+       case METRICS_OP_BITMAP:
+               return "glBitmap*";
+       case METRICS_OP_BLIT_FRAMEBUFFER:
+               return "glBlitFramebuffer*";
+       case METRICS_OP_CLEAR:
+               return "glClear(+)";
+       case METRICS_OP_CLEAR_BUFFER_DATA:
+               return "glCearBufferData(+)";
+       case METRICS_OP_CLEAR_TEX_IMAGE:
+               return "glClearTexImage(+)";
+       case METRICS_OP_COPY_PIXELS:
+               return "glCopyPixels";
+       case METRICS_OP_COPY_TEX_IMAGE:
+               return "glCopyTexImage(+)";
+       case METRICS_OP_DRAW_PIXELS:
+               return "glDrawPixels";
+       case METRICS_OP_GET_TEX_IMAGE:
+               return "glGetTexImage(+)";
+       case METRICS_OP_READ_PIXELS:
+               return "glReadPixels*";
+       case METRICS_OP_TEX_IMAGE:
+               return "glTexImage*(+)";
+       default:
+               fprintf (stderr, "Internal error: "
+                        "Unknown metrics op value: %d\n", op);
+               exit (1);
+       }
+
+       return "";
+}
+
 void
 metrics_counter_start (void)
 {
@@ -78,7 +124,7 @@ metrics_counter_start (void)
 
        glGenQueries (1, &counter->id);
 
-       counter->program = current_context.program;
+       counter->op = current_context.op;
        counter->next = NULL;
 
        if (current_context.counter_tail) {
@@ -99,29 +145,29 @@ metrics_counter_stop (void)
 }
 
 void
-metrics_set_current_program (unsigned program)
+metrics_set_current_op (metrics_op_t op)
 {
-       current_context.program = program;
+       current_context.op = op;
 }
 
 static void
-accumulate_program_time (unsigned program_id, unsigned time_ns)
+accumulate_program_time (metrics_op_t op, unsigned time_ns)
 {
        context_t *ctx = &current_context;
        unsigned i;
 
-       if (program_id >= ctx->num_program_metrics) {
-               ctx->program_metrics = realloc (ctx->program_metrics,
-                                               (program_id + 1) * sizeof (program_metrics_t));
-               for (i = ctx->num_program_metrics; i < program_id + 1; i++) {
-                       ctx->program_metrics[i].id = i;
-                       ctx->program_metrics[i].time_ns = 0.0;
+       if (op >= ctx->num_op_metrics) {
+               ctx->op_metrics = realloc (ctx->op_metrics,
+                                          (op + 1) * sizeof (op_metrics_t));
+               for (i = ctx->num_op_metrics; i < op + 1; i++) {
+                       ctx->op_metrics[i].op = i;
+                       ctx->op_metrics[i].time_ns = 0.0;
                }
 
-               ctx->num_program_metrics = program_id + 1;
+               ctx->num_op_metrics = op + 1;
        }
 
-       ctx->program_metrics[program_id].time_ns += time_ns;
+       ctx->op_metrics[op].time_ns += time_ns;
 }
 
 static int
@@ -129,7 +175,7 @@ time_compare(const void *in_a, const void *in_b, void *arg)
 {
        int a = *(const int *)in_a;
        int b = *(const int *)in_b;
-       struct program_metrics *metrics = arg;
+       struct op_metrics *metrics = arg;
 
        if (metrics[a].time_ns < metrics[b].time_ns)
                return -1;
@@ -142,24 +188,24 @@ static void
 print_program_metrics (void)
 {
        context_t *ctx = &current_context;
-       unsigned i;
-       int *sorted; /* Sorted indices into the ctx->program_metrics */
+       unsigned i, j;
+       int *sorted; /* Sorted indices into the ctx->op_metrics */
        double total = 0;
 
-       /* Make a sorted list of the programs by time used, and figure
-        * out to total so we can print percentages.
+       /* Make a sorted list of the operations by time used, and figure
+        * out the total so we can print percentages.
         */
-       sorted = calloc(ctx->num_program_metrics, sizeof(*sorted));
-       for (i = 0; i < ctx->num_program_metrics; i++) {
+       sorted = calloc(ctx->num_op_metrics, sizeof(*sorted));
+       for (i = 0; i < ctx->num_op_metrics; i++) {
                sorted[i] = i;
-               total += ctx->program_metrics[i].time_ns;
+               total += ctx->op_metrics[i].time_ns;
        }
-       qsort_r(sorted, ctx->num_program_metrics, sizeof(*sorted),
-               time_compare, ctx->program_metrics);
+       qsort_r(sorted, ctx->num_op_metrics, sizeof(*sorted),
+               time_compare, ctx->op_metrics);
 
-       for (i = 0; i < ctx->num_program_metrics; i++) {
-               struct program_metrics *metric =
-                       &ctx->program_metrics[sorted[i]];
+       for (i = 0; i < ctx->num_op_metrics; i++) {
+               const char *op_string;
+               op_metrics_t *metric =&ctx->op_metrics[sorted[i]];
 
                /* Since we sparsely fill the array based on program
                 * id, many "programs" have no time.
@@ -167,8 +213,18 @@ print_program_metrics (void)
                if (metric->time_ns == 0.0)
                        continue;
 
-               printf ("Program %d:\t%7.2f ms (% 2.1f%%)\n",
-                       metric->id, metric->time_ns / 1e6,
+               op_string = metrics_op_string (metric->op);
+
+               printf ("%s", op_string);
+               if (metric->op >= METRICS_OP_SHADER) {
+                       printf (" %d:", metric->op - METRICS_OP_SHADER);
+               } else {
+                       printf (":");
+                       for (j = strlen (op_string); j < 20; j++)
+                               printf (" ");
+               }
+               printf ("\t%7.2f ms (% 2.1f%%)\n",
+                       metric->time_ns / 1e6,
                        metric->time_ns / total * 100);
        }
 }
@@ -215,7 +271,7 @@ metrics_end_frame (void)
 
                glGetQueryObjectuiv (counter->id, GL_QUERY_RESULT, &elapsed);
 
-               accumulate_program_time (counter->program, elapsed);
+               accumulate_program_time (counter->op, elapsed);
 
                current_context.counter_head = counter->next;
                if (current_context.counter_head == NULL)
index 8b688678d2f5601d1471d67289418ff13f5fc8a4..b5f985977a5a6ecbeec45024a1a45864a5b196c0 100644 (file)
--- a/metrics.h
+++ b/metrics.h
 #ifndef METRICS_H
 #define METRICS_H
 
+typedef enum
+{
+       METRICS_OP_ACCUM,
+       METRICS_OP_BUFFER_DATA,
+       METRICS_OP_BUFFER_SUB_DATA,
+       METRICS_OP_BITMAP,
+       METRICS_OP_BLIT_FRAMEBUFFER,
+       METRICS_OP_CLEAR,
+       METRICS_OP_CLEAR_BUFFER_DATA,
+       METRICS_OP_CLEAR_TEX_IMAGE,
+       METRICS_OP_COPY_PIXELS,
+       METRICS_OP_COPY_TEX_IMAGE,
+       METRICS_OP_DRAW_PIXELS,
+       METRICS_OP_GET_TEX_IMAGE,
+       METRICS_OP_READ_PIXELS,
+       METRICS_OP_TEX_IMAGE,
+
+       /* METRICS_OP_SHADER must be last.
+        * 
+        * All larger values for metrics_op_t are interpreted as:
+        *
+        *      METRICS_OP_SHADER + shader_program_number
+        *
+        * to indicate a specific shader program.
+        */
+       METRICS_OP_SHADER
+} metrics_op_t;
+
 /* Start accumulating GPU time.
  *
  * The time accumulated will be accounted against the
@@ -34,14 +62,20 @@ metrics_counter_start (void);
 void
 metrics_counter_stop (void);
 
-/* Set the ID of the currently executing shader program.
+/* Set a metrics_op_t value to indicate what kind of operation is
+ * being performed.
+ *
+ * The metrics-tracking code will account for timings by accumulating
+ * measured counter values into a separate counter for each
+ * metrics_op_t value, (so that the report can describe which
+ * operations are the most expensive).
  *
- * The metrics-tracking code will account for per-shader-program
- * timings by accumulating counter values measured while each porogram
- * is active (see metrics_add_counter).
+ * In addition, for the value METRICS_OP_SHADER, each specific shader
+ * program can be distinguished. To accomplish this, pass a value of
+ * METRICS_OP_SHADER + shader_program_number to this function.
  */
 void
-metrics_set_current_program (unsigned program);
+metrics_set_current_op (metrics_op_t op);
 
 /* Should be called at the end of every function wrapper for a
  * function that ends a frame, (glXSwapBuffers and similar).