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 | /* fxvsetup.c - 3Dfx VooDoo vertices setup functions */
|
---|
47 |
|
---|
48 |
|
---|
49 | #ifdef HAVE_CONFIG_H
|
---|
50 | #include "conf.h"
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | #if defined(FX)
|
---|
54 |
|
---|
55 | #include "fxdrv.h"
|
---|
56 | #include "mmath.h"
|
---|
57 | #include "pipeline.h"
|
---|
58 | #include "fxvsetup.h"
|
---|
59 |
|
---|
60 | void fxPrintSetupFlags( const char *msg, GLuint flags )
|
---|
61 | {
|
---|
62 | fprintf(stderr, "%s: %d %s%s%s%s%s%s\n",
|
---|
63 | msg,
|
---|
64 | flags,
|
---|
65 | (flags & SETUP_XY) ? " xy," : "",
|
---|
66 | (flags & SETUP_Z) ? " z," : "",
|
---|
67 | (flags & SETUP_W) ? " w," : "",
|
---|
68 | (flags & SETUP_RGBA) ? " rgba," : "",
|
---|
69 | (flags & SETUP_TMU0) ? " tmu0," : "",
|
---|
70 | (flags & SETUP_TMU1) ? " tmu1," : "");
|
---|
71 | }
|
---|
72 |
|
---|
73 | static void project_texcoords( struct vertex_buffer *VB,
|
---|
74 | GLuint tmu_nr, GLuint tc_nr,
|
---|
75 | GLuint start, GLuint count )
|
---|
76 | {
|
---|
77 | fxVertex *v = FX_DRIVER_DATA(VB)->verts + start;
|
---|
78 | GrTmuVertex *tmu = &(((GrVertex *)v->f)->tmuvtx[tmu_nr]);
|
---|
79 | GLvector4f *vec = VB->TexCoordPtr[tc_nr];
|
---|
80 |
|
---|
81 | GLuint i;
|
---|
82 | GLuint stride = vec->stride;
|
---|
83 | GLfloat *data = VEC_ELT(vec, GLfloat, start);
|
---|
84 |
|
---|
85 | for (i = start ; i < count ; i++, STRIDE_F(data, stride), v++) {
|
---|
86 | tmu->oow = v->f[OOWCOORD] * data[3];
|
---|
87 | tmu = (GrTmuVertex *)((char *)tmu + sizeof(fxVertex));
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | static void copy_w( struct vertex_buffer *VB,
|
---|
93 | GLuint tmu_nr,
|
---|
94 | GLuint start, GLuint count )
|
---|
95 | {
|
---|
96 | fxVertex *v = FX_DRIVER_DATA(VB)->verts + start;
|
---|
97 | GrTmuVertex *tmu = &(((GrVertex *)v->f)->tmuvtx[tmu_nr]);
|
---|
98 | GLuint i;
|
---|
99 |
|
---|
100 | for (i = start ; i < count ; i++, v++) {
|
---|
101 | tmu->oow = v->f[OOWCOORD];
|
---|
102 | tmu = (GrTmuVertex *)((char *)tmu + sizeof(fxVertex));
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 | static tfxSetupFunc setupfuncs[0x40];
|
---|
108 |
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 | #define IND SETUP_XY
|
---|
113 | #define NAME fxsetupXY
|
---|
114 | #include "fxvs_tmp.h"
|
---|
115 |
|
---|
116 | #define IND (SETUP_XY|SETUP_Z)
|
---|
117 | #define NAME fxsetupXYZ
|
---|
118 | #include "fxvs_tmp.h"
|
---|
119 |
|
---|
120 | #define IND (SETUP_XY|SETUP_W)
|
---|
121 | #define NAME fxsetupXYW
|
---|
122 | #include "fxvs_tmp.h"
|
---|
123 |
|
---|
124 | #define IND (SETUP_XY|SETUP_Z|SETUP_W)
|
---|
125 | #define NAME fxsetupXYZW
|
---|
126 | #include "fxvs_tmp.h"
|
---|
127 |
|
---|
128 | #define IND (SETUP_RGBA|SETUP_XY)
|
---|
129 | #define NAME fxsetupXYRGBA
|
---|
130 | #include "fxvs_tmp.h"
|
---|
131 |
|
---|
132 | #define IND (SETUP_RGBA|SETUP_XY|SETUP_Z)
|
---|
133 | #define NAME fxsetupXYZRGBA
|
---|
134 | #include "fxvs_tmp.h"
|
---|
135 |
|
---|
136 | #define IND (SETUP_RGBA|SETUP_XY|SETUP_W)
|
---|
137 | #define NAME fxsetupXYWRGBA
|
---|
138 | #include "fxvs_tmp.h"
|
---|
139 |
|
---|
140 | #define IND (SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W)
|
---|
141 | #define NAME fxsetupXYZWRGBA
|
---|
142 | #include "fxvs_tmp.h"
|
---|
143 |
|
---|
144 | #define IND (SETUP_TMU0|SETUP_XY|SETUP_W)
|
---|
145 | #define NAME fxsetupXYWT0
|
---|
146 | #include "fxvs_tmp.h"
|
---|
147 |
|
---|
148 | #define IND (SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W)
|
---|
149 | #define NAME fxsetupXYZWT0
|
---|
150 | #include "fxvs_tmp.h"
|
---|
151 |
|
---|
152 | #define IND (SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_W)
|
---|
153 | #define NAME fxsetupXYWT0T1
|
---|
154 | #include "fxvs_tmp.h"
|
---|
155 |
|
---|
156 | #define IND (SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W)
|
---|
157 | #define NAME fxsetupXYZWT0T1
|
---|
158 | #include "fxvs_tmp.h"
|
---|
159 |
|
---|
160 | #define IND (SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W)
|
---|
161 | #define NAME fxsetupXYWRGBAT0
|
---|
162 | #include "fxvs_tmp.h"
|
---|
163 |
|
---|
164 | #define IND (SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W)
|
---|
165 | #define NAME fxsetupXYZWRGBAT0
|
---|
166 | #include "fxvs_tmp.h"
|
---|
167 |
|
---|
168 | #define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W)
|
---|
169 | #define NAME fxsetupXYWRGBAT0T1
|
---|
170 | #include "fxvs_tmp.h"
|
---|
171 |
|
---|
172 | #define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W)
|
---|
173 | #define NAME fxsetupXYZWRGBAT0T1
|
---|
174 | #include "fxvs_tmp.h"
|
---|
175 |
|
---|
176 | #define IND (SETUP_RGBA)
|
---|
177 | #define NAME fxsetupRGBA
|
---|
178 | #include "fxvs_tmp.h"
|
---|
179 |
|
---|
180 | #define IND (SETUP_TMU0)
|
---|
181 | #define NAME fxsetupT0
|
---|
182 | #include "fxvs_tmp.h"
|
---|
183 |
|
---|
184 | #define IND (SETUP_TMU1)
|
---|
185 | #define NAME fxsetupT1
|
---|
186 | #include "fxvs_tmp.h"
|
---|
187 |
|
---|
188 | #define IND (SETUP_TMU1|SETUP_TMU0)
|
---|
189 | #define NAME fxsetupT0T1
|
---|
190 | #include "fxvs_tmp.h"
|
---|
191 |
|
---|
192 | #define IND (SETUP_TMU0|SETUP_RGBA)
|
---|
193 | #define NAME fxsetupRGBAT0
|
---|
194 | #include "fxvs_tmp.h"
|
---|
195 |
|
---|
196 | #define IND (SETUP_TMU1|SETUP_RGBA)
|
---|
197 | #define NAME fxsetupRGBAT1
|
---|
198 | #include "fxvs_tmp.h"
|
---|
199 |
|
---|
200 | #define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA)
|
---|
201 | #define NAME fxsetupRGBAT0T1
|
---|
202 | #include "fxvs_tmp.h"
|
---|
203 |
|
---|
204 | #define IND (SETUP_W|SETUP_RGBA)
|
---|
205 | #define NAME fxsetupWRGBA
|
---|
206 | #include "fxvs_tmp.h"
|
---|
207 |
|
---|
208 | #define IND (SETUP_W|SETUP_TMU0)
|
---|
209 | #define NAME fxsetupWT0
|
---|
210 | #include "fxvs_tmp.h"
|
---|
211 |
|
---|
212 | #define IND (SETUP_W|SETUP_TMU1)
|
---|
213 | #define NAME fxsetupWT1
|
---|
214 | #include "fxvs_tmp.h"
|
---|
215 |
|
---|
216 | #define IND (SETUP_W|SETUP_TMU1|SETUP_TMU0)
|
---|
217 | #define NAME fxsetupWT0T1
|
---|
218 | #include "fxvs_tmp.h"
|
---|
219 |
|
---|
220 | #define IND (SETUP_W|SETUP_TMU0|SETUP_RGBA)
|
---|
221 | #define NAME fxsetupWRGBAT0
|
---|
222 | #include "fxvs_tmp.h"
|
---|
223 |
|
---|
224 | #define IND (SETUP_W|SETUP_TMU1|SETUP_RGBA)
|
---|
225 | #define NAME fxsetupWRGBAT1
|
---|
226 | #include "fxvs_tmp.h"
|
---|
227 |
|
---|
228 | #define IND (SETUP_W|SETUP_TMU1|SETUP_TMU0|SETUP_RGBA)
|
---|
229 | #define NAME fxsetupWRGBAT0T1
|
---|
230 | #include "fxvs_tmp.h"
|
---|
231 |
|
---|
232 |
|
---|
233 |
|
---|
234 | void fxDDSetupInit( void )
|
---|
235 | {
|
---|
236 | setupfuncs[SETUP_XY] = fxsetupXY;
|
---|
237 | setupfuncs[SETUP_XY|SETUP_Z] = fxsetupXYZ;
|
---|
238 | setupfuncs[SETUP_XY|SETUP_W] = fxsetupXYW;
|
---|
239 | setupfuncs[SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZW;
|
---|
240 |
|
---|
241 | setupfuncs[SETUP_RGBA|SETUP_XY] = fxsetupXYRGBA;
|
---|
242 | setupfuncs[SETUP_RGBA|SETUP_XY|SETUP_Z] = fxsetupXYZRGBA;
|
---|
243 | setupfuncs[SETUP_RGBA|SETUP_XY|SETUP_W] = fxsetupXYWRGBA;
|
---|
244 | setupfuncs[SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWRGBA;
|
---|
245 |
|
---|
246 | /* If we have texture and xy then we must have w.
|
---|
247 | * If we have texture1 and w then we must have texture 0.
|
---|
248 | */
|
---|
249 | setupfuncs[SETUP_TMU0|SETUP_XY|SETUP_W] = fxsetupXYWT0;
|
---|
250 | setupfuncs[SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWT0;
|
---|
251 |
|
---|
252 | setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_W] = fxsetupXYWT0T1;
|
---|
253 | setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWT0T1;
|
---|
254 |
|
---|
255 | setupfuncs[SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W] = fxsetupXYWRGBAT0;
|
---|
256 | setupfuncs[SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWRGBAT0;
|
---|
257 |
|
---|
258 | setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W] = fxsetupXYWRGBAT0T1;
|
---|
259 | setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W] = fxsetupXYZWRGBAT0T1;
|
---|
260 |
|
---|
261 | /* If we don't have xy then we can't have z... w is still a possibility.
|
---|
262 | */
|
---|
263 | setupfuncs[SETUP_RGBA] = fxsetupRGBA;
|
---|
264 | setupfuncs[SETUP_TMU0] = fxsetupT0;
|
---|
265 | setupfuncs[SETUP_TMU1] = fxsetupT1;
|
---|
266 | setupfuncs[SETUP_TMU1|SETUP_TMU0] = fxsetupT0T1;
|
---|
267 | setupfuncs[SETUP_TMU0|SETUP_RGBA] = fxsetupRGBAT0;
|
---|
268 | setupfuncs[SETUP_TMU1|SETUP_RGBA] = fxsetupRGBAT1;
|
---|
269 | setupfuncs[SETUP_TMU1|SETUP_TMU0|SETUP_RGBA] = fxsetupRGBAT0T1;
|
---|
270 |
|
---|
271 | setupfuncs[SETUP_W|SETUP_RGBA] = fxsetupWRGBA;
|
---|
272 | setupfuncs[SETUP_W|SETUP_TMU0] = fxsetupWT0;
|
---|
273 | setupfuncs[SETUP_W|SETUP_TMU1] = fxsetupWT1;
|
---|
274 | setupfuncs[SETUP_W|SETUP_TMU1|SETUP_TMU0] = fxsetupWT0T1;
|
---|
275 | setupfuncs[SETUP_W|SETUP_TMU0|SETUP_RGBA] = fxsetupWRGBAT0;
|
---|
276 | setupfuncs[SETUP_W|SETUP_TMU1|SETUP_RGBA] = fxsetupWRGBAT1;
|
---|
277 | setupfuncs[SETUP_W|SETUP_TMU1|SETUP_TMU0|SETUP_RGBA] = fxsetupWRGBAT0T1;
|
---|
278 |
|
---|
279 | }
|
---|
280 |
|
---|
281 |
|
---|
282 |
|
---|
283 | tfxSetupFunc fxDDChooseSetupFunction(GLcontext *ctx)
|
---|
284 | {
|
---|
285 | GLuint setupindex = SETUP_XY|SETUP_Z;
|
---|
286 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
---|
287 |
|
---|
288 | fxMesa->setupindex = 0;
|
---|
289 |
|
---|
290 | if (ctx->RenderMode != GL_RENDER)
|
---|
291 | return 0;
|
---|
292 |
|
---|
293 | fxMesa->tmu_source[0] = 0;
|
---|
294 | fxMesa->tmu_source[1] = 1;
|
---|
295 |
|
---|
296 | fxMesa->tex_dest[0] = SETUP_TMU0;
|
---|
297 | fxMesa->tex_dest[1] = SETUP_TMU1;
|
---|
298 |
|
---|
299 | if (ctx->Light.ShadeModel == GL_SMOOTH && !ctx->Light.Model.TwoSide)
|
---|
300 | setupindex |= SETUP_RGBA;
|
---|
301 |
|
---|
302 | if (ctx->Fog.Enabled && ctx->FogMode==FOG_FRAGMENT)
|
---|
303 | setupindex |= SETUP_RGBA|SETUP_W;
|
---|
304 |
|
---|
305 | if ((ctx->Texture.ReallyEnabled & (TEXTURE0_2D|TEXTURE0_3D)) == TEXTURE0_2D)
|
---|
306 | {
|
---|
307 | if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
|
---|
308 | setupindex &= ~SETUP_RGBA;
|
---|
309 |
|
---|
310 | setupindex |= SETUP_TMU0|SETUP_W;
|
---|
311 | }
|
---|
312 |
|
---|
313 | if ((ctx->Texture.ReallyEnabled & (TEXTURE1_2D|TEXTURE1_3D)) == TEXTURE1_2D)
|
---|
314 | {
|
---|
315 | setupindex |= SETUP_TMU1|SETUP_W;
|
---|
316 | if (setupindex & SETUP_TMU0) { /* both TMUs in use */
|
---|
317 | struct gl_texture_object *tObj=ctx->Texture.Unit[0].CurrentD[2];
|
---|
318 | tfxTexInfo *ti=fxTMGetTexInfo(tObj);
|
---|
319 |
|
---|
320 | if (ti->whichTMU!=FX_TMU0) { /* TMU0 and TMU1 are swapped */
|
---|
321 | fxMesa->tmu_source[0] = 1; fxMesa->tex_dest[1] = SETUP_TMU0;
|
---|
322 | fxMesa->tmu_source[1] = 0; fxMesa->tex_dest[0] = SETUP_TMU1;
|
---|
323 | }
|
---|
324 | }
|
---|
325 | }
|
---|
326 |
|
---|
327 | if (ctx->Color.BlendEnabled)
|
---|
328 | setupindex |= SETUP_RGBA;
|
---|
329 |
|
---|
330 | if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_PIPELINE|VERBOSE_STATE))
|
---|
331 | fxPrintSetupFlags("fxmesa: vertex setup function", setupindex);
|
---|
332 |
|
---|
333 | fxMesa->setupindex = setupindex;
|
---|
334 | fxMesa->view_clip_tri = fxTriViewClipTab[setupindex&0x7];
|
---|
335 | fxMesa->clip_tri_stride = fxTriClipStrideTab[setupindex&0x7];
|
---|
336 | return setupfuncs[setupindex];
|
---|
337 | }
|
---|
338 |
|
---|
339 | void fxDDDoRasterSetup( struct vertex_buffer *VB )
|
---|
340 | {
|
---|
341 | GLcontext *ctx = VB->ctx;
|
---|
342 | FX_DRIVER_DATA(VB)->last_vert = FX_DRIVER_DATA(VB)->verts + VB->Count;
|
---|
343 |
|
---|
344 | if ((ctx->IndirectTriangles & DD_SW_RASTERIZE) == DD_SW_RASTERIZE) {
|
---|
345 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
---|
346 | fxMesa->setupdone = 0;
|
---|
347 | return;
|
---|
348 | }
|
---|
349 |
|
---|
350 | if (VB->Type == VB_CVA_PRECALC)
|
---|
351 | fxDDPartialRasterSetup( VB );
|
---|
352 | else
|
---|
353 | ctx->Driver.RasterSetup( VB, VB->CopyStart, VB->Count );
|
---|
354 | }
|
---|
355 |
|
---|
356 |
|
---|
357 | /*
|
---|
358 | * Need to check that merge&render will work before allowing this to
|
---|
359 | * happen here. Therefore - need to know that this will be fired when
|
---|
360 | * we get a forbidden input in the elt pipeline - and therefore need to check
|
---|
361 | * whether we have one *now*. Similarly need to know if state changes cause
|
---|
362 | * size4 texcoords to be introduced.
|
---|
363 | */
|
---|
364 | void fxDDCheckPartialRasterSetup( GLcontext *ctx, struct gl_pipeline_stage *d )
|
---|
365 | {
|
---|
366 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
---|
367 | GLuint tmp = fxMesa->setupdone;
|
---|
368 |
|
---|
369 | d->type = 0;
|
---|
370 | d->pre_forbidden_inputs = 0;
|
---|
371 | fxMesa->setupdone = 0; /* cleared if we return */
|
---|
372 |
|
---|
373 | /* Indirect triangles must be rendered via the immediate pipeline.
|
---|
374 | * If all rasterization is software, no need to set up.
|
---|
375 | */
|
---|
376 | if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0)
|
---|
377 | return;
|
---|
378 |
|
---|
379 | if ((ctx->IndirectTriangles & DD_SW_SETUP) ||
|
---|
380 | (ctx->IndirectTriangles & DD_SW_RASTERIZE) == DD_SW_RASTERIZE)
|
---|
381 | return;
|
---|
382 |
|
---|
383 | if ((ctx->Texture.ReallyEnabled & 0xf) &&
|
---|
384 | !(ctx->Array.Flags & VERT_TEX0_ANY))
|
---|
385 | {
|
---|
386 | if (ctx->TextureMatrix[0].type == MATRIX_GENERAL ||
|
---|
387 | ctx->TextureMatrix[0].type == MATRIX_PERSPECTIVE ||
|
---|
388 | (ctx->Texture.Unit[1].TexGenEnabled & Q_BIT))
|
---|
389 | return;
|
---|
390 |
|
---|
391 | d->pre_forbidden_inputs |= VERT_TEX0_4;
|
---|
392 | }
|
---|
393 |
|
---|
394 | if ((ctx->Texture.ReallyEnabled & 0xf0) &&
|
---|
395 | !(ctx->Array.Flags & VERT_TEX1_ANY))
|
---|
396 | {
|
---|
397 | if (ctx->TextureMatrix[1].type == MATRIX_GENERAL ||
|
---|
398 | ctx->TextureMatrix[1].type == MATRIX_PERSPECTIVE ||
|
---|
399 | (ctx->Texture.Unit[1].TexGenEnabled & Q_BIT))
|
---|
400 | return;
|
---|
401 |
|
---|
402 | d->pre_forbidden_inputs |= VERT_TEX1_4;
|
---|
403 | }
|
---|
404 |
|
---|
405 |
|
---|
406 | fxMesa->setupdone = tmp;
|
---|
407 | d->inputs = 0;
|
---|
408 | d->outputs = VERT_SETUP_PART;
|
---|
409 | d->type = PIPE_PRECALC;
|
---|
410 | }
|
---|
411 |
|
---|
412 |
|
---|
413 | /* Will be different every time - no point in trying to precalc the
|
---|
414 | * function to call.
|
---|
415 | */
|
---|
416 | void fxDDPartialRasterSetup( struct vertex_buffer *VB )
|
---|
417 | {
|
---|
418 | GLuint newout = VB->pipeline->new_outputs;
|
---|
419 | fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;
|
---|
420 | GLuint ind = 0;
|
---|
421 |
|
---|
422 | FX_DRIVER_DATA(VB)->last_vert = FX_DRIVER_DATA(VB)->verts + VB->Count;
|
---|
423 |
|
---|
424 | if (newout & VERT_WIN) {
|
---|
425 | newout = VB->pipeline->outputs;
|
---|
426 | ind |= SETUP_XY|SETUP_W|SETUP_Z;
|
---|
427 | }
|
---|
428 |
|
---|
429 | if (newout & VERT_TEX0_ANY)
|
---|
430 | ind |= SETUP_W | fxMesa->tex_dest[0];
|
---|
431 |
|
---|
432 | if (newout & VERT_TEX1_ANY)
|
---|
433 | ind |= SETUP_W | fxMesa->tex_dest[1];
|
---|
434 |
|
---|
435 | if (newout & VERT_RGBA)
|
---|
436 | ind |= SETUP_W|SETUP_RGBA;
|
---|
437 |
|
---|
438 | if ((newout & VERT_WIN) == 0)
|
---|
439 | ind &= ~(fxMesa->setupdone & SETUP_W);
|
---|
440 |
|
---|
441 | fxMesa->setupdone &= ~ind;
|
---|
442 | ind &= fxMesa->setupindex;
|
---|
443 | fxMesa->setupdone |= ind;
|
---|
444 |
|
---|
445 | if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_PIPELINE)) {
|
---|
446 | gl_print_vert_flags("new outputs", VB->pipeline->new_outputs);
|
---|
447 | fxPrintSetupFlags("fxmesa: partial setup function", ind);
|
---|
448 | }
|
---|
449 |
|
---|
450 | if (ind)
|
---|
451 | setupfuncs[ind]( VB, VB->Start, VB->Count );
|
---|
452 | }
|
---|
453 |
|
---|
454 | /* Almost certainly never called.
|
---|
455 | */
|
---|
456 | void fxDDResizeVB( struct vertex_buffer *VB, GLuint size )
|
---|
457 | {
|
---|
458 | struct tfxMesaVertexBuffer *fvb = FX_DRIVER_DATA(VB);
|
---|
459 |
|
---|
460 | while (fvb->size < size)
|
---|
461 | fvb->size *= 2;
|
---|
462 |
|
---|
463 | FREE( VB->ClipMask );
|
---|
464 | VB->ClipMask = (GLubyte *)MALLOC(sizeof(GLubyte) * fvb->size);
|
---|
465 |
|
---|
466 | FREE( fvb->vert_store );
|
---|
467 | fvb->vert_store = MALLOC( sizeof(fxVertex) * fvb->size + 31);
|
---|
468 | if (!fvb->vert_store || !VB->ClipMask)
|
---|
469 | {
|
---|
470 | fprintf(stderr,"fx Driver: out of memory !\n");
|
---|
471 | fxCloseHardware();
|
---|
472 | EXIT(-1);
|
---|
473 | }
|
---|
474 | fvb->verts = (fxVertex *)(((unsigned long)fvb->vert_store + 31) & ~31);
|
---|
475 |
|
---|
476 | gl_vector1ui_free( &fvb->clipped_elements );
|
---|
477 | gl_vector1ui_alloc( &fvb->clipped_elements, VEC_WRITABLE, fvb->size, 32 );
|
---|
478 |
|
---|
479 | if (!fvb->clipped_elements.start) goto memerror;
|
---|
480 |
|
---|
481 | return;
|
---|
482 | memerror:
|
---|
483 | fprintf(stderr,"fx Driver: out of memory !\n");
|
---|
484 | fxCloseHardware();
|
---|
485 | EXIT(-1);
|
---|
486 | }
|
---|
487 |
|
---|
488 |
|
---|
489 | void fxDDRegisterVB( struct vertex_buffer *VB )
|
---|
490 | {
|
---|
491 | struct tfxMesaVertexBuffer *fvb;
|
---|
492 |
|
---|
493 | fvb = (struct tfxMesaVertexBuffer *)calloc( 1, sizeof(*fvb) );
|
---|
494 |
|
---|
495 | /* This looks like it allocates a lot of memory, but it basically
|
---|
496 | * just sets an upper limit on how much can be used - nothing like
|
---|
497 | * this amount will ever be turned into 'real' memory.
|
---|
498 | */
|
---|
499 | if (VB->Type == VB_CVA_PRECALC) {
|
---|
500 | fvb->size = VB->Size * 5;
|
---|
501 | fvb->vert_store = MALLOC( sizeof(fxVertex) * fvb->size + 31);
|
---|
502 | if (!fvb->vert_store) goto memerror;
|
---|
503 | #if defined(FX_GLIDE3)
|
---|
504 | fvb->triangle_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
|
---|
505 | if (!fvb->triangle_b) goto memerror;
|
---|
506 | fvb->strips_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
|
---|
507 | if (!fvb->strips_b ) goto memerror;
|
---|
508 | #endif
|
---|
509 | fvb->verts = (fxVertex *)(((unsigned long)fvb->vert_store + 31) & ~31);
|
---|
510 | gl_vector1ui_alloc( &fvb->clipped_elements, VEC_WRITABLE, fvb->size, 32 );
|
---|
511 | if (!fvb->clipped_elements.start) goto memerror;
|
---|
512 |
|
---|
513 | FREE( VB->ClipMask );
|
---|
514 | VB->ClipMask = (GLubyte *)MALLOC(sizeof(GLubyte) * fvb->size);
|
---|
515 | if (!VB->ClipMask) goto memerror;
|
---|
516 |
|
---|
517 | } else {
|
---|
518 | fvb->vert_store = MALLOC( sizeof(fxVertex) * (VB->Size + 12) + 31);
|
---|
519 | if (!fvb->vert_store) goto memerror;
|
---|
520 | #if defined(FX_GLIDE3)
|
---|
521 | fvb->triangle_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
|
---|
522 | if (!fvb->triangle_b) goto memerror;
|
---|
523 | fvb->strips_b = MALLOC( sizeof(GrVertex*) *4* fvb->size+ 31);
|
---|
524 | if (!fvb->strips_b ) goto memerror;
|
---|
525 | #endif
|
---|
526 | fvb->verts = (fxVertex *)(((unsigned long)fvb->vert_store + 31) & ~31);
|
---|
527 | fvb->size = VB->Size + 12;
|
---|
528 | }
|
---|
529 |
|
---|
530 |
|
---|
531 | VB->driver_data = fvb;
|
---|
532 | return;
|
---|
533 | memerror:
|
---|
534 | fprintf(stderr,"fx Driver: out of memory !\n");
|
---|
535 | fxCloseHardware();
|
---|
536 | EXIT(-1);
|
---|
537 | }
|
---|
538 |
|
---|
539 | void fxDDUnregisterVB( struct vertex_buffer *VB )
|
---|
540 | {
|
---|
541 | struct tfxMesaVertexBuffer *fvb = FX_DRIVER_DATA(VB);
|
---|
542 |
|
---|
543 | if (fvb) {
|
---|
544 | if (fvb->vert_store) FREE(fvb->vert_store);
|
---|
545 | gl_vector1ui_free( &fvb->clipped_elements );
|
---|
546 | FREE(fvb);
|
---|
547 | #if defined(FX_GLIDE3)
|
---|
548 | if (fvb->strips_b)
|
---|
549 | FREE(fvb->strips_b);
|
---|
550 | if (fvb->triangle_b)
|
---|
551 | FREE(fvb->triangle_b);
|
---|
552 | #endif
|
---|
553 | VB->driver_data = 0;
|
---|
554 | }
|
---|
555 | }
|
---|
556 |
|
---|
557 |
|
---|
558 |
|
---|
559 | #else
|
---|
560 |
|
---|
561 |
|
---|
562 | /*
|
---|
563 | * Need this to provide at least one external definition.
|
---|
564 | */
|
---|
565 |
|
---|
566 | int gl_fx_dummy_function_vsetup(void)
|
---|
567 | {
|
---|
568 | return 0;
|
---|
569 | }
|
---|
570 |
|
---|
571 | #endif /* FX */
|
---|