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