summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-02-23 04:10:54 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-02-23 04:10:54 +0000
commitb8d6607acd3b6d18dab0c7247d5e0fc72e98ceae (patch)
treea146f6d4b57ace61c62b1464fbd059bf8f387870 /src/mesa/swrast
parent4e44d8c4c68c8a4e68b42f1fb2689d348369da86 (diff)
Move span stuff from swrast.h to s_context.h (it's private).
Implemented remaining fragment program instructions. Initial changes to implement fragment program texture sampling.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_alpha.h4
-rw-r--r--src/mesa/swrast/s_blend.h4
-rw-r--r--src/mesa/swrast/s_context.c21
-rw-r--r--src/mesa/swrast/s_context.h169
-rw-r--r--src/mesa/swrast/s_depth.h4
-rw-r--r--src/mesa/swrast/s_nvfragprog.c514
-rw-r--r--src/mesa/swrast/s_nvfragprog.h4
-rw-r--r--src/mesa/swrast/s_texture.c278
-rw-r--r--src/mesa/swrast/s_texture.h5
-rw-r--r--src/mesa/swrast/swrast.h154
10 files changed, 798 insertions, 359 deletions
diff --git a/src/mesa/swrast/s_alpha.h b/src/mesa/swrast/s_alpha.h
index 784307b5b2..413babb3e9 100644
--- a/src/mesa/swrast/s_alpha.h
+++ b/src/mesa/swrast/s_alpha.h
@@ -1,4 +1,4 @@
-/* $Id: s_alpha.h,v 1.6 2002/02/02 21:40:33 brianp Exp $ */
+/* $Id: s_alpha.h,v 1.7 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,7 +30,7 @@
#include "mtypes.h"
-#include "swrast.h"
+#include "s_context.h"
extern GLint
diff --git a/src/mesa/swrast/s_blend.h b/src/mesa/swrast/s_blend.h
index 090547d18b..8d3124f28c 100644
--- a/src/mesa/swrast/s_blend.h
+++ b/src/mesa/swrast/s_blend.h
@@ -1,4 +1,4 @@
-/* $Id: s_blend.h,v 1.6 2002/02/02 21:40:33 brianp Exp $ */
+/* $Id: s_blend.h,v 1.7 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,7 +30,7 @@
#include "mtypes.h"
-#include "swrast.h"
+#include "s_context.h"
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 89427578e6..2c3ffbedd7 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.44 2003/01/26 14:37:16 brianp Exp $ */
+/* $Id: s_context.c,v 1.45 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -267,6 +267,7 @@ _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
swrast->Point( ctx, v0 );
}
+
static void
_swrast_validate_blend_func( GLcontext *ctx, GLuint n,
const GLubyte mask[],
@@ -285,13 +286,27 @@ _swrast_validate_blend_func( GLcontext *ctx, GLuint n,
static void
_swrast_validate_texture_sample( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoords[][4],
+ GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
_swrast_validate_derived( ctx );
- _swrast_choose_texture_sample_func( ctx, texUnit, tObj );
+
+ /* Compute min/mag filter threshold */
+ if (tObj->MinFilter != tObj->MagFilter) {
+ if (tObj->MagFilter == GL_LINEAR
+ && (tObj->MinFilter == GL_NEAREST_MIPMAP_NEAREST ||
+ tObj->MinFilter == GL_NEAREST_MIPMAP_LINEAR)) {
+ swrast->_MinMagThresh[texUnit] = 0.5F;
+ }
+ else {
+ swrast->_MinMagThresh[texUnit] = 0.0F;
+ }
+ }
+
+ swrast->TextureSample[texUnit] =
+ _swrast_choose_texture_sample_func( ctx, tObj );
swrast->TextureSample[texUnit]( ctx, texUnit, tObj, n, texcoords,
lambda, rgba );
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 3fd7f3c3a9..2be1545c8f 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -1,10 +1,10 @@
-/* $Id: s_context.h,v 1.23 2003/01/14 04:55:46 brianp Exp $ */
+/* $Id: s_context.h,v 1.24 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -22,14 +22,12 @@
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
*/
+
/**
* \file swrast/s_context.h
- * \brief fill in description
+ * \brief Software rasterization context and private types.
* \author Keith Whitwell <keith@tungstengraphics.com>
*/
@@ -39,19 +37,160 @@
#include "mtypes.h"
#include "swrast.h"
-/*
- * For texture sampling:
+
+/**
+ * \struct sw_span
+ * \brief Contains data for either a horizontal line or a set of
+ * pixels that are passed through a pipeline of functions before being
+ * drawn.
+ *
+ * The sw_span structure describes the colors, Z, fogcoord, texcoords,
+ * etc for either a horizontal run or a set of independent pixels. We
+ * can either specify a base/step to indicate interpolated values, or
+ * fill in arrays of values. The interpMask and arrayMask bitfields
+ * indicate which are active.
+ *
+ * With this structure it's easy to hand-off span rasterization to
+ * subroutines instead of doing it all inline in the triangle functions
+ * like we used to do.
+ * It also cleans up the local variable namespace a great deal.
+ *
+ * It would be interesting to experiment with multiprocessor rasterization
+ * with this structure. The triangle rasterizer could simply emit a
+ * stream of these structures which would be consumed by one or more
+ * span-processing threads which could run in parallel.
*/
-typedef void (*TextureSampleFunc)( GLcontext *ctx, GLuint texUnit,
- const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoords[][4],
- const GLfloat lambda[], GLchan rgba[][4] );
+/**
+ * \defgroup SpanFlags SPAN_XXX-flags
+ * Bitmasks to indicate which span_arrays need to be computed
+ * (sw_span::interpMask) or have already been filled
+ * (sw_span::arrayMask)
+ */
+/*@{*/
+#define SPAN_RGBA 0x001
+#define SPAN_SPEC 0x002
+#define SPAN_INDEX 0x004
+#define SPAN_Z 0x008
+#define SPAN_FOG 0x010
+#define SPAN_TEXTURE 0x020
+#define SPAN_INT_TEXTURE 0x040
+#define SPAN_LAMBDA 0x080
+#define SPAN_COVERAGE 0x100
+#define SPAN_FLAT 0x200 /**< flat shading? */
+/** sw_span::arrayMask only - for span_arrays::x, span_arrays::y */
+#define SPAN_XY 0x400
+#define SPAN_MASK 0x800 /**< sw_span::arrayMask only */
+/*@}*/
+
-/*
- * Blending function
+/**
+ * \struct span_arrays
+ * \brief Arrays of fragment values.
+ *
+ * These will either be computed from the x/xStep values above or
+ * filled in by glDraw/CopyPixels, etc.
+ * These arrays are separated out of sw_span to conserve memory.
*/
+struct span_arrays {
+ GLchan rgb[MAX_WIDTH][3];
+ GLchan rgba[MAX_WIDTH][4];
+ GLuint index[MAX_WIDTH];
+ GLchan spec[MAX_WIDTH][4]; /* specular color */
+ GLint x[MAX_WIDTH]; /**< X/Y used for point/line rendering only */
+ GLint y[MAX_WIDTH]; /**< X/Y used for point/line rendering only */
+ GLdepth z[MAX_WIDTH];
+ GLfloat fog[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 */
+ GLubyte mask[MAX_WIDTH];
+};
+
+
+struct sw_span {
+ GLint x, y;
+
+ /** Only need to process pixels between start <= i < end */
+ /** At this time, start is always zero. */
+ GLuint start, end;
+
+ /** This flag indicates that mask[] array is effectively filled with ones */
+ GLboolean writeAll;
+
+ /** either GL_POLYGON, GL_LINE, GL_POLYGON, GL_BITMAP */
+ GLenum primitive;
+
+ /** 0 = front-facing span, 1 = back-facing span (for two-sided stencil) */
+ GLuint facing;
+
+ /**
+ * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates
+ * which of the x/xStep variables are relevant.
+ */
+ GLuint interpMask;
+
+#if CHAN_TYPE == GL_FLOAT
+ GLfloat red, redStep;
+ GLfloat green, greenStep;
+ GLfloat blue, blueStep;
+ GLfloat alpha, alphaStep;
+ GLfloat specRed, specRedStep;
+ GLfloat specGreen, specGreenStep;
+ GLfloat specBlue, specBlueStep;
+#else /* CHAN_TYPE == GL_UNSIGNED_BYTE or GL_UNSIGNED SHORT */
+ GLfixed red, redStep;
+ GLfixed green, greenStep;
+ GLfixed blue, blueStep;
+ GLfixed alpha, alphaStep;
+ GLfixed specRed, specRedStep;
+ GLfixed specGreen, specGreenStep;
+ GLfixed specBlue, specBlueStep;
+#endif
+ GLfixed index, indexStep;
+ GLfixed z, zStep;
+ GLfloat fog, fogStep;
+ 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
+ * which of the fragment arrays in the span_arrays struct are relevant.
+ */
+ GLuint arrayMask;
+
+ /**
+ * We store the arrays of fragment values in a separate struct so
+ * that we can allocate sw_span structs on the stack without using
+ * a lot of memory. The span_arrays struct is about 400KB while the
+ * sw_span struct is only about 512 bytes.
+ */
+ struct span_arrays *array;
+};
+
+
+#define INIT_SPAN(S, PRIMITIVE, END, INTERP_MASK, ARRAY_MASK) \
+do { \
+ (S).primitive = (PRIMITIVE); \
+ (S).interpMask = (INTERP_MASK); \
+ (S).arrayMask = (ARRAY_MASK); \
+ (S).start = 0; \
+ (S).end = (END); \
+ (S).facing = 0; \
+ (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \
+} while (0)
+
+
+typedef void (*texture_sample_func)(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4]);
+
#ifdef USE_MMX_ASM
typedef void (_ASMAPIP blend_func)( GLcontext *ctx, GLuint n,
const GLubyte mask[],
@@ -188,7 +327,7 @@ typedef struct
/** Internal hooks, kept uptodate by the same mechanism as above.
*/
blend_func BlendFunc;
- TextureSampleFunc TextureSample[MAX_TEXTURE_IMAGE_UNITS];
+ texture_sample_func 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_depth.h b/src/mesa/swrast/s_depth.h
index 2b7e9ddeb4..674ee5e7b5 100644
--- a/src/mesa/swrast/s_depth.h
+++ b/src/mesa/swrast/s_depth.h
@@ -1,4 +1,4 @@
-/* $Id: s_depth.h,v 1.6 2002/03/16 00:53:15 brianp Exp $ */
+/* $Id: s_depth.h,v 1.7 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,7 +30,7 @@
#include "mtypes.h"
-#include "swrast.h"
+#include "s_context.h"
extern GLvoid *
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index 6ff4569a8e..16bfe7d1c4 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -1,10 +1,10 @@
-/* $Id: s_nvfragprog.c,v 1.2 2003/02/17 15:38:04 brianp Exp $ */
+/* $Id: s_nvfragprog.c,v 1.3 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -36,56 +36,42 @@
#include "s_nvfragprog.h"
+
/**
* Fetch a texel.
*/
static void
fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLuint unit,
- GLenum target, GLfloat color[4] )
+ GLuint targetIndex, GLfloat color[4] )
{
+ const GLfloat *lambda = NULL;
+ GLchan rgba[4];
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
const struct gl_texture_object *texObj;
- /* XXX Use swrast->TextureSample[texUnit]() to sample texture.
- * Needs to be swrast->TextureSample[target][texUnit]() though.
- */
-
- switch (target) {
- case GL_TEXTURE_1D:
+ switch (targetIndex) {
+ case TEXTURE_1D_INDEX:
texObj = ctx->Texture.Unit[unit].Current1D;
break;
- case GL_TEXTURE_2D:
+ case TEXTURE_2D_INDEX:
texObj = ctx->Texture.Unit[unit].Current2D;
break;
- case GL_TEXTURE_3D:
+ case TEXTURE_3D_INDEX:
texObj = ctx->Texture.Unit[unit].Current3D;
break;
- case GL_TEXTURE_CUBE_MAP:
+ case TEXTURE_CUBE_INDEX:
texObj = ctx->Texture.Unit[unit].CurrentCubeMap;
break;
- case GL_TEXTURE_RECTANGLE_NV:
+ case TEXTURE_RECT_INDEX:
texObj = ctx->Texture.Unit[unit].CurrentRect;
break;
default:
_mesa_problem(ctx, "Invalid target in fetch_texel");
}
- if (texObj->Complete) {
- const struct gl_texture_image *texImage;
- GLint col, row, img;
- GLchan texel[4];
- col = IROUND(texcoord[0] * texImage->Width); /* XXX temporary! */
- row = IROUND(texcoord[1] * texImage->Height); /* XXX temporary! */
- img = 0;
- texImage->FetchTexel(texImage, col, row, img, texel);
- /* XXX texture format? */
- color[0] = CHAN_TO_FLOAT(texel[0]);
- color[1] = CHAN_TO_FLOAT(texel[1]);
- color[2] = CHAN_TO_FLOAT(texel[2]);
- color[3] = CHAN_TO_FLOAT(texel[3]);
- }
- else {
- ASSIGN_4V(color, 0.0, 0.0, 0.0, 0.0);
- }
+ swrast->TextureSample[unit](ctx, unit, texObj, 1,
+ (const GLfloat (*)[4]) &texcoord,
+ lambda, &rgba);
}
@@ -95,7 +81,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, GLenum target, GLfloat color[4] )
+ GLuint unit, GLuint targetIndex, GLfloat color[4] )
{
/* XXX to do */
@@ -314,6 +300,30 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
inst->UpdateCondRegister );
}
break;
+ case FP_OPCODE_DDX: /* Partial derivative with respect to X */
+ {
+ GLfloat a[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ result[0] = 0; /* XXX fix */
+ result[1] = 0;
+ result[2] = 0;
+ result[3] = 0;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_DDY: /* Partial derivative with respect to Y */
+ {
+ GLfloat a[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ result[0] = 0; /* XXX fix */
+ result[1] = 0;
+ result[2] = 0;
+ result[3] = 0;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
case FP_OPCODE_DP3:
{
GLfloat a[4], b[4], result[4];
@@ -336,6 +346,53 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
inst->UpdateCondRegister );
}
break;
+ case FP_OPCODE_DST: /* Distance vector */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = 1.0F;
+ result[1] = a[1] * b[1];
+ result[2] = a[2];
+ result[3] = b[3];
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_EX2: /* Exponential base 2 */
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ result[0] = result[1] = result[2] = result[3] =
+ (GLfloat) pow(2.0, a[0]);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_FLR:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ result[0] = FLOORF(a[0]);
+ result[1] = FLOORF(a[1]);
+ result[2] = FLOORF(a[2]);
+ result[3] = FLOORF(a[3]);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_FRC:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ result[0] = a[0] - FLOORF(a[0]);
+ result[1] = a[1] - FLOORF(a[1]);
+ result[2] = a[2] - FLOORF(a[2]);
+ result[3] = a[3] - FLOORF(a[3]);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
case FP_OPCODE_KIL:
{
const GLuint *swizzle = inst->DstReg.CondSwizzle;
@@ -347,6 +404,32 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
return;
}
break;
+ case FP_OPCODE_LG2: /* log base 2 */
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ result[0] = result[1] = result[2] = result[3]
+ = LOG2(a[0]);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_LIT:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ if (a[0] < 0.0F)
+ a[0] = 0.0F;
+ if (a[1] < 0.0F)
+ a[1] = 0.0F;
+ result[0] = 1.0F;
+ result[1] = a[0];
+ result[2] = (a[0] > 0.0) ? pow(2.0, a[3]) : 0.0F;
+ result[3] = 1.0F;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
case FP_OPCODE_LRP:
{
GLfloat a[4], b[4], c[4], result[4];
@@ -361,6 +444,46 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
inst->UpdateCondRegister );
}
break;
+ case FP_OPCODE_MAD:
+ {
+ GLfloat a[4], b[4], c[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ fetch_vector4( &inst->SrcReg[2], machine, c );
+ result[0] = a[0] * b[0] + c[0];
+ result[1] = a[1] * b[1] + c[1];
+ result[2] = a[2] * b[2] + c[2];
+ result[3] = a[3] * b[3] + c[3];
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_MAX:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = MAX2(a[0], b[0]);
+ result[1] = MAX2(a[1], b[1]);
+ result[2] = MAX2(a[2], b[2]);
+ result[3] = MAX2(a[3], b[3]);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_MIN:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = MIN2(a[0], b[0]);
+ result[1] = MIN2(a[1], b[1]);
+ result[2] = MIN2(a[2], b[2]);
+ result[3] = MIN2(a[3], b[3]);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
case FP_OPCODE_MOV:
{
GLfloat t[4];
@@ -369,7 +492,136 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
inst->UpdateCondRegister );
}
break;
- case FP_OPCODE_SEQ:
+ case FP_OPCODE_MUL:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = a[0] * b[0];
+ result[1] = a[1] * b[1];
+ result[2] = a[2] * b[2];
+ result[3] = a[3] * b[3];
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_PK2H: /* pack two 16-bit floats */
+ /* XXX this is probably wrong */
+ {
+ GLfloat a[4], result[4];
+ const GLuint *rawBits = (const GLuint *) a;
+ GLuint *rawResult = (GLuint *) result;
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ rawResult[0] = rawResult[1] = rawResult[2] = rawResult[3]
+ = rawBits[0] | (rawBits[1] << 16);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_PK2US: /* pack two GLushorts */
+ {
+ GLfloat a[4], result[4];
+ GLuint usx, usy, *rawResult = (GLuint *) result;
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ a[0] = CLAMP(a[0], 0.0F, 1.0F);
+ a[1] = CLAMP(a[0], 0.0F, 1.0F);
+ usx = IROUND(a[0] * 65535.0F);
+ usy = IROUND(a[1] * 65535.0F);
+ rawResult[0] = rawResult[1] = rawResult[2] = rawResult[3]
+ = usx | (usy << 16);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_PK4B: /* pack four GLbytes */
+ {
+ GLfloat a[4], result[4];
+ GLuint ubx, uby, ubz, ubw, *rawResult = (GLuint *) result;
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ a[0] = CLAMP(a[0], -128.0F / 127.0F, 1.0F);
+ a[1] = CLAMP(a[1], -128.0F / 127.0F, 1.0F);
+ a[2] = CLAMP(a[2], -128.0F / 127.0F, 1.0F);
+ a[3] = CLAMP(a[3], -128.0F / 127.0F, 1.0F);
+ ubx = IROUND(127.0F * a[0] + 128.0F);
+ uby = IROUND(127.0F * a[1] + 128.0F);
+ ubz = IROUND(127.0F * a[2] + 128.0F);
+ ubw = IROUND(127.0F * a[3] + 128.0F);
+ rawResult[0] = rawResult[1] = rawResult[2] = rawResult[3]
+ = ubx | (uby << 8) | (ubz << 16) | (ubw << 24);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_PK4UB: /* pack four GLubytes */
+ {
+ GLfloat a[4], result[4];
+ GLuint ubx, uby, ubz, ubw, *rawResult = (GLuint *) result;
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ a[0] = CLAMP(a[0], 0.0F, 1.0F);
+ a[1] = CLAMP(a[1], 0.0F, 1.0F);
+ a[2] = CLAMP(a[2], 0.0F, 1.0F);
+ a[3] = CLAMP(a[3], 0.0F, 1.0F);
+ ubx = IROUND(255.0F * a[0]);
+ uby = IROUND(255.0F * a[1]);
+ ubz = IROUND(255.0F * a[2]);
+ ubw = IROUND(255.0F * a[3]);
+ rawResult[0] = rawResult[1] = rawResult[2] = rawResult[3]
+ = ubx | (uby << 8) | (ubz << 16) | (ubw << 24);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_POW:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ fetch_vector1( &inst->SrcReg[1], machine, b );
+ result[0] = result[1] = result[2] = result[3]
+ = pow(a[0], b[0]);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_RCP:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ result[0] = result[1] = result[2] = result[3]
+ = 1.0F / a[0];
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_RFL:
+ {
+ GLfloat axis[4], dir[4], result[4], tmp[4];
+ fetch_vector4( &inst->SrcReg[0], machine, axis );
+ fetch_vector4( &inst->SrcReg[1], machine, dir );
+ tmp[3] = axis[0] * axis[0]
+ + axis[1] * axis[1]
+ + axis[2] * axis[2];
+ tmp[0] = (2.0F * (axis[0] * dir[0] +
+ axis[1] * dir[1] +
+ axis[2] * dir[2])) / tmp[3];
+ result[0] = tmp[0] * axis[0] - dir[0];
+ result[1] = tmp[0] * axis[1] - dir[1];
+ result[2] = tmp[0] * axis[2] - dir[2];
+ /* result[3] is never written! XXX enforce in parser! */
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_RSQ: /* 1 / sqrt() */
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ result[0] = result[1] = result[2] = result[3]
+ = 1.0F / GL_SQRT(a[0]);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_SEQ: /* set on equal */
{
GLfloat a[4], b[4], result[4];
fetch_vector4( &inst->SrcReg[0], machine, a );
@@ -382,13 +634,114 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
inst->UpdateCondRegister );
}
break;
+ case FP_OPCODE_SFL: /* set false, operands ignored */
+ {
+ static const GLfloat result[4] = { 0.0F, 0.0F, 0.0F, 0.0F };
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_SGE: /* set on greater or equal */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = (a[0] >= b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] >= b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] >= b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] >= b[3]) ? 1.0F : 0.0F;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_SGT: /* set on greater */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = (a[0] > b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] > b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] > b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] > b[3]) ? 1.0F : 0.0F;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_SIN:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ result[0] = result[1] = result[2] = result[3] = sin(a[0]);
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_SLE: /* set on less or equal */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = (a[0] <= b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] <= b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] <= b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] <= b[3]) ? 1.0F : 0.0F;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_SLT: /* set on less */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = (a[0] < b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] < b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] < b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] < b[3]) ? 1.0F : 0.0F;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_SNE: /* set on not equal */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = (a[0] != b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] != b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] != b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] != b[3]) ? 1.0F : 0.0F;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_STR: /* set true, operands ignored */
+ {
+ static const GLfloat result[4] = { 1.0F, 1.0F, 1.0F, 1.0F };
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_SUB:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ result[0] = a[0] - b[0];
+ result[1] = a[1] - b[1];
+ result[2] = a[2] - b[2];
+ result[3] = a[3] - b[3];
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
case FP_OPCODE_TEX:
/* Texel lookup */
{
GLfloat texcoord[4], color[4];
fetch_vector4( &inst->SrcReg[0], machine, texcoord );
fetch_texel( ctx, texcoord, inst->TexSrcUnit,
- inst->TexSrcTarget, color );
+ inst->TexSrcIndex, color );
store_vector4( &inst->DstReg, machine, color, inst->Saturate,
inst->UpdateCondRegister );
}
@@ -401,7 +754,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->TexSrcTarget, color );
+ inst->TexSrcIndex, color );
store_vector4( &inst->DstReg, machine, color, inst->Saturate,
inst->UpdateCondRegister );
}
@@ -415,17 +768,84 @@ execute_program(GLcontext *ctx, const struct fragment_program *program)
texcoord[1] /= texcoord[3];
texcoord[2] /= texcoord[3];
fetch_texel( ctx, texcoord, inst->TexSrcUnit,
- inst->TexSrcTarget, color );
+ inst->TexSrcIndex, color );
store_vector4( &inst->DstReg, machine, color, inst->Saturate,
inst->UpdateCondRegister );
}
break;
+ case FP_OPCODE_UP2H: /* unpack two 16-bit floats */
+ /* XXX this is probably wrong */
+ {
+ GLfloat a[4], result[4];
+ const GLuint *rawBits = (const GLuint *) a;
+ GLuint *rawResult = (GLuint *) result;
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ rawResult[0] = rawBits[0] & 0xffff;
+ rawResult[1] = (rawBits[0] >> 16) & 0xffff;
+ rawResult[2] = rawBits[0] & 0xffff;
+ rawResult[3] = (rawBits[0] >> 16) & 0xffff;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_UP2US: /* unpack two GLushorts */
+ {
+ GLfloat a[4], result[4];
+ const GLuint *rawBits = (const GLuint *) a;
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ result[0] = (GLfloat) ((rawBits[0] >> 0) & 0xffff) / 65535.0F;
+ result[1] = (GLfloat) ((rawBits[0] >> 16) & 0xffff) / 65535.0F;
+ result[2] = result[0];
+ result[3] = result[1];
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_UP4B: /* unpack four GLbytes */
+ {
+ GLfloat a[4], result[4];
+ const GLuint *rawBits = (const GLuint *) a;
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ result[0] = (((rawBits[0] >> 0) & 0xff) - 128) / 127.0F;
+ result[0] = (((rawBits[0] >> 8) & 0xff) - 128) / 127.0F;
+ result[0] = (((rawBits[0] >> 16) & 0xff) - 128) / 127.0F;
+ result[0] = (((rawBits[0] >> 24) & 0xff) - 128) / 127.0F;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_UP4UB: /* unpack four GLubytes */
+ {
+ GLfloat a[4], result[4];
+ const GLuint *rawBits = (const GLuint *) a;
+ fetch_vector1( &inst->SrcReg[0], machine, a );
+ result[0] = ((rawBits[0] >> 0) & 0xff) / 255.0F;
+ result[0] = ((rawBits[0] >> 8) & 0xff) / 255.0F;
+ result[0] = ((rawBits[0] >> 16) & 0xff) / 255.0F;
+ result[0] = ((rawBits[0] >> 24) & 0xff) / 255.0F;
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
+ case FP_OPCODE_X2D: /* 2-D matrix transform */
+ {
+ GLfloat a[4], b[4], c[4], result[4];
+ fetch_vector4( &inst->SrcReg[0], machine, a );
+ fetch_vector4( &inst->SrcReg[1], machine, b );
+ fetch_vector4( &inst->SrcReg[2], machine, c );
+ result[0] = a[0] + b[0] * c[0] + b[1] * c[1];
+ result[1] = a[1] + b[0] * c[2] + b[1] * c[3];
+ result[2] = a[2] + b[0] * c[0] + b[1] * c[1];
+ result[3] = a[3] + b[0] * c[2] + b[1] * c[3];
+ store_vector4( &inst->DstReg, machine, result, inst->Saturate,
+ inst->UpdateCondRegister );
+ }
+ break;
default:
_mesa_problem(ctx, "Bad opcode in _mesa_exec_fragment_program");
return;
}
}
-
}
@@ -443,7 +863,7 @@ _swrast_exec_nv_fragment_program( GLcontext *ctx, struct sw_span *span )
const GLfloat *colOut = ctx->FragmentProgram.Machine.Registers[FP_OUTPUT_REG_START];
GLuint j;
- /* Clear temporary registers */
+ /* Clear temporary registers XXX use memzero() */
for (j = 0; j < MAX_NV_FRAGMENT_PROGRAM_TEMPS; j++) {
ctx->FragmentProgram.Machine.Registers[FP_TEMP_REG_START+j][0] = 0.0F;
ctx->FragmentProgram.Machine.Registers[FP_TEMP_REG_START+j][1] = 0.0F;
@@ -451,11 +871,13 @@ _swrast_exec_nv_fragment_program( GLcontext *ctx, struct sw_span *span )
ctx->FragmentProgram.Machine.Registers[FP_TEMP_REG_START+j][3] = 0.0F;
}
- /* Load input registers */
+ /*
+ * Load input registers - yes this is all very inefficient for now.
+ */
wpos[0] = span->x + i;
wpos[1] = span->y + i;
wpos[2] = span->array->z[i];
- wpos[3] = 1.0;
+ wpos[3] = 1.0; /* XXX should be 1/w */
col0[0] = CHAN_TO_FLOAT(span->array->rgba[i][RCOMP]);
col0[1] = CHAN_TO_FLOAT(span->array->rgba[i][GCOMP]);
@@ -468,6 +890,20 @@ _swrast_exec_nv_fragment_program( GLcontext *ctx, struct sw_span *span )
col1[3] = CHAN_TO_FLOAT(span->array->spec[i][ACOMP]);
fogc[0] = span->array->fog[i];
+ fogc[1] = 0.0F;
+ fogc[2] = 0.0F;
+ fogc[3] = 0.0F;
+
+ for (j = 0; j < ctx->Const.MaxTextureCoordUnits; j++) {
+ if (ctx->Texture.Unit[j]._ReallyEnabled) {
+ COPY_4V(ctx->FragmentProgram.Machine.Registers[4 + j],
+ span->array->texcoords[j][i]);
+ }
+ else {
+ COPY_4V(ctx->FragmentProgram.Machine.Registers[4 + j],
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0 + j]);
+ }
+ }
execute_program(ctx, ctx->FragmentProgram.Current);
diff --git a/src/mesa/swrast/s_nvfragprog.h b/src/mesa/swrast/s_nvfragprog.h
index 2966df9c16..5aefdaeb3a 100644
--- a/src/mesa/swrast/s_nvfragprog.h
+++ b/src/mesa/swrast/s_nvfragprog.h
@@ -1,4 +1,4 @@
-/* $Id: s_nvfragprog.h,v 1.1 2003/01/14 04:57:47 brianp Exp $ */
+/* $Id: s_nvfragprog.h,v 1.2 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -29,7 +29,7 @@
#define S_NVFRAGPROG_H
-#include "swrast.h"
+#include "s_context.h"
extern void
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 00d0f3f5d2..ca3918e99a 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.79 2003/02/06 13:44:55 brianp Exp $ */
+/* $Id: s_texture.c,v 1.80 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -812,7 +812,7 @@ sample_1d_linear(GLcontext *ctx,
static void
sample_1d_nearest_mipmap_nearest(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -828,7 +828,7 @@ sample_1d_nearest_mipmap_nearest(GLcontext *ctx,
static void
sample_1d_linear_mipmap_nearest(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -855,7 +855,7 @@ sample_1d_linear_mipmap_nearest(GLcontext *ctx,
static void
sample_1d_nearest_mipmap_linear(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -885,7 +885,7 @@ sample_1d_nearest_mipmap_linear(GLcontext *ctx,
static void
sample_1d_linear_mipmap_linear(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -915,7 +915,7 @@ sample_1d_linear_mipmap_linear(GLcontext *ctx,
static void
sample_nearest_1d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4] )
{
GLuint i;
@@ -931,7 +931,7 @@ sample_nearest_1d( GLcontext *ctx, GLuint texUnit,
static void
sample_linear_1d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4] )
{
GLuint i;
@@ -951,7 +951,7 @@ sample_linear_1d( GLcontext *ctx, GLuint texUnit,
static void
sample_lambda_1d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4],
+ const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint minStart, minEnd; /* texels with minification */
@@ -1264,7 +1264,7 @@ sample_2d_linear_repeat(GLcontext *ctx,
static void
sample_2d_nearest_mipmap_nearest(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -1280,7 +1280,7 @@ sample_2d_nearest_mipmap_nearest(GLcontext *ctx,
static void
sample_2d_linear_mipmap_nearest(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -1297,7 +1297,7 @@ sample_2d_linear_mipmap_nearest(GLcontext *ctx,
static void
sample_2d_nearest_mipmap_linear(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -1328,7 +1328,7 @@ sample_2d_nearest_mipmap_linear(GLcontext *ctx,
static void
sample_2d_linear_mipmap_linear( GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint i;
@@ -1357,7 +1357,7 @@ sample_2d_linear_mipmap_linear( GLcontext *ctx,
static void
sample_2d_linear_mipmap_linear_repeat( GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint i;
@@ -1388,7 +1388,7 @@ sample_2d_linear_mipmap_linear_repeat( GLcontext *ctx,
static void
sample_nearest_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4],
+ const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint i;
@@ -1404,7 +1404,7 @@ sample_nearest_2d( GLcontext *ctx, GLuint texUnit,
static void
sample_linear_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4],
+ const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint i;
@@ -1427,7 +1427,7 @@ sample_linear_2d( GLcontext *ctx, GLuint texUnit,
static void
opt_sample_rgb_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoords[][4],
+ GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
const struct gl_texture_image *img = tObj->Image[tObj->BaseLevel];
@@ -1466,7 +1466,7 @@ opt_sample_rgb_2d( GLcontext *ctx, GLuint texUnit,
static void
opt_sample_rgba_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoords[][4],
+ GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
const struct gl_texture_image *img = tObj->Image[tObj->BaseLevel];
@@ -1499,7 +1499,7 @@ opt_sample_rgba_2d( GLcontext *ctx, GLuint texUnit,
static void
sample_lambda_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoords[][4],
+ GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
const struct gl_texture_image *tImg = tObj->Image[tObj->BaseLevel];
@@ -1545,7 +1545,8 @@ sample_lambda_2d( GLcontext *ctx, GLuint texUnit,
NULL, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_2d_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_2d_nearest_mipmap_nearest(ctx, tObj, m,
+ texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
@@ -1844,7 +1845,7 @@ sample_3d_linear(GLcontext *ctx,
static void
sample_3d_nearest_mipmap_nearest(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint i;
@@ -1859,7 +1860,7 @@ sample_3d_nearest_mipmap_nearest(GLcontext *ctx,
static void
sample_3d_linear_mipmap_nearest(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -1875,7 +1876,7 @@ sample_3d_linear_mipmap_nearest(GLcontext *ctx,
static void
sample_3d_nearest_mipmap_linear(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -1904,7 +1905,7 @@ sample_3d_nearest_mipmap_linear(GLcontext *ctx,
static void
sample_3d_linear_mipmap_linear(GLcontext *ctx,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -1933,7 +1934,7 @@ sample_3d_linear_mipmap_linear(GLcontext *ctx,
static void
sample_nearest_3d(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
{
GLuint i;
@@ -1949,7 +1950,7 @@ sample_nearest_3d(GLcontext *ctx, GLuint texUnit,
static void
sample_linear_3d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4],
+ const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4] )
{
GLuint i;
@@ -1968,7 +1969,7 @@ sample_linear_3d( GLcontext *ctx, GLuint texUnit,
static void
sample_lambda_3d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4] )
{
GLuint minStart, minEnd; /* texels with minification */
@@ -2119,7 +2120,7 @@ choose_cube_face(const struct gl_texture_object *texObj,
static void
sample_nearest_cube(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
{
GLuint i;
@@ -2137,7 +2138,7 @@ sample_nearest_cube(GLcontext *ctx, GLuint texUnit,
static void
sample_linear_cube(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4],
+ const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -2155,7 +2156,7 @@ sample_linear_cube(GLcontext *ctx, GLuint texUnit,
static void
sample_cube_nearest_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -2174,7 +2175,7 @@ sample_cube_nearest_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
static void
sample_cube_linear_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -2193,7 +2194,7 @@ sample_cube_linear_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
static void
sample_cube_nearest_mipmap_linear(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -2225,7 +2226,7 @@ sample_cube_nearest_mipmap_linear(GLcontext *ctx, GLuint texUnit,
static void
sample_cube_linear_mipmap_linear(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
- GLuint n, GLfloat texcoord[][4],
+ GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
GLuint i;
@@ -2257,7 +2258,7 @@ sample_cube_linear_mipmap_linear(GLcontext *ctx, GLuint texUnit,
static void
sample_lambda_cube( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
{
GLuint minStart, minEnd; /* texels with minification */
@@ -2330,7 +2331,7 @@ sample_lambda_cube( GLcontext *ctx, GLuint texUnit,
static void
sample_nearest_rect(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
{
const struct gl_texture_image *img = tObj->Image[0];
@@ -2385,7 +2386,7 @@ sample_nearest_rect(GLcontext *ctx, GLuint texUnit,
static void
sample_linear_rect(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4],
+ const GLfloat texcoords[][4],
const GLfloat lambda[], GLchan rgba[][4])
{
const struct gl_texture_image *img = tObj->Image[0];
@@ -2473,7 +2474,7 @@ sample_linear_rect(GLcontext *ctx, GLuint texUnit,
static void
sample_lambda_rect( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
{
GLuint minStart, minEnd, magStart, magEnd;
@@ -2514,7 +2515,7 @@ sample_lambda_rect( GLcontext *ctx, GLuint texUnit,
static void
sample_depth_texture( GLcontext *ctx, GLuint unit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan texel[][4] )
{
const GLint baseLevel = tObj->BaseLevel;
@@ -2804,7 +2805,7 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
static void
sample_depth_texture2(const GLcontext *ctx,
const struct gl_texture_unit *texUnit,
- GLuint n, GLfloat texcoords[][4],
+ GLuint n, const GLfloat texcoords[][4],
GLchan texel[][4])
{
const struct gl_texture_object *texObj = texUnit->_Current;
@@ -2896,13 +2897,22 @@ sample_depth_texture2(const GLcontext *ctx,
/**
* We use this function when a texture object is in an "incomplete" state.
+ * When a fragment program attempts to sample an incomplete texture we
+ * return black.
+ * Note: frag progs don't observe texture enable/disable flags.
*/
static void
null_sample_func( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
- GLfloat texcoords[][4], const GLfloat lambda[],
+ const GLfloat texcoords[][4], const GLfloat lambda[],
GLchan rgba[][4])
{
+ (void) ctx;
+ (void) texUnit;
+ (void) tObj;
+ (void) texcoords;
+ (void) lambda;
+ _mesa_bzero(rgba, n * 4 * sizeof(GLchan));
}
@@ -2910,115 +2920,103 @@ null_sample_func( GLcontext *ctx, GLuint texUnit,
/**
* Setup the texture sampling function for this texture object.
*/
-void
-_swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
+texture_sample_func
+_swrast_choose_texture_sample_func( GLcontext *ctx,
const struct gl_texture_object *t )
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLboolean needLambda = (GLboolean) (t->MinFilter != t->MagFilter);
+ const GLenum format = t->Image[t->BaseLevel]->Format;
if (!t->Complete) {
- swrast->TextureSample[texUnit] = null_sample_func;
+ return null_sample_func;
}
- else {
- const GLboolean needLambda = (GLboolean) (t->MinFilter != t->MagFilter);
- const GLenum format = t->Image[t->BaseLevel]->Format;
- if (needLambda) {
- /* Compute min/mag filter threshold */
- if (t->MagFilter == GL_LINEAR
- && (t->MinFilter == GL_NEAREST_MIPMAP_NEAREST ||
- t->MinFilter == GL_NEAREST_MIPMAP_LINEAR)) {
- swrast->_MinMagThresh[texUnit] = 0.5F;
+ switch (t->Target) {
+ case GL_TEXTURE_1D:
+ if (format == GL_DEPTH_COMPONENT) {
+ return sample_depth_texture;
+ }
+ else if (needLambda) {
+ return sample_lambda_1d;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return sample_linear_1d;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ return sample_nearest_1d;
+ }
+ break;
+ case GL_TEXTURE_2D:
+ if (format == GL_DEPTH_COMPONENT) {
+ return sample_depth_texture;
+ }
+ else if (needLambda) {
+ return sample_lambda_2d;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return sample_linear_2d;
+ }
+ else {
+ GLint baseLevel = t->BaseLevel;
+ ASSERT(t->MinFilter == GL_NEAREST);
+ if (t->WrapS == GL_REPEAT &&
+ t->WrapT == GL_REPEAT &&
+ t->Image[baseLevel]->Border == 0 &&
+ t->Image[baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGB) {
+ return opt_sample_rgb_2d;
+ }
+ else if (t->WrapS == GL_REPEAT &&
+ t->WrapT == GL_REPEAT &&
+ t->Image[baseLevel]->Border == 0 &&
+ t->Image[baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGBA) {
+ return opt_sample_rgba_2d;
}
else {
- swrast->_MinMagThresh[texUnit] = 0.0F;
+ return sample_nearest_2d;
}
}
-
- switch (t->Target) {
- case GL_TEXTURE_1D:
- if (format == GL_DEPTH_COMPONENT) {
- swrast->TextureSample[texUnit] = sample_depth_texture;
- }
- else if (needLambda) {
- swrast->TextureSample[texUnit] = sample_lambda_1d;
- }
- else if (t->MinFilter == GL_LINEAR) {
- swrast->TextureSample[texUnit] = sample_linear_1d;
- }
- else {
- ASSERT(t->MinFilter == GL_NEAREST);
- swrast->TextureSample[texUnit] = sample_nearest_1d;
- }
- break;
- case GL_TEXTURE_2D:
- if (format == GL_DEPTH_COMPONENT) {
- swrast->TextureSample[texUnit] = sample_depth_texture;
- }
- else if (needLambda) {
- swrast->TextureSample[texUnit] = sample_lambda_2d;
- }
- else if (t->MinFilter == GL_LINEAR) {
- swrast->TextureSample[texUnit] = sample_linear_2d;
- }
- else {
- GLint baseLevel = t->BaseLevel;
- ASSERT(t->MinFilter == GL_NEAREST);
- if (t->WrapS == GL_REPEAT &&
- t->WrapT == GL_REPEAT &&
- t->Image[baseLevel]->Border == 0 &&
- t->Image[baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGB) {
- swrast->TextureSample[texUnit] = opt_sample_rgb_2d;
- }
- else if (t->WrapS == GL_REPEAT &&
- t->WrapT == GL_REPEAT &&
- t->Image[baseLevel]->Border == 0 &&
- t->Image[baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGBA) {
- swrast->TextureSample[texUnit] = opt_sample_rgba_2d;
- }
- else
- swrast->TextureSample[texUnit] = sample_nearest_2d;
- }
- break;
- case GL_TEXTURE_3D:
- if (needLambda) {
- swrast->TextureSample[texUnit] = sample_lambda_3d;
- }
- else if (t->MinFilter == GL_LINEAR) {
- swrast->TextureSample[texUnit] = sample_linear_3d;
- }
- else {
- ASSERT(t->MinFilter == GL_NEAREST);
- swrast->TextureSample[texUnit] = sample_nearest_3d;
- }
- break;
- case GL_TEXTURE_CUBE_MAP:
- if (needLambda) {
- swrast->TextureSample[texUnit] = sample_lambda_cube;
- }
- else if (t->MinFilter == GL_LINEAR) {
- swrast->TextureSample[texUnit] = sample_linear_cube;
- }
- else {
- ASSERT(t->MinFilter == GL_NEAREST);
- swrast->TextureSample[texUnit] = sample_nearest_cube;
- }
- break;
- case GL_TEXTURE_RECTANGLE_NV:
- if (needLambda) {
- swrast->TextureSample[texUnit] = sample_lambda_rect;
- }
- else if (t->MinFilter == GL_LINEAR) {
- swrast->TextureSample[texUnit] = sample_linear_rect;
- }
- else {
- ASSERT(t->MinFilter == GL_NEAREST);
- swrast->TextureSample[texUnit] = sample_nearest_rect;
- }
- break;
- default:
- _mesa_problem(ctx, "invalid target in _swrast_choose_texture_sample_func");
+ break;
+ case GL_TEXTURE_3D:
+ if (needLambda) {
+ return sample_lambda_3d;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return sample_linear_3d;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ return sample_nearest_3d;
+ }
+ break;
+ case GL_TEXTURE_CUBE_MAP:
+ if (needLambda) {
+ return sample_lambda_cube;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return sample_linear_cube;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ return sample_nearest_cube;
+ }
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (needLambda) {
+ return sample_lambda_rect;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return sample_linear_rect;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ return sample_nearest_rect;
}
+ break;
+ default:
+ _mesa_problem(ctx,
+ "invalid target in _swrast_choose_texture_sample_func");
+ return null_sample_func;
}
}
@@ -4170,9 +4168,9 @@ _swrast_texture_span( GLcontext *ctx, struct sw_span *span )
}
/* Sample the texture (span->end fragments) */
- swrast->TextureSample[unit]( ctx, unit, texUnit->_Current,
- span->end, span->array->texcoords[unit],
- lambda, texels );
+ swrast->TextureSample[unit]( ctx, unit, texUnit->_Current, span->end,
+ (const GLfloat (*)[4]) span->array->texcoords[unit],
+ lambda, texels );
/* GL_SGI_texture_color_table */
if (texUnit->ColorTableEnabled) {
_swrast_texture_table_lookup(&texUnit->ColorTable, span->end, texels);
diff --git a/src/mesa/swrast/s_texture.h b/src/mesa/swrast/s_texture.h
index 388c2db08d..ddb7b0dde8 100644
--- a/src/mesa/swrast/s_texture.h
+++ b/src/mesa/swrast/s_texture.h
@@ -1,4 +1,4 @@
-/* $Id: s_texture.h,v 1.14 2003/01/26 14:37:17 brianp Exp $ */
+/* $Id: s_texture.h,v 1.15 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -37,9 +37,8 @@ extern void
_swrast_texture_table_lookup( const struct gl_color_table *table,
GLuint n, GLchan rgba[][4] );
-extern void
+extern texture_sample_func
_swrast_choose_texture_sample_func( GLcontext *ctx,
- GLuint texUnit,
const struct gl_texture_object *tObj );
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index 6113b86061..3f33dbb355 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -1,10 +1,10 @@
-/* $Id: swrast.h,v 1.34 2003/01/14 04:55:47 brianp Exp $ */
+/* $Id: swrast.h,v 1.35 2003/02/23 04:10:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,7 +27,7 @@
/**
* \file swrast/swrast.h
- * \brief Defines basic structures for sw_rasterizer.
+ * \brief Public interface to the software rasterization functions.
* \author Keith Whitwell <keith@tungstengraphics.com>
*/
@@ -75,154 +75,6 @@ typedef struct {
} SWvertex;
-/**
- * \struct sw_span
- * \brief Contains data for either a horizontal line or a set of
- * pixels that are passed through a pipeline of functions before being
- * drawn.
- *
- * The sw_span structure describes the colors, Z, fogcoord, texcoords,
- * etc for either a horizontal run or a set of independent pixels. We
- * can either specify a base/step to indicate interpolated values, or
- * fill in arrays of values. The interpMask and arrayMask bitfields
- * indicate which are active.
- *
- * With this structure it's easy to hand-off span rasterization to
- * subroutines instead of doing it all inline in the triangle functions
- * like we used to do.
- * It also cleans up the local variable namespace a great deal.
- *
- * It would be interesting to experiment with multiprocessor rasterization
- * with this structure. The triangle rasterizer could simply emit a
- * stream of these structures which would be consumed by one or more
- * span-processing threads which could run in parallel.
- */
-
-
-/**
- * \defgroup SpanFlags SPAN_XXX-flags
- * Bitmasks to indicate which span_arrays need to be computed
- * (sw_span::interpMask) or have already been filled
- * (sw_span::arrayMask)
- */
-/*@{*/
-#define SPAN_RGBA 0x001
-#define SPAN_SPEC 0x002
-#define SPAN_INDEX 0x004
-#define SPAN_Z 0x008
-#define SPAN_FOG 0x010
-#define SPAN_TEXTURE 0x020
-#define SPAN_INT_TEXTURE 0x040
-#define SPAN_LAMBDA 0x080
-#define SPAN_COVERAGE 0x100
-#define SPAN_FLAT 0x200 /**< flat shading? */
-/** sw_span::arrayMask only - for span_arrays::x, span_arrays::y */
-#define SPAN_XY 0x400
-#define SPAN_MASK 0x800 /**< sw_span::arrayMask only */
-/*@}*/
-
-
-/**
- * \struct span_arrays
- * \brief Arrays of fragment values.
- *
- * These will either be computed from the x/xStep values above or
- * filled in by glDraw/CopyPixels, etc.
- */
-struct span_arrays {
- GLchan rgb[MAX_WIDTH][3];
- GLchan rgba[MAX_WIDTH][4];
- GLuint index[MAX_WIDTH];
- GLchan spec[MAX_WIDTH][4]; /* specular color */
- GLint x[MAX_WIDTH]; /**< X/Y used for point/line rendering only */
- GLint y[MAX_WIDTH]; /**< X/Y used for point/line rendering only */
- GLdepth z[MAX_WIDTH];
- GLfloat fog[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 */
- GLubyte mask[MAX_WIDTH];
-};
-
-
-struct sw_span {
- GLint x, y;
-
- /** Only need to process pixels between start <= i < end */
- /** At this time, start is always zero. */
- GLuint start, end;
-
- /** This flag indicates that mask[] array is effectively filled with ones */
- GLboolean writeAll;
-
- /** either GL_POLYGON, GL_LINE, GL_POLYGON, GL_BITMAP */
- GLenum primitive;
-
- /** 0 = front-facing span, 1 = back-facing span (for two-sided stencil) */
- GLuint facing;
-
- /**
- * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates
- * which of the x/xStep variables are relevant.
- */
- GLuint interpMask;
-
-#if CHAN_TYPE == GL_FLOAT
- GLfloat red, redStep;
- GLfloat green, greenStep;
- GLfloat blue, blueStep;
- GLfloat alpha, alphaStep;
- GLfloat specRed, specRedStep;
- GLfloat specGreen, specGreenStep;
- GLfloat specBlue, specBlueStep;
-#else /* CHAN_TYPE == GL_UNSIGNED_BYTE or GL_UNSIGNED SHORT */
- GLfixed red, redStep;
- GLfixed green, greenStep;
- GLfixed blue, blueStep;
- GLfixed alpha, alphaStep;
- GLfixed specRed, specRedStep;
- GLfixed specGreen, specGreenStep;
- GLfixed specBlue, specBlueStep;
-#endif
- GLfixed index, indexStep;
- GLfixed z, zStep;
- GLfloat fog, fogStep;
- 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
- * which of the fragment arrays in the span_arrays struct are relevant.
- */
- GLuint arrayMask;
-
- /**
- * We store the arrays of fragment values in a separate struct so
- * that we can allocate sw_span structs on the stack without using
- * a lot of memory. The span_arrays struct is about 400KB while the
- * sw_span struct is only about 512 bytes.
- */
- struct span_arrays *array;
-};
-
-
-#define INIT_SPAN(S, PRIMITIVE, END, INTERP_MASK, ARRAY_MASK) \
-do { \
- (S).primitive = (PRIMITIVE); \
- (S).interpMask = (INTERP_MASK); \
- (S).arrayMask = (ARRAY_MASK); \
- (S).start = 0; \
- (S).end = (END); \
- (S).facing = 0; \
- (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \
-} while (0)
-
-
-
struct swrast_device_driver;