Source code of Windows XP (NT5)
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.

232 lines
8.2 KiB

  1. /*
  2. ** Copyright 1995-2095, Silicon Graphics, Inc.
  3. ** All Rights Reserved.
  4. **
  5. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6. ** the contents of this file may not be disclosed to third parties, copied or
  7. ** duplicated in any form, in whole or in part, without the prior written
  8. ** permission of Silicon Graphics, Inc.
  9. **
  10. ** RESTRICTED RIGHTS LEGEND:
  11. ** Use, duplication or disclosure by the Government is subject to restrictions
  12. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15. ** rights reserved under the Copyright Laws of the United States.
  16. */
  17. #include "glslib.h"
  18. #define __GLS_HEAD_LARGE_BYTES sizeof(__GLSbinCommandHead_large)
  19. GLboolean __glsReader_call_bin(__GLSreader *inoutReader) {
  20. GLubyte *pc;
  21. GLubyte *pcNext;
  22. GLuint word;
  23. __GLSdecodeBinFunc *const dispatchDecode = (
  24. __GLS_CONTEXT->dispatchDecode_bin
  25. );
  26. GLubyte *pcLimit;
  27. if (
  28. inoutReader->readPtr + __GLS_HEAD_LARGE_BYTES > inoutReader->readTail &&
  29. !__glsReader_fillBuf(inoutReader, __GLS_HEAD_LARGE_BYTES, GL_TRUE)
  30. ) {
  31. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  32. return GL_FALSE;
  33. }
  34. pc = inoutReader->readPtr;
  35. pcLimit = inoutReader->readTail - __GLS_HEAD_LARGE_BYTES;
  36. for (;;) {
  37. if (word = *(GLuint *)pc) {
  38. pcNext = pc + (__GLS_COUNT_SMALL(word) << 2);
  39. word = __glsMapOpcode(__GLS_OP_SMALL(word));
  40. if (pcNext > pcLimit) {
  41. inoutReader->readPtr = pc;
  42. if (__GLS_CONTEXT->abortMode) break;
  43. if (!__glsReader_fillBuf(
  44. inoutReader, (size_t)(pcNext - pc + __GLS_HEAD_LARGE_BYTES), GL_TRUE
  45. )) {
  46. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  47. break;
  48. }
  49. pc = inoutReader->readPtr;
  50. pcLimit = inoutReader->readTail - __GLS_HEAD_LARGE_BYTES;
  51. } else if (pcNext == pc) {
  52. inoutReader->readPtr = pc;
  53. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  54. break;
  55. } else if (!__glsOpcodeString[word]) {
  56. __GLS_CALL_UNSUPPORTED_COMMAND(__GLS_CONTEXT);
  57. pc = pcNext;
  58. } else {
  59. #ifndef __GLS_PLATFORM_WIN32
  60. // DrewB
  61. dispatchDecode[word](pc + 4);
  62. #else
  63. dispatchDecode[word](__GLS_CONTEXT, pc + 4);
  64. #endif
  65. pc = pcNext;
  66. }
  67. } else if (word = __GLS_HEAD_LARGE(pc)->opLarge) {
  68. word = __glsMapOpcode(word);
  69. pcNext = pc + (__GLS_HEAD_LARGE(pc)->countLarge << 2);
  70. if (word == GLS_OP_glsEndGLS) {
  71. inoutReader->readPtr = pcNext;
  72. return GL_TRUE;
  73. } else if (pcNext > pcLimit) {
  74. inoutReader->readPtr = pc;
  75. if (__GLS_CONTEXT->abortMode) break;
  76. if (!__glsReader_fillBuf(
  77. inoutReader, (size_t)((ULONG_PTR)(pcNext - pc + __GLS_HEAD_LARGE_BYTES)), GL_TRUE
  78. )) {
  79. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  80. break;
  81. }
  82. pc = inoutReader->readPtr;
  83. pcLimit = inoutReader->readTail - __GLS_HEAD_LARGE_BYTES;
  84. } else if (pcNext == pc) {
  85. inoutReader->readPtr = pc;
  86. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  87. break;
  88. } else if (!__glsOpcodeString[word]) {
  89. __GLS_CALL_UNSUPPORTED_COMMAND(__GLS_CONTEXT);
  90. pc = pcNext;
  91. } else {
  92. #ifndef __GLS_PLATFORM_WIN32
  93. // DrewB
  94. dispatchDecode[word](pc + 12);
  95. #else
  96. dispatchDecode[word](__GLS_CONTEXT, pc + 12);
  97. #endif
  98. pc = pcNext;
  99. }
  100. } else {
  101. inoutReader->readPtr = pc;
  102. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  103. break;
  104. }
  105. }
  106. return GL_FALSE;
  107. }
  108. GLboolean __glsReader_call_bin_swap(__GLSreader *inoutReader) {
  109. GLubyte *pc;
  110. GLubyte *pcNext;
  111. GLuint word;
  112. const __GLSdecodeBinFunc *const dispatchDecode = (
  113. __glsDispatchDecode_bin_swap
  114. );
  115. GLubyte *pcLimit;
  116. if (
  117. inoutReader->readPtr + __GLS_HEAD_LARGE_BYTES > inoutReader->readTail &&
  118. !__glsReader_fillBuf(inoutReader, __GLS_HEAD_LARGE_BYTES, GL_TRUE)
  119. ) {
  120. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  121. return GL_FALSE;
  122. }
  123. pc = inoutReader->readPtr;
  124. pcLimit = inoutReader->readTail - __GLS_HEAD_LARGE_BYTES;
  125. for (;;) {
  126. if (__GLS_CONTEXT->abortMode) {
  127. inoutReader->readPtr = pc;
  128. break;
  129. } else if (*(GLuint *)pc) {
  130. __glsSwap2(pc);
  131. __glsSwap2(pc + 2);
  132. word = *(GLuint*)pc;
  133. pcNext = pc + (__GLS_COUNT_SMALL(word) << 2);
  134. word = __glsMapOpcode(__GLS_OP_SMALL(word));
  135. if (pcNext > pcLimit) {
  136. inoutReader->readPtr = pc;
  137. if (!__glsReader_fillBuf(
  138. inoutReader, (size_t)((ULONG_PTR)(pcNext - pc + __GLS_HEAD_LARGE_BYTES)), GL_TRUE
  139. )) {
  140. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  141. break;
  142. }
  143. pc = inoutReader->readPtr;
  144. pcLimit = inoutReader->readTail - __GLS_HEAD_LARGE_BYTES;
  145. __glsSwap2(pc);
  146. __glsSwap2(pc + 2);
  147. } else if (pcNext == pc) {
  148. inoutReader->readPtr = pc;
  149. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  150. break;
  151. } else if (!__glsOpcodeString[word]) {
  152. __GLS_CALL_UNSUPPORTED_COMMAND(__GLS_CONTEXT);
  153. pc = pcNext;
  154. } else {
  155. #ifndef __GLS_PLATFORM_WIN32
  156. // DrewB
  157. dispatchDecode[word](pc + 4);
  158. #else
  159. dispatchDecode[word](__GLS_CONTEXT, pc + 4);
  160. #endif
  161. pc = pcNext;
  162. }
  163. } else if (__GLS_HEAD_LARGE(pc)->opLarge) {
  164. __glsSwap4(&__GLS_HEAD_LARGE(pc)->opLarge);
  165. __glsSwap4(&__GLS_HEAD_LARGE(pc)->countLarge);
  166. word = __glsMapOpcode(__GLS_HEAD_LARGE(pc)->opLarge);
  167. pcNext = pc + (__GLS_HEAD_LARGE(pc)->countLarge << 2);
  168. if (word == GLS_OP_glsEndGLS) {
  169. inoutReader->readPtr = pcNext;
  170. return GL_TRUE;
  171. } else if (pcNext > pcLimit) {
  172. inoutReader->readPtr = pc;
  173. if (!__glsReader_fillBuf(
  174. inoutReader, (size_t)((ULONG_PTR)(pcNext - pc + __GLS_HEAD_LARGE_BYTES)), GL_TRUE
  175. )) {
  176. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  177. break;
  178. }
  179. pc = inoutReader->readPtr;
  180. pcLimit = inoutReader->readTail - __GLS_HEAD_LARGE_BYTES;
  181. __glsSwap4(&__GLS_HEAD_LARGE(pc)->opLarge);
  182. __glsSwap4(&__GLS_HEAD_LARGE(pc)->countLarge);
  183. } else if (pcNext == pc) {
  184. inoutReader->readPtr = pc;
  185. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  186. break;
  187. } else if (!__glsOpcodeString[word]) {
  188. __GLS_CALL_UNSUPPORTED_COMMAND(__GLS_CONTEXT);
  189. pc = pcNext;
  190. } else {
  191. #ifndef __GLS_PLATFORM_WIN32
  192. // DrewB
  193. dispatchDecode[word](pc + 12);
  194. #else
  195. dispatchDecode[word](__GLS_CONTEXT, pc + 12);
  196. #endif
  197. pc = pcNext;
  198. }
  199. } else {
  200. inoutReader->readPtr = pc;
  201. __GLS_RAISE_ERROR(GLS_DECODE_ERROR);
  202. break;
  203. }
  204. }
  205. return GL_FALSE;
  206. }
  207. GLSenum __glsReader_readBeginGLS_bin(
  208. __GLSreader *inoutReader, __GLSversion *outVersion
  209. ) {
  210. if (__glsReader_fillBuf(
  211. inoutReader, sizeof(__GLSbinCommand_BeginGLS), GL_FALSE
  212. )) {
  213. const GLSenum outType = __glsBinCommand_BeginGLS_getType(
  214. (__GLSbinCommand_BeginGLS *)inoutReader->readPtr, outVersion
  215. );
  216. if (outType != GLS_NONE) {
  217. inoutReader->readPtr += sizeof(__GLSbinCommand_BeginGLS);
  218. }
  219. return outType;
  220. } else {
  221. return GLS_NONE;
  222. }
  223. }