Brian Paul | 8e4fa8c | 2000-11-03 15:10:04 +0000 | [diff] [blame^] | 1 | XXX - Not complete yet!!! |
| 2 | |
| 3 | Name |
| 4 | |
| 5 | MESA_trace |
| 6 | |
| 7 | Name Strings |
| 8 | |
| 9 | GL_MESA_TRACE |
| 10 | |
| 11 | Contact |
| 12 | |
| 13 | Bernd Kreimeier, Loki Entertainment, bk 'at' lokigames.com |
| 14 | Brian Paul, VA Linux Systems, Inc., brianp 'at' valinux.com |
| 15 | |
| 16 | Status |
| 17 | |
| 18 | XXX - Not complete yet!!! |
| 19 | |
| 20 | Version |
| 21 | |
| 22 | $Id: MESA_trace.spec,v 1.1 2000/11/03 15:10:04 brianp Exp $ |
| 23 | |
| 24 | Number |
| 25 | |
| 26 | ??? |
| 27 | |
| 28 | Dependencies |
| 29 | |
| 30 | OpenGL 1.2 is required. |
| 31 | The extension is written against the OpenGL 1.2 Specification |
| 32 | |
| 33 | Overview |
| 34 | |
| 35 | Provides the application with means to enable and disable logging |
| 36 | of GL calls including parameters as readable text. The verbosity |
| 37 | of the generated log can be controlled. The resulting logs are |
| 38 | valid (but possibly incomplete) C code and can be compiled and |
| 39 | linked for standalone test programs. The set of calls and the |
| 40 | amount of static data that is logged can be controlled at runtime. |
| 41 | The application can add comments and enable or disable tracing of GL |
| 42 | operations at any time. The data flow from the application to GL |
| 43 | and back is unaffected except for timing. |
| 44 | |
| 45 | Application-side implementation of these features raises namespace |
| 46 | and linkage issues. In the driver dispatch table a simple |
| 47 | "chain of responsibility" pattern (aka "composable piepline") |
| 48 | can be added. |
| 49 | |
| 50 | IP Status |
| 51 | |
| 52 | The extension spec is in the public domain. The current implementation |
| 53 | in Mesa is covered by Mesa's XFree86-style copyright by the authors above. |
| 54 | This extension is partially inspired by the Quake2 QGL wrapper. |
| 55 | |
| 56 | Issues |
| 57 | |
| 58 | none yet |
| 59 | |
| 60 | New Procedures and Functions |
| 61 | |
| 62 | void NewTraceMESA( bitfield mask, const ubyte *traceName ) |
| 63 | |
| 64 | void EndTraceMESA( void ) |
| 65 | |
| 66 | void EnableTraceMESA( bitfield mask ) |
| 67 | |
| 68 | void DisableTraceMESA( bitfield mask ) |
| 69 | |
| 70 | void TraceAssertAttribMESA( bitfield attribMask ) |
| 71 | |
| 72 | void TraceCommentMESA( const ubyte *comment ) |
| 73 | |
| 74 | void TraceTextureMESA( uint name, const ubyte *comment ) |
| 75 | |
| 76 | void TraceListMESA( uint name, const ubyte *comment ) |
| 77 | |
| 78 | void TracePointerMESA( void *pointer, const ubyte *comment ) |
| 79 | |
| 80 | void TracePointerRangeMESA( const void *first, const void *last, |
| 81 | const ubyte *comment ) |
| 82 | |
| 83 | New Tokens |
| 84 | |
| 85 | Accepted by the <mask> parameter of EnableTrace and DisableTrace: |
| 86 | |
| 87 | TRACE_ALL_BITS_MESA 0x0001 |
| 88 | TRACE_OPERATIONS_BIT_MESA 0x0002 |
| 89 | TRACE_PRIMITIVES_BIT_MESA 0x0004 |
| 90 | TRACE_ARRAYS_BIT_MESA 0x0008 |
| 91 | TRACE_TEXTURES_BIT_MESA 0x0010 |
| 92 | TRACE_PIXELS_BIT_MESA 0x0020 |
| 93 | |
| 94 | Accepted by the <pname> parameter of GetIntegerv, GetBooleanv, |
| 95 | GetFloatv, and GetDoublev: |
| 96 | |
| 97 | TRACE_MASK_MESA 0x8755 |
| 98 | |
| 99 | Accepted by the <pname> parameter to GetString: |
| 100 | |
| 101 | TRACE_NAME_MESA 0x8756 |
| 102 | |
| 103 | Additions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation) |
| 104 | |
| 105 | None. |
| 106 | |
| 107 | Additions to Chapter 3 of the OpenGL 1.2.1 Specification (OpenGL Operation) |
| 108 | |
| 109 | None. |
| 110 | |
| 111 | Additions to Chapter 4 of the OpenGL 1.2.1 Specification (OpenGL Operation) |
| 112 | |
| 113 | None. |
| 114 | |
| 115 | Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions) |
| 116 | |
| 117 | Add a new section: |
| 118 | |
| 119 | 5.7 Tracing |
| 120 | |
| 121 | The tracing facility is used to record the execution of a GL program |
| 122 | to a human-readable log. The log appears as a sequence of GL commands |
| 123 | using C syntax. The primary intention of tracing is to aid in program |
| 124 | debugging. |
| 125 | |
| 126 | A trace is started with the command |
| 127 | |
| 128 | void NewTraceMESA( bitfield mask, const GLubyte * traceName ) |
| 129 | |
| 130 | <mask> may be any value accepted by PushAttrib and specifies a set of |
| 131 | attribute groups. The state values included in those attribute groups |
| 132 | is written to the trace as a sequence of GL commands. |
| 133 | |
| 134 | <traceName> specifies a name or label for the trace. It is expected |
| 135 | that <traceName> will be interpreted as a filename in most implementations. |
| 136 | |
| 137 | A trace is ended by calling the command |
| 138 | |
| 139 | void EndTraceMESA( void ) |
| 140 | |
| 141 | It is illegal to call NewTrace or EndTrace between Begin and End. |
| 142 | |
| 143 | The commands |
| 144 | |
| 145 | void EnableTraceMESA( bitfield mask ) |
| 146 | void DisableTraceMESA( bitfield mask ) |
| 147 | |
| 148 | enable or disable tracing of different classes of GL commands. |
| 149 | <mask> may be the union of any of TRACE_OPERATIONS_BIT_MESA, |
| 150 | TRACE_PRIMITIVES_BIT_MESA, TRACE_ARRAYS_BIT_MESA, TRACE_TEXTURES_BIT_MESA, |
| 151 | and TRACE_PIXELS_BIT_MESA. The special token TRACE_ALL_BITS_MESA |
| 152 | indicates all classes of commands are to be logged. |
| 153 | |
| 154 | TRACE_OPERATIONS_BIT_MESA controls logging of all commands outside of |
| 155 | Begin/End, including Begin/End. |
| 156 | |
| 157 | TRACE_PRIMITIVES_BIT_MESA controls logging of all commands inside of |
| 158 | Begin/End, including Begin/End. |
| 159 | |
| 160 | TRACE_ARRAYS_BIT_MESA controls logging of VertexPointer, NormalPointer, |
| 161 | ColorPointer, IndexPointer, TexCoordPointer and EdgeFlagPointer commands. |
| 162 | |
| 163 | TRACE_TEXTURES_BIT_MESA controls logging of texture data dereferenced by |
| 164 | TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, and |
| 165 | TexSubImage3D commands. |
| 166 | |
| 167 | TRACE_PIXELS_BIT_MESA controls logging of image data dereferenced by |
| 168 | Bitmap and DrawPixels commands. |
| 169 | |
| 170 | The command |
| 171 | |
| 172 | void TraceCommentMESA( const ubyte* comment ) |
| 173 | |
| 174 | immediately adds the <comment> string to the trace output, surrounded |
| 175 | by C-style comment delimiters. |
| 176 | |
| 177 | The commands |
| 178 | |
| 179 | void TraceTextureMESA( uint name, const ubyte* comment ) |
| 180 | void TraceListMESA( uint name, const ubyte* comment ) |
| 181 | |
| 182 | associates <comment> with the texture object or display list specified |
| 183 | by <name>. Logged commands which reference the named texture object or |
| 184 | display list will be annotated with <comment>. If IsTexture(name) or |
| 185 | IsList(name) fail (respectively) the command is quietly ignored. |
| 186 | |
| 187 | The commands |
| 188 | |
| 189 | void TracePointerMESA( void* pointer, const ubyte* comment ) |
| 190 | |
| 191 | void TracePointerRangeMESA( const void* first, const void* last, |
| 192 | const ubyte* comment ) |
| 193 | |
| 194 | associate <comment> with the address specified by <pointer> or with |
| 195 | a range of addresses specified by <first> through <last>. |
| 196 | Any logged commands which reference <pointer> or an address between |
| 197 | <first> and <last> will be annotated with <comment>. |
| 198 | |
| 199 | The command |
| 200 | |
| 201 | void TraceAssertAttribMESA( bitfield attribMask ) |
| 202 | |
| 203 | will add GL state queries and assertion statements to the log to |
| 204 | confirm that the current state at the time TraceAssertAttrib is |
| 205 | executed matches the current state when the trace log is executed |
| 206 | in the future. |
| 207 | |
| 208 | <attribMask> is any value accepted by PushAttrib and specifies |
| 209 | the groups of state variables which are to be asserted. |
| 210 | |
| 211 | The commands NewTrace, EndTrace, EnableTrace, DisableTrace, |
| 212 | TraceAssertAttrib, TraceComment, TraceTexture, TraceList, TracePointer, |
| 213 | TracePointerRange, GetTraceName and GetTraceMask are not compiled |
| 214 | into display lists. |
| 215 | |
| 216 | |
| 217 | Examples: |
| 218 | |
| 219 | The command NewTrace(DEPTH_BUFFER_BIT, "log") will query the state |
| 220 | variables DEPTH_TEST, DEPTH_FUNC, DEPTH_WRITEMASK, and DEPTH_CLEAR_VALUE |
| 221 | to get the values <test>, <func>, <mask>, and <clear> respectively. |
| 222 | Statements equivalent to the following will then be logged: |
| 223 | |
| 224 | glEnable(GL_DEPTH_TEST); (if <test> is true) |
| 225 | glDisable(GL_DEPTH_TEST); (if <test> is false) |
| 226 | glDepthFunc(<func>); |
| 227 | glDepthMask(<mask>); |
| 228 | glClearDepth(<clear>); |
| 229 | |
| 230 | |
| 231 | The command TraceAssertAttrib(DEPTH_BUFFER_BIT) will query the state |
| 232 | variables DEPTH_TEST, DEPTH_FUNC, DEPTH_WRITEMASK, and DEPTH_CLEAR_VALUE |
| 233 | to get the values <test>, <func>, <mask>, and <clear> respectively. |
| 234 | Statements equivalent to the following will then be logged: |
| 235 | |
| 236 | { |
| 237 | GLboolean b; |
| 238 | GLint i; |
| 239 | GLfloat f; |
| 240 | b = glIsEnabled(GL_DEPTH_TEST); |
| 241 | assert(b == <test>); |
| 242 | glGetIntegerv(GL_DEPTH_FUNC, &i); |
| 243 | assert(i == <func>); |
| 244 | glGetIntegerv(GL_DEPTH_MASK, &i); |
| 245 | assert(i == <mask>); |
| 246 | glGetFloatv(GL_DEPTH_CLEAR_VALUE, &f); |
| 247 | assert(f == <clear>); |
| 248 | } |
| 249 | |
| 250 | |
| 251 | Additions to Chapter 6 of the OpenGL 1.2.1 Specification |
| 252 | (State and State Requests) |
| 253 | |
| 254 | Querying TRACE_MASK_MESA with GetIntegerv, GetFloatv, GetBooleanv or |
| 255 | GetDoublev returns the current command class trace mask. |
| 256 | |
| 257 | Querying TRACE_NAME_MESA with GetString returns the current trace name. |
| 258 | |
| 259 | Additions to Appendix A of the OpenGL 1.2.1 Specification (Invariance) |
| 260 | |
| 261 | The MESA_tracelog extension does not affect data flow from application |
| 262 | to OpenGL, as well as data flow from OpenGL to application, except for |
| 263 | timing, possible print I/O, and sequence of GetError queries. With |
| 264 | the possible exception of performance, OpenGL rendering should not be |
| 265 | affect by the logging operation. |
| 266 | |
| 267 | Additions to the AGL/GLX/WGL Specifications |
| 268 | |
| 269 | None. |
| 270 | ? Hooking into glXSwapBuffers() ? |
| 271 | |
| 272 | GLX Protocol |
| 273 | |
| 274 | None. The logging operation is carried out client-side, by exporting |
| 275 | entry points to the wrapper functions that execute the logging operation. |
| 276 | |
| 277 | Errors |
| 278 | |
| 279 | INVALID_OPERATION is generated if any trace command except TraceComment |
| 280 | is called between Begin and End. |
| 281 | |
| 282 | New State |
| 283 | |
| 284 | The current trace name and current command class mask are stored |
| 285 | per-context. |
| 286 | |
| 287 | New Implementation Dependent State |
| 288 | |
| 289 | None. |
| 290 | |
| 291 | Revision History |
| 292 | |
| 293 | * Revision 0.1 - Initial draft from template (bk000415) |
| 294 | * Revision 0.2 - Draft (bk000906) |
| 295 | * Revision 0.3 - Draft (bk000913) |
| 296 | * Revision 0.4 - Added GetTraceName/Mask, fixed typos (bp000914) |
| 297 | * Revision 0.5 - Assigned final GLenum values |