diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2003-09-17 16:06:49 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2003-09-17 16:06:49 +0000 |
commit | 57d882b6847128fe5f72575f61a2b2dace7ac46c (patch) | |
tree | 0b8d61a758d856e9521c03e4c38ed72c29cdd3d1 | |
parent | 397d1e4d5750bda09e52451cfeb0a69126602a56 (diff) |
GL_ARB_vertex_buffer_object working now, at least for non-indexed
vertex arrays.
-rw-r--r-- | src/mesa/array_cache/ac_context.c | 32 | ||||
-rw-r--r-- | src/mesa/array_cache/ac_import.c | 32 | ||||
-rw-r--r-- | src/mesa/drivers/osmesa/osmesa.c | 11 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 58 | ||||
-rw-r--r-- | src/mesa/main/api_arrayelt.c | 11 | ||||
-rw-r--r-- | src/mesa/main/imports.h | 10 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 2 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 45 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_elt.c | 24 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_eval.c | 19 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.c | 2 |
11 files changed, 156 insertions, 90 deletions
diff --git a/src/mesa/array_cache/ac_context.c b/src/mesa/array_cache/ac_context.c index e3c09fbd20..b259d5d071 100644 --- a/src/mesa/array_cache/ac_context.c +++ b/src/mesa/array_cache/ac_context.c @@ -328,28 +328,40 @@ GLboolean _ac_CreateContext( GLcontext *ctx ) void _ac_DestroyContext( GLcontext *ctx ) { + struct gl_buffer_object *nullObj = ctx->Array.NullBufferObj; ACcontext *ac = AC_CONTEXT(ctx); GLint i; - if (ac->Cache.Vertex.Ptr) FREE( ac->Cache.Vertex.Ptr ); - if (ac->Cache.Normal.Ptr) FREE( ac->Cache.Normal.Ptr ); - if (ac->Cache.Color.Ptr) FREE( ac->Cache.Color.Ptr ); - if (ac->Cache.SecondaryColor.Ptr) FREE( ac->Cache.SecondaryColor.Ptr ); - if (ac->Cache.EdgeFlag.Ptr) FREE( ac->Cache.EdgeFlag.Ptr ); - if (ac->Cache.Index.Ptr) FREE( ac->Cache.Index.Ptr ); - if (ac->Cache.FogCoord.Ptr) FREE( ac->Cache.FogCoord.Ptr ); + /* only free vertex data if it's really a pointer to vertex data and + * not an offset into a buffer object. + */ + if (ac->Cache.Vertex.Ptr && ac->Cache.Vertex.BufferObj == nullObj) + FREE( ac->Cache.Vertex.Ptr ); + if (ac->Cache.Normal.Ptr && ac->Cache.Normal.BufferObj == nullObj) + FREE( ac->Cache.Normal.Ptr ); + if (ac->Cache.Color.Ptr && ac->Cache.Color.BufferObj == nullObj) + FREE( ac->Cache.Color.Ptr ); + if (ac->Cache.SecondaryColor.Ptr && ac->Cache.SecondaryColor.BufferObj == nullObj) + FREE( ac->Cache.SecondaryColor.Ptr ); + if (ac->Cache.EdgeFlag.Ptr && ac->Cache.EdgeFlag.BufferObj == nullObj) + FREE( ac->Cache.EdgeFlag.Ptr ); + if (ac->Cache.Index.Ptr && ac->Cache.Index.BufferObj == nullObj) + FREE( ac->Cache.Index.Ptr ); + if (ac->Cache.FogCoord.Ptr && ac->Cache.FogCoord.BufferObj == nullObj) + FREE( ac->Cache.FogCoord.Ptr ); for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { - if (ac->Cache.TexCoord[i].Ptr) + if (ac->Cache.TexCoord[i].Ptr && ac->Cache.TexCoord[i].BufferObj == nullObj) FREE( ac->Cache.TexCoord[i].Ptr ); } for (i = 0; i < VERT_ATTRIB_MAX; i++) { - if (ac->Cache.Attrib[i].Ptr) + if (ac->Cache.Attrib[i].Ptr && ac->Cache.Attrib[i].BufferObj == nullObj) FREE( ac->Cache.Attrib[i].Ptr ); } - if (ac->Elts) FREE( ac->Elts ); + if (ac->Elts) + FREE( ac->Elts ); /* Free the context structure itself */ FREE(ac); diff --git a/src/mesa/array_cache/ac_import.c b/src/mesa/array_cache/ac_import.c index b2b7eeb219..78f5435635 100644 --- a/src/mesa/array_cache/ac_import.c +++ b/src/mesa/array_cache/ac_import.c @@ -34,17 +34,17 @@ #include "array_cache/ac_context.h" #include "math/m_translate.h" -#define STRIDE_ARRAY( array, offset ) \ -do { \ - GLubyte *tmp = (array).Ptr; \ - tmp += (offset) * (array).StrideB; \ - (array).Ptr = tmp; \ +#define STRIDE_ARRAY( array, offset ) \ +do { \ + GLubyte *tmp = ADD_POINTERS( (array).BufferObj->Data, (array).Ptr ) \ + + (offset) * (array).StrideB; \ + (array).Ptr = tmp; \ } while (0) + /* Set the array pointer back to its source when the cached data is * invalidated: */ - static void reset_texcoord( GLcontext *ctx, GLuint unit ) { ACcontext *ac = AC_CONTEXT(ctx); @@ -202,15 +202,23 @@ static void import( GLcontext *ctx, struct gl_client_array *to, struct gl_client_array *from ) { + GLubyte *dest; + const GLubyte *src; ACcontext *ac = AC_CONTEXT(ctx); if (type == 0) type = from->Type; + /* The dest and source data addresses are the sum of the buffer + * object's start plus the vertex array pointer/offset. + */ + dest = ADD_POINTERS(to->BufferObj->Data, to->Ptr); + src = ADD_POINTERS(from->BufferObj->Data, from->Ptr); + switch (type) { case GL_FLOAT: - _math_trans_4fc( (GLfloat (*)[4]) to->Ptr, - from->Ptr, + _math_trans_4fc( (GLfloat (*)[4]) dest, + src, from->StrideB, from->Type, from->Size, @@ -222,8 +230,8 @@ static void import( GLcontext *ctx, break; case GL_UNSIGNED_BYTE: - _math_trans_4ub( (GLubyte (*)[4]) to->Ptr, - from->Ptr, + _math_trans_4ub( (GLubyte (*)[4]) dest, + src, from->StrideB, from->Type, from->Size, @@ -235,8 +243,8 @@ static void import( GLcontext *ctx, break; case GL_UNSIGNED_SHORT: - _math_trans_4us( (GLushort (*)[4]) to->Ptr, - from->Ptr, + _math_trans_4us( (GLushort (*)[4]) dest, + src, from->StrideB, from->Type, from->Size, diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 8d833f8d1c..396f9af6b0 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -36,6 +36,7 @@ #include "glheader.h" #include "GL/osmesa.h" #include "buffers.h" +#include "bufferobj.h" #include "context.h" #include "colormac.h" #include "depth.h" @@ -681,6 +682,16 @@ hook_in_driver_functions( GLcontext *ctx ) ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; +#if FEATURE_ARB_vertex_buffer_object + ctx->Driver.NewBufferObject = _mesa_new_buffer_object; + ctx->Driver.DeleteBuffer = _mesa_delete_buffer_object; + ctx->Driver.BindBuffer = NULL; + ctx->Driver.BufferData = _mesa_buffer_data; + ctx->Driver.BufferSubData = _mesa_buffer_subdata; + ctx->Driver.MapBuffer = _mesa_buffer_map; + ctx->Driver.UnmapBuffer = NULL; +#endif + swdd->SetBuffer = set_buffer; /* RGB(A) span/pixel functions */ diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 3a3375f34c..a99c0d4b5f 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -24,6 +24,7 @@ #include "glxheader.h" +#include "bufferobj.h" #include "context.h" #include "colormac.h" #include "depth.h" @@ -92,7 +93,7 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) static void -finish( GLcontext *ctx ) +finish_or_flush( GLcontext *ctx ) { #ifdef XFree86Server /* NOT_NEEDED */ @@ -107,22 +108,6 @@ finish( GLcontext *ctx ) } -static void -flush( GLcontext *ctx ) -{ -#ifdef XFree86Server - /* NOT_NEEDED */ -#else - const XMesaContext xmesa = XMESA_CONTEXT(ctx); - if (xmesa) { - _glthread_LOCK_MUTEX(_xmesa_lock); - XFlush( xmesa->display ); - _glthread_UNLOCK_MUTEX(_xmesa_lock); - } -#endif -} - - /* * This chooses the color buffer for reading and writing spans, points, @@ -832,7 +817,10 @@ drawpixels_8R8G8B( GLcontext *ctx, #endif - +/* + * Every driver should implement a GetString function in order to + * return a meaningful GL_RENDERER string. + */ static const GLubyte * get_string( GLcontext *ctx, GLenum name ) { @@ -856,6 +844,10 @@ get_string( GLcontext *ctx, GLenum name ) } +/* + * We implement the glEnable function only because we care about + * dither enable/disable. + */ static void enable( GLcontext *ctx, GLenum pname, GLboolean state ) { @@ -970,11 +962,17 @@ void xmesa_init_pointers( GLcontext *ctx ) TNLcontext *tnl; struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference( ctx ); + /* Plug in our driver-specific functions here */ ctx->Driver.GetString = get_string; ctx->Driver.GetBufferSize = get_buffer_size; - ctx->Driver.Flush = flush; - ctx->Driver.Finish = finish; - + ctx->Driver.Flush = finish_or_flush; + ctx->Driver.Finish = finish_or_flush; + ctx->Driver.ClearIndex = clear_index; + ctx->Driver.ClearColor = clear_color; + ctx->Driver.IndexMask = index_mask; + ctx->Driver.ColorMask = color_mask; + ctx->Driver.Enable = enable; + /* Software rasterizer pixel paths: */ ctx->Driver.Accum = _swrast_Accum; @@ -1017,15 +1015,15 @@ void xmesa_init_pointers( GLcontext *ctx ) ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; - - /* Statechange callbacks: - */ - ctx->Driver.ClearIndex = clear_index; - ctx->Driver.ClearColor = clear_color; - ctx->Driver.IndexMask = index_mask; - ctx->Driver.ColorMask = color_mask; - ctx->Driver.Enable = enable; - +#if FEATURE_ARB_vertex_buffer_object + ctx->Driver.NewBufferObject = _mesa_new_buffer_object; + ctx->Driver.DeleteBuffer = _mesa_delete_buffer_object; + ctx->Driver.BindBuffer = NULL; + ctx->Driver.BufferData = _mesa_buffer_data; + ctx->Driver.BufferSubData = _mesa_buffer_subdata; + ctx->Driver.MapBuffer = _mesa_buffer_map; + ctx->Driver.UnmapBuffer = NULL; +#endif /* Initialize the TNL driver interface: */ diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index edfa8e53cf..e4533713cd 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -1,4 +1,3 @@ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -346,13 +345,19 @@ void _ae_loopback_array_elt( GLint elt ) _ae_update_state( ctx ); for (ta = actx->texarrays ; ta->func ; ta++) { - ta->func( ta->unit + GL_TEXTURE0_ARB, (char *)ta->array->Ptr + elt * ta->array->StrideB ); + GLubyte *src = ta->array->BufferObj->Data + + (GLuint) ta->array->Ptr + + elt * ta->array->StrideB; + ta->func( ta->unit + GL_TEXTURE0_ARB, src); } /* Must be last */ for (aa = actx->arrays ; aa->func ; aa++) { - aa->func( (char *)aa->array->Ptr + elt * aa->array->StrideB ); + GLubyte *src = aa->array->BufferObj->Data + + (GLuint) aa->array->Ptr + + elt * aa->array->StrideB; + aa->func( src ); } } diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 532649a354..df0d6d771d 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -92,6 +92,16 @@ extern "C" { /*@}*/ +/* + * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers + * as offsets into buffer stores. Since the vertex array pointer and + * buffer store pointer are both pointers and we need to add them, we use + * this macro. + * Both pointers/offsets are expressed in bytes. + */ +#define ADD_POINTERS(A, B) ( (A) + (unsigned long) (B) ) + + /**********************************************************************/ /** \name [Pseudo] static array declaration. * diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 341a028ee6..36954675c8 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1262,7 +1262,7 @@ struct gl_buffer_object { GLenum Access; GLvoid *Pointer; /**< Only valid while buffer is mapped */ GLuint Size; /**< Size of data array in bytes */ - GLubyte *Data; /**< The storage */ + GLubyte *Data; /**< The storage */ }; diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 1bdf1c64e5..ab11f50c8f 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -1,4 +1,3 @@ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -48,6 +47,7 @@ static void _tnl_import_vertex( GLcontext *ctx, struct gl_client_array *tmp; GLboolean is_writeable = 0; struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + GLubyte *data; tmp = _ac_import_vertex(ctx, GL_FLOAT, @@ -56,8 +56,9 @@ static void _tnl_import_vertex( GLcontext *ctx, writeable, &is_writeable); - inputs->Obj.data = (GLfloat (*)[4]) tmp->Ptr; - inputs->Obj.start = (GLfloat *) tmp->Ptr; + data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); + inputs->Obj.data = (GLfloat (*)[4]) data; + inputs->Obj.start = (GLfloat *) data; inputs->Obj.stride = tmp->StrideB; inputs->Obj.size = tmp->Size; inputs->Obj.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); @@ -74,13 +75,15 @@ static void _tnl_import_normal( GLcontext *ctx, struct gl_client_array *tmp; GLboolean is_writeable = 0; struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + GLubyte *data; tmp = _ac_import_normal(ctx, GL_FLOAT, stride ? 3*sizeof(GLfloat) : 0, writeable, &is_writeable); - inputs->Normal.data = (GLfloat (*)[4]) tmp->Ptr; - inputs->Normal.start = (GLfloat *) tmp->Ptr; + data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); + inputs->Normal.data = (GLfloat (*)[4]) data; + inputs->Normal.start = (GLfloat *) data; inputs->Normal.stride = tmp->StrideB; inputs->Normal.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); if (inputs->Normal.stride != 3*sizeof(GLfloat)) @@ -134,15 +137,17 @@ static void _tnl_import_fogcoord( GLcontext *ctx, GLboolean stride ) { struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - struct gl_client_array *tmp; + struct gl_client_array *tmp; GLboolean is_writeable = 0; + GLubyte *data; tmp = _ac_import_fogcoord(ctx, GL_FLOAT, stride ? sizeof(GLfloat) : 0, writeable, &is_writeable); - inputs->FogCoord.data = (GLfloat (*)[4]) tmp->Ptr; - inputs->FogCoord.start = (GLfloat *) tmp->Ptr; + data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); + inputs->FogCoord.data = (GLfloat (*)[4]) data; + inputs->FogCoord.start = (GLfloat *) data; inputs->FogCoord.stride = tmp->StrideB; inputs->FogCoord.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); if (inputs->FogCoord.stride != sizeof(GLfloat)) @@ -158,13 +163,15 @@ static void _tnl_import_index( GLcontext *ctx, struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; + GLubyte *data; tmp = _ac_import_index(ctx, GL_UNSIGNED_INT, stride ? sizeof(GLuint) : 0, writeable, &is_writeable); - inputs->Index.data = (GLuint *) tmp->Ptr; - inputs->Index.start = (GLuint *) tmp->Ptr; + data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); + inputs->Index.data = (GLuint *) data; + inputs->Index.start = (GLuint *) data; inputs->Index.stride = tmp->StrideB; inputs->Index.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); if (inputs->Index.stride != sizeof(GLuint)) @@ -182,6 +189,7 @@ static void _tnl_import_texcoord( GLcontext *ctx, struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; + GLubyte *data; tmp = _ac_import_texcoord(ctx, unit, GL_FLOAT, stride ? 4 * sizeof(GLfloat) : 0, @@ -189,8 +197,9 @@ static void _tnl_import_texcoord( GLcontext *ctx, writeable, &is_writeable); - inputs->TexCoord[unit].data = (GLfloat (*)[4]) tmp->Ptr; - inputs->TexCoord[unit].start = (GLfloat *) tmp->Ptr; + data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); + inputs->TexCoord[unit].data = (GLfloat (*)[4]) data; + inputs->TexCoord[unit].start = (GLfloat *) data; inputs->TexCoord[unit].stride = tmp->StrideB; inputs->TexCoord[unit].size = tmp->Size; inputs->TexCoord[unit].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); @@ -208,14 +217,16 @@ static void _tnl_import_edgeflag( GLcontext *ctx, struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; + GLubyte *data; tmp = _ac_import_edgeflag(ctx, GL_UNSIGNED_BYTE, stride ? sizeof(GLubyte) : 0, 0, &is_writeable); - inputs->EdgeFlag.data = (GLubyte *) tmp->Ptr; - inputs->EdgeFlag.start = (GLubyte *) tmp->Ptr; + data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); + inputs->EdgeFlag.data = (GLubyte *) data; + inputs->EdgeFlag.start = (GLubyte *) data; inputs->EdgeFlag.stride = tmp->StrideB; inputs->EdgeFlag.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); if (inputs->EdgeFlag.stride != sizeof(GLubyte)) @@ -234,6 +245,7 @@ static void _tnl_import_attrib( GLcontext *ctx, struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; + GLubyte *data; tmp = _ac_import_attrib(ctx, index, GL_FLOAT, stride ? 4 * sizeof(GLfloat) : 0, @@ -241,8 +253,9 @@ static void _tnl_import_attrib( GLcontext *ctx, writeable, &is_writeable); - inputs->Attribs[index].data = (GLfloat (*)[4]) tmp->Ptr; - inputs->Attribs[index].start = (GLfloat *) tmp->Ptr; + data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); + inputs->Attribs[index].data = (GLfloat (*)[4]) data; + inputs->Attribs[index].start = (GLfloat *) data; inputs->Attribs[index].stride = tmp->StrideB; inputs->Attribs[index].size = tmp->Size; inputs->Attribs[index].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c index 44c2a32c85..fdecef61af 100644 --- a/src/mesa/tnl/t_imm_elt.c +++ b/src/mesa/tnl/t_imm_elt.c @@ -516,14 +516,15 @@ static void _tnl_trans_elt_1ui(GLuint *to, GLuint start, GLuint n ) { + GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); _tnl_trans_elt_1ui_tab[TYPE_IDX(from->Type)]( to, - from->Ptr, - from->StrideB, - flags, - elts, - match, - start, - n ); + fromData, + from->StrideB, + flags, + elts, + match, + start, + n ); } @@ -536,8 +537,9 @@ static void _tnl_trans_elt_1ub(GLubyte *to, GLuint start, GLuint n ) { + GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to, - from->Ptr, + fromData, from->StrideB, flags, elts, @@ -555,8 +557,9 @@ static void _tnl_trans_elt_4f(GLfloat (*to)[4], GLuint start, GLuint n ) { + GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); _tnl_trans_elt_4f_tab[from->Size][TYPE_IDX(from->Type)]( to, - from->Ptr, + fromData, from->StrideB, flags, elts, @@ -575,8 +578,9 @@ static void _tnl_trans_elt_4fc(GLfloat (*to)[4], GLuint start, GLuint n ) { + GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); _tnl_trans_elt_4fc_tab[from->Size][TYPE_IDX(from->Type)]( to, - from->Ptr, + fromData, from->StrideB, flags, elts, diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c index 8411d7da47..560e0c5933 100644 --- a/src/mesa/tnl/t_imm_eval.c +++ b/src/mesa/tnl/t_imm_eval.c @@ -1,4 +1,3 @@ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -120,7 +119,8 @@ static void eval1_4f_ca( struct gl_client_array *dest, { const GLfloat u1 = map->u1; const GLfloat du = map->du; - GLfloat (*to)[4] = (GLfloat (*)[4])dest->Ptr; + GLubyte *destData = ADD_POINTERS(dest->Ptr, dest->BufferObj->Data); + GLfloat (*to)[4] = (GLfloat (*)[4]) destData; GLuint i; ASSERT(dest->Type == GL_FLOAT); @@ -258,7 +258,8 @@ static void eval2_4f_ca( struct gl_client_array *dest, const GLfloat du = map->du; const GLfloat v1 = map->v1; const GLfloat dv = map->dv; - GLfloat (*to)[4] = (GLfloat (*)[4])dest->Ptr; + GLubyte *destData = ADD_POINTERS(dest->Ptr, dest->BufferObj->Data); + GLfloat (*to)[4] = (GLfloat (*)[4]) destData; GLuint i; ASSERT(dest->Type == GL_FLOAT); @@ -540,11 +541,13 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) if (req & VERT_BIT_COLOR0) { GLuint generated = 0; - if (copycount) - copy_4f_stride( store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart, - (GLfloat *)tmp->Color.Ptr, - tmp->Color.StrideB, - copycount ); + if (copycount) { + GLubyte *destData = ADD_POINTERS(tmp->Color.Ptr, tmp->Color.BufferObj->Data); + copy_4f_stride( store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart, + (GLfloat *) destData, + tmp->Color.StrideB, + copycount ); + } tmp->Color.Ptr = (GLubyte *) (store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart); tmp->Color.StrideB = 4 * sizeof(GLfloat); diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 85f63dd8fb..14d214e843 100644 --- a/src/mesa/tnl/t_imm_exec.c +++ b/src/mesa/tnl/t_imm_exec.c @@ -538,6 +538,7 @@ void _tnl_imm_init( GLcontext *ctx ) tmp->Color.Stride = 0; tmp->Color.StrideB = 4 * sizeof(GLfloat); tmp->Color.Flags = 0; + tmp->Color.BufferObj = ctx->Array.NullBufferObj; tmp->SecondaryColor.Ptr = NULL; tmp->SecondaryColor.Type = GL_FLOAT; @@ -545,6 +546,7 @@ void _tnl_imm_init( GLcontext *ctx ) tmp->SecondaryColor.Stride = 0; tmp->SecondaryColor.StrideB = 4 * sizeof(GLfloat); tmp->SecondaryColor.Flags = 0; + tmp->SecondaryColor.BufferObj = ctx->Array.NullBufferObj; _mesa_vector4f_init( &tmp->FogCoord, 0, 0 ); _mesa_vector1ui_init( &tmp->Index, 0, 0 ); |