Brian Paul | 5ac8282 | 2001-09-23 16:50:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
Brian Paul | b79e99a | 2002-08-21 02:59:00 +0000 | [diff] [blame] | 3 | * Version: 4.1 |
Brian Paul | 5ac8282 | 2001-09-23 16:50:01 +0000 | [diff] [blame] | 4 | * |
Brian Paul | b79e99a | 2002-08-21 02:59:00 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. |
Brian Paul | 5ac8282 | 2001-09-23 16:50:01 +0000 | [diff] [blame] | 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 | /* Authors: |
Brian Paul | 05a4b37 | 2002-10-29 20:28:36 +0000 | [diff] [blame] | 26 | * Keith Whitwell <keith@tungstengraphics.com> |
Daniel Borca | 854b4a3 | 2003-11-26 08:32:35 +0000 | [diff] [blame] | 27 | * Daniel Borca <dborca@users.sourceforge.net> |
Brian Paul | 5ac8282 | 2001-09-23 16:50:01 +0000 | [diff] [blame] | 28 | */ |
| 29 | |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 30 | |
Daniel Borca | d9f1e45 | 2003-10-09 15:12:20 +0000 | [diff] [blame] | 31 | #define VIEWPORT_X(dst,x) dst = s[0] * x + s[12] |
| 32 | #define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13] |
| 33 | #define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14] |
| 34 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 35 | static void TAG(emit)( GLcontext *ctx, |
| 36 | GLuint start, GLuint end, |
| 37 | void *dest ) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 38 | { |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 39 | fxMesaContext fxMesa = FX_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 40 | struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
| 41 | GLuint tmu0_source = fxMesa->tmu_source[0]; |
| 42 | GLuint tmu1_source = fxMesa->tmu_source[1]; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 43 | GLfloat (*tc0)[4], (*tc1)[4]; |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 44 | GLfloat (*col)[4], (*spec)[4]; |
| 45 | GLuint tc0_stride, tc1_stride, col_stride, spec_stride; |
Daniel Borca | 3dc3cc9 | 2004-06-14 09:11:13 +0000 | [diff] [blame] | 46 | GLuint tc0_size, tc1_size, col_size; |
Brian Paul | b79e99a | 2002-08-21 02:59:00 +0000 | [diff] [blame] | 47 | GLfloat (*proj)[4] = VB->NdcPtr->data; |
| 48 | GLuint proj_stride = VB->NdcPtr->stride; |
Daniel Borca | 2844285 | 2003-12-10 15:24:49 +0000 | [diff] [blame] | 49 | GLfloat (*psize)[4]; |
| 50 | GLuint psize_stride; |
Daniel Borca | 009542a | 2004-07-02 10:34:48 +0000 | [diff] [blame] | 51 | GLfloat (*fog)[4]; |
| 52 | GLuint fog_stride; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 53 | GrVertex *v = (GrVertex *)dest; |
| 54 | GLfloat u0scale,v0scale,u1scale,v1scale; |
Daniel Borca | b516007 | 2004-12-20 08:24:10 +0000 | [diff] [blame] | 55 | const GLubyte *mask = VB->ClipMask; |
Brian Paul | d622697 | 2001-03-03 20:59:06 +0000 | [diff] [blame] | 56 | const GLfloat *const s = ctx->Viewport._WindowMap.m; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 57 | int i; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 58 | |
Daniel Borca | 2844285 | 2003-12-10 15:24:49 +0000 | [diff] [blame] | 59 | if (IND & SETUP_PSIZ) { |
| 60 | psize = VB->PointSizePtr->data; |
| 61 | psize_stride = VB->PointSizePtr->stride; |
| 62 | } |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 63 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 64 | if (IND & SETUP_TMU0) { |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 65 | tc0 = VB->TexCoordPtr[tmu0_source]->data; |
Brian Paul | 2fc06af | 2001-09-19 03:37:16 +0000 | [diff] [blame] | 66 | tc0_stride = VB->TexCoordPtr[tmu0_source]->stride; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 67 | u0scale = fxMesa->s0scale; |
| 68 | v0scale = fxMesa->t0scale; |
| 69 | if (IND & SETUP_PTEX) |
| 70 | tc0_size = VB->TexCoordPtr[tmu0_source]->size; |
| 71 | } |
Brian Paul | d622697 | 2001-03-03 20:59:06 +0000 | [diff] [blame] | 72 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 73 | if (IND & SETUP_TMU1) { |
| 74 | tc1 = VB->TexCoordPtr[tmu1_source]->data; |
| 75 | tc1_stride = VB->TexCoordPtr[tmu1_source]->stride; |
| 76 | u1scale = fxMesa->s1scale; /* wrong if tmu1_source == 0, possible? */ |
| 77 | v1scale = fxMesa->t1scale; |
| 78 | if (IND & SETUP_PTEX) |
| 79 | tc1_size = VB->TexCoordPtr[tmu1_source]->size; |
| 80 | } |
| 81 | |
| 82 | if (IND & SETUP_RGBA) { |
Daniel Borca | 854b4a3 | 2003-11-26 08:32:35 +0000 | [diff] [blame] | 83 | col = VB->ColorPtr[0]->data; |
| 84 | col_stride = VB->ColorPtr[0]->stride; |
Daniel Borca | 3dc3cc9 | 2004-06-14 09:11:13 +0000 | [diff] [blame] | 85 | col_size = VB->ColorPtr[0]->size; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 86 | } |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 87 | |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 88 | if (IND & SETUP_SPEC) { |
| 89 | spec = VB->SecondaryColorPtr[0]->data; |
| 90 | spec_stride = VB->SecondaryColorPtr[0]->stride; |
| 91 | } |
| 92 | |
Daniel Borca | 009542a | 2004-07-02 10:34:48 +0000 | [diff] [blame] | 93 | if (IND & SETUP_FOGC) { |
| 94 | fog = VB->FogCoordPtr->data; |
| 95 | fog_stride = VB->FogCoordPtr->stride; |
| 96 | } |
| 97 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 98 | if (start) { |
| 99 | proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride); |
Daniel Borca | d075366 | 2004-01-13 08:46:12 +0000 | [diff] [blame] | 100 | if (IND & SETUP_PSIZ) |
Daniel Borca | 2844285 | 2003-12-10 15:24:49 +0000 | [diff] [blame] | 101 | psize = (GLfloat (*)[4])((GLubyte *)psize + start * psize_stride); |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 102 | if (IND & SETUP_TMU0) |
| 103 | tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride); |
| 104 | if (IND & SETUP_TMU1) |
| 105 | tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride); |
| 106 | if (IND & SETUP_RGBA) |
Daniel Borca | 854b4a3 | 2003-11-26 08:32:35 +0000 | [diff] [blame] | 107 | STRIDE_4F(col, start * col_stride); |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 108 | if (IND & SETUP_SPEC) |
| 109 | STRIDE_4F(spec, start * spec_stride); |
Daniel Borca | 009542a | 2004-07-02 10:34:48 +0000 | [diff] [blame] | 110 | if (IND & SETUP_FOGC) |
| 111 | fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride); |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 112 | } |
Brian Paul | d622697 | 2001-03-03 20:59:06 +0000 | [diff] [blame] | 113 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 114 | for (i=start; i < end; i++, v++) { |
Daniel Borca | 2844285 | 2003-12-10 15:24:49 +0000 | [diff] [blame] | 115 | if (IND & SETUP_PSIZ) { |
| 116 | v->psize = psize[0][0]; |
| 117 | psize = (GLfloat (*)[4])((GLubyte *)psize + psize_stride); |
| 118 | } |
| 119 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 120 | if (IND & SETUP_XYZW) { |
Daniel Borca | b516007 | 2004-12-20 08:24:10 +0000 | [diff] [blame] | 121 | if (mask[i] == 0) { |
Brian Paul | a75246f | 2003-10-02 17:36:43 +0000 | [diff] [blame] | 122 | /* unclipped */ |
Daniel Borca | d9f1e45 | 2003-10-09 15:12:20 +0000 | [diff] [blame] | 123 | VIEWPORT_X(v->x, proj[0][0]); |
| 124 | VIEWPORT_Y(v->y, proj[0][1]); |
| 125 | VIEWPORT_Z(v->ooz, proj[0][2]); |
Brian Paul | a75246f | 2003-10-02 17:36:43 +0000 | [diff] [blame] | 126 | v->oow = proj[0][3]; |
Daniel Borca | b516007 | 2004-12-20 08:24:10 +0000 | [diff] [blame] | 127 | |
| 128 | if (IND & SETUP_SNAP) { |
| 129 | #if defined(USE_IEEE) |
| 130 | const float snapper = (3L << 18); |
| 131 | v->x += snapper; |
| 132 | v->x -= snapper; |
| 133 | v->y += snapper; |
| 134 | v->y -= snapper; |
| 135 | #else |
| 136 | v->x = ((int) (v->x * 16.0f)) * (1.0f / 16.0f); |
| 137 | v->y = ((int) (v->y * 16.0f)) * (1.0f / 16.0f); |
| 138 | #endif |
| 139 | } |
Brian Paul | a75246f | 2003-10-02 17:36:43 +0000 | [diff] [blame] | 140 | } else { |
| 141 | /* clipped */ |
| 142 | v->oow = 1.0; |
| 143 | } |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 144 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 145 | proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride); |
| 146 | } |
| 147 | if (IND & SETUP_RGBA) { |
Daniel Borca | d9873c5 | 2004-09-24 07:03:53 +0000 | [diff] [blame] | 148 | #if FX_PACKEDCOLOR |
Daniel Borca | 2844285 | 2003-12-10 15:24:49 +0000 | [diff] [blame] | 149 | UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[2], col[0][0]); |
| 150 | UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[1], col[0][1]); |
| 151 | UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[0], col[0][2]); |
Daniel Borca | 3dc3cc9 | 2004-06-14 09:11:13 +0000 | [diff] [blame] | 152 | if (col_size == 4) { |
| 153 | UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[3], col[0][3]); |
| 154 | } else { |
| 155 | v->pargb[3] = 255; |
| 156 | } |
Daniel Borca | d9873c5 | 2004-09-24 07:03:53 +0000 | [diff] [blame] | 157 | #else /* !FX_PACKEDCOLOR */ |
| 158 | CNORM(v->r, col[0][0]); |
| 159 | CNORM(v->g, col[0][1]); |
| 160 | CNORM(v->b, col[0][2]); |
| 161 | if (col_size == 4) { |
| 162 | CNORM(v->a, col[0][3]); |
| 163 | } else { |
| 164 | v->a = 255.0f; |
| 165 | } |
| 166 | #endif /* !FX_PACKEDCOLOR */ |
Daniel Borca | 854b4a3 | 2003-11-26 08:32:35 +0000 | [diff] [blame] | 167 | STRIDE_4F(col, col_stride); |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 168 | } |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 169 | if (IND & SETUP_SPEC) { |
Daniel Borca | d9873c5 | 2004-09-24 07:03:53 +0000 | [diff] [blame] | 170 | #if FX_PACKEDCOLOR |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 171 | UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[2], spec[0][0]); |
| 172 | UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[1], spec[0][1]); |
| 173 | UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[0], spec[0][2]); |
Daniel Borca | d9873c5 | 2004-09-24 07:03:53 +0000 | [diff] [blame] | 174 | #else /* !FX_PACKEDCOLOR */ |
| 175 | CNORM(v->r1, spec[0][0]); |
| 176 | CNORM(v->g1, spec[0][1]); |
| 177 | CNORM(v->b1, spec[0][2]); |
| 178 | #endif /* !FX_PACKEDCOLOR */ |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 179 | STRIDE_4F(spec, spec_stride); |
| 180 | } |
Daniel Borca | 009542a | 2004-07-02 10:34:48 +0000 | [diff] [blame] | 181 | if (IND & SETUP_FOGC) { |
| 182 | v->fog = CLAMP(fog[0][0], 0.0f, 1.0f); |
| 183 | fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride); |
| 184 | } |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 185 | if (IND & SETUP_TMU0) { |
| 186 | GLfloat w = v->oow; |
Daniel Borca | d9f1e45 | 2003-10-09 15:12:20 +0000 | [diff] [blame] | 187 | v->tmuvtx[0].sow = tc0[0][0] * u0scale * w; |
| 188 | v->tmuvtx[0].tow = tc0[0][1] * v0scale * w; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 189 | if (IND & SETUP_PTEX) { |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 190 | v->tmuvtx[0].oow = w; |
| 191 | if (tc0_size == 4) |
Daniel Borca | d9f1e45 | 2003-10-09 15:12:20 +0000 | [diff] [blame] | 192 | v->tmuvtx[0].oow *= tc0[0][3]; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 193 | } |
| 194 | tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride); |
| 195 | } |
| 196 | if (IND & SETUP_TMU1) { |
| 197 | GLfloat w = v->oow; |
Daniel Borca | d9f1e45 | 2003-10-09 15:12:20 +0000 | [diff] [blame] | 198 | v->tmuvtx[1].sow = tc1[0][0] * u1scale * w; |
| 199 | v->tmuvtx[1].tow = tc1[0][1] * v1scale * w; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 200 | if (IND & SETUP_PTEX) { |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 201 | v->tmuvtx[1].oow = w; |
| 202 | if (tc1_size == 4) |
Daniel Borca | d9f1e45 | 2003-10-09 15:12:20 +0000 | [diff] [blame] | 203 | v->tmuvtx[1].oow *= tc1[0][3]; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 204 | } |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 205 | tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride); |
| 206 | } |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 210 | #if (IND & SETUP_XYZW) && (IND & SETUP_RGBA) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 211 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 212 | static GLboolean TAG(check_tex_sizes)( GLcontext *ctx ) |
| 213 | { |
| 214 | /* fprintf(stderr, "%s\n", __FUNCTION__); */ |
| 215 | |
| 216 | if (IND & SETUP_PTEX) |
| 217 | return GL_TRUE; |
| 218 | |
| 219 | if (IND & SETUP_TMU0) { |
| 220 | struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
| 221 | |
| 222 | if (IND & SETUP_TMU1) { |
| 223 | if (VB->TexCoordPtr[0] == 0) |
| 224 | VB->TexCoordPtr[0] = VB->TexCoordPtr[1]; |
| 225 | |
| 226 | if (VB->TexCoordPtr[1]->size == 4) |
| 227 | return GL_FALSE; |
| 228 | } |
| 229 | |
Brian Paul | 2fc06af | 2001-09-19 03:37:16 +0000 | [diff] [blame] | 230 | if (VB->TexCoordPtr[0] && VB->TexCoordPtr[0]->size == 4) |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 231 | return GL_FALSE; |
| 232 | } |
| 233 | |
| 234 | return GL_TRUE; |
| 235 | } |
| 236 | |
| 237 | static void TAG(interp)( GLcontext *ctx, |
| 238 | GLfloat t, |
| 239 | GLuint edst, GLuint eout, GLuint ein, |
| 240 | GLboolean force_boundary ) |
| 241 | { |
| 242 | fxMesaContext fxMesa = FX_CONTEXT( ctx ); |
| 243 | struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
| 244 | const GLfloat *dstclip = VB->ClipPtr->data[edst]; |
| 245 | const GLfloat oow = (dstclip[3] == 0.0F) ? 1.0F : (1.0F / dstclip[3]); |
| 246 | const GLfloat *const s = ctx->Viewport._WindowMap.m; |
| 247 | GrVertex *fxverts = fxMesa->verts; |
| 248 | GrVertex *dst = (GrVertex *) (fxverts + edst); |
| 249 | const GrVertex *out = (const GrVertex *) (fxverts + eout); |
| 250 | const GrVertex *in = (const GrVertex *) (fxverts + ein); |
Daniel Borca | 63f025c | 2004-01-07 12:50:30 +0000 | [diff] [blame] | 251 | const GLfloat wout = oow / out->oow; |
| 252 | const GLfloat win = oow / in->oow; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 253 | |
Daniel Borca | d9f1e45 | 2003-10-09 15:12:20 +0000 | [diff] [blame] | 254 | VIEWPORT_X(dst->x, dstclip[0] * oow); |
| 255 | VIEWPORT_Y(dst->y, dstclip[1] * oow); |
| 256 | VIEWPORT_Z(dst->ooz, dstclip[2] * oow); |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 257 | dst->oow = oow; |
| 258 | |
| 259 | if (IND & SETUP_SNAP) { |
| 260 | #if defined(USE_IEEE) |
| 261 | const float snapper = (3L << 18); |
| 262 | dst->x += snapper; |
| 263 | dst->x -= snapper; |
| 264 | dst->y += snapper; |
| 265 | dst->y -= snapper; |
| 266 | #else |
| 267 | dst->x = ((int) (dst->x * 16.0f)) * (1.0f / 16.0f); |
| 268 | dst->y = ((int) (dst->y * 16.0f)) * (1.0f / 16.0f); |
| 269 | #endif |
| 270 | } |
| 271 | |
| 272 | |
Daniel Borca | d9873c5 | 2004-09-24 07:03:53 +0000 | [diff] [blame] | 273 | #if FX_PACKEDCOLOR |
Brian Paul | a75246f | 2003-10-02 17:36:43 +0000 | [diff] [blame] | 274 | INTERP_UB( t, dst->pargb[0], out->pargb[0], in->pargb[0] ); |
| 275 | INTERP_UB( t, dst->pargb[1], out->pargb[1], in->pargb[1] ); |
| 276 | INTERP_UB( t, dst->pargb[2], out->pargb[2], in->pargb[2] ); |
| 277 | INTERP_UB( t, dst->pargb[3], out->pargb[3], in->pargb[3] ); |
Daniel Borca | d9873c5 | 2004-09-24 07:03:53 +0000 | [diff] [blame] | 278 | #else /* !FX_PACKEDCOLOR */ |
| 279 | INTERP_F( t, dst->r, out->r, in->r ); |
| 280 | INTERP_F( t, dst->g, out->g, in->g ); |
| 281 | INTERP_F( t, dst->b, out->b, in->b ); |
| 282 | INTERP_F( t, dst->a, out->a, in->a ); |
| 283 | #endif /* !FX_PACKEDCOLOR */ |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 284 | |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 285 | if (IND & SETUP_SPEC) { |
Daniel Borca | d9873c5 | 2004-09-24 07:03:53 +0000 | [diff] [blame] | 286 | #if FX_PACKEDCOLOR |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 287 | INTERP_UB( t, dst->pspec[0], out->pspec[0], in->pspec[0] ); |
| 288 | INTERP_UB( t, dst->pspec[1], out->pspec[1], in->pspec[1] ); |
| 289 | INTERP_UB( t, dst->pspec[2], out->pspec[2], in->pspec[2] ); |
Daniel Borca | d9873c5 | 2004-09-24 07:03:53 +0000 | [diff] [blame] | 290 | #else /* !FX_PACKEDCOLOR */ |
| 291 | INTERP_F( t, dst->r1, out->r1, in->r1 ); |
| 292 | INTERP_F( t, dst->g1, out->g1, in->g1 ); |
| 293 | INTERP_F( t, dst->b1, out->b1, in->b1 ); |
| 294 | #endif /* !FX_PACKEDCOLOR */ |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Daniel Borca | 009542a | 2004-07-02 10:34:48 +0000 | [diff] [blame] | 297 | if (IND & SETUP_FOGC) { |
| 298 | INTERP_F( t, dst->fog, out->fog, in->fog ); |
| 299 | } |
| 300 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 301 | if (IND & SETUP_TMU0) { |
Daniel Borca | a71d444 | 2004-01-08 07:37:21 +0000 | [diff] [blame] | 302 | INTERP_F( t, |
| 303 | dst->tmuvtx[0].sow, |
| 304 | out->tmuvtx[0].sow * wout, |
Daniel Borca | 63f025c | 2004-01-07 12:50:30 +0000 | [diff] [blame] | 305 | in->tmuvtx[0].sow * win ); |
| 306 | INTERP_F( t, |
| 307 | dst->tmuvtx[0].tow, |
Daniel Borca | a71d444 | 2004-01-08 07:37:21 +0000 | [diff] [blame] | 308 | out->tmuvtx[0].tow * wout, |
Daniel Borca | 63f025c | 2004-01-07 12:50:30 +0000 | [diff] [blame] | 309 | in->tmuvtx[0].tow * win ); |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 310 | if (IND & SETUP_PTEX) { |
Daniel Borca | a71d444 | 2004-01-08 07:37:21 +0000 | [diff] [blame] | 311 | INTERP_F( t, |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 312 | dst->tmuvtx[0].oow, |
| 313 | out->tmuvtx[0].oow * wout, |
| 314 | in->tmuvtx[0].oow * win ); |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | |
| 318 | if (IND & SETUP_TMU1) { |
Daniel Borca | a71d444 | 2004-01-08 07:37:21 +0000 | [diff] [blame] | 319 | INTERP_F( t, |
| 320 | dst->tmuvtx[1].sow, |
| 321 | out->tmuvtx[1].sow * wout, |
Daniel Borca | 63f025c | 2004-01-07 12:50:30 +0000 | [diff] [blame] | 322 | in->tmuvtx[1].sow * win ); |
| 323 | INTERP_F( t, |
| 324 | dst->tmuvtx[1].tow, |
Daniel Borca | a71d444 | 2004-01-08 07:37:21 +0000 | [diff] [blame] | 325 | out->tmuvtx[1].tow * wout, |
Daniel Borca | 63f025c | 2004-01-07 12:50:30 +0000 | [diff] [blame] | 326 | in->tmuvtx[1].tow * win ); |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 327 | if (IND & SETUP_PTEX) { |
Daniel Borca | a71d444 | 2004-01-08 07:37:21 +0000 | [diff] [blame] | 328 | INTERP_F( t, |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 329 | dst->tmuvtx[1].oow, |
| 330 | out->tmuvtx[1].oow * wout, |
| 331 | in->tmuvtx[1].oow * win ); |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 332 | } |
| 333 | } |
| 334 | } |
| 335 | #endif |
| 336 | |
| 337 | |
| 338 | static void TAG(init)( void ) |
| 339 | { |
| 340 | setup_tab[IND].emit = TAG(emit); |
| 341 | |
Daniel Borca | f80220d | 2003-12-15 10:38:12 +0000 | [diff] [blame] | 342 | if (IND & SETUP_SPEC) { |
| 343 | setup_tab[IND].copy_pv = copy_pv2; |
| 344 | } else { |
| 345 | setup_tab[IND].copy_pv = copy_pv; |
| 346 | } |
| 347 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 348 | #if ((IND & SETUP_XYZW) && (IND & SETUP_RGBA)) |
| 349 | setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes); |
| 350 | setup_tab[IND].interp = TAG(interp); |
| 351 | |
Daniel Borca | 27df1ec | 2004-07-26 15:10:34 +0000 | [diff] [blame] | 352 | setup_tab[IND].vertex_format = 0; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 353 | if (IND & SETUP_PTEX) { |
Daniel Borca | 27df1ec | 2004-07-26 15:10:34 +0000 | [diff] [blame] | 354 | setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU0; |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 355 | } |
Brian Paul | 2fc06af | 2001-09-19 03:37:16 +0000 | [diff] [blame] | 356 | |
| 357 | #if (IND & SETUP_TMU1) |
Daniel Borca | 27df1ec | 2004-07-26 15:10:34 +0000 | [diff] [blame] | 358 | setup_tab[IND].vertex_format |= GR_STWHINT_ST_DIFF_TMU1; |
| 359 | if (IND & SETUP_PTEX) { |
| 360 | setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU1; |
| 361 | } |
Brian Paul | 2fc06af | 2001-09-19 03:37:16 +0000 | [diff] [blame] | 362 | #endif |
| 363 | |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 364 | #endif |
| 365 | } |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 366 | |
| 367 | |
| 368 | #undef IND |
Keith Whitwell | 1182ffe | 2001-07-12 22:09:21 +0000 | [diff] [blame] | 369 | #undef TAG |