Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MESA_trace.spec 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. Name
  2. MESA_trace
  3. Name Strings
  4. GL_MESA_trace
  5. Contact
  6. Bernd Kreimeier, Loki Entertainment, bk 'at' lokigames.com
  7. Brian Paul, VA Linux Systems, Inc., brianp 'at' valinux.com
  8. Status
  9. Obsolete.
  10. Version
  11. Number
  12. none yet
  13. Dependencies
  14. OpenGL 1.2 is required.
  15. The extension is written against the OpenGL 1.2 Specification
  16. Overview
  17. Provides the application with means to enable and disable logging
  18. of GL calls including parameters as readable text. The verbosity
  19. of the generated log can be controlled. The resulting logs are
  20. valid (but possibly incomplete) C code and can be compiled and
  21. linked for standalone test programs. The set of calls and the
  22. amount of static data that is logged can be controlled at runtime.
  23. The application can add comments and enable or disable tracing of GL
  24. operations at any time. The data flow from the application to GL
  25. and back is unaffected except for timing.
  26. Application-side implementation of these features raises namespace
  27. and linkage issues. In the driver dispatch table a simple
  28. "chain of responsibility" pattern (aka "composable piepline")
  29. can be added.
  30. IP Status
  31. The extension spec is in the public domain. The current implementation
  32. in Mesa is covered by Mesa's XFree86-style copyright by the authors above.
  33. This extension is partially inspired by the Quake2 QGL wrapper.
  34. Issues
  35. (1) Is this Extension obsolete because it can
  36. be implemented as a wrapper DLL?
  37. RESOLVED: No. While certain operating systems (Win32) provide linkers
  38. that facilitate this kind of solution, other operating systems
  39. (Linux) do not support hierarchical linking, so a wrapper solution
  40. would result in symbol collisions.
  41. Further, IHV's might have builtin support for tracing GL execution
  42. that enjoys privileged access, or that they do not wish to separate
  43. the tracing code from their driver code base.
  44. (2) Should the Trace API explicitely support the notion of "frames?
  45. This would require hooking into glXSwapBuffers calls as well.
  46. RESOLVED: No. The application can use NewTraceMESA/EndTraceMESA
  47. and TraceComment along with external parsing tools to split the
  48. trace into frames, in whatever way considered adequate.
  49. (2a) Should GLX calls be traced?
  50. PBuffers and other render-to-texture solutions demonstrate that
  51. context level commands beyond SwapBuffers might have to be
  52. traced. The GL DLL exports the entry points, so this would not
  53. be out of the question.
  54. (3) Should the specification mandate the actual output format?
  55. RESOLVED: No. It is sufficient to guarantee that all data and commands
  56. will be traced as requested by Enable/DisableTraceMESA, in the order
  57. encountered. Whether the resulting trace is available as a readable
  58. text file, binary metafile, compilable source code, much less which
  59. indentation and formatting has been used, is up to the implementation.
  60. For the same reason this specification does not enforce or prohibit
  61. additional information added to the trace (statistics, profiling/timing,
  62. warnings on possible error conditions).
  63. (4) Should the comment strings associated with names and pointer (ranges)
  64. be considered persistent state?
  65. RESOLVED: No. The implementation is not forced to use this information
  66. on subsequent occurences of name/pointer, and is free to consider it
  67. transient state.
  68. (5) Should comment commands be prohibited between Begin/End?
  69. RESOLVED: Yes, with the exception of TraceCommentMESA. TraceCommentMESA
  70. is transient, the other commands might cause storage of persistent
  71. data in the context. There is no need to have the ability mark names
  72. or pointers between Begin and End.
  73. New Procedures and Functions
  74. void NewTraceMESA( bitfield mask, const ubyte * traceName )
  75. void EndTraceMESA( void )
  76. void EnableTraceMESA( bitfield mask )
  77. void DisableTraceMESA( bitfield mask )
  78. void TraceAssertAttribMESA( bitfield attribMask )
  79. void TraceCommentMESA( const ubyte* comment )
  80. void TraceTextureMESA( uint name, const ubyte* comment )
  81. void TraceListMESA( uint name, const ubyte* comment )
  82. void TracePointerMESA( void* pointer, const ubyte* comment )
  83. void TracePointerRangeMESA( const void* first,
  84. const void* last,
  85. const ubyte* comment )
  86. New Tokens
  87. Accepted by the <mask> parameter of EnableTrace and DisableTrace:
  88. TRACE_ALL_BITS_MESA 0xFFFF
  89. TRACE_OPERATIONS_BIT_MESA 0x0001
  90. TRACE_PRIMITIVES_BIT_MESA 0x0002
  91. TRACE_ARRAYS_BIT_MESA 0x0004
  92. TRACE_TEXTURES_BIT_MESA 0x0008
  93. TRACE_PIXELS_BIT_MESA 0x0010
  94. TRACE_ERRORS_BIT_MESA 0x0020
  95. Accepted by the <pname> parameter of GetIntegerv, GetBooleanv,
  96. GetFloatv, and GetDoublev:
  97. TRACE_MASK_MESA 0x8755
  98. Accepted by the <pname> parameter to GetString:
  99. TRACE_NAME_MESA 0x8756
  100. Additions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation)
  101. None.
  102. Additions to Chapter 3 of the OpenGL 1.2.1 Specification (OpenGL Operation)
  103. None.
  104. Additions to Chapter 4 of the OpenGL 1.2.1 Specification (OpenGL Operation)
  105. None.
  106. Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions)
  107. Add a new section:
  108. 5.7 Tracing
  109. The tracing facility is used to record the execution of a GL program
  110. to a human-readable log. The log appears as a sequence of GL commands
  111. using C syntax. The primary intention of tracing is to aid in program
  112. debugging.
  113. A trace is started with the command
  114. void NewTraceMESA( bitfield mask, const GLubyte * traceName )
  115. <mask> may be any value accepted by PushAttrib and specifies a set of
  116. attribute groups. The state values included in those attribute groups
  117. is written to the trace as a sequence of GL commands.
  118. <traceName> specifies a name or label for the trace. It is expected
  119. that <traceName> will be interpreted as a filename in most implementations.
  120. A trace is ended by calling the command
  121. void EndTraceMESA( void )
  122. It is illegal to call NewTraceMESA or EndTraceMESA between Begin and End.
  123. The commands
  124. void EnableTraceMESA( bitfield mask )
  125. void DisableTraceMESA( bitfield mask )
  126. enable or disable tracing of different classes of GL commands.
  127. <mask> may be the union of any of TRACE_OPERATIONS_BIT_MESA,
  128. TRACE_PRIMITIVES_BIT_MESA, TRACE_ARRAYS_BIT_MESA, TRACE_TEXTURES_BIT_MESA,
  129. and TRACE_PIXELS_BIT_MESA. The special token TRACE_ALL_BITS_MESA
  130. indicates all classes of commands are to be logged.
  131. TRACE_OPERATIONS_BIT_MESA controls logging of all commands outside of
  132. Begin/End, including Begin/End.
  133. TRACE_PRIMITIVES_BIT_MESA controls logging of all commands inside of
  134. Begin/End, including Begin/End.
  135. TRACE_ARRAYS_BIT_MESA controls logging of VertexPointer, NormalPointer,
  136. ColorPointer, IndexPointer, TexCoordPointer and EdgeFlagPointer commands.
  137. TRACE_TEXTURES_BIT_MESA controls logging of texture data dereferenced by
  138. TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, and
  139. TexSubImage3D commands.
  140. TRACE_PIXELS_BIT_MESA controls logging of image data dereferenced by
  141. Bitmap and DrawPixels commands.
  142. TRACE_ERRORS_BIT_MESA controls logging of all errors. If this bit is
  143. set, GetError will be executed whereever applicable, and the result will
  144. be added to the trace as a comment. The error returns are cached and
  145. returned to the application on its GetError calls. If the user does not
  146. wish the additional GetError calls to be performed, this bit should not
  147. be set.
  148. The command
  149. void TraceCommentMESA( const ubyte* comment )
  150. immediately adds the <comment> string to the trace output, surrounded
  151. by C-style comment delimiters.
  152. The commands
  153. void TraceTextureMESA( uint name, const ubyte* comment )
  154. void TraceListMESA( uint name, const ubyte* comment )
  155. associates <comment> with the texture object or display list specified
  156. by <name>. Logged commands which reference the named texture object or
  157. display list will be annotated with <comment>. If IsTexture(name) or
  158. IsList(name) fail (respectively) the command is quietly ignored.
  159. The commands
  160. void TracePointerMESA( void* pointer, const ubyte* comment )
  161. void TracePointerRangeMESA( const void* first,
  162. const void* last,
  163. const ubyte* comment )
  164. associate <comment> with the address specified by <pointer> or with
  165. a range of addresses specified by <first> through <last>.
  166. Any logged commands which reference <pointer> or an address between
  167. <first> and <last> will be annotated with <comment>.
  168. The command
  169. void TraceAssertAttribMESA( bitfield attribMask )
  170. will add GL state queries and assertion statements to the log to
  171. confirm that the current state at the time TraceAssertAttrib is
  172. executed matches the current state when the trace log is executed
  173. in the future.
  174. <attribMask> is any value accepted by PushAttrib and specifies
  175. the groups of state variables which are to be asserted.
  176. The commands NewTraceMESA, EndTraceMESA, EnableTraceMESA, DisableTraceMESA,
  177. TraceAssertAttribMESA, TraceCommentMESA, TraceTextureMESA, TraceListMESA,
  178. TracePointerMESA and TracePointerRangeMESA are not compiled into display lists.
  179. Examples:
  180. The command NewTraceMESA(DEPTH_BUFFER_BIT, "log") will query the state
  181. variables DEPTH_TEST, DEPTH_FUNC, DEPTH_WRITEMASK, and DEPTH_CLEAR_VALUE
  182. to get the values <test>, <func>, <mask>, and <clear> respectively.
  183. Statements equivalent to the following will then be logged:
  184. glEnable(GL_DEPTH_TEST); (if <test> is true)
  185. glDisable(GL_DEPTH_TEST); (if <test> is false)
  186. glDepthFunc(<func>);
  187. glDepthMask(<mask>);
  188. glClearDepth(<clear>);
  189. The command TraceAssertAttribMESA(DEPTH_BUFFER_BIT) will query the state
  190. variables DEPTH_TEST, DEPTH_FUNC, DEPTH_WRITEMASK, and DEPTH_CLEAR_VALUE
  191. to get the values <test>, <func>, <mask>, and <clear> respectively.
  192. The resulting trace might then look will like this:
  193. {
  194. GLboolean b;
  195. GLint i;
  196. GLfloat f;
  197. b = glIsEnabled(GL_DEPTH_TEST);
  198. assert(b == <test>);
  199. glGetIntegerv(GL_DEPTH_FUNC, &i);
  200. assert(i == <func>);
  201. glGetIntegerv(GL_DEPTH_MASK, &i);
  202. assert(i == <mask>);
  203. glGetFloatv(GL_DEPTH_CLEAR_VALUE, &f);
  204. assert(f == <clear>);
  205. }
  206. Additions to Chapter 6 of the OpenGL 1.2.1 Specification
  207. (State and State Requests)
  208. Querying TRACE_MASK_MESA with GetIntegerv, GetFloatv, GetBooleanv or
  209. GetDoublev returns the current command class trace mask.
  210. Querying TRACE_NAME_MESA with GetString returns the current trace name.
  211. Additions to Appendix A of the OpenGL 1.2.1 Specification (Invariance)
  212. The MESA_trace extension can be used in a way that does not affect data
  213. flow from application to OpenGL, as well as data flow from OpenGL to
  214. application, except for timing, possible print I/O. TRACE_ERRORS_BIT_MESA
  215. will add additional GetError queries. Setting a trace mask with NewTraceMESA
  216. as well as use of TraceAssertAttribMESA might cause additional state queries.
  217. With the possible exception of performance, OpenGL rendering should not be
  218. affected at all by a properly chosen logging operation.
  219. Additions to the AGL/GLX/WGL Specifications
  220. None.
  221. GLX Protocol
  222. None. The logging operation is carried out client-side, by exporting
  223. entry points to the wrapper functions that execute the logging operation.
  224. Errors
  225. INVALID_OPERATION is generated if any trace command except TraceCommentMESA
  226. is called between Begin and End.
  227. New State
  228. The current trace name and current command class mask are stored
  229. per-context.
  230. New Implementation Dependent State
  231. None.
  232. Revision History
  233. * Revision 0.1 - Initial draft from template (bk000415)
  234. * Revision 0.2 - Draft (bk000906)
  235. * Revision 0.3 - Draft (bk000913)
  236. * Revision 0.4 - Reworked text, fixed typos (bp000914)
  237. * Revision 0.5 - Assigned final GLenum values (bp001103)
  238. * Revision 0.6 - TRACE_ERRORS_BIT_MESA (bk000916)
  239. * Revision 0.7 - Added MESA postfix (bk010126)