1 | /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Mesa 3-D graphics library
|
---|
5 | * Version: 3.3
|
---|
6 | *
|
---|
7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
25 | *
|
---|
26 | *
|
---|
27 | * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
|
---|
28 | * terms stated above.
|
---|
29 | *
|
---|
30 | * Thank you for your contribution, David!
|
---|
31 | *
|
---|
32 | * Please make note of the above copyright/license statement. If you
|
---|
33 | * contributed code or bug fixes to this code under the previous (GNU
|
---|
34 | * Library) license and object to the new license, your code will be
|
---|
35 | * removed at your request. Please see the Mesa docs/COPYRIGHT file
|
---|
36 | * for more information.
|
---|
37 | *
|
---|
38 | * Additional Mesa/3Dfx driver developers:
|
---|
39 | * Daryll Strauss <daryll@precisioninsight.com>
|
---|
40 | * Keith Whitwell <keith@precisioninsight.com>
|
---|
41 | *
|
---|
42 | * See fxapi.h for more revision/author details.
|
---|
43 | */
|
---|
44 |
|
---|
45 |
|
---|
46 | #ifndef _FXVSETUP_H_
|
---|
47 | #define _FXVSETUP_H_
|
---|
48 |
|
---|
49 |
|
---|
50 | #define VARS_W
|
---|
51 |
|
---|
52 | #define VARS_Z
|
---|
53 |
|
---|
54 | #define VARS_TMU0 \
|
---|
55 | GLuint tmu0_source = fxMesa->tmu_source[0]; \
|
---|
56 | GLfloat *tmu0_data = VEC_ELT(VB->TexCoordPtr[tmu0_source], \
|
---|
57 | GLfloat, start); \
|
---|
58 | GLuint tmu0_stride = VB->TexCoordPtr[tmu0_source]->stride; \
|
---|
59 | GLuint tmu0_sz = VB->TexCoordPtr[tmu0_source]->size; \
|
---|
60 | struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source]; \
|
---|
61 | GLfloat sscale0 = FX_TEXTURE_DATA(t0)->sScale; \
|
---|
62 | GLfloat tscale0 = FX_TEXTURE_DATA(t0)->tScale;
|
---|
63 |
|
---|
64 | #define VARS_TMU1 \
|
---|
65 | GLuint tmu1_source = fxMesa->tmu_source[1]; \
|
---|
66 | GLfloat *tmu1_data = VEC_ELT(VB->TexCoordPtr[tmu1_source], \
|
---|
67 | GLfloat, start); \
|
---|
68 | GLuint tmu1_stride = VB->TexCoordPtr[tmu1_source]->stride; \
|
---|
69 | GLuint tmu1_sz = VB->TexCoordPtr[tmu1_source]->size; \
|
---|
70 | struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source]; \
|
---|
71 | GLfloat sscale1 = FX_TEXTURE_DATA(t1)->sScale; \
|
---|
72 | GLfloat tscale1 = FX_TEXTURE_DATA(t1)->tScale;
|
---|
73 |
|
---|
74 | #define VARS_RGBA \
|
---|
75 | GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, start); \
|
---|
76 | GLuint col_stride = VB->ColorPtr->stride;
|
---|
77 |
|
---|
78 | #define VARS_XY GLfloat *win = VB->Win.data[start];
|
---|
79 |
|
---|
80 | #define INCR_XY win += 4
|
---|
81 |
|
---|
82 |
|
---|
83 | #ifdef FX_V2
|
---|
84 | # define DO_SETUP_XY \
|
---|
85 | v[XCOORD]=win[0]; \
|
---|
86 | v[YCOORD]=win[1];
|
---|
87 | #else
|
---|
88 | #ifdef DRIVERTS
|
---|
89 | # define DO_SETUP_XY \
|
---|
90 | v[XCOORD]=win[0]+fxMesa->x_offset; \
|
---|
91 | v[YCOORD]=win[1]+fxMesa->y_delta;
|
---|
92 | #else
|
---|
93 | # if (defined(__linux__) && defined(__i386__)) || defined(macintosh)
|
---|
94 | # define DO_SETUP_XY { \
|
---|
95 | GLfloat t1 = win[0] + snapper; \
|
---|
96 | GLfloat t2 = win[1] + snapper; \
|
---|
97 | v[XCOORD] = t1 - snapper; \
|
---|
98 | v[YCOORD] = t2 - snapper; \
|
---|
99 | }
|
---|
100 | # else
|
---|
101 | # define DO_SETUP_XY { \
|
---|
102 | /* trunc (x,y) to multiple of 1/16 */ \
|
---|
103 | v[XCOORD]=((int)(win[0]*16.0f))*(1.0f/16.0f); \
|
---|
104 | v[YCOORD]=((int)(win[1]*16.0f))*(1.0f/16.0f); \
|
---|
105 | }
|
---|
106 | # endif
|
---|
107 | #endif
|
---|
108 | #endif
|
---|
109 |
|
---|
110 |
|
---|
111 | #define DO_SETUP_W { \
|
---|
112 | v[OOWCOORD]=win[3]; \
|
---|
113 | }
|
---|
114 |
|
---|
115 | #define DO_SETUP_Z v[ZCOORD]=win[2];
|
---|
116 |
|
---|
117 | #define DO_SETUP_TMU0 \
|
---|
118 | { \
|
---|
119 | v[S0COORD]=sscale0*tmu0_data[0]*v[OOWCOORD]; \
|
---|
120 | v[T0COORD]=tscale0*tmu0_data[1]*v[OOWCOORD]; \
|
---|
121 | }
|
---|
122 |
|
---|
123 | #define INCR_TMU0 STRIDE_F(tmu0_data, tmu0_stride)
|
---|
124 |
|
---|
125 | #define DO_SETUP_TMU1 \
|
---|
126 | { \
|
---|
127 | v[S1COORD]=sscale1*tmu1_data[0]*v[OOWCOORD]; \
|
---|
128 | v[T1COORD]=tscale1*tmu1_data[1]*v[OOWCOORD]; \
|
---|
129 | }
|
---|
130 |
|
---|
131 | #define INCR_TMU1 STRIDE_F(tmu1_data, tmu1_stride)
|
---|
132 |
|
---|
133 | #if FX_USE_PARGB
|
---|
134 | #define DO_SETUP_RGBA \
|
---|
135 | { GET_PARGB(v) = color[ACOMP] << 24 | color[RCOMP] << 16 | color[GCOMP] << 8 | color[BCOMP];}
|
---|
136 |
|
---|
137 | #else
|
---|
138 | #define DO_SETUP_RGBA \
|
---|
139 | { \
|
---|
140 | UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[RCOORD], color[0]); \
|
---|
141 | UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[GCOORD], color[1]); \
|
---|
142 | UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[BCOORD], color[2]); \
|
---|
143 | UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[ACOORD], color[3]); \
|
---|
144 | }
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | #define INCR_RGBA color += col_stride
|
---|
148 |
|
---|
149 |
|
---|
150 | #define _FIXUP_PRE \
|
---|
151 | GLuint hs = fxMesa->stw_hint_state & ~(GR_STWHINT_W_DIFF_TMU0 | \
|
---|
152 | GR_STWHINT_W_DIFF_TMU1);
|
---|
153 |
|
---|
154 | #define _FIXUP_TMU0 \
|
---|
155 | if (tmu0_sz == 4) { \
|
---|
156 | project_texcoords( VB, 0, tmu0_source, start, end ); \
|
---|
157 | hs |= GR_STWHINT_W_DIFF_TMU0; \
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | #define _FIXUP_TMU1 \
|
---|
162 | if (tmu1_sz == 4) { \
|
---|
163 | project_texcoords( VB, 1, tmu1_source, start, end ); \
|
---|
164 | hs |= GR_STWHINT_W_DIFF_TMU1; \
|
---|
165 | }
|
---|
166 |
|
---|
167 |
|
---|
168 | #define _FIXUP_TMU01 \
|
---|
169 | if (tmu0_sz == 4) { \
|
---|
170 | project_texcoords( VB, 0, tmu0_source, start, end ); \
|
---|
171 | if (tmu1_sz == 4) \
|
---|
172 | project_texcoords( VB, 1, tmu1_source, start, end ); \
|
---|
173 | else \
|
---|
174 | copy_w( VB, 1, start, end ); \
|
---|
175 | hs |= (GR_STWHINT_W_DIFF_TMU0|GR_STWHINT_W_DIFF_TMU1); \
|
---|
176 | } else if (tmu1_sz == 4) { \
|
---|
177 | project_texcoords( VB, 1, tmu1_source, start, end ); \
|
---|
178 | hs |= GR_STWHINT_W_DIFF_TMU1; \
|
---|
179 | }
|
---|
180 |
|
---|
181 | #define _FIXUP_POST \
|
---|
182 | if (hs != fxMesa->stw_hint_state) { \
|
---|
183 | fxMesa->stw_hint_state = hs; \
|
---|
184 | FX_grHints(GR_HINT_STWHINT, hs); \
|
---|
185 | }
|
---|
186 |
|
---|
187 |
|
---|
188 | #define FIXUP_TMU0 { _FIXUP_PRE _FIXUP_TMU0 _FIXUP_POST }
|
---|
189 | #define FIXUP_TMU1 { _FIXUP_PRE _FIXUP_TMU1 _FIXUP_POST }
|
---|
190 | #define FIXUP_TMU01 { _FIXUP_PRE _FIXUP_TMU01 _FIXUP_POST }
|
---|
191 |
|
---|
192 |
|
---|
193 | /* v - pointer to destination GrVertex
|
---|
194 | * VB - source of data
|
---|
195 | * i - index into vb for data
|
---|
196 | */
|
---|
197 |
|
---|
198 |
|
---|
199 | #endif
|
---|