summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2003-03-14 15:40:59 +0000
committerBrian Paul <[email protected]>2003-03-14 15:40:59 +0000
commitf386f73f9e4054a750d453fa2f5449c2f1d2e242 (patch)
tree5ced5cfb6cb7f5006cc67618dac6eb83bdf93e4d /src/mesa/swrast
parenta2da1155c285fde2a5e5824d50ee8a57c6e982f5 (diff)
Clean-up of parser error handling/reporting.
Basic fragment program texture instructions are limping along.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_context.c38
-rw-r--r--src/mesa/swrast/s_nvfragprog.c36
-rw-r--r--src/mesa/swrast/s_triangle.c3
3 files changed, 57 insertions, 20 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 2c3ffbedd77..6ed0c42e4d6 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,4 +1,4 @@
-/* $Id: s_context.c,v 1.45 2003/02/23 04:10:54 brianp Exp $ */
+/* $Id: s_context.c,v 1.46 2003/03/14 15:41:00 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -25,12 +25,13 @@
*
* Authors:
* Keith Whitwell <[email protected]>
+ * Brian Paul
*/
-#include "glheader.h"
+#include "imports.h"
#include "context.h"
#include "mtypes.h"
-#include "imports.h"
+#include "texobj.h"
#include "swrast.h"
#include "s_blend.h"
@@ -305,11 +306,40 @@ _swrast_validate_texture_sample( GLcontext *ctx, GLuint texUnit,
}
}
+ if (ctx->FragmentProgram.Enabled) {
+ ASSERT(ctx->FragmentProgram.Current);
+ /* only one target can be referenced per unit per fragment program */
+ switch (ctx->FragmentProgram.Current->TexturesUsed[texUnit]) {
+ case TEXTURE_1D_BIT:
+ tObj = ctx->Texture.Unit[texUnit].Current1D;
+ break;
+ case TEXTURE_2D_BIT:
+ tObj = ctx->Texture.Unit[texUnit].Current2D;
+ break;
+ case TEXTURE_3D_BIT:
+ tObj = ctx->Texture.Unit[texUnit].Current3D;
+ break;
+ case TEXTURE_CUBE_BIT:
+ tObj = ctx->Texture.Unit[texUnit].CurrentCubeMap;
+ break;
+ case TEXTURE_RECT_BIT:
+ tObj = ctx->Texture.Unit[texUnit].CurrentRect;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad texture in _swrast_validate_texture_sample");
+ return;
+ }
+ if (!tObj->Complete) {
+ _mesa_test_texobj_completeness(ctx,
+ (struct gl_texture_object *) tObj );
+ }
+ }
+
swrast->TextureSample[texUnit] =
_swrast_choose_texture_sample_func( ctx, tObj );
swrast->TextureSample[texUnit]( ctx, texUnit, tObj, n, texcoords,
- lambda, rgba );
+ lambda, rgba );
/* GL_SGI_texture_color_table */
if (ctx->Texture.Unit[texUnit].ColorTableEnabled) {
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index 147b5248d4c..c55080c0aac 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -1,4 +1,4 @@
-/* $Id: s_nvfragprog.c,v 1.6 2003/03/04 16:34:03 brianp Exp $ */
+/* $Id: s_nvfragprog.c,v 1.7 2003/03/14 15:41:00 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,7 +33,7 @@
#include "macros.h"
#include "s_nvfragprog.h"
-
+#include "s_texture.h"
/**
@@ -41,27 +41,27 @@
*/
static void
fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLuint unit,
- GLuint targetIndex, GLfloat color[4] )
+ GLuint targetBit, GLfloat color[4] )
{
const GLfloat *lambda = NULL;
GLchan rgba[4];
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const struct gl_texture_object *texObj = NULL;
- switch (targetIndex) {
- case TEXTURE_1D_INDEX:
+ switch (targetBit) {
+ case TEXTURE_1D_BIT:
texObj = ctx->Texture.Unit[unit].Current1D;
break;
- case TEXTURE_2D_INDEX:
+ case TEXTURE_2D_BIT:
texObj = ctx->Texture.Unit[unit].Current2D;
break;
- case TEXTURE_3D_INDEX:
+ case TEXTURE_3D_BIT:
texObj = ctx->Texture.Unit[unit].Current3D;
break;
- case TEXTURE_CUBE_INDEX:
+ case TEXTURE_CUBE_BIT:
texObj = ctx->Texture.Unit[unit].CurrentCubeMap;
break;
- case TEXTURE_RECT_INDEX:
+ case TEXTURE_RECT_BIT:
texObj = ctx->Texture.Unit[unit].CurrentRect;
break;
default:
@@ -69,8 +69,12 @@ fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLuint unit,
}
swrast->TextureSample[unit](ctx, unit, texObj, 1,
- (const GLfloat (*)[4]) &texcoord,
+ (const GLfloat (*)[4]) texcoord,
lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
}
@@ -80,7 +84,7 @@ fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLuint unit,
static void
fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4],
const GLfloat dtdx[4], const GLfloat dtdy[4],
- GLuint unit, GLuint targetIndex, GLfloat color[4] )
+ GLuint unit, GLuint targetBit, GLfloat color[4] )
{
/* XXX to do */
@@ -259,7 +263,9 @@ store_vector4( const struct fp_instruction *inst,
/**
- * Execute the given vertex program
+ * Execute the given vertex program.
+ * NOTE: we do everything in single-precision floating point; we don't
+ * currently observe the single/half/fixed-precision qualifiers.
* \return GL_TRUE if program completed or GL_FALSE if program executed KIL.
*/
static GLboolean
@@ -696,7 +702,7 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
GLfloat texcoord[4], color[4];
fetch_vector4( &inst->SrcReg[0], machine, texcoord );
fetch_texel( ctx, texcoord, inst->TexSrcUnit,
- inst->TexSrcIndex, color );
+ inst->TexSrcBit, color );
store_vector4( inst, machine, color );
}
break;
@@ -708,7 +714,7 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
fetch_vector4( &inst->SrcReg[1], machine, dtdx );
fetch_vector4( &inst->SrcReg[2], machine, dtdy );
fetch_texel_deriv( ctx, texcoord, dtdx, dtdy, inst->TexSrcUnit,
- inst->TexSrcIndex, color );
+ inst->TexSrcBit, color );
store_vector4( inst, machine, color );
}
break;
@@ -721,7 +727,7 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
texcoord[1] /= texcoord[3];
texcoord[2] /= texcoord[3];
fetch_texel( ctx, texcoord, inst->TexSrcUnit,
- inst->TexSrcIndex, color );
+ inst->TexSrcBit, color );
store_vector4( inst, machine, color );
}
break;
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 76a45b96b5e..538102f41ff 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.67 2003/03/01 01:50:26 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.68 2003/03/14 15:41:00 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1066,6 +1066,7 @@ _swrast_choose_triangle( GLcontext *ctx )
/* First see if we can use an optimized 2-D texture function */
if (ctx->Texture._EnabledUnits == 1
+ && !ctx->FragmentProgram.Enabled
&& ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
&& texObj2D->WrapS==GL_REPEAT
&& texObj2D->WrapT==GL_REPEAT