static void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b )
{
GET_CURRENT_CONTEXT(ctx);
- ctx->Current.EdgeFlag = b;
+ ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] = (GLfloat)b;
}
static void GLAPIENTRY _mesa_noop_Indexf( GLfloat f )
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR0], 1.0, 1.0, 1.0, 1.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR1], 0.0, 0.0, 0.0, 1.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_FOG], 0.0, 0.0, 0.0, 0.0 );
- ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = 1.0;
- ctx->Current.EdgeFlag = GL_TRUE;
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX], 1.0, 0.0, 0.0, 1.0 );
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG], 1.0, 0.0, 0.0, 1.0 );
}
case GL_EDGE_FLAG:
{
FLUSH_CURRENT(ctx, 0);
- params[0] = ctx->Current.EdgeFlag;
+ params[0] = (ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0F);
}
break;
case GL_FEEDBACK_BUFFER_SIZE:
case GL_EDGE_FLAG:
{
FLUSH_CURRENT(ctx, 0);
- params[0] = BOOLEAN_TO_FLOAT(ctx->Current.EdgeFlag);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0F);
}
break;
case GL_FEEDBACK_BUFFER_SIZE:
case GL_EDGE_FLAG:
{
FLUSH_CURRENT(ctx, 0);
- params[0] = BOOLEAN_TO_INT(ctx->Current.EdgeFlag);
+ params[0] = BOOLEAN_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0F);
}
break;
case GL_FEEDBACK_BUFFER_SIZE:
VERT_ATTRIB_COLOR1 = 4,
VERT_ATTRIB_FOG = 5,
VERT_ATTRIB_COLOR_INDEX = 6,
- VERT_ATTRIB_SEVEN = 7,
+ VERT_ATTRIB_EDGEFLAG = 7,
VERT_ATTRIB_TEX0 = 8,
VERT_ATTRIB_TEX1 = 9,
VERT_ATTRIB_TEX2 = 10,
#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX)
-#define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
+#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG)
#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
/**
* \name Current vertex attributes.
* \note Values are valid only after FLUSH_VERTICES has been called.
+ * \note Index and Edgeflag current values are stored as floats in the
+ * SIX and SEVEN attribute slots.
*/
/*@{*/
GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */
- GLfloat Index; /**< Current color index */
- GLboolean EdgeFlag; /**< Current edge flag */
/*@}*/
/**
#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX
-#define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
+#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG
#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
/* 7 */
if (ctx->VertexProgram._Enabled
- && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_SEVEN].Enabled) {
- min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_SEVEN]._MaxElement);
+ && ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
+ min = MIN2(min, ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]._MaxElement);
}
/* 8..15 */
for (i = 0; i < NR_LEGACY_ATTRIBS; i++) {
struct gl_client_array *cl = &arrays[i];
- switch (i) {
- case VBO_ATTRIB_EDGEFLAG:
- cl->Type = GL_UNSIGNED_BYTE;
- cl->Ptr = (const void *)&ctx->Current.EdgeFlag;
- break;
- case VBO_ATTRIB_INDEX:
- cl->Type = GL_FLOAT;
- cl->Ptr = (const void *)&ctx->Current.Index;
- break;
- default:
- cl->Type = GL_FLOAT;
- cl->Ptr = (const void *)ctx->Current.Attrib[i];
- break;
- }
-
- /* This will have to be determined at runtime:
+ /* Size will have to be determined at runtime:
*/
cl->Size = 1;
cl->Stride = 0;
cl->StrideB = 0;
cl->Enabled = 1;
+ cl->Type = GL_FLOAT;
+ cl->Ptr = (const void *)ctx->Current.Attrib[i];
cl->BufferObj = ctx->Array.NullBufferObj;
}
}
struct gl_client_array *arrays = vbo->mat_currval;
GLuint i;
- memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS);
+ memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS);
/* Set up a constant (StrideB == 0) array for each current
* attribute:
*/
- for (i = 0; i < NR_GENERIC_ATTRIBS; i++) {
+ for (i = 0; i < NR_MAT_ATTRIBS; i++) {
struct gl_client_array *cl = &arrays[i];
/* Size is fixed for the material attributes, for others will
}
}
+#if 0
+static void vbo_exec_current_init( struct vbo_exec_context *exec )
+{
+ GLcontext *ctx = exec->ctx;
+ GLint i;
+
+ /* setup the pointers for the typical 16 vertex attributes */
+ for (i = 0; i < VBO_ATTRIB_FIRST_MATERIAL; i++)
+ exec->vtx.current[i] = ctx->Current.Attrib[i];
+
+ /* setup pointers for the 12 material attributes */
+ for (i = 0; i < MAT_ATTRIB_MAX; i++)
+ exec->vtx.current[VBO_ATTRIB_FIRST_MATERIAL + i] =
+ ctx->Light.Material.Attrib[i];
+}
+#endif
GLboolean _vbo_CreateContext( GLcontext *ctx )
{
return GL_FALSE;
}
- /* Hook our functions into exec and compile dispatch tables. These
- * will pretty much be permanently installed, which means that the
- * vtxfmt mechanism can be removed now.
+ /* TODO: remove these pointers.
*/
- vbo_exec_init( ctx );
- vbo_save_init( ctx );
-
+ vbo->legacy_currval = &vbo->currval[VBO_ATTRIB_POS];
+ vbo->generic_currval = &vbo->currval[VBO_ATTRIB_GENERIC0];
+ vbo->mat_currval = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT];
init_legacy_currval( ctx );
init_generic_currval( ctx );
/* By default:
*/
vbo->draw_prims = _tnl_draw_prims;
+
+ /* Hook our functions into exec and compile dispatch tables. These
+ * will pretty much be permanently installed, which means that the
+ * vtxfmt mechanism can be removed now.
+ */
+ vbo_exec_init( ctx );
+ vbo_save_init( ctx );
+
return GL_TRUE;
}
struct vbo_context {
- struct gl_client_array legacy_currval[16];
- struct gl_client_array generic_currval[16];
- struct gl_client_array mat_currval[16];
+ struct gl_client_array currval[VBO_ATTRIB_MAX];
+
+ /* These point into the above. TODO: remove.
+ */
+ struct gl_client_array *legacy_currval;
+ struct gl_client_array *generic_currval;
+ struct gl_client_array *mat_currval;
GLuint map_vp_none[32];
GLuint map_vp_arb[32];
+ GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->Current, ctx->Light.Material */
+ GLfloat CurrentFloatEdgeFlag;
+
+
struct vbo_exec_context exec;
struct vbo_save_context save;
GLfloat *vbptr; /* cursor, points into buffer */
GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current vertex */
- GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->Current, ctx->Light.Material */
- GLfloat CurrentFloatEdgeFlag;
-
GLuint vert_count;
GLuint max_vert;
struct vbo_exec_copied_vtx copied;
static void vbo_exec_copy_to_current( struct vbo_exec_context *exec )
{
GLcontext *ctx = exec->ctx;
+ struct vbo_context *vbo = vbo_context(ctx);
GLuint i;
for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) {
if (exec->vtx.attrsz[i]) {
+ GLfloat *current = (GLfloat *)vbo->currval[i].Ptr;
+
/* Note: the exec->vtx.current[i] pointers point into the
* ctx->Current.Attrib and ctx->Light.Material.Attrib arrays.
*/
- COPY_CLEAN_4V(exec->vtx.current[i],
+ COPY_CLEAN_4V(current,
exec->vtx.attrsz[i],
exec->vtx.attrptr[i]);
+
+ /* Given that we explicitly state size here, there is no need
+ * for the COPY_CLEAN above, could just copy 16 bytes and be
+ * done. The only problem is when Mesa accesses ctx->Current
+ * directly.
+ */
+ vbo->currval[i].Size = exec->vtx.attrsz[i];
+
/* This triggers rather too much recalculation of Mesa state
* that doesn't get used (eg light positions).
*/
}
}
- /* color index is special (it's not a float[4] so COPY_CLEAN_4V above
- * will trash adjacent memory!)
- */
- if (exec->vtx.attrsz[VBO_ATTRIB_INDEX]) {
- ctx->Current.Index = exec->vtx.attrptr[VBO_ATTRIB_INDEX][0];
- }
-
- /* Edgeflag requires additional treatment:
- */
- if (exec->vtx.attrsz[VBO_ATTRIB_EDGEFLAG]) {
- ctx->Current.EdgeFlag = (exec->vtx.CurrentFloatEdgeFlag == 1.0);
- }
-
/* Colormaterial -- this kindof sucks.
*/
if (ctx->Light.ColorMaterialEnabled &&
static void vbo_exec_copy_from_current( struct vbo_exec_context *exec )
{
GLcontext *ctx = exec->ctx;
+ struct vbo_context *vbo = vbo_context(ctx);
GLint i;
- /* Edgeflag requires additional treatment:
- */
- exec->vtx.CurrentFloatEdgeFlag =
- (GLfloat)ctx->Current.EdgeFlag;
-
- for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++)
+ for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) {
+ const GLfloat *current = (GLfloat *)vbo->currval[i].Ptr;
switch (exec->vtx.attrsz[i]) {
- case 4: exec->vtx.attrptr[i][3] = exec->vtx.current[i][3];
- case 3: exec->vtx.attrptr[i][2] = exec->vtx.current[i][2];
- case 2: exec->vtx.attrptr[i][1] = exec->vtx.current[i][1];
- case 1: exec->vtx.attrptr[i][0] = exec->vtx.current[i][0];
+ case 4: exec->vtx.attrptr[i][3] = current[3];
+ case 3: exec->vtx.attrptr[i][2] = current[2];
+ case 2: exec->vtx.attrptr[i][1] = current[1];
+ case 1: exec->vtx.attrptr[i][0] = current[0];
break;
}
+ }
ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
}
GLuint newsz )
{
GLcontext *ctx = exec->ctx;
+ struct vbo_context *vbo = vbo_context(ctx);
GLint lastcount = exec->vtx.vert_count;
GLfloat *tmp;
GLuint oldsz;
data += oldsz;
dest += newsz;
} else {
- COPY_SZ_4V( dest, newsz, exec->vtx.current[j] );
+ const GLfloat *current = (const GLfloat *)vbo->currval[j].Ptr;
+ COPY_SZ_4V( dest, newsz, current );
dest += newsz;
}
}
}
-static void vbo_exec_current_init( struct vbo_exec_context *exec )
-{
- GLcontext *ctx = exec->ctx;
- GLint i;
-
- /* setup the pointers for the typical 16 vertex attributes */
- for (i = 0; i < VBO_ATTRIB_FIRST_MATERIAL; i++)
- exec->vtx.current[i] = ctx->Current.Attrib[i];
-
- /* setup pointers for the 12 material attributes */
- for (i = 0; i < MAT_ATTRIB_MAX; i++)
- exec->vtx.current[VBO_ATTRIB_FIRST_MATERIAL + i] =
- ctx->Light.Material.Attrib[i];
-
- exec->vtx.current[VBO_ATTRIB_INDEX] = &ctx->Current.Index;
- exec->vtx.current[VBO_ATTRIB_EDGEFLAG] = &exec->vtx.CurrentFloatEdgeFlag;
-}
-
void vbo_exec_vtx_init( struct vbo_exec_context *exec )
{
GLcontext *ctx = exec->ctx;
+ struct vbo_context *vbo = vbo_context(ctx);
GLuint i;
/* Allocate a buffer object. Will just reuse this object
exec->vtx.bufferobj = ctx->Array.NullBufferObj;
exec->vtx.buffer_map = ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE * sizeof(GLfloat), 64);
- vbo_exec_current_init( exec );
vbo_exec_vtxfmt_init( exec );
/* Hook our functions into the dispatch table.
exec->vtx.active_sz[i] = 0;
exec->vtx.inputs[i] = &exec->vtx.arrays[i];
}
-
+
+ {
+ struct gl_client_array *arrays = exec->vtx.arrays;
+ memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
+ memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
+ }
+
exec->vtx.vertex_size = 0;
}
switch (get_program_mode(exec->ctx)) {
case VP_NONE:
memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->mat_currval, 16 * sizeof(arrays[0]));
+ memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0]));
map = vbo->map_vp_none;
break;
case VP_NV:
void vbo_save_init( GLcontext *ctx )
{
- struct vbo_save_context *save = &vbo_context(ctx)->save;
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct vbo_save_context *save = &vbo->save;
save->ctx = ctx;
vbo_save_api_init( save );
vbo_save_callback_init(ctx);
+ {
+ struct gl_client_array *arrays = save->arrays;
+ memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
+ memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
+ }
+
ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
}
static void _playback_copy_to_current( GLcontext *ctx,
const struct vbo_save_vertex_list *node )
{
- struct vbo_save_context *save = &vbo_context(ctx)->save;
+ struct vbo_context *vbo = vbo_context(ctx);
GLfloat vertex[VBO_ATTRIB_MAX * 4], *data = vertex;
GLuint i, offset;
for (i = VBO_ATTRIB_POS+1 ; i <= VBO_ATTRIB_INDEX ; i++) {
if (node->attrsz[i]) {
- COPY_CLEAN_4V(save->current[i], node->attrsz[i], data);
+ GLfloat *current = (GLfloat *)vbo->currval[i].Ptr;
+
+ COPY_CLEAN_4V(current,
+ node->attrsz[i],
+ data);
+
+ vbo->currval[i].Size = node->attrsz[i];
+
data += node->attrsz[i];
if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT &&
}
}
- /* Edgeflag requires special treatment:
- */
- if (node->attrsz[VBO_ATTRIB_EDGEFLAG]) {
- ctx->Current.EdgeFlag = (data[0] == 1.0);
- }
-
-
-#if 1
/* Colormaterial -- this kindof sucks.
*/
if (ctx->Light.ColorMaterialEnabled) {
_mesa_update_color_material(ctx, ctx->Current.Attrib[VBO_ATTRIB_COLOR0]);
}
-#endif
/* CurrentExecPrimitive
*/
switch (get_program_mode(ctx)) {
case VP_NONE:
memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->mat_currval, 16 * sizeof(arrays[0]));
+ memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0]));
map = vbo->map_vp_none;
break;
case VP_NV: