11
Bernd Kreimeier, Loki Entertainment, bk 'at' lokigames.com
12
Brian Paul, VA Linux Systems, Inc., brianp 'at' valinux.com
27
OpenGL 1.2 is required.
28
The extension is written against the OpenGL 1.2 Specification
32
Provides the application with means to enable and disable logging
33
of GL calls including parameters as readable text. The verbosity
34
of the generated log can be controlled. The resulting logs are
35
valid (but possibly incomplete) C code and can be compiled and
36
linked for standalone test programs. The set of calls and the
37
amount of static data that is logged can be controlled at runtime.
38
The application can add comments and enable or disable tracing of GL
39
operations at any time. The data flow from the application to GL
40
and back is unaffected except for timing.
42
Application-side implementation of these features raises namespace
43
and linkage issues. In the driver dispatch table a simple
44
"chain of responsibility" pattern (aka "composable piepline")
49
The extension spec is in the public domain. The current implementation
50
in Mesa is covered by Mesa's XFree86-style copyright by the authors above.
51
This extension is partially inspired by the Quake2 QGL wrapper.
56
(1) Is this Extension obsolete because it can
57
be implemented as a wrapper DLL?
59
RESOLVED: No. While certain operating systems (Win32) provide linkers
60
that facilitate this kind of solution, other operating systems
61
(Linux) do not support hierarchical linking, so a wrapper solution
62
would result in symbol collisions.
63
Further, IHV's might have builtin support for tracing GL execution
64
that enjoys privileged access, or that they do not wish to separate
65
the tracing code from their driver code base.
67
(2) Should the Trace API explicitely support the notion of "frames?
68
This would require hooking into glXSwapBuffers calls as well.
70
RESOLVED: No. The application can use NewTraceMESA/EndTraceMESA
71
and TraceComment along with external parsing tools to split the
72
trace into frames, in whatever way considered adequate.
74
(2a) Should GLX calls be traced?
76
PBuffers and other render-to-texture solutions demonstrate that
77
context level commands beyond SwapBuffers might have to be
78
traced. The GL DLL exports the entry points, so this would not
79
be out of the question.
81
(3) Should the specification mandate the actual output format?
83
RESOLVED: No. It is sufficient to guarantee that all data and commands
84
will be traced as requested by Enable/DisableTraceMESA, in the order
85
encountered. Whether the resulting trace is available as a readable
86
text file, binary metafile, compilable source code, much less which
87
indentation and formatting has been used, is up to the implementation.
88
For the same reason this specification does not enforce or prohibit
89
additional information added to the trace (statistics, profiling/timing,
90
warnings on possible error conditions).
92
(4) Should the comment strings associated with names and pointer (ranges)
93
be considered persistent state?
95
RESOLVED: No. The implementation is not forced to use this information
96
on subsequent occurences of name/pointer, and is free to consider it
99
(5) Should comment commands be prohibited between Begin/End?
101
RESOLVED: Yes, with the exception of TraceCommentMESA. TraceCommentMESA
102
is transient, the other commands might cause storage of persistent
103
data in the context. There is no need to have the ability mark names
104
or pointers between Begin and End.
107
New Procedures and Functions
109
void NewTraceMESA( bitfield mask, const ubyte * traceName )
111
void EndTraceMESA( void )
113
void EnableTraceMESA( bitfield mask )
115
void DisableTraceMESA( bitfield mask )
117
void TraceAssertAttribMESA( bitfield attribMask )
119
void TraceCommentMESA( const ubyte* comment )
121
void TraceTextureMESA( uint name, const ubyte* comment )
123
void TraceListMESA( uint name, const ubyte* comment )
125
void TracePointerMESA( void* pointer, const ubyte* comment )
127
void TracePointerRangeMESA( const void* first,
129
const ubyte* comment )
133
Accepted by the <mask> parameter of EnableTrace and DisableTrace:
135
TRACE_ALL_BITS_MESA 0xFFFF
136
TRACE_OPERATIONS_BIT_MESA 0x0001
137
TRACE_PRIMITIVES_BIT_MESA 0x0002
138
TRACE_ARRAYS_BIT_MESA 0x0004
139
TRACE_TEXTURES_BIT_MESA 0x0008
140
TRACE_PIXELS_BIT_MESA 0x0010
141
TRACE_ERRORS_BIT_MESA 0x0020
143
Accepted by the <pname> parameter of GetIntegerv, GetBooleanv,
144
GetFloatv, and GetDoublev:
146
TRACE_MASK_MESA 0x8755
148
Accepted by the <pname> parameter to GetString:
150
TRACE_NAME_MESA 0x8756
153
Additions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation)
157
Additions to Chapter 3 of the OpenGL 1.2.1 Specification (OpenGL Operation)
161
Additions to Chapter 4 of the OpenGL 1.2.1 Specification (OpenGL Operation)
165
Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions)
171
The tracing facility is used to record the execution of a GL program
172
to a human-readable log. The log appears as a sequence of GL commands
173
using C syntax. The primary intention of tracing is to aid in program
176
A trace is started with the command
178
void NewTraceMESA( bitfield mask, const GLubyte * traceName )
180
<mask> may be any value accepted by PushAttrib and specifies a set of
181
attribute groups. The state values included in those attribute groups
182
is written to the trace as a sequence of GL commands.
184
<traceName> specifies a name or label for the trace. It is expected
185
that <traceName> will be interpreted as a filename in most implementations.
187
A trace is ended by calling the command
189
void EndTraceMESA( void )
191
It is illegal to call NewTraceMESA or EndTraceMESA between Begin and End.
195
void EnableTraceMESA( bitfield mask )
196
void DisableTraceMESA( bitfield mask )
198
enable or disable tracing of different classes of GL commands.
199
<mask> may be the union of any of TRACE_OPERATIONS_BIT_MESA,
200
TRACE_PRIMITIVES_BIT_MESA, TRACE_ARRAYS_BIT_MESA, TRACE_TEXTURES_BIT_MESA,
201
and TRACE_PIXELS_BIT_MESA. The special token TRACE_ALL_BITS_MESA
202
indicates all classes of commands are to be logged.
204
TRACE_OPERATIONS_BIT_MESA controls logging of all commands outside of
205
Begin/End, including Begin/End.
207
TRACE_PRIMITIVES_BIT_MESA controls logging of all commands inside of
208
Begin/End, including Begin/End.
210
TRACE_ARRAYS_BIT_MESA controls logging of VertexPointer, NormalPointer,
211
ColorPointer, IndexPointer, TexCoordPointer and EdgeFlagPointer commands.
213
TRACE_TEXTURES_BIT_MESA controls logging of texture data dereferenced by
214
TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, and
215
TexSubImage3D commands.
217
TRACE_PIXELS_BIT_MESA controls logging of image data dereferenced by
218
Bitmap and DrawPixels commands.
220
TRACE_ERRORS_BIT_MESA controls logging of all errors. If this bit is
221
set, GetError will be executed whereever applicable, and the result will
222
be added to the trace as a comment. The error returns are cached and
223
returned to the application on its GetError calls. If the user does not
224
wish the additional GetError calls to be performed, this bit should not
229
void TraceCommentMESA( const ubyte* comment )
231
immediately adds the <comment> string to the trace output, surrounded
232
by C-style comment delimiters.
236
void TraceTextureMESA( uint name, const ubyte* comment )
237
void TraceListMESA( uint name, const ubyte* comment )
239
associates <comment> with the texture object or display list specified
240
by <name>. Logged commands which reference the named texture object or
241
display list will be annotated with <comment>. If IsTexture(name) or
242
IsList(name) fail (respectively) the command is quietly ignored.
246
void TracePointerMESA( void* pointer, const ubyte* comment )
248
void TracePointerRangeMESA( const void* first,
250
const ubyte* comment )
252
associate <comment> with the address specified by <pointer> or with
253
a range of addresses specified by <first> through <last>.
254
Any logged commands which reference <pointer> or an address between
255
<first> and <last> will be annotated with <comment>.
259
void TraceAssertAttribMESA( bitfield attribMask )
261
will add GL state queries and assertion statements to the log to
262
confirm that the current state at the time TraceAssertAttrib is
263
executed matches the current state when the trace log is executed
266
<attribMask> is any value accepted by PushAttrib and specifies
267
the groups of state variables which are to be asserted.
269
The commands NewTraceMESA, EndTraceMESA, EnableTraceMESA, DisableTraceMESA,
270
TraceAssertAttribMESA, TraceCommentMESA, TraceTextureMESA, TraceListMESA,
271
TracePointerMESA and TracePointerRangeMESA are not compiled into display lists.
276
The command NewTraceMESA(DEPTH_BUFFER_BIT, "log") will query the state
277
variables DEPTH_TEST, DEPTH_FUNC, DEPTH_WRITEMASK, and DEPTH_CLEAR_VALUE
278
to get the values <test>, <func>, <mask>, and <clear> respectively.
279
Statements equivalent to the following will then be logged:
281
glEnable(GL_DEPTH_TEST); (if <test> is true)
282
glDisable(GL_DEPTH_TEST); (if <test> is false)
285
glClearDepth(<clear>);
288
The command TraceAssertAttribMESA(DEPTH_BUFFER_BIT) will query the state
289
variables DEPTH_TEST, DEPTH_FUNC, DEPTH_WRITEMASK, and DEPTH_CLEAR_VALUE
290
to get the values <test>, <func>, <mask>, and <clear> respectively.
291
The resulting trace might then look will like this:
297
b = glIsEnabled(GL_DEPTH_TEST);
299
glGetIntegerv(GL_DEPTH_FUNC, &i);
301
glGetIntegerv(GL_DEPTH_MASK, &i);
303
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &f);
304
assert(f == <clear>);
308
Additions to Chapter 6 of the OpenGL 1.2.1 Specification
309
(State and State Requests)
311
Querying TRACE_MASK_MESA with GetIntegerv, GetFloatv, GetBooleanv or
312
GetDoublev returns the current command class trace mask.
314
Querying TRACE_NAME_MESA with GetString returns the current trace name.
317
Additions to Appendix A of the OpenGL 1.2.1 Specification (Invariance)
319
The MESA_trace extension can be used in a way that does not affect data
320
flow from application to OpenGL, as well as data flow from OpenGL to
321
application, except for timing, possible print I/O. TRACE_ERRORS_BIT_MESA
322
will add additional GetError queries. Setting a trace mask with NewTraceMESA
323
as well as use of TraceAssertAttribMESA might cause additional state queries.
324
With the possible exception of performance, OpenGL rendering should not be
325
affected at all by a properly chosen logging operation.
327
Additions to the AGL/GLX/WGL Specifications
333
None. The logging operation is carried out client-side, by exporting
334
entry points to the wrapper functions that execute the logging operation.
338
INVALID_OPERATION is generated if any trace command except TraceCommentMESA
339
is called between Begin and End.
343
The current trace name and current command class mask are stored
346
New Implementation Dependent State
352
* Revision 0.1 - Initial draft from template (bk000415)
353
* Revision 0.2 - Draft (bk000906)
354
* Revision 0.3 - Draft (bk000913)
355
* Revision 0.4 - Reworked text, fixed typos (bp000914)
356
* Revision 0.5 - Assigned final GLenum values (bp001103)
357
* Revision 0.6 - TRACE_ERRORS_BIT_MESA (bk000916)
358
* Revision 0.7 - Added MESA postfix (bk010126)