Leaked source code of windows server 2003
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.

307 lines
9.4 KiB

  1. #ifndef __gldlist_h_
  2. #define __gldlist_h_
  3. /*
  4. ** Copyright 1991-1993, Silicon Graphics, Inc.
  5. ** All Rights Reserved.
  6. **
  7. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  8. ** the contents of this file may not be disclosed to third parties, copied or
  9. ** duplicated in any form, in whole or in part, without the prior written
  10. ** permission of Silicon Graphics, Inc.
  11. **
  12. ** RESTRICTED RIGHTS LEGEND:
  13. ** Use, duplication or disclosure by the Government is subject to restrictions
  14. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  15. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  16. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  17. ** rights reserved under the Copyright Laws of the United States.
  18. **
  19. ** Display list state descriptions.
  20. **
  21. */
  22. #include "os.h"
  23. #include "types.h"
  24. typedef const GLubyte * FASTCALL __GLlistExecFunc(__GLcontext *gc, const GLubyte *);
  25. /*
  26. ** Maximum recursive nesting of display list calls.
  27. */
  28. #define __GL_MAX_LIST_NESTING 64
  29. //
  30. // Turn on list sharing for NT if we're a client/server implementation
  31. //
  32. #ifdef NT
  33. #define NT_SERVER_SHARE_LISTS
  34. #endif
  35. #ifndef NT
  36. /*
  37. ** Machine specific opcodes should start here. All opcodes lower than
  38. ** this are reserved by the generic code.
  39. */
  40. #define __GL_MACHINE_DLIST_OPCODE 10000
  41. typedef void (FASTCALL *__GLdlistFreeProc)(__GLcontext *gc, GLubyte *);
  42. /*
  43. ** A compiled, unoptimized dlist. Conceptually a linked list of operations.
  44. ** An optimizer may work through the operations and delete, add, or change
  45. ** them.
  46. **
  47. ** These are only stored transiently. They are created, optimized, and
  48. ** converted into optimized dlists.
  49. **
  50. ** This structure *MUST* be set up so that data is doubleword aligned!
  51. */
  52. struct __GLdlistOpRec {
  53. __GLdlistOp *next; /* Linked list chain */
  54. __GLdlistFreeProc dlistFree;
  55. /* This dlist free function is called when
  56. ** the entire dlist is freed. It is passed
  57. ** a pointer to data. It should *not* free
  58. ** data, but only any memory that has been
  59. ** allocated and is pointed to by the
  60. ** structure contained in data (which will
  61. ** be freed after this function returns).
  62. */
  63. GLuint size; /* Actual size of data */
  64. GLshort opcode; /* Opcode for this operation */
  65. GLboolean aligned; /* GL_TRUE if data needs to be doubleword
  66. ** aligned.
  67. */
  68. GLboolean pad1; /* Padding */
  69. GLubyte data[4]; /* Variable size */
  70. };
  71. typedef struct __GLcompiledDistRec {
  72. GLint freeCount; /* Number of free functions defined */
  73. GLuint genericFlags; /* Flags needed by generic optimizers */
  74. GLuint machineFlags; /* Machine controlled flags */
  75. __GLdlistOp *dlist; /* The linked list of operations */
  76. __GLdlistOp *lastDlist; /* For quick appends */
  77. } __GLcompiledDlist;
  78. typedef struct __GLDlistFreeFnRec {
  79. __GLdlistFreeProc freeFn;
  80. GLubyte *data;
  81. } __GLDlistFreeFn;
  82. #endif // !NT
  83. /*
  84. ** A fully optimized dlist. One of these is stored for every permanent
  85. ** dlist.
  86. **
  87. ** NOTE: 'head' is assumed to start at word offset, but NOT a double word
  88. ** offset!
  89. */
  90. typedef struct __GLdlistRec __GLdlist;
  91. struct __GLdlistRec {
  92. GLuint refcount; /* To deal with multi-threading, must be first */
  93. GLuint size; /* Total size of this block */
  94. #ifndef NT
  95. GLint freeCount; /* Number of operations */
  96. __GLDlistFreeFn *freeFns; /* Array of functions called before freeing */
  97. #endif
  98. GLubyte *end; /* End of optimized block */
  99. #ifdef NT
  100. #if 0
  101. GLint drawBuffer; /* Contains DrawBuffer calls or not,
  102. used for optimizing lock checking in
  103. DCLDispatchLoop */
  104. #endif
  105. GLuint used; /* Amount of space used in the list so far */
  106. __GLdlist *nextBlock; /* Next block in chain of blocks */
  107. #if 0
  108. GLuint pad; /* Pad to put head on a word offset */
  109. #endif
  110. #endif // NT
  111. GLubyte head[4]; /* Optimized block (variable size) */
  112. };
  113. #ifdef NT
  114. // Adds on overhead bytes for a given dlist op data size
  115. // Currently the only overhead is four bytes for the function pointer
  116. #define DLIST_SIZE(n) ((n)+sizeof(__GLlistExecFunc *))
  117. #define DLIST_GENERIC_OP(name) __glle_##name
  118. #else
  119. #define DLIST_SIZE(n) (n)
  120. #define DLIST_GENERIC_OP(name) __glop_##name
  121. #define DLIST_OPT_OP(name) __glop_##name
  122. #endif
  123. #ifndef NT
  124. /*
  125. ** Some data structure for storing and retrieving display lists quickly.
  126. ** This structure is kept hidden so that a new implementation can be used
  127. ** if desired.
  128. */
  129. typedef struct __GLdlistArrayRec __GLdlistArray;
  130. #endif
  131. typedef struct __GLdlistMachineRec {
  132. #ifndef NT
  133. __GLdlistArray *dlistArray;
  134. #endif
  135. __GLnamesArray *namesArray;
  136. #ifndef NT
  137. /*
  138. ** The optimizer for the display list. Runs through a __GLcompiledDlist
  139. ** and deletes, changes, adds operations. Presumably, this optimizer
  140. ** will be a set of function calls to other optimizers (some provided
  141. ** by the generic dlist code, some by machine specific code).
  142. **
  143. ** Operations created by the machine specific optimizers need to have
  144. ** opcodes starting with __GL_MACHINE_DLIST_OPCODE.
  145. */
  146. void (FASTCALL *optimizer)(__GLcontext *gc, __GLcompiledDlist *);
  147. /*
  148. ** This routine is called before puting each new command into the
  149. ** display list at list compilation time.
  150. */
  151. void (FASTCALL *checkOp)(__GLcontext *gc, __GLdlistOp *);
  152. #endif
  153. /*
  154. ** This routine is called when a new display list is about to be
  155. ** compiled.
  156. */
  157. void (FASTCALL *initState)(__GLcontext *gc);
  158. #ifndef NT
  159. /*
  160. ** Array of functions pointers used for display list execution of
  161. ** generic ops.
  162. */
  163. __GLlistExecFunc **baseListExec;
  164. /*
  165. ** Array of functions pointers used for display list execution of
  166. ** generic optimizations.
  167. */
  168. __GLlistExecFunc **listExec;
  169. /*
  170. ** The machine specific list execution routines. These function
  171. ** pointers are bound into the display list at list compilation time,
  172. ** so it is illegal to be changing these dynamically based upon the
  173. ** machine state. Any optimizations based upon the current state need
  174. ** to be performed in the machine specific code. The first entry of
  175. ** this array corresponds to opcode __GL_MACHINE_DLIST_OPCODE, and
  176. ** subsequent entries correspond to subsequent opcodes.
  177. **
  178. ** machineListExec is a pointer to an array of function pointers.
  179. */
  180. __GLlistExecFunc **machineListExec;
  181. #endif
  182. /*
  183. ** If a list is being executed (glCallList or glCallLists) then this
  184. ** is the current nesting of calls. It is constrained by the limit
  185. ** __GL_MAX_LIST_NESTING (this prevents infinite recursion).
  186. */
  187. GLint nesting;
  188. /*
  189. ** GL_COMPILE or GL_COMPILE_AND_EXECUTE.
  190. */
  191. GLenum mode;
  192. /*
  193. ** List being compiled - 0 means none.
  194. */
  195. GLuint currentList;
  196. #ifdef NT
  197. /* Points to the current begin record when compiling poly array */
  198. struct __gllc_Begin_Rec *beginRec;
  199. /* Skip compiling of the next PolyData when compiling poly array */
  200. GLboolean skipPolyData;
  201. #endif
  202. #if 0
  203. #ifdef NT
  204. // Whether the current list contains a DrawBuffer call or not
  205. GLboolean drawBuffer;
  206. #endif
  207. #endif
  208. #ifndef NT
  209. /*
  210. ** Data for the current list being compiled.
  211. */
  212. __GLcompiledDlist listData;
  213. /*
  214. ** For fast memory manipulation. Check out soft/so_memmgr for details.
  215. */
  216. __GLarena *arena;
  217. #else
  218. /*
  219. ** Data for current list
  220. */
  221. __GLdlist *listData;
  222. #endif
  223. } __GLdlistMachine;
  224. #ifndef NT
  225. extern void FASTCALL__glDestroyDisplayLists(__GLcontext *gc);
  226. #endif
  227. #ifdef NT_SERVER_SHARE_LISTS
  228. extern GLboolean FASTCALL __glCanShareDlist(__GLcontext *gc, __GLcontext *share_cx);
  229. #endif
  230. extern void FASTCALL __glShareDlist(__GLcontext *gc, __GLcontext *share_cx);
  231. // Perform thread-exit cleanup for dlists
  232. #ifdef NT_SERVER_SHARE_LISTS
  233. extern void __glDlistThreadCleanup(__GLcontext *gc);
  234. #endif
  235. /*
  236. ** Assorted routines needed by dlist compilation routines.
  237. */
  238. /*
  239. ** Create and destroy display list ops. __glDlistAllocOp2() sets an
  240. ** out of memory error before returning NULL if there is no memory left.
  241. */
  242. #ifndef NT
  243. extern __GLdlistOp *__glDlistAllocOp(__GLcontext *gc, GLuint size);
  244. extern __GLdlistOp *__glDlistAllocOp2(__GLcontext *gc, GLuint size);
  245. extern void FASTCALL __glDlistFreeOp(__GLcontext *gc, __GLdlistOp *op);
  246. /*
  247. ** Append the given op to the currently under construction list.
  248. */
  249. extern void FASTCALL __glDlistAppendOp(__GLcontext *gc, __GLdlistOp *newop,
  250. __GLlistExecFunc *listExec);
  251. #else
  252. extern __GLdlist *__glDlistGrow(GLuint size);
  253. #endif
  254. /*
  255. ** Create and destroy optimized display lists.
  256. */
  257. extern __GLdlist *__glAllocDlist(__GLcontext *gc, GLuint size);
  258. extern void FASTCALL __glFreeDlist(__GLcontext *gc, __GLdlist *dlist);
  259. #ifndef NT
  260. /*
  261. ** Generic dlist memory manager.
  262. */
  263. extern void *__glDlistAlloc(GLuint size);
  264. extern void *__glDlistRealloc(void *oldmem, GLuint oldsize, GLuint newsize);
  265. extern void FASTCALL __glDlistFree(void *memory, GLuint size);
  266. /*
  267. ** Generic table of display list execution routines.
  268. */
  269. extern __GLlistExecFunc *__glListExecTable[];
  270. #endif
  271. #endif /* __gldlist_h_ */