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.

635 lines
16 KiB

  1. /*
  2. ** Copyright 1991-1993, 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 "precomp.h"
  18. #pragma hdrstop
  19. #include <imfuncs.h>
  20. #include "glsbmsg.h"
  21. #include "glsbmsgh.h"
  22. #include "srvsize.h"
  23. /********************************************************************/
  24. VOID * FASTCALL
  25. sbs_glRenderMode( __GLcontext *gc, IN GLMSG_RENDERMODE *pMsg)
  26. {
  27. GLint Result;
  28. /*
  29. * Make the call
  30. *
  31. * When exiting Selection mode, RenderMode returns the number of hit
  32. * records or -1 if an overflow occured.
  33. *
  34. * When exiting Feedback mode, RenderMode returns the number of values
  35. * placed in the feedback buffer or -1 if an overflow occured.
  36. */
  37. Result =
  38. __glim_RenderMode
  39. ( pMsg->mode );
  40. GLTEB_RETURNVALUE() = (ULONG)Result;
  41. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  42. }
  43. VOID * FASTCALL
  44. sbs_glFeedbackBuffer( __GLcontext *gc, IN GLMSG_FEEDBACKBUFFER *pMsg )
  45. {
  46. __GLGENcontext *gengc;
  47. GLint PreviousError;
  48. GLfloat *Buffer;
  49. GLuint SizeInBytes;
  50. gengc = (__GLGENcontext *)gc;
  51. /*
  52. * Save the current error code so that we can determine
  53. * if the call was successful.
  54. */
  55. PreviousError = gc->error;
  56. gc->error = GL_NO_ERROR; /* clear the error code */
  57. /*
  58. * Figure out the size of the buffer in bytes
  59. */
  60. SizeInBytes = pMsg->size * sizeof(GLfloat);
  61. /*
  62. * Allocate the server side buffer
  63. * Use GenMalloc() because it may be used indefinitely.
  64. */
  65. if ( NULL == (Buffer = (GLfloat *) pMsg->bufferOff) )
  66. {
  67. __glSetError(GL_OUT_OF_MEMORY);
  68. DBGERROR("GenMalloc failed\n");
  69. }
  70. else
  71. {
  72. /*
  73. * Make the call
  74. */
  75. __glim_FeedbackBuffer(
  76. pMsg->size, pMsg->type, Buffer );
  77. /*
  78. * If the call was successful, save the parameters
  79. */
  80. if ( GL_NO_ERROR == gc->error )
  81. {
  82. gc->error = PreviousError; /* Restore the error code */
  83. gengc->RenderState.SrvFeedbackBuffer = Buffer;
  84. gengc->RenderState.CltFeedbackBuffer = (GLfloat *)pMsg->bufferOff;
  85. gengc->RenderState.FeedbackBufferSize = SizeInBytes;
  86. gengc->RenderState.FeedbackType = pMsg->type;
  87. }
  88. }
  89. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  90. }
  91. VOID * FASTCALL
  92. sbs_glSelectBuffer( __GLcontext *gc, IN GLMSG_SELECTBUFFER *pMsg)
  93. {
  94. __GLGENcontext *gengc;
  95. GLint PreviousError;
  96. GLuint *Buffer;
  97. GLuint SizeInBytes;
  98. gengc = (__GLGENcontext *)gc;
  99. /*
  100. * Save the current error code so that we can determine
  101. * if the call was successful.
  102. */
  103. PreviousError = gc->error;
  104. gc->error = GL_NO_ERROR; /* clear the error code */
  105. /*
  106. * Figure out the size of the buffer in bytes
  107. */
  108. SizeInBytes = pMsg->size * sizeof(GLuint);
  109. /*
  110. * Allocate the server side buffer
  111. * Use GenMalloc() because it may be used indefinitely.
  112. */
  113. if ( NULL == (Buffer = (GLuint *) pMsg->bufferOff) )
  114. {
  115. __glSetError(GL_OUT_OF_MEMORY);
  116. DBGERROR("GenMalloc failed\n");
  117. }
  118. else
  119. {
  120. /*
  121. * Make the call
  122. */
  123. __glim_SelectBuffer
  124. (pMsg->size, Buffer );
  125. /*
  126. * If the call was successful, save the parameters
  127. */
  128. if ( GL_NO_ERROR == gc->error )
  129. {
  130. gc->error = PreviousError; /* Restore the error code */
  131. gengc->RenderState.SrvSelectBuffer = Buffer;
  132. gengc->RenderState.CltSelectBuffer = (GLuint *)pMsg->bufferOff;
  133. gengc->RenderState.SelectBufferSize = SizeInBytes;
  134. }
  135. }
  136. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  137. }
  138. /******************* Pixel Functions ********************************/
  139. VOID * FASTCALL
  140. sbs_glReadPixels ( __GLcontext *gc, IN GLMSG_READPIXELS *pMsg )
  141. {
  142. VOID *Data;
  143. VOID *NextOffset;
  144. #ifdef _MCD_
  145. if (((__GLGENcontext *)gc)->pMcdState)
  146. {
  147. // This function potentially touches the framebuffer memory. Since,
  148. // this function is not going to first pass through the MCD driver
  149. // (which would give the MCD driver the oportunity to sync to the HW),
  150. // we need to do this synchronization explicitly.
  151. GenMcdSynchronize((__GLGENcontext *)gc);
  152. }
  153. #endif
  154. NextOffset = (VOID *) ( ((BYTE *)pMsg) + GLMSG_ALIGN(sizeof(*pMsg)) );
  155. Data = (VOID *) pMsg->pixelsOff;
  156. __glim_ReadPixels
  157. ( pMsg->x,
  158. pMsg->y,
  159. pMsg->width,
  160. pMsg->height,
  161. pMsg->format,
  162. pMsg->type,
  163. Data );
  164. return( NextOffset );
  165. }
  166. VOID * FASTCALL
  167. sbs_glGetPolygonStipple ( __GLcontext *gc, IN GLMSG_GETPOLYGONSTIPPLE *pMsg )
  168. {
  169. VOID *Data;
  170. VOID *NextOffset;
  171. NextOffset = (VOID *) ( ((BYTE *)pMsg) + GLMSG_ALIGN(sizeof(*pMsg)) );
  172. Data = (VOID *) pMsg->maskOff;
  173. __glim_GetPolygonStipple
  174. ( Data );
  175. return( NextOffset );
  176. }
  177. /*
  178. * XXXX From Ptar:
  179. *
  180. * This code is very similar to __glCheckReadPixelArgs() in
  181. * pixel/px_api.c, and could possibly replace it.
  182. */
  183. VOID * FASTCALL
  184. sbs_glGetTexImage ( __GLcontext *gc, IN GLMSG_GETTEXIMAGE *pMsg )
  185. {
  186. VOID *Data;
  187. VOID *NextOffset;
  188. NextOffset = (VOID *) ( ((BYTE *)pMsg) + GLMSG_ALIGN(sizeof(*pMsg)) );
  189. Data = (VOID *) pMsg->pixelsOff;
  190. __glim_GetTexImage
  191. ( pMsg->target,
  192. pMsg->level,
  193. pMsg->format,
  194. pMsg->type,
  195. Data );
  196. return( NextOffset );
  197. }
  198. VOID * FASTCALL
  199. sbs_glDrawPixels ( __GLcontext *gc, IN GLMSG_DRAWPIXELS *pMsg )
  200. {
  201. VOID *Data;
  202. VOID *NextOffset;
  203. #ifdef _MCD_
  204. if (((__GLGENcontext *)gc)->pMcdState)
  205. {
  206. // This function potentially touches the framebuffer memory. Since,
  207. // this function is not going to first pass through the MCD driver
  208. // (which would give the MCD driver the oportunity to sync to the HW),
  209. // we need to do this synchronization explicitly.
  210. GenMcdSynchronize((__GLGENcontext *)gc);
  211. }
  212. #endif
  213. NextOffset = (VOID *) ( ((BYTE *)pMsg) + GLMSG_ALIGN(sizeof(*pMsg)) );
  214. Data = (VOID *) pMsg->pixelsOff;
  215. __glim_DrawPixels
  216. ( pMsg->width,
  217. pMsg->height,
  218. pMsg->format,
  219. pMsg->type,
  220. #ifdef NT
  221. Data,
  222. pMsg->_IsDlist);
  223. #else
  224. Data );
  225. #endif
  226. return( NextOffset );
  227. }
  228. VOID * FASTCALL
  229. sbs_glPolygonStipple ( __GLcontext *gc, IN GLMSG_POLYGONSTIPPLE *pMsg )
  230. {
  231. VOID *Data;
  232. VOID *NextOffset;
  233. NextOffset = (VOID *) ( ((BYTE *)pMsg) + GLMSG_ALIGN(sizeof(*pMsg)) );
  234. Data = (VOID *) pMsg->maskOff;
  235. __glim_PolygonStipple
  236. #ifdef NT
  237. ( Data, pMsg->_IsDlist );
  238. #else
  239. ( Data );
  240. #endif
  241. return( NextOffset );
  242. }
  243. /*
  244. * XXXX from Ptar:
  245. *
  246. * The whole bitmap is copied, the server (not the client)
  247. * could be modified so that only the data starting at
  248. * xorig and yorig is copied, then width and height probably
  249. * need to be modified.
  250. * Note that __glBitmap_size() will also need to be modified
  251. *
  252. */
  253. VOID * FASTCALL
  254. sbs_glBitmap ( __GLcontext *gc, IN GLMSG_BITMAP *pMsg )
  255. {
  256. VOID *Data;
  257. VOID *NextOffset;
  258. #ifdef _MCD_
  259. if (((__GLGENcontext *)gc)->pMcdState)
  260. {
  261. // This function potentially touches the framebuffer memory. Since,
  262. // this function is not going to first pass through the MCD driver
  263. // (which would give the MCD driver the oportunity to sync to the HW),
  264. // we need to do this synchronization explicitly.
  265. GenMcdSynchronize((__GLGENcontext *)gc);
  266. }
  267. #endif
  268. NextOffset = (VOID *) ( ((BYTE *)pMsg) + GLMSG_ALIGN(sizeof(*pMsg)) );
  269. Data = (VOID *) pMsg->bitmapOff;
  270. __glim_Bitmap
  271. (
  272. pMsg->width ,
  273. pMsg->height,
  274. pMsg->xorig ,
  275. pMsg->yorig ,
  276. pMsg->xmove ,
  277. pMsg->ymove ,
  278. #ifdef NT
  279. Data ,
  280. pMsg->_IsDlist
  281. #else
  282. Data
  283. #endif
  284. );
  285. return( NextOffset );
  286. }
  287. VOID * FASTCALL
  288. sbs_glTexImage1D ( __GLcontext *gc, IN GLMSG_TEXIMAGE1D *pMsg )
  289. {
  290. VOID *Data;
  291. VOID *NextOffset;
  292. NextOffset = (VOID *) ( ((BYTE *)pMsg) + GLMSG_ALIGN(sizeof(*pMsg)) );
  293. Data = (VOID *) pMsg->pixelsOff;
  294. __glim_TexImage1D
  295. (
  296. pMsg->target ,
  297. pMsg->level ,
  298. pMsg->components ,
  299. pMsg->width ,
  300. pMsg->border ,
  301. pMsg->format ,
  302. pMsg->type ,
  303. #ifdef NT
  304. Data ,
  305. pMsg->_IsDlist
  306. #else
  307. Data
  308. #endif
  309. );
  310. return( NextOffset );
  311. }
  312. VOID * FASTCALL
  313. sbs_glTexImage2D ( __GLcontext *gc, IN GLMSG_TEXIMAGE2D *pMsg )
  314. {
  315. VOID *Data;
  316. VOID *NextOffset;
  317. NextOffset = (VOID *) ( ((BYTE *)pMsg) + GLMSG_ALIGN(sizeof(*pMsg)) );
  318. Data = (VOID *) pMsg->pixelsOff;
  319. __glim_TexImage2D
  320. (
  321. pMsg->target ,
  322. pMsg->level ,
  323. pMsg->components ,
  324. pMsg->width ,
  325. pMsg->height ,
  326. pMsg->border ,
  327. pMsg->format ,
  328. pMsg->type ,
  329. #ifdef NT
  330. Data ,
  331. pMsg->_IsDlist
  332. #else
  333. Data
  334. #endif
  335. );
  336. return( NextOffset );
  337. }
  338. VOID * FASTCALL
  339. sbs_glAreTexturesResident( __GLcontext *gc, IN GLMSG_ARETEXTURESRESIDENT *pMsg)
  340. {
  341. GLboolean retval;
  342. retval = __glim_AreTexturesResident
  343. ( pMsg->n, pMsg->textures, pMsg->residences );
  344. GLTEB_RETURNVALUE() = (ULONG)retval;
  345. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  346. }
  347. VOID * FASTCALL
  348. sbs_glBindTexture( __GLcontext *gc, IN GLMSG_BINDTEXTURE *pMsg)
  349. {
  350. __glim_BindTexture
  351. ( pMsg->target, pMsg->texture );
  352. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  353. }
  354. VOID * FASTCALL
  355. sbs_glCopyTexImage1D( __GLcontext *gc, IN GLMSG_COPYTEXIMAGE1D *pMsg)
  356. {
  357. __glim_CopyTexImage1D
  358. ( pMsg->target, pMsg->level, pMsg->internalformat, pMsg->x,
  359. pMsg->y, pMsg->width, pMsg->border);
  360. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  361. }
  362. VOID * FASTCALL
  363. sbs_glCopyTexImage2D( __GLcontext *gc, IN GLMSG_COPYTEXIMAGE2D *pMsg)
  364. {
  365. __glim_CopyTexImage2D
  366. ( pMsg->target, pMsg->level, pMsg->internalformat, pMsg->x,
  367. pMsg->y, pMsg->width, pMsg->height, pMsg->border);
  368. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  369. }
  370. VOID * FASTCALL
  371. sbs_glCopyTexSubImage1D( __GLcontext *gc, IN GLMSG_COPYTEXSUBIMAGE1D *pMsg)
  372. {
  373. __glim_CopyTexSubImage1D
  374. ( pMsg->target, pMsg->level, pMsg->xoffset, pMsg->x,
  375. pMsg->y, pMsg->width);
  376. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  377. }
  378. VOID * FASTCALL
  379. sbs_glCopyTexSubImage2D( __GLcontext *gc, IN GLMSG_COPYTEXSUBIMAGE2D *pMsg)
  380. {
  381. __glim_CopyTexSubImage2D
  382. ( pMsg->target, pMsg->level, pMsg->xoffset, pMsg->yoffset, pMsg->x,
  383. pMsg->y, pMsg->width, pMsg->height);
  384. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  385. }
  386. VOID * FASTCALL
  387. sbs_glDeleteTextures( __GLcontext *gc, IN GLMSG_DELETETEXTURES *pMsg)
  388. {
  389. __glim_DeleteTextures
  390. ( pMsg->n, pMsg->textures );
  391. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  392. }
  393. VOID * FASTCALL
  394. sbs_glGenTextures( __GLcontext *gc, IN GLMSG_GENTEXTURES *pMsg)
  395. {
  396. __glim_GenTextures
  397. ( pMsg->n, pMsg->textures );
  398. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  399. }
  400. VOID * FASTCALL
  401. sbs_glIsTexture( __GLcontext *gc, IN GLMSG_ISTEXTURE *pMsg)
  402. {
  403. GLboolean retval;
  404. retval = __glim_IsTexture
  405. ( pMsg->texture );
  406. GLTEB_RETURNVALUE() = (ULONG)retval;
  407. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  408. }
  409. VOID * FASTCALL
  410. sbs_glPrioritizeTextures( __GLcontext *gc, IN GLMSG_PRIORITIZETEXTURES *pMsg)
  411. {
  412. __glim_PrioritizeTextures
  413. ( pMsg->n, pMsg->textures, pMsg->priorities );
  414. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  415. }
  416. VOID * FASTCALL
  417. sbs_glTexSubImage1D( __GLcontext *gc, IN GLMSG_TEXSUBIMAGE1D *pMsg)
  418. {
  419. __glim_TexSubImage1D
  420. (pMsg->target, pMsg->level, pMsg->xoffset, pMsg->width,
  421. pMsg->format, pMsg->type,
  422. #ifdef NT
  423. (const GLvoid *)pMsg->pixelsOff, pMsg->_IsDlist);
  424. #else
  425. (const GLvoid *)pMsg->pixelsOff);
  426. #endif
  427. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  428. }
  429. VOID * FASTCALL
  430. sbs_glTexSubImage2D( __GLcontext *gc, IN GLMSG_TEXSUBIMAGE2D *pMsg)
  431. {
  432. __glim_TexSubImage2D
  433. (pMsg->target, pMsg->level, pMsg->xoffset, pMsg->yoffset, pMsg->width,
  434. pMsg->height, pMsg->format, pMsg->type,
  435. #ifdef NT
  436. (const GLvoid *)pMsg->pixelsOff, pMsg->_IsDlist);
  437. #else
  438. (const GLvoid *)pMsg->pixelsOff);
  439. #endif
  440. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  441. }
  442. VOID * FASTCALL
  443. sbs_glColorTableEXT( __GLcontext *gc, IN GLMSG_COLORTABLEEXT *pMsg)
  444. {
  445. __glim_ColorTableEXT
  446. (pMsg->target, pMsg->internalFormat, pMsg->width, pMsg->format, pMsg->type,
  447. pMsg->data, pMsg->_IsDlist);
  448. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  449. }
  450. VOID * FASTCALL
  451. sbs_glColorSubTableEXT( __GLcontext *gc, IN GLMSG_COLORSUBTABLEEXT *pMsg)
  452. {
  453. __glim_ColorSubTableEXT
  454. (pMsg->target, pMsg->start, pMsg->count, pMsg->format, pMsg->type,
  455. pMsg->data, pMsg->_IsDlist);
  456. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  457. }
  458. VOID * FASTCALL
  459. sbs_glGetColorTableEXT( __GLcontext *gc, IN GLMSG_GETCOLORTABLEEXT *pMsg)
  460. {
  461. __glim_GetColorTableEXT
  462. (pMsg->target, pMsg->format, pMsg->type, pMsg->data);
  463. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  464. }
  465. VOID * FASTCALL
  466. sbs_glGetColorTableParameterivEXT( __GLcontext *gc, IN GLMSG_GETCOLORTABLEPARAMETERIVEXT *pMsg)
  467. {
  468. __glim_GetColorTableParameterivEXT
  469. (pMsg->target, pMsg->pname, pMsg->params);
  470. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  471. }
  472. VOID * FASTCALL
  473. sbs_glGetColorTableParameterfvEXT( __GLcontext *gc, IN GLMSG_GETCOLORTABLEPARAMETERFVEXT *pMsg)
  474. {
  475. __glim_GetColorTableParameterfvEXT
  476. (pMsg->target, pMsg->pname, pMsg->params);
  477. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  478. }
  479. VOID * FASTCALL
  480. sbs_glPolygonOffset( __GLcontext *gc, IN GLMSG_POLYGONOFFSET *pMsg)
  481. {
  482. __glim_PolygonOffset
  483. (pMsg->factor, pMsg->units);
  484. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  485. }
  486. #ifdef GL_WIN_multiple_textures
  487. VOID * FASTCALL
  488. sbs_glCurrentTextureIndexWIN( __GLcontext *gc, IN GLMSG_CURRENTTEXTUREINDEXWIN *pMsg)
  489. {
  490. __glim_CurrentTextureIndexWIN
  491. (pMsg->index);
  492. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  493. }
  494. VOID * FASTCALL
  495. sbs_glBindNthTextureWIN( __GLcontext *gc, IN GLMSG_BINDNTHTEXTUREWIN *pMsg)
  496. {
  497. __glim_BindNthTextureWIN
  498. (pMsg->index, pMsg->target, pMsg->texture);
  499. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  500. }
  501. VOID * FASTCALL
  502. sbs_glNthTexCombineFuncWIN( __GLcontext *gc, IN GLMSG_NTHTEXCOMBINEFUNCWIN *pMsg)
  503. {
  504. __glim_NthTexCombineFuncWIN
  505. (pMsg->index, pMsg->leftColorFactor, pMsg->colorOp,
  506. pMsg->rightColorFactor, pMsg->leftAlphaFactor,
  507. pMsg->alphaOp, pMsg->rightAlphaFactor);
  508. return ( (BYTE *)pMsg + GLMSG_ALIGN(sizeof(*pMsg)) );
  509. }
  510. #endif // GL_WIN_multiple_textures