From fbc5192c8164986f8960815cfbc29730625dd8cf Mon Sep 17 00:00:00 2001
From: =?utf8?q?Jos=C3=A9=20Fonseca?= <jose.r.fonseca@gmail.com>
Date: Sun, 14 Apr 2013 14:45:04 +0100
Subject: [PATCH] gltrace: Better handling of GetPerfMonitorCounterInfoAMD

---
 specs/glapi.py    |  2 +-
 specs/gltypes.py  | 10 ++++++++++
 wrappers/trace.py |  2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/specs/glapi.py b/specs/glapi.py
index b0c0a27..82b7902 100644
--- a/specs/glapi.py
+++ b/specs/glapi.py
@@ -2690,7 +2690,7 @@ glapi.addFunctions([
     GlFunction(Void, "glGetPerfMonitorCountersAMD", [(GLuint, "group"), Out(Pointer(GLint), "numCounters"), Out(Pointer(GLint), "maxActiveCounters"), (GLsizei, "counterSize"), Out(Array(GLuint, "counterSize"), "counters")], sideeffects=False),
     GlFunction(Void, "glGetPerfMonitorGroupStringAMD", [(GLuint, "group"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), OutGlString(GLchar, "length", "groupString")], sideeffects=False),
     GlFunction(Void, "glGetPerfMonitorCounterStringAMD", [(GLuint, "group"), (GLuint, "counter"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), OutGlString(GLchar, "length", "counterString")], sideeffects=False),
-    GlFunction(Void, "glGetPerfMonitorCounterInfoAMD", [(GLuint, "group"), (GLuint, "counter"), (GLenum, "pname"), Out(OpaqueBlob(GLvoid, "_glGetPerfMonitorCounterInfoAMD_size(pname)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetPerfMonitorCounterInfoAMD", [(GLuint, "group"), (GLuint, "counter"), (GLenum, "pname"), Out(GLperfMonitorCounterInfoAMD, "data")], sideeffects=False),
     GlFunction(Void, "glGenPerfMonitorsAMD", [(GLsizei, "n"), Out(Array(GLuint, "n"), "monitors")]),
     GlFunction(Void, "glDeletePerfMonitorsAMD", [(GLsizei, "n"), (Array(GLuint, "n"), "monitors")]),
     GlFunction(Void, "glSelectPerfMonitorCountersAMD", [(GLuint, "monitor"), (GLboolean, "enable"), (GLuint, "group"), (GLint, "numCounters"), (Array(GLuint, "numCounters"), "counterList")]),
diff --git a/specs/gltypes.py b/specs/gltypes.py
index a04990d..0c1b7ae 100644
--- a/specs/gltypes.py
+++ b/specs/gltypes.py
@@ -250,3 +250,13 @@ def GLindexBuffer(countExpr, typeExpr):
         IntPointer("const GLvoid *"), 
         contextLess=False,
     )
+
+
+# GL_AMD_performance_monitor
+GLperfMonitorCounterInfoAMD = Polymorphic('pname', [
+        ('GL_COUNTER_TYPE_AMD', Pointer(GLenum)),
+        ('GL_PERCENTAGE_AMD', Pointer(Float)),
+        ('GL_COUNTER_RANGE_AMD', Array(Float, 2)),
+    ],
+    OpaquePointer(GLvoid),
+)
diff --git a/wrappers/trace.py b/wrappers/trace.py
index 61a2cb9..d9c2900 100644
--- a/wrappers/trace.py
+++ b/wrappers/trace.py
@@ -138,7 +138,7 @@ class ComplexValueSerializer(stdapi.OnceVisitor):
     def visitPolymorphic(self, polymorphic):
         if not polymorphic.contextLess:
             return
-        print 'static void _write__%s(int selector, const %s & value) {' % (polymorphic.tag, polymorphic.expr)
+        print 'static void _write__%s(int selector, %s const & value) {' % (polymorphic.tag, polymorphic.expr)
         print '    switch (selector) {'
         for cases, type in polymorphic.iterSwitch():
             for case in cases:
-- 
2.45.2