17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 37117f1b4Smrg * 47117f1b4Smrg * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 57117f1b4Smrg * 67117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 77117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 87117f1b4Smrg * to deal in the Software without restriction, including without limitation 97117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 107117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 117117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 127117f1b4Smrg * 137117f1b4Smrg * The above copyright notice and this permission notice shall be included 147117f1b4Smrg * in all copies or substantial portions of the Software. 157117f1b4Smrg * 167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 177117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 237117f1b4Smrg */ 247117f1b4Smrg 257117f1b4Smrg/** 267117f1b4Smrg * \brief Templates for vector conversions. 277117f1b4Smrg * \author Keith Whitwell. 287117f1b4Smrg */ 297117f1b4Smrg 307117f1b4Smrg#ifdef DEST_4F 317117f1b4Smrgstatic void DEST_4F( GLfloat (*t)[4], 32af69d88dSmrg const void *ptr, 337117f1b4Smrg GLuint stride, 347117f1b4Smrg ARGS ) 357117f1b4Smrg{ 367117f1b4Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 377117f1b4Smrg const GLubyte *first = f; 387117f1b4Smrg GLuint i; 397117f1b4Smrg 407117f1b4Smrg (void) first; 417117f1b4Smrg (void) start; 427117f1b4Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 4301e04c3fSmrg NEXT_F2; 4401e04c3fSmrg if (SZ >= 1) t[i][0] = TRX_4F(f, 0); 4501e04c3fSmrg if (SZ >= 2) t[i][1] = TRX_4F(f, 1); 4601e04c3fSmrg if (SZ >= 3) t[i][2] = TRX_4F(f, 2); 4701e04c3fSmrg if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; 487117f1b4Smrg } 497117f1b4Smrg} 507117f1b4Smrg#endif 517117f1b4Smrg 527117f1b4Smrg 537117f1b4Smrg 547117f1b4Smrg#ifdef DEST_4FN 557117f1b4Smrgstatic void DEST_4FN( GLfloat (*t)[4], 56af69d88dSmrg const void *ptr, 577117f1b4Smrg GLuint stride, 587117f1b4Smrg ARGS ) 597117f1b4Smrg{ 607117f1b4Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 617117f1b4Smrg const GLubyte *first = f; 627117f1b4Smrg GLuint i; 637117f1b4Smrg 647117f1b4Smrg (void) first; 657117f1b4Smrg (void) start; 667117f1b4Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 6701e04c3fSmrg NEXT_F2; 6801e04c3fSmrg if (SZ >= 1) t[i][0] = TRX_4FN(f, 0); 6901e04c3fSmrg if (SZ >= 2) t[i][1] = TRX_4FN(f, 1); 7001e04c3fSmrg if (SZ >= 3) t[i][2] = TRX_4FN(f, 2); 7101e04c3fSmrg if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0; 727117f1b4Smrg } 737117f1b4Smrg} 747117f1b4Smrg#endif 757117f1b4Smrg 767117f1b4Smrg 777117f1b4Smrg#ifdef DEST_3FN 787117f1b4Smrgstatic void DEST_3FN( GLfloat (*t)[3], 79af69d88dSmrg const void *ptr, 807117f1b4Smrg GLuint stride, 817117f1b4Smrg ARGS ) 827117f1b4Smrg{ 837117f1b4Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 847117f1b4Smrg const GLubyte *first = f; 857117f1b4Smrg GLuint i; 867117f1b4Smrg (void) first; 877117f1b4Smrg (void) start; 887117f1b4Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 8901e04c3fSmrg NEXT_F2; 9001e04c3fSmrg t[i][0] = TRX_3FN(f, 0); 9101e04c3fSmrg t[i][1] = TRX_3FN(f, 1); 9201e04c3fSmrg t[i][2] = TRX_3FN(f, 2); 937117f1b4Smrg } 947117f1b4Smrg} 957117f1b4Smrg#endif 967117f1b4Smrg 977117f1b4Smrg#ifdef DEST_1F 987117f1b4Smrgstatic void DEST_1F( GLfloat *t, 99af69d88dSmrg const void *ptr, 1007117f1b4Smrg GLuint stride, 1017117f1b4Smrg ARGS ) 1027117f1b4Smrg{ 1037117f1b4Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 1047117f1b4Smrg const GLubyte *first = f; 1057117f1b4Smrg GLuint i; 1067117f1b4Smrg (void) first; 1077117f1b4Smrg (void) start; 1087117f1b4Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 10901e04c3fSmrg NEXT_F2; 11001e04c3fSmrg t[i] = TRX_1F(f, 0); 1117117f1b4Smrg } 1127117f1b4Smrg} 1137117f1b4Smrg#endif 1147117f1b4Smrg 1157117f1b4Smrg#ifdef DEST_4UB 1167117f1b4Smrgstatic void DEST_4UB( GLubyte (*t)[4], 117af69d88dSmrg const void *ptr, 1187117f1b4Smrg GLuint stride, 1197117f1b4Smrg ARGS ) 1207117f1b4Smrg{ 1217117f1b4Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 1227117f1b4Smrg const GLubyte *first = f; 1237117f1b4Smrg GLuint i; 1247117f1b4Smrg (void) start; 1257117f1b4Smrg (void) first; 1267117f1b4Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 12701e04c3fSmrg NEXT_F2; 12801e04c3fSmrg if (SZ >= 1) TRX_UB(t[i][0], f, 0); 12901e04c3fSmrg if (SZ >= 2) TRX_UB(t[i][1], f, 1); 13001e04c3fSmrg if (SZ >= 3) TRX_UB(t[i][2], f, 2); 13101e04c3fSmrg if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; 1327117f1b4Smrg } 1337117f1b4Smrg} 1347117f1b4Smrg#endif 1357117f1b4Smrg 1367117f1b4Smrg 1377117f1b4Smrg#ifdef DEST_4US 1387117f1b4Smrgstatic void DEST_4US( GLushort (*t)[4], 139af69d88dSmrg const void *ptr, 1407117f1b4Smrg GLuint stride, 1417117f1b4Smrg ARGS ) 1427117f1b4Smrg{ 1437117f1b4Smrg const GLubyte *f = (GLubyte *) ((GLubyte *) ptr + SRC_START * stride); 1447117f1b4Smrg const GLubyte *first = f; 1457117f1b4Smrg GLuint i; 1467117f1b4Smrg (void) start; 1477117f1b4Smrg (void) first; 1487117f1b4Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 14901e04c3fSmrg NEXT_F2; 15001e04c3fSmrg if (SZ >= 1) TRX_US(t[i][0], f, 0); 15101e04c3fSmrg if (SZ >= 2) TRX_US(t[i][1], f, 1); 15201e04c3fSmrg if (SZ >= 3) TRX_US(t[i][2], f, 2); 15301e04c3fSmrg if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; 1547117f1b4Smrg } 1557117f1b4Smrg} 1567117f1b4Smrg#endif 1577117f1b4Smrg 1587117f1b4Smrg 1597117f1b4Smrg#ifdef DEST_1UB 1607117f1b4Smrgstatic void DEST_1UB( GLubyte *t, 161af69d88dSmrg const void *ptr, 1627117f1b4Smrg GLuint stride, 1637117f1b4Smrg ARGS ) 1647117f1b4Smrg{ 1657117f1b4Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 1667117f1b4Smrg const GLubyte *first = f; 1677117f1b4Smrg GLuint i; 1687117f1b4Smrg (void) start; 1697117f1b4Smrg (void) first; 1707117f1b4Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 17101e04c3fSmrg NEXT_F2; 17201e04c3fSmrg TRX_UB(t[i], f, 0); 1737117f1b4Smrg } 1747117f1b4Smrg} 1757117f1b4Smrg#endif 1767117f1b4Smrg 1777117f1b4Smrg 1787117f1b4Smrg#ifdef DEST_1UI 1797117f1b4Smrgstatic void DEST_1UI( GLuint *t, 180af69d88dSmrg const void *ptr, 1817117f1b4Smrg GLuint stride, 1827117f1b4Smrg ARGS ) 1837117f1b4Smrg{ 1847117f1b4Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 1857117f1b4Smrg const GLubyte *first = f; 1867117f1b4Smrg GLuint i; 1877117f1b4Smrg (void) start; 1887117f1b4Smrg (void) first; 1897117f1b4Smrg 1907117f1b4Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 19101e04c3fSmrg NEXT_F2; 19201e04c3fSmrg t[i] = TRX_UI(f, 0); 1937117f1b4Smrg } 1947117f1b4Smrg} 1957117f1b4Smrg#endif 1967117f1b4Smrg 1977117f1b4Smrg 1987117f1b4Smrgstatic void INIT(void) 1997117f1b4Smrg{ 2007117f1b4Smrg#ifdef DEST_1UI 20101e04c3fSmrg assert(SZ == 1); 2027117f1b4Smrg TAB(_1ui)[SRC_IDX] = DEST_1UI; 2037117f1b4Smrg#endif 2047117f1b4Smrg#ifdef DEST_1UB 20501e04c3fSmrg assert(SZ == 1); 2067117f1b4Smrg TAB(_1ub)[SRC_IDX] = DEST_1UB; 2077117f1b4Smrg#endif 2087117f1b4Smrg#ifdef DEST_1F 20901e04c3fSmrg assert(SZ == 1); 2107117f1b4Smrg TAB(_1f)[SRC_IDX] = DEST_1F; 2117117f1b4Smrg#endif 2127117f1b4Smrg#ifdef DEST_3FN 21301e04c3fSmrg assert(SZ == 3); 2147117f1b4Smrg TAB(_3fn)[SRC_IDX] = DEST_3FN; 2157117f1b4Smrg#endif 2167117f1b4Smrg#ifdef DEST_4UB 2177117f1b4Smrg TAB(_4ub)[SZ][SRC_IDX] = DEST_4UB; 2187117f1b4Smrg#endif 2197117f1b4Smrg#ifdef DEST_4US 2207117f1b4Smrg TAB(_4us)[SZ][SRC_IDX] = DEST_4US; 2217117f1b4Smrg#endif 2227117f1b4Smrg#ifdef DEST_4F 2237117f1b4Smrg TAB(_4f)[SZ][SRC_IDX] = DEST_4F; 2247117f1b4Smrg#endif 2257117f1b4Smrg#ifdef DEST_4FN 2267117f1b4Smrg TAB(_4fn)[SZ][SRC_IDX] = DEST_4FN; 2277117f1b4Smrg#endif 2287117f1b4Smrg 2297117f1b4Smrg} 2307117f1b4Smrg 2317117f1b4Smrg 2327117f1b4Smrg#ifdef INIT 2337117f1b4Smrg#undef INIT 2347117f1b4Smrg#endif 2357117f1b4Smrg#ifdef DEST_1UI 2367117f1b4Smrg#undef DEST_1UI 2377117f1b4Smrg#endif 2387117f1b4Smrg#ifdef DEST_1UB 2397117f1b4Smrg#undef DEST_1UB 2407117f1b4Smrg#endif 2417117f1b4Smrg#ifdef DEST_4UB 2427117f1b4Smrg#undef DEST_4UB 2437117f1b4Smrg#endif 2447117f1b4Smrg#ifdef DEST_4US 2457117f1b4Smrg#undef DEST_4US 2467117f1b4Smrg#endif 2477117f1b4Smrg#ifdef DEST_3FN 2487117f1b4Smrg#undef DEST_3FN 2497117f1b4Smrg#endif 2507117f1b4Smrg#ifdef DEST_4F 2517117f1b4Smrg#undef DEST_4F 2527117f1b4Smrg#endif 2537117f1b4Smrg#ifdef DEST_4FN 2547117f1b4Smrg#undef DEST_4FN 2557117f1b4Smrg#endif 2567117f1b4Smrg#ifdef DEST_1F 2577117f1b4Smrg#undef DEST_1F 2587117f1b4Smrg#endif 2597117f1b4Smrg#ifdef SZ 2607117f1b4Smrg#undef SZ 2617117f1b4Smrg#endif 2627117f1b4Smrg#ifdef TAG 2637117f1b4Smrg#undef TAG 2647117f1b4Smrg#endif 2657117f1b4Smrg 266