int
_mesa_strncmp( const char *s1, const char *s2, size_t n )
{
- #if defined(XFree86LOADER) && defined(IN_MODULE)
- return xf86strncmp(s1, s2, n);
- #else
return strncmp(s1, s2, n);
- #endif
}
-/** Implemented using _mesa_malloc() and _mesa_strcpy */
+/**
+ * Implemented using _mesa_malloc() and _mesa_strcpy.
+ * Note that NULL is handled accordingly.
+ */
char *
_mesa_strdup( const char *s )
{
- size_t l = _mesa_strlen(s);
- char *s2 = (char *) _mesa_malloc(l + 1);
- if (s2)
- _mesa_strcpy(s2, s);
- return s2;
+ if (s) {
+ size_t l = _mesa_strlen(s);
+ char *s2 = (char *) _mesa_malloc(l + 1);
+ if (s2)
+ _mesa_strcpy(s2, s);
+ return s2;
+ }
+ else {
+ return NULL;
+ }
}
- /** Wrapper around either atoi() or xf86atoi() */
+ /** Wrapper around atoi() */
int
_mesa_atoi(const char *s)
{
}
+
/**
+ * Update the ctx->_TriangleCaps bitfield.
+ * XXX that bitfield should really go away someday!
+ * This function must be called after other update_*() functions since
+ * there are dependencies on some other derived values.
+ */
+ static void
+ update_tricaps(GLcontext *ctx, GLbitfield new_state)
+ {
+ ctx->_TriangleCaps = 0;
+
+ /*
+ * Points
+ */
+ if (new_state & _NEW_POINT) {
+ if (ctx->Point.SmoothFlag)
+ ctx->_TriangleCaps |= DD_POINT_SMOOTH;
+ if (ctx->Point._Size != 1.0F)
+ ctx->_TriangleCaps |= DD_POINT_SIZE;
+ if (ctx->Point._Attenuated)
+ ctx->_TriangleCaps |= DD_POINT_ATTEN;
+ }
+
+ /*
+ * Lines
+ */
+ if (new_state & _NEW_LINE) {
+ if (ctx->Line.SmoothFlag)
+ ctx->_TriangleCaps |= DD_LINE_SMOOTH;
+ if (ctx->Line.StippleFlag)
+ ctx->_TriangleCaps |= DD_LINE_STIPPLE;
+ if (ctx->Line._Width != 1.0)
+ ctx->_TriangleCaps |= DD_LINE_WIDTH;
+ }
+
+ /*
+ * Polygons
+ */
+ if (new_state & _NEW_POLYGON) {
+ if (ctx->Polygon.SmoothFlag)
+ ctx->_TriangleCaps |= DD_TRI_SMOOTH;
+ if (ctx->Polygon.StippleFlag)
+ ctx->_TriangleCaps |= DD_TRI_STIPPLE;
+ if (ctx->Polygon.FrontMode != GL_FILL
+ || ctx->Polygon.BackMode != GL_FILL)
+ ctx->_TriangleCaps |= DD_TRI_UNFILLED;
+ if (ctx->Polygon.CullFlag
+ && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
+ ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
+ if (ctx->Polygon.OffsetPoint ||
+ ctx->Polygon.OffsetLine ||
+ ctx->Polygon.OffsetFill)
+ ctx->_TriangleCaps |= DD_TRI_OFFSET;
+ }
+
+ /*
+ * Lighting and shading
+ */
+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
+ if (ctx->Light.ShadeModel == GL_FLAT)
+ ctx->_TriangleCaps |= DD_FLATSHADE;
+ if (NEED_SECONDARY_COLOR(ctx))
+ ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
+
+ /*
+ * Stencil
+ */
+ if (ctx->Stencil._TestTwoSide)
+ ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
+ }
+
+
+ /**
* Compute derived GL state.
* If __GLcontextRec::NewState is non-zero then this function \b must
* be called before rendering anything.
if (new_state & _NEW_COLOR)
update_color( ctx );
- if (ctx->_MaintainTexEnvProgram) {
+ if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT
+ | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR))
+ update_tricaps( ctx, new_state );
+
+ if (ctx->FragmentProgram._MaintainTexEnvProgram) {
if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))
_mesa_UpdateTexEnvProgram(ctx);
}
void
_mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
{
- static const GLint fogParamsState[]
- = { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0 };
- static const GLint fogColorState[]
- = { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0 };
+ static const GLint fogPStateOpt[] = { STATE_INTERNAL,
+ STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 };
- static const GLint fogColorState[] = { STATE_FOG_COLOR, 0, 0, 0, 0 };
++ static const GLint fogColorState[] = { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0};
struct prog_instruction *newInst, *inst;
const GLuint origLen = fprog->Base.NumInstructions;
- const GLuint newLen = origLen + 6;
+ const GLuint newLen = origLen + 5;
GLuint i;
- GLint fogParamsRef, fogColorRef; /* state references */
+ GLint fogPRefOpt, fogColorRef; /* state references */
GLuint colorTemp, fogFactorTemp; /* temporary registerss */
- GLfloat fogVals[4];
- GLuint fogConsts; /* constant values for EXP, EXP2 mode */
- GLuint swizzle;
if (fprog->FogOption == GL_NONE) {
_mesa_problem(ctx, "_mesa_append_fog_code() called for fragment program"
swrast_setup/ss_triangle.c
TNL_SOURCES = \
- tnl/t_array_api.c \
- tnl/t_array_import.c \
tnl/t_context.c \
tnl/t_pipeline.c \
- tnl/t_save_api.c \
- tnl/t_save_loopback.c \
- tnl/t_save_playback.c \
+ tnl/t_draw.c \
tnl/t_vb_arbprogram.c \
tnl/t_vb_arbprogram_sse.c \
- tnl/t_vb_arbshader.c\
tnl/t_vb_program.c \
tnl/t_vb_render.c \
tnl/t_vb_texgen.c \
/* no convolution */
const GLint dstStride
= _mesa_image_row_stride(packing, width, format, type);
- GLfloat (*rgba)[4] = swrast->SpanArrays->color.sz4.rgba;
+ GLfloat (*rgba)[4] = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0];
GLint row;
- GLubyte *dst = _mesa_image_address2d(packing, pixels, width, height,
- format, type, 0, 0);
+ GLubyte *dst
+ = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
+ format, type, 0, 0);
for (row = 0; row < height; row++, y++) {
tnl->vb.Size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES;
- /* Initialize tnl state and tnl->vtxfmt.
+ /* Initialize tnl state.
*/
- _tnl_save_init( ctx );
- _tnl_array_init( ctx );
- _tnl_vtx_init( ctx );
-
- if (ctx->_MaintainTnlProgram) {
+ if (ctx->VertexProgram._MaintainTnlProgram) {
_tnl_ProgramCacheInit( ctx );
_tnl_install_pipeline( ctx, _tnl_vp_pipeline );
} else {
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
- _tnl_array_destroy( ctx );
- _tnl_vtx_destroy( ctx );
- _tnl_save_destroy( ctx );
_tnl_destroy_pipeline( ctx );
- _ae_destroy_context( ctx );
- if (ctx->_MaintainTnlProgram)
+ if (ctx->VertexProgram._MaintainTnlProgram)
_tnl_ProgramCacheDestroy( ctx );
FREE(tnl);
GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */
GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */
GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */
- GLvector4f *VaryingPtr[MAX_VARYING_VECTORS];
+ GLvector4f *VaryingPtr[MAX_VARYING];
- struct tnl_prim *Primitive;
+ const struct _mesa_prim *Primitive;
GLuint PrimitiveCount;
/* Inputs to the vertex program stage */
{
struct compilation cp;
struct tnl_compiled_program *p = CALLOC_STRUCT(tnl_compiled_program);
- GLuint i;
+ GLint i;
+#if 1
+ if (!program->IsNVProgram && program->IsPositionInvariant) {
+ printf("Adding MVP code\n");
+ if (!program->Base.Parameters)
+ program->Base.Parameters = _mesa_new_parameter_list();
+ _mesa_insert_mvp_code(NULL, program);
+ program->IsPositionInvariant = 0;
+ }
+#endif
+
if (program->TnlData)
free_tnl_data( program );
case 2: m->File[0][idx][1] = m->input[j].data[1];
case 1: m->File[0][idx][0] = m->input[j].data[0];
}
--
++#if 0
++ printf(" attr %d/%d: %g %g %g %g\n", j, idx-REG_IN0,
++ m->input[j].data[0],
++ m->input[j].data[1],
++ m->input[j].data[2],
++ m->input[j].data[3]);
++#endif
STRIDE_F(m->input[j].data, m->input[j].stride);
}