source: trunk/src/opengl/mesa/3dfx/fxpipeline.c

Last change on this file was 3598, checked in by jeroen, 25 years ago

* empty log message *

File size: 8.7 KB
Line 
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#ifdef HAVE_CONFIG_H
47#include "conf.h"
48#endif
49
50
51#if defined(FX)
52
53#include "fxdrv.h"
54#include "vbindirect.h"
55
56
57/* We don't handle texcoord-4 in the safe clip routines - maybe we should.
58 */
59static void fxDDRenderElements( struct vertex_buffer *VB )
60{
61 GLcontext *ctx = VB->ctx;
62 fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
63
64 if (fxMesa->render_index != 0 ||
65 ((ctx->Texture.ReallyEnabled & 0xf) && VB->TexCoordPtr[0]->size>2) ||
66 ((ctx->Texture.ReallyEnabled & 0xf0) && VB->TexCoordPtr[1]->size>2) ||
67 (VB->ClipPtr->size != 4)) /* Brokes clipping otherwise*/
68 gl_render_elts( VB );
69 else
70 fxDDRenderElementsDirect( VB );
71}
72
73static void fxDDCheckRenderVBIndirect( GLcontext *ctx,
74 struct gl_pipeline_stage *d )
75{
76 d->type = 0;
77
78 if ((ctx->IndirectTriangles & DD_SW_SETUP) == 0 &&
79 ctx->Driver.MultipassFunc == 0)
80 {
81 d->type = PIPE_IMMEDIATE;
82 d->inputs = VERT_SETUP_FULL | VERT_ELT | VERT_PRECALC_DATA;
83 }
84}
85
86static void fxDDRenderVBIndirect( struct vertex_buffer *VB )
87{
88 GLcontext *ctx = VB->ctx;
89 fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
90 struct vertex_buffer *cvaVB = ctx->CVA.VB;
91
92 if (fxMesa->render_index != 0 ||
93 ((ctx->Texture.ReallyEnabled & 0xf) && cvaVB->TexCoordPtr[0]->size>2) ||
94 ((ctx->Texture.ReallyEnabled & 0xf0) && cvaVB->TexCoordPtr[1]->size>2) ||
95 (VB->ClipPtr->size != 4)) /* Brokes clipping otherwise */
96 gl_render_vb_indirect( VB );
97 else
98 fxDDRenderVBIndirectDirect( VB );
99}
100
101
102static void fxDDRenderVB( struct vertex_buffer *VB )
103{
104 GLcontext *ctx = VB->ctx;
105 fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
106
107 if ((fxMesa->render_index & ~FX_FLAT) ||
108 ((ctx->Texture.ReallyEnabled & 0xf) && VB->TexCoordPtr[0]->size>2) ||
109 ((ctx->Texture.ReallyEnabled & 0xf0) && VB->TexCoordPtr[1]->size>2))
110 gl_render_vb( VB );
111 else
112 fxDDDoRenderVB( VB );
113}
114
115
116
117
118/* This sort of driver-based reconfiguration of the pipeline could be
119 * used to support accelerated transformation and lighting on capable
120 * hardware.
121 *
122 */
123GLuint fxDDRegisterPipelineStages( struct gl_pipeline_stage *out,
124 const struct gl_pipeline_stage *in,
125 GLuint nr )
126{
127 GLuint i, o;
128
129 for (i = o = 0 ; i < nr ; i++) {
130 switch (in[i].ops) {
131 case PIPE_OP_RAST_SETUP_1|PIPE_OP_RENDER:
132 out[o] = in[i];
133 out[o].state_change = NEW_CLIENT_STATE;
134 out[o].check = fxDDCheckMergeAndRender;
135 out[o].run = fxDDMergeAndRender;
136 o++;
137 break;
138 case PIPE_OP_RAST_SETUP_0:
139 out[o] = in[i];
140 out[o].cva_state_change = NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS;
141 out[o].state_change = ~0;
142 out[o].check = fxDDCheckPartialRasterSetup;
143 out[o].run = fxDDPartialRasterSetup;
144 o++;
145 break;
146 case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1:
147 out[o] = in[i];
148 out[o].run = fxDDDoRasterSetup;
149 o++;
150 break;
151 case PIPE_OP_RENDER:
152 out[o] = in[i];
153 if (in[i].run == gl_render_elts) {
154 out[o].run = fxDDRenderElements;
155 } else if (in[i].run == gl_render_vb_indirect) {
156 out[o].check = fxDDCheckRenderVBIndirect;
157 out[o].run = fxDDRenderVBIndirect;
158 } else if (in[i].run == gl_render_vb) {
159 out[o].run = fxDDRenderVB;
160 }
161
162 o++;
163 break;
164 default:
165 out[o++] = in[i];
166 break;
167 }
168 }
169
170 return o;
171}
172
173#define ILLEGAL_ENABLES (TEXTURE0_3D| \
174 TEXTURE1_3D| \
175 ENABLE_TEXMAT0 | \
176 ENABLE_TEXMAT1 | \
177 ENABLE_TEXGEN0 | \
178 ENABLE_TEXGEN1 | \
179 ENABLE_USERCLIP | \
180 ENABLE_LIGHT | \
181 ENABLE_FOG)
182
183
184
185/* Because this is slotted in by the OptimizePipeline function, most
186 * of the information here is just for gl_print_pipeline(). Only the
187 * run member is required.
188 */
189static struct gl_pipeline_stage fx_fast_stage = {
190 "FX combined vertex transform, setup and rasterization stage",
191 PIPE_OP_VERT_XFORM|PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1|PIPE_OP_RENDER,
192 PIPE_PRECALC,
193 0,
194 0,
195 0,
196 0,
197 0,
198 0,
199 0,
200 0,
201 0, /* never called */
202 fxDDFastPath
203};
204
205
206
207
208/* Better than optimizing the pipeline, we can do the whole build very
209 * quickly with the aid of a new flags member.
210 */
211GLboolean fxDDBuildPrecalcPipeline( GLcontext *ctx )
212{
213 struct gl_pipeline *pipe = &ctx->CVA.pre;
214 fxMesaContext fxMesa = FX_CONTEXT(ctx);
215
216
217 if (fxMesa->is_in_hardware &&
218 fxMesa->render_index == 0 &&
219 (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
220 (ctx->Array.Flags & (VERT_OBJ_234|
221 VERT_TEX0_4|
222 VERT_TEX1_4|
223 VERT_ELT)) == (VERT_OBJ_23|VERT_ELT))
224 {
225 if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_DRIVER))
226 if (!fxMesa->using_fast_path)
227 fprintf(stderr, "fxMesa: using fast path\n");
228
229 pipe->stages[0] = &fx_fast_stage;
230 pipe->stages[1] = 0;
231 pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
232 pipe->ops = pipe->stages[0]->ops;
233 fxMesa->using_fast_path = 1;
234 return 1;
235 }
236
237 if (fxMesa->using_fast_path)
238 {
239 if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_DRIVER))
240 fprintf(stderr, "fxMesa: fall back to full pipeline %x %x %x %x %x\n",
241 fxMesa->is_in_hardware,
242 fxMesa->render_index,
243 (ctx->Enabled & ILLEGAL_ENABLES),
244 (ctx->Array.Summary & (VERT_OBJ_23)),
245 (ctx->Array.Summary & (VERT_OBJ_4|VERT_TEX0_4|VERT_TEX1_4)));
246
247 fxMesa->using_fast_path = 0;
248 ctx->CVA.VB->ClipOrMask = 0;
249 ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS;
250 ctx->Array.NewArrayState |= ctx->Array.Summary;
251 return 0;
252 }
253
254 return 0;
255}
256
257
258
259
260
261
262/* Perform global optimizations to the pipeline. The fx driver
263 * implements a single such fast path, which corresponds to the standard
264 * quake3 cva pipeline.
265 *
266 * This is now handled by the 'build' function above.
267 */
268void fxDDOptimizePrecalcPipeline( GLcontext *ctx, struct gl_pipeline *pipe )
269{
270 fxMesaContext fxMesa = FX_CONTEXT(ctx);
271
272 if (fxMesa->is_in_hardware &&
273 fxMesa->render_index == 0 &&
274 (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
275 (ctx->Array.Summary & VERT_ELT))
276 {
277 pipe->stages[0] = &fx_fast_stage;
278 pipe->stages[1] = 0;
279 }
280}
281
282
283
284void fxDDOptimizeEltPipeline( GLcontext *ctx, struct gl_pipeline *pipe )
285{
286 (void) ctx;
287 (void) pipe;
288}
289
290
291#else
292
293/*
294 * Need this to provide at least one external definition.
295 */
296int gl_fxpipeline_dummy(void)
297{
298 return 0;
299}
300
301#endif
Note: See TracBrowser for help on using the repository browser.