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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /*
  2. * Mesa 3-D graphics library
  3. * Version: 6.5.1
  4. *
  5. * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included
  15. * in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  21. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. /**
  25. * \brief Templates for vector conversions.
  26. * \author Keith Whitwell.
  27. */
  28. #ifdef DEST_4F
  29. static void DEST_4F( GLfloat (*t)[4],
  30. CONST void *ptr,
  31. GLuint stride,
  32. ARGS )
  33. {
  34. const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
  35. const GLubyte *first = f;
  36. GLuint i;
  37. (void) first;
  38. (void) start;
  39. for (i = DST_START ; i < n ; i++, NEXT_F) {
  40. CHECK {
  41. NEXT_F2;
  42. if (SZ >= 1) t[i][0] = TRX_4F(f, 0);
  43. if (SZ >= 2) t[i][1] = TRX_4F(f, 1);
  44. if (SZ >= 3) t[i][2] = TRX_4F(f, 2);
  45. if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0;
  46. }
  47. }
  48. }
  49. #endif
  50. #ifdef DEST_4FN
  51. static void DEST_4FN( GLfloat (*t)[4],
  52. CONST void *ptr,
  53. GLuint stride,
  54. ARGS )
  55. {
  56. const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
  57. const GLubyte *first = f;
  58. GLuint i;
  59. (void) first;
  60. (void) start;
  61. for (i = DST_START ; i < n ; i++, NEXT_F) {
  62. CHECK {
  63. NEXT_F2;
  64. if (SZ >= 1) t[i][0] = TRX_4FN(f, 0);
  65. if (SZ >= 2) t[i][1] = TRX_4FN(f, 1);
  66. if (SZ >= 3) t[i][2] = TRX_4FN(f, 2);
  67. if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0;
  68. }
  69. }
  70. }
  71. #endif
  72. #ifdef DEST_3FN
  73. static void DEST_3FN( GLfloat (*t)[3],
  74. CONST void *ptr,
  75. GLuint stride,
  76. ARGS )
  77. {
  78. const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
  79. const GLubyte *first = f;
  80. GLuint i;
  81. (void) first;
  82. (void) start;
  83. for (i = DST_START ; i < n ; i++, NEXT_F) {
  84. CHECK {
  85. NEXT_F2;
  86. t[i][0] = TRX_3FN(f, 0);
  87. t[i][1] = TRX_3FN(f, 1);
  88. t[i][2] = TRX_3FN(f, 2);
  89. }
  90. }
  91. }
  92. #endif
  93. #ifdef DEST_1F
  94. static void DEST_1F( GLfloat *t,
  95. CONST void *ptr,
  96. GLuint stride,
  97. ARGS )
  98. {
  99. const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
  100. const GLubyte *first = f;
  101. GLuint i;
  102. (void) first;
  103. (void) start;
  104. for (i = DST_START ; i < n ; i++, NEXT_F) {
  105. CHECK {
  106. NEXT_F2;
  107. t[i] = TRX_1F(f, 0);
  108. }
  109. }
  110. }
  111. #endif
  112. #ifdef DEST_4UB
  113. static void DEST_4UB( GLubyte (*t)[4],
  114. CONST void *ptr,
  115. GLuint stride,
  116. ARGS )
  117. {
  118. const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
  119. const GLubyte *first = f;
  120. GLuint i;
  121. (void) start;
  122. (void) first;
  123. for (i = DST_START ; i < n ; i++, NEXT_F) {
  124. CHECK {
  125. NEXT_F2;
  126. if (SZ >= 1) TRX_UB(t[i][0], f, 0);
  127. if (SZ >= 2) TRX_UB(t[i][1], f, 1);
  128. if (SZ >= 3) TRX_UB(t[i][2], f, 2);
  129. if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255;
  130. }
  131. }
  132. }
  133. #endif
  134. #ifdef DEST_4US
  135. static void DEST_4US( GLushort (*t)[4],
  136. CONST void *ptr,
  137. GLuint stride,
  138. ARGS )
  139. {
  140. const GLubyte *f = (GLubyte *) ((GLubyte *) ptr + SRC_START * stride);
  141. const GLubyte *first = f;
  142. GLuint i;
  143. (void) start;
  144. (void) first;
  145. for (i = DST_START ; i < n ; i++, NEXT_F) {
  146. CHECK {
  147. NEXT_F2;
  148. if (SZ >= 1) TRX_US(t[i][0], f, 0);
  149. if (SZ >= 2) TRX_US(t[i][1], f, 1);
  150. if (SZ >= 3) TRX_US(t[i][2], f, 2);
  151. if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535;
  152. }
  153. }
  154. }
  155. #endif
  156. #ifdef DEST_1UB
  157. static void DEST_1UB( GLubyte *t,
  158. CONST void *ptr,
  159. GLuint stride,
  160. ARGS )
  161. {
  162. const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
  163. const GLubyte *first = f;
  164. GLuint i;
  165. (void) start;
  166. (void) first;
  167. for (i = DST_START ; i < n ; i++, NEXT_F) {
  168. CHECK {
  169. NEXT_F2;
  170. TRX_UB(t[i], f, 0);
  171. }
  172. }
  173. }
  174. #endif
  175. #ifdef DEST_1UI
  176. static void DEST_1UI( GLuint *t,
  177. CONST void *ptr,
  178. GLuint stride,
  179. ARGS )
  180. {
  181. const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
  182. const GLubyte *first = f;
  183. GLuint i;
  184. (void) start;
  185. (void) first;
  186. for (i = DST_START ; i < n ; i++, NEXT_F) {
  187. CHECK {
  188. NEXT_F2;
  189. t[i] = TRX_UI(f, 0);
  190. }
  191. }
  192. }
  193. #endif
  194. static void INIT(void)
  195. {
  196. #ifdef DEST_1UI
  197. ASSERT(SZ == 1);
  198. TAB(_1ui)[SRC_IDX] = DEST_1UI;
  199. #endif
  200. #ifdef DEST_1UB
  201. ASSERT(SZ == 1);
  202. TAB(_1ub)[SRC_IDX] = DEST_1UB;
  203. #endif
  204. #ifdef DEST_1F
  205. ASSERT(SZ == 1);
  206. TAB(_1f)[SRC_IDX] = DEST_1F;
  207. #endif
  208. #ifdef DEST_3FN
  209. ASSERT(SZ == 3);
  210. TAB(_3fn)[SRC_IDX] = DEST_3FN;
  211. #endif
  212. #ifdef DEST_4UB
  213. TAB(_4ub)[SZ][SRC_IDX] = DEST_4UB;
  214. #endif
  215. #ifdef DEST_4US
  216. TAB(_4us)[SZ][SRC_IDX] = DEST_4US;
  217. #endif
  218. #ifdef DEST_4F
  219. TAB(_4f)[SZ][SRC_IDX] = DEST_4F;
  220. #endif
  221. #ifdef DEST_4FN
  222. TAB(_4fn)[SZ][SRC_IDX] = DEST_4FN;
  223. #endif
  224. }
  225. #ifdef INIT
  226. #undef INIT
  227. #endif
  228. #ifdef DEST_1UI
  229. #undef DEST_1UI
  230. #endif
  231. #ifdef DEST_1UB
  232. #undef DEST_1UB
  233. #endif
  234. #ifdef DEST_4UB
  235. #undef DEST_4UB
  236. #endif
  237. #ifdef DEST_4US
  238. #undef DEST_4US
  239. #endif
  240. #ifdef DEST_3FN
  241. #undef DEST_3FN
  242. #endif
  243. #ifdef DEST_4F
  244. #undef DEST_4F
  245. #endif
  246. #ifdef DEST_4FN
  247. #undef DEST_4FN
  248. #endif
  249. #ifdef DEST_1F
  250. #undef DEST_1F
  251. #endif
  252. #ifdef SZ
  253. #undef SZ
  254. #endif
  255. #ifdef TAG
  256. #undef TAG
  257. #endif