Reorganized software rasterizer as a module which manages its own state,

with tighter interfaces with the rest of the world.

Proper documentation to come.
This commit is contained in:
Keith Whitwell 2000-11-05 18:24:40 +00:00
parent 7c20642b10
commit cd03ed4f54
33 changed files with 2548 additions and 2074 deletions

View file

@ -1,4 +1,4 @@
/* $Id: s_aatriangle.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_aatriangle.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -31,6 +31,7 @@
#include "s_aatriangle.h"
#include "s_context.h"
#include "s_span.h"
@ -297,7 +298,10 @@ compute_coveragei(const GLfloat v0[3], const GLfloat v1[3],
static void
rgba_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
rgba_aa_tri(GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2)
{
#define DO_Z
#define DO_RGBA
@ -306,7 +310,10 @@ rgba_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
static void
index_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
index_aa_tri(GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2)
{
#define DO_Z
#define DO_INDEX
@ -334,7 +341,10 @@ compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4],
static void
tex_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
tex_aa_tri(GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2)
{
#define DO_Z
#define DO_RGBA
@ -344,7 +354,10 @@ tex_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
static void
spec_tex_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
spec_tex_aa_tri(GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2)
{
#define DO_Z
#define DO_RGBA
@ -355,7 +368,10 @@ spec_tex_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
static void
multitex_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
multitex_aa_tri(GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2)
{
#define DO_Z
#define DO_RGBA
@ -364,7 +380,10 @@ multitex_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
}
static void
spec_multitex_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv)
spec_multitex_aa_tri(GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2)
{
#define DO_Z
#define DO_RGBA
@ -382,32 +401,34 @@ void
_mesa_set_aa_triangle_function(GLcontext *ctx)
{
ASSERT(ctx->Polygon.SmoothFlag);
if (ctx->Texture.ReallyEnabled) {
if (ctx->Texture._ReallyEnabled) {
if (ctx->Light.Enabled &&
ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) {
if (ctx->Texture.MultiTextureEnabled) {
ctx->Driver.TriangleFunc = spec_multitex_aa_tri;
(ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ||
ctx->Fog.ColorSumEnabled)) {
if (ctx->Texture._MultiTextureEnabled) {
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
}
else {
ctx->Driver.TriangleFunc = spec_tex_aa_tri;
SWRAST_CONTEXT(ctx)->Triangle = spec_tex_aa_tri;
}
}
else {
if (ctx->Texture.MultiTextureEnabled) {
ctx->Driver.TriangleFunc = multitex_aa_tri;
if (ctx->Texture._MultiTextureEnabled) {
SWRAST_CONTEXT(ctx)->Triangle = multitex_aa_tri;
}
else {
ctx->Driver.TriangleFunc = tex_aa_tri;
SWRAST_CONTEXT(ctx)->Triangle = tex_aa_tri;
}
}
}
else {
if (ctx->Visual.RGBAflag) {
ctx->Driver.TriangleFunc = rgba_aa_tri;
SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri;
}
else {
ctx->Driver.TriangleFunc = index_aa_tri;
SWRAST_CONTEXT(ctx)->Triangle = index_aa_tri;
}
}
ASSERT(ctx->Driver.TriangleFunc);
ASSERT(SWRAST_CONTEXT(ctx)->Triangle);
}

View file

@ -1,4 +1,4 @@
/* $Id: s_aatritemp.h,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_aatritemp.h,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -44,11 +44,10 @@
/*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/
{
const struct vertex_buffer *VB = ctx->VB;
const GLfloat *p0 = VB->Win.data[v0];
const GLfloat *p1 = VB->Win.data[v1];
const GLfloat *p2 = VB->Win.data[v2];
GLint vMin, vMid, vMax;
const GLfloat *p0 = v0->win;
const GLfloat *p1 = v1->win;
const GLfloat *p2 = v2->win;
SWvertex *vMin, *vMid, *vMax;
GLint iyMin, iyMax;
GLfloat yMin, yMax;
GLboolean ltor;
@ -87,13 +86,13 @@
GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH];
GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH];
#endif
GLfloat bf = ctx->backface_sign;
GLfloat bf = ctx->_backface_sign;
/* determine bottom to top order of vertices */
{
GLfloat y0 = VB->Win.data[v0][1];
GLfloat y1 = VB->Win.data[v1][1];
GLfloat y2 = VB->Win.data[v2][1];
GLfloat y0 = v0->win[1];
GLfloat y1 = v1->win[1];
GLfloat y2 = v2->win[1];
if (y0 <= y1) {
if (y1 <= y2) {
vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */
@ -118,12 +117,12 @@
}
}
majDx = VB->Win.data[vMax][0] - VB->Win.data[vMin][0];
majDy = VB->Win.data[vMax][1] - VB->Win.data[vMin][1];
majDx = vMax->win[0] - vMin->win[0];
majDy = vMax->win[1] - vMin->win[1];
{
const GLfloat botDx = VB->Win.data[vMid][0] - VB->Win.data[vMin][0];
const GLfloat botDy = VB->Win.data[vMid][1] - VB->Win.data[vMin][1];
const GLfloat botDx = vMid->win[0] - vMin->win[0];
const GLfloat botDy = vMid->win[1] - vMin->win[1];
const GLfloat area = majDx * botDy - botDx * majDy;
ltor = (GLboolean) (area < 0.0F);
/* Do backface culling */
@ -139,64 +138,60 @@
#ifdef DO_Z
compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane);
compute_plane(p0, p1, p2,
VB->FogCoordPtr->data[v0],
VB->FogCoordPtr->data[v1],
VB->FogCoordPtr->data[v2],
v0->fog,
v1->fog,
v2->fog,
fogPlane);
#endif
#ifdef DO_RGBA
if (ctx->Light.ShadeModel == GL_SMOOTH) {
GLchan (*rgba)[4] = VB->ColorPtr->data;
compute_plane(p0, p1, p2, rgba[v0][0], rgba[v1][0], rgba[v2][0], rPlane);
compute_plane(p0, p1, p2, rgba[v0][1], rgba[v1][1], rgba[v2][1], gPlane);
compute_plane(p0, p1, p2, rgba[v0][2], rgba[v1][2], rgba[v2][2], bPlane);
compute_plane(p0, p1, p2, rgba[v0][3], rgba[v1][3], rgba[v2][3], aPlane);
compute_plane(p0, p1, p2, v0->color[0], v1->color[0], v2->color[0], rPlane);
compute_plane(p0, p1, p2, v0->color[1], v1->color[1], v2->color[1], gPlane);
compute_plane(p0, p1, p2, v0->color[2], v1->color[2], v2->color[2], bPlane);
compute_plane(p0, p1, p2, v0->color[3], v1->color[3], v2->color[3], aPlane);
}
else {
constant_plane(VB->ColorPtr->data[pv][RCOMP], rPlane);
constant_plane(VB->ColorPtr->data[pv][GCOMP], gPlane);
constant_plane(VB->ColorPtr->data[pv][BCOMP], bPlane);
constant_plane(VB->ColorPtr->data[pv][ACOMP], aPlane);
constant_plane(v0->color[RCOMP], rPlane);
constant_plane(v0->color[GCOMP], gPlane);
constant_plane(v0->color[BCOMP], bPlane);
constant_plane(v0->color[ACOMP], aPlane);
}
#endif
#ifdef DO_INDEX
if (ctx->Light.ShadeModel == GL_SMOOTH) {
compute_plane(p0, p1, p2, VB->IndexPtr->data[v0],
VB->IndexPtr->data[v1], VB->IndexPtr->data[v2], iPlane);
compute_plane(p0, p1, p2, v0->index,
v1->index, v2->index, iPlane);
}
else {
constant_plane(VB->IndexPtr->data[pv], iPlane);
constant_plane(v0->index, iPlane);
}
#endif
#ifdef DO_SPEC
{
GLchan (*spec)[4] = VB->SecondaryColorPtr->data;
compute_plane(p0, p1, p2, spec[v0][0], spec[v1][0], spec[v2][0],srPlane);
compute_plane(p0, p1, p2, spec[v0][1], spec[v1][1], spec[v2][1],sgPlane);
compute_plane(p0, p1, p2, spec[v0][2], spec[v1][2], spec[v2][2],sbPlane);
compute_plane(p0, p1, p2, v0->specular[0], v1->specular[0], v2->specular[0],srPlane);
compute_plane(p0, p1, p2, v0->specular[1], v1->specular[1], v2->specular[1],sgPlane);
compute_plane(p0, p1, p2, v0->specular[2], v1->specular[2], v2->specular[2],sbPlane);
}
#endif
#ifdef DO_TEX
{
const struct gl_texture_object *obj = ctx->Texture.Unit[0].Current;
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current;
const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel];
const GLint tSize = 3;
const GLfloat invW0 = VB->Win.data[v0][3];
const GLfloat invW1 = VB->Win.data[v1][3];
const GLfloat invW2 = VB->Win.data[v2][3];
GLfloat (*texCoord)[4] = VB->TexCoordPtr[0]->data;
const GLfloat s0 = texCoord[v0][0] * invW0;
const GLfloat s1 = texCoord[v1][0] * invW1;
const GLfloat s2 = texCoord[v2][0] * invW2;
const GLfloat t0 = (tSize > 1) ? texCoord[v0][1] * invW0 : 0.0F;
const GLfloat t1 = (tSize > 1) ? texCoord[v1][1] * invW1 : 0.0F;
const GLfloat t2 = (tSize > 1) ? texCoord[v2][1] * invW2 : 0.0F;
const GLfloat r0 = (tSize > 2) ? texCoord[v0][2] * invW0 : 0.0F;
const GLfloat r1 = (tSize > 2) ? texCoord[v1][2] * invW1 : 0.0F;
const GLfloat r2 = (tSize > 2) ? texCoord[v2][2] * invW2 : 0.0F;
const GLfloat q0 = (tSize > 3) ? texCoord[v0][3] * invW0 : invW0;
const GLfloat q1 = (tSize > 3) ? texCoord[v1][3] * invW1 : invW1;
const GLfloat q2 = (tSize > 3) ? texCoord[v2][3] * invW2 : invW2;
const GLfloat invW0 = v0->win[3];
const GLfloat invW1 = v1->win[3];
const GLfloat invW2 = v2->win[3];
const GLfloat s0 = v0->texcoord[0][0] * invW0;
const GLfloat s1 = v1->texcoord[0][0] * invW1;
const GLfloat s2 = v2->texcoord[0][0] * invW2;
const GLfloat t0 = v0->texcoord[0][1] * invW0;
const GLfloat t1 = v1->texcoord[0][1] * invW1;
const GLfloat t2 = v2->texcoord[0][1] * invW2;
const GLfloat r0 = v0->texcoord[0][2] * invW0;
const GLfloat r1 = v1->texcoord[0][2] * invW1;
const GLfloat r2 = v2->texcoord[0][2] * invW2;
const GLfloat q0 = v0->texcoord[0][3] * invW0;
const GLfloat q1 = v1->texcoord[0][3] * invW1;
const GLfloat q2 = v2->texcoord[0][3] * invW2;
compute_plane(p0, p1, p2, s0, s1, s2, sPlane);
compute_plane(p0, p1, p2, t0, t1, t2, tPlane);
compute_plane(p0, p1, p2, r0, r1, r2, uPlane);
@ -208,26 +203,24 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
const struct gl_texture_object *obj = ctx->Texture.Unit[u].Current;
if (ctx->Texture.Unit[u]._ReallyEnabled) {
const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current;
const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel];
const GLint tSize = VB->TexCoordPtr[u]->size;
const GLfloat invW0 = VB->Win.data[v0][3];
const GLfloat invW1 = VB->Win.data[v1][3];
const GLfloat invW2 = VB->Win.data[v2][3];
GLfloat (*texCoord)[4] = VB->TexCoordPtr[u]->data;
const GLfloat s0 = texCoord[v0][0] * invW0;
const GLfloat s1 = texCoord[v1][0] * invW1;
const GLfloat s2 = texCoord[v2][0] * invW2;
const GLfloat t0 = (tSize > 1) ? texCoord[v0][1] * invW0 : 0.0F;
const GLfloat t1 = (tSize > 1) ? texCoord[v1][1] * invW1 : 0.0F;
const GLfloat t2 = (tSize > 1) ? texCoord[v2][1] * invW2 : 0.0F;
const GLfloat r0 = (tSize > 2) ? texCoord[v0][2] * invW0 : 0.0F;
const GLfloat r1 = (tSize > 2) ? texCoord[v1][2] * invW1 : 0.0F;
const GLfloat r2 = (tSize > 2) ? texCoord[v2][2] * invW2 : 0.0F;
const GLfloat q0 = (tSize > 3) ? texCoord[v0][3] * invW0 : invW0;
const GLfloat q1 = (tSize > 3) ? texCoord[v1][3] * invW1 : invW1;
const GLfloat q2 = (tSize > 3) ? texCoord[v2][3] * invW2 : invW2;
const GLfloat invW0 = v0->win[3];
const GLfloat invW1 = v1->win[3];
const GLfloat invW2 = v2->win[3];
const GLfloat s0 = v0->texcoord[u][0] * invW0;
const GLfloat s1 = v1->texcoord[u][0] * invW1;
const GLfloat s2 = v2->texcoord[u][0] * invW2;
const GLfloat t0 = v0->texcoord[u][1] * invW0;
const GLfloat t1 = v1->texcoord[u][1] * invW1;
const GLfloat t2 = v2->texcoord[u][1] * invW2;
const GLfloat r0 = v0->texcoord[u][2] * invW0;
const GLfloat r1 = v1->texcoord[u][2] * invW1;
const GLfloat r2 = v2->texcoord[u][2] * invW2;
const GLfloat q0 = v0->texcoord[u][3] * invW0;
const GLfloat q1 = v1->texcoord[u][3] * invW1;
const GLfloat q2 = v2->texcoord[u][3] * invW2;
compute_plane(p0, p1, p2, s0, s1, s2, sPlane[u]);
compute_plane(p0, p1, p2, t0, t1, t2, tPlane[u]);
compute_plane(p0, p1, p2, r0, r1, r2, uPlane[u]);
@ -239,19 +232,19 @@
}
#endif
yMin = VB->Win.data[vMin][1];
yMax = VB->Win.data[vMax][1];
yMin = vMin->win[1];
yMax = vMax->win[1];
iyMin = (int) yMin;
iyMax = (int) yMax + 1;
if (ltor) {
/* scan left to right */
const float *pMin = VB->Win.data[vMin];
const float *pMid = VB->Win.data[vMid];
const float *pMax = VB->Win.data[vMax];
const float *pMin = vMin->win;
const float *pMid = vMid->win;
const float *pMax = vMax->win;
const float dxdy = majDx / majDy;
const float xAdj = dxdy < 0.0F ? -dxdy : 0.0F;
float x = VB->Win.data[vMin][0] - (yMin - iyMin) * dxdy;
float x = vMin->win[0] - (yMin - iyMin) * dxdy;
int iy;
for (iy = iyMin; iy < iyMax; iy++, x += dxdy) {
GLint ix, startX = (GLint) (x - xAdj);
@ -304,7 +297,7 @@
{
GLuint unit;
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit].ReallyEnabled) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLfloat invQ = solve_plane_recip(ix, iy, vPlane[unit]);
s[unit][count] = solve_plane(ix, iy, sPlane[unit]) * invQ;
t[unit][count] = solve_plane(ix, iy, tPlane[unit]) * invQ;
@ -356,12 +349,12 @@
}
else {
/* scan right to left */
const GLfloat *pMin = VB->Win.data[vMin];
const GLfloat *pMid = VB->Win.data[vMid];
const GLfloat *pMax = VB->Win.data[vMax];
const GLfloat *pMin = vMin->win;
const GLfloat *pMid = vMid->win;
const GLfloat *pMax = vMax->win;
const GLfloat dxdy = majDx / majDy;
const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F;
GLfloat x = VB->Win.data[vMin][0] - (yMin - iyMin) * dxdy;
GLfloat x = vMin->win[0] - (yMin - iyMin) * dxdy;
GLint iy;
for (iy = iyMin; iy < iyMax; iy++, x += dxdy) {
GLint ix, left, startX = (GLint) (x + xAdj);
@ -414,7 +407,7 @@
{
GLuint unit;
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit].ReallyEnabled) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLfloat invQ = solve_plane_recip(ix, iy, vPlane[unit]);
s[unit][ix] = solve_plane(ix, iy, sPlane[unit]) * invQ;
t[unit][ix] = solve_plane(ix, iy, tPlane[unit]) * invQ;
@ -436,7 +429,7 @@
{
GLuint unit;
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit].ReallyEnabled) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLint j;
for (j = 0; j < n; j++) {
s[unit][j] = s[unit][j + left];

View file

@ -1,4 +1,4 @@
/* $Id: s_accum.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_accum.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -30,6 +30,7 @@
#include "mem.h"
#include "s_accum.h"
#include "s_context.h"
#include "s_masking.h"
#include "s_span.h"
@ -119,6 +120,116 @@ static void rescale_accum( GLcontext *ctx )
/*
* Clear the accumulation Buffer.
*/
void
_mesa_clear_accum_buffer( GLcontext *ctx )
{
GLuint buffersize;
GLfloat acc_scale;
if (ctx->Visual.AccumRedBits==0) {
/* No accumulation buffer! */
return;
}
if (sizeof(GLaccum)==1) {
acc_scale = 127.0;
}
else if (sizeof(GLaccum)==2) {
acc_scale = 32767.0;
}
else {
/* sizeof(GLaccum) > 2 (Cray) */
acc_scale = (float) SHRT_MAX;
}
/* number of pixels */
buffersize = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
if (!ctx->DrawBuffer->Accum) {
/* try to alloc accumulation buffer */
ctx->DrawBuffer->Accum = (GLaccum *)
MALLOC( buffersize * 4 * sizeof(GLaccum) );
}
if (ctx->DrawBuffer->Accum) {
if (ctx->Scissor.Enabled) {
/* Limit clear to scissor box */
GLaccum r, g, b, a;
GLint i, j;
GLint width, height;
GLaccum *row;
r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
/* size of region to clear */
width = 4 * (ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin);
height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
/* ptr to first element to clear */
row = ctx->DrawBuffer->Accum
+ 4 * (ctx->DrawBuffer->Ymin * ctx->DrawBuffer->Width
+ ctx->DrawBuffer->Xmin);
for (j=0;j<height;j++) {
for (i=0;i<width;i+=4) {
row[i+0] = r;
row[i+1] = g;
row[i+2] = b;
row[i+3] = a;
}
row += 4 * ctx->DrawBuffer->Width;
}
}
else {
/* clear whole buffer */
if (ctx->Accum.ClearColor[0]==0.0 &&
ctx->Accum.ClearColor[1]==0.0 &&
ctx->Accum.ClearColor[2]==0.0 &&
ctx->Accum.ClearColor[3]==0.0) {
/* Black */
BZERO( ctx->DrawBuffer->Accum, buffersize * 4 * sizeof(GLaccum) );
}
else {
/* Not black */
GLaccum *acc, r, g, b, a;
GLuint i;
acc = ctx->DrawBuffer->Accum;
r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
for (i=0;i<buffersize;i++) {
*acc++ = r;
*acc++ = g;
*acc++ = b;
*acc++ = a;
}
}
}
/* update optimized accum state vars */
if (ctx->Accum.ClearColor[0] == 0.0 && ctx->Accum.ClearColor[1] == 0.0 &&
ctx->Accum.ClearColor[2] == 0.0 && ctx->Accum.ClearColor[3] == 0.0) {
#ifdef USE_OPTIMIZED_ACCUM
ctx->IntegerAccumMode = GL_TRUE;
#else
ctx->IntegerAccumMode = GL_FALSE;
#endif
ctx->IntegerAccumScaler = 0.0; /* denotes empty accum buffer */
}
else {
ctx->IntegerAccumMode = GL_FALSE;
}
}
}
void
_swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
GLint xpos, GLint ypos,
@ -133,8 +244,13 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
const GLfloat fChanMax = (1 << (sizeof(GLchan) * 8)) - 1;
if (SWRAST_CONTEXT(ctx)->NewState)
_swrast_validate_derived( ctx );
if (!ctx->DrawBuffer->Accum) {
_mesa_warning(ctx, "Calling glAccum() without an accumulation buffer (low memory?)");
_mesa_warning(ctx,
"Calling glAccum() without an accumulation "
"buffer (low memory?)");
return;
}
@ -389,111 +505,3 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
gl_error( ctx, GL_INVALID_ENUM, "glAccum" );
}
}
/*
* Clear the accumulation Buffer.
*/
void
_mesa_clear_accum_buffer( GLcontext *ctx )
{
GLuint buffersize;
GLfloat acc_scale;
if (ctx->Visual.AccumRedBits==0) {
/* No accumulation buffer! */
return;
}
if (sizeof(GLaccum)==1) {
acc_scale = 127.0;
}
else if (sizeof(GLaccum)==2) {
acc_scale = 32767.0;
}
else {
/* sizeof(GLaccum) > 2 (Cray) */
acc_scale = (float) SHRT_MAX;
}
/* number of pixels */
buffersize = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
if (!ctx->DrawBuffer->Accum) {
/* try to alloc accumulation buffer */
ctx->DrawBuffer->Accum = (GLaccum *)
MALLOC( buffersize * 4 * sizeof(GLaccum) );
}
if (ctx->DrawBuffer->Accum) {
if (ctx->Scissor.Enabled) {
/* Limit clear to scissor box */
GLaccum r, g, b, a;
GLint i, j;
GLint width, height;
GLaccum *row;
r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
/* size of region to clear */
width = 4 * (ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin);
height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
/* ptr to first element to clear */
row = ctx->DrawBuffer->Accum
+ 4 * (ctx->DrawBuffer->Ymin * ctx->DrawBuffer->Width
+ ctx->DrawBuffer->Xmin);
for (j=0;j<height;j++) {
for (i=0;i<width;i+=4) {
row[i+0] = r;
row[i+1] = g;
row[i+2] = b;
row[i+3] = a;
}
row += 4 * ctx->DrawBuffer->Width;
}
}
else {
/* clear whole buffer */
if (ctx->Accum.ClearColor[0]==0.0 &&
ctx->Accum.ClearColor[1]==0.0 &&
ctx->Accum.ClearColor[2]==0.0 &&
ctx->Accum.ClearColor[3]==0.0) {
/* Black */
BZERO( ctx->DrawBuffer->Accum, buffersize * 4 * sizeof(GLaccum) );
}
else {
/* Not black */
GLaccum *acc, r, g, b, a;
GLuint i;
acc = ctx->DrawBuffer->Accum;
r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
for (i=0;i<buffersize;i++) {
*acc++ = r;
*acc++ = g;
*acc++ = b;
*acc++ = a;
}
}
}
/* update optimized accum state vars */
if (ctx->Accum.ClearColor[0] == 0.0 && ctx->Accum.ClearColor[1] == 0.0 &&
ctx->Accum.ClearColor[2] == 0.0 && ctx->Accum.ClearColor[3] == 0.0) {
#ifdef USE_OPTIMIZED_ACCUM
ctx->IntegerAccumMode = GL_TRUE;
#else
ctx->IntegerAccumMode = GL_FALSE;
#endif
ctx->IntegerAccumScaler = 0.0; /* denotes empty accum buffer */
}
else {
ctx->IntegerAccumMode = GL_FALSE;
}
}
}

View file

@ -1,4 +1,4 @@
/* $Id: s_bitmap.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_bitmap.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -30,6 +30,7 @@
#include "macros.h"
#include "pixel.h"
#include "s_context.h"
#include "s_fog.h"
#include "s_pb.h"
@ -44,7 +45,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
const struct gl_pixelstore_attrib *unpack,
const GLubyte *bitmap )
{
struct pixel_buffer *PB = ctx->PB;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint row, col;
GLdepth fragZ;
GLfixed fogCoord;
@ -52,9 +53,12 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
ASSERT(ctx->RenderMode == GL_RENDER);
ASSERT(bitmap);
if (ctx->PB->primitive != GL_BITMAP) {
if (SWRAST_CONTEXT(ctx)->NewState)
_swrast_validate_derived( ctx );
if (PB->primitive != GL_BITMAP) {
gl_flush_pb( ctx );
ctx->PB->primitive = GL_BITMAP;
PB->primitive = GL_BITMAP;
}
/* Set bitmap drawing color */

View file

@ -1,4 +1,4 @@
/* $Id: s_blend.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_blend.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -32,16 +32,20 @@
#include "s_alphabuf.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_pb.h"
#include "s_span.h"
#ifdef USE_MMX_ASM
#if defined(USE_MMX_ASM)
#include "X86/mmx.h"
#include "X86/common_x86_asm.h"
#define _BLENDAPI _ASMAPI
#else
#define _BLENDAPI
#endif
/*
* Common transparency blending mode.
*/
@ -547,17 +551,13 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[],
#if defined(USE_MMX_ASM)
#include "X86/mmx.h"
#include "X86/common_x86_asm.h"
#endif
/*
* Analyze current blending parameters to pick fastest blending function.
* Result: the ctx->Color.BlendFunc pointer is updated.
*/
static void set_blend_function( GLcontext *ctx )
void _swrast_choose_blend_func( GLcontext *ctx )
{
const GLenum eq = ctx->Color.BlendEquation;
const GLenum srcRGB = ctx->Color.BlendSrcRGB;
@ -565,40 +565,38 @@ static void set_blend_function( GLcontext *ctx )
const GLenum srcA = ctx->Color.BlendSrcA;
const GLenum dstA = ctx->Color.BlendDstA;
#if defined(USE_MMX_ASM)
/* Hmm. A table here would have 12^4 == way too many entries.
* Provide a hook for MMX instead.
*/
if ( cpu_has_mmx ) {
gl_mmx_set_blend_function( ctx );
}
else
#endif
if (srcRGB != srcA || dstRGB != dstA) {
ctx->Color.BlendFunc = blend_general;
SWRAST_CONTEXT(ctx)->BlendFunc = blend_general;
}
else if (eq==GL_FUNC_ADD_EXT && srcRGB==GL_SRC_ALPHA
&& dstRGB==GL_ONE_MINUS_SRC_ALPHA) {
ctx->Color.BlendFunc = blend_transparency;
&& dstRGB==GL_ONE_MINUS_SRC_ALPHA)
{
#if defined(USE_MMX_ASM)
if ( cpu_has_mmx ) {
SWRAST_CONTEXT(ctx)->BlendFunc = gl_mmx_blend_transparency;
}
else
#endif
SWRAST_CONTEXT(ctx)->BlendFunc = blend_transparency;
}
else if (eq==GL_FUNC_ADD_EXT && srcRGB==GL_ONE && dstRGB==GL_ONE) {
ctx->Color.BlendFunc = blend_add;
SWRAST_CONTEXT(ctx)->BlendFunc = blend_add;
}
else if (((eq==GL_FUNC_ADD_EXT || eq==GL_FUNC_REVERSE_SUBTRACT_EXT)
&& (srcRGB==GL_ZERO && dstRGB==GL_SRC_COLOR))
||
((eq==GL_FUNC_ADD_EXT || eq==GL_FUNC_SUBTRACT_EXT)
&& (srcRGB==GL_DST_COLOR && dstRGB==GL_ZERO))) {
ctx->Color.BlendFunc = blend_modulate;
&& (srcRGB==GL_ZERO && dstRGB==GL_SRC_COLOR))
||
((eq==GL_FUNC_ADD_EXT || eq==GL_FUNC_SUBTRACT_EXT)
&& (srcRGB==GL_DST_COLOR && dstRGB==GL_ZERO))) {
SWRAST_CONTEXT(ctx)->BlendFunc = blend_modulate;
}
else if (eq==GL_MIN_EXT) {
ctx->Color.BlendFunc = blend_min;
SWRAST_CONTEXT(ctx)->BlendFunc = blend_min;
}
else if (eq==GL_MAX_EXT) {
ctx->Color.BlendFunc = blend_max;
SWRAST_CONTEXT(ctx)->BlendFunc = blend_max;
}
else {
ctx->Color.BlendFunc = blend_general;
SWRAST_CONTEXT(ctx)->BlendFunc = blend_general;
}
}
@ -626,10 +624,8 @@ _mesa_blend_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
/* Read span of current frame buffer pixels */
gl_read_rgba_span( ctx, ctx->DrawBuffer, n, x, y, dest );
if (!ctx->Color.BlendFunc)
set_blend_function(ctx);
(*ctx->Color.BlendFunc)( ctx, n, mask, rgba, (const GLchan (*)[4])dest );
SWRAST_CONTEXT(ctx)->BlendFunc( ctx, n, mask, rgba,
(const GLchan (*)[4])dest );
}
@ -646,6 +642,7 @@ _mesa_blend_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan dest[PB_SIZE][4];
/* Check if device driver can do the work */
@ -656,12 +653,11 @@ _mesa_blend_pixels( GLcontext *ctx,
/* Read pixels from current color buffer */
(*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
if (!ctx->Color.BlendFunc)
set_blend_function(ctx);
(*ctx->Color.BlendFunc)( ctx, n, mask, rgba, (const GLchan (*)[4])dest );
swrast->BlendFunc( ctx, n, mask, rgba, (const GLchan (*)[4])dest );
}

View file

@ -1,4 +1,4 @@
/* $Id: s_blend.h,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_blend.h,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -44,6 +44,8 @@ _mesa_blend_pixels( GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] );
extern void
_swrast_choose_blend_func( GLcontext *ctx );
#endif

View file

@ -1,4 +1,4 @@
/* $Id: s_context.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_context.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -22,28 +22,365 @@
* 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 <keithw@valinux.com>
*/
#include "glheader.h"
#include "types.h"
#include "mem.h"
#include "s_pb.h"
#include "s_points.h"
#include "s_lines.h"
#include "s_triangle.h"
#include "s_quads.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_texture.h"
/*
* Recompute the value of swrast->_RasterMask, etc. according to
* the current context.
*/
static void
_swrast_update_rasterflags( GLcontext *ctx )
{
GLuint RasterMask = 0;
if (ctx->Color.AlphaEnabled) RasterMask |= ALPHATEST_BIT;
if (ctx->Color.BlendEnabled) RasterMask |= BLEND_BIT;
if (ctx->Depth.Test) RasterMask |= DEPTH_BIT;
if (ctx->Fog.Enabled) RasterMask |= FOG_BIT;
if (ctx->Scissor.Enabled) RasterMask |= SCISSOR_BIT;
if (ctx->Stencil.Enabled) RasterMask |= STENCIL_BIT;
if (ctx->Visual.RGBAflag) {
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
if (colorMask != 0xffffffff) RasterMask |= MASKING_BIT;
if (ctx->Color.ColorLogicOpEnabled) RasterMask |= LOGIC_OP_BIT;
if (ctx->Texture._ReallyEnabled) RasterMask |= TEXTURE_BIT;
}
else {
if (ctx->Color.IndexMask != 0xffffffff) RasterMask |= MASKING_BIT;
if (ctx->Color.IndexLogicOpEnabled) RasterMask |= LOGIC_OP_BIT;
}
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
&& ctx->Color.ColorMask[ACOMP]
&& ctx->Color.DrawBuffer != GL_NONE)
RasterMask |= ALPHABUF_BIT;
if ( ctx->Viewport.X < 0
|| ctx->Viewport.X + ctx->Viewport.Width > ctx->DrawBuffer->Width
|| ctx->Viewport.Y < 0
|| ctx->Viewport.Y + ctx->Viewport.Height > ctx->DrawBuffer->Height) {
RasterMask |= WINCLIP_BIT;
}
if (ctx->Depth.OcclusionTest)
RasterMask |= OCCLUSION_BIT;
/* If we're not drawing to exactly one color buffer set the
* MULTI_DRAW_BIT flag. Also set it if we're drawing to no
* buffers or the RGBA or CI mask disables all writes.
*/
if (ctx->Color.MultiDrawBuffer) {
RasterMask |= MULTI_DRAW_BIT;
}
else if (ctx->Color.DrawBuffer==GL_NONE) {
RasterMask |= MULTI_DRAW_BIT;
}
else if (ctx->Visual.RGBAflag && *((GLuint *) ctx->Color.ColorMask) == 0) {
RasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */
}
else if (!ctx->Visual.RGBAflag && ctx->Color.IndexMask==0) {
RasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */
}
if ( ctx->Viewport.X<0
|| ctx->Viewport.X + ctx->Viewport.Width > ctx->DrawBuffer->Width
|| ctx->Viewport.Y<0
|| ctx->Viewport.Y + ctx->Viewport.Height > ctx->DrawBuffer->Height) {
RasterMask |= WINCLIP_BIT;
}
SWRAST_CONTEXT(ctx)->_RasterMask = RasterMask;
}
#define _SWRAST_NEW_TRIANGLE (_NEW_RENDERMODE| \
_NEW_POLYGON| \
_NEW_DEPTH| \
_NEW_STENCIL| \
_NEW_COLOR| \
_NEW_TEXTURE| \
_NEW_HINT| \
_SWRAST_NEW_RASTERMASK| \
_NEW_LIGHT| \
_NEW_FOG)
#define _SWRAST_NEW_LINE (_NEW_RENDERMODE| \
_NEW_LINE| \
_NEW_TEXTURE| \
_NEW_LIGHT| \
_NEW_FOG| \
_NEW_DEPTH)
#define _SWRAST_NEW_POINT (_NEW_RENDERMODE | \
_NEW_POINT | \
_NEW_TEXTURE | \
_NEW_LIGHT | \
_NEW_FOG)
#define _SWRAST_NEW_QUAD 0
#define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE
#define _SWRAST_NEW_BLEND_FUNC _NEW_COLOR
/* Stub for swrast->Triangle to select a true triangle function
* after a state change.
*/
static void
_swrast_validate_quad( GLcontext *ctx,
SWvertex *v0, SWvertex *v1, SWvertex *v2, SWvertex *v3 )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
_swrast_validate_derived( ctx );
swrast->choose_quad( ctx );
swrast->Quad( ctx, v0, v1, v2, v3 );
}
static void
_swrast_validate_triangle( GLcontext *ctx,
SWvertex *v0, SWvertex *v1, SWvertex *v2 )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
_swrast_validate_derived( ctx );
swrast->choose_triangle( ctx );
swrast->Triangle( ctx, v0, v1, v2 );
}
static void
_swrast_validate_line( GLcontext *ctx, SWvertex *v0, SWvertex *v1 )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
_swrast_validate_derived( ctx );
swrast->choose_line( ctx );
swrast->Line( ctx, v0, v1 );
}
static void
_swrast_validate_point( GLcontext *ctx, SWvertex *v0 )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
_swrast_validate_derived( ctx );
swrast->choose_point( ctx );
swrast->Point( ctx, v0 );
}
void
_swrast_validate_blend_func( GLcontext *ctx, GLuint n,
const GLubyte mask[],
GLchan src[][4],
CONST GLchan dst[][4] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
_swrast_validate_derived( ctx );
_swrast_choose_blend_func( ctx );
swrast->BlendFunc( ctx, n, mask, src, dst );
}
void
_swrast_validate_texture_sample( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
_swrast_validate_derived( ctx );
_swrast_choose_texture_sample_func( ctx, texUnit, tObj );
swrast->TextureSample[texUnit]( ctx, texUnit, tObj, n, s, t, u,
lambda, rgba );
}
static void
_swrast_sleep( GLcontext *ctx, GLuint new_state )
{
}
static void
_swrast_invalidate_state( GLcontext *ctx, GLuint new_state )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint i;
swrast->NewState |= new_state;
/* After 10 statechanges without any swrast functions being called,
* put the module to sleep.
*/
if (++swrast->StateChanges > 10) {
swrast->InvalidateState = _swrast_sleep;
swrast->NewState = ~0;
new_state = ~0;
}
if (new_state & swrast->invalidate_triangle)
swrast->Triangle = _swrast_validate_triangle;
if (new_state & swrast->invalidate_line)
swrast->Line = _swrast_validate_line;
if (new_state & swrast->invalidate_point)
swrast->Point = _swrast_validate_point;
if (new_state & swrast->invalidate_quad)
swrast->Quad = _swrast_validate_quad;
if (new_state & _SWRAST_NEW_BLEND_FUNC)
swrast->BlendFunc = _swrast_validate_blend_func;
if (new_state & _SWRAST_NEW_TEXTURE_SAMPLE_FUNC)
for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
swrast->TextureSample[i] = _swrast_validate_texture_sample;
}
void
_swrast_validate_derived( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (swrast->NewState)
{
if (swrast->NewState & _SWRAST_NEW_RASTERMASK)
_swrast_update_rasterflags( ctx );
swrast->NewState = 0;
swrast->StateChanges = 0;
swrast->InvalidateState = _swrast_invalidate_state;
}
}
/* Public entrypoints: See also s_accum.c, s_bitmap.c, etc.
*/
void
_swrast_Quad( GLcontext *ctx,
SWvertex *v0, SWvertex *v1, SWvertex *v2, SWvertex *v3 )
{
SWRAST_CONTEXT(ctx)->Quad( ctx, v0, v1, v2, v3 );
}
void
_swrast_Triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2 )
{
SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2 );
}
void
_swrast_Line( GLcontext *ctx, SWvertex *v0, SWvertex *v1 )
{
SWRAST_CONTEXT(ctx)->Line( ctx, v0, v1 );
}
void
_swrast_Point( GLcontext *ctx, SWvertex *v0 )
{
SWRAST_CONTEXT(ctx)->Point( ctx, v0 );
}
void
_swrast_InvalidateState( GLcontext *ctx, GLuint new_state )
{
SWRAST_CONTEXT(ctx)->InvalidateState( ctx, new_state );
}
GLuint *
_swrast_get_stipple_counter_ref( GLcontext *ctx )
{
return &SWRAST_CONTEXT(ctx)->StippleCounter;
}
GLboolean
_swrast_create_context( GLcontext *ctx )
_swrast_CreateContext( GLcontext *ctx )
{
ctx->PB = gl_alloc_pb();
if (!ctx->PB) return GL_FALSE;
GLuint i;
SWcontext *swrast = (SWcontext *)CALLOC(sizeof(SWcontext));
if (!swrast)
return GL_FALSE;
swrast->PB = gl_alloc_pb();
if (!swrast->PB) {
FREE(swrast);
return GL_FALSE;
}
swrast->NewState = ~0;
swrast->choose_point = _swrast_choose_point;
swrast->choose_line = _swrast_choose_line;
swrast->choose_triangle = _swrast_choose_triangle;
swrast->choose_quad = _swrast_choose_quad;
swrast->invalidate_point = _SWRAST_NEW_POINT;
swrast->invalidate_line = _SWRAST_NEW_LINE;
swrast->invalidate_triangle = _SWRAST_NEW_TRIANGLE;
swrast->invalidate_quad = _SWRAST_NEW_QUAD;
swrast->Point = _swrast_validate_point;
swrast->Line = _swrast_validate_line;
swrast->Triangle = _swrast_validate_triangle;
swrast->Quad = _swrast_validate_quad;
swrast->InvalidateState = _swrast_sleep;
swrast->BlendFunc = _swrast_validate_blend_func;
for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
swrast->TextureSample[i] = _swrast_validate_texture_sample;
ctx->swrast_context = swrast;
return GL_TRUE;
}
void
_swrast_destroy_context( GLcontext *ctx )
_swrast_DestroyContext( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
FREE( swrast->PB );
FREE( swrast );
ctx->swrast_context = 0;
}

145
src/mesa/swrast/s_context.h Normal file
View file

@ -0,0 +1,145 @@
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999 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"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* 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 <keithw@valinux.com>
*/
#ifndef S_CONTEXT_H
#define S_CONTEXT_H
#include "types.h"
#include "swrast.h"
/*
* For texture sampling:
*/
typedef void (*TextureSampleFunc)( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] );
/*
* Blending function
*/
#ifdef USE_MMX_ASM
typedef void (_ASMAPIP blend_func)( GLcontext *ctx, GLuint n,
const GLubyte mask[],
GLchan src[][4], CONST GLchan dst[][4] );
#else
typedef void (*blend_func)( GLcontext *ctx, GLuint n, const GLubyte mask[],
GLchan src[][4], CONST GLchan dst[][4] );
#endif
typedef void (*swrast_tri_func)( GLcontext *ctx,
SWvertex *, SWvertex *, SWvertex *);
typedef void (*swrast_line_func)( GLcontext *ctx, SWvertex *, SWvertex *);
typedef void (*swrast_point_func)( GLcontext *ctx, SWvertex *);
/*
* Bitmasks to indicate which rasterization options are enabled (RasterMask)
*/
#define ALPHATEST_BIT 0x001 /* Alpha-test pixels */
#define BLEND_BIT 0x002 /* Blend pixels */
#define DEPTH_BIT 0x004 /* Depth-test pixels */
#define FOG_BIT 0x008 /* Fog pixels */
#define LOGIC_OP_BIT 0x010 /* Apply logic op in software */
#define SCISSOR_BIT 0x020 /* Scissor pixels */
#define STENCIL_BIT 0x040 /* Stencil pixels */
#define MASKING_BIT 0x080 /* Do glColorMask or glIndexMask */
#define ALPHABUF_BIT 0x100 /* Using software alpha buffer */
#define WINCLIP_BIT 0x200 /* Clip pixels/primitives to window */
#define MULTI_DRAW_BIT 0x400 /* Write to more than one color- */
/* buffer or no buffers. */
#define OCCLUSION_BIT 0x800 /* GL_HP_occlusion_test enabled */
#define TEXTURE_BIT 0x1000 /* Texturing really enabled */
#define _SWRAST_NEW_RASTERMASK (_NEW_BUFFERS| \
_NEW_SCISSOR| \
_NEW_COLOR| \
_NEW_DEPTH| \
_NEW_FOG| \
_NEW_STENCIL| \
_NEW_TEXTURE| \
_NEW_VIEWPORT| \
_NEW_DEPTH)
typedef struct
{
GLuint NewState;
GLuint StateChanges;
GLuint _RasterMask;
GLuint _MinMagThresh[MAX_TEXTURE_UNITS];
struct pixel_buffer* PB;
GLuint StippleCounter; /* Line stipple counter */
/* Mechanism to allow driver (like X11) to register further
* software rasterization routines.
*/
void (*choose_point)( GLcontext * );
void (*choose_line)( GLcontext * );
void (*choose_triangle)( GLcontext * );
void (*choose_quad)( GLcontext * );
GLuint invalidate_point;
GLuint invalidate_line;
GLuint invalidate_triangle;
GLuint invalidate_quad;
/* Function pointers for dispatch behind public entrypoints.
*/
void (*InvalidateState)( GLcontext *ctx, GLuint new_state );
void (*Point)( GLcontext *ctx, SWvertex *v );
void (*Line)( GLcontext *ctx, SWvertex *v0, SWvertex *v1 );
void (*Triangle)( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2 );
void (*Quad)( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2,
SWvertex *v3);
/* Internal hooks, kept uptodate by the same mechanism as above.
*/
blend_func BlendFunc;
TextureSampleFunc TextureSample[MAX_TEXTURE_UNITS];
} SWcontext;
void
_swrast_validate_derived( GLcontext *ctx );
#define SWRAST_CONTEXT(ctx) ((SWcontext *)ctx->swrast_context)
#endif

View file

@ -1,4 +1,4 @@
/* $Id: s_copypix.c,v 1.2 2000/10/31 23:11:06 brianp Exp $ */
/* $Id: s_copypix.c,v 1.3 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -35,6 +35,7 @@
#include "mmath.h"
#include "pixel.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_imaging.h"
#include "s_pixeltex.h"
@ -81,7 +82,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLboolean changeBuffer;
GLchan *saveReadAlpha;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
const GLuint transferOps = ctx->ImageTransferState;
const GLuint transferOps = ctx->_ImageTransferState;
GLfloat *dest, *tmpImage, *convImage;
if (ctx->Depth.Test || ctx->Fog.Enabled) {
@ -94,7 +95,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
}
if (ctx->RasterMask == 0
if (SWRAST_CONTEXT(ctx)->_RasterMask == 0
&& !zoom
&& destx >= 0
&& destx + width <= ctx->DrawBuffer->Width) {
@ -231,7 +232,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
}
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
GLchan primary_rgba[MAX_WIDTH][4];
GLuint unit;
@ -284,7 +285,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLchan *saveReadAlpha;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
GLint overlapping;
const GLuint transferOps = ctx->ImageTransferState;
const GLuint transferOps = ctx->_ImageTransferState;
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty);
@ -316,7 +317,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
}
if (ctx->RasterMask == 0
if (SWRAST_CONTEXT(ctx)->_RasterMask == 0
&& !zoom
&& destx >= 0
&& destx + width <= ctx->DrawBuffer->Width) {
@ -461,7 +462,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
}
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
GLchan primary_rgba[MAX_WIDTH][4];
GLuint unit;
@ -817,6 +818,9 @@ _swrast_CopyPixels( GLcontext *ctx,
GLint destx, GLint desty,
GLenum type )
{
if (SWRAST_CONTEXT(ctx)->NewState)
_swrast_validate_derived( ctx );
if (type == GL_COLOR && ctx->Visual.RGBAflag) {
copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty );
}

View file

@ -1,4 +1,4 @@
/* $Id: s_depth.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_depth.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -31,6 +31,7 @@
#include "mem.h"
#include "s_depth.h"
#include "s_context.h"
#include "s_pb.h"

View file

@ -1,4 +1,4 @@
/* $Id: s_drawpix.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_drawpix.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -35,6 +35,7 @@
#include "mmath.h"
#include "pixel.h"
#include "s_context.h"
#include "s_pixeltex.h"
#include "s_span.h"
#include "s_stencil.h"
@ -110,8 +111,8 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
return GL_TRUE; /* no-op */
}
if ((ctx->RasterMask&(~(SCISSOR_BIT|WINCLIP_BIT)))==0
&& ctx->Texture.ReallyEnabled == 0
if ((SWRAST_CONTEXT(ctx)->_RasterMask&(~(SCISSOR_BIT|WINCLIP_BIT)))==0
&& ctx->Texture._ReallyEnabled == 0
&& unpack->Alignment == 1
&& !unpack->SwapBytes
&& !unpack->LsbFirst) {
@ -204,7 +205,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
*/
if (format == GL_RGBA && type == CHAN_TYPE
&& ctx->ImageTransferState==0) {
&& ctx->_ImageTransferState==0) {
if (ctx->Visual.RGBAflag) {
GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels) * 4;
@ -242,7 +243,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
return GL_TRUE;
}
else if (format == GL_RGB && type == CHAN_TYPE
&& ctx->ImageTransferState == 0) {
&& ctx->_ImageTransferState == 0) {
if (ctx->Visual.RGBAflag) {
GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels) * 3;
@ -279,7 +280,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
return GL_TRUE;
}
else if (format == GL_LUMINANCE && type == CHAN_TYPE
&& ctx->ImageTransferState==0) {
&& ctx->_ImageTransferState==0) {
if (ctx->Visual.RGBAflag) {
GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels);
@ -338,7 +339,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
return GL_TRUE;
}
else if (format == GL_LUMINANCE_ALPHA && type == CHAN_TYPE
&& ctx->ImageTransferState == 0) {
&& ctx->_ImageTransferState == 0) {
if (ctx->Visual.RGBAflag) {
GLchan *src = (GLchan *) pixels
+ (skipRows * rowLength + skipPixels)*2;
@ -448,7 +449,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
return GL_TRUE;
}
}
else if (ctx->ImageTransferState==0) {
else if (ctx->_ImageTransferState==0) {
/* write CI data to CI frame buffer */
GLint row;
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
@ -512,7 +513,7 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
_mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT, indexes,
type, source, &ctx->Unpack,
ctx->ImageTransferState);
ctx->_ImageTransferState);
if (zoom) {
gl_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, 0, indexes, desty);
}
@ -559,8 +560,8 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
_mesa_unpack_index_span(ctx, drawWidth, destType, values,
type, source, &ctx->Unpack,
ctx->ImageTransferState);
if (ctx->ImageTransferState & IMAGE_SHIFT_OFFSET_BIT) {
ctx->_ImageTransferState);
if (ctx->_ImageTransferState & IMAGE_SHIFT_OFFSET_BIT) {
_mesa_shift_and_offset_stencil( ctx, drawWidth, values );
}
if (ctx->Pixel.MapStencilFlag) {
@ -658,7 +659,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
const GLvoid *src = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
_mesa_unpack_depth_span( ctx, drawWidth, zspan, type, src,
&ctx->Unpack, ctx->ImageTransferState );
&ctx->Unpack, ctx->_ImageTransferState );
if (ctx->Visual.RGBAflag) {
if (zoom) {
gl_write_zoomed_rgba_span(ctx, width, x, y, zspan, 0,
@ -698,7 +699,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
GLdepth zspan[MAX_WIDTH];
GLboolean quickDraw;
GLfloat *convImage = NULL;
GLuint transferOps = ctx->ImageTransferState;
GLuint transferOps = ctx->_ImageTransferState;
if (!_mesa_is_legal_format_and_type(format, type)) {
gl_error(ctx, GL_INVALID_ENUM, "glDrawPixels(format or type)");
@ -720,7 +721,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
}
if (ctx->RasterMask == 0 && !zoom && x >= 0 && y >= 0
if (SWRAST_CONTEXT(ctx)->_RasterMask == 0 && !zoom && x >= 0 && y >= 0
&& x + width <= ctx->DrawBuffer->Width
&& y + height <= ctx->DrawBuffer->Height) {
quickDraw = GL_TRUE;
@ -799,7 +800,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
(ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink))
continue;
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
if (ctx->Texture._ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
GLchan primary_rgba[MAX_WIDTH][4];
GLuint unit;
@ -808,7 +809,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLchan));
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit].ReallyEnabled) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
_mesa_pixeltexgen(ctx, width, (const GLchan (*)[4]) rgba,
s, t, r, q);
gl_texture_pixels(ctx, unit, width, s, t, r, NULL,
@ -852,6 +853,9 @@ _swrast_DrawPixels( GLcontext *ctx,
{
(void) unpack;
if (SWRAST_CONTEXT(ctx)->NewState)
_swrast_validate_derived( ctx );
switch (format) {
case GL_STENCIL_INDEX:
draw_stencil_pixels( ctx, x, y, width, height, type, pixels );

View file

@ -0,0 +1,153 @@
/* $Id: s_feedback.c,v 1.1 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
*
* Copyright (C) 1999-2000 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"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* 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.
*/
#include "glheader.h"
#include "colormac.h"
#include "context.h"
#include "enums.h"
#include "feedback.h"
#include "macros.h"
#include "mmath.h"
#include "s_context.h"
#include "s_feedback.h"
#include "s_triangle.h"
#define FB_3D 0x01
#define FB_4D 0x02
#define FB_INDEX 0x04
#define FB_COLOR 0x08
#define FB_TEXTURE 0X10
static void feedback_vertex( GLcontext *ctx, SWvertex *v )
{
GLfloat win[4];
GLfloat color[4];
GLfloat tc[4];
GLuint texUnit = ctx->Texture.CurrentTransformUnit;
GLuint index;
win[0] = v->win[0];
win[1] = v->win[1];
win[2] = v->win[2] / ctx->Visual.DepthMaxF;
win[3] = 1.0 / v->win[3];
color[0] = CHAN_TO_FLOAT(v->color[0]);
color[1] = CHAN_TO_FLOAT(v->color[1]);
color[2] = CHAN_TO_FLOAT(v->color[2]);
color[3] = CHAN_TO_FLOAT(v->color[3]);
if (v->texcoord[texUnit][3] != 1.0 &&
v->texcoord[texUnit][3] != 0.0) {
GLfloat invq = 1.0F / v->texcoord[texUnit][3];
tc[0] = v->texcoord[texUnit][0] * invq;
tc[1] = v->texcoord[texUnit][1] * invq;
tc[2] = v->texcoord[texUnit][2] * invq;
tc[3] = v->texcoord[texUnit][3];
}
else {
COPY_4V(tc, v->texcoord[texUnit]);
}
index = v->index;
gl_feedback_vertex( ctx, win, color, index, tc );
}
/*
* Put triangle in feedback buffer.
*/
void gl_feedback_triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1,
SWvertex *v2)
{
if (gl_cull_triangle( ctx, v0, v1, v2 )) {
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POLYGON_TOKEN );
FEEDBACK_TOKEN( ctx, (GLfloat) 3 ); /* three vertices */
feedback_vertex( ctx, v0 );
feedback_vertex( ctx, v1 );
feedback_vertex( ctx, v2 );
}
}
void gl_feedback_line( GLcontext *ctx, SWvertex *v0, SWvertex *v1 )
{
GLenum token = GL_LINE_TOKEN;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (swrast->StippleCounter==0)
token = GL_LINE_RESET_TOKEN;
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) token );
feedback_vertex( ctx, v0 );
feedback_vertex( ctx, v1 );
swrast->StippleCounter++;
}
void gl_feedback_point( GLcontext *ctx, SWvertex *v )
{
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POINT_TOKEN );
feedback_vertex( ctx, v );
}
void gl_select_triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1,
SWvertex *v2)
{
if (gl_cull_triangle( ctx, v0, v1, v2 )) {
const GLfloat zs = 1.0F / ctx->Visual.DepthMaxF;
gl_update_hitflag( ctx, v0->win[2] * zs );
gl_update_hitflag( ctx, v1->win[2] * zs );
gl_update_hitflag( ctx, v2->win[2] * zs );
}
}
void gl_select_line( GLcontext *ctx, SWvertex *v0, SWvertex *v1 )
{
const GLfloat zs = 1.0F / ctx->Visual.DepthMaxF;
gl_update_hitflag( ctx, v0->win[2] * zs );
gl_update_hitflag( ctx, v1->win[2] * zs );
}
void gl_select_point( GLcontext *ctx, SWvertex *v )
{
const GLfloat zs = 1.0F / ctx->Visual.DepthMaxF;
gl_update_hitflag( ctx, v->win[2] * zs );
}

View file

@ -0,0 +1,47 @@
/* $Id: s_feedback.h,v 1.1 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
*
* Copyright (C) 1999 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"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* 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.
*/
#ifndef S_FEEDBACK_H
#define S_FEEDBACK_H
#include "types.h"
#include "swrast.h"
extern void gl_feedback_point( GLcontext *ctx, SWvertex *v );
extern void gl_feedback_line( GLcontext *ctx, SWvertex *v1, SWvertex *v2 );
extern void gl_feedback_triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1,
SWvertex *v2 );
extern void gl_select_point( GLcontext *ctx, SWvertex *v );
extern void gl_select_line( GLcontext *ctx, SWvertex *v1, SWvertex *v2 );
extern void gl_select_triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1,
SWvertex *v2 );
#endif

View file

@ -1,4 +1,4 @@
/* $Id: s_fog.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_fog.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -31,6 +31,7 @@
#include "macros.h"
#include "mmath.h"
#include "s_context.h"
#include "s_fog.h"
@ -105,8 +106,8 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx,
GLfloat d = ctx->ProjectionMatrix.m[14];
GLuint i;
GLfloat tz = ctx->Viewport.WindowMap.m[MAT_TZ];
GLfloat szInv = 1.0F / ctx->Viewport.WindowMap.m[MAT_SZ];
GLfloat tz = ctx->Viewport._WindowMap.m[MAT_TZ];
GLfloat szInv = 1.0F / ctx->Viewport._WindowMap.m[MAT_SZ];
switch (ctx->Fog.Mode) {
case GL_LINEAR:

View file

@ -1,4 +1,4 @@
/* $Id: s_imaging.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_imaging.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -36,6 +36,7 @@
#include "image.h"
#include "mmath.h"
#include "s_context.h"
#include "s_imaging.h"
#include "s_span.h"

View file

@ -1,4 +1,4 @@
/* $Id: s_lines.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_lines.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -26,13 +26,15 @@
#include "glheader.h"
#include "feedback.h"
#include "macros.h"
#include "mmath.h"
#include "vb.h"
#include "s_pb.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_lines.h"
#include "s_feedback.h"
@ -53,7 +55,6 @@
/*
* All line drawing functions have the same arguments:
* v1, v2 - indexes of first and second endpoints into vertex buffer arrays
* pv - provoking vertex: which vertex color/index to use for flat shading.
*/
@ -70,12 +71,15 @@
/* Flat, color index line */
static void flat_ci_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
PB_SET_INDEX( ctx->PB, ctx->VB->IndexPtr->data[pvert] );
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
PB_SET_INDEX( PB, vert0->index );
#define INTERP_XY 1
#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0, 0);
#define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, 0, 0);
#include "s_linetemp.h"
@ -86,13 +90,15 @@ static void flat_ci_line( GLcontext *ctx,
/* Flat, color index line with Z interpolation/testing */
static void flat_ci_z_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
PB_SET_INDEX( ctx->PB, ctx->VB->IndexPtr->data[pvert] );
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
PB_SET_INDEX( PB, vert0->index );
#define INTERP_XY 1
#define INTERP_Z 1
#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
#define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
#include "s_linetemp.h"
@ -103,13 +109,15 @@ static void flat_ci_z_line( GLcontext *ctx,
/* Flat-shaded, RGBA line */
static void flat_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
const GLchan *color = ctx->VB->ColorPtr->data[pvert];
PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
const GLchan *color = vert0->color;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
PB_SET_COLOR( PB, color[0], color[1], color[2], color[3] );
#define INTERP_XY 1
#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0, 0);
#define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, 0, 0);
#include "s_linetemp.h"
@ -120,14 +128,16 @@ static void flat_rgba_line( GLcontext *ctx,
/* Flat-shaded, RGBA line with Z interpolation/testing */
static void flat_rgba_z_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
const GLchan *color = ctx->VB->ColorPtr->data[pvert];
PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
const GLchan *color = vert0->color;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
PB_SET_COLOR( PB, color[0], color[1], color[2], color[3] );
#define INTERP_XY 1
#define INTERP_Z 1
#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
#define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
#include "s_linetemp.h"
@ -138,15 +148,16 @@ static void flat_rgba_z_line( GLcontext *ctx,
/* Smooth shaded, color index line */
static void smooth_ci_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLuint *pbi = ctx->PB->index;
(void) pvert;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count = PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLuint *pbi = PB->index;
ctx->PB->mono = GL_FALSE;
PB->mono = GL_FALSE;
#define INTERP_XY 1
#define INTERP_INDEX 1
@ -159,7 +170,7 @@ static void smooth_ci_line( GLcontext *ctx,
#include "s_linetemp.h"
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
@ -167,16 +178,17 @@ static void smooth_ci_line( GLcontext *ctx,
/* Smooth shaded, color index line with Z interpolation/testing */
static void smooth_ci_z_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLuint *pbi = ctx->PB->index;
(void) pvert;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count = PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLdepth *pbz = PB->z;
GLuint *pbi = PB->index;
ctx->PB->mono = GL_FALSE;
PB->mono = GL_FALSE;
#define INTERP_XY 1
#define INTERP_Z 1
@ -191,7 +203,7 @@ static void smooth_ci_z_line( GLcontext *ctx,
#include "s_linetemp.h"
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
@ -199,15 +211,16 @@ static void smooth_ci_z_line( GLcontext *ctx,
/* Smooth-shaded, RGBA line */
static void smooth_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLchan (*pbrgba)[4] = ctx->PB->rgba;
(void) pvert;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count = PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLchan (*pbrgba)[4] = PB->rgba;
ctx->PB->mono = GL_FALSE;
PB->mono = GL_FALSE;
#define INTERP_XY 1
#define INTERP_RGB 1
@ -224,7 +237,7 @@ static void smooth_rgba_line( GLcontext *ctx,
#include "s_linetemp.h"
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
@ -232,18 +245,19 @@ static void smooth_rgba_line( GLcontext *ctx,
/* Smooth-shaded, RGBA line with Z interpolation/testing */
static void smooth_rgba_z_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfixed *pbfog = ctx->PB->fog;
GLchan (*pbrgba)[4] = ctx->PB->rgba;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count = PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLdepth *pbz = PB->z;
GLfixed *pbfog = PB->fog;
GLchan (*pbrgba)[4] = PB->rgba;
(void) pvert;
ctx->PB->mono = GL_FALSE;
PB->mono = GL_FALSE;
#define INTERP_XY 1
#define INTERP_Z 1
@ -263,33 +277,34 @@ static void smooth_rgba_z_line( GLcontext *ctx,
#include "s_linetemp.h"
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
#define CHECK_FULL(count) \
if (count >= PB_SIZE-MAX_WIDTH) { \
ctx->PB->count = count; \
PB->count = count; \
gl_flush_pb(ctx); \
count = ctx->PB->count; \
count = PB->count; \
}
/* Smooth shaded, color index, any width, maybe stippled */
static void general_smooth_ci_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfixed *pbfog = ctx->PB->fog;
GLuint *pbi = ctx->PB->index;
(void) pvert;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count = PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLdepth *pbz = PB->z;
GLfixed *pbfog = PB->fog;
GLuint *pbi = PB->index;
ctx->PB->mono = GL_FALSE;
PB->mono = GL_FALSE;
if (ctx->Line.StippleFlag) {
/* stippled */
@ -351,22 +366,24 @@ static void general_smooth_ci_line( GLcontext *ctx,
}
}
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
/* Flat shaded, color index, any width, maybe stippled */
static void general_flat_ci_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfixed *pbfog = ctx->PB->fog;
PB_SET_INDEX( ctx->PB, ctx->VB->IndexPtr->data[pvert] );
count = ctx->PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLdepth *pbz = PB->z;
GLfixed *pbfog = PB->fog;
PB_SET_INDEX( PB, vert0->index );
count = PB->count;
if (ctx->Line.StippleFlag) {
/* stippled, any width */
@ -421,25 +438,25 @@ static void general_flat_ci_line( GLcontext *ctx,
}
}
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
static void general_smooth_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert)
SWvertex *vert0,
SWvertex *vert1 )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfixed *pbfog = ctx->PB->fog;
GLchan (*pbrgba)[4] = ctx->PB->rgba;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count = PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLdepth *pbz = PB->z;
GLfixed *pbfog = PB->fog;
GLchan (*pbrgba)[4] = PB->rgba;
(void) pvert;
ctx->PB->mono = GL_FALSE;
PB->mono = GL_FALSE;
if (ctx->Line.StippleFlag) {
/* stippled */
@ -524,16 +541,18 @@ static void general_smooth_rgba_line( GLcontext *ctx,
}
}
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
static void general_flat_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
const GLchan *color = ctx->VB->ColorPtr->data[pvert];
PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
const GLchan *color = vert0->color;
PB_SET_COLOR( PB, color[0], color[1], color[2], color[3] );
if (ctx->Line.StippleFlag) {
/* stippled */
@ -541,7 +560,7 @@ static void general_flat_rgba_line( GLcontext *ctx,
#define INTERP_Z 1
#define WIDE 1
#define STIPPLE 1
#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
#define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
#include "s_linetemp.h"
}
else {
@ -550,10 +569,10 @@ static void general_flat_rgba_line( GLcontext *ctx,
/* special case: unstippled and width=2 */
#define INTERP_XY 1
#define INTERP_Z 1
#define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0); \
PB_WRITE_PIXEL(ctx->PB, X, Y+1, Z, fog0);
#define YMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0); \
PB_WRITE_PIXEL(ctx->PB, X+1, Y, Z, fog0);
#define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0); \
PB_WRITE_PIXEL(PB, X, Y+1, Z, fog0);
#define YMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0); \
PB_WRITE_PIXEL(PB, X+1, Y, Z, fog0);
#include "s_linetemp.h"
}
else {
@ -561,7 +580,7 @@ static void general_flat_rgba_line( GLcontext *ctx,
#define INTERP_XY 1
#define INTERP_Z 1
#define WIDE 1
#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
#define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
#include "s_linetemp.h"
}
}
@ -572,19 +591,21 @@ static void general_flat_rgba_line( GLcontext *ctx,
/* Flat-shaded, textured, any width, maybe stippled */
static void flat_textured_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pv )
SWvertex *vert0,
SWvertex *vert1 )
{
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfixed *pbfog = ctx->PB->fog;
GLfloat *pbs = ctx->PB->s[0];
GLfloat *pbt = ctx->PB->t[0];
GLfloat *pbu = ctx->PB->u[0];
GLchan *color = ctx->VB->ColorPtr->data[pv];
PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
count = ctx->PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLdepth *pbz = PB->z;
GLfixed *pbfog = PB->fog;
GLfloat *pbs = PB->s[0];
GLfloat *pbt = PB->t[0];
GLfloat *pbu = PB->u[0];
GLchan *color = vert0->color;
PB_SET_COLOR( PB, color[0], color[1], color[2], color[3] );
count = PB->count;
if (ctx->Line.StippleFlag) {
/* stippled */
@ -628,7 +649,7 @@ static void flat_textured_line( GLcontext *ctx,
#include "s_linetemp.h"
}
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
@ -636,20 +657,21 @@ static void flat_textured_line( GLcontext *ctx,
/* Smooth-shaded, textured, any width, maybe stippled */
static void smooth_textured_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfixed *pbfog = ctx->PB->fog;
GLfloat *pbs = ctx->PB->s[0];
GLfloat *pbt = ctx->PB->t[0];
GLfloat *pbu = ctx->PB->u[0];
GLchan (*pbrgba)[4] = ctx->PB->rgba;
(void) pvert;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count = PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLdepth *pbz = PB->z;
GLfixed *pbfog = PB->fog;
GLfloat *pbs = PB->s[0];
GLfloat *pbt = PB->t[0];
GLfloat *pbu = PB->u[0];
GLchan (*pbrgba)[4] = PB->rgba;
ctx->PB->mono = GL_FALSE;
PB->mono = GL_FALSE;
if (ctx->Line.StippleFlag) {
/* stippled */
@ -705,7 +727,7 @@ static void smooth_textured_line( GLcontext *ctx,
#include "s_linetemp.h"
}
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
@ -714,19 +736,19 @@ static void smooth_textured_line( GLcontext *ctx,
* color interpolation.
*/
static void smooth_multitextured_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfixed *pbfog = ctx->PB->fog;
GLchan (*pbrgba)[4] = ctx->PB->rgba;
GLchan (*pbspec)[3] = ctx->PB->spec;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count = PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLdepth *pbz = PB->z;
GLfixed *pbfog = PB->fog;
GLchan (*pbrgba)[4] = PB->rgba;
GLchan (*pbspec)[3] = PB->spec;
(void) pvert;
ctx->PB->mono = GL_FALSE;
PB->mono = GL_FALSE;
if (ctx->Line.StippleFlag) {
/* stippled */
@ -753,11 +775,11 @@ static void smooth_multitextured_line( GLcontext *ctx,
pbspec[count][GCOMP] = FixedToInt(sg0); \
pbspec[count][BCOMP] = FixedToInt(sb0); \
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
if (ctx->Texture.Unit[u].ReallyEnabled) { \
ctx->PB->s[u][0] = fragTexcoord[u][0]; \
ctx->PB->s[u][1] = fragTexcoord[u][1]; \
ctx->PB->s[u][2] = fragTexcoord[u][2]; \
ctx->PB->s[u][3] = fragTexcoord[u][3]; \
if (ctx->Texture.Unit[u]._ReallyEnabled) { \
PB->s[u][0] = fragTexcoord[u][0]; \
PB->s[u][1] = fragTexcoord[u][1]; \
PB->s[u][2] = fragTexcoord[u][2]; \
PB->s[u][3] = fragTexcoord[u][3]; \
} \
} \
count++; \
@ -789,11 +811,11 @@ static void smooth_multitextured_line( GLcontext *ctx,
pbspec[count][GCOMP] = FixedToInt(sg0); \
pbspec[count][BCOMP] = FixedToInt(sb0); \
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
if (ctx->Texture.Unit[u].ReallyEnabled) { \
ctx->PB->s[u][0] = fragTexcoord[u][0]; \
ctx->PB->s[u][1] = fragTexcoord[u][1]; \
ctx->PB->s[u][2] = fragTexcoord[u][2]; \
ctx->PB->s[u][3] = fragTexcoord[u][3]; \
if (ctx->Texture.Unit[u]._ReallyEnabled) { \
PB->s[u][0] = fragTexcoord[u][0]; \
PB->s[u][1] = fragTexcoord[u][1]; \
PB->s[u][2] = fragTexcoord[u][2]; \
PB->s[u][3] = fragTexcoord[u][3]; \
} \
} \
count++; \
@ -802,7 +824,7 @@ static void smooth_multitextured_line( GLcontext *ctx,
#include "s_linetemp.h"
}
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
@ -811,23 +833,23 @@ static void smooth_multitextured_line( GLcontext *ctx,
* color interpolation.
*/
static void flat_multitextured_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
GLint count = ctx->PB->count;
GLint *pbx = ctx->PB->x;
GLint *pby = ctx->PB->y;
GLdepth *pbz = ctx->PB->z;
GLfixed *pbfog = ctx->PB->fog;
GLchan (*pbrgba)[4] = ctx->PB->rgba;
GLchan (*pbspec)[3] = ctx->PB->spec;
GLchan *color = ctx->VB->ColorPtr->data[pvert];
GLchan sRed = ctx->VB->SecondaryColorPtr->data ? ctx->VB->SecondaryColorPtr->data[pvert][0] : 0;
GLchan sGreen = ctx->VB->SecondaryColorPtr->data ? ctx->VB->SecondaryColorPtr->data[pvert][1] : 0;
GLchan sBlue = ctx->VB->SecondaryColorPtr->data ? ctx->VB->SecondaryColorPtr->data[pvert][2] : 0;
struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
GLint count = PB->count;
GLint *pbx = PB->x;
GLint *pby = PB->y;
GLdepth *pbz = PB->z;
GLfixed *pbfog = PB->fog;
GLchan (*pbrgba)[4] = PB->rgba;
GLchan (*pbspec)[3] = PB->spec;
GLchan *color = vert0->color;
GLchan sRed = vert0->specular[0];
GLchan sGreen = vert0->specular[1];
GLchan sBlue = vert0->specular[2];
(void) pvert;
ctx->PB->mono = GL_FALSE;
PB->mono = GL_FALSE;
if (ctx->Line.StippleFlag) {
/* stippled */
@ -852,11 +874,11 @@ static void flat_multitextured_line( GLcontext *ctx,
pbspec[count][GCOMP] = sGreen; \
pbspec[count][BCOMP] = sBlue; \
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
if (ctx->Texture.Unit[u].ReallyEnabled) { \
ctx->PB->s[u][0] = fragTexcoord[u][0]; \
ctx->PB->s[u][1] = fragTexcoord[u][1]; \
ctx->PB->s[u][2] = fragTexcoord[u][2]; \
ctx->PB->s[u][3] = fragTexcoord[u][3]; \
if (ctx->Texture.Unit[u]._ReallyEnabled) { \
PB->s[u][0] = fragTexcoord[u][0]; \
PB->s[u][1] = fragTexcoord[u][1]; \
PB->s[u][2] = fragTexcoord[u][2]; \
PB->s[u][3] = fragTexcoord[u][3]; \
} \
} \
count++; \
@ -886,11 +908,11 @@ static void flat_multitextured_line( GLcontext *ctx,
pbspec[count][GCOMP] = sGreen; \
pbspec[count][BCOMP] = sBlue; \
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
if (ctx->Texture.Unit[u].ReallyEnabled) { \
ctx->PB->s[u][0] = fragTexcoord[u][0]; \
ctx->PB->s[u][1] = fragTexcoord[u][1]; \
ctx->PB->s[u][2] = fragTexcoord[u][2]; \
ctx->PB->s[u][3] = fragTexcoord[u][3]; \
if (ctx->Texture.Unit[u]._ReallyEnabled) { \
PB->s[u][0] = fragTexcoord[u][0]; \
PB->s[u][1] = fragTexcoord[u][1]; \
PB->s[u][2] = fragTexcoord[u][2]; \
PB->s[u][3] = fragTexcoord[u][3]; \
} \
} \
count++; \
@ -899,7 +921,7 @@ static void flat_multitextured_line( GLcontext *ctx,
#include "s_linetemp.h"
}
ctx->PB->count = count;
PB->count = count;
gl_flush_pb(ctx);
}
@ -914,7 +936,8 @@ static void flat_multitextured_line( GLcontext *ctx,
* to the specification.
*/
static void aa_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
#define INTERP_RGBA 1
#define PLOT(x, y) \
@ -933,7 +956,8 @@ static void aa_rgba_line( GLcontext *ctx,
* to the specification.
*/
static void aa_tex_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
#define INTERP_RGBA 1
#define INTERP_TEX 1
@ -955,7 +979,8 @@ static void aa_tex_rgba_line( GLcontext *ctx,
* to the specification.
*/
static void aa_multitex_rgba_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
#define INTERP_RGBA 1
#define INTERP_SPEC 1
@ -974,7 +999,8 @@ static void aa_multitex_rgba_line( GLcontext *ctx,
* Antialiased CI line. Same comments for RGBA antialiased lines apply.
*/
static void aa_ci_line( GLcontext *ctx,
GLuint vert0, GLuint vert1, GLuint pvert )
SWvertex *vert0,
SWvertex *vert1 )
{
#define INTERP_INDEX 1
#define PLOT(x, y) \
@ -985,68 +1011,56 @@ static void aa_ci_line( GLcontext *ctx,
}
/*
* Null rasterizer for measuring transformation speed.
*/
static void null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
{
(void) ctx;
(void) v1;
(void) v2;
(void) pv;
}
#ifdef DEBUG
void
_mesa_print_line_function(GLcontext *ctx)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
printf("Line Func == ");
if (ctx->Driver.LineFunc == flat_ci_line)
if (swrast->Line == flat_ci_line)
printf("flat_ci_line\n");
else if (ctx->Driver.LineFunc == flat_ci_z_line)
else if (swrast->Line == flat_ci_z_line)
printf("flat_ci_z_line\n");
else if (ctx->Driver.LineFunc == flat_rgba_line)
else if (swrast->Line == flat_rgba_line)
printf("flat_rgba_line\n");
else if (ctx->Driver.LineFunc == flat_rgba_z_line)
else if (swrast->Line == flat_rgba_z_line)
printf("flat_rgba_z_line\n");
else if (ctx->Driver.LineFunc == smooth_ci_line)
else if (swrast->Line == smooth_ci_line)
printf("smooth_ci_line\n");
else if (ctx->Driver.LineFunc == smooth_ci_z_line)
else if (swrast->Line == smooth_ci_z_line)
printf("smooth_ci_z_line\n");
else if (ctx->Driver.LineFunc == smooth_rgba_line)
else if (swrast->Line == smooth_rgba_line)
printf("smooth_rgba_line\n");
else if (ctx->Driver.LineFunc == smooth_rgba_z_line)
else if (swrast->Line == smooth_rgba_z_line)
printf("smooth_rgba_z_line\n");
else if (ctx->Driver.LineFunc == general_smooth_ci_line)
else if (swrast->Line == general_smooth_ci_line)
printf("general_smooth_ci_line\n");
else if (ctx->Driver.LineFunc == general_flat_ci_line)
else if (swrast->Line == general_flat_ci_line)
printf("general_flat_ci_line\n");
else if (ctx->Driver.LineFunc == general_smooth_rgba_line)
else if (swrast->Line == general_smooth_rgba_line)
printf("general_smooth_rgba_line\n");
else if (ctx->Driver.LineFunc == general_flat_rgba_line)
else if (swrast->Line == general_flat_rgba_line)
printf("general_flat_rgba_line\n");
else if (ctx->Driver.LineFunc == flat_textured_line)
else if (swrast->Line == flat_textured_line)
printf("flat_textured_line\n");
else if (ctx->Driver.LineFunc == smooth_textured_line)
else if (swrast->Line == smooth_textured_line)
printf("smooth_textured_line\n");
else if (ctx->Driver.LineFunc == smooth_multitextured_line)
else if (swrast->Line == smooth_multitextured_line)
printf("smooth_multitextured_line\n");
else if (ctx->Driver.LineFunc == flat_multitextured_line)
else if (swrast->Line == flat_multitextured_line)
printf("flat_multitextured_line\n");
else if (ctx->Driver.LineFunc == aa_rgba_line)
else if (swrast->Line == aa_rgba_line)
printf("aa_rgba_line\n");
else if (ctx->Driver.LineFunc == aa_tex_rgba_line)
else if (swrast->Line == aa_tex_rgba_line)
printf("aa_tex_rgba_line\n");
else if (ctx->Driver.LineFunc == aa_multitex_rgba_line)
else if (swrast->Line == aa_multitex_rgba_line)
printf("aa_multitex_rgba_line\n");
else if (ctx->Driver.LineFunc == aa_ci_line)
else if (swrast->Line == aa_ci_line)
printf("aa_ci_line\n");
else if (ctx->Driver.LineFunc == null_line)
printf("null_line\n");
else
printf("Driver func %p\n", ctx->Driver.LineFunc);
printf("Driver func %p\n", swrast->Line);
}
#endif
@ -1060,56 +1074,49 @@ _mesa_print_line_function(GLcontext *ctx)
* tests to this code.
*/
void
_swrast_set_line_function( GLcontext *ctx )
_swrast_choose_line( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLboolean rgbmode = ctx->Visual.RGBAflag;
/* TODO: antialiased lines */
if (ctx->RenderMode==GL_RENDER) {
if (ctx->NoRaster) {
ctx->Driver.LineFunc = null_line;
return;
}
if (ctx->Driver.LineFunc) {
/* Device driver will draw lines. */
return;
}
if (ctx->Line.SmoothFlag) {
/* antialiased lines */
if (rgbmode) {
if (ctx->Texture.ReallyEnabled) {
if (ctx->Texture.MultiTextureEnabled
if (ctx->Texture._ReallyEnabled) {
if (ctx->Texture._MultiTextureEnabled
|| ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR
|| ctx->Fog.ColorSumEnabled)
/* Multitextured! */
ctx->Driver.LineFunc = aa_multitex_rgba_line;
swrast->Line = aa_multitex_rgba_line;
else
ctx->Driver.LineFunc = aa_tex_rgba_line;
swrast->Line = aa_tex_rgba_line;
} else {
ctx->Driver.LineFunc = aa_rgba_line;
swrast->Line = aa_rgba_line;
}
}
else {
ctx->Driver.LineFunc = aa_ci_line;
swrast->Line = aa_ci_line;
}
}
else if (ctx->Texture.ReallyEnabled) {
if (ctx->Texture.MultiTextureEnabled
else if (ctx->Texture._ReallyEnabled) {
if (ctx->Texture._MultiTextureEnabled
|| ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR
|| ctx->Fog.ColorSumEnabled) {
/* multi-texture and/or separate specular color */
if (ctx->Light.ShadeModel==GL_SMOOTH)
ctx->Driver.LineFunc = smooth_multitextured_line;
swrast->Line = smooth_multitextured_line;
else
ctx->Driver.LineFunc = flat_multitextured_line;
swrast->Line = flat_multitextured_line;
}
else {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
ctx->Driver.LineFunc = smooth_textured_line;
swrast->Line = smooth_textured_line;
}
else {
ctx->Driver.LineFunc = flat_textured_line;
swrast->Line = flat_textured_line;
}
}
}
@ -1117,15 +1124,15 @@ _swrast_set_line_function( GLcontext *ctx )
|| ctx->Line.SmoothFlag) {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
if (rgbmode)
ctx->Driver.LineFunc = general_smooth_rgba_line;
swrast->Line = general_smooth_rgba_line;
else
ctx->Driver.LineFunc = general_smooth_ci_line;
swrast->Line = general_smooth_ci_line;
}
else {
if (rgbmode)
ctx->Driver.LineFunc = general_flat_rgba_line;
swrast->Line = general_flat_rgba_line;
else
ctx->Driver.LineFunc = general_flat_ci_line;
swrast->Line = general_flat_ci_line;
}
}
else {
@ -1133,41 +1140,43 @@ _swrast_set_line_function( GLcontext *ctx )
/* Width==1, non-stippled, smooth-shaded */
if (ctx->Depth.Test || ctx->Fog.Enabled) {
if (rgbmode)
ctx->Driver.LineFunc = smooth_rgba_z_line;
swrast->Line = smooth_rgba_z_line;
else
ctx->Driver.LineFunc = smooth_ci_z_line;
swrast->Line = smooth_ci_z_line;
}
else {
if (rgbmode)
ctx->Driver.LineFunc = smooth_rgba_line;
swrast->Line = smooth_rgba_line;
else
ctx->Driver.LineFunc = smooth_ci_line;
swrast->Line = smooth_ci_line;
}
}
else {
/* Width==1, non-stippled, flat-shaded */
if (ctx->Depth.Test || ctx->Fog.Enabled) {
if (rgbmode)
ctx->Driver.LineFunc = flat_rgba_z_line;
swrast->Line = flat_rgba_z_line;
else
ctx->Driver.LineFunc = flat_ci_z_line;
swrast->Line = flat_ci_z_line;
}
else {
if (rgbmode)
ctx->Driver.LineFunc = flat_rgba_line;
swrast->Line = flat_rgba_line;
else
ctx->Driver.LineFunc = flat_ci_line;
swrast->Line = flat_ci_line;
}
}
}
}
else if (ctx->RenderMode==GL_FEEDBACK) {
ctx->Driver.LineFunc = gl_feedback_line;
swrast->Line = gl_feedback_line;
}
else {
/* GL_SELECT mode */
ctx->Driver.LineFunc = gl_select_line;
swrast->Line = gl_select_line;
}
/*_mesa_print_line_function(ctx);*/
}

10
src/mesa/swrast/s_lines.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef S_LINES_H
#define S_LINES_H
#include "types.h"
void
_swrast_choose_line( GLcontext *ctx );
#endif

View file

@ -1,4 +1,4 @@
/* $Id: s_linetemp.h,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_linetemp.h,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -73,13 +73,12 @@
*/
/*void line( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert )*/
/*void line( GLcontext *ctx, SWvertex *vert0, SWvertex *vert1 )*/
{
const struct vertex_buffer *VB = ctx->VB;
GLint x0 = (GLint) VB->Win.data[vert0][0];
GLint x1 = (GLint) VB->Win.data[vert1][0];
GLint y0 = (GLint) VB->Win.data[vert0][1];
GLint y1 = (GLint) VB->Win.data[vert1][1];
GLint x0 = (GLint) vert0->win[0];
GLint x1 = (GLint) vert1->win[0];
GLint y0 = (GLint) vert0->win[1];
GLint y1 = (GLint) vert1->win[1];
GLint dx, dy;
#ifdef INTERP_XY
GLint xstep, ystep;
@ -90,46 +89,46 @@
const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
# define FixedToDepth(F) ((F) >> fixedToDepthShift)
# ifdef DEPTH_TYPE
GLint zPtrXstep, zPtrYstep;
DEPTH_TYPE *zPtr;
GLint zPtrXstep, zPtrYstep;
DEPTH_TYPE *zPtr;
# endif
GLfixed fog0 = FloatToFixed(VB->FogCoordPtr->data[vert0]);
GLfixed dfog = FloatToFixed(VB->FogCoordPtr->data[vert1]) - fog0;
GLfixed fog0 = FloatToFixed(vert0->fog);
GLfixed dfog = FloatToFixed(vert1->fog) - fog0;
#endif
#ifdef INTERP_RGB
GLfixed r0 = IntToFixed(VB->ColorPtr->data[vert0][0]);
GLfixed dr = IntToFixed(VB->ColorPtr->data[vert1][0]) - r0;
GLfixed g0 = IntToFixed(VB->ColorPtr->data[vert0][1]);
GLfixed dg = IntToFixed(VB->ColorPtr->data[vert1][1]) - g0;
GLfixed b0 = IntToFixed(VB->ColorPtr->data[vert0][2]);
GLfixed db = IntToFixed(VB->ColorPtr->data[vert1][2]) - b0;
GLfixed r0 = IntToFixed(vert0->color[0]);
GLfixed dr = IntToFixed(vert1->color[0]) - r0;
GLfixed g0 = IntToFixed(vert0->color[1]);
GLfixed dg = IntToFixed(vert1->color[1]) - g0;
GLfixed b0 = IntToFixed(vert0->color[2]);
GLfixed db = IntToFixed(vert1->color[2]) - b0;
#endif
#ifdef INTERP_SPEC
GLfixed sr0 = VB->SecondaryColorPtr->data ? IntToFixed(VB->SecondaryColorPtr->data[vert0][0]) : 0;
GLfixed dsr = VB->SecondaryColorPtr->data ? IntToFixed(VB->SecondaryColorPtr->data[vert1][0]) - sr0 : 0;
GLfixed sg0 = VB->SecondaryColorPtr->data ? IntToFixed(VB->SecondaryColorPtr->data[vert0][1]) : 0;
GLfixed dsg = VB->SecondaryColorPtr->data ? IntToFixed(VB->SecondaryColorPtr->data[vert1][1]) - sg0 : 0;
GLfixed sb0 = VB->SecondaryColorPtr->data ? IntToFixed(VB->SecondaryColorPtr->data[vert0][2]) : 0;
GLfixed dsb = VB->SecondaryColorPtr->data ? IntToFixed(VB->SecondaryColorPtr->data[vert1][2]) - sb0 : 0;
GLfixed sr0 = IntToFixed(vert0->specular[0]);
GLfixed dsr = IntToFixed(vert1->specular[0]) - sr0;
GLfixed sg0 = IntToFixed(vert0->specular[1]);
GLfixed dsg = IntToFixed(vert1->specular[1]) - sg0;
GLfixed sb0 = IntToFixed(vert0->specular[2]);
GLfixed dsb = IntToFixed(vert1->specular[2]) - sb0;
#endif
#ifdef INTERP_ALPHA
GLfixed a0 = IntToFixed(VB->ColorPtr->data[vert0][3]);
GLfixed da = IntToFixed(VB->ColorPtr->data[vert1][3]) - a0;
GLfixed a0 = IntToFixed(vert0->color[3]);
GLfixed da = IntToFixed(vert1->color[3]) - a0;
#endif
#ifdef INTERP_INDEX
GLint i0 = VB->IndexPtr->data[vert0] << 8;
GLint di = (GLint) (VB->IndexPtr->data[vert1] << 8) - i0;
GLint i0 = vert0->index << 8;
GLint di = (GLint) (vert1->index << 8) - i0;
#endif
#ifdef INTERP_TEX
const GLfloat invw0 = VB->Win.data[vert0][3];
const GLfloat invw1 = VB->Win.data[vert1][3];
const GLfloat invw0 = vert0->win[3];
const GLfloat invw1 = vert1->win[3];
GLfloat tex[4];
GLfloat dtex[4];
GLfloat fragTexcoord[4];
#endif
#ifdef INTERP_MULTITEX
const GLfloat invw0 = VB->Win.data[vert0][3];
const GLfloat invw1 = VB->Win.data[vert1][3];
const GLfloat invw0 = vert0->win[3];
const GLfloat invw1 = vert1->win[3];
GLfloat tex[MAX_TEXTURE_UNITS][4];
GLfloat dtex[MAX_TEXTURE_UNITS][4];
GLfloat fragTexcoord[MAX_TEXTURE_UNITS][4];
@ -138,6 +137,9 @@
PIXEL_TYPE *pixelPtr;
GLint pixelXstep, pixelYstep;
#endif
#ifdef STIPPLE
SWcontext *swrast = SWRAST_CONTEXT(ctx);
#endif
#ifdef WIDE
/* for wide lines, draw all X in [x+min, x+max] or Y in [y+min, y+max] */
GLint width, min, max;
@ -147,66 +149,30 @@
#endif
#ifdef INTERP_TEX
{
tex[0] = invw0 * VB->TexCoordPtr[0]->data[vert0][0];
dtex[0] = invw1 * VB->TexCoordPtr[0]->data[vert1][0] - tex[0];
if (VB->TexCoordPtr[0]->size > 1) {
tex[1] = invw0 * VB->TexCoordPtr[0]->data[vert0][1];
dtex[1] = invw1 * VB->TexCoordPtr[0]->data[vert1][1] - tex[1];
}
else {
tex[1] = 0.0;
dtex[1] = 0.0;
}
if (VB->TexCoordPtr[0]->size > 2) {
tex[2] = invw0 * VB->TexCoordPtr[0]->data[vert0][2];
dtex[2] = invw1 * VB->TexCoordPtr[0]->data[vert1][2] - tex[2];
}
else {
tex[2] = 0.0;
dtex[2] = 0.0;
}
if (VB->TexCoordPtr[0]->size > 3) {
tex[3] = invw0 * VB->TexCoordPtr[0]->data[vert0][3];
dtex[3] = invw1 * VB->TexCoordPtr[0]->data[vert1][3] - tex[3];
}
else {
tex[3] = invw0;
dtex[3] = invw1 - invw0;
}
tex[0] = invw0 * vert0->texcoord[0][0];
dtex[0] = invw1 * vert1->texcoord[0][0] - tex[0];
tex[1] = invw0 * vert0->texcoord[0][1];
dtex[1] = invw1 * vert1->texcoord[0][1] - tex[1];
tex[2] = invw0 * vert0->texcoord[0][2];
dtex[2] = invw1 * vert1->texcoord[0][2] - tex[2];
tex[3] = invw0 * vert0->texcoord[0][3];
dtex[3] = invw1 * vert1->texcoord[0][3] - tex[3];
}
#endif
#ifdef INTERP_MULTITEX
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
tex[u][0] = invw0 * VB->TexCoordPtr[u]->data[vert0][0];
dtex[u][0] = invw1 * VB->TexCoordPtr[u]->data[vert1][0] - tex[u][0];
if (VB->TexCoordPtr[u]->size > 1) {
tex[u][1] = invw0 * VB->TexCoordPtr[u]->data[vert0][1];
dtex[u][1] = invw1 * VB->TexCoordPtr[u]->data[vert1][1] - tex[u][1];
}
else {
tex[u][1] = 0.0;
dtex[u][1] = 0.0;
}
if (VB->TexCoordPtr[u]->size > 2) {
tex[u][2] = invw0 * VB->TexCoordPtr[u]->data[vert0][2];
dtex[u][2] = invw1 * VB->TexCoordPtr[u]->data[vert1][2] - tex[u][2];
}
else {
tex[u][2] = 0.0;
dtex[u][2] = 0.0;
}
if (VB->TexCoordPtr[u]->size > 3) {
tex[u][3] = invw0 * VB->TexCoordPtr[u]->data[vert0][3];
dtex[u][3] = invw1 * VB->TexCoordPtr[u]->data[vert1][3] - tex[u][3];
}
else {
tex[u][3] = invw0;
dtex[u][3] = invw1 - invw0;
}
}
if (ctx->Texture.Unit[u]._ReallyEnabled) {
tex[u][0] = invw0 * vert0->texcoord[u][0];
dtex[u][0] = invw1 * vert1->texcoord[u][0] - tex[u][0];
tex[u][1] = invw0 * vert0->texcoord[u][1];
dtex[u][1] = invw1 * vert1->texcoord[u][1] - tex[u][1];
tex[u][2] = invw0 * vert0->texcoord[u][2];
dtex[u][2] = invw1 * vert1->texcoord[u][2] - tex[u][2];
tex[u][3] = invw0 * vert0->texcoord[u][3];
dtex[u][3] = invw1 * vert1->texcoord[u][3] - tex[u][3];
}
}
}
#endif
@ -255,12 +221,12 @@
zPtr = (DEPTH_TYPE *) _mesa_zbuffer_address(ctx, x0, y0);
# endif
if (depthBits <= 16) {
z0 = FloatToFixed(VB->Win.data[vert0][2] + ctx->LineZoffset);
z1 = FloatToFixed(VB->Win.data[vert1][2] + ctx->LineZoffset);
z0 = FloatToFixed(vert0->win[2]);
z1 = FloatToFixed(vert1->win[2]);
}
else {
z0 = (int) VB->Win.data[vert0][2] + ctx->LineZoffset;
z1 = (int) VB->Win.data[vert1][2] + ctx->LineZoffset;
z0 = (int) vert0->win[2];
z1 = (int) vert1->win[2];
}
#endif
#ifdef PIXEL_ADDRESS
@ -359,7 +325,7 @@
const GLfloat invDx = 1.0F / (GLfloat) dx;
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
dtex[u][0] *= invDx;
dtex[u][1] *= invDx;
dtex[u][2] *= invDx;
@ -372,7 +338,7 @@
for (i=0;i<dx;i++) {
#ifdef STIPPLE
GLushort m;
m = 1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf);
m = 1 << ((swrast->StippleCounter/ctx->Line.StippleFactor) & 0xf);
if (ctx->Line.StipplePattern & m) {
#endif
#ifdef INTERP_Z
@ -393,7 +359,7 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
const GLfloat invQ = 1.0F / tex[u][3];
fragTexcoord[u][0] = tex[u][0] * invQ;
fragTexcoord[u][1] = tex[u][1] * invQ;
@ -420,7 +386,7 @@
#endif /*WIDE*/
#ifdef STIPPLE
}
ctx->StippleCounter++;
swrast->StippleCounter++;
#endif
#ifdef INTERP_XY
x0 += xstep;
@ -458,7 +424,7 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
tex[u][0] += dtex[u][0];
tex[u][1] += dtex[u][1];
tex[u][2] += dtex[u][2];
@ -528,7 +494,7 @@
const GLfloat invDy = 1.0F / (GLfloat) dy;
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
dtex[u][0] *= invDy;
dtex[u][1] *= invDy;
dtex[u][2] *= invDy;
@ -541,7 +507,7 @@
for (i=0;i<dy;i++) {
#ifdef STIPPLE
GLushort m;
m = 1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf);
m = 1 << ((swrast->StippleCounter/ctx->Line.StippleFactor) & 0xf);
if (ctx->Line.StipplePattern & m) {
#endif
#ifdef INTERP_Z
@ -562,7 +528,7 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
const GLfloat invQ = 1.0F / tex[u][3];
fragTexcoord[u][0] = tex[u][0] * invQ;
fragTexcoord[u][1] = tex[u][1] * invQ;
@ -589,7 +555,7 @@
#endif /*WIDE*/
#ifdef STIPPLE
}
ctx->StippleCounter++;
swrast->StippleCounter++;
#endif
#ifdef INTERP_XY
y0 += ystep;
@ -627,7 +593,7 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
tex[u][0] += dtex[u][0];
tex[u][1] += dtex[u][1];
tex[u][2] += dtex[u][2];

View file

@ -1,4 +1,4 @@
/* $Id: s_logic.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_logic.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -30,6 +30,7 @@
#include "macros.h"
#include "s_alphabuf.h"
#include "s_context.h"
#include "s_logic.h"
#include "s_pb.h"
#include "s_span.h"
@ -353,7 +354,7 @@ _mesa_logicop_rgba_pixels( GLcontext *ctx,
{
GLchan dest[PB_SIZE][4];
(*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
rgba_logicop( ctx, n, mask, (GLuint *) rgba, (const GLuint *) dest );

View file

@ -1,4 +1,4 @@
/* $Id: s_masking.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_masking.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -35,6 +35,7 @@
#include "macros.h"
#include "s_alphabuf.h"
#include "s_context.h"
#include "s_masking.h"
#include "s_pb.h"
#include "s_span.h"
@ -101,7 +102,7 @@ _mesa_mask_rgba_pixels( GLcontext *ctx,
GLuint *dest32 = (GLuint *) dest;
(*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}
@ -117,7 +118,7 @@ _mesa_mask_rgba_pixels( GLcontext *ctx,
const GLint aMask = ctx->Color.ColorMask[ACOMP];
(*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (SWRAST_CONTEXT(ctx)->_RasterMask & ALPHABUF_BIT) {
_mesa_read_alpha_pixels( ctx, n, x, y, dest, mask );
}

View file

@ -1,4 +1,4 @@
/* $Id: s_pixeltex.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_pixeltex.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -36,6 +36,7 @@
#include "glheader.h"
#include "colormac.h"
#include "s_context.h"
#include "s_pixeltex.h"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
#ifndef S_POINTS_H
#define S_POINTS_H
#include "types.h"
void
_swrast_choose_point( GLcontext *ctx );
#endif

View file

@ -1,4 +1,4 @@
/* $Id: s_readpix.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_readpix.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -36,6 +36,7 @@
#include "pixel.h"
#include "s_alphabuf.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_span.h"
#include "s_stencil.h"
@ -497,7 +498,7 @@ read_fast_rgba_pixels( GLcontext *ctx,
const struct gl_pixelstore_attrib *packing )
{
/* can't do scale, bias, mapping, etc */
if (ctx->ImageTransferState)
if (ctx->_ImageTransferState)
return GL_FALSE;
/* can't do fancy pixel packing */
@ -636,7 +637,7 @@ static void read_rgba_pixels( GLcontext *ctx,
}
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
const GLuint transferOps = ctx->ImageTransferState;
const GLuint transferOps = ctx->_ImageTransferState;
GLfloat *dest, *src, *tmpImage, *convImage;
GLint row;
@ -717,7 +718,7 @@ static void read_rgba_pixels( GLcontext *ctx,
format, type, 0, row, 0);
_mesa_pack_rgba_span(ctx, readWidth, (const GLchan (*)[4]) rgba,
format, type, dst, packing,
ctx->ImageTransferState);
ctx->_ImageTransferState);
}
}
@ -735,6 +736,9 @@ _swrast_ReadPixels( GLcontext *ctx,
{
(void) pack;
if (SWRAST_CONTEXT(ctx)->NewState)
_swrast_validate_derived( ctx );
switch (format) {
case GL_COLOR_INDEX:
read_index_pixels(ctx, x, y, width, height, type, pixels, &ctx->Pack);

View file

@ -1,4 +1,4 @@
/* $Id: s_span.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_span.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -39,6 +39,7 @@
#include "s_alpha.h"
#include "s_alphabuf.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_fog.h"
#include "s_logic.h"
@ -182,18 +183,19 @@ void gl_write_index_span( GLcontext *ctx,
GLubyte mask[MAX_WIDTH];
GLuint indexBackup[MAX_WIDTH];
GLuint *index; /* points to indexIn or indexBackup */
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* init mask to 1's (all pixels are to be written) */
MEMSET(mask, 1, n);
if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span(ctx,n,x,y,mask)==0) {
return;
}
}
if ((primitive==GL_BITMAP && (ctx->RasterMask & modBits))
|| (ctx->RasterMask & MULTI_DRAW_BIT)) {
if ((primitive==GL_BITMAP && (swrast->_RasterMask & modBits))
|| (swrast->_RasterMask & MULTI_DRAW_BIT)) {
/* Make copy of color indexes */
MEMCPY( indexBackup, indexIn, n * sizeof(GLuint) );
index = indexBackup;
@ -236,7 +238,7 @@ void gl_write_index_span( GLcontext *ctx,
/* if we get here, something passed the depth test */
ctx->OcclusionResult = GL_TRUE;
if (ctx->RasterMask & MULTI_DRAW_BIT) {
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
/* draw to zero or two or more buffers */
multi_write_index_span( ctx, n, x, y, index, mask );
}
@ -267,13 +269,14 @@ void gl_write_monoindex_span( GLcontext *ctx,
const GLfixed fog[],
GLuint index, GLenum primitive )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLubyte mask[MAX_WIDTH];
GLuint i;
/* init mask to 1's (all pixels are to be written) */
MEMSET(mask, 1, n);
if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span( ctx, n, x, y, mask)==0) {
return;
}
@ -330,7 +333,7 @@ void gl_write_monoindex_span( GLcontext *ctx,
_mesa_logicop_ci_span( ctx, n, x, y, indexes, mask );
}
if (ctx->RasterMask & MULTI_DRAW_BIT) {
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
/* draw to zero or two or more buffers */
multi_write_index_span( ctx, n, x, y, indexes, mask );
}
@ -352,7 +355,7 @@ void gl_write_monoindex_span( GLcontext *ctx,
/* same color index for all pixels */
ASSERT(!ctx->Color.IndexLogicOpEnabled);
ASSERT(ctx->Color.IndexMask == 0xffffffff);
if (ctx->RasterMask & MULTI_DRAW_BIT) {
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
/* draw to zero or two or more buffers */
GLuint indexes[MAX_WIDTH];
for (i=0;i<n;i++)
@ -377,6 +380,7 @@ static void multi_write_rgba_span( GLcontext *ctx, GLuint n,
{
const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
GLuint bufferBit;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (ctx->Color.DrawBuffer == GL_NONE)
return;
@ -422,7 +426,7 @@ static void multi_write_rgba_span( GLcontext *ctx, GLuint n,
(*ctx->Driver.WriteRGBASpan)( ctx, n, x, y,
(const GLchan (*)[4]) rgbaTmp, mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, n, x, y,
(const GLchan (*)[4])rgbaTmp, mask );
}
@ -448,19 +452,20 @@ void gl_write_rgba_span( GLcontext *ctx,
GLchan rgbaBackup[MAX_WIDTH][4];
GLchan (*rgba)[4];
const GLubyte *Null = 0;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* init mask to 1's (all pixels are to be written) */
MEMSET(mask, 1, n);
if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span( ctx,n,x,y,mask)==0) {
return;
}
write_all = GL_FALSE;
}
if ((primitive==GL_BITMAP && (ctx->RasterMask & modBits))
|| (ctx->RasterMask & MULTI_DRAW_BIT)) {
if ((primitive==GL_BITMAP && (swrast->_RasterMask & modBits))
|| (swrast->_RasterMask & MULTI_DRAW_BIT)) {
/* must make a copy of the colors since they may be modified */
MEMCPY( rgbaBackup, rgbaIn, 4 * n * sizeof(GLchan) );
rgba = rgbaBackup;
@ -520,7 +525,7 @@ void gl_write_rgba_span( GLcontext *ctx,
/* if we get here, something passed the depth test */
ctx->OcclusionResult = GL_TRUE;
if (ctx->RasterMask & MULTI_DRAW_BIT) {
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, n, x, y, (const GLchan (*)[4]) rgba, mask );
}
else {
@ -548,7 +553,7 @@ void gl_write_rgba_span( GLcontext *ctx,
(const GLchan (*)[4]) rgba,
write_all ? Null : mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, n, x, y,
(const GLchan (*)[4]) rgba,
write_all ? Null : mask );
@ -581,11 +586,12 @@ void gl_write_monocolor_span( GLcontext *ctx,
GLboolean write_all = GL_TRUE;
GLchan rgba[MAX_WIDTH][4];
const GLubyte *Null = 0;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* init mask to 1's (all pixels are to be written) */
MEMSET(mask, 1, n);
if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span( ctx,n,x,y,mask)==0) {
return;
}
@ -644,7 +650,7 @@ void gl_write_monocolor_span( GLcontext *ctx,
}
if (ctx->Color.ColorLogicOpEnabled || colorMask != 0xffffffff ||
(ctx->RasterMask & (BLEND_BIT | FOG_BIT))) {
(swrast->_RasterMask & (BLEND_BIT | FOG_BIT))) {
/* assign same color to each pixel */
for (i=0;i<n;i++) {
if (mask[i]) {
@ -660,7 +666,7 @@ void gl_write_monocolor_span( GLcontext *ctx,
_mesa_depth_fog_rgba_pixels( ctx, n, z, rgba );
}
if (ctx->RasterMask & MULTI_DRAW_BIT) {
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, n, x, y,
(const GLchan (*)[4]) rgba, mask );
}
@ -685,7 +691,7 @@ void gl_write_monocolor_span( GLcontext *ctx,
(*ctx->Driver.WriteRGBASpan)( ctx, n, x, y,
(const GLchan (*)[4]) rgba,
write_all ? Null : mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, n, x, y,
(const GLchan (*)[4]) rgba,
write_all ? Null : mask );
@ -697,7 +703,7 @@ void gl_write_monocolor_span( GLcontext *ctx,
ASSERT(!ctx->Color.BlendEnabled);
ASSERT(!ctx->Color.ColorLogicOpEnabled);
if (ctx->RasterMask & MULTI_DRAW_BIT) {
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
for (i=0;i<n;i++) {
if (mask[i]) {
COPY_CHAN4(rgba[i], color);
@ -708,7 +714,7 @@ void gl_write_monocolor_span( GLcontext *ctx,
}
else {
(*ctx->Driver.WriteMonoRGBASpan)( ctx, n, x, y, mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_mono_alpha_span( ctx, n, x, y, (GLchan) color[ACOMP],
write_all ? Null : mask );
}
@ -763,11 +769,12 @@ void gl_write_texture_span( GLcontext *ctx,
GLchan rgbaBackup[MAX_WIDTH][4];
GLchan (*rgba)[4]; /* points to either rgbaIn or rgbaBackup */
const GLubyte *Null = 0;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* init mask to 1's (all pixels are to be written) */
MEMSET(mask, 1, n);
if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span(ctx, n, x, y, mask)==0) {
return;
}
@ -775,7 +782,7 @@ void gl_write_texture_span( GLcontext *ctx,
}
if (primitive==GL_BITMAP || (ctx->RasterMask & MULTI_DRAW_BIT)) {
if (primitive==GL_BITMAP || (swrast->_RasterMask & MULTI_DRAW_BIT)) {
/* must make a copy of the colors since they may be modified */
MEMCPY(rgbaBackup, rgbaIn, 4 * n * sizeof(GLchan));
rgba = rgbaBackup;
@ -785,7 +792,7 @@ void gl_write_texture_span( GLcontext *ctx,
}
/* Texture */
ASSERT(ctx->Texture.ReallyEnabled);
ASSERT(ctx->Texture._ReallyEnabled);
gl_texture_pixels( ctx, 0, n, s, t, u, lambda, rgba, rgba );
/* Add base and specular colors */
@ -844,7 +851,7 @@ void gl_write_texture_span( GLcontext *ctx,
/* if we get here, something passed the depth test */
ctx->OcclusionResult = GL_TRUE;
if (ctx->RasterMask & MULTI_DRAW_BIT) {
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, n, x, y, (const GLchan (*)[4]) rgba, mask );
}
else {
@ -864,7 +871,7 @@ void gl_write_texture_span( GLcontext *ctx,
(*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLchan (*)[4])rgba,
write_all ? Null : mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, n, x, y, (const GLchan (*)[4]) rgba,
write_all ? Null : mask );
}
@ -896,11 +903,12 @@ gl_write_multitexture_span( GLcontext *ctx,
GLuint i;
const GLubyte *Null = 0;
const GLuint texUnits = ctx->Const.MaxTextureUnits;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* init mask to 1's (all pixels are to be written) */
MEMSET(mask, 1, n);
if ((ctx->RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if ((swrast->_RasterMask & WINCLIP_BIT) || primitive==GL_BITMAP) {
if (clip_span(ctx, n, x, y, mask)==0) {
return;
}
@ -908,7 +916,7 @@ gl_write_multitexture_span( GLcontext *ctx,
}
if (primitive==GL_BITMAP || (ctx->RasterMask & MULTI_DRAW_BIT)
if (primitive==GL_BITMAP || (swrast->_RasterMask & MULTI_DRAW_BIT)
|| texUnits > 1) {
/* must make a copy of the colors since they may be modified */
MEMCPY(rgbaBackup, rgbaIn, 4 * n * sizeof(GLchan));
@ -919,7 +927,7 @@ gl_write_multitexture_span( GLcontext *ctx,
}
/* Texture */
ASSERT(ctx->Texture.ReallyEnabled);
ASSERT(ctx->Texture._ReallyEnabled);
for (i = 0; i < texUnits; i++)
gl_texture_pixels( ctx, i, n, s[i], t[i], u[i], lambda[i], rgbaIn, rgba );
@ -979,7 +987,7 @@ gl_write_multitexture_span( GLcontext *ctx,
/* if we get here, something passed the depth test */
ctx->OcclusionResult = GL_TRUE;
if (ctx->RasterMask & MULTI_DRAW_BIT) {
if (swrast->_RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, n, x, y, (const GLchan (*)[4]) rgba, mask );
}
else {
@ -1001,7 +1009,7 @@ gl_write_multitexture_span( GLcontext *ctx,
}
(*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLchan (*)[4])rgba, write_all ? Null : mask );
if (ctx->RasterMask & ALPHABUF_BIT) {
if (swrast->_RasterMask & ALPHABUF_BIT) {
_mesa_write_alpha_span( ctx, n, x, y, (const GLchan (*)[4])rgba,
write_all ? Null : mask );
}

View file

@ -1,4 +1,4 @@
/* $Id: s_stencil.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_stencil.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -30,6 +30,7 @@
#include "macros.h"
#include "mem.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_pb.h"
#include "s_stencil.h"

View file

@ -1,4 +1,4 @@
/* $Id: s_texture.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_texture.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -33,6 +33,7 @@
#include "mem.h"
#include "teximage.h"
#include "s_context.h"
#include "s_pb.h"
#include "s_texture.h"
@ -174,8 +175,8 @@ static void palette_sample(const struct gl_texture_object *tObj,
{ \
if (lambda < 0.0F) \
lambda = 0.0F; \
else if (lambda > tObj->M) \
lambda = tObj->M; \
else if (lambda > tObj->_M) \
lambda = tObj->_M; \
level = (GLint) (tObj->BaseLevel + lambda); \
}
@ -187,11 +188,11 @@ static void palette_sample(const struct gl_texture_object *tObj,
{ \
if (lambda <= 0.5F) \
lambda = 0.0F; \
else if (lambda > tObj->M + 0.4999F) \
lambda = tObj->M + 0.4999F; \
else if (lambda > tObj->_M + 0.4999F) \
lambda = tObj->_M + 0.4999F; \
level = (GLint) (tObj->BaseLevel + lambda + 0.5F); \
if (level > tObj->P) \
level = tObj->P; \
if (level > tObj->_P) \
level = tObj->_P; \
}
@ -432,8 +433,8 @@ sample_1d_nearest_mipmap_linear( const struct gl_texture_object *tObj,
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_1d_nearest( tObj, tObj->Image[tObj->P], s, rgba );
if (level >= tObj->_P) {
sample_1d_nearest( tObj, tObj->Image[tObj->_P], s, rgba );
}
else {
GLchan t0[4], t1[4];
@ -458,8 +459,8 @@ sample_1d_linear_mipmap_linear( const struct gl_texture_object *tObj,
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_1d_linear( tObj, tObj->Image[tObj->P], s, rgba );
if (level >= tObj->_P) {
sample_1d_linear( tObj, tObj->Image[tObj->_P], s, rgba );
}
else {
GLchan t0[4], t1[4];
@ -475,7 +476,8 @@ sample_1d_linear_mipmap_linear( const struct gl_texture_object *tObj,
static void sample_nearest_1d( const struct gl_texture_object *tObj, GLuint n,
static void sample_nearest_1d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
@ -492,7 +494,8 @@ static void sample_nearest_1d( const struct gl_texture_object *tObj, GLuint n,
static void sample_linear_1d( const struct gl_texture_object *tObj, GLuint n,
static void sample_linear_1d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
@ -513,18 +516,20 @@ static void sample_linear_1d( const struct gl_texture_object *tObj, GLuint n,
* return a texture sample.
*
*/
static void sample_lambda_1d( const struct gl_texture_object *tObj, GLuint n,
static void sample_lambda_1d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
{
GLfloat MinMagThresh = SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit];
GLuint i;
(void) t;
(void) u;
for (i=0;i<n;i++) {
if (lambda[i] > tObj->MinMagThresh) {
if (lambda[i] > MinMagThresh) {
/* minification */
switch (tObj->MinFilter) {
case GL_NEAREST:
@ -806,8 +811,8 @@ sample_2d_nearest_mipmap_linear( const struct gl_texture_object *tObj,
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_2d_nearest( tObj, tObj->Image[tObj->P], s, t, rgba );
if (level >= tObj->_P) {
sample_2d_nearest( tObj, tObj->Image[tObj->_P], s, t, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
@ -832,8 +837,8 @@ sample_2d_linear_mipmap_linear( const struct gl_texture_object *tObj,
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_2d_linear( tObj, tObj->Image[tObj->P], s, t, rgba );
if (level >= tObj->_P) {
sample_2d_linear( tObj, tObj->Image[tObj->_P], s, t, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
@ -849,7 +854,8 @@ sample_2d_linear_mipmap_linear( const struct gl_texture_object *tObj,
static void sample_nearest_2d( const struct gl_texture_object *tObj, GLuint n,
static void sample_nearest_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
@ -865,7 +871,8 @@ static void sample_nearest_2d( const struct gl_texture_object *tObj, GLuint n,
static void sample_linear_2d( const struct gl_texture_object *tObj, GLuint n,
static void sample_linear_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
@ -884,16 +891,18 @@ static void sample_linear_2d( const struct gl_texture_object *tObj, GLuint n,
* Given an (s,t) texture coordinate and lambda (level of detail) value,
* return a texture sample.
*/
static void sample_lambda_2d( const struct gl_texture_object *tObj,
static void sample_lambda_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
{
GLfloat MinMagThresh = SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit];
GLuint i;
(void) u;
for (i=0;i<n;i++) {
if (lambda[i] > tObj->MinMagThresh) {
if (lambda[i] > MinMagThresh) {
/* minification */
switch (tObj->MinFilter) {
case GL_NEAREST:
@ -943,7 +952,8 @@ static void sample_lambda_2d( const struct gl_texture_object *tObj,
* No border
* Format = GL_RGB
*/
static void opt_sample_rgb_2d( const struct gl_texture_object *tObj,
static void opt_sample_rgb_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
@ -984,7 +994,8 @@ static void opt_sample_rgb_2d( const struct gl_texture_object *tObj,
* No border
* Format = GL_RGBA
*/
static void opt_sample_rgba_2d( const struct gl_texture_object *tObj,
static void opt_sample_rgba_2d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
@ -1303,8 +1314,8 @@ sample_3d_nearest_mipmap_linear( const struct gl_texture_object *tObj,
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_3d_nearest( tObj, tObj->Image[tObj->P], s, t, r, rgba );
if (level >= tObj->_P) {
sample_3d_nearest( tObj, tObj->Image[tObj->_P], s, t, r, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
@ -1328,8 +1339,8 @@ sample_3d_linear_mipmap_linear( const struct gl_texture_object *tObj,
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
if (level >= tObj->P) {
sample_3d_linear( tObj, tObj->Image[tObj->P], s, t, r, rgba );
if (level >= tObj->_P) {
sample_3d_linear( tObj, tObj->Image[tObj->_P], s, t, r, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
@ -1344,7 +1355,8 @@ sample_3d_linear_mipmap_linear( const struct gl_texture_object *tObj,
}
static void sample_nearest_3d( const struct gl_texture_object *tObj, GLuint n,
static void sample_nearest_3d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
@ -1359,7 +1371,8 @@ static void sample_nearest_3d( const struct gl_texture_object *tObj, GLuint n,
static void sample_linear_3d( const struct gl_texture_object *tObj, GLuint n,
static void sample_linear_3d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
@ -1377,16 +1390,18 @@ static void sample_linear_3d( const struct gl_texture_object *tObj, GLuint n,
* Given an (s,t,r) texture coordinate and lambda (level of detail) value,
* return a texture sample.
*/
static void sample_lambda_3d( const struct gl_texture_object *tObj, GLuint n,
static void sample_lambda_3d( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4] )
{
GLuint i;
GLfloat MinMagThresh = SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit];
for (i=0;i<n;i++) {
if (lambda[i] > tObj->MinMagThresh) {
if (lambda[i] > MinMagThresh) {
/* minification */
switch (tObj->MinFilter) {
case GL_NEAREST:
@ -1507,7 +1522,8 @@ choose_cube_face(const struct gl_texture_object *texObj,
static void
sample_nearest_cube(const struct gl_texture_object *tObj, GLuint n,
sample_nearest_cube(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4])
@ -1524,7 +1540,8 @@ sample_nearest_cube(const struct gl_texture_object *tObj, GLuint n,
static void
sample_linear_cube(const struct gl_texture_object *tObj, GLuint n,
sample_linear_cube(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4])
@ -1585,8 +1602,8 @@ sample_cube_nearest_mipmap_linear( const struct gl_texture_object *tObj,
images = choose_cube_face(tObj, s, t, u, &newS, &newT);
if (level >= tObj->P) {
sample_2d_nearest( tObj, images[tObj->P], newS, newT, rgba );
if (level >= tObj->_P) {
sample_2d_nearest( tObj, images[tObj->_P], newS, newT, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
@ -1614,8 +1631,8 @@ sample_cube_linear_mipmap_linear( const struct gl_texture_object *tObj,
images = choose_cube_face(tObj, s, t, u, &newS, &newT);
if (level >= tObj->P) {
sample_2d_linear( tObj, images[tObj->P], newS, newT, rgba );
if (level >= tObj->_P) {
sample_2d_linear( tObj, images[tObj->_P], newS, newT, rgba );
}
else {
GLchan t0[4], t1[4];
@ -1631,15 +1648,17 @@ sample_cube_linear_mipmap_linear( const struct gl_texture_object *tObj,
static void
sample_lambda_cube(const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4])
sample_lambda_cube( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4])
{
GLfloat MinMagThresh = SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit];
GLuint i;
for (i = 0; i < n; i++) {
if (lambda[i] > tObj->MinMagThresh) {
if (lambda[i] > MinMagThresh) {
/* minification */
switch (tObj->MinFilter) {
case GL_NEAREST:
@ -1704,6 +1723,14 @@ sample_lambda_cube(const struct gl_texture_object *tObj, GLuint n,
}
}
static void
null_sample_func( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat s[], const GLfloat t[],
const GLfloat u[], const GLfloat lambda[],
GLchan rgba[][4])
{
}
/**********************************************************************/
/* Texture Sampling Setup */
@ -1714,10 +1741,13 @@ sample_lambda_cube(const struct gl_texture_object *tObj, GLuint n,
* Setup the texture sampling function for this texture object.
*/
void
_swrast_set_texture_sampler( struct gl_texture_object *t )
_swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *t )
{
if (!t->Complete) {
t->SampleFunc = NULL;
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (!t->Complete) {
swrast->TextureSample[texUnit] = null_sample_func;
}
else {
GLboolean needLambda = (GLboolean) (t->MinFilter != t->MagFilter);
@ -1727,69 +1757,69 @@ _swrast_set_texture_sampler( struct gl_texture_object *t )
if (t->MagFilter==GL_LINEAR
&& (t->MinFilter==GL_NEAREST_MIPMAP_NEAREST ||
t->MinFilter==GL_LINEAR_MIPMAP_NEAREST)) {
t->MinMagThresh = 0.5F;
swrast->_MinMagThresh[texUnit] = 0.5F;
}
else {
t->MinMagThresh = 0.0F;
swrast->_MinMagThresh[texUnit] = 0.0F;
}
}
switch (t->Dimensions) {
case 1:
if (needLambda) {
t->SampleFunc = sample_lambda_1d;
swrast->TextureSample[texUnit] = sample_lambda_1d;
}
else if (t->MinFilter==GL_LINEAR) {
t->SampleFunc = sample_linear_1d;
swrast->TextureSample[texUnit] = sample_linear_1d;
}
else {
ASSERT(t->MinFilter==GL_NEAREST);
t->SampleFunc = sample_nearest_1d;
swrast->TextureSample[texUnit] = sample_nearest_1d;
}
break;
case 2:
if (needLambda) {
t->SampleFunc = sample_lambda_2d;
swrast->TextureSample[texUnit] = sample_lambda_2d;
}
else if (t->MinFilter==GL_LINEAR) {
t->SampleFunc = sample_linear_2d;
swrast->TextureSample[texUnit] = sample_linear_2d;
}
else {
ASSERT(t->MinFilter==GL_NEAREST);
if (t->WrapS==GL_REPEAT && t->WrapT==GL_REPEAT
&& t->Image[0]->Border==0 && t->Image[0]->Format==GL_RGB) {
t->SampleFunc = opt_sample_rgb_2d;
swrast->TextureSample[texUnit] = opt_sample_rgb_2d;
}
else if (t->WrapS==GL_REPEAT && t->WrapT==GL_REPEAT
&& t->Image[0]->Border==0 && t->Image[0]->Format==GL_RGBA) {
t->SampleFunc = opt_sample_rgba_2d;
swrast->TextureSample[texUnit] = opt_sample_rgba_2d;
}
else
t->SampleFunc = sample_nearest_2d;
swrast->TextureSample[texUnit] = sample_nearest_2d;
}
break;
case 3:
if (needLambda) {
t->SampleFunc = sample_lambda_3d;
swrast->TextureSample[texUnit] = sample_lambda_3d;
}
else if (t->MinFilter==GL_LINEAR) {
t->SampleFunc = sample_linear_3d;
swrast->TextureSample[texUnit] = sample_linear_3d;
}
else {
ASSERT(t->MinFilter==GL_NEAREST);
t->SampleFunc = sample_nearest_3d;
swrast->TextureSample[texUnit] = sample_nearest_3d;
}
break;
case 6: /* cube map */
if (needLambda) {
t->SampleFunc = sample_lambda_cube;
swrast->TextureSample[texUnit] = sample_lambda_cube;
}
else if (t->MinFilter==GL_LINEAR) {
t->SampleFunc = sample_linear_cube;
swrast->TextureSample[texUnit] = sample_linear_cube;
}
else {
ASSERT(t->MinFilter==GL_NEAREST);
t->SampleFunc = sample_nearest_cube;
swrast->TextureSample[texUnit] = sample_nearest_cube;
}
break;
default:
@ -2116,12 +2146,12 @@ apply_texture( const GLcontext *ctx,
GLenum format;
ASSERT(texUnit);
ASSERT(texUnit->Current);
ASSERT(texUnit->_Current);
baseLevel = texUnit->Current->BaseLevel;
ASSERT(texUnit->Current->Image[baseLevel]);
baseLevel = texUnit->_Current->BaseLevel;
ASSERT(texUnit->_Current->Image[baseLevel]);
format = texUnit->Current->Image[baseLevel]->Format;
format = texUnit->_Current->Image[baseLevel]->Format;
if (format==GL_COLOR_INDEX) {
format = GL_RGBA; /* XXXX a hack! */
@ -2496,10 +2526,10 @@ void gl_texture_pixels( GLcontext *ctx, GLuint texUnit, GLuint n,
{
const GLuint mask = TEXTURE0_ANY << (texUnit * 4);
if (ctx->Texture.ReallyEnabled & mask) {
if (ctx->Texture._ReallyEnabled & mask) {
const struct gl_texture_unit *textureUnit = &ctx->Texture.Unit[texUnit];
if (textureUnit->Current && textureUnit->Current->SampleFunc) {
if (textureUnit->_Current) {
GLchan texel[PB_SIZE][4];
if (textureUnit->LodBias != 0.0F) {
@ -2510,11 +2540,11 @@ void gl_texture_pixels( GLcontext *ctx, GLuint texUnit, GLuint n,
}
}
if (textureUnit->Current->MinLod != -1000.0
|| textureUnit->Current->MaxLod != 1000.0) {
if (textureUnit->_Current->MinLod != -1000.0
|| textureUnit->_Current->MaxLod != 1000.0) {
/* apply LOD clamping to lambda */
GLfloat min = textureUnit->Current->MinLod;
GLfloat max = textureUnit->Current->MaxLod;
GLfloat min = textureUnit->_Current->MinLod;
GLfloat max = textureUnit->_Current->MaxLod;
GLuint i;
for (i=0;i<n;i++) {
GLfloat l = lambda[i];
@ -2524,14 +2554,16 @@ void gl_texture_pixels( GLcontext *ctx, GLuint texUnit, GLuint n,
/* fetch texture images from device driver, if needed */
if (ctx->Driver.GetTexImage) {
if (!_mesa_get_teximages_from_driver(ctx, textureUnit->Current)) {
if (!_mesa_get_teximages_from_driver(ctx, textureUnit->_Current)) {
return;
}
}
/* Sample the texture. */
(*textureUnit->Current->SampleFunc)( textureUnit->Current, n,
s, t, r, lambda, texel );
SWRAST_CONTEXT(ctx)->TextureSample[texUnit]( ctx, texUnit,
textureUnit->_Current,
n, s, t, r,
lambda, texel );
apply_texture( ctx, textureUnit, n, primary_rgba, texel, rgba );
}

View file

@ -1,4 +1,4 @@
/* $Id: s_texture.h,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_texture.h,v 1.2 2000/11/05 18:24:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -41,6 +41,10 @@ extern void gl_texture_pixels( GLcontext *ctx, GLuint texSet, GLuint n,
const GLfloat r[], GLfloat lambda[],
GLchan primary_rgba[][4], GLchan rgba[][4] );
extern void
_swrast_choose_texture_sample_func( GLcontext *ctx,
GLuint texUnit,
const struct gl_texture_object *tObj );
#endif

View file

@ -1,4 +1,4 @@
/* $Id: s_triangle.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_triangle.c,v 1.2 2000/11/05 18:24:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -34,7 +34,6 @@
#include "glheader.h"
#include "context.h"
#include "feedback.h"
#include "macros.h"
#include "mem.h"
#include "mmath.h"
@ -42,21 +41,24 @@
#include "texstate.h"
#include "s_aatriangle.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_feedback.h"
#include "s_span.h"
static GLboolean cull_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
#include "s_triangle.h"
GLboolean gl_cull_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
struct vertex_buffer *VB = ctx->VB;
GLfloat (*win)[4] = VB->Win.data;
GLfloat ex = win[v1][0] - win[v0][0];
GLfloat ey = win[v1][1] - win[v0][1];
GLfloat fx = win[v2][0] - win[v0][0];
GLfloat fy = win[v2][1] - win[v0][1];
GLfloat ex = v1->win[0] - v0->win[0];
GLfloat ey = v1->win[1] - v0->win[1];
GLfloat fx = v2->win[0] - v0->win[0];
GLfloat fy = v2->win[1] - v0->win[1];
GLfloat c = ex*fy-ey*fx;
if (c * ctx->backface_sign > 0)
if (c * ctx->_backface_sign > 0)
return 0;
return 1;
@ -67,11 +69,13 @@ static GLboolean cull_triangle( GLcontext *ctx,
* Render a flat-shaded color index triangle.
*/
static void flat_ci_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
#define INTERP_Z 1
#define SETUP_CODE \
GLuint index = VB->IndexPtr->data[pv]; \
GLuint index = v0->index; \
if (1) { \
/* set the color index */ \
(*ctx->Driver.Index)( ctx, index ); \
@ -104,9 +108,10 @@ static void flat_ci_triangle( GLcontext *ctx,
* Render a smooth-shaded color index triangle.
*/
static void smooth_ci_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
(void) pv;
#define INTERP_Z 1
#define INTERP_INDEX 1
@ -140,7 +145,9 @@ static void smooth_ci_triangle( GLcontext *ctx,
* Render a flat-shaded RGBA triangle.
*/
static void flat_rgba_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@ -148,10 +155,10 @@ static void flat_rgba_triangle( GLcontext *ctx,
#define SETUP_CODE \
if (1) { \
/* set the color */ \
GLchan r = VB->ColorPtr->data[pv][0]; \
GLchan g = VB->ColorPtr->data[pv][1]; \
GLchan b = VB->ColorPtr->data[pv][2]; \
GLchan a = VB->ColorPtr->data[pv][3]; \
GLchan r = v0->color[0]; \
GLchan g = v0->color[1]; \
GLchan b = v0->color[2]; \
GLchan a = v0->color[3]; \
(*ctx->Driver.Color)( ctx, r, g, b, a ); \
}
@ -170,14 +177,14 @@ static void flat_rgba_triangle( GLcontext *ctx,
} \
gl_write_monocolor_span( ctx, n, LEFT, Y, zspan, \
fogspan, \
VB->ColorPtr->data[pv], \
v0->color, \
GL_POLYGON ); \
} \
}
#include "s_tritemp.h"
ASSERT(!ctx->Texture.ReallyEnabled); /* texturing must be off */
ASSERT(!ctx->Texture._ReallyEnabled); /* texturing must be off */
ASSERT(ctx->Light.ShadeModel==GL_FLAT);
}
@ -187,9 +194,11 @@ static void flat_rgba_triangle( GLcontext *ctx,
* Render a smooth-shaded RGBA triangle.
*/
static void smooth_rgba_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
(void) pv;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
@ -226,7 +235,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
#include "s_tritemp.h"
ASSERT(!ctx->Texture.ReallyEnabled); /* texturing must be off */
ASSERT(!ctx->Texture._ReallyEnabled); /* texturing must be off */
ASSERT(ctx->Light.ShadeModel==GL_SMOOTH);
}
@ -237,8 +246,10 @@ static void smooth_rgba_triangle( GLcontext *ctx,
*
* No fog.
*/
static void simple_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
static void simple_textured_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
#define INTERP_INT_TEX 1
#define S_SCALE twidth
@ -252,7 +263,6 @@ static void simple_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLchan *texture = obj->Image[b]->Data; \
GLint smask = obj->Image[b]->Width - 1; \
GLint tmask = obj->Image[b]->Height - 1; \
(void) pv; \
if (!texture) { \
if (!_mesa_get_teximages_from_driver(ctx, obj)) \
return; \
@ -295,8 +305,10 @@ static void simple_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
*
* No fog.
*/
static void simple_z_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
static void simple_z_textured_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@ -312,7 +324,6 @@ static void simple_z_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLchan *texture = obj->Image[b]->Data; \
GLint smask = obj->Image[b]->Width - 1; \
GLint tmask = obj->Image[b]->Height - 1; \
(void) pv; \
if (!texture) { \
if (!_mesa_get_teximages_from_driver(ctx, obj)) \
return; \
@ -363,8 +374,10 @@ static void simple_z_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
/*
* Render an RGB/RGBA textured triangle without perspective correction.
*/
static void affine_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
static void affine_textured_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@ -423,7 +436,7 @@ static void affine_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
} \
tbytesline = obj->Image[b]->Width * comp; \
tsize = theight * tbytesline;
(void) pv;
/* Instead of defining a function for each mode, a test is done
* between the outer and inner loops. This is to reduce code size
@ -683,8 +696,10 @@ static void affine_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
* This function written by Klaus Niederkrueger <klaus@math.leidenuniv.nl>
* Send all questions and bug reports to him.
*/
static void near_persp_textured_triangle(GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
static void near_persp_textured_triangle(GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
/* The BIAS value is used to shift negative values into positive values.
* Without this, negative texture values don't GL_REPEAT correctly at just
@ -712,7 +727,6 @@ static void near_persp_textured_triangle(GLcontext *ctx, GLuint v0, GLuint v1,
const GLint format = obj->Image[b]->Format; \
const GLint envmode = unit->EnvMode; \
GLfloat sscale, tscale; \
/*GLint comp, tbytesline, tsize; */ \
GLfixed er, eg, eb, ea; \
GLint tr, tg, tb, ta; \
if (!texture) { \
@ -727,30 +741,9 @@ static void near_persp_textured_triangle(GLcontext *ctx, GLuint v0, GLuint v1,
eb = FloatToFixed(unit->EnvColor[2]); \
ea = FloatToFixed(unit->EnvColor[3]); \
} \
/*switch (format) { \
case GL_ALPHA: \
case GL_LUMINANCE: \
case GL_INTENSITY: \
comp = 1; \
break; \
case GL_LUMINANCE_ALPHA: \
comp = 2; \
break; \
case GL_RGB: \
comp = 3; \
break; \
case GL_RGBA: \
comp = 4; \
break; \
default: \
gl_problem(NULL, "Bad texture format in near_persp_texture_triangle"); \
return; \
} */ \
sscale = twidth; \
tscale = theight; \
/*tbytesline = obj->Image[b]->Width * comp; \
tsize = theight * tbytesline;*/
(void) pv;
#define OLD_SPAN(DO_TEX,COMP) \
for (i=0;i<n;i++) { \
@ -1443,8 +1436,10 @@ static void near_persp_textured_triangle(GLcontext *ctx, GLuint v0, GLuint v1,
* This function written by Klaus Niederkrueger <klaus@math.leidenuniv.nl>
* Send all questions and bug reports to him.
*/
static void lin_persp_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
static void lin_persp_textured_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@ -1502,7 +1497,7 @@ static void lin_persp_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
tscale = FIXED_SCALE * theight; \
tbytesline = obj->Image[b]->Width * comp; \
tsize = theight * tbytesline;
(void) pv;
#define SPAN(DO_TEX,COMP) \
for (i=0;i<n;i++) { \
@ -1620,8 +1615,10 @@ static void lin_persp_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
* Note: we use texture coordinates S,T,U,V instead of S,T,R,Q because
* R is already used for red.
*/
static void general_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
static void general_textured_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@ -1632,10 +1629,10 @@ static void general_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a; \
if (flat_shade) { \
r = VB->ColorPtr->data[pv][0]; \
g = VB->ColorPtr->data[pv][1]; \
b = VB->ColorPtr->data[pv][2]; \
a = VB->ColorPtr->data[pv][3]; \
r = v0->color[0]; \
g = v0->color[1]; \
b = v0->color[2]; \
a = v0->color[3]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@ -1708,8 +1705,10 @@ static void general_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
* Note: we use texture coordinates S,T,U,V instead of S,T,R,Q because
* R is already used for red.
*/
static void general_textured_spec_triangle1( GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint pv,
static void general_textured_spec_triangle1( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2,
GLdepth zspan[MAX_WIDTH],
GLfixed fogspan[MAX_WIDTH],
GLchan rgba[MAX_WIDTH][4],
@ -1725,13 +1724,13 @@ static void general_textured_spec_triangle1( GLcontext *ctx, GLuint v0,
GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a, sr, sg, sb; \
if (flat_shade) { \
r = VB->ColorPtr->data[pv][0]; \
g = VB->ColorPtr->data[pv][1]; \
b = VB->ColorPtr->data[pv][2]; \
a = VB->ColorPtr->data[pv][3]; \
sr = VB->SecondaryColorPtr->data[pv][0]; \
sg = VB->SecondaryColorPtr->data[pv][1]; \
sb = VB->SecondaryColorPtr->data[pv][2]; \
r = v0->color[0]; \
g = v0->color[1]; \
b = v0->color[2]; \
a = v0->color[3]; \
sr = v0->specular[0]; \
sg = v0->specular[1]; \
sb = v0->specular[2]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@ -1831,8 +1830,10 @@ compute_lambda( GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
* minification or magnification filter. If minification and using
* mipmaps, lambda is also used to select the texture level of detail.
*/
static void lambda_textured_triangle1( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv,
static void lambda_textured_triangle1( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2,
GLfloat s[MAX_WIDTH],
GLfloat t[MAX_WIDTH],
GLfloat u[MAX_WIDTH] )
@ -1844,7 +1845,7 @@ static void lambda_textured_triangle1( GLcontext *ctx, GLuint v0, GLuint v1,
#define INTERP_TEX 1
#define SETUP_CODE \
const struct gl_texture_object *obj = ctx->Texture.Unit[0].Current; \
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; \
const GLint baseLevel = obj->BaseLevel; \
const struct gl_texture_image *texImage = obj->Image[baseLevel]; \
const GLfloat twidth = (GLfloat) texImage->Width; \
@ -1852,10 +1853,10 @@ static void lambda_textured_triangle1( GLcontext *ctx, GLuint v0, GLuint v1,
const GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a; \
if (flat_shade) { \
r = VB->ColorPtr->data[pv][0]; \
g = VB->ColorPtr->data[pv][1]; \
b = VB->ColorPtr->data[pv][2]; \
a = VB->ColorPtr->data[pv][3]; \
r = v0->color[0]; \
g = v0->color[1]; \
b = v0->color[2]; \
a = v0->color[3]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
@ -1933,8 +1934,10 @@ static void lambda_textured_triangle1( GLcontext *ctx, GLuint v0, GLuint v1,
* minification or magnification filter. If minification and using
* mipmaps, lambda is also used to select the texture level of detail.
*/
static void lambda_textured_spec_triangle1( GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint pv,
static void lambda_textured_spec_triangle1( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2,
GLfloat s[MAX_WIDTH],
GLfloat t[MAX_WIDTH],
GLfloat u[MAX_WIDTH] )
@ -1947,7 +1950,7 @@ static void lambda_textured_spec_triangle1( GLcontext *ctx, GLuint v0,
#define INTERP_TEX 1
#define SETUP_CODE \
const struct gl_texture_object *obj = ctx->Texture.Unit[0].Current; \
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; \
const GLint baseLevel = obj->BaseLevel; \
const struct gl_texture_image *texImage = obj->Image[baseLevel]; \
const GLfloat twidth = (GLfloat) texImage->Width; \
@ -1955,13 +1958,13 @@ static void lambda_textured_spec_triangle1( GLcontext *ctx, GLuint v0,
const GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a, sr, sg, sb; \
if (flat_shade) { \
r = VB->ColorPtr->data[pv][0]; \
g = VB->ColorPtr->data[pv][1]; \
b = VB->ColorPtr->data[pv][2]; \
a = VB->ColorPtr->data[pv][3]; \
sr = VB->SecondaryColorPtr->data[pv][0]; \
sg = VB->SecondaryColorPtr->data[pv][1]; \
sb = VB->SecondaryColorPtr->data[pv][2]; \
r = v0->color[0]; \
g = v0->color[1]; \
b = v0->color[2]; \
a = v0->color[3]; \
sr = v0->specular[0]; \
sg = v0->specular[1]; \
sb = v0->specular[2]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
@ -2047,12 +2050,14 @@ static void lambda_textured_spec_triangle1( GLcontext *ctx, GLuint v0,
* Interpolate Z, RGB, Alpha, and two sets of texture coordinates.
* Yup, it's slow.
*/
static void lambda_multitextured_triangle1( GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint pv,
GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH],
GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH],
GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH]
)
static void
lambda_multitextured_triangle1( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2,
GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH],
GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH],
GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH])
{
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@ -2066,16 +2071,16 @@ static void lambda_multitextured_triangle1( GLcontext *ctx, GLuint v0,
GLfloat twidth[MAX_TEXTURE_UNITS], theight[MAX_TEXTURE_UNITS]; \
GLint r, g, b, a; \
if (flat_shade) { \
r = VB->ColorPtr->data[pv][0]; \
g = VB->ColorPtr->data[pv][1]; \
b = VB->ColorPtr->data[pv][2]; \
a = VB->ColorPtr->data[pv][3]; \
r = v0->color[0]; \
g = v0->color[1]; \
b = v0->color[2]; \
a = v0->color[3]; \
} \
{ \
GLuint unit; \
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { \
if (ctx->Texture.Unit[unit].ReallyEnabled) { \
const struct gl_texture_object *obj = ctx->Texture.Unit[unit].Current; \
if (ctx->Texture.Unit[unit]._ReallyEnabled) { \
const struct gl_texture_object *obj = ctx->Texture.Unit[unit]._Current; \
const GLint baseLevel = obj->BaseLevel; \
const struct gl_texture_image *texImage = obj->Image[baseLevel]; \
twidth[unit] = (GLfloat) texImage->Width; \
@ -2107,7 +2112,7 @@ static void lambda_multitextured_triangle1( GLcontext *ctx, GLuint v0,
{ \
GLuint unit; \
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { \
if (ctx->Texture.Unit[unit].ReallyEnabled) { \
if (ctx->Texture.Unit[unit]._ReallyEnabled) { \
GLdouble invQ = 1.0 / vv[unit]; \
s[unit][i] = ss[unit] * invQ; \
t[unit][i] = tt[unit] * invQ; \
@ -2141,7 +2146,7 @@ static void lambda_multitextured_triangle1( GLcontext *ctx, GLuint v0,
{ \
GLuint unit; \
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { \
if (ctx->Texture.Unit[unit].ReallyEnabled) { \
if (ctx->Texture.Unit[unit]._ReallyEnabled) { \
GLdouble invQ = 1.0 / vv[unit]; \
s[unit][i] = ss[unit] * invQ; \
t[unit][i] = tt[unit] * invQ; \
@ -2175,34 +2180,42 @@ static void lambda_multitextured_triangle1( GLcontext *ctx, GLuint v0,
* on Mac / PowerPC systems.
*/
static void general_textured_spec_triangle(GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint pv)
static void general_textured_spec_triangle(GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
GLdepth zspan[MAX_WIDTH];
GLfixed fogspan[MAX_WIDTH];
GLchan rgba[MAX_WIDTH][4], spec[MAX_WIDTH][4];
general_textured_spec_triangle1(ctx,v0,v1,v2,pv,zspan,fogspan,rgba,spec);
general_textured_spec_triangle1(ctx,v0,v1,v2,zspan,fogspan,rgba,spec);
}
static void lambda_textured_triangle( GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint pv )
static void lambda_textured_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], u[MAX_WIDTH];
lambda_textured_triangle1(ctx,v0,v1,v2,pv,s,t,u);
lambda_textured_triangle1(ctx,v0,v1,v2,s,t,u);
}
static void lambda_textured_spec_triangle( GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint pv )
static void lambda_textured_spec_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
GLfloat s[MAX_WIDTH];
GLfloat t[MAX_WIDTH];
GLfloat u[MAX_WIDTH];
lambda_textured_spec_triangle1(ctx,v0,v1,v2,pv,s,t,u);
lambda_textured_spec_triangle1(ctx,v0,v1,v2,s,t,u);
}
static void lambda_multitextured_triangle( GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint pv)
static void lambda_multitextured_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH];
@ -2210,17 +2223,18 @@ static void lambda_multitextured_triangle( GLcontext *ctx, GLuint v0,
DEFMARRAY(GLfloat,u,MAX_TEXTURE_UNITS,MAX_WIDTH);
CHECKARRAY(u,return);
lambda_multitextured_triangle1(ctx,v0,v1,v2,pv,s,t,u);
lambda_multitextured_triangle1(ctx,v0,v1,v2,s,t,u);
UNDEFARRAY(u);
}
static void occlusion_zless_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
static void occlusion_zless_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2 )
{
(void)pv;
if (ctx->OcclusionResult) {
return;
}
@ -2247,18 +2261,6 @@ static void occlusion_zless_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
/*
* Null rasterizer for measuring transformation speed.
*/
static void null_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
{
(void) ctx;
(void) v0;
(void) v1;
(void) v2;
(void) pv;
}
#if 0
@ -2277,24 +2279,16 @@ static void null_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
* remove tests to this code.
*/
void
_swrast_set_triangle_function( GLcontext *ctx )
_swrast_choose_triangle( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLboolean rgbmode = ctx->Visual.RGBAflag;
if (ctx->RenderMode==GL_RENDER) {
if (ctx->NoRaster) {
ctx->Driver.TriangleFunc = null_triangle;
return;
}
if (ctx->Driver.TriangleFunc) {
/* Device driver will draw triangles. */
dputs("Driver triangle");
return;
}
if (ctx->Polygon.SmoothFlag) {
_mesa_set_aa_triangle_function(ctx);
ASSERT(ctx->Driver.TriangleFunc);
ASSERT(swrast->Triangle);
return;
}
@ -2311,18 +2305,18 @@ _swrast_set_triangle_function( GLcontext *ctx )
||
(!rgbmode && ctx->Color.IndexMask == 0)) {
dputs("occlusion_test_triangle");
ctx->Driver.TriangleFunc = occlusion_zless_triangle;
swrast->Triangle = occlusion_zless_triangle;
return;
}
}
if (ctx->Texture.ReallyEnabled) {
if (ctx->Texture._ReallyEnabled) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
GLint format, filter;
const struct gl_texture_object *current2Dtex = ctx->Texture.Unit[0].CurrentD[2];
const struct gl_texture_image *image;
/* First see if we can used an optimized 2-D texture function */
if (ctx->Texture.ReallyEnabled==TEXTURE0_2D
if (ctx->Texture._ReallyEnabled==TEXTURE0_2D
&& current2Dtex->WrapS==GL_REPEAT
&& current2Dtex->WrapT==GL_REPEAT
&& ((image = current2Dtex->Image[current2Dtex->BaseLevel]) != 0) /* correct! */
@ -2338,39 +2332,39 @@ _swrast_set_triangle_function( GLcontext *ctx )
&& format==GL_RGB
&& (ctx->Texture.Unit[0].EnvMode==GL_REPLACE
|| ctx->Texture.Unit[0].EnvMode==GL_DECAL)
&& ((ctx->RasterMask==DEPTH_BIT
&& ((swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE)
|| ctx->RasterMask==0)
|| swrast->_RasterMask==0)
&& ctx->Polygon.StippleFlag==GL_FALSE) {
if (ctx->RasterMask==DEPTH_BIT) {
ctx->Driver.TriangleFunc = simple_z_textured_triangle;
if (swrast->_RasterMask==DEPTH_BIT) {
swrast->Triangle = simple_z_textured_triangle;
dputs("simple_z_textured_triangle");
}
else {
ctx->Driver.TriangleFunc = simple_textured_triangle;
swrast->Triangle = simple_textured_triangle;
dputs("simple_textured_triangle");
}
}
else {
if (ctx->Texture.Unit[0].EnvMode==GL_ADD) {
ctx->Driver.TriangleFunc = general_textured_triangle;
swrast->Triangle = general_textured_triangle;
dputs("general_textured_triangle");
}
else {
ctx->Driver.TriangleFunc = affine_textured_triangle;
swrast->Triangle = affine_textured_triangle;
dputs("affine_textured_triangle");
}
}
}
else {
if (filter==GL_NEAREST) {
ctx->Driver.TriangleFunc = near_persp_textured_triangle;
swrast->Triangle = near_persp_textured_triangle;
dputs("near_persp_textured_triangle");
}
else {
ctx->Driver.TriangleFunc = lin_persp_textured_triangle;
swrast->Triangle = lin_persp_textured_triangle;
dputs("lin_persp_textured_triangle");
}
}
@ -2379,13 +2373,13 @@ _swrast_set_triangle_function( GLcontext *ctx )
/* More complicated textures (mipmap, multi-tex, sep specular) */
GLboolean needLambda;
/* if mag filter != min filter we need to compute lambda */
const struct gl_texture_object *obj = ctx->Texture.Unit[0].Current;
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current;
if (obj && obj->MinFilter != obj->MagFilter)
needLambda = GL_TRUE;
else
needLambda = GL_FALSE;
if (ctx->Texture.MultiTextureEnabled) {
ctx->Driver.TriangleFunc = lambda_multitextured_triangle;
if (ctx->Texture._MultiTextureEnabled) {
swrast->Triangle = lambda_multitextured_triangle;
dputs("lambda_multitextured_triangle");
}
else if ((ctx->Light.Enabled &&
@ -2393,21 +2387,21 @@ _swrast_set_triangle_function( GLcontext *ctx )
|| ctx->Fog.ColorSumEnabled) {
/* separate specular color interpolation */
if (needLambda) {
ctx->Driver.TriangleFunc = lambda_textured_spec_triangle;
swrast->Triangle = lambda_textured_spec_triangle;
dputs("lambda_textured_spec_triangle");
}
else {
ctx->Driver.TriangleFunc = general_textured_spec_triangle;
swrast->Triangle = general_textured_spec_triangle;
dputs("general_textured_spec_triangle");
}
}
else {
if (needLambda) {
ctx->Driver.TriangleFunc = lambda_textured_triangle;
swrast->Triangle = lambda_textured_triangle;
dputs("lambda_textured_triangle");
}
else {
ctx->Driver.TriangleFunc = general_textured_triangle;
swrast->Triangle = general_textured_triangle;
dputs("general_textured_triangle");
}
}
@ -2418,31 +2412,31 @@ _swrast_set_triangle_function( GLcontext *ctx )
/* smooth shaded, no texturing, stippled or some raster ops */
if (rgbmode) {
dputs("smooth_rgba_triangle");
ctx->Driver.TriangleFunc = smooth_rgba_triangle;
swrast->Triangle = smooth_rgba_triangle;
}
else {
dputs("smooth_ci_triangle");
ctx->Driver.TriangleFunc = smooth_ci_triangle;
swrast->Triangle = smooth_ci_triangle;
}
}
else {
/* flat shaded, no texturing, stippled or some raster ops */
if (rgbmode) {
dputs("flat_rgba_triangle");
ctx->Driver.TriangleFunc = flat_rgba_triangle;
swrast->Triangle = flat_rgba_triangle;
}
else {
dputs("flat_ci_triangle");
ctx->Driver.TriangleFunc = flat_ci_triangle;
swrast->Triangle = flat_ci_triangle;
}
}
}
}
else if (ctx->RenderMode==GL_FEEDBACK) {
ctx->Driver.TriangleFunc = gl_feedback_triangle;
swrast->Triangle = gl_feedback_triangle;
}
else {
/* GL_SELECT mode */
ctx->Driver.TriangleFunc = gl_select_triangle;
swrast->Triangle = gl_select_triangle;
}
}

View file

@ -1,4 +1,4 @@
/* $Id: s_triangle.h,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_triangle.h,v 1.2 2000/11/05 18:24:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -36,8 +36,14 @@
#include "swrast.h"
void gl_set_triangle_function( GLcontext *ctx );
GLboolean gl_cull_triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv );
GLboolean gl_cull_triangle( GLcontext *ctx,
SWvertex *v0,
SWvertex *v1,
SWvertex *v2);
void
_swrast_choose_triangle( GLcontext *ctx );
#endif

View file

@ -1,4 +1,4 @@
/* $Id: s_tritemp.h,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
/* $Id: s_tritemp.h,v 1.2 2000/11/05 18:24:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -73,10 +73,10 @@
*/
/*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/
/*void triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2 )*/
{
typedef struct {
GLint v0, v1; /* Y(v0) < Y(v1) */
SWvertex *v0, *v1; /* Y(v0) < Y(v1) */
GLfloat dx; /* X(v1) - X(v0) */
GLfloat dy; /* Y(v1) - Y(v0) */
GLfixed fdxdy; /* dx/dy in fixed-point */
@ -93,17 +93,16 @@
const GLfloat maxDepth = ctx->Visual.DepthMaxF;
#define FixedToDepth(F) ((F) >> fixedToDepthShift)
#endif
const struct vertex_buffer *VB = ctx->VB;
EdgeT eMaj, eTop, eBot;
GLfloat oneOverArea;
int vMin, vMid, vMax; /* vertex indexes: Y(vMin)<=Y(vMid)<=Y(vMax) */
float bf = ctx->backface_sign;
SWvertex *vMin, *vMid, *vMax; /* Y(vMin)<=Y(vMid)<=Y(vMax) */
float bf = ctx->_backface_sign;
/* find the order of the 3 vertices along the Y axis */
{
GLfloat y0 = VB->Win.data[v0][1];
GLfloat y1 = VB->Win.data[v1][1];
GLfloat y2 = VB->Win.data[v2][1];
GLfloat y0 = v0->win[1];
GLfloat y1 = v1->win[1];
GLfloat y2 = v2->win[1];
if (y0<=y1) {
if (y1<=y2) {
@ -135,12 +134,12 @@
eBot.v0 = vMin; eBot.v1 = vMid;
/* compute deltas for each edge: vertex[v1] - vertex[v0] */
eMaj.dx = VB->Win.data[vMax][0] - VB->Win.data[vMin][0];
eMaj.dy = VB->Win.data[vMax][1] - VB->Win.data[vMin][1];
eTop.dx = VB->Win.data[vMax][0] - VB->Win.data[vMid][0];
eTop.dy = VB->Win.data[vMax][1] - VB->Win.data[vMid][1];
eBot.dx = VB->Win.data[vMid][0] - VB->Win.data[vMin][0];
eBot.dy = VB->Win.data[vMid][1] - VB->Win.data[vMin][1];
eMaj.dx = vMax->win[0] - vMin->win[0];
eMaj.dy = vMax->win[1] - vMin->win[1];
eTop.dx = vMax->win[0] - vMid->win[0];
eTop.dy = vMax->win[1] - vMid->win[1];
eBot.dx = vMid->win[0] - vMin->win[0];
eBot.dy = vMid->win[1] - vMin->win[1];
/* compute oneOverArea */
{
@ -167,11 +166,11 @@
/* Edge setup. For a triangle strip these could be reused... */
{
/* fixed point Y coordinates */
GLfixed vMin_fx = FloatToFixed(VB->Win.data[vMin][0] + 0.5F);
GLfixed vMin_fy = FloatToFixed(VB->Win.data[vMin][1] - 0.5F);
GLfixed vMid_fx = FloatToFixed(VB->Win.data[vMid][0] + 0.5F);
GLfixed vMid_fy = FloatToFixed(VB->Win.data[vMid][1] - 0.5F);
GLfixed vMax_fy = FloatToFixed(VB->Win.data[vMax][1] - 0.5F);
GLfixed vMin_fx = FloatToFixed(vMin->win[0] + 0.5F);
GLfixed vMin_fy = FloatToFixed(vMin->win[1] - 0.5F);
GLfixed vMid_fx = FloatToFixed(vMid->win[0] + 0.5F);
GLfixed vMid_fy = FloatToFixed(vMid->win[1] - 0.5F);
GLfixed vMax_fy = FloatToFixed(vMax->win[1] - 0.5F);
eMaj.fsy = FixedCeil(vMin_fy);
eMaj.lines = FixedToInt(vMax_fy + FIXED_ONE - FIXED_EPSILON - eMaj.fsy);
@ -293,8 +292,8 @@
#ifdef INTERP_Z
{
GLfloat eMaj_dz, eBot_dz;
eMaj_dz = VB->Win.data[vMax][2] - VB->Win.data[vMin][2];
eBot_dz = VB->Win.data[vMid][2] - VB->Win.data[vMin][2];
eMaj_dz = vMax->win[2] - vMin->win[2];
eBot_dz = vMid->win[2] - vMin->win[2];
dzdx = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz);
if (dzdx > maxDepth || dzdx < -maxDepth) {
/* probably a sliver triangle */
@ -311,8 +310,8 @@
}
{
GLfloat eMaj_dfog, eBot_dfog;
eMaj_dfog = (VB->FogCoordPtr->data[vMax] - VB->FogCoordPtr->data[vMin]) * 256;
eBot_dfog = (VB->FogCoordPtr->data[vMid] - VB->FogCoordPtr->data[vMin]) * 256;
eMaj_dfog = (vMax->fog - vMin->fog) * 256;
eBot_dfog = (vMid->fog - vMin->fog) * 256;
dfogdx = oneOverArea * (eMaj_dfog * eBot.dy - eMaj.dy * eBot_dfog);
fdfogdx = SignedFloatToFixed(dfogdx);
dfogdy = oneOverArea * (eMaj.dx * eBot_dfog - eMaj_dfog * eBot.dx);
@ -321,30 +320,30 @@
#ifdef INTERP_RGB
{
GLfloat eMaj_dr, eBot_dr;
eMaj_dr = (GLint) VB->ColorPtr->data[vMax][0]
- (GLint) VB->ColorPtr->data[vMin][0];
eBot_dr = (GLint) VB->ColorPtr->data[vMid][0]
- (GLint) VB->ColorPtr->data[vMin][0];
eMaj_dr = (GLint) vMax->color[0]
- (GLint) vMin->color[0];
eBot_dr = (GLint) vMid->color[0]
- (GLint) vMin->color[0];
drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
fdrdx = SignedFloatToFixed(drdx);
drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
}
{
GLfloat eMaj_dg, eBot_dg;
eMaj_dg = (GLint) VB->ColorPtr->data[vMax][1]
- (GLint) VB->ColorPtr->data[vMin][1];
eBot_dg = (GLint) VB->ColorPtr->data[vMid][1]
- (GLint) VB->ColorPtr->data[vMin][1];
eMaj_dg = (GLint) vMax->color[1]
- (GLint) vMin->color[1];
eBot_dg = (GLint) vMid->color[1]
- (GLint) vMin->color[1];
dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg);
fdgdx = SignedFloatToFixed(dgdx);
dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx);
}
{
GLfloat eMaj_db, eBot_db;
eMaj_db = (GLint) VB->ColorPtr->data[vMax][2]
- (GLint) VB->ColorPtr->data[vMin][2];
eBot_db = (GLint) VB->ColorPtr->data[vMid][2]
- (GLint) VB->ColorPtr->data[vMin][2];
eMaj_db = (GLint) vMax->color[2]
- (GLint) vMin->color[2];
eBot_db = (GLint) vMid->color[2]
- (GLint) vMin->color[2];
dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db);
fdbdx = SignedFloatToFixed(dbdx);
dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx);
@ -353,30 +352,30 @@
#ifdef INTERP_SPEC
{
GLfloat eMaj_dsr, eBot_dsr;
eMaj_dsr = (GLint) VB->SecondaryColorPtr->data[vMax][0]
- (GLint) VB->SecondaryColorPtr->data[vMin][0];
eBot_dsr = (GLint) VB->SecondaryColorPtr->data[vMid][0]
- (GLint) VB->SecondaryColorPtr->data[vMin][0];
eMaj_dsr = (GLint) vMax->specular[0]
- (GLint) vMin->specular[0];
eBot_dsr = (GLint) vMid->specular[0]
- (GLint) vMin->specular[0];
dsrdx = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr);
fdsrdx = SignedFloatToFixed(dsrdx);
dsrdy = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx);
}
{
GLfloat eMaj_dsg, eBot_dsg;
eMaj_dsg = (GLint) VB->SecondaryColorPtr->data[vMax][1]
- (GLint) VB->SecondaryColorPtr->data[vMin][1];
eBot_dsg = (GLint) VB->SecondaryColorPtr->data[vMid][1]
- (GLint) VB->SecondaryColorPtr->data[vMin][1];
eMaj_dsg = (GLint) vMax->specular[1]
- (GLint) vMin->specular[1];
eBot_dsg = (GLint) vMid->specular[1]
- (GLint) vMin->specular[1];
dsgdx = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg);
fdsgdx = SignedFloatToFixed(dsgdx);
dsgdy = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx);
}
{
GLfloat eMaj_dsb, eBot_dsb;
eMaj_dsb = (GLint) VB->SecondaryColorPtr->data[vMax][2]
- (GLint) VB->SecondaryColorPtr->data[vMin][2];
eBot_dsb = (GLint) VB->SecondaryColorPtr->data[vMid][2]
- (GLint) VB->SecondaryColorPtr->data[vMin][2];
eMaj_dsb = (GLint) vMax->specular[2]
- (GLint) vMin->specular[2];
eBot_dsb = (GLint) vMid->specular[2]
- (GLint) vMin->specular[2];
dsbdx = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb);
fdsbdx = SignedFloatToFixed(dsbdx);
dsbdy = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx);
@ -385,10 +384,10 @@
#ifdef INTERP_ALPHA
{
GLfloat eMaj_da, eBot_da;
eMaj_da = (GLint) VB->ColorPtr->data[vMax][3]
- (GLint) VB->ColorPtr->data[vMin][3];
eBot_da = (GLint) VB->ColorPtr->data[vMid][3]
- (GLint) VB->ColorPtr->data[vMin][3];
eMaj_da = (GLint) vMax->color[3]
- (GLint) vMin->color[3];
eBot_da = (GLint) vMid->color[3]
- (GLint) vMin->color[3];
dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da);
fdadx = SignedFloatToFixed(dadx);
dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx);
@ -397,10 +396,10 @@
#ifdef INTERP_INDEX
{
GLfloat eMaj_di, eBot_di;
eMaj_di = (GLint) VB->IndexPtr->data[vMax]
- (GLint) VB->IndexPtr->data[vMin];
eBot_di = (GLint) VB->IndexPtr->data[vMid]
- (GLint) VB->IndexPtr->data[vMin];
eMaj_di = (GLint) vMax->index
- (GLint) vMin->index;
eBot_di = (GLint) vMid->index
- (GLint) vMin->index;
didx = oneOverArea * (eMaj_di * eBot.dy - eMaj.dy * eBot_di);
fdidx = SignedFloatToFixed(didx);
didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx);
@ -409,150 +408,94 @@
#ifdef INTERP_INT_TEX
{
GLfloat eMaj_ds, eBot_ds;
eMaj_ds = (VB->TexCoordPtr[0]->data[vMax][0]
- VB->TexCoordPtr[0]->data[vMin][0]) * S_SCALE;
eBot_ds = (VB->TexCoordPtr[0]->data[vMid][0]
- VB->TexCoordPtr[0]->data[vMin][0]) * S_SCALE;
eMaj_ds = (vMax->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
eBot_ds = (vMid->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
dsdx = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
fdsdx = SignedFloatToFixed(dsdx);
dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
}
if (VB->TexCoordPtr[0]->size > 1) {
{
GLfloat eMaj_dt, eBot_dt;
eMaj_dt = (VB->TexCoordPtr[0]->data[vMax][1]
- VB->TexCoordPtr[0]->data[vMin][1]) * T_SCALE;
eBot_dt = (VB->TexCoordPtr[0]->data[vMid][1]
- VB->TexCoordPtr[0]->data[vMin][1]) * T_SCALE;
eMaj_dt = (vMax->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
eBot_dt = (vMid->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
dtdx = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
fdtdx = SignedFloatToFixed(dtdx);
dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
}
else {
dtdx = 0;
fdtdx = SignedFloatToFixed(dtdx);
dtdy = 0;
}
#endif
#ifdef INTERP_TEX
{
GLfloat wMax = VB->Win.data[vMax][3];
GLfloat wMin = VB->Win.data[vMin][3];
GLfloat wMid = VB->Win.data[vMid][3];
GLfloat wMax = vMax->win[3];
GLfloat wMin = vMin->win[3];
GLfloat wMid = vMid->win[3];
GLfloat eMaj_ds, eBot_ds;
GLfloat eMaj_dt, eBot_dt;
GLfloat eMaj_du, eBot_du;
GLfloat eMaj_dv, eBot_dv;
eMaj_ds = VB->TexCoordPtr[0]->data[vMax][0] * wMax
- VB->TexCoordPtr[0]->data[vMin][0] * wMin;
eBot_ds = VB->TexCoordPtr[0]->data[vMid][0] * wMid
- VB->TexCoordPtr[0]->data[vMin][0] * wMin;
eMaj_ds = vMax->texcoord[0][0] * wMax - vMin->texcoord[0][0] * wMin;
eBot_ds = vMid->texcoord[0][0] * wMid - vMin->texcoord[0][0] * wMin;
dsdx = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
dsdy = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
if (VB->TexCoordPtr[0]->size > 1) {
eMaj_dt = VB->TexCoordPtr[0]->data[vMax][1] * wMax
- VB->TexCoordPtr[0]->data[vMin][1] * wMin;
eBot_dt = VB->TexCoordPtr[0]->data[vMid][1] * wMid
- VB->TexCoordPtr[0]->data[vMin][1] * wMin;
dtdx = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
}
else {
dtdx = 0;
dtdy = 0;
}
eMaj_dt = vMax->texcoord[0][1] * wMax - vMin->texcoord[0][1] * wMin;
eBot_dt = vMid->texcoord[0][1] * wMid - vMin->texcoord[0][1] * wMin;
dtdx = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
dtdy = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
eMaj_du = vMax->texcoord[0][2] * wMax - vMin->texcoord[0][2] * wMin;
eBot_du = vMid->texcoord[0][2] * wMid - vMin->texcoord[0][2] * wMin;
dudx = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du);
dudy = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
if (VB->TexCoordPtr[0]->size > 2) {
eMaj_du = VB->TexCoordPtr[0]->data[vMax][2] * wMax
- VB->TexCoordPtr[0]->data[vMin][2] * wMin;
eBot_du = VB->TexCoordPtr[0]->data[vMid][2] * wMid
- VB->TexCoordPtr[0]->data[vMin][2] * wMin;
dudx = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du);
dudy = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
}
else {
dudx = 0;
dudy = 0;
}
if (VB->TexCoordPtr[0]->size > 3) {
eMaj_dv = VB->TexCoordPtr[0]->data[vMax][3] * wMax
- VB->TexCoordPtr[0]->data[vMin][3] * wMin;
eBot_dv = VB->TexCoordPtr[0]->data[vMid][3] * wMid
- VB->TexCoordPtr[0]->data[vMin][3] * wMin;
dvdx = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
dvdy = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
}
else {
eMaj_dv = wMax - wMin;
eBot_dv = wMid - wMin;
dvdx = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
dvdy = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
}
eMaj_dv = vMax->texcoord[0][3] * wMax - vMin->texcoord[0][3] * wMin;
eBot_dv = vMid->texcoord[0][3] * wMid - vMin->texcoord[0][3] * wMin;
dvdx = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
dvdy = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
}
#endif
#ifdef INTERP_MULTITEX
{
GLfloat wMax = VB->Win.data[vMax][3];
GLfloat wMin = VB->Win.data[vMin][3];
GLfloat wMid = VB->Win.data[vMid][3];
GLfloat wMax = vMax->win[3];
GLfloat wMin = vMin->win[3];
GLfloat wMid = vMid->win[3];
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
GLfloat eMaj_ds, eBot_ds;
GLfloat eMaj_dt, eBot_dt;
GLfloat eMaj_du, eBot_du;
GLfloat eMaj_dv, eBot_dv;
eMaj_ds = VB->TexCoordPtr[u]->data[vMax][0] * wMax
- VB->TexCoordPtr[u]->data[vMin][0] * wMin;
eBot_ds = VB->TexCoordPtr[u]->data[vMid][0] * wMid
- VB->TexCoordPtr[u]->data[vMin][0] * wMin;
eMaj_ds = vMax->texcoord[u][0] * wMax
- vMin->texcoord[u][0] * wMin;
eBot_ds = vMid->texcoord[u][0] * wMid
- vMin->texcoord[u][0] * wMin;
dsdx[u] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
dsdy[u] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
if (VB->TexCoordPtr[u]->size > 1) {
eMaj_dt = VB->TexCoordPtr[u]->data[vMax][1] * wMax
- VB->TexCoordPtr[u]->data[vMin][1] * wMin;
eBot_dt = VB->TexCoordPtr[u]->data[vMid][1] * wMid
- VB->TexCoordPtr[u]->data[vMin][1] * wMin;
dtdx[u] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
dtdy[u] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
}
else {
dtdx[u] = 0.0;
dtdy[u] = 0.0;
}
if (VB->TexCoordPtr[u]->size > 2) {
eMaj_du = VB->TexCoordPtr[u]->data[vMax][2] * wMax
- VB->TexCoordPtr[u]->data[vMin][2] * wMin;
eBot_du = VB->TexCoordPtr[u]->data[vMid][2] * wMid
- VB->TexCoordPtr[u]->data[vMin][2] * wMin;
dudx[u] = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du);
dudy[u] = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
}
else {
dudx[u] = 0.0;
dudy[u] = 0.0;
}
if (VB->TexCoordPtr[u]->size > 3) {
eMaj_dv = VB->TexCoordPtr[u]->data[vMax][3] * wMax
- VB->TexCoordPtr[u]->data[vMin][3] * wMin;
eBot_dv = VB->TexCoordPtr[u]->data[vMid][3] * wMid
- VB->TexCoordPtr[u]->data[vMin][3] * wMin;
dvdx[u] = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
dvdy[u] = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
}
else {
eMaj_dv = wMax - wMin;
eBot_dv = wMid - wMin;
dvdx[u] = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
dvdy[u] = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
}
eMaj_dt = vMax->texcoord[u][1] * wMax
- vMin->texcoord[u][1] * wMin;
eBot_dt = vMid->texcoord[u][1] * wMid
- vMin->texcoord[u][1] * wMin;
dtdx[u] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
dtdy[u] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
eMaj_du = vMax->texcoord[u][2] * wMax
- vMin->texcoord[u][2] * wMin;
eBot_du = vMid->texcoord[u][2] * wMid
- vMin->texcoord[u][2] * wMin;
dudx[u] = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du);
dudy[u] = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
eMaj_dv = vMax->texcoord[u][3] * wMax
- vMin->texcoord[u][3] * wMin;
eBot_dv = vMid->texcoord[u][3] * wMid
- vMin->texcoord[u][3] * wMin;
dvdx[u] = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
dvdy[u] = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
}
}
}
@ -707,7 +650,7 @@
}
if (setupLeft && eLeft->lines > 0) {
GLint vLower;
SWvertex *vLower;
GLfixed fsx = eLeft->fsx;
fx = FixedCeil(fsx);
fError = fx - fsx - FIXED_ONE;
@ -749,7 +692,7 @@
#ifdef INTERP_Z
{
GLfloat z0 = VB->Win.data[vLower][2] + ctx->PolygonZoffset;
GLfloat z0 = vLower->win[2];
if (depthBits <= 16) {
/* interpolate fixed-pt values */
GLfloat tmp = (z0 * FIXED_SCALE +
@ -770,95 +713,71 @@
dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(DEPTH_TYPE);
# endif
}
ffog = FloatToFixed(VB->FogCoordPtr->data[vLower]) * 256 + dfogdx * adjx + dfogdy * adjy + FIXED_HALF;
ffog = FloatToFixed(vLower->fog) * 256 + dfogdx * adjx + dfogdy * adjy + FIXED_HALF;
fdfogOuter = SignedFloatToFixed(dfogdy + dxOuter * dfogdx);
#endif
#ifdef INTERP_RGB
fr = (GLfixed)(IntToFixed(VB->ColorPtr->data[vLower][0])
fr = (GLfixed)(IntToFixed(vLower->color[0])
+ drdx * adjx + drdy * adjy) + FIXED_HALF;
fdrOuter = SignedFloatToFixed(drdy + dxOuter * drdx);
fg = (GLfixed)(IntToFixed(VB->ColorPtr->data[vLower][1])
fg = (GLfixed)(IntToFixed(vLower->color[1])
+ dgdx * adjx + dgdy * adjy) + FIXED_HALF;
fdgOuter = SignedFloatToFixed(dgdy + dxOuter * dgdx);
fb = (GLfixed)(IntToFixed(VB->ColorPtr->data[vLower][2])
fb = (GLfixed)(IntToFixed(vLower->color[2])
+ dbdx * adjx + dbdy * adjy) + FIXED_HALF;
fdbOuter = SignedFloatToFixed(dbdy + dxOuter * dbdx);
#endif
#ifdef INTERP_SPEC
fsr = (GLfixed)(IntToFixed(VB->SecondaryColorPtr->data[vLower][0])
fsr = (GLfixed)(IntToFixed(vLower->specular[0])
+ dsrdx * adjx + dsrdy * adjy) + FIXED_HALF;
fdsrOuter = SignedFloatToFixed(dsrdy + dxOuter * dsrdx);
fsg = (GLfixed)(IntToFixed(VB->SecondaryColorPtr->data[vLower][1])
fsg = (GLfixed)(IntToFixed(vLower->specular[1])
+ dsgdx * adjx + dsgdy * adjy) + FIXED_HALF;
fdsgOuter = SignedFloatToFixed(dsgdy + dxOuter * dsgdx);
fsb = (GLfixed)(IntToFixed(VB->SecondaryColorPtr->data[vLower][2])
fsb = (GLfixed)(IntToFixed(vLower->specular[2])
+ dsbdx * adjx + dsbdy * adjy) + FIXED_HALF;
fdsbOuter = SignedFloatToFixed(dsbdy + dxOuter * dsbdx);
#endif
#ifdef INTERP_ALPHA
fa = (GLfixed)(IntToFixed(VB->ColorPtr->data[vLower][3])
fa = (GLfixed)(IntToFixed(vLower->color[3])
+ dadx * adjx + dady * adjy) + FIXED_HALF;
fdaOuter = SignedFloatToFixed(dady + dxOuter * dadx);
#endif
#ifdef INTERP_INDEX
fi = (GLfixed)(VB->IndexPtr->data[vLower] * FIXED_SCALE
fi = (GLfixed)(vLower->index * FIXED_SCALE
+ didx * adjx + didy * adjy) + FIXED_HALF;
fdiOuter = SignedFloatToFixed(didy + dxOuter * didx);
#endif
#ifdef INTERP_INT_TEX
{
GLfloat s0, t0;
s0 = VB->TexCoordPtr[0]->data[vLower][0] * S_SCALE;
s0 = vLower->texcoord[0][0] * S_SCALE;
fs = (GLfixed)(s0 * FIXED_SCALE + dsdx * adjx + dsdy * adjy) + FIXED_HALF;
fdsOuter = SignedFloatToFixed(dsdy + dxOuter * dsdx);
if (VB->TexCoordPtr[0]->size > 1)
{
t0 = VB->TexCoordPtr[0]->data[vLower][1] * T_SCALE;
ft = (GLfixed)(t0 * FIXED_SCALE + dtdx * adjx + dtdy * adjy) + FIXED_HALF;
fdtOuter = SignedFloatToFixed(dtdy + dxOuter * dtdx);
}
else
{
t0 = 0;
ft = (GLfixed) FIXED_HALF;
fdtOuter = SignedFloatToFixed(0);
}
t0 = vLower->texcoord[0][1] * T_SCALE;
ft = (GLfixed)(t0 * FIXED_SCALE + dtdx * adjx + dtdy * adjy) + FIXED_HALF;
fdtOuter = SignedFloatToFixed(dtdy + dxOuter * dtdx);
}
#endif
#ifdef INTERP_TEX
{
GLfloat invW = VB->Win.data[vLower][3];
GLfloat invW = vLower->win[3];
GLfloat s0, t0, u0, v0;
s0 = VB->TexCoordPtr[0]->data[vLower][0] * invW;
s0 = vLower->texcoord[0][0] * invW;
sLeft = s0 + (dsdx * adjx + dsdy * adjy) * (1.0F/FIXED_SCALE);
dsOuter = dsdy + dxOuter * dsdx;
if (VB->TexCoordPtr[0]->size > 1) {
t0 = VB->TexCoordPtr[0]->data[vLower][1] * invW;
tLeft = t0 + (dtdx * adjx + dtdy * adjy) * (1.0F/FIXED_SCALE);
dtOuter = dtdy + dxOuter * dtdx;
}
else {
tLeft = dtOuter = 0.0;
}
if (VB->TexCoordPtr[0]->size > 2) {
u0 = VB->TexCoordPtr[0]->data[vLower][2] * invW;
uLeft = u0 + (dudx * adjx + dudy * adjy) * (1.0F/FIXED_SCALE);
duOuter = dudy + dxOuter * dudx;
}
else {
uLeft = duOuter = 0.0;
}
if (VB->TexCoordPtr[0]->size > 3) {
v0 = VB->TexCoordPtr[0]->data[vLower][3] * invW;
}
else {
v0 = invW;
}
t0 = vLower->texcoord[0][1] * invW;
tLeft = t0 + (dtdx * adjx + dtdy * adjy) * (1.0F/FIXED_SCALE);
dtOuter = dtdy + dxOuter * dtdx;
u0 = vLower->texcoord[0][2] * invW;
uLeft = u0 + (dudx * adjx + dudy * adjy) * (1.0F/FIXED_SCALE);
duOuter = dudy + dxOuter * dudx;
v0 = vLower->texcoord[0][3] * invW;
vLeft = v0 + (dvdx * adjx + dvdy * adjy) * (1.0F/FIXED_SCALE);
dvOuter = dvdy + dxOuter * dvdx;
}
@ -867,34 +786,19 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
GLfloat invW = VB->Win.data[vLower][3];
if (ctx->Texture.Unit[u]._ReallyEnabled) {
GLfloat invW = vLower->win[3];
GLfloat s0, t0, u0, v0;
s0 = VB->TexCoordPtr[u]->data[vLower][0] * invW;
s0 = vLower->texcoord[u][0] * invW;
sLeft[u] = s0 + (dsdx[u] * adjx + dsdy[u] * adjy) * (1.0F/FIXED_SCALE);
dsOuter[u] = dsdy[u] + dxOuter * dsdx[u];
if (VB->TexCoordPtr[u]->size > 1) {
t0 = VB->TexCoordPtr[u]->data[vLower][1] * invW;
tLeft[u] = t0 + (dtdx[u] * adjx + dtdy[u] * adjy) * (1.0F/FIXED_SCALE);
dtOuter[u] = dtdy[u] + dxOuter * dtdx[u];
}
else {
tLeft[u] = dtOuter[u] = 0.0;
}
if (VB->TexCoordPtr[u]->size > 2) {
u0 = VB->TexCoordPtr[u]->data[vLower][2] * invW;
uLeft[u] = u0 + (dudx[u] * adjx + dudy[u] * adjy) * (1.0F/FIXED_SCALE);
duOuter[u] = dudy[u] + dxOuter * dudx[u];
}
else {
uLeft[u] = duOuter[u] = 0.0;
}
if (VB->TexCoordPtr[u]->size > 3) {
v0 = VB->TexCoordPtr[u]->data[vLower][3] * invW;
}
else {
v0 = invW;
}
t0 = vLower->texcoord[u][1] * invW;
tLeft[u] = t0 + (dtdx[u] * adjx + dtdy[u] * adjy) * (1.0F/FIXED_SCALE);
dtOuter[u] = dtdy[u] + dxOuter * dtdx[u];
u0 = vLower->texcoord[u][2] * invW;
uLeft[u] = u0 + (dudx[u] * adjx + dudy[u] * adjy) * (1.0F/FIXED_SCALE);
duOuter[u] = dudy[u] + dxOuter * dudx[u];
v0 = vLower->texcoord[u][3] * invW;
vLeft[u] = v0 + (dvdx[u] * adjx + dvdy[u] * adjy) * (1.0F/FIXED_SCALE);
dvOuter[u] = dvdy[u] + dxOuter * dvdx[u];
}
@ -956,7 +860,7 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
dsInner[u] = dsOuter[u] + dsdx[u];
dtInner[u] = dtOuter[u] + dtdx[u];
duInner[u] = duOuter[u] + dudx[u];
@ -1001,7 +905,7 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
ss[u] = sLeft[u];
tt[u] = tLeft[u];
uu[u] = uLeft[u];
@ -1103,7 +1007,7 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
sLeft[u] += dsOuter[u];
tLeft[u] += dtOuter[u];
uLeft[u] += duOuter[u];
@ -1149,7 +1053,7 @@
{
GLuint u;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
if (ctx->Texture.Unit[u].ReallyEnabled) {
if (ctx->Texture.Unit[u]._ReallyEnabled) {
sLeft[u] += dsInner[u];
tLeft[u] += dtInner[u];
uLeft[u] += duInner[u];

View file

@ -1,4 +1,4 @@
/* $Id: s_zoom.c,v 1.1 2000/10/31 18:00:05 keithw Exp $ */
/* $Id: s_zoom.c,v 1.2 2000/11/05 18:24:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -27,6 +27,7 @@
#include "glheader.h"
#include "macros.h"
#include "s_context.h"
#include "s_span.h"
#include "s_stencil.h"
#include "s_zoom.h"

View file

@ -1,13 +1,83 @@
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999 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"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* 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 <keithw@valinux.com>
*/
#ifndef SWRAST_H
#define SWRAST_H
#include "types.h"
/* These are the functions exported from swrast. (more to come)
/* The software rasterizer now uses this format for vertices. Thus a
* 'RasterSetup' stage or other translation is required between the
* tnl module and the swrast rasterization functions. This serves to
* isolate the swrast module from the internals of the tnl module, and
* improve its usefulness as a fallback mechanism for hardware
* drivers.
*
* Full software drivers:
* - Register the rastersetup and triangle functions from
* utils/software_helper.
* - On statechange, update the rasterization pointers in that module.
*
* Rasterization hardware drivers:
* - Keep native rastersetup.
* - Implement native twoside,offset and unfilled triangle setup.
* - Implement a translator from native vertices to swrast vertices.
* - On partial fallback (mix of accelerated and unaccelerated
* prims), call a pass-through function which translates native
* vertices to SWvertices and calls the appropriate swrast function.
* - On total fallback (vertex format insufficient for state or all
* primitives unaccelerated), hook in swrast_setup instead.
*/
typedef struct {
GLfloat win[4];
GLfloat eye[4]; /* for GL_EXT_point_param only */
GLfloat texcoord[MAX_TEXTURE_UNITS][4];
GLchan color[4];
GLchan specular[4];
GLfloat fog;
GLuint index;
} SWvertex;
/* These are the public-access functions exported from swrast.
*/
void
_swrast_alloc_buffers( GLcontext *ctx );
GLboolean
_swrast_CreateContext( GLcontext *ctx );
void
_swrast_DestroyContext( GLcontext *ctx );
void
_swrast_Bitmap( GLcontext *ctx,
@ -47,62 +117,35 @@ _swrast_Accum( GLcontext *ctx, GLenum op,
GLfloat value, GLint xpos, GLint ypos,
GLint width, GLint height );
void
_swrast_set_line_function( GLcontext *ctx );
/* Get a pointer to the stipple counter.
*/
GLuint *
_swrast_get_stipple_counter_ref( GLcontext *ctx );
void
_swrast_set_point_function( GLcontext *ctx );
void
_swrast_set_triangle_function( GLcontext *ctx );
/* These will always render the correct point/line/triangle for the
* current state.
*/
void
_swrast_Point( GLcontext *ctx, SWvertex *v );
void
_swrast_set_quad_function( GLcontext *ctx );
void
_swrast_Line( GLcontext *ctx, SWvertex *v0, SWvertex *v1 );
void
_swrast_Triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2 );
void
_swrast_Quad( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2,
SWvertex *v3);
void
_swrast_flush( GLcontext *ctx );
GLboolean
_swrast_create_context( GLcontext *ctx );
void
_swrast_destroy_context( GLcontext *ctx );
/* Replace:
/* Tell the software rasterizer about core state changes.
*/
void
_swrast_set_texture_sampler( struct gl_texture_object *t );
#define _SWRAST_NEW_TRIANGLE (_NEW_RENDERMODE| \
_NEW_POLYGON| \
_NEW_DEPTH| \
_NEW_STENCIL| \
_NEW_COLOR| \
_NEW_TEXTURE| \
_NEW_HINT| \
_SWRAST_NEW_RASTERMASK| \
_NEW_LIGHT| \
_NEW_FOG)
#define _SWRAST_NEW_LINE (_NEW_RENDERMODE| \
_NEW_LINE| \
_NEW_TEXTURE| \
_NEW_LIGHT| \
_NEW_FOG| \
_NEW_DEPTH)
#define _SWRAST_NEW_POINT (_NEW_RENDERMODE | \
_NEW_POINT | \
_NEW_TEXTURE | \
_NEW_LIGHT | \
_NEW_FOG)
_swrast_InvalidateState( GLcontext *ctx, GLuint new_state );
#endif