-/* $Id: ac_context.h,v 1.3 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: ac_context.h,v 1.4 2002/04/21 18:49:19 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * 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"),
struct gl_client_array Index;
struct gl_client_array TexCoord[MAX_TEXTURE_UNITS];
struct gl_client_array EdgeFlag;
+ struct gl_client_array Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
};
struct ac_array_pointers {
struct gl_client_array *Index;
struct gl_client_array *TexCoord[MAX_TEXTURE_UNITS];
struct gl_client_array *EdgeFlag;
+ struct gl_client_array *Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
};
struct ac_array_flags {
GLboolean Index;
GLboolean TexCoord[MAX_TEXTURE_UNITS];
GLboolean EdgeFlag;
+ GLboolean Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
};
-/* $Id: ac_import.c,v 1.16 2002/01/05 20:51:12 brianp Exp $ */
+/* $Id: ac_import.c,v 1.17 2002/04/21 18:49:19 brianp Exp $ */
/*
* Mesa 3-D graphics library
ac->NewArrayState &= ~_NEW_ARRAY_INDEX;
}
+
static void reset_fogcoord( GLcontext *ctx )
{
ACcontext *ac = AC_CONTEXT(ctx);
ac->NewArrayState &= ~_NEW_ARRAY_FOGCOORD;
}
+
static void reset_edgeflag( GLcontext *ctx )
{
ACcontext *ac = AC_CONTEXT(ctx);
}
+static void reset_attrib( GLcontext *ctx, GLuint index )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (ctx->Array._Enabled & _NEW_ARRAY_ATTRIB(index)) {
+ ac->Raw.Attrib[index] = ctx->Array.VertexAttrib[index];
+ STRIDE_ARRAY(ac->Raw.Attrib[index], ac->start);
+ }
+ else {
+ ac->Raw.Attrib[index] = ac->Fallback.Attrib[index];
+
+ if (ctx->Current.Attrib[index][3] != 1.0)
+ ac->Raw.Attrib[index].Size = 4;
+ else if (ctx->Current.Attrib[index][2] != 0.0)
+ ac->Raw.Attrib[index].Size = 3;
+ else
+ ac->Raw.Attrib[index].Size = 2;
+ }
+
+ ac->IsCached.Attrib[index] = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_ATTRIB(index);
+}
+
+/*
+ * Generic import function for color data
+ */
static void import( GLcontext *ctx,
GLenum type,
struct gl_client_array *to,
-/* Functions to import array ranges with specified types and strides.
+/*
+ * Functions to import array ranges with specified types and strides.
+ * For example, if the vertex data is GLshort[2] and we want GLfloat[3]
+ * we'll use an import function to do the data conversion.
*/
+
static void import_texcoord( GLcontext *ctx, GLuint unit,
GLenum type, GLuint stride )
{
struct gl_client_array *from = &ac->Raw.TexCoord[unit];
struct gl_client_array *to = &ac->Cache.TexCoord[unit];
+ ASSERT(unit < ctx->Const.MaxTextureUnits);
+
/* Limited choices at this stage:
*/
ASSERT(type == GL_FLOAT);
ac->IsCached.Normal = GL_TRUE;
}
-
-
-
static void import_color( GLcontext *ctx,
GLenum type, GLuint stride )
{
ac->IsCached.EdgeFlag = GL_TRUE;
}
+static void import_attrib( GLcontext *ctx, GLuint index,
+ GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ struct gl_client_array *from = &ac->Raw.Attrib[index];
+ struct gl_client_array *to = &ac->Cache.Attrib[index];
+ ASSERT(index < VERT_ATTRIB_MAX);
-/* Externals to request arrays with specific properties:
+ /* Limited choices at this stage:
+ */
+ ASSERT(type == GL_FLOAT);
+ ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
+ ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize);
+
+ _math_trans_4f( (GLfloat (*)[4]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ ac->count - ac->start);
+
+ to->Size = from->Size;
+ to->StrideB = 4 * sizeof(GLfloat);
+ to->Type = GL_FLOAT;
+ ac->IsCached.Attrib[index] = GL_TRUE;
+}
+
+
+
+/*
+ * Externals to request arrays with specific properties:
*/
+
+
struct gl_client_array *_ac_import_texcoord( GLcontext *ctx,
GLuint unit,
GLenum type,
{
ACcontext *ac = AC_CONTEXT(ctx);
+ ASSERT(unit < ctx->Const.MaxTextureUnits);
+
/* Can we keep the existing version?
*/
if (ac->NewArrayState & _NEW_ARRAY_TEXCOORD(unit))
}
}
-
-
-
struct gl_client_array *_ac_import_edgeflag( GLcontext *ctx,
GLenum type,
GLuint reqstride,
}
}
+/* GL_NV_vertex_program */
+struct gl_client_array *_ac_import_attrib( GLcontext *ctx,
+ GLuint index,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ ASSERT(index < VERT_ATTRIB_MAX);
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index))
+ reset_attrib( ctx, index );
+ /* Is the request impossible?
+ */
+ if (reqsize != 0 && ac->Raw.Attrib[index].Size > (GLint) reqsize)
+ return 0;
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if (ac->Raw.Attrib[index].Type != type ||
+ (reqstride != 0 && ac->Raw.Attrib[index].StrideB != (GLint)reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.Attrib[index])
+ import_attrib(ctx, index, type, reqstride );
+ *writeable = GL_TRUE;
+ return &ac->Cache.Attrib[index];
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.Attrib[index];
+ }
+}
/* Clients must call this function to validate state and set bounds
-/* Additional convienence function for importing a the element list
- * for drawelements, drawrangeelements:
+/* Additional convienence function for importing the element list
+ * for glDrawElements() and glDrawRangeElements().
*/
CONST void *
_ac_import_elements( GLcontext *ctx,
-/* $Id: acache.h,v 1.2 2001/03/12 00:48:41 gareth Exp $ */
+/* $Id: acache.h,v 1.3 2002/04/21 18:49:19 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * 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"),
extern void
_ac_InvalidateState( GLcontext *ctx, GLuint new_state );
-extern struct gl_client_array *
-_ac_import_texcoord( GLcontext *ctx,
- GLuint unit,
- GLenum type,
- GLuint reqstride,
- GLuint reqsize,
- GLboolean reqwritable,
- GLboolean *writable );
-
extern struct gl_client_array *
_ac_import_vertex( GLcontext *ctx,
GLenum type,
GLboolean reqwritable,
GLboolean *writable );
+extern struct gl_client_array *
+_ac_import_texcoord( GLcontext *ctx,
+ GLuint unit,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+extern struct gl_client_array *
+_ac_import_attrib( GLcontext *ctx,
+ GLuint index,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
/* Clients must call this function to validate state and set bounds
* before importing any data:
-/* $Id: dd.h,v 1.67 2002/03/16 00:57:14 brianp Exp $ */
+/* $Id: dd.h,v 1.68 2002/04/21 18:49:18 brianp Exp $ */
/*
* Mesa 3-D graphics library
void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr);
void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
+ void (*VertexAttribPointer)(GLcontext *ctx, GLuint index, GLint size,
+ GLenum type, GLsizei stride, const GLvoid *ptr);
/*** State-query functions
-/* $Id: enable.c,v 1.61 2002/04/19 08:38:23 alanh Exp $ */
+/* $Id: enable.c,v 1.62 2002/04/21 18:49:18 brianp Exp $ */
/*
* Mesa 3-D graphics library
{
GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
var = &ctx->Array.VertexAttrib[n].Enabled;
- flag = _NEW_ARRAY_VERT_ATTRIB0; /* XXX flag OK? */
+ flag = _NEW_ARRAY_ATTRIB(n);
}
break;
default:
-/* $Id: mtypes.h,v 1.71 2002/04/19 15:49:40 kschultz Exp $ */
+/* $Id: mtypes.h,v 1.72 2002/04/21 18:49:18 brianp Exp $ */
/*
* Mesa 3-D graphics library
#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
#define _NEW_ARRAY_ALL 0xffff
-#define _NEW_ARRAY_VERT_ATTRIB0 0x10000
+#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
+#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
/* A bunch of flags that we think might be useful to drivers.
*/
-/* $Id: varray.c,v 1.42 2002/04/04 23:59:14 brianp Exp $ */
+/* $Id: varray.c,v 1.43 2002/04/21 18:49:18 brianp Exp $ */
/*
* Mesa 3-D graphics library
void _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
- GLsizei stride, const GLvoid *pointer)
+ GLsizei stride, const GLvoid *ptr)
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (index >= VP_NUM_PROG_REGS) {
+ if (index >= VERT_ATTRIB_MAX) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)");
return;
}
ctx->Array.VertexAttrib[index].Stride = stride;
ctx->Array.VertexAttrib[index].Size = size;
ctx->Array.VertexAttrib[index].Type = type;
+ ctx->Array.VertexAttrib[index].Ptr = (void *) ptr;
- /* XXX need new flags here??? */
ctx->NewState |= _NEW_ARRAY;
- /* XXX probably need new flags!!!! */
- ctx->Array.NewState |= _NEW_ARRAY_VERT_ATTRIB0;
+ ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
- /* XXX
- if (ctx->Driver.VertexAttribdPointer)
+ if (ctx->Driver.VertexAttribPointer)
ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
- */
}