diff options
author | Brian Paul <[email protected]> | 2003-01-14 04:55:45 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2003-01-14 04:55:45 +0000 |
commit | 610d59981a9f43fefe29b34ef19c184d28e2bef5 (patch) | |
tree | 6bac42c2fd25b19ed35260538c6d945de8d699d8 /src/mesa/swrast | |
parent | cf01d97dc3e23af067dd9633a2bfa61a6a794ce6 (diff) |
First batch of code for GL_NV_fragment_program.
Re-org of some GL_NV_vertex_program code.
Replace MAX_TEXTURE_UNITS with MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_aaline.c | 17 | ||||
-rw-r--r-- | src/mesa/swrast/s_aatritemp.h | 15 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.c | 6 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.h | 8 | ||||
-rw-r--r-- | src/mesa/swrast/s_pointtemp.h | 6 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 25 | ||||
-rw-r--r-- | src/mesa/swrast/s_tritemp.h | 26 | ||||
-rw-r--r-- | src/mesa/swrast/swrast.h | 16 |
8 files changed, 70 insertions, 49 deletions
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c index 663d43ec87d..c5994d668f3 100644 --- a/src/mesa/swrast/s_aaline.c +++ b/src/mesa/swrast/s_aaline.c @@ -1,8 +1,8 @@ -/* $Id: s_aaline.c,v 1.16 2002/08/07 00:45:07 brianp Exp $ */ +/* $Id: s_aaline.c,v 1.17 2003/01/14 04:55:46 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 5.1 * * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * @@ -69,12 +69,13 @@ struct LineInfo /* DO_SPEC */ GLfloat srPlane[4], sgPlane[4], sbPlane[4]; /* DO_TEX or DO_MULTITEX */ - GLfloat sPlane[MAX_TEXTURE_UNITS][4]; - GLfloat tPlane[MAX_TEXTURE_UNITS][4]; - GLfloat uPlane[MAX_TEXTURE_UNITS][4]; - GLfloat vPlane[MAX_TEXTURE_UNITS][4]; - GLfloat lambda[MAX_TEXTURE_UNITS]; - GLfloat texWidth[MAX_TEXTURE_UNITS], texHeight[MAX_TEXTURE_UNITS]; + GLfloat sPlane[MAX_TEXTURE_COORD_UNITS][4]; + GLfloat tPlane[MAX_TEXTURE_COORD_UNITS][4]; + GLfloat uPlane[MAX_TEXTURE_COORD_UNITS][4]; + GLfloat vPlane[MAX_TEXTURE_COORD_UNITS][4]; + GLfloat lambda[MAX_TEXTURE_COORD_UNITS]; + GLfloat texWidth[MAX_TEXTURE_COORD_UNITS]; + GLfloat texHeight[MAX_TEXTURE_COORD_UNITS]; struct sw_span span; }; diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 0a70cf184f2..7a20ba60e5e 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -1,8 +1,8 @@ -/* $Id: s_aatritemp.h,v 1.30 2002/08/07 00:45:07 brianp Exp $ */ +/* $Id: s_aatritemp.h,v 1.31 2003/01/14 04:55:46 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 5.1 * * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * @@ -76,11 +76,12 @@ GLfloat sPlane[4], tPlane[4], uPlane[4], vPlane[4]; GLfloat texWidth, texHeight; #elif defined(DO_MULTITEX) - GLfloat sPlane[MAX_TEXTURE_UNITS][4]; /* texture S */ - GLfloat tPlane[MAX_TEXTURE_UNITS][4]; /* texture T */ - GLfloat uPlane[MAX_TEXTURE_UNITS][4]; /* texture R */ - GLfloat vPlane[MAX_TEXTURE_UNITS][4]; /* texture Q */ - GLfloat texWidth[MAX_TEXTURE_UNITS], texHeight[MAX_TEXTURE_UNITS]; + GLfloat sPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture S */ + GLfloat tPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture T */ + GLfloat uPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture R */ + GLfloat vPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture Q */ + GLfloat texWidth[MAX_TEXTURE_COORD_UNITS]; + GLfloat texHeight[MAX_TEXTURE_COORD_UNITS]; #endif GLfloat bf = SWRAST_CONTEXT(ctx)->_backface_sign; diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index aa9620a0559..c4bc9de9f16 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -1,8 +1,8 @@ -/* $Id: s_context.c,v 1.42 2002/10/29 20:28:59 brianp Exp $ */ +/* $Id: s_context.c,v 1.43 2003/01/14 04:55:46 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 5.1 * * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * @@ -516,7 +516,7 @@ _swrast_CreateContext( GLcontext *ctx ) swrast->_IntegerAccumMode = GL_TRUE; swrast->_IntegerAccumScaler = 0.0; - for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) + for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) swrast->TextureSample[i] = _swrast_validate_texture_sample; swrast->SpanArrays = MALLOC_STRUCT(span_arrays); diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index e1c22977dd8..3fd7f3c3a94 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -1,8 +1,8 @@ -/* $Id: s_context.h,v 1.22 2002/10/29 20:29:00 brianp Exp $ */ +/* $Id: s_context.h,v 1.23 2003/01/14 04:55:46 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 5.1 * * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * @@ -121,7 +121,7 @@ typedef struct * _swrast_validate_derived(): */ GLuint _RasterMask; - GLfloat _MinMagThresh[MAX_TEXTURE_UNITS]; + GLfloat _MinMagThresh[MAX_TEXTURE_IMAGE_UNITS]; GLfloat _backface_sign; GLboolean _PreferPixelFog; GLboolean _AnyTextureCombine; @@ -188,7 +188,7 @@ typedef struct /** Internal hooks, kept uptodate by the same mechanism as above. */ blend_func BlendFunc; - TextureSampleFunc TextureSample[MAX_TEXTURE_UNITS]; + TextureSampleFunc TextureSample[MAX_TEXTURE_IMAGE_UNITS]; /** Buffer for saving the sampled texture colors. * Needed for GL_ARB_texture_env_crossbar implementation. diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h index f7bd1240b15..d4c86ab00e7 100644 --- a/src/mesa/swrast/s_pointtemp.h +++ b/src/mesa/swrast/s_pointtemp.h @@ -1,8 +1,8 @@ -/* $Id: s_pointtemp.h,v 1.21 2002/11/09 21:26:41 brianp Exp $ */ +/* $Id: s_pointtemp.h,v 1.22 2003/01/14 04:55:46 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 5.0 + * Version: 5.1 * * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * @@ -82,7 +82,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) const GLuint colorIndex = vert->index; #endif #if FLAGS & TEXTURE - GLfloat texcoord[MAX_TEXTURE_UNITS][4]; + GLfloat texcoord[MAX_TEXTURE_COORD_UNITS][4]; GLuint u; #endif SWcontext *swrast = SWRAST_CONTEXT(ctx); diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index a03eec8b2aa..4e00c645faf 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1,4 +1,4 @@ -/* $Id: s_span.c,v 1.53 2002/11/26 03:00:04 brianp Exp $ */ +/* $Id: s_span.c,v 1.54 2003/01/14 04:55:46 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -47,6 +47,7 @@ #include "s_fog.h" #include "s_logic.h" #include "s_masking.h" +#include "s_nvfragprog.h" #include "s_span.h" #include "s_stencil.h" #include "s_texture.h" @@ -949,6 +950,18 @@ _mesa_write_rgba_span( GLcontext *ctx, struct sw_span *span) stipple_polygon_span(ctx, span); } + /* Fragment program */ + if (ctx->FragmentProgram.Enabled) { + /* Now we may need to interpolate the colors */ + if ((span->interpMask & SPAN_RGBA) && + (span->arrayMask & SPAN_RGBA) == 0) { + interpolate_colors(ctx, span); + span->interpMask &= ~SPAN_RGBA; + } + _swrast_exec_nv_fragment_program(ctx, span); + monoColor = GL_FALSE; + } + /* Do the alpha test */ if (ctx->Color.AlphaEnabled) { if (!_mesa_alpha_test(ctx, span)) { @@ -1183,7 +1196,10 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span) /* Texturing without alpha is done after depth-testing which * gives a potential speed-up. */ - _swrast_texture_span( ctx, span ); + if (ctx->FragmentProgram.Enabled) + _swrast_exec_nv_fragment_program( ctx, span ); + else + _swrast_texture_span( ctx, span ); /* Do the alpha test */ if (!_mesa_alpha_test(ctx, span)) { @@ -1232,7 +1248,10 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span) if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0) interpolate_colors(ctx, span); - _swrast_texture_span( ctx, span ); + if (ctx->FragmentProgram.Enabled) + _swrast_exec_nv_fragment_program( ctx, span ); + else + _swrast_texture_span( ctx, span ); } ASSERT(span->arrayMask & SPAN_RGBA); diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 38762112f0d..0dc4f891820 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -1,4 +1,4 @@ -/* $Id: s_tritemp.h,v 1.41 2002/11/13 16:51:02 brianp Exp $ */ +/* $Id: s_tritemp.h,v 1.42 2003/01/14 04:55:46 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -325,10 +325,10 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, GLfloat dvdx, dvdy; #endif #ifdef INTERP_MULTITEX - GLfloat dsdx[MAX_TEXTURE_UNITS], dsdy[MAX_TEXTURE_UNITS]; - GLfloat dtdx[MAX_TEXTURE_UNITS], dtdy[MAX_TEXTURE_UNITS]; - GLfloat dudx[MAX_TEXTURE_UNITS], dudy[MAX_TEXTURE_UNITS]; - GLfloat dvdx[MAX_TEXTURE_UNITS], dvdy[MAX_TEXTURE_UNITS]; + GLfloat dsdx[MAX_TEXTURE_COORD_UNITS], dsdy[MAX_TEXTURE_COORD_UNITS]; + GLfloat dtdx[MAX_TEXTURE_COORD_UNITS], dtdy[MAX_TEXTURE_COORD_UNITS]; + GLfloat dudx[MAX_TEXTURE_COORD_UNITS], dudy[MAX_TEXTURE_COORD_UNITS]; + GLfloat dvdx[MAX_TEXTURE_COORD_UNITS], dvdy[MAX_TEXTURE_COORD_UNITS]; #endif /* @@ -766,14 +766,14 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, GLfloat vLeft=0, dvOuter=0, dvInner; #endif #ifdef INTERP_MULTITEX - GLfloat sLeft[MAX_TEXTURE_UNITS]; - GLfloat tLeft[MAX_TEXTURE_UNITS]; - GLfloat uLeft[MAX_TEXTURE_UNITS]; - GLfloat vLeft[MAX_TEXTURE_UNITS]; - GLfloat dsOuter[MAX_TEXTURE_UNITS], dsInner[MAX_TEXTURE_UNITS]; - GLfloat dtOuter[MAX_TEXTURE_UNITS], dtInner[MAX_TEXTURE_UNITS]; - GLfloat duOuter[MAX_TEXTURE_UNITS], duInner[MAX_TEXTURE_UNITS]; - GLfloat dvOuter[MAX_TEXTURE_UNITS], dvInner[MAX_TEXTURE_UNITS]; + GLfloat sLeft[MAX_TEXTURE_COORD_UNITS]; + GLfloat tLeft[MAX_TEXTURE_COORD_UNITS]; + GLfloat uLeft[MAX_TEXTURE_COORD_UNITS]; + GLfloat vLeft[MAX_TEXTURE_COORD_UNITS]; + GLfloat dsOuter[MAX_TEXTURE_COORD_UNITS], dsInner[MAX_TEXTURE_COORD_UNITS]; + GLfloat dtOuter[MAX_TEXTURE_COORD_UNITS], dtInner[MAX_TEXTURE_COORD_UNITS]; + GLfloat duOuter[MAX_TEXTURE_COORD_UNITS], duInner[MAX_TEXTURE_COORD_UNITS]; + GLfloat dvOuter[MAX_TEXTURE_COORD_UNITS], dvInner[MAX_TEXTURE_COORD_UNITS]; #endif for (subTriangle=0; subTriangle<=1; subTriangle++) { diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index 55c1593246a..6113b860614 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -1,4 +1,4 @@ -/* $Id: swrast.h,v 1.33 2002/11/13 16:47:18 brianp Exp $ */ +/* $Id: swrast.h,v 1.34 2003/01/14 04:55:47 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -66,7 +66,7 @@ typedef struct { /** win[0], win[1] are the screen-coords of SWvertex. win[2] is the * z-coord. what is win[3]? */ GLfloat win[4]; - GLfloat texcoord[MAX_TEXTURE_UNITS][4]; + GLfloat texcoord[MAX_TEXTURE_COORD_UNITS][4]; GLchan color[4]; GLchan specular[4]; GLfloat fog; @@ -138,8 +138,8 @@ struct span_arrays { GLint y[MAX_WIDTH]; /**< X/Y used for point/line rendering only */ GLdepth z[MAX_WIDTH]; GLfloat fog[MAX_WIDTH]; - GLfloat texcoords[MAX_TEXTURE_UNITS][MAX_WIDTH][4]; - GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH]; + GLfloat texcoords[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH][4]; + GLfloat lambda[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH]; GLfloat coverage[MAX_WIDTH]; /** This mask indicates if fragment is alive or culled */ @@ -189,10 +189,10 @@ struct sw_span { GLfixed index, indexStep; GLfixed z, zStep; GLfloat fog, fogStep; - GLfloat tex[MAX_TEXTURE_UNITS][4]; - GLfloat texStepX[MAX_TEXTURE_UNITS][4]; - GLfloat texStepY[MAX_TEXTURE_UNITS][4]; - GLfixed intTex[2], intTexStep[2]; + GLfloat tex[MAX_TEXTURE_COORD_UNITS][4]; /* s, t, r, q */ + GLfloat texStepX[MAX_TEXTURE_COORD_UNITS][4]; + GLfloat texStepY[MAX_TEXTURE_COORD_UNITS][4]; + GLfixed intTex[2], intTexStep[2]; /* s, t only */ /** * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates |