Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 142 → Rev 143

/shark/trunk/ports/mesa/src/swrast_setup/ss_context.h
File deleted
/shark/trunk/ports/mesa/src/swrast_setup/ss_triangle.h
File deleted
/shark/trunk/ports/mesa/src/swrast_setup/ss_vb.h
File deleted
/shark/trunk/ports/mesa/src/swrast_setup/ss_vbtmp.h
File deleted
/shark/trunk/ports/mesa/src/swrast_setup/swrast_setup.h
File deleted
/shark/trunk/ports/mesa/src/swrast_setup/ss_tritmp.h
File deleted
/shark/trunk/ports/mesa/src/swrast_setup/ss_context.c
File deleted
/shark/trunk/ports/mesa/src/swrast_setup/ss_triangle.c
File deleted
/shark/trunk/ports/mesa/src/swrast_setup/ss_vb.c
File deleted
/shark/trunk/ports/mesa/src/swrastst/ss_context.h
0,0 → 1,51
/* $Id: ss_context.h,v 1.1 2003-04-29 12:46:51 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
* Version: 4.1
*
* Copyright (C) 1999-2002 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 <keith@tungstengraphics.com>
*/
 
#ifndef SS_CONTEXT_H
#define SS_CONTEXT_H
 
#include "mtypes.h"
#include "swrast/swrast.h"
#include "swrast_setup.h"
 
typedef struct {
GLuint NewState;
SWvertex *verts;
GLenum render_prim;
GLuint SetupIndex;
 
/* Temporaries for translating away float colors:
*/
struct gl_client_array ChanColor;
struct gl_client_array ChanSecondaryColor;
} SScontext;
 
#define SWSETUP_CONTEXT(ctx) ((SScontext *)ctx->swsetup_context)
 
#endif
/shark/trunk/ports/mesa/src/swrastst/ss_triangle.h
0,0 → 1,40
/* $Id: ss_triangle.h,v 1.1 2003-04-29 12:46:51 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 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 <keith@tungstengraphics.com>
*/
 
#ifndef SS_TRIANGLE_H
#define SS_TRIANGLE_H
 
#include "mtypes.h"
#include "ss_context.h"
 
 
void _swsetup_trifuncs_init( GLcontext *ctx );
void _swsetup_choose_trifuncs( GLcontext *ctx );
 
#endif
/shark/trunk/ports/mesa/src/swrastst/ss_vb.h
0,0 → 1,39
/* $Id: ss_vb.h,v 1.1 2003-04-29 12:46:52 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 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 <keith@tungstengraphics.com>
*/
 
#ifndef SS_VB_H
#define SS_VB_H
 
#include "mtypes.h"
#include "swrast_setup.h"
 
void _swsetup_vb_init( GLcontext *ctx );
void _swsetup_choose_rastersetup_func( GLcontext *ctx );
 
#endif
/shark/trunk/ports/mesa/src/swrastst/ss_vbtmp.h
0,0 → 1,254
/* $Id: ss_vbtmp.h,v 1.1 2003-04-29 12:46:52 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
* Version: 4.1
*
* Copyright (C) 1999-2002 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 <keith@tungstengraphics.com>
*/
 
 
static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
GLuint newinputs )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
SWvertex *v;
GLfloat *proj; /* projected clip coordinates */
GLfloat *tc[MAX_TEXTURE_UNITS];
GLchan *color;
GLchan *spec;
GLuint *index;
GLfloat *fog;
GLfloat *pointSize;
GLuint tsz[MAX_TEXTURE_UNITS];
GLuint tstride[MAX_TEXTURE_UNITS];
GLuint proj_stride, color_stride, spec_stride, index_stride;
GLuint fog_stride, pointSize_stride;
GLuint i;
GLfloat *m = ctx->Viewport._WindowMap.m;
const GLfloat sx = m[0];
const GLfloat sy = m[5];
const GLfloat sz = m[10];
const GLfloat tx = m[12];
const GLfloat ty = m[13];
const GLfloat tz = m[14];
GLuint maxtex = 0;
 
if (IND & TEX0) {
tc[0] = (GLfloat *)VB->TexCoordPtr[0]->data;
tsz[0] = VB->TexCoordPtr[0]->size;
tstride[0] = VB->TexCoordPtr[0]->stride;
}
 
if (IND & MULTITEX) {
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
if (VB->TexCoordPtr[i]) {
maxtex = i+1;
tc[i] = (GLfloat *)VB->TexCoordPtr[i]->data;
tsz[i] = VB->TexCoordPtr[i]->size;
tstride[i] = VB->TexCoordPtr[i]->stride;
}
else tc[i] = 0;
}
}
 
proj = VB->NdcPtr->data[0];
proj_stride = VB->NdcPtr->stride;
 
if (IND & FOG) {
fog = (GLfloat *) VB->FogCoordPtr->data;
fog_stride = VB->FogCoordPtr->stride;
}
if (IND & COLOR) {
if (VB->ColorPtr[0]->Type != CHAN_TYPE)
import_float_colors( ctx );
 
color = (GLchan *) VB->ColorPtr[0]->Ptr;
color_stride = VB->ColorPtr[0]->StrideB;
}
if (IND & SPEC) {
if (VB->SecondaryColorPtr[0]->Type != CHAN_TYPE)
import_float_spec_colors( ctx );
 
spec = (GLchan *) VB->SecondaryColorPtr[0]->Ptr;
spec_stride = VB->SecondaryColorPtr[0]->StrideB;
}
if (IND & INDEX) {
index = VB->IndexPtr[0]->data;
index_stride = VB->IndexPtr[0]->stride;
}
if (IND & POINT) {
pointSize = (GLfloat *) VB->PointSizePtr->data;
pointSize_stride = VB->PointSizePtr->stride;
}
 
v = &(SWSETUP_CONTEXT(ctx)->verts[start]);
 
for (i=start; i < end; i++, v++) {
if (VB->ClipMask[i] == 0) {
v->win[0] = sx * proj[0] + tx;
v->win[1] = sy * proj[1] + ty;
v->win[2] = sz * proj[2] + tz;
v->win[3] = proj[3];
}
STRIDE_F(proj, proj_stride);
 
if (IND & TEX0) {
COPY_CLEAN_4V( v->texcoord[0], tsz[0], tc[0] );
STRIDE_F(tc[0], tstride[0]);
}
 
if (IND & MULTITEX) {
GLuint u;
for (u = 0 ; u < maxtex ; u++)
if (tc[u]) {
COPY_CLEAN_4V( v->texcoord[u], tsz[u], tc[u] );
STRIDE_F(tc[u], tstride[u]);
}
}
 
if (IND & COLOR) {
COPY_CHAN4(v->color, color);
STRIDE_CHAN(color, color_stride);
}
 
if (IND & SPEC) {
COPY_CHAN4(v->specular, spec);
STRIDE_CHAN(spec, spec_stride);
}
 
if (IND & FOG) {
v->fog = fog[0];
STRIDE_F(fog, fog_stride);
}
 
if (IND & INDEX) {
v->index = index[0];
STRIDE_UI(index, index_stride);
}
 
if (IND & POINT) {
v->pointSize = pointSize[0];
STRIDE_F(pointSize, pointSize_stride);
}
}
}
 
 
 
static void TAG(interp)( GLcontext *ctx,
GLfloat t,
GLuint edst, GLuint eout, GLuint ein,
GLboolean force_boundary )
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLfloat *m = ctx->Viewport._WindowMap.m;
GLfloat *clip = VB->ClipPtr->data[edst];
 
SWvertex *dst = &swsetup->verts[edst];
SWvertex *in = &swsetup->verts[ein];
SWvertex *out = &swsetup->verts[eout];
 
/* Avoid division by zero by rearranging order of clip planes?
*/
if (clip[3] != 0.0) {
GLfloat oow = 1.0F / clip[3];
dst->win[0] = m[0] * clip[0] * oow + m[12];
dst->win[1] = m[5] * clip[1] * oow + m[13];
dst->win[2] = m[10] * clip[2] * oow + m[14];
dst->win[3] = oow;
}
if (IND & TEX0) {
INTERP_4F( t, dst->texcoord[0], out->texcoord[0], in->texcoord[0] );
}
 
if (IND & MULTITEX) {
GLuint u;
GLuint maxtex = ctx->Const.MaxTextureUnits;
for (u = 0 ; u < maxtex ; u++)
if (VB->TexCoordPtr[u]) {
INTERP_4F( t, dst->texcoord[u], out->texcoord[u], in->texcoord[u] );
}
}
 
if (IND & COLOR) {
INTERP_CHAN( t, dst->color[0], out->color[0], in->color[0] );
INTERP_CHAN( t, dst->color[1], out->color[1], in->color[1] );
INTERP_CHAN( t, dst->color[2], out->color[2], in->color[2] );
INTERP_CHAN( t, dst->color[3], out->color[3], in->color[3] );
}
 
if (IND & SPEC) {
INTERP_CHAN( t, dst->specular[0], out->specular[0], in->specular[0] );
INTERP_CHAN( t, dst->specular[1], out->specular[1], in->specular[1] );
INTERP_CHAN( t, dst->specular[2], out->specular[2], in->specular[2] );
}
 
if (IND & FOG) {
INTERP_F( t, dst->fog, out->fog, in->fog );
}
 
if (IND & INDEX) {
INTERP_UI( t, dst->index, out->index, in->index );
}
 
/* XXX Point size interpolation??? */
if (IND & POINT) {
INTERP_F( t, dst->pointSize, out->pointSize, in->pointSize );
}
}
 
 
static void TAG(copy_pv)( GLcontext *ctx, GLuint edst, GLuint esrc )
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
SWvertex *dst = &swsetup->verts[edst];
SWvertex *src = &swsetup->verts[esrc];
 
if (IND & COLOR) {
COPY_CHAN4( dst->color, src->color );
}
 
if (IND & SPEC) {
COPY_3V( dst->specular, src->specular );
}
 
if (IND & INDEX) {
dst->index = src->index;
}
}
 
 
static void TAG(init)( void )
{
setup_tab[IND] = TAG(emit);
interp_tab[IND] = TAG(interp);
copy_pv_tab[IND] = TAG(copy_pv);
}
 
#undef TAG
#undef IND
#undef SETUP_FLAGS
/shark/trunk/ports/mesa/src/swrastst/swrast_setup.h
0,0 → 1,54
/* $Id: swrast_setup.h,v 1.1 2003-04-29 12:46:52 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 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 <keith@tungstengraphics.com>
*/
 
/* Public interface to the swrast_setup module. This module provides
* an implementation of the driver interface to t_vb_render.c, and uses
* the software rasterizer (swrast) to perform actual rasterization.
*
* The internals of the implementation are private, but can be hooked
* into tnl at any time (except between RenderStart/RenderEnd) by
* calling _swsetup_Wakeup().
*/
 
#ifndef SWRAST_SETUP_H
#define SWRAST_SETUP_H
 
extern GLboolean
_swsetup_CreateContext( GLcontext *ctx );
 
extern void
_swsetup_DestroyContext( GLcontext *ctx );
 
extern void
_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state );
 
extern void
_swsetup_Wakeup( GLcontext *ctx );
 
#endif
/shark/trunk/ports/mesa/src/swrastst/ss_context.c
0,0 → 1,167
/* $Id: ss_context.c,v 1.1 2003-04-29 12:46:51 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
* Version: 4.1
*
* Copyright (C) 1999-2002 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 <keith@tungstengraphics.com>
*/
 
#include "glheader.h"
#include "imports.h"
#include "ss_context.h"
#include "ss_triangle.h"
#include "ss_vb.h"
#include "swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
 
 
#define _SWSETUP_NEW_VERTS (_NEW_RENDERMODE| \
_NEW_POLYGON| \
_NEW_LIGHT| \
_NEW_TEXTURE| \
_NEW_COLOR| \
_NEW_FOG| \
_NEW_POINT)
 
#define _SWSETUP_NEW_RENDERINDEX (_NEW_POLYGON|_NEW_LIGHT)
 
 
GLboolean
_swsetup_CreateContext( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
SScontext *swsetup = (SScontext *)CALLOC(sizeof(SScontext));
 
if (!swsetup)
return GL_FALSE;
 
swsetup->verts = (SWvertex *) ALIGN_CALLOC( sizeof(SWvertex) * tnl->vb.Size,
32);
if (!swsetup->verts) {
FREE(swsetup);
return GL_FALSE;
}
 
ctx->swsetup_context = swsetup;
 
swsetup->NewState = ~0;
_swsetup_vb_init( ctx );
_swsetup_trifuncs_init( ctx );
 
return GL_TRUE;
}
 
void
_swsetup_DestroyContext( GLcontext *ctx )
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
 
if (swsetup) {
if (swsetup->verts)
ALIGN_FREE(swsetup->verts);
 
if (swsetup->ChanSecondaryColor.Ptr)
ALIGN_FREE(swsetup->ChanSecondaryColor.Ptr);
 
if (swsetup->ChanColor.Ptr)
ALIGN_FREE(swsetup->ChanColor.Ptr);
 
FREE(swsetup);
ctx->swsetup_context = 0;
}
}
 
static void
_swsetup_RenderPrimitive( GLcontext *ctx, GLenum mode )
{
SWSETUP_CONTEXT(ctx)->render_prim = mode;
_swrast_render_primitive( ctx, mode );
}
 
/*
* We patch this function into tnl->Driver.Render.Start.
* It's called when we start rendering a vertex buffer.
*/
static void
_swsetup_RenderStart( GLcontext *ctx )
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
GLuint new_state = swsetup->NewState;
 
if (new_state & _SWSETUP_NEW_RENDERINDEX) {
_swsetup_choose_trifuncs( ctx );
}
 
if (new_state & _SWSETUP_NEW_VERTS) {
_swsetup_choose_rastersetup_func( ctx );
}
 
swsetup->NewState = 0;
 
_swrast_render_start( ctx );
}
 
/*
* We patch this function into tnl->Driver.Render.Finish.
* It's called when we finish rendering a vertex buffer.
*/
static void
_swsetup_RenderFinish( GLcontext *ctx )
{
_swrast_render_finish( ctx );
}
 
void
_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state )
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
swsetup->NewState |= new_state;
}
 
 
void
_swsetup_Wakeup( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
tnl->Driver.Render.Start = _swsetup_RenderStart;
tnl->Driver.Render.Finish = _swsetup_RenderFinish;
tnl->Driver.Render.PrimitiveNotify = _swsetup_RenderPrimitive;
/* interp */
/* copypv */
tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; /* new */
tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; /* new */
/* points */
/* line */
/* triangle */
/* quad */
tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
/* buildvertices */
tnl->Driver.Render.Multipass = 0;
_tnl_need_projected_coords( ctx, GL_TRUE );
_swsetup_InvalidateState( ctx, ~0 );
}
/shark/trunk/ports/mesa/src/swrastst/ss_tritmp.h
0,0 → 1,195
/* $Id: ss_tritmp.h,v 1.1 2003-04-29 12:46:52 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
* Version: 5.0
*
* Copyright (C) 1999-2002 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 <keith@tungstengraphics.com>
*/
 
 
static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
SWvertex *v[3];
GLfloat z[3];
GLfloat offset;
GLenum mode = GL_FILL;
GLuint facing = 0;
 
v[0] = &verts[e0];
v[1] = &verts[e1];
v[2] = &verts[e2];
 
 
if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT))
{
GLfloat ex = v[0]->win[0] - v[2]->win[0];
GLfloat ey = v[0]->win[1] - v[2]->win[1];
GLfloat fx = v[1]->win[0] - v[2]->win[0];
GLfloat fy = v[1]->win[1] - v[2]->win[1];
GLfloat cc = ex*fy - ey*fx;
 
if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT))
{
facing = (cc < 0.0) ^ ctx->Polygon._FrontBit;
if (ctx->Stencil.TestTwoSide)
ctx->_Facing = facing; /* for 2-sided stencil test */
 
if (IND & SS_UNFILLED_BIT)
mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode;
 
if (facing == 1) {
if (IND & SS_TWOSIDE_BIT) {
if (IND & SS_RGBA_BIT) {
GLchan (*vbcolor)[4] = (GLchan (*)[4])VB->ColorPtr[1]->Ptr;
SS_COLOR(v[0]->color, vbcolor[e0]);
SS_COLOR(v[1]->color, vbcolor[e1]);
SS_COLOR(v[2]->color, vbcolor[e2]);
if (VB->SecondaryColorPtr[1]) {
GLchan (*vbspec)[4] = (GLchan (*)[4])VB->SecondaryColorPtr[1]->Ptr;
SS_SPEC(v[0]->specular, vbspec[e0]);
SS_SPEC(v[1]->specular, vbspec[e1]);
SS_SPEC(v[2]->specular, vbspec[e2]);
}
} else {
GLuint *vbindex = VB->IndexPtr[1]->data;
SS_IND(v[0]->index, vbindex[e0]);
SS_IND(v[1]->index, vbindex[e1]);
SS_IND(v[2]->index, vbindex[e2]);
}
}
}
}
 
if (IND & SS_OFFSET_BIT)
{
offset = ctx->Polygon.OffsetUnits;
z[0] = v[0]->win[2];
z[1] = v[1]->win[2];
z[2] = v[2]->win[2];
if (cc * cc > 1e-16) {
GLfloat ez = z[0] - z[2];
GLfloat fz = z[1] - z[2];
GLfloat a = ey*fz - ez*fy;
GLfloat b = ez*fx - ex*fz;
GLfloat ic = 1.0F / cc;
GLfloat ac = a * ic;
GLfloat bc = b * ic;
if (ac < 0.0F) ac = -ac;
if (bc < 0.0F) bc = -bc;
offset += MAX2(ac, bc) * ctx->Polygon.OffsetFactor;
}
offset *= ctx->MRD;
/*printf("offset %g\n", offset);*/
}
}
 
if (mode == GL_POINT) {
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) {
v[0]->win[2] += offset;
v[1]->win[2] += offset;
v[2]->win[2] += offset;
}
_swsetup_render_point_tri( ctx, e0, e1, e2, facing );
} else if (mode == GL_LINE) {
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) {
v[0]->win[2] += offset;
v[1]->win[2] += offset;
v[2]->win[2] += offset;
}
_swsetup_render_line_tri( ctx, e0, e1, e2, facing );
} else {
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) {
v[0]->win[2] += offset;
v[1]->win[2] += offset;
v[2]->win[2] += offset;
}
_swrast_Triangle( ctx, v[0], v[1], v[2] );
}
 
if (IND & SS_OFFSET_BIT) {
v[0]->win[2] = z[0];
v[1]->win[2] = z[1];
v[2]->win[2] = z[2];
}
 
if (IND & SS_TWOSIDE_BIT) {
if (facing == 1) {
if (IND & SS_RGBA_BIT) {
GLchan (*vbcolor)[4] = (GLchan (*)[4])VB->ColorPtr[0]->Ptr;
SS_COLOR(v[0]->color, vbcolor[e0]);
SS_COLOR(v[1]->color, vbcolor[e1]);
SS_COLOR(v[2]->color, vbcolor[e2]);
if (VB->SecondaryColorPtr[0]) {
GLchan (*vbspec)[4] = (GLchan (*)[4])VB->SecondaryColorPtr[0]->Ptr;
SS_SPEC(v[0]->specular, vbspec[e0]);
SS_SPEC(v[1]->specular, vbspec[e1]);
SS_SPEC(v[2]->specular, vbspec[e2]);
}
} else {
GLuint *vbindex = VB->IndexPtr[0]->data;
SS_IND(v[0]->index, vbindex[e0]);
SS_IND(v[1]->index, vbindex[e1]);
SS_IND(v[2]->index, vbindex[e2]);
}
}
}
}
 
 
 
/* Need to fixup edgeflags when decomposing to triangles:
*/
static void TAG(quadfunc)( GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint v3 )
{
if (IND & SS_UNFILLED_BIT) {
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLubyte ef1 = VB->EdgeFlag[v1];
GLubyte ef3 = VB->EdgeFlag[v3];
VB->EdgeFlag[v1] = 0;
TAG(triangle)( ctx, v0, v1, v3 );
VB->EdgeFlag[v1] = ef1;
VB->EdgeFlag[v3] = 0;
TAG(triangle)( ctx, v1, v2, v3 );
VB->EdgeFlag[v3] = ef3;
} else {
TAG(triangle)( ctx, v0, v1, v3 );
TAG(triangle)( ctx, v1, v2, v3 );
}
}
 
 
 
 
static void TAG(init)( void )
{
tri_tab[IND] = TAG(triangle);
quad_tab[IND] = TAG(quadfunc);
}
 
 
#undef IND
#undef TAG
/shark/trunk/ports/mesa/src/swrastst/ss_triangle.c
0,0 → 1,311
/* $Id: ss_triangle.c,v 1.1 2003-04-29 12:46:51 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 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 <keith@tungstengraphics.com>
*/
 
#include "glheader.h"
#include "colormac.h"
#include "macros.h"
#include "mtypes.h"
 
#include "tnl/t_context.h"
 
#include "ss_triangle.h"
#include "ss_context.h"
 
#define SS_RGBA_BIT 0x1
#define SS_OFFSET_BIT 0x2
#define SS_TWOSIDE_BIT 0x4
#define SS_UNFILLED_BIT 0x8
#define SS_MAX_TRIFUNC 0x10
 
static triangle_func tri_tab[SS_MAX_TRIFUNC];
static quad_func quad_tab[SS_MAX_TRIFUNC];
 
 
static void _swsetup_render_line_tri( GLcontext *ctx,
GLuint e0, GLuint e1, GLuint e2,
GLuint facing )
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLubyte *ef = VB->EdgeFlag;
SWvertex *verts = swsetup->verts;
SWvertex *v0 = &verts[e0];
SWvertex *v1 = &verts[e1];
SWvertex *v2 = &verts[e2];
GLchan c[2][4];
GLchan s[2][4];
GLuint i[2];
 
/* cull testing */
if (ctx->Polygon.CullFlag) {
if (facing == 1 && ctx->Polygon.CullFaceMode != GL_FRONT)
return;
if (facing == 0 && ctx->Polygon.CullFaceMode != GL_BACK)
return;
}
 
if (ctx->_TriangleCaps & DD_FLATSHADE) {
COPY_CHAN4(c[0], v0->color);
COPY_CHAN4(c[1], v1->color);
COPY_CHAN4(s[0], v0->specular);
COPY_CHAN4(s[1], v1->specular);
i[0] = v0->index;
i[1] = v1->index;
 
COPY_CHAN4(v0->color, v2->color);
COPY_CHAN4(v1->color, v2->color);
COPY_CHAN4(v0->specular, v2->specular);
COPY_CHAN4(v1->specular, v2->specular);
v0->index = v2->index;
v1->index = v2->index;
}
 
if (swsetup->render_prim == GL_POLYGON) {
if (ef[e2]) _swrast_Line( ctx, v2, v0 );
if (ef[e0]) _swrast_Line( ctx, v0, v1 );
if (ef[e1]) _swrast_Line( ctx, v1, v2 );
} else {
if (ef[e0]) _swrast_Line( ctx, v0, v1 );
if (ef[e1]) _swrast_Line( ctx, v1, v2 );
if (ef[e2]) _swrast_Line( ctx, v2, v0 );
}
 
if (ctx->_TriangleCaps & DD_FLATSHADE) {
COPY_CHAN4(v0->color, c[0]);
COPY_CHAN4(v1->color, c[1]);
COPY_CHAN4(v0->specular, s[0]);
COPY_CHAN4(v1->specular, s[1]);
v0->index = i[0];
v1->index = i[1];
}
}
 
static void _swsetup_render_point_tri( GLcontext *ctx,
GLuint e0, GLuint e1, GLuint e2,
GLuint facing )
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLubyte *ef = VB->EdgeFlag;
SWvertex *verts = swsetup->verts;
SWvertex *v0 = &verts[e0];
SWvertex *v1 = &verts[e1];
SWvertex *v2 = &verts[e2];
GLchan c[2][4];
GLchan s[2][4];
GLuint i[2];
 
/* cull testing */
if (ctx->Polygon.CullFlag) {
if (facing == 1 && ctx->Polygon.CullFaceMode != GL_FRONT)
return;
if (facing == 0 && ctx->Polygon.CullFaceMode != GL_BACK)
return;
}
 
if (ctx->_TriangleCaps & DD_FLATSHADE) {
COPY_CHAN4(c[0], v0->color);
COPY_CHAN4(c[1], v1->color);
COPY_CHAN4(s[0], v0->specular);
COPY_CHAN4(s[1], v1->specular);
i[0] = v0->index;
i[1] = v1->index;
 
COPY_CHAN4(v0->color, v2->color);
COPY_CHAN4(v1->color, v2->color);
COPY_CHAN4(v0->specular, v2->specular);
COPY_CHAN4(v1->specular, v2->specular);
v0->index = v2->index;
v1->index = v2->index;
}
 
if (ef[e0]) _swrast_Point( ctx, v0 );
if (ef[e1]) _swrast_Point( ctx, v1 );
if (ef[e2]) _swrast_Point( ctx, v2 );
 
if (ctx->_TriangleCaps & DD_FLATSHADE) {
COPY_CHAN4(v0->color, c[0]);
COPY_CHAN4(v1->color, c[1]);
COPY_CHAN4(v0->specular, s[0]);
COPY_CHAN4(v1->specular, s[1]);
v0->index = i[0];
v1->index = i[1];
}
_swrast_flush(ctx);
}
 
#define SS_COLOR(a,b) COPY_CHAN4(a,b)
#define SS_SPEC(a,b) COPY_3V(a,b)
#define SS_IND(a,b) (a = b)
 
#define IND (0)
#define TAG(x) x
#include "ss_tritmp.h"
 
#define IND (SS_OFFSET_BIT)
#define TAG(x) x##_offset
#include "ss_tritmp.h"
 
#define IND (SS_TWOSIDE_BIT)
#define TAG(x) x##_twoside
#include "ss_tritmp.h"
 
#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
#define TAG(x) x##_offset_twoside
#include "ss_tritmp.h"
 
#define IND (SS_UNFILLED_BIT)
#define TAG(x) x##_unfilled
#include "ss_tritmp.h"
 
#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
#define TAG(x) x##_offset_unfilled
#include "ss_tritmp.h"
 
#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
#define TAG(x) x##_twoside_unfilled
#include "ss_tritmp.h"
 
#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
#define TAG(x) x##_offset_twoside_unfilled
#include "ss_tritmp.h"
 
#define IND (0|SS_RGBA_BIT)
#define TAG(x) x##_rgba
#include "ss_tritmp.h"
 
#define IND (SS_OFFSET_BIT|SS_RGBA_BIT)
#define TAG(x) x##_offset_rgba
#include "ss_tritmp.h"
 
#define IND (SS_TWOSIDE_BIT|SS_RGBA_BIT)
#define TAG(x) x##_twoside_rgba
#include "ss_tritmp.h"
 
#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_RGBA_BIT)
#define TAG(x) x##_offset_twoside_rgba
#include "ss_tritmp.h"
 
#define IND (SS_UNFILLED_BIT|SS_RGBA_BIT)
#define TAG(x) x##_unfilled_rgba
#include "ss_tritmp.h"
 
#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
#define TAG(x) x##_offset_unfilled_rgba
#include "ss_tritmp.h"
 
#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
#define TAG(x) x##_twoside_unfilled_rgba
#include "ss_tritmp.h"
 
#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
#define TAG(x) x##_offset_twoside_unfilled_rgba
#include "ss_tritmp.h"
 
 
void _swsetup_trifuncs_init( GLcontext *ctx )
{
(void) ctx;
 
init();
init_offset();
init_twoside();
init_offset_twoside();
init_unfilled();
init_offset_unfilled();
init_twoside_unfilled();
init_offset_twoside_unfilled();
 
init_rgba();
init_offset_rgba();
init_twoside_rgba();
init_offset_twoside_rgba();
init_unfilled_rgba();
init_offset_unfilled_rgba();
init_twoside_unfilled_rgba();
init_offset_twoside_unfilled_rgba();
}
 
 
static void swsetup_points( GLcontext *ctx, GLuint first, GLuint last )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
GLuint i;
 
if (VB->Elts) {
for (i = first; i < last; i++)
if (VB->ClipMask[VB->Elts[i]] == 0)
_swrast_Point( ctx, &verts[VB->Elts[i]] );
}
else {
for (i = first; i < last; i++)
if (VB->ClipMask[i] == 0)
_swrast_Point( ctx, &verts[i] );
}
}
 
static void swsetup_line( GLcontext *ctx, GLuint v0, GLuint v1 )
{
SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
_swrast_Line( ctx, &verts[v0], &verts[v1] );
}
 
 
 
void _swsetup_choose_trifuncs( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
GLuint ind = 0;
 
if (ctx->Polygon.OffsetPoint ||
ctx->Polygon.OffsetLine ||
ctx->Polygon.OffsetFill)
ind |= SS_OFFSET_BIT;
 
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
ind |= SS_TWOSIDE_BIT;
 
/* We piggyback the two-sided stencil front/back determination on the
* unfilled triangle path.
*/
if ((ctx->_TriangleCaps & DD_TRI_UNFILLED) ||
(ctx->Stencil.Enabled && ctx->Stencil.TestTwoSide))
ind |= SS_UNFILLED_BIT;
 
if (ctx->Visual.rgbMode)
ind |= SS_RGBA_BIT;
 
tnl->Driver.Render.Triangle = tri_tab[ind];
tnl->Driver.Render.Quad = quad_tab[ind];
tnl->Driver.Render.Line = swsetup_line;
tnl->Driver.Render.Points = swsetup_points;
 
ctx->_Facing = 0;
}
/shark/trunk/ports/mesa/src/swrastst/ss_vb.c
0,0 → 1,446
/* $Id: ss_vb.c,v 1.1 2003-04-29 12:46:52 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
* Version: 4.1
*
* Copyright (C) 1999-2002 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 <keith@tungstengraphics.com>
*/
 
#include "glheader.h"
#include "colormac.h"
#include "context.h"
#include "macros.h"
#include "imports.h"
 
#include "swrast/swrast.h"
#include "tnl/t_context.h"
#include "math/m_vector.h"
#include "math/m_translate.h"
 
#include "ss_context.h"
#include "ss_vb.h"
 
static void do_import( struct vertex_buffer *VB,
struct gl_client_array *to,
struct gl_client_array *from )
{
GLuint count = VB->Count;
 
if (!to->Ptr) {
to->Ptr = ALIGN_MALLOC( VB->Size * 4 * sizeof(GLchan), 32 );
to->Type = CHAN_TYPE;
}
 
/* No need to transform the same value 3000 times.
*/
if (!from->StrideB) {
to->StrideB = 0;
count = 1;
}
else
to->StrideB = 4 * sizeof(GLchan);
_math_trans_4chan( (GLchan (*)[4]) to->Ptr,
from->Ptr,
from->StrideB,
from->Type,
from->Size,
0,
count);
}
 
static void import_float_colors( GLcontext *ctx )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct gl_client_array *to = &SWSETUP_CONTEXT(ctx)->ChanColor;
do_import( VB, to, VB->ColorPtr[0] );
VB->ColorPtr[0] = to;
}
 
static void import_float_spec_colors( GLcontext *ctx )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct gl_client_array *to = &SWSETUP_CONTEXT(ctx)->ChanSecondaryColor;
do_import( VB, to, VB->SecondaryColorPtr[0] );
VB->SecondaryColorPtr[0] = to;
}
 
 
/* Provides a RasterSetup function which prebuilds vertices for the
* software rasterizer. This is required for the triangle functions
* in this module, but not the rest of the swrast module.
*/
 
 
#define COLOR 0x1
#define INDEX 0x2
#define TEX0 0x4
#define MULTITEX 0x8
#define SPEC 0x10
#define FOG 0x20
#define POINT 0x40
#define MAX_SETUPFUNC 0x80
 
static setup_func setup_tab[MAX_SETUPFUNC];
static interp_func interp_tab[MAX_SETUPFUNC];
static copy_pv_func copy_pv_tab[MAX_SETUPFUNC];
 
 
#define IND (0)
#define TAG(x) x##_none
#include "ss_vbtmp.h"
 
#define IND (COLOR)
#define TAG(x) x##_color
#include "ss_vbtmp.h"
 
#define IND (COLOR|SPEC)
#define TAG(x) x##_color_spec
#include "ss_vbtmp.h"
 
#define IND (COLOR|FOG)
#define TAG(x) x##_color_fog
#include "ss_vbtmp.h"
 
#define IND (COLOR|SPEC|FOG)
#define TAG(x) x##_color_spec_fog
#include "ss_vbtmp.h"
 
#define IND (COLOR|TEX0)
#define TAG(x) x##_color_tex0
#include "ss_vbtmp.h"
 
#define IND (COLOR|TEX0|SPEC)
#define TAG(x) x##_color_tex0_spec
#include "ss_vbtmp.h"
 
#define IND (COLOR|TEX0|FOG)
#define TAG(x) x##_color_tex0_fog
#include "ss_vbtmp.h"
 
#define IND (COLOR|TEX0|SPEC|FOG)
#define TAG(x) x##_color_tex0_spec_fog
#include "ss_vbtmp.h"
 
#define IND (COLOR|MULTITEX)
#define TAG(x) x##_color_multitex
#include "ss_vbtmp.h"
 
#define IND (COLOR|MULTITEX|SPEC)
#define TAG(x) x##_color_multitex_spec
#include "ss_vbtmp.h"
 
#define IND (COLOR|MULTITEX|FOG)
#define TAG(x) x##_color_multitex_fog
#include "ss_vbtmp.h"
 
#define IND (COLOR|MULTITEX|SPEC|FOG)
#define TAG(x) x##_color_multitex_spec_fog
#include "ss_vbtmp.h"
 
#define IND (COLOR|POINT)
#define TAG(x) x##_color_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|SPEC|POINT)
#define TAG(x) x##_color_spec_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|FOG|POINT)
#define TAG(x) x##_color_fog_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|SPEC|FOG|POINT)
#define TAG(x) x##_color_spec_fog_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|TEX0|POINT)
#define TAG(x) x##_color_tex0_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|TEX0|SPEC|POINT)
#define TAG(x) x##_color_tex0_spec_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|TEX0|FOG|POINT)
#define TAG(x) x##_color_tex0_fog_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|TEX0|SPEC|FOG|POINT)
#define TAG(x) x##_color_tex0_spec_fog_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|MULTITEX|POINT)
#define TAG(x) x##_color_multitex_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|MULTITEX|SPEC|POINT)
#define TAG(x) x##_color_multitex_spec_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|MULTITEX|FOG|POINT)
#define TAG(x) x##_color_multitex_fog_point
#include "ss_vbtmp.h"
 
#define IND (COLOR|MULTITEX|SPEC|FOG|POINT)
#define TAG(x) x##_color_multitex_spec_fog_point
#include "ss_vbtmp.h"
 
#define IND (INDEX)
#define TAG(x) x##_index
#include "ss_vbtmp.h"
 
#define IND (INDEX|FOG)
#define TAG(x) x##_index_fog
#include "ss_vbtmp.h"
 
#define IND (INDEX|POINT)
#define TAG(x) x##_index_point
#include "ss_vbtmp.h"
 
#define IND (INDEX|FOG|POINT)
#define TAG(x) x##_index_fog_point
#include "ss_vbtmp.h"
 
 
/***********************************************************************
* Additional setup and interp for back color and edgeflag.
***********************************************************************/
 
#define GET_COLOR(ptr, idx) (((GLchan (*)[4])((ptr)->Ptr))[idx])
 
static void interp_extras( GLcontext *ctx,
GLfloat t,
GLuint dst, GLuint out, GLuint in,
GLboolean force_boundary )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
if (VB->ColorPtr[1]) {
INTERP_4CHAN( t,
GET_COLOR(VB->ColorPtr[1], dst),
GET_COLOR(VB->ColorPtr[1], out),
GET_COLOR(VB->ColorPtr[1], in) );
 
if (VB->SecondaryColorPtr[1]) {
INTERP_3CHAN( t,
GET_COLOR(VB->SecondaryColorPtr[1], dst),
GET_COLOR(VB->SecondaryColorPtr[1], out),
GET_COLOR(VB->SecondaryColorPtr[1], in) );
}
}
else if (VB->IndexPtr[1]) {
VB->IndexPtr[1]->data[dst] = (GLuint) (GLint)
LINTERP( t,
(GLfloat) VB->IndexPtr[1]->data[out],
(GLfloat) VB->IndexPtr[1]->data[in] );
}
 
if (VB->EdgeFlag) {
VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
}
 
interp_tab[SWSETUP_CONTEXT(ctx)->SetupIndex](ctx, t, dst, out, in,
force_boundary);
}
 
static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
if (VB->ColorPtr[1]) {
COPY_CHAN4( GET_COLOR(VB->ColorPtr[1], dst),
GET_COLOR(VB->ColorPtr[1], src) );
if (VB->SecondaryColorPtr[1]) {
COPY_3V( GET_COLOR(VB->SecondaryColorPtr[1], dst),
GET_COLOR(VB->SecondaryColorPtr[1], src) );
}
}
else if (VB->IndexPtr[1]) {
VB->IndexPtr[1]->data[dst] = VB->IndexPtr[1]->data[src];
}
 
copy_pv_tab[SWSETUP_CONTEXT(ctx)->SetupIndex](ctx, dst, src);
}
 
 
 
 
/***********************************************************************
* Initialization
***********************************************************************/
 
static void
emit_invalid( GLcontext *ctx, GLuint start, GLuint end, GLuint newinputs )
{
_mesa_debug(ctx, "swrast_setup: invalid setup function\n");
(void) (ctx && start && end && newinputs);
}
 
 
static void
interp_invalid( GLcontext *ctx, GLfloat t,
GLuint edst, GLuint eout, GLuint ein,
GLboolean force_boundary )
{
_mesa_debug(ctx, "swrast_setup: invalid interp function\n");
(void) (ctx && t && edst && eout && ein && force_boundary);
}
 
 
static void
copy_pv_invalid( GLcontext *ctx, GLuint edst, GLuint esrc )
{
_mesa_debug(ctx, "swrast_setup: invalid copy_pv function\n");
(void) (ctx && edst && esrc );
}
 
 
static void init_standard( void )
{
GLuint i;
 
for (i = 0 ; i < Elements(setup_tab) ; i++) {
setup_tab[i] = emit_invalid;
interp_tab[i] = interp_invalid;
copy_pv_tab[i] = copy_pv_invalid;
}
 
init_none();
init_color();
init_color_spec();
init_color_fog();
init_color_spec_fog();
init_color_tex0();
init_color_tex0_spec();
init_color_tex0_fog();
init_color_tex0_spec_fog();
init_color_multitex();
init_color_multitex_spec();
init_color_multitex_fog();
init_color_multitex_spec_fog();
init_color_point();
init_color_spec_point();
init_color_fog_point();
init_color_spec_fog_point();
init_color_tex0_point();
init_color_tex0_spec_point();
init_color_tex0_fog_point();
init_color_tex0_spec_fog_point();
init_color_multitex_point();
init_color_multitex_spec_point();
init_color_multitex_fog_point();
init_color_multitex_spec_fog_point();
init_index();
init_index_fog();
init_index_point();
init_index_fog_point();
}
 
 
/* debug only */
#if 0
static void
printSetupFlags(const GLcontext *ctx, char *msg, GLuint flags )
{
_mesa_debug(ctx, "%s(%x): %s%s%s%s%s%s%s\n",
msg,
(int) flags,
(flags & COLOR) ? "color, " : "",
(flags & INDEX) ? "index, " : "",
(flags & TEX0) ? "tex0, " : "",
(flags & MULTITEX) ? "multitex, " : "",
(flags & SPEC) ? "spec, " : "",
(flags & FOG) ? "fog, " : "",
(flags & POINT) ? "point, " : "");
}
#endif
 
void
_swsetup_choose_rastersetup_func(GLcontext *ctx)
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
int funcindex = 0;
 
if (ctx->RenderMode == GL_RENDER) {
if (ctx->Visual.rgbMode) {
funcindex = COLOR;
 
if (ctx->Texture._EnabledUnits > 1)
funcindex |= MULTITEX; /* a unit above unit[0] is enabled */
else if (ctx->Texture._EnabledUnits == 1)
funcindex |= TEX0; /* only unit 0 is enabled */
 
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
funcindex |= SPEC;
}
else {
funcindex = INDEX;
}
 
if (ctx->Point._Attenuated ||
(ctx->VertexProgram.Enabled && ctx->VertexProgram.PointSizeEnabled))
funcindex |= POINT;
 
if (ctx->Fog.Enabled)
funcindex |= FOG;
}
else if (ctx->RenderMode == GL_FEEDBACK) {
if (ctx->Visual.rgbMode)
funcindex = (COLOR | TEX0); /* is feedback color subject to fogging? */
else
funcindex = INDEX;
}
else
funcindex = 0;
swsetup->SetupIndex = funcindex;
tnl->Driver.Render.BuildVertices = setup_tab[funcindex];
 
if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
tnl->Driver.Render.Interp = interp_extras;
tnl->Driver.Render.CopyPV = copy_pv_extras;
}
else {
tnl->Driver.Render.Interp = interp_tab[funcindex];
tnl->Driver.Render.CopyPV = copy_pv_tab[funcindex];
}
 
ASSERT(tnl->Driver.Render.BuildVertices);
ASSERT(tnl->Driver.Render.BuildVertices != emit_invalid);
}
 
 
void
_swsetup_vb_init( GLcontext *ctx )
{
(void) ctx;
init_standard();
/*
printSetupFlags(ctx);
*/
}
/shark/trunk/ports/mesa/src/makefile
25,8 → 25,8
./swrast/s_histogram.o ./swrast/s_imaging.o ./swrast/s_lines.o ./swrast/s_logic.o\
./swrast/s_masking.o ./swrast/s_pixeltex.o ./swrast/s_points.o ./swrast/s_readpix.o\
./swrast/s_span.o ./swrast/s_stencil.o ./swrast/s_texstore.o ./swrast/s_texture.o\
./swrast/s_triangle.o ./swrast/s_zoom.o ./swrast_setup/ss_context.o\
./swrast_setup/ss_triangle.o ./swrast_setup/ss_vb.o ./tnl/t_array_api.o\
./swrast/s_triangle.o ./swrast/s_zoom.o ./swrastst/ss_context.o\
./swrastst/ss_triangle.o ./swrastst/ss_vb.o ./tnl/t_array_api.o\
./tnl/t_import_array.o ./tnl/t_context.o ./tnl/t_eval_api.o ./tnl/t_imm_alloc.o\
./tnl/t_imm_api.o ./tnl/t_imm_debug.o ./tnl/t_imm_dlist.o ./tnl/t_imm_elt.o\
./tnl/t_imm_eval.o ./tnl/t_imm_exec.o ./tnl/t_imm_fixup.o ./tnl/t_pipeline.o\
/shark/trunk/ports/mesa/src/osmesa/osmesa.c
1,4 → 1,4
/* $Id: osmesa.c,v 1.2 2003-03-13 12:20:29 giacomo Exp $ */
/* $Id: osmesa.c,v 1.3 2003-04-29 12:46:51 giacomo Exp $ */
 
/*
* Mesa 3-D graphics library
51,7 → 51,7
#include "texstore.h"
#include "array_cache/acache.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "swrastst/swrast_setup.h"
#include "swrast/s_context.h"
#include "swrast/s_depth.h"
#include "swrast/s_lines.h"