#include "vbo.h"
#include "vbo_context.h"
-#if 0
-/* Reach out and grab this to use as the default:
- */
-extern void _tnl_draw_prims( GLcontext *ctx,
- const struct gl_client_array *arrays[],
- const struct _mesa_prim *prims,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLuint min_index,
- GLuint max_index );
-#endif
-
-
-
-#define NR_LEGACY_ATTRIBS 16
-#define NR_GENERIC_ATTRIBS 16
#define NR_MAT_ATTRIBS 12
static GLuint check_size( const GLfloat *attr )
return 1;
}
-static void init_legacy_currval(GLcontext *ctx)
+
+static void init_legacy_currval(struct gl_context *ctx)
{
struct vbo_context *vbo = vbo_context(ctx);
- struct gl_client_array *arrays = vbo->legacy_currval;
+ struct gl_client_array *arrays = &vbo->currval[VBO_ATTRIB_POS];
GLuint i;
- memset(arrays, 0, sizeof(*arrays) * NR_LEGACY_ATTRIBS);
+ memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_FF_MAX);
/* Set up a constant (StrideB == 0) array for each current
* attribute:
*/
- for (i = 0; i < NR_LEGACY_ATTRIBS; i++) {
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
struct gl_client_array *cl = &arrays[i];
/* Size will have to be determined at runtime:
cl->Type = GL_FLOAT;
cl->Format = GL_RGBA;
cl->Ptr = (const void *)ctx->Current.Attrib[i];
+ cl->_ElementSize = cl->Size * sizeof(GLfloat);
_mesa_reference_buffer_object(ctx, &cl->BufferObj,
ctx->Shared->NullBufferObj);
}
}
-static void init_generic_currval(GLcontext *ctx)
+static void init_generic_currval(struct gl_context *ctx)
{
struct vbo_context *vbo = vbo_context(ctx);
- struct gl_client_array *arrays = vbo->generic_currval;
+ struct gl_client_array *arrays = &vbo->currval[VBO_ATTRIB_GENERIC0];
GLuint i;
- memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS);
+ memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_GENERIC_MAX);
- for (i = 0; i < NR_GENERIC_ATTRIBS; i++) {
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
struct gl_client_array *cl = &arrays[i];
/* This will have to be determined at runtime:
cl->Stride = 0;
cl->StrideB = 0;
cl->Enabled = 1;
+ cl->_ElementSize = cl->Size * sizeof(GLfloat);
_mesa_reference_buffer_object(ctx, &cl->BufferObj,
ctx->Shared->NullBufferObj);
}
}
-static void init_mat_currval(GLcontext *ctx)
+static void init_mat_currval(struct gl_context *ctx)
{
struct vbo_context *vbo = vbo_context(ctx);
- struct gl_client_array *arrays = vbo->mat_currval;
+ struct gl_client_array *arrays =
+ &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT];
GLuint i;
ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX);
cl->Stride = 0;
cl->StrideB = 0;
cl->Enabled = 1;
- cl->BufferObj = ctx->Shared->NullBufferObj;
+ cl->_ElementSize = cl->Size * sizeof(GLfloat);
+ _mesa_reference_buffer_object(ctx, &cl->BufferObj,
+ ctx->Shared->NullBufferObj);
}
}
-#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 )
+GLboolean _vbo_CreateContext( struct gl_context *ctx )
{
struct vbo_context *vbo = CALLOC_STRUCT(vbo_context);
return GL_FALSE;
}
- /* TODO: remove these pointers.
- */
- 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 );
init_mat_currval( ctx );
{
GLuint i;
- /* When no vertex program, pull in the material attributes in
- * the 16..32 generic range.
- */
- for (i = 0; i < 16; i++)
+ /* identity mapping */
+ for (i = 0; i < Elements(vbo->map_vp_none); i++)
vbo->map_vp_none[i] = i;
- for (i = 0; i < 12; i++)
- vbo->map_vp_none[16+i] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
- for (i = 0; i < 4; i++)
- vbo->map_vp_none[28+i] = i;
-
+ /* map material attribs to generic slots */
+ for (i = 0; i < NR_MAT_ATTRIBS; i++)
+ vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)]
+ = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
+
for (i = 0; i < Elements(vbo->map_vp_arb); i++)
vbo->map_vp_arb[i] = i;
}
- /* By default:
- */
-#if 0 /* dead - see vbo_set_draw_func() */
- vbo->draw_prims = _tnl_draw_prims;
-#endif
-
/* 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 );
-#if FEATURE_dlist
- vbo_save_init( ctx );
-#endif
+ if (ctx->API == API_OPENGL)
+ vbo_save_init( ctx );
_math_init_eval();
return GL_TRUE;
}
-void _vbo_InvalidateState( GLcontext *ctx, GLuint new_state )
+
+void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state )
{
- _ae_invalidate_state(ctx, new_state);
vbo_exec_invalidate_state(ctx, new_state);
}
-void _vbo_DestroyContext( GLcontext *ctx )
+void _vbo_DestroyContext( struct gl_context *ctx )
{
+ struct vbo_context *vbo = vbo_context(ctx);
+
if (ctx->aelt_context) {
_ae_destroy_context( ctx );
ctx->aelt_context = NULL;
}
- if (vbo_context(ctx)) {
+ if (vbo) {
+ GLuint i;
+
+ for (i = 0; i < VBO_ATTRIB_MAX; i++) {
+ _mesa_reference_buffer_object(ctx, &vbo->currval[i].BufferObj, NULL);
+ }
+
vbo_exec_destroy(ctx);
-#if FEATURE_dlist
- vbo_save_destroy(ctx);
-#endif
- FREE(vbo_context(ctx));
+ if (ctx->API == API_OPENGL)
+ vbo_save_destroy(ctx);
+ free(vbo);
ctx->swtnl_im = NULL;
}
}
-void vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func)
+void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func)
{
struct vbo_context *vbo = vbo_context(ctx);
vbo->draw_prims = func;