| 1 |
/* |
| 2 |
* Mesa 3-D graphics library |
| 3 |
* Version: 5.1 |
| 4 |
* |
| 5 |
* Copyright (C) 1999-2003 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 |
/* |
| 26 |
* New (3.1) transformation code written by Keith Whitwell. |
| 27 |
*/ |
| 28 |
|
| 29 |
|
| 30 |
/* KW: This file also included by tnl/trans_elt.c to build code |
| 31 |
* specific to the implementation of array-elements in the |
| 32 |
* tnl module. |
| 33 |
*/ |
| 34 |
|
| 35 |
|
| 36 |
#ifdef DEST_4F |
| 37 |
static void DEST_4F( GLfloat (*t)[4], |
| 38 |
CONST void *ptr, |
| 39 |
GLuint stride, |
| 40 |
ARGS ) |
| 41 |
{ |
| 42 |
const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; |
| 43 |
const GLubyte *first = f; |
| 44 |
GLuint i; |
| 45 |
|
| 46 |
(void) first; |
| 47 |
(void) start; |
| 48 |
for (i = DST_START ; i < n ; i++, NEXT_F) { |
| 49 |
CHECK { |
| 50 |
NEXT_F2; |
| 51 |
if (SZ >= 1) t[i][0] = TRX_4F(f, 0); |
| 52 |
if (SZ >= 2) t[i][1] = TRX_4F(f, 1); |
| 53 |
if (SZ >= 3) t[i][2] = TRX_4F(f, 2); |
| 54 |
if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
#endif |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
#ifdef DEST_4FC |
| 63 |
static void DEST_4FC( GLfloat (*t)[4], |
| 64 |
CONST void *ptr, |
| 65 |
GLuint stride, |
| 66 |
ARGS ) |
| 67 |
{ |
| 68 |
const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; |
| 69 |
const GLubyte *first = f; |
| 70 |
GLuint i; |
| 71 |
|
| 72 |
(void) first; |
| 73 |
(void) start; |
| 74 |
for (i = DST_START ; i < n ; i++, NEXT_F) { |
| 75 |
CHECK { |
| 76 |
NEXT_F2; |
| 77 |
if (SZ >= 1) t[i][0] = TRX_4FC(f, 0); |
| 78 |
if (SZ >= 2) t[i][1] = TRX_4FC(f, 1); |
| 79 |
if (SZ >= 3) t[i][2] = TRX_4FC(f, 2); |
| 80 |
if (SZ == 4) t[i][3] = TRX_4FC(f, 3); else t[i][3] = 1.0; |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
#endif |
| 85 |
|
| 86 |
|
| 87 |
#ifdef DEST_3F |
| 88 |
static void DEST_3F( GLfloat (*t)[3], |
| 89 |
CONST void *ptr, |
| 90 |
GLuint stride, |
| 91 |
ARGS ) |
| 92 |
{ |
| 93 |
const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; |
| 94 |
const GLubyte *first = f; |
| 95 |
GLuint i; |
| 96 |
(void) first; |
| 97 |
(void) start; |
| 98 |
for (i = DST_START ; i < n ; i++, NEXT_F) { |
| 99 |
CHECK { |
| 100 |
NEXT_F2; |
| 101 |
t[i][0] = TRX_3F(f, 0); |
| 102 |
t[i][1] = TRX_3F(f, 1); |
| 103 |
t[i][2] = TRX_3F(f, 2); |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
#endif |
| 108 |
|
| 109 |
#ifdef DEST_1F |
| 110 |
static void DEST_1F( GLfloat *t, |
| 111 |
CONST void *ptr, |
| 112 |
GLuint stride, |
| 113 |
ARGS ) |
| 114 |
{ |
| 115 |
const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; |
| 116 |
const GLubyte *first = f; |
| 117 |
GLuint i; |
| 118 |
(void) first; |
| 119 |
(void) start; |
| 120 |
for (i = DST_START ; i < n ; i++, NEXT_F) { |
| 121 |
CHECK { |
| 122 |
NEXT_F2; |
| 123 |
t[i] = TRX_1F(f, 0); |
| 124 |
} |
| 125 |
} |
| 126 |
} |
| 127 |
#endif |
| 128 |
|
| 129 |
#ifdef DEST_4UB |
| 130 |
static void DEST_4UB( GLubyte (*t)[4], |
| 131 |
CONST void *ptr, |
| 132 |
GLuint stride, |
| 133 |
ARGS ) |
| 134 |
{ |
| 135 |
const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; |
| 136 |
const GLubyte *first = f; |
| 137 |
GLuint i; |
| 138 |
(void) start; |
| 139 |
(void) first; |
| 140 |
for (i = DST_START ; i < n ; i++, NEXT_F) { |
| 141 |
CHECK { |
| 142 |
NEXT_F2; |
| 143 |
if (SZ >= 1) TRX_UB(t[i][0], f, 0); |
| 144 |
if (SZ >= 2) TRX_UB(t[i][1], f, 1); |
| 145 |
if (SZ >= 3) TRX_UB(t[i][2], f, 2); |
| 146 |
if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; |
| 147 |
} |
| 148 |
} |
| 149 |
} |
| 150 |
#endif |
| 151 |
|
| 152 |
|
| 153 |
#ifdef DEST_4US |
| 154 |
static void DEST_4US( GLushort (*t)[4], |
| 155 |
CONST void *ptr, |
| 156 |
GLuint stride, |
| 157 |
ARGS ) |
| 158 |
{ |
| 159 |
const GLubyte *f = (GLubyte *) ((GLubyte *) ptr + SRC_START * stride); |
| 160 |
const GLubyte *first = f; |
| 161 |
GLuint i; |
| 162 |
(void) start; |
| 163 |
(void) first; |
| 164 |
for (i = DST_START ; i < n ; i++, NEXT_F) { |
| 165 |
CHECK { |
| 166 |
NEXT_F2; |
| 167 |
if (SZ >= 1) TRX_US(t[i][0], f, 0); |
| 168 |
if (SZ >= 2) TRX_US(t[i][1], f, 1); |
| 169 |
if (SZ >= 3) TRX_US(t[i][2], f, 2); |
| 170 |
if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; |
| 171 |
} |
| 172 |
} |
| 173 |
} |
| 174 |
#endif |
| 175 |
|
| 176 |
|
| 177 |
#ifdef DEST_1UB |
| 178 |
static void DEST_1UB( GLubyte *t, |
| 179 |
CONST void *ptr, |
| 180 |
GLuint stride, |
| 181 |
ARGS ) |
| 182 |
{ |
| 183 |
const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; |
| 184 |
const GLubyte *first = f; |
| 185 |
GLuint i; |
| 186 |
(void) start; |
| 187 |
(void) first; |
| 188 |
for (i = DST_START ; i < n ; i++, NEXT_F) { |
| 189 |
CHECK { |
| 190 |
NEXT_F2; |
| 191 |
TRX_UB(t[i], f, 0); |
| 192 |
} |
| 193 |
} |
| 194 |
} |
| 195 |
#endif |
| 196 |
|
| 197 |
|
| 198 |
#ifdef DEST_1UI |
| 199 |
static void DEST_1UI( GLuint *t, |
| 200 |
CONST void *ptr, |
| 201 |
GLuint stride, |
| 202 |
ARGS ) |
| 203 |
{ |
| 204 |
const GLubyte *f = (GLubyte *) ptr + SRC_START * stride; |
| 205 |
const GLubyte *first = f; |
| 206 |
GLuint i; |
| 207 |
(void) start; |
| 208 |
(void) first; |
| 209 |
|
| 210 |
for (i = DST_START ; i < n ; i++, NEXT_F) { |
| 211 |
CHECK { |
| 212 |
NEXT_F2; |
| 213 |
t[i] = TRX_UI(f, 0); |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
#endif |
| 218 |
|
| 219 |
|
| 220 |
static void INIT(void) |
| 221 |
{ |
| 222 |
#ifdef DEST_1UI |
| 223 |
ASSERT(SZ == 1); |
| 224 |
TAB(_1ui)[SRC_IDX] = DEST_1UI; |
| 225 |
#endif |
| 226 |
#ifdef DEST_1UB |
| 227 |
ASSERT(SZ == 1); |
| 228 |
TAB(_1ub)[SRC_IDX] = DEST_1UB; |
| 229 |
#endif |
| 230 |
#ifdef DEST_1F |
| 231 |
ASSERT(SZ == 1); |
| 232 |
TAB(_1f)[SRC_IDX] = DEST_1F; |
| 233 |
#endif |
| 234 |
#ifdef DEST_3F |
| 235 |
ASSERT(SZ == 3); |
| 236 |
TAB(_3f)[SRC_IDX] = DEST_3F; |
| 237 |
#endif |
| 238 |
#ifdef DEST_4UB |
| 239 |
TAB(_4ub)[SZ][SRC_IDX] = DEST_4UB; |
| 240 |
#endif |
| 241 |
#ifdef DEST_4US |
| 242 |
TAB(_4us)[SZ][SRC_IDX] = DEST_4US; |
| 243 |
#endif |
| 244 |
#ifdef DEST_4F |
| 245 |
TAB(_4f)[SZ][SRC_IDX] = DEST_4F; |
| 246 |
#endif |
| 247 |
#ifdef DEST_4FC |
| 248 |
TAB(_4fc)[SZ][SRC_IDX] = DEST_4FC; |
| 249 |
#endif |
| 250 |
|
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
#ifdef INIT |
| 255 |
#undef INIT |
| 256 |
#endif |
| 257 |
#ifdef DEST_1UI |
| 258 |
#undef DEST_1UI |
| 259 |
#endif |
| 260 |
#ifdef DEST_1UB |
| 261 |
#undef DEST_1UB |
| 262 |
#endif |
| 263 |
#ifdef DEST_4UB |
| 264 |
#undef DEST_4UB |
| 265 |
#endif |
| 266 |
#ifdef DEST_4US |
| 267 |
#undef DEST_4US |
| 268 |
#endif |
| 269 |
#ifdef DEST_3F |
| 270 |
#undef DEST_3F |
| 271 |
#endif |
| 272 |
#ifdef DEST_4F |
| 273 |
#undef DEST_4F |
| 274 |
#endif |
| 275 |
#ifdef DEST_4FC |
| 276 |
#undef DEST_4FC |
| 277 |
#endif |
| 278 |
#ifdef DEST_1F |
| 279 |
#undef DEST_1F |
| 280 |
#endif |
| 281 |
#ifdef SZ |
| 282 |
#undef SZ |
| 283 |
#endif |
| 284 |
#ifdef TAG |
| 285 |
#undef TAG |
| 286 |
#endif |
| 287 |
|