1848b8605Smrg/* 2848b8605Smrg * Mesa 3-D graphics library 3848b8605Smrg * 4848b8605Smrg * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 5848b8605Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the "Software"), 8848b8605Smrg * to deal in the Software without restriction, including without limitation 9848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the 11848b8605Smrg * Software is furnished to do so, subject to the following conditions: 12848b8605Smrg * 13848b8605Smrg * The above copyright notice and this permission notice shall be included 14848b8605Smrg * in all copies or substantial portions of the Software. 15848b8605Smrg * 16848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20848b8605Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21848b8605Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22848b8605Smrg * OTHER DEALINGS IN THE SOFTWARE. 23848b8605Smrg */ 24848b8605Smrg 25848b8605Smrg/** 26848b8605Smrg * \brief Templates for vector conversions. 27848b8605Smrg * \author Keith Whitwell. 28848b8605Smrg */ 29848b8605Smrg 30848b8605Smrg#ifdef DEST_4F 31848b8605Smrgstatic void DEST_4F( GLfloat (*t)[4], 32848b8605Smrg const void *ptr, 33848b8605Smrg GLuint stride, 34848b8605Smrg ARGS ) 35848b8605Smrg{ 36848b8605Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 37848b8605Smrg const GLubyte *first = f; 38848b8605Smrg GLuint i; 39848b8605Smrg 40848b8605Smrg (void) first; 41848b8605Smrg (void) start; 42848b8605Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 43b8e80941Smrg NEXT_F2; 44b8e80941Smrg if (SZ >= 1) t[i][0] = TRX_4F(f, 0); 45b8e80941Smrg if (SZ >= 2) t[i][1] = TRX_4F(f, 1); 46b8e80941Smrg if (SZ >= 3) t[i][2] = TRX_4F(f, 2); 47b8e80941Smrg if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; 48848b8605Smrg } 49848b8605Smrg} 50848b8605Smrg#endif 51848b8605Smrg 52848b8605Smrg 53848b8605Smrg 54848b8605Smrg#ifdef DEST_4FN 55848b8605Smrgstatic void DEST_4FN( GLfloat (*t)[4], 56848b8605Smrg const void *ptr, 57848b8605Smrg GLuint stride, 58848b8605Smrg ARGS ) 59848b8605Smrg{ 60848b8605Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 61848b8605Smrg const GLubyte *first = f; 62848b8605Smrg GLuint i; 63848b8605Smrg 64848b8605Smrg (void) first; 65848b8605Smrg (void) start; 66848b8605Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 67b8e80941Smrg NEXT_F2; 68b8e80941Smrg if (SZ >= 1) t[i][0] = TRX_4FN(f, 0); 69b8e80941Smrg if (SZ >= 2) t[i][1] = TRX_4FN(f, 1); 70b8e80941Smrg if (SZ >= 3) t[i][2] = TRX_4FN(f, 2); 71b8e80941Smrg if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0; 72848b8605Smrg } 73848b8605Smrg} 74848b8605Smrg#endif 75848b8605Smrg 76848b8605Smrg 77848b8605Smrg#ifdef DEST_3FN 78848b8605Smrgstatic void DEST_3FN( GLfloat (*t)[3], 79848b8605Smrg const void *ptr, 80848b8605Smrg GLuint stride, 81848b8605Smrg ARGS ) 82848b8605Smrg{ 83848b8605Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 84848b8605Smrg const GLubyte *first = f; 85848b8605Smrg GLuint i; 86848b8605Smrg (void) first; 87848b8605Smrg (void) start; 88848b8605Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 89b8e80941Smrg NEXT_F2; 90b8e80941Smrg t[i][0] = TRX_3FN(f, 0); 91b8e80941Smrg t[i][1] = TRX_3FN(f, 1); 92b8e80941Smrg t[i][2] = TRX_3FN(f, 2); 93848b8605Smrg } 94848b8605Smrg} 95848b8605Smrg#endif 96848b8605Smrg 97848b8605Smrg#ifdef DEST_1F 98848b8605Smrgstatic void DEST_1F( GLfloat *t, 99848b8605Smrg const void *ptr, 100848b8605Smrg GLuint stride, 101848b8605Smrg ARGS ) 102848b8605Smrg{ 103848b8605Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 104848b8605Smrg const GLubyte *first = f; 105848b8605Smrg GLuint i; 106848b8605Smrg (void) first; 107848b8605Smrg (void) start; 108848b8605Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 109b8e80941Smrg NEXT_F2; 110b8e80941Smrg t[i] = TRX_1F(f, 0); 111848b8605Smrg } 112848b8605Smrg} 113848b8605Smrg#endif 114848b8605Smrg 115848b8605Smrg#ifdef DEST_4UB 116848b8605Smrgstatic void DEST_4UB( GLubyte (*t)[4], 117848b8605Smrg const void *ptr, 118848b8605Smrg GLuint stride, 119848b8605Smrg ARGS ) 120848b8605Smrg{ 121848b8605Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 122848b8605Smrg const GLubyte *first = f; 123848b8605Smrg GLuint i; 124848b8605Smrg (void) start; 125848b8605Smrg (void) first; 126848b8605Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 127b8e80941Smrg NEXT_F2; 128b8e80941Smrg if (SZ >= 1) TRX_UB(t[i][0], f, 0); 129b8e80941Smrg if (SZ >= 2) TRX_UB(t[i][1], f, 1); 130b8e80941Smrg if (SZ >= 3) TRX_UB(t[i][2], f, 2); 131b8e80941Smrg if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; 132848b8605Smrg } 133848b8605Smrg} 134848b8605Smrg#endif 135848b8605Smrg 136848b8605Smrg 137848b8605Smrg#ifdef DEST_4US 138848b8605Smrgstatic void DEST_4US( GLushort (*t)[4], 139848b8605Smrg const void *ptr, 140848b8605Smrg GLuint stride, 141848b8605Smrg ARGS ) 142848b8605Smrg{ 143848b8605Smrg const GLubyte *f = (GLubyte *) ((GLubyte *) ptr + SRC_START * stride); 144848b8605Smrg const GLubyte *first = f; 145848b8605Smrg GLuint i; 146848b8605Smrg (void) start; 147848b8605Smrg (void) first; 148848b8605Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 149b8e80941Smrg NEXT_F2; 150b8e80941Smrg if (SZ >= 1) TRX_US(t[i][0], f, 0); 151b8e80941Smrg if (SZ >= 2) TRX_US(t[i][1], f, 1); 152b8e80941Smrg if (SZ >= 3) TRX_US(t[i][2], f, 2); 153b8e80941Smrg if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; 154848b8605Smrg } 155848b8605Smrg} 156848b8605Smrg#endif 157848b8605Smrg 158848b8605Smrg 159848b8605Smrg#ifdef DEST_1UB 160848b8605Smrgstatic void DEST_1UB( GLubyte *t, 161848b8605Smrg const void *ptr, 162848b8605Smrg GLuint stride, 163848b8605Smrg ARGS ) 164848b8605Smrg{ 165848b8605Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 166848b8605Smrg const GLubyte *first = f; 167848b8605Smrg GLuint i; 168848b8605Smrg (void) start; 169848b8605Smrg (void) first; 170848b8605Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 171b8e80941Smrg NEXT_F2; 172b8e80941Smrg TRX_UB(t[i], f, 0); 173848b8605Smrg } 174848b8605Smrg} 175848b8605Smrg#endif 176848b8605Smrg 177848b8605Smrg 178848b8605Smrg#ifdef DEST_1UI 179848b8605Smrgstatic void DEST_1UI( GLuint *t, 180848b8605Smrg const void *ptr, 181848b8605Smrg GLuint stride, 182848b8605Smrg ARGS ) 183848b8605Smrg{ 184848b8605Smrg const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; 185848b8605Smrg const GLubyte *first = f; 186848b8605Smrg GLuint i; 187848b8605Smrg (void) start; 188848b8605Smrg (void) first; 189848b8605Smrg 190848b8605Smrg for (i = DST_START ; i < n ; i++, NEXT_F) { 191b8e80941Smrg NEXT_F2; 192b8e80941Smrg t[i] = TRX_UI(f, 0); 193848b8605Smrg } 194848b8605Smrg} 195848b8605Smrg#endif 196848b8605Smrg 197848b8605Smrg 198848b8605Smrgstatic void INIT(void) 199848b8605Smrg{ 200848b8605Smrg#ifdef DEST_1UI 201b8e80941Smrg assert(SZ == 1); 202848b8605Smrg TAB(_1ui)[SRC_IDX] = DEST_1UI; 203848b8605Smrg#endif 204848b8605Smrg#ifdef DEST_1UB 205b8e80941Smrg assert(SZ == 1); 206848b8605Smrg TAB(_1ub)[SRC_IDX] = DEST_1UB; 207848b8605Smrg#endif 208848b8605Smrg#ifdef DEST_1F 209b8e80941Smrg assert(SZ == 1); 210848b8605Smrg TAB(_1f)[SRC_IDX] = DEST_1F; 211848b8605Smrg#endif 212848b8605Smrg#ifdef DEST_3FN 213b8e80941Smrg assert(SZ == 3); 214848b8605Smrg TAB(_3fn)[SRC_IDX] = DEST_3FN; 215848b8605Smrg#endif 216848b8605Smrg#ifdef DEST_4UB 217848b8605Smrg TAB(_4ub)[SZ][SRC_IDX] = DEST_4UB; 218848b8605Smrg#endif 219848b8605Smrg#ifdef DEST_4US 220848b8605Smrg TAB(_4us)[SZ][SRC_IDX] = DEST_4US; 221848b8605Smrg#endif 222848b8605Smrg#ifdef DEST_4F 223848b8605Smrg TAB(_4f)[SZ][SRC_IDX] = DEST_4F; 224848b8605Smrg#endif 225848b8605Smrg#ifdef DEST_4FN 226848b8605Smrg TAB(_4fn)[SZ][SRC_IDX] = DEST_4FN; 227848b8605Smrg#endif 228848b8605Smrg 229848b8605Smrg} 230848b8605Smrg 231848b8605Smrg 232848b8605Smrg#ifdef INIT 233848b8605Smrg#undef INIT 234848b8605Smrg#endif 235848b8605Smrg#ifdef DEST_1UI 236848b8605Smrg#undef DEST_1UI 237848b8605Smrg#endif 238848b8605Smrg#ifdef DEST_1UB 239848b8605Smrg#undef DEST_1UB 240848b8605Smrg#endif 241848b8605Smrg#ifdef DEST_4UB 242848b8605Smrg#undef DEST_4UB 243848b8605Smrg#endif 244848b8605Smrg#ifdef DEST_4US 245848b8605Smrg#undef DEST_4US 246848b8605Smrg#endif 247848b8605Smrg#ifdef DEST_3FN 248848b8605Smrg#undef DEST_3FN 249848b8605Smrg#endif 250848b8605Smrg#ifdef DEST_4F 251848b8605Smrg#undef DEST_4F 252848b8605Smrg#endif 253848b8605Smrg#ifdef DEST_4FN 254848b8605Smrg#undef DEST_4FN 255848b8605Smrg#endif 256848b8605Smrg#ifdef DEST_1F 257848b8605Smrg#undef DEST_1F 258848b8605Smrg#endif 259848b8605Smrg#ifdef SZ 260848b8605Smrg#undef SZ 261848b8605Smrg#endif 262848b8605Smrg#ifdef TAG 263848b8605Smrg#undef TAG 264848b8605Smrg#endif 265848b8605Smrg 266