X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fvbo%2Fvbo_context.c;h=e3be39a342e134255a4fac96e9b758e6b7a20b0b;hb=25da8e66f8f9b5a6a20ba95412e80b1f422f48d0;hp=467ab4e3e5505dc42c8e7ba540c623f8f536a687;hpb=ee4c921b65fb76998711f3c40330505cbc49a0e0;p=mesa.git diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index 467ab4e3e55..e3be39a342e 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -28,27 +28,18 @@ #include "main/imports.h" #include "main/mtypes.h" #include "main/api_arrayelt.h" +#include "main/bufferobj.h" +#include "math/m_eval.h" #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 ) { if (attr[3] != 1.0) return 4; @@ -57,6 +48,7 @@ static GLuint check_size( const GLfloat *attr ) return 1; } + static void init_legacy_currval(GLcontext *ctx) { struct vbo_context *vbo = vbo_context(ctx); @@ -80,7 +72,8 @@ static void init_legacy_currval(GLcontext *ctx) cl->Type = GL_FLOAT; cl->Format = GL_RGBA; cl->Ptr = (const void *)ctx->Current.Attrib[i]; - cl->BufferObj = ctx->Array.NullBufferObj; + _mesa_reference_buffer_object(ctx, &cl->BufferObj, + ctx->Shared->NullBufferObj); } } @@ -105,7 +98,8 @@ static void init_generic_currval(GLcontext *ctx) cl->Stride = 0; cl->StrideB = 0; cl->Enabled = 1; - cl->BufferObj = ctx->Array.NullBufferObj; + _mesa_reference_buffer_object(ctx, &cl->BufferObj, + ctx->Shared->NullBufferObj); } } @@ -149,27 +143,11 @@ static void init_mat_currval(GLcontext *ctx) cl->Stride = 0; cl->StrideB = 0; cl->Enabled = 1; - cl->BufferObj = ctx->Array.NullBufferObj; + _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 ) { @@ -210,17 +188,11 @@ GLboolean _vbo_CreateContext( GLcontext *ctx ) for (i = 0; i < 4; i++) vbo->map_vp_none[28+i] = i; - for (i = 0; i < VERT_ATTRIB_MAX; 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. @@ -230,9 +202,12 @@ GLboolean _vbo_CreateContext( GLcontext *ctx ) vbo_save_init( ctx ); #endif + _math_init_eval(); + return GL_TRUE; } + void _vbo_InvalidateState( GLcontext *ctx, GLuint new_state ) { _ae_invalidate_state(ctx, new_state); @@ -242,17 +217,25 @@ void _vbo_InvalidateState( GLcontext *ctx, GLuint new_state ) void _vbo_DestroyContext( GLcontext *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)); + FREE(vbo); ctx->swtnl_im = NULL; } }