From 5568a7d30120d830c93494a7b3382bfa8b4d2800 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 17 Aug 2007 15:26:33 +0100 Subject: added vbo_use_buffer_objects() to specify that immediate mode data should be put into bufferobjects --- src/mesa/vbo/vbo_exec_api.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 7f56b3b629..24e2eba472 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -631,6 +631,41 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) } +/** + * Tell the VBO module to use a real OpenGL vertex buffer object to + * store accumulated immediate-mode vertex data. + * This replaces the malloced buffer which was created in + * vb_exec_vtx_init() below. + */ +void vbo_use_buffer_objects(GLcontext *ctx) +{ + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + /* Any buffer name but 0 can be used here since this bufferobj won't + * go into the bufferobj hashtable. + */ + GLuint bufName = 0xaabbccdd; + GLenum target = GL_ARRAY_BUFFER_ARB; + GLenum access = GL_READ_WRITE_ARB; + GLenum usage = GL_STREAM_DRAW_ARB; + GLsizei size = VBO_VERT_BUFFER_SIZE * sizeof(GLfloat); + + /* Make sure this func is only used once */ + assert(exec->vtx.bufferobj == ctx->Array.NullBufferObj); + if (exec->vtx.buffer_map) { + _mesa_align_free(exec->vtx.buffer_map); + } + + /* Allocate a real buffer object now */ + exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName, target); + ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); + + /* and map it */ + exec->vtx.buffer_map + = ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); +} + + + void vbo_exec_vtx_init( struct vbo_exec_context *exec ) { GLcontext *ctx = exec->ctx; -- cgit v1.2.3 From f252974121febc6a1a59793d932b32b798f90fc6 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 20 Aug 2007 11:05:35 -0600 Subject: fix VBO clean-up in vbo_exec_vtx_destroy() --- src/mesa/vbo/vbo_exec_api.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 24e2eba472..b7f4d8a307 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -673,7 +673,8 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) GLuint i; /* Allocate a buffer object. Will just reuse this object - * continuously. + * continuously, unless vbo_use_buffer_objects() is called to enable + * use of real VBOs. */ exec->vtx.bufferobj = ctx->Array.NullBufferObj; exec->vtx.buffer_map = ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE * sizeof(GLfloat), 64); @@ -702,9 +703,17 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) { - if (exec->vtx.buffer_map) { - ALIGN_FREE(exec->vtx.buffer_map); - exec->vtx.buffer_map = NULL; + GLcontext *ctx = exec->ctx; + if (exec->vtx.bufferobj->Name) { + ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, exec->vtx.bufferobj); + ctx->Driver.DeleteBuffer(ctx, exec->vtx.bufferobj); + exec->vtx.bufferobj = NULL; + } + else { + if (exec->vtx.buffer_map) { + ALIGN_FREE(exec->vtx.buffer_map); + exec->vtx.buffer_map = NULL; + } } } -- cgit v1.2.3 From d08cd68d3f5456b69ad504ede2b090c0bb6474db Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 10 Mar 2008 19:44:54 +0000 Subject: mesa: fast-track glColor and similar calls when not immediate mode rendering Often these are mixed in with draw arrays calls, etc. Try not to get the whole immediate rendering state machine going when we receive one of these on their own. --- src/mesa/vbo/vbo_exec_api.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index b7f4d8a307..35dc0e768f 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -309,16 +309,23 @@ static void vbo_exec_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz ) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + static const GLfloat id[4] = { 0, 0, 0, 1 }; int i; - if (sz > exec->vtx.attrsz[attr]) { + if (exec->vtx.prim_count == 0) { + GLfloat *current = (GLfloat *)vbo_context(ctx)->currval[attr].Ptr; + exec->vtx.attrptr[attr] = current; + memcpy(current, id, sizeof(id)); + ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; + return; + } + else if (sz > exec->vtx.attrsz[attr]) { /* New size is larger. Need to flush existing vertices and get * an enlarged vertex format. */ vbo_exec_wrap_upgrade_vertex( exec, attr, sz ); } else if (sz < exec->vtx.active_sz[attr]) { - static const GLfloat id[4] = { 0, 0, 0, 1 }; /* New size is smaller - just need to fill in some * zeros. Don't need to flush or wrap. -- cgit v1.2.3 From c45a525cdc4bd5f9b35c4f6abae6a65f3279e2c4 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 14 Mar 2008 10:20:29 -0600 Subject: mesa: revert fast-track glColor and similar calls when not immediate mode rendering Revert commit d08cd68d3f5456b69ad504ede2b090c0bb6474db This change caused some glean tests to fail. The alpha value of colors was always 1.0 instead of the value from glColor4fv(). The mesa color array found in st_draw() has size=3 instead of size=4. --- src/mesa/vbo/vbo_exec_api.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 35dc0e768f..b7f4d8a307 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -309,23 +309,16 @@ static void vbo_exec_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz ) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - static const GLfloat id[4] = { 0, 0, 0, 1 }; int i; - if (exec->vtx.prim_count == 0) { - GLfloat *current = (GLfloat *)vbo_context(ctx)->currval[attr].Ptr; - exec->vtx.attrptr[attr] = current; - memcpy(current, id, sizeof(id)); - ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; - return; - } - else if (sz > exec->vtx.attrsz[attr]) { + if (sz > exec->vtx.attrsz[attr]) { /* New size is larger. Need to flush existing vertices and get * an enlarged vertex format. */ vbo_exec_wrap_upgrade_vertex( exec, attr, sz ); } else if (sz < exec->vtx.active_sz[attr]) { + static const GLfloat id[4] = { 0, 0, 0, 1 }; /* New size is smaller - just need to fill in some * zeros. Don't need to flush or wrap. -- cgit v1.2.3 From d758479b9fbff803bdac15f3f39d32ef9064db71 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 11 Apr 2008 10:14:17 -0600 Subject: mesa: Fix glBegin-time test for invalid programs/shaders. Cherry-picked from master. --- src/mesa/vbo/vbo_exec.h | 3 +++ src/mesa/vbo/vbo_exec_api.c | 31 +++++++++++++++++++++++-------- src/mesa/vbo/vbo_exec_array.c | 15 +++++++++++++++ 3 files changed, 41 insertions(+), 8 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index b7e8c9fe79..ddbcbe1181 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -162,4 +162,7 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, void vbo_exec_do_EvalCoord1f( struct vbo_exec_context *exec, GLfloat u); +extern GLboolean +vbo_validate_shaders(GLcontext *ctx); + #endif diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index b7f4d8a307..98580170e3 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -477,6 +477,23 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j ) } +/** + * Check if programs/shaders are enabled and valid at glBegin time. + */ +GLboolean +vbo_validate_shaders(GLcontext *ctx) +{ + if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) || + (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) { + return GL_FALSE; + } + if (ctx->Shader.CurrentProgram && !ctx->Shader.CurrentProgram->LinkStatus) { + return GL_FALSE; + } + return GL_TRUE; +} + + /* Build a list of primitives on the fly. Keep * ctx->Driver.CurrentExecPrimitive uptodate as well. */ @@ -491,18 +508,16 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) if (ctx->NewState) { _mesa_update_state( ctx ); - /* XXX also need to check if shader enabled, but invalid */ - if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) || - (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBegin (invalid vertex/fragment program)"); - return; - } - CALL_Begin(ctx->Exec, (mode)); return; } + if (!vbo_validate_shaders(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBegin (invalid vertex/fragment program)"); + return; + } + /* Heuristic: attempt to isolate attributes occuring outside * begin/end pairs. */ diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 77f3cf1455..a52521db64 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -245,6 +245,11 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) if (ctx->NewState) _mesa_update_state( ctx ); + if (!vbo_validate_shaders(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawArrays(bad shader)"); + return; + } + bind_arrays( ctx ); prim[0].begin = 1; @@ -280,6 +285,11 @@ vbo_exec_DrawRangeElements(GLenum mode, if (ctx->NewState) _mesa_update_state( ctx ); + if (!vbo_validate_shaders(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawRangeElements(bad shader)"); + return; + } + bind_arrays( ctx ); ib.count = count; @@ -340,6 +350,11 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *ind if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices )) return; + if (!vbo_validate_shaders(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawElements(bad shader)"); + return; + } + if (ctx->Array.ElementArrayBufferObj->Name) { const GLvoid *map = ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, -- cgit v1.2.3 From 40d1a40f294f1ed2dacfad6f5498322fc08cc2d1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 10 Jun 2008 16:13:42 -0600 Subject: mesa: refactor: move #define FEATURE flags into new mfeatures.h file Also, check the FEATURE flags in many places. --- src/mesa/main/api_exec.c | 140 ++++++++++++++++++++++++++++++-------------- src/mesa/main/api_exec.h | 5 +- src/mesa/main/api_noop.c | 9 +++ src/mesa/main/config.h | 38 ++---------- src/mesa/main/context.c | 50 +++++++++++++++- src/mesa/main/mfeatures.h | 77 ++++++++++++++++++++++++ src/mesa/main/state.c | 4 ++ src/mesa/main/texformat.c | 26 +++++--- src/mesa/main/teximage.c | 21 ++++++- src/mesa/main/texobj.c | 4 ++ src/mesa/main/texstate.c | 15 +++-- src/mesa/main/texstore.c | 17 +++++- src/mesa/vbo/vbo_context.c | 5 +- src/mesa/vbo/vbo_context.h | 6 +- src/mesa/vbo/vbo_exec.c | 1 - src/mesa/vbo/vbo_exec_api.c | 4 ++ 16 files changed, 323 insertions(+), 99 deletions(-) create mode 100644 src/mesa/main/mfeatures.h (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c index 8cdbaada9b..f7cf42f600 100644 --- a/src/mesa/main/api_exec.c +++ b/src/mesa/main/api_exec.c @@ -30,7 +30,9 @@ #include "glheader.h" +#if FEATURE_accum #include "accum.h" +#endif #include "api_loopback.h" #include "api_exec.h" #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program @@ -39,25 +41,42 @@ #if FEATURE_ATI_fragment_shader #include "shader/atifragshader.h" #endif +#if FEATURE_attrib_stack #include "attrib.h" +#endif #include "blend.h" #if FEATURE_ARB_vertex_buffer_object #include "bufferobj.h" #endif #include "arrayobj.h" +#if FEATURE_draw_read_buffer #include "buffers.h" +#endif #include "clear.h" #include "clip.h" +#if FEATURE_colortable #include "colortab.h" +#endif #include "context.h" +#if FEATURE_convolution #include "convolve.h" +#endif #include "depth.h" +#if FEATURE_dlist #include "dlist.h" +#endif +#if FEATURE_drawpix #include "drawpix.h" +#include "rastpos.h" +#endif #include "enable.h" +#if FEATURE_evaluators #include "eval.h" +#endif #include "get.h" +#if FEATURE_feadback #include "feedback.h" +#endif #include "fog.h" #if FEATURE_EXT_framebuffer_object #include "fbobject.h" @@ -65,21 +84,24 @@ #include "ffvertex_prog.h" #include "framebuffer.h" #include "hint.h" +#if FEATURE_histogram #include "histogram.h" +#endif #include "imports.h" #include "light.h" #include "lines.h" #include "macros.h" #include "matrix.h" #include "multisample.h" +#if FEATURE_pixel_transfer #include "pixel.h" +#endif #include "pixelstore.h" #include "points.h" #include "polygon.h" #if FEATURE_ARB_occlusion_query || FEATURE_EXT_timer_query #include "queryobj.h" #endif -#include "rastpos.h" #include "readpix.h" #include "scissor.h" #include "state.h" @@ -131,7 +153,10 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_ColorMask(exec, _mesa_ColorMask); SET_CullFace(exec, _mesa_CullFace); SET_Disable(exec, _mesa_Disable); +#if FEATURE_draw_read_buffer SET_DrawBuffer(exec, _mesa_DrawBuffer); + SET_ReadBuffer(exec, _mesa_ReadBuffer); +#endif SET_Enable(exec, _mesa_Enable); SET_Finish(exec, _mesa_Finish); SET_Flush(exec, _mesa_Flush); @@ -140,31 +165,20 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_GetError(exec, _mesa_GetError); SET_GetFloatv(exec, _mesa_GetFloatv); SET_GetString(exec, _mesa_GetString); - SET_InitNames(exec, _mesa_InitNames); SET_LineStipple(exec, _mesa_LineStipple); SET_LineWidth(exec, _mesa_LineWidth); SET_LoadIdentity(exec, _mesa_LoadIdentity); SET_LoadMatrixf(exec, _mesa_LoadMatrixf); - SET_LoadName(exec, _mesa_LoadName); SET_LogicOp(exec, _mesa_LogicOp); SET_MatrixMode(exec, _mesa_MatrixMode); SET_MultMatrixf(exec, _mesa_MultMatrixf); SET_Ortho(exec, _mesa_Ortho); SET_PixelStorei(exec, _mesa_PixelStorei); SET_PopMatrix(exec, _mesa_PopMatrix); - SET_PopName(exec, _mesa_PopName); SET_PushMatrix(exec, _mesa_PushMatrix); - SET_PushName(exec, _mesa_PushName); - SET_RasterPos2f(exec, _mesa_RasterPos2f); - SET_RasterPos2fv(exec, _mesa_RasterPos2fv); - SET_RasterPos2i(exec, _mesa_RasterPos2i); - SET_RasterPos2iv(exec, _mesa_RasterPos2iv); - SET_ReadBuffer(exec, _mesa_ReadBuffer); - SET_RenderMode(exec, _mesa_RenderMode); SET_Rotatef(exec, _mesa_Rotatef); SET_Scalef(exec, _mesa_Scalef); SET_Scissor(exec, _mesa_Scissor); - SET_SelectBuffer(exec, _mesa_SelectBuffer); SET_ShadeModel(exec, _mesa_ShadeModel); SET_StencilFunc(exec, _mesa_StencilFunc); SET_StencilMask(exec, _mesa_StencilMask); @@ -175,46 +189,57 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_TexParameteri(exec, _mesa_TexParameteri); SET_Translatef(exec, _mesa_Translatef); SET_Viewport(exec, _mesa_Viewport); -#if _HAVE_FULL_GL +#if FEATURE_accum SET_Accum(exec, _mesa_Accum); - SET_Bitmap(exec, _mesa_Bitmap); + SET_ClearAccum(exec, _mesa_ClearAccum); +#endif +#if FEATURE_dlist SET_CallList(exec, _mesa_CallList); SET_CallLists(exec, _mesa_CallLists); - SET_ClearAccum(exec, _mesa_ClearAccum); + SET_DeleteLists(exec, _mesa_DeleteLists); + SET_EndList(exec, _mesa_EndList); + SET_GenLists(exec, _mesa_GenLists); + SET_IsList(exec, _mesa_IsList); + SET_ListBase(exec, _mesa_ListBase); + SET_NewList(exec, _mesa_NewList); +#endif SET_ClearDepth(exec, _mesa_ClearDepth); SET_ClearIndex(exec, _mesa_ClearIndex); SET_ClipPlane(exec, _mesa_ClipPlane); SET_ColorMaterial(exec, _mesa_ColorMaterial); - SET_CopyPixels(exec, _mesa_CopyPixels); SET_CullParameterfvEXT(exec, _mesa_CullParameterfvEXT); SET_CullParameterdvEXT(exec, _mesa_CullParameterdvEXT); - SET_DeleteLists(exec, _mesa_DeleteLists); SET_DepthFunc(exec, _mesa_DepthFunc); SET_DepthMask(exec, _mesa_DepthMask); SET_DepthRange(exec, _mesa_DepthRange); +#if FEATURE_drawpix + SET_Bitmap(exec, _mesa_Bitmap); + SET_CopyPixels(exec, _mesa_CopyPixels); SET_DrawPixels(exec, _mesa_DrawPixels); - SET_EndList(exec, _mesa_EndList); +#endif +#if FEATURE_feadback + SET_InitNames(exec, _mesa_InitNames); SET_FeedbackBuffer(exec, _mesa_FeedbackBuffer); + SET_LoadName(exec, _mesa_LoadName); + SET_PassThrough(exec, _mesa_PassThrough); + SET_PopName(exec, _mesa_PopName); + SET_PushName(exec, _mesa_PushName); + SET_SelectBuffer(exec, _mesa_SelectBuffer); + SET_RenderMode(exec, _mesa_RenderMode); +#endif SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT); SET_Fogf(exec, _mesa_Fogf); SET_Fogfv(exec, _mesa_Fogfv); SET_Fogi(exec, _mesa_Fogi); SET_Fogiv(exec, _mesa_Fogiv); - SET_GenLists(exec, _mesa_GenLists); SET_GetClipPlane(exec, _mesa_GetClipPlane); SET_GetBooleanv(exec, _mesa_GetBooleanv); SET_GetDoublev(exec, _mesa_GetDoublev); SET_GetIntegerv(exec, _mesa_GetIntegerv); SET_GetLightfv(exec, _mesa_GetLightfv); SET_GetLightiv(exec, _mesa_GetLightiv); - SET_GetMapdv(exec, _mesa_GetMapdv); - SET_GetMapfv(exec, _mesa_GetMapfv); - SET_GetMapiv(exec, _mesa_GetMapiv); SET_GetMaterialfv(exec, _mesa_GetMaterialfv); SET_GetMaterialiv(exec, _mesa_GetMaterialiv); - SET_GetPixelMapfv(exec, _mesa_GetPixelMapfv); - SET_GetPixelMapuiv(exec, _mesa_GetPixelMapuiv); - SET_GetPixelMapusv(exec, _mesa_GetPixelMapusv); SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple); SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv); SET_GetTexEnviv(exec, _mesa_GetTexEnviv); @@ -222,14 +247,10 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv); SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv); SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv); - SET_GetTexGendv(exec, _mesa_GetTexGendv); - SET_GetTexGenfv(exec, _mesa_GetTexGenfv); - SET_GetTexGeniv(exec, _mesa_GetTexGeniv); SET_GetTexImage(exec, _mesa_GetTexImage); SET_Hint(exec, _mesa_Hint); SET_IndexMask(exec, _mesa_IndexMask); SET_IsEnabled(exec, _mesa_IsEnabled); - SET_IsList(exec, _mesa_IsList); SET_LightModelf(exec, _mesa_LightModelf); SET_LightModelfv(exec, _mesa_LightModelfv); SET_LightModeli(exec, _mesa_LightModeli); @@ -238,8 +259,11 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_Lightfv(exec, _mesa_Lightfv); SET_Lighti(exec, _mesa_Lighti); SET_Lightiv(exec, _mesa_Lightiv); - SET_ListBase(exec, _mesa_ListBase); SET_LoadMatrixd(exec, _mesa_LoadMatrixd); +#if FEATURE_evaluators + SET_GetMapdv(exec, _mesa_GetMapdv); + SET_GetMapfv(exec, _mesa_GetMapfv); + SET_GetMapiv(exec, _mesa_GetMapiv); SET_Map1d(exec, _mesa_Map1d); SET_Map1f(exec, _mesa_Map1f); SET_Map2d(exec, _mesa_Map2d); @@ -248,22 +272,35 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_MapGrid1f(exec, _mesa_MapGrid1f); SET_MapGrid2d(exec, _mesa_MapGrid2d); SET_MapGrid2f(exec, _mesa_MapGrid2f); +#endif SET_MultMatrixd(exec, _mesa_MultMatrixd); - SET_NewList(exec, _mesa_NewList); - SET_PassThrough(exec, _mesa_PassThrough); +#if FEATURE_pixel_transfer + SET_GetPixelMapfv(exec, _mesa_GetPixelMapfv); + SET_GetPixelMapuiv(exec, _mesa_GetPixelMapuiv); + SET_GetPixelMapusv(exec, _mesa_GetPixelMapusv); SET_PixelMapfv(exec, _mesa_PixelMapfv); SET_PixelMapuiv(exec, _mesa_PixelMapuiv); SET_PixelMapusv(exec, _mesa_PixelMapusv); - SET_PixelStoref(exec, _mesa_PixelStoref); SET_PixelTransferf(exec, _mesa_PixelTransferf); SET_PixelTransferi(exec, _mesa_PixelTransferi); SET_PixelZoom(exec, _mesa_PixelZoom); +#endif + SET_PixelStoref(exec, _mesa_PixelStoref); SET_PointSize(exec, _mesa_PointSize); SET_PolygonMode(exec, _mesa_PolygonMode); SET_PolygonOffset(exec, _mesa_PolygonOffset); SET_PolygonStipple(exec, _mesa_PolygonStipple); +#if FEATURE_attrib_stack SET_PopAttrib(exec, _mesa_PopAttrib); SET_PushAttrib(exec, _mesa_PushAttrib); + SET_PopClientAttrib(exec, _mesa_PopClientAttrib); + SET_PushClientAttrib(exec, _mesa_PushClientAttrib); +#endif +#if FEATURE_drawpix + SET_RasterPos2f(exec, _mesa_RasterPos2f); + SET_RasterPos2fv(exec, _mesa_RasterPos2fv); + SET_RasterPos2i(exec, _mesa_RasterPos2i); + SET_RasterPos2iv(exec, _mesa_RasterPos2iv); SET_RasterPos2d(exec, _mesa_RasterPos2d); SET_RasterPos2dv(exec, _mesa_RasterPos2dv); SET_RasterPos2s(exec, _mesa_RasterPos2s); @@ -284,24 +321,31 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_RasterPos4iv(exec, _mesa_RasterPos4iv); SET_RasterPos4s(exec, _mesa_RasterPos4s); SET_RasterPos4sv(exec, _mesa_RasterPos4sv); +#endif SET_ReadPixels(exec, _mesa_ReadPixels); SET_Rotated(exec, _mesa_Rotated); SET_Scaled(exec, _mesa_Scaled); SET_SecondaryColorPointerEXT(exec, _mesa_SecondaryColorPointerEXT); SET_TexEnvf(exec, _mesa_TexEnvf); SET_TexEnviv(exec, _mesa_TexEnviv); + +#if FEATURE_texgen + SET_GetTexGendv(exec, _mesa_GetTexGendv); + SET_GetTexGenfv(exec, _mesa_GetTexGenfv); + SET_GetTexGeniv(exec, _mesa_GetTexGeniv); SET_TexGend(exec, _mesa_TexGend); SET_TexGendv(exec, _mesa_TexGendv); SET_TexGenf(exec, _mesa_TexGenf); SET_TexGenfv(exec, _mesa_TexGenfv); SET_TexGeni(exec, _mesa_TexGeni); SET_TexGeniv(exec, _mesa_TexGeniv); +#endif + SET_TexImage1D(exec, _mesa_TexImage1D); SET_TexParameterf(exec, _mesa_TexParameterf); SET_TexParameterfv(exec, _mesa_TexParameterfv); SET_TexParameteriv(exec, _mesa_TexParameteriv); SET_Translated(exec, _mesa_Translated); -#endif /* 1.1 */ SET_BindTexture(exec, _mesa_BindTexture); @@ -322,9 +366,7 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_InterleavedArrays(exec, _mesa_InterleavedArrays); SET_IsTexture(exec, _mesa_IsTexture); SET_NormalPointer(exec, _mesa_NormalPointer); - SET_PopClientAttrib(exec, _mesa_PopClientAttrib); SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures); - SET_PushClientAttrib(exec, _mesa_PushClientAttrib); SET_TexCoordPointer(exec, _mesa_TexCoordPointer); SET_TexSubImage1D(exec, _mesa_TexSubImage1D); SET_TexSubImage2D(exec, _mesa_TexSubImage2D); @@ -339,30 +381,37 @@ _mesa_init_exec_table(struct _glapi_table *exec) #endif /* OpenGL 1.2 GL_ARB_imaging */ -#if _HAVE_FULL_GL SET_BlendColor(exec, _mesa_BlendColor); SET_BlendEquation(exec, _mesa_BlendEquation); SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT); + +#if FEATURE_colortable SET_ColorSubTable(exec, _mesa_ColorSubTable); SET_ColorTable(exec, _mesa_ColorTable); SET_ColorTableParameterfv(exec, _mesa_ColorTableParameterfv); SET_ColorTableParameteriv(exec, _mesa_ColorTableParameteriv); + SET_CopyColorSubTable(exec, _mesa_CopyColorSubTable); + SET_CopyColorTable(exec, _mesa_CopyColorTable); + SET_GetColorTable(exec, _mesa_GetColorTable); + SET_GetColorTableParameterfv(exec, _mesa_GetColorTableParameterfv); + SET_GetColorTableParameteriv(exec, _mesa_GetColorTableParameteriv); +#endif + +#if FEATURE_convolution SET_ConvolutionFilter1D(exec, _mesa_ConvolutionFilter1D); SET_ConvolutionFilter2D(exec, _mesa_ConvolutionFilter2D); SET_ConvolutionParameterf(exec, _mesa_ConvolutionParameterf); SET_ConvolutionParameterfv(exec, _mesa_ConvolutionParameterfv); SET_ConvolutionParameteri(exec, _mesa_ConvolutionParameteri); SET_ConvolutionParameteriv(exec, _mesa_ConvolutionParameteriv); - SET_CopyColorSubTable(exec, _mesa_CopyColorSubTable); - SET_CopyColorTable(exec, _mesa_CopyColorTable); SET_CopyConvolutionFilter1D(exec, _mesa_CopyConvolutionFilter1D); SET_CopyConvolutionFilter2D(exec, _mesa_CopyConvolutionFilter2D); - SET_GetColorTable(exec, _mesa_GetColorTable); - SET_GetColorTableParameterfv(exec, _mesa_GetColorTableParameterfv); - SET_GetColorTableParameteriv(exec, _mesa_GetColorTableParameteriv); SET_GetConvolutionFilter(exec, _mesa_GetConvolutionFilter); SET_GetConvolutionParameterfv(exec, _mesa_GetConvolutionParameterfv); SET_GetConvolutionParameteriv(exec, _mesa_GetConvolutionParameteriv); + SET_SeparableFilter2D(exec, _mesa_SeparableFilter2D); +#endif +#if FEATURE_histogram SET_GetHistogram(exec, _mesa_GetHistogram); SET_GetHistogramParameterfv(exec, _mesa_GetHistogramParameterfv); SET_GetHistogramParameteriv(exec, _mesa_GetHistogramParameteriv); @@ -374,7 +423,6 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_Minmax(exec, _mesa_Minmax); SET_ResetHistogram(exec, _mesa_ResetHistogram); SET_ResetMinmax(exec, _mesa_ResetMinmax); - SET_SeparableFilter2D(exec, _mesa_SeparableFilter2D); #endif /* OpenGL 2.0 */ @@ -488,7 +536,7 @@ _mesa_init_exec_table(struct _glapi_table *exec) #endif /* 197. GL_MESA_window_pos */ -#if _HAVE_FULL_GL +#if FEATURE_drawpix SET_WindowPos2dMESA(exec, _mesa_WindowPos2dMESA); SET_WindowPos2dvMESA(exec, _mesa_WindowPos2dvMESA); SET_WindowPos2fMESA(exec, _mesa_WindowPos2fMESA); @@ -715,8 +763,10 @@ _mesa_init_exec_table(struct _glapi_table *exec) #endif /* ARB 37. GL_ARB_draw_buffers */ +#if FEATURE_draw_read_buffer SET_DrawBuffersARB(exec, _mesa_DrawBuffersARB); - +#endif + #if FEATURE_ARB_shader_objects SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB); SET_GetHandleARB(exec, _mesa_GetHandleARB); diff --git a/src/mesa/main/api_exec.h b/src/mesa/main/api_exec.h index 7f15ea9d00..4bd715053a 100644 --- a/src/mesa/main/api_exec.h +++ b/src/mesa/main/api_exec.h @@ -27,7 +27,10 @@ #define API_EXEC_H -void +struct _glapi_table; + + +extern void _mesa_init_exec_table(struct _glapi_table *exec); diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index 3df64362ea..a1cc3a2a4b 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -30,7 +30,9 @@ #include "context.h" #include "light.h" #include "macros.h" +#if FEATURE_dlist #include "dlist.h" +#endif #include "glapi/dispatch.h" @@ -621,6 +623,8 @@ static void GLAPIENTRY _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLf (void) a; (void) b; (void) c; (void) d; } + +#if FEATURE_evaluators /* Similarly, these have no effect outside begin/end: */ static void GLAPIENTRY _mesa_noop_EvalCoord1f( GLfloat a ) @@ -652,6 +656,7 @@ static void GLAPIENTRY _mesa_noop_EvalPoint2( GLint a, GLint b ) { (void) a; (void) b; } +#endif /* FEATURE_evaluators */ /* Begin -- call into driver, should result in the vtxfmt being @@ -904,20 +909,24 @@ _mesa_noop_vtxfmt_init( GLvertexformat *vfmt ) { vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */ vfmt->Begin = _mesa_noop_Begin; +#if FEATURE_dlist vfmt->CallList = _mesa_CallList; vfmt->CallLists = _mesa_CallLists; +#endif vfmt->Color3f = _mesa_noop_Color3f; vfmt->Color3fv = _mesa_noop_Color3fv; vfmt->Color4f = _mesa_noop_Color4f; vfmt->Color4fv = _mesa_noop_Color4fv; vfmt->EdgeFlag = _mesa_noop_EdgeFlag; vfmt->End = _mesa_noop_End; +#if FEATURE_evaluators vfmt->EvalCoord1f = _mesa_noop_EvalCoord1f; vfmt->EvalCoord1fv = _mesa_noop_EvalCoord1fv; vfmt->EvalCoord2f = _mesa_noop_EvalCoord2f; vfmt->EvalCoord2fv = _mesa_noop_EvalCoord2fv; vfmt->EvalPoint1 = _mesa_noop_EvalPoint1; vfmt->EvalPoint2 = _mesa_noop_EvalPoint2; +#endif vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT; vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT; vfmt->Indexf = _mesa_noop_Indexf; diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 232e698f50..9ff0b708dd 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -31,6 +31,10 @@ #ifndef MESA_CONFIG_H_INCLUDED #define MESA_CONFIG_H_INCLUDED + +#include "main/mfeatures.h" + + /** * \name OpenGL implementation limits */ @@ -283,40 +287,6 @@ #define ACOMP 3 -/* - * Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1. - */ -#ifndef _HAVE_FULL_GL -#define _HAVE_FULL_GL 1 -#endif - -#define FEATURE_userclip _HAVE_FULL_GL -#define FEATURE_texgen _HAVE_FULL_GL -#define FEATURE_windowpos _HAVE_FULL_GL -#define FEATURE_ARB_occlusion_query _HAVE_FULL_GL -#define FEATURE_ARB_fragment_program _HAVE_FULL_GL -#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL -#define FEATURE_ARB_vertex_program _HAVE_FULL_GL - -#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL -#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL -#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) -#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects -#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects - -#define FEATURE_EXT_framebuffer_blit _HAVE_FULL_GL -#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL -#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL -#define FEATURE_EXT_texture_sRGB _HAVE_FULL_GL -#define FEATURE_EXT_timer_query _HAVE_FULL_GL -#define FEATURE_ATI_fragment_shader _HAVE_FULL_GL -#define FEATURE_MESA_program_debug _HAVE_FULL_GL -#define FEATURE_NV_fence _HAVE_FULL_GL -#define FEATURE_NV_fragment_program _HAVE_FULL_GL -#define FEATURE_NV_vertex_program _HAVE_FULL_GL -/*@}*/ - - /** * Maximum number of temporary vertices required for clipping. * diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 1b357ae6c2..d975814592 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -78,27 +78,41 @@ #include "glheader.h" #include "imports.h" +#if FEATURE_accum #include "accum.h" +#endif #include "api_exec.h" #include "arrayobj.h" +#if FEATURE_attrib_stack #include "attrib.h" +#endif #include "blend.h" #include "buffers.h" #include "bufferobj.h" +#if FEATURE_colortable #include "colortab.h" +#endif #include "context.h" #include "debug.h" #include "depth.h" +#if FEATURE_dlist #include "dlist.h" +#endif +#if FEATURE_evaluators #include "eval.h" +#endif #include "enums.h" #include "extensions.h" #include "fbobject.h" +#if FEATURE_feedback #include "feedback.h" +#endif #include "fog.h" #include "framebuffer.h" #include "get.h" +#if FEATURE_histogram #include "histogram.h" +#endif #include "hint.h" #include "hash.h" #include "light.h" @@ -106,12 +120,16 @@ #include "macros.h" #include "matrix.h" #include "multisample.h" +#if FEATURE_pixel_transfer #include "pixel.h" +#endif #include "pixelstore.h" #include "points.h" #include "polygon.h" #include "queryobj.h" +#if FEATURE_drawpix #include "rastpos.h" +#endif #include "scissor.h" #include "simple_list.h" #include "state.h" @@ -573,9 +591,11 @@ alloc_shared_state( GLcontext *ctx ) static void delete_displaylist_cb(GLuint id, void *data, void *userData) { +#if FEATURE_dlist struct mesa_display_list *list = (struct mesa_display_list *) data; GLcontext *ctx = (GLcontext *) userData; _mesa_delete_list(ctx, list); +#endif } /** @@ -954,31 +974,49 @@ init_attrib_groups(GLcontext *ctx) _mesa_init_extensions( ctx ); /* Attribute Groups */ +#if FEATURE_accum _mesa_init_accum( ctx ); +#endif +#if FEATURE_attrib_stack _mesa_init_attrib( ctx ); +#endif _mesa_init_buffer_objects( ctx ); _mesa_init_color( ctx ); +#if FEATURE_colortable _mesa_init_colortables( ctx ); +#endif _mesa_init_current( ctx ); _mesa_init_depth( ctx ); _mesa_init_debug( ctx ); +#if FEATURE_dlist _mesa_init_display_list( ctx ); +#endif +#if FEATURE_evaluators _mesa_init_eval( ctx ); +#endif +#if FEATURE_feedback _mesa_init_feedback( ctx ); +#endif _mesa_init_fog( ctx ); +#if FEATURE_histogram _mesa_init_histogram( ctx ); +#endif _mesa_init_hint( ctx ); _mesa_init_line( ctx ); _mesa_init_lighting( ctx ); _mesa_init_matrix( ctx ); _mesa_init_multisample( ctx ); +#if FEATURE_pixel_transfer _mesa_init_pixel( ctx ); +#endif _mesa_init_pixelstore( ctx ); _mesa_init_point( ctx ); _mesa_init_polygon( ctx ); _mesa_init_program( ctx ); _mesa_init_query( ctx ); +#if FEATURE_drawpix _mesa_init_rastpos( ctx ); +#endif _mesa_init_scissor( ctx ); _mesa_init_shader_state( ctx ); _mesa_init_stencil( ctx ); @@ -989,8 +1027,12 @@ init_attrib_groups(GLcontext *ctx) if (!_mesa_init_texture( ctx )) return GL_FALSE; +#if FEATURE_texture_s3tc _mesa_init_texture_s3tc( ctx ); +#endif +#if FEATURE_texture_fxt1 _mesa_init_texture_fxt1( ctx ); +#endif /* Miscellaneous */ ctx->NewState = _NEW_ALL; @@ -1123,14 +1165,14 @@ _mesa_initialize_context(GLcontext *ctx, } _mesa_init_exec_table(ctx->Exec); ctx->CurrentDispatch = ctx->Exec; -#if _HAVE_FULL_GL +#if FEATURE_dlist _mesa_init_dlist_table(ctx->Save); _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); +#endif /* Neutral tnl module stuff */ _mesa_init_exec_vtxfmt( ctx ); ctx->TnlModule.Current = NULL; ctx->TnlModule.SwapCount = 0; -#endif ctx->FragmentProgram._MaintainTexEnvProgram = (_mesa_getenv("MESA_TEX_PROG") != NULL); @@ -1220,11 +1262,15 @@ _mesa_free_context_data( GLcontext *ctx ) _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL); _mesa_free_lighting_data( ctx ); +#if FEATURE_evaluators _mesa_free_eval_data( ctx ); +#endif _mesa_free_texture_data( ctx ); _mesa_free_matrix_data( ctx ); _mesa_free_viewport_data( ctx ); +#if FEATURE_colortable _mesa_free_colortables_data( ctx ); +#endif _mesa_free_program_data(ctx); _mesa_free_shader_state(ctx); _mesa_free_query_data(ctx); diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h new file mode 100644 index 0000000000..228de76af1 --- /dev/null +++ b/src/mesa/main/mfeatures.h @@ -0,0 +1,77 @@ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file mfeatures.h + * Flags to enable/disable specific parts of the API. + */ + +#ifndef FEATURES_H +#define FEATURES_H + + +#ifndef _HAVE_FULL_GL +#define _HAVE_FULL_GL 1 +#endif + +#define FEATURE_accum _HAVE_FULL_GL +#define FEATURE_attrib_stacks _HAVE_FULL_GL +#define FEATURE_colortable _HAVE_FULL_GL +#define FEATURE_convolution _HAVE_FULL_GL +#define FEATURE_dlist _HAVE_FULL_GL +#define FEATURE_draw_read_buffer _HAVE_FULL_GL +#define FEATURE_drawpix _HAVE_FULL_GL +#define FEATURE_evaluators _HAVE_FULL_GL +#define FEATURE_feedback _HAVE_FULL_GL +#define FEATURE_histogram _HAVE_FULL_GL +#define FEATURE_pixeltransfer _HAVE_FULL_GL +#define FEATURE_texgen _HAVE_FULL_GL +#define FEATURE_texture_fxt1 _HAVE_FULL_GL +#define FEATURE_texture_s3tc _HAVE_FULL_GL +#define FEATURE_userclip _HAVE_FULL_GL + +#define FEATURE_ARB_occlusion_query _HAVE_FULL_GL +#define FEATURE_ARB_fragment_program _HAVE_FULL_GL +#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL +#define FEATURE_ARB_vertex_program _HAVE_FULL_GL +#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL +#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL +#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) +#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects +#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects + +#define FEATURE_EXT_framebuffer_blit _HAVE_FULL_GL +#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL +#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL +#define FEATURE_EXT_texture_sRGB _HAVE_FULL_GL +#define FEATURE_EXT_timer_query _HAVE_FULL_GL +#define FEATURE_ATI_fragment_shader _HAVE_FULL_GL +#define FEATURE_MESA_program_debug _HAVE_FULL_GL +#define FEATURE_NV_fence _HAVE_FULL_GL +#define FEATURE_NV_fragment_program _HAVE_FULL_GL +#define FEATURE_NV_vertex_program _HAVE_FULL_GL + + +#endif /* FEATURES_H */ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 89920f8443..4d1fdbf47c 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -40,7 +40,9 @@ #include "framebuffer.h" #include "light.h" #include "matrix.h" +#if FEATURE_pixel_transfer #include "pixel.h" +#endif #include "shader/program.h" #include "state.h" #include "stencil.h" @@ -412,8 +414,10 @@ _mesa_update_state_locked( GLcontext *ctx ) if (new_state & _NEW_STENCIL) _mesa_update_stencil( ctx ); +#if FEATURE_pixel_transfer if (new_state & _IMAGE_NEW_TRANSFER_STATE) _mesa_update_pixel( ctx, new_state ); +#endif if (new_state & (_NEW_ARRAY | _NEW_PROGRAM)) update_arrays( ctx ); diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 17859a9fec..a35195a695 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -1449,21 +1449,27 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, case GL_COMPRESSED_INTENSITY_ARB: return &_mesa_texformat_intensity; case GL_COMPRESSED_RGB_ARB: +#if FEATURE_texture_fxt1 if (ctx->Extensions.TDFX_texture_compression_FXT1) return &_mesa_texformat_rgb_fxt1; - else if (ctx->Extensions.EXT_texture_compression_s3tc || - ctx->Extensions.S3_s3tc) +#endif +#if FEATURE_texture_s3tc + if (ctx->Extensions.EXT_texture_compression_s3tc || + ctx->Extensions.S3_s3tc) return &_mesa_texformat_rgb_dxt1; - else - return &_mesa_texformat_rgb; +#endif + return &_mesa_texformat_rgb; case GL_COMPRESSED_RGBA_ARB: +#if FEATURE_texture_fxt1 if (ctx->Extensions.TDFX_texture_compression_FXT1) return &_mesa_texformat_rgba_fxt1; - else if (ctx->Extensions.EXT_texture_compression_s3tc || - ctx->Extensions.S3_s3tc) +#endif +#if FEATURE_texture_s3tc + if (ctx->Extensions.EXT_texture_compression_s3tc || + ctx->Extensions.S3_s3tc) return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */ - else - return &_mesa_texformat_rgba; +#endif + return &_mesa_texformat_rgba; default: ; /* fallthrough */ } @@ -1478,6 +1484,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, } } +#if FEATURE_texture_fxt1 if (ctx->Extensions.TDFX_texture_compression_FXT1) { switch (internalFormat) { case GL_COMPRESSED_RGB_FXT1_3DFX: @@ -1488,7 +1495,9 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, ; /* fallthrough */ } } +#endif +#if FEATURE_texture_s3tc if (ctx->Extensions.EXT_texture_compression_s3tc) { switch (internalFormat) { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: @@ -1516,6 +1525,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, ; /* fallthrough */ } } +#endif if (ctx->Extensions.ARB_texture_float) { switch (internalFormat) { diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 384e145520..eed1937517 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -32,7 +32,9 @@ #include "glheader.h" #include "bufferobj.h" #include "context.h" +#if FEATURE_convolve #include "convolve.h" +#endif #include "fbobject.h" #include "framebuffer.h" #include "image.h" @@ -2429,9 +2431,11 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); +#if FEATURE_convolve if (is_color_format(internalFormat)) { _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); } +#endif if (target == GL_TEXTURE_1D) { /* non-proxy target */ @@ -2524,10 +2528,12 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); +#if FEATURE_convolve if (is_color_format(internalFormat)) { _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight); } +#endif if (target == GL_TEXTURE_2D || (ctx->Extensions.ARB_texture_cube_map && @@ -2746,10 +2752,12 @@ _mesa_TexSubImage1D( GLenum target, GLint level, if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) _mesa_update_state(ctx); +#if FEATURE_convolve /* XXX should test internal format */ if (is_color_format(format)) { _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); } +#endif if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0, postConvWidth, 1, 1, format, type)) { @@ -2804,11 +2812,13 @@ _mesa_TexSubImage2D( GLenum target, GLint level, if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) _mesa_update_state(ctx); +#if FEATURE_convolve /* XXX should test internal format */ if (is_color_format(format)) { _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight); } +#endif if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0, postConvWidth, postConvHeight, 1, format, type)) { @@ -2918,9 +2928,11 @@ _mesa_CopyTexImage1D( GLenum target, GLint level, if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) _mesa_update_state(ctx); +#if FEATURE_convolve if (is_color_format(internalFormat)) { _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); } +#endif if (copytexture_error_check(ctx, 1, target, level, internalFormat, postConvWidth, 1, border)) @@ -2981,11 +2993,12 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) _mesa_update_state(ctx); +#if FEATURE_convolve if (is_color_format(internalFormat)) { _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight); } - +#endif if (copytexture_error_check(ctx, 2, target, level, internalFormat, postConvWidth, postConvHeight, border)) return; @@ -3047,8 +3060,10 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) _mesa_update_state(ctx); +#if FEATURE_convolve /* XXX should test internal format */ _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); +#endif if (copytexsubimage_error_check(ctx, 1, target, level, xoffset, 0, 0, postConvWidth, 1)) @@ -3100,8 +3115,10 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) _mesa_update_state(ctx); +#if FEATURE_convolve /* XXX should test internal format */ _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight); +#endif if (copytexsubimage_error_check(ctx, 2, target, level, xoffset, yoffset, 0, postConvWidth, postConvHeight)) @@ -3152,8 +3169,10 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) _mesa_update_state(ctx); +#if FEATURE_convolve /* XXX should test internal format */ _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight); +#endif if (copytexsubimage_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset, postConvWidth, postConvHeight)) diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index df64002f99..606e62d7a0 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -29,7 +29,9 @@ #include "glheader.h" +#if FEATURE_colortable #include "colortab.h" +#endif #include "context.h" #include "enums.h" #include "fbobject.h" @@ -153,7 +155,9 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj ) (void) ctx; +#if FEATURE_colortable _mesa_free_colortable_data(&texObj->Palette); +#endif /* free the texture images */ for (face = 0; face < 6; face++) { diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 84acfbd92c..2a83d6df4a 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -30,7 +30,9 @@ #include "glheader.h" #include "colormac.h" +#if FEATURE_colortable #include "colortab.h" +#endif #include "context.h" #include "enums.h" #include "macros.h" @@ -3213,7 +3215,9 @@ _mesa_init_texture(GLcontext *ctx) for (i=0; iTexture.SharedPalette = GL_FALSE; +#if FEATURE_colortable _mesa_init_colortable(&ctx->Texture.Palette); +#endif /* Allocate proxy textures */ if (!alloc_proxy_textures( ctx )) @@ -3229,8 +3233,6 @@ _mesa_init_texture(GLcontext *ctx) void _mesa_free_texture_data(GLcontext *ctx) { - GLuint i; - /* Free proxy texture objects */ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D ); (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2D ); @@ -3240,6 +3242,11 @@ _mesa_free_texture_data(GLcontext *ctx) (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1DArray ); (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2DArray ); - for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) - _mesa_free_colortable_data( &ctx->Texture.Unit[i].ColorTable ); +#if FEATURE_colortable + { + GLuint i; + for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) + _mesa_free_colortable_data( &ctx->Texture.Unit[i].ColorTable ); + } +#endif } diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index a6a18910fc..5ac6116950 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -55,7 +55,9 @@ #include "bufferobj.h" #include "colormac.h" #include "context.h" +#if FEATURE_convolve #include "convolve.h" +#endif #include "image.h" #include "macros.h" #include "mipmap.h" @@ -269,6 +271,16 @@ compute_component_mapping(GLenum inFormat, GLenum outFormat, } +#if !FEATURE_convolve +static void +_mesa_adjust_image_for_convolution(GLcontext *ctx, GLuint dims, + GLsizei *srcWidth, GLsizei *srcHeight) +{ + /* no-op */ +} +#endif + + /** * Make a temporary (color) texture image with GLfloat components. * Apply all needed pixel unpacking and pixel transfer operations. @@ -368,6 +380,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, dst += srcWidth * 4; } +#if FEATURE_convolve /* do convolution */ { GLfloat *src = tempImage + img * (srcWidth * srcHeight * 4); @@ -389,7 +402,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, } } } - +#endif /* do post-convolution transfer and pack into tempImage */ { const GLint logComponents @@ -546,6 +559,7 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, textureBaseFormat == GL_ALPHA || textureBaseFormat == GL_INTENSITY); +#if FEATURE_convolve if ((dims == 1 && ctx->Pixel.Convolution1DEnabled) || (dims >= 2 && ctx->Pixel.Convolution2DEnabled) || (dims >= 2 && ctx->Pixel.Separable2DEnabled)) { @@ -567,6 +581,7 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, transferOps = 0; freeSrcImage = GL_TRUE; } +#endif /* unpack and transfer the source image */ tempImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index 235cee2429..dc7c534251 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -225,9 +225,10 @@ GLboolean _vbo_CreateContext( GLcontext *ctx ) * vtxfmt mechanism can be removed now. */ vbo_exec_init( ctx ); +#if FEATURE_dlist vbo_save_init( ctx ); +#endif - return GL_TRUE; } @@ -246,7 +247,9 @@ void _vbo_DestroyContext( GLcontext *ctx ) } vbo_exec_destroy(ctx); +#if FEATURE_dlist vbo_save_destroy(ctx); +#endif FREE(vbo_context(ctx)); ctx->swtnl_im = NULL; } diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h index 013f81bdd5..bf405eb693 100644 --- a/src/mesa/vbo/vbo_context.h +++ b/src/mesa/vbo/vbo_context.h @@ -53,8 +53,10 @@ #include "vbo.h" #include "vbo_attrib.h" -#include "vbo_save.h" #include "vbo_exec.h" +#if FEATURE_dlist +#include "vbo_save.h" +#endif struct vbo_context { @@ -74,7 +76,9 @@ struct vbo_context { struct vbo_exec_context exec; +#if FEATURE_dlist struct vbo_save_context save; +#endif /* Callback into the driver. This must always succeed, the driver * is responsible for initiating any fallback actions required: diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index 1efa74945d..635f239acc 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -32,7 +32,6 @@ #include "main/context.h" #include "main/macros.h" #include "main/mtypes.h" -#include "main/dlist.h" #include "main/vtxfmt.h" #include "vbo_context.h" diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 98580170e3..5dd774d839 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -34,7 +34,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/context.h" #include "main/macros.h" #include "main/vtxfmt.h" +#if FEATURE_dlist #include "main/dlist.h" +#endif #include "main/state.h" #include "main/light.h" #include "main/api_arrayelt.h" @@ -569,8 +571,10 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */ vfmt->Begin = vbo_exec_Begin; +#if FEATURE_dlist vfmt->CallList = _mesa_CallList; vfmt->CallLists = _mesa_CallLists; +#endif vfmt->End = vbo_exec_End; vfmt->EvalCoord1f = vbo_exec_EvalCoord1f; vfmt->EvalCoord1fv = vbo_exec_EvalCoord1fv; -- cgit v1.2.3 From 8a369b909a6648ae7a5a0c2dcb972a2f96f99a80 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 17 Jun 2008 11:31:45 -0600 Subject: mesa: s/GL_POLYGON+1/PRIM_OUTSIDE_BEGIN_END/ --- src/mesa/vbo/vbo_exec_api.c | 10 +++++----- src/mesa/vbo/vbo_exec_draw.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 5dd774d839..b263885388 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -67,7 +67,7 @@ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) GLuint last_begin = exec->vtx.prim[exec->vtx.prim_count-1].begin; GLuint last_count; - if (exec->ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) { + if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { GLint i = exec->vtx.prim_count - 1; assert(i >= 0); exec->vtx.prim[i].count = (exec->vtx.vert_count - @@ -89,7 +89,7 @@ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) */ assert(exec->vtx.prim_count == 0); - if (exec->ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) { + if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { exec->vtx.prim[0].mode = exec->ctx->Driver.CurrentExecPrimitive; exec->vtx.prim[0].start = 0; exec->vtx.prim[0].count = 0; @@ -503,7 +503,7 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) { GET_CURRENT_CONTEXT( ctx ); - if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) { + if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; int i; @@ -547,7 +547,7 @@ static void GLAPIENTRY vbo_exec_End( void ) { GET_CURRENT_CONTEXT( ctx ); - if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) { + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; int idx = exec->vtx.vert_count; int i = exec->vtx.prim_count - 1; @@ -555,7 +555,7 @@ static void GLAPIENTRY vbo_exec_End( void ) exec->vtx.prim[i].end = 1; exec->vtx.prim[i].count = idx - exec->vtx.prim[i].start; - ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1; + ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; if (exec->vtx.prim_count == VBO_MAX_PRIM) vbo_exec_vtx_flush( exec ); diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 6bb6849a6a..3609a7452a 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -128,7 +128,7 @@ static GLuint vbo_copy_vertices( struct vbo_exec_context *exec ) for (i = 0 ; i < ovf ; i++) _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) ); return i; - case GL_POLYGON+1: + case PRIM_OUTSIDE_BEGIN_END: return 0; default: assert(0); -- cgit v1.2.3 From 71f67dde34546f40c7617948f8fa945288e55e17 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 20 Jun 2008 10:48:14 -0600 Subject: mesa: _vbo_Color4f, _vbo_Normal3f, _vbo_MultiTexCoord4f functions --- src/mesa/vbo/vbo.h | 10 ++++++++++ src/mesa/vbo/vbo_exec_api.c | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 79d33d09c1..1a737babd3 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -120,4 +120,14 @@ void vbo_use_buffer_objects(GLcontext *ctx); void vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func); +void +_vbo_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); + +void +_vbo_Normal3f(GLfloat x, GLfloat y, GLfloat z); + +void +_vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); + + #endif diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index b263885388..cf9c860263 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -769,3 +769,24 @@ static void reset_attrfv( struct vbo_exec_context *exec ) exec->vtx.vertex_size = 0; } + +void +_vbo_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) +{ + vbo_Color4f(r, g, b, a); +} + + +void +_vbo_Normal3f(GLfloat x, GLfloat y, GLfloat z) +{ + vbo_Normal3f(x, y, z); +} + + +void +_vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + vbo_MultiTexCoord4f(target, s, t, r, q); +} + -- cgit v1.2.3 From 1b241a4369fcba5972a7ab38b9a5595a434e0b56 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 20 Jun 2008 11:04:37 -0600 Subject: mesa: added _vbo_Materialfv() --- src/mesa/vbo/vbo.h | 3 +++ src/mesa/vbo/vbo_exec_api.c | 5 +++++ 2 files changed, 8 insertions(+) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 1a737babd3..bd10956ee4 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -129,5 +129,8 @@ _vbo_Normal3f(GLfloat x, GLfloat y, GLfloat z); void _vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +void +_vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params); + #endif diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index cf9c860263..1e2a08bc8e 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -790,3 +790,8 @@ _vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) vbo_MultiTexCoord4f(target, s, t, r, q); } +void +_vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params) +{ + vbo_Materialfv(face, pname, params); +} -- cgit v1.2.3 From dd3311aa89035aa2e624f54b6914cfbcf57b33d7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 3 Jul 2008 16:59:24 -0600 Subject: mesa: added _vbo_VertexAttrib4f() --- src/mesa/vbo/vbo.h | 2 ++ src/mesa/vbo/vbo_exec_api.c | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index bd10956ee4..59cd7f6984 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -132,5 +132,7 @@ _vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); void _vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params); +void +_vbo_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); #endif diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 1e2a08bc8e..2c2e66dd0b 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -795,3 +795,10 @@ _vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params) { vbo_Materialfv(face, pname, params); } + + +void +_vbo_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + vbo_VertexAttrib4fARB(index, x, y, z, w); +} -- cgit v1.2.3 From 8d2400f2161efa95d2ef18fec353db4841f09637 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Mon, 7 Jul 2008 17:56:29 -0600 Subject: mesa: added GLAPIENTRY keywords --- src/mesa/vbo/vbo.h | 10 +++++----- src/mesa/vbo/vbo_exec_api.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 59cd7f6984..5362226c2f 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -120,19 +120,19 @@ void vbo_use_buffer_objects(GLcontext *ctx); void vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func); -void +void GLAPIENTRY _vbo_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); -void +void GLAPIENTRY _vbo_Normal3f(GLfloat x, GLfloat y, GLfloat z); -void +void GLAPIENTRY _vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -void +void GLAPIENTRY _vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params); -void +void GLAPIENTRY _vbo_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); #endif diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 2c2e66dd0b..579bbeb4f3 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -770,34 +770,34 @@ static void reset_attrfv( struct vbo_exec_context *exec ) } -void +void GLAPIENTRY _vbo_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { vbo_Color4f(r, g, b, a); } -void +void GLAPIENTRY _vbo_Normal3f(GLfloat x, GLfloat y, GLfloat z) { vbo_Normal3f(x, y, z); } -void +void GLAPIENTRY _vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) { vbo_MultiTexCoord4f(target, s, t, r, q); } -void +void GLAPIENTRY _vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params) { vbo_Materialfv(face, pname, params); } -void +void GLAPIENTRY _vbo_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { vbo_VertexAttrib4fARB(index, x, y, z, w); -- cgit v1.2.3 From a69fc5129bdf2f245c5bf2e0fe7b542caf7809a9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Sep 2008 15:25:45 -0600 Subject: mesa: improved gl_buffer_object reference counting Use new _mesa_reference_buffer_object() function wherever possible. Fixes buffer object/display list crash reported in ParaView. --- src/mesa/main/arrayobj.c | 31 ++++--- src/mesa/main/attrib.c | 87 +++++++++++--------- src/mesa/main/bufferobj.c | 188 +++++++++++++++++++++---------------------- src/mesa/main/bufferobj.h | 11 +-- src/mesa/main/varray.c | 15 ++-- src/mesa/vbo/vbo_exec_api.c | 8 +- src/mesa/vbo/vbo_exec_draw.c | 26 ++++-- src/mesa/vbo/vbo_save.c | 16 ++-- src/mesa/vbo/vbo_save_api.c | 17 +++- src/mesa/vbo/vbo_save_draw.c | 28 +++++-- 10 files changed, 241 insertions(+), 186 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index af2feb3553..1461239317 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.2 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * (C) Copyright IBM Corporation 2006 * * Permission is hereby granted, free of charge, to any person obtaining a @@ -219,6 +219,15 @@ _mesa_remove_array_object( GLcontext *ctx, struct gl_array_object *obj ) } +static void +unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) +{ + if (bufObj != ctx->Array.NullBufferObj) { + _mesa_reference_buffer_object(ctx, &bufObj, NULL); + } +} + + /**********************************************************************/ /* API Functions */ /**********************************************************************/ @@ -320,18 +329,18 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids) /* Unbind any buffer objects that might be bound to arrays in * this array object. */ - _mesa_unbind_buffer_object( ctx, obj->Vertex.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->Normal.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->Color.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->FogCoord.BufferObj ); - _mesa_unbind_buffer_object( ctx, obj->Index.BufferObj ); + unbind_buffer_object( ctx, obj->Vertex.BufferObj ); + unbind_buffer_object( ctx, obj->Normal.BufferObj ); + unbind_buffer_object( ctx, obj->Color.BufferObj ); + unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj ); + unbind_buffer_object( ctx, obj->FogCoord.BufferObj ); + unbind_buffer_object( ctx, obj->Index.BufferObj ); for (i = 0; i < MAX_TEXTURE_UNITS; i++) { - _mesa_unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj ); + unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj ); } - _mesa_unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj ); + unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj ); for (i = 0; i < VERT_ATTRIB_MAX; i++) { - _mesa_unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj ); + unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj ); } #endif diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index b990369a9e..4cbb0273ab 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.2 * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -1269,6 +1269,29 @@ adjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step) } +/** + * Copy gl_pixelstore_attrib from src to dst, updating buffer + * object refcounts. + */ +static void +copy_pixelstore(GLcontext *ctx, + struct gl_pixelstore_attrib *dst, + const struct gl_pixelstore_attrib *src) +{ + dst->Alignment = src->Alignment; + dst->RowLength = src->RowLength; + dst->SkipPixels = src->SkipPixels; + dst->SkipRows = src->SkipRows; + dst->ImageHeight = src->ImageHeight; + dst->SkipImages = src->SkipImages; + dst->SwapBytes = src->SwapBytes; + dst->LsbFirst = src->LsbFirst; + dst->ClientStorage = src->ClientStorage; + dst->Invert = src->Invert; + _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); +} + + #define GL_CLIENT_PACK_BIT (1<<20) #define GL_CLIENT_UNPACK_BIT (1<<21) @@ -1287,31 +1310,29 @@ _mesa_PushClientAttrib(GLbitfield mask) return; } - /* Build linked list of attribute nodes which save all attribute */ - /* groups specified by the mask. */ + /* Build linked list of attribute nodes which save all attribute + * groups specified by the mask. + */ head = NULL; if (mask & GL_CLIENT_PIXEL_STORE_BIT) { struct gl_pixelstore_attrib *attr; -#if FEATURE_EXT_pixel_buffer_object - ctx->Pack.BufferObj->RefCount++; - ctx->Unpack.BufferObj->RefCount++; -#endif /* packing attribs */ - attr = MALLOC_STRUCT( gl_pixelstore_attrib ); - MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) ); + attr = CALLOC_STRUCT( gl_pixelstore_attrib ); + copy_pixelstore(ctx, attr, &ctx->Pack); newnode = new_attrib_node( GL_CLIENT_PACK_BIT ); newnode->data = attr; newnode->next = head; head = newnode; /* unpacking attribs */ attr = MALLOC_STRUCT( gl_pixelstore_attrib ); - MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) ); + copy_pixelstore(ctx, attr, &ctx->Unpack); newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT ); newnode->data = attr; newnode->next = head; head = newnode; } + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { struct gl_array_attrib *attr; struct gl_array_object *obj; @@ -1348,7 +1369,7 @@ _mesa_PushClientAttrib(GLbitfield mask) void GLAPIENTRY _mesa_PopClientAttrib(void) { - struct gl_attrib_node *attr, *next; + struct gl_attrib_node *node, *next; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -1359,37 +1380,31 @@ _mesa_PopClientAttrib(void) } ctx->ClientAttribStackDepth--; - attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; + node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; - while (attr) { - switch (attr->kind) { + while (node) { + switch (node->kind) { case GL_CLIENT_PACK_BIT: -#if FEATURE_EXT_pixel_buffer_object - ctx->Pack.BufferObj->RefCount--; - if (ctx->Pack.BufferObj->RefCount <= 0) { - _mesa_remove_buffer_object( ctx, ctx->Pack.BufferObj ); - (*ctx->Driver.DeleteBuffer)( ctx, ctx->Pack.BufferObj ); + { + struct gl_pixelstore_attrib *store = + (struct gl_pixelstore_attrib *) node->data; + copy_pixelstore(ctx, &ctx->Pack, store); + _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); } -#endif - MEMCPY( &ctx->Pack, attr->data, - sizeof(struct gl_pixelstore_attrib) ); ctx->NewState |= _NEW_PACKUNPACK; break; case GL_CLIENT_UNPACK_BIT: -#if FEATURE_EXT_pixel_buffer_object - ctx->Unpack.BufferObj->RefCount--; - if (ctx->Unpack.BufferObj->RefCount <= 0) { - _mesa_remove_buffer_object( ctx, ctx->Unpack.BufferObj ); - (*ctx->Driver.DeleteBuffer)( ctx, ctx->Unpack.BufferObj ); + { + struct gl_pixelstore_attrib *store = + (struct gl_pixelstore_attrib *) node->data; + copy_pixelstore(ctx, &ctx->Unpack, store); + _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); } -#endif - MEMCPY( &ctx->Unpack, attr->data, - sizeof(struct gl_pixelstore_attrib) ); ctx->NewState |= _NEW_PACKUNPACK; break; case GL_CLIENT_VERTEX_ARRAY_BIT: { struct gl_array_attrib * data = - (struct gl_array_attrib *) attr->data; + (struct gl_array_attrib *) node->data; adjust_buffer_object_ref_counts(&ctx->Array, -1); @@ -1424,10 +1439,10 @@ _mesa_PopClientAttrib(void) break; } - next = attr->next; - FREE( attr->data ); - FREE( attr ); - attr = next; + next = node->next; + FREE( node->data ); + FREE( node ); + node = next; } } diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index dc0307feb5..f1e0932b07 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.2 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * @@ -166,22 +166,75 @@ _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) if (bufObj->Data) _mesa_free(bufObj->Data); + + /* assign strange values here to help w/ debugging */ + bufObj->RefCount = -1000; + bufObj->Name = ~0; + _mesa_free(bufObj); } + +/** + * Set ptr to bufObj w/ reference counting. + */ void -_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) +_mesa_reference_buffer_object(GLcontext *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *bufObj) { - if (bufObj != ctx->Array.NullBufferObj) { - bufObj->RefCount--; - if (bufObj->RefCount <= 0) { + if (*ptr == bufObj) + return; + + if (*ptr) { + /* Unreference the old texture */ + GLboolean deleteFlag = GL_FALSE; + struct gl_buffer_object *oldObj = *ptr; + + /*_glthread_LOCK_MUTEX(oldObj->Mutex);*/ + ASSERT(oldObj->RefCount > 0); + oldObj->RefCount--; +#if 0 + printf("BufferObj %p %d DECR to %d\n", + (void *) oldObj, oldObj->Name, oldObj->RefCount); +#endif + deleteFlag = (oldObj->RefCount == 0); + /*_glthread_UNLOCK_MUTEX(oldObj->Mutex);*/ + + if (deleteFlag) { + + /* some sanity checking: don't delete a buffer still in use */ ASSERT(ctx->Array.ArrayBufferObj != bufObj); ASSERT(ctx->Array.ElementArrayBufferObj != bufObj); ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj); ASSERT(ctx->Driver.DeleteBuffer); - ctx->Driver.DeleteBuffer(ctx, bufObj); + + ctx->Driver.DeleteBuffer(ctx, oldObj); } + + *ptr = NULL; + } + ASSERT(!*ptr); + + if (bufObj) { + /* reference new texture */ + /*_glthread_LOCK_MUTEX(tex->Mutex);*/ + if (bufObj->RefCount == 0) { + /* this buffer's being deleted (look just above) */ + /* Not sure this can every really happen. Warn if it does. */ + _mesa_problem(NULL, "referencing deleted buffer object"); + *ptr = NULL; + } + else { + bufObj->RefCount++; +#if 0 + printf("BufferObj %p %d INCR to %d\n", + (void *) bufObj, bufObj->Name, bufObj->RefCount); +#endif + *ptr = bufObj; + } + /*_glthread_UNLOCK_MUTEX(tex->Mutex);*/ } } @@ -203,33 +256,6 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj, } -/** - * Add the given buffer object to the buffer object pool. - */ -void -_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj ) -{ - if (obj->Name > 0) { - /* insert into hash table */ - _mesa_HashInsert(ctx->Shared->BufferObjects, obj->Name, obj); - } -} - - -/** - * Remove the given buffer object from the buffer object pool. - * Do not deallocate the buffer object though. - */ -void -_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) -{ - if (bufObj->Name > 0) { - /* remove from hash table */ - _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name); - } -} - - /** * Allocate space for and store data in a buffer object. Any data that was * previously stored in the buffer object is lost. If \c data is \c NULL, @@ -400,6 +426,7 @@ _mesa_init_buffer_objects( GLcontext *ctx ) { /* Allocate the default buffer object and set refcount so high that * it never gets deleted. + * XXX with recent/improved refcounting this may not longer be needed. */ ctx->Array.NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0); if (ctx->Array.NullBufferObj) @@ -621,6 +648,23 @@ _mesa_lookup_bufferobj(GLcontext *ctx, GLuint buffer) } +/** + * If *ptr points to obj, set ptr = the Null/default buffer object. + * This is a helper for buffer object deletion. + * The GL spec says that deleting a buffer object causes it to get + * unbound from all arrays in the current context. + */ +static void +unbind(GLcontext *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *obj) +{ + if (*ptr == obj) { + _mesa_reference_buffer_object(ctx, ptr, ctx->Array.NullBufferObj); + } +} + + /**********************************************************************/ /* API Functions */ @@ -678,28 +722,16 @@ _mesa_BindBufferARB(GLenum target, GLuint buffer) _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB"); return; } - _mesa_save_buffer_object(ctx, newBufObj); + _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj); } } - /* Make new binding */ - *bindTarget = newBufObj; - newBufObj->RefCount++; + /* bind new buffer */ + _mesa_reference_buffer_object(ctx, bindTarget, newBufObj); /* Pass BindBuffer call to device driver */ if (ctx->Driver.BindBuffer && newBufObj) ctx->Driver.BindBuffer( ctx, target, newBufObj ); - - /* decr ref count on old buffer obj, delete if needed */ - if (oldBufObj) { - oldBufObj->RefCount--; - assert(oldBufObj->RefCount >= 0); - if (oldBufObj->RefCount == 0) { - assert(oldBufObj->Name != 0); - ASSERT(ctx->Driver.DeleteBuffer); - ctx->Driver.DeleteBuffer( ctx, oldBufObj ); - } - } } @@ -731,54 +763,18 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) ASSERT(bufObj->Name == ids[i]); - if (ctx->Array.ArrayObj->Vertex.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->Vertex.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->Normal.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->Normal.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->Color.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->Color.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->SecondaryColor.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->SecondaryColor.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->FogCoord.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->FogCoord.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->Index.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->Index.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } - if (ctx->Array.ArrayObj->EdgeFlag.BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->EdgeFlag.BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } + unbind(ctx, &ctx->Array.ArrayObj->Vertex.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->Normal.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->Color.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->SecondaryColor.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->FogCoord.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->Index.BufferObj, bufObj); + unbind(ctx, &ctx->Array.ArrayObj->EdgeFlag.BufferObj, bufObj); for (j = 0; j < MAX_TEXTURE_UNITS; j++) { - if (ctx->Array.ArrayObj->TexCoord[j].BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->TexCoord[j].BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } + unbind(ctx, &ctx->Array.ArrayObj->TexCoord[j].BufferObj, bufObj); } for (j = 0; j < VERT_ATTRIB_MAX; j++) { - if (ctx->Array.ArrayObj->VertexAttrib[j].BufferObj == bufObj) { - bufObj->RefCount--; - ctx->Array.ArrayObj->VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj; - ctx->Array.NullBufferObj->RefCount++; - } + unbind(ctx, &ctx->Array.ArrayObj->VertexAttrib[j].BufferObj, bufObj); } if (ctx->Array.ArrayBufferObj == bufObj) { @@ -796,8 +792,8 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) } /* The ID is immediately freed for re-use */ - _mesa_remove_buffer_object(ctx, bufObj); - _mesa_unbind_buffer_object(ctx, bufObj); + _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name); + _mesa_reference_buffer_object(ctx, &bufObj, NULL); } } @@ -846,7 +842,7 @@ _mesa_GenBuffersARB(GLsizei n, GLuint *buffer) _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB"); return; } - _mesa_save_buffer_object(ctx, bufObj); + _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, bufObj); buffer[i] = first + i; } diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 024e5a8c3c..2f908c5c35 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.2 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * @@ -52,10 +52,9 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj, GLuint name, GLenum target ); extern void -_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj ); - -extern void -_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ); +_mesa_reference_buffer_object(GLcontext *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *bufObj); extern void _mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size, @@ -115,8 +114,6 @@ _mesa_unmap_readpix_pbo(GLcontext *ctx, const struct gl_pixelstore_attrib *pack); -extern void -_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ); /* * API functions diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index a6aa9c34b2..9f1fcd9d26 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.2 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -62,14 +62,9 @@ update_array(GLcontext *ctx, struct gl_client_array *array, array->Normalized = normalized; array->Ptr = (const GLubyte *) ptr; #if FEATURE_ARB_vertex_buffer_object - array->BufferObj->RefCount--; - if (array->BufferObj->RefCount <= 0) { - ASSERT(array->BufferObj->Name); - _mesa_remove_buffer_object( ctx, array->BufferObj ); - (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj ); - } - array->BufferObj = ctx->Array.ArrayBufferObj; - array->BufferObj->RefCount++; + _mesa_reference_buffer_object(ctx, &array->BufferObj, + ctx->Array.ArrayBufferObj); + /* Compute the index of the last array element that's inside the buffer. * Later in glDrawArrays we'll check if start + count > _MaxElement to * be sure we won't go out of bounds. diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 579bbeb4f3..d70b4bb1a1 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -1,6 +1,6 @@ /************************************************************************** -Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. +Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas. All Rights Reserved. @@ -31,6 +31,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "main/glheader.h" +#include "main/bufferobj.h" #include "main/context.h" #include "main/macros.h" #include "main/vtxfmt.h" @@ -695,7 +696,10 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) * continuously, unless vbo_use_buffer_objects() is called to enable * use of real VBOs. */ - exec->vtx.bufferobj = ctx->Array.NullBufferObj; + _mesa_reference_buffer_object(ctx, + &exec->vtx.bufferobj, + ctx->Array.NullBufferObj); + exec->vtx.buffer_map = ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE * sizeof(GLfloat), 64); vbo_exec_vtxfmt_init( exec ); diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 3609a7452a..f497e9a5a5 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 7.2 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -26,6 +26,7 @@ */ #include "main/glheader.h" +#include "main/bufferobj.h" #include "main/context.h" #include "main/enums.h" #include "main/state.h" @@ -155,8 +156,12 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) */ switch (get_program_mode(exec->ctx)) { case VP_NONE: - memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); - memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0])); + for (attr = 0; attr < 16; attr++) { + exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; + } + for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { + exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr]; + } map = vbo->map_vp_none; break; case VP_NV: @@ -165,8 +170,10 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) * occurred. NV vertex programs cannot access material values, * nor attributes greater than VERT_ATTRIB_TEX7. */ - memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); - memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0])); + for (attr = 0; attr < 16; attr++) { + exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; + exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr]; + } map = vbo->map_vp_arb; break; } @@ -178,6 +185,9 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) const GLuint src = map[attr]; if (exec->vtx.attrsz[src]) { + /* override the default array set above */ + exec->vtx.inputs[attr] = &arrays[attr]; + if (exec->vtx.bufferobj->Name) { /* a real buffer obj: Ptr is an offset, not a pointer*/ int offset; @@ -195,7 +205,9 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat); arrays[attr].Type = GL_FLOAT; arrays[attr].Enabled = 1; - arrays[attr].BufferObj = exec->vtx.bufferobj; + _mesa_reference_buffer_object(ctx, + &arrays[attr].BufferObj, + exec->vtx.bufferobj); arrays[attr]._MaxElement = count; /* ??? */ data += exec->vtx.attrsz[src] * sizeof(GLfloat); diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c index 8dd87141c0..9757c3d9f6 100644 --- a/src/mesa/vbo/vbo_save.c +++ b/src/mesa/vbo/vbo_save.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 7.2 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -27,6 +27,7 @@ #include "main/mtypes.h" +#include "main/bufferobj.h" #include "main/dlist.h" #include "main/vtxfmt.h" #include "main/imports.h" @@ -71,19 +72,24 @@ void vbo_save_destroy( GLcontext *ctx ) { struct vbo_context *vbo = vbo_context(ctx); struct vbo_save_context *save = &vbo->save; + GLuint i; + if (save->prim_store) { if ( --save->prim_store->refcount == 0 ) { FREE( save->prim_store ); save->prim_store = NULL; } if ( --save->vertex_store->refcount == 0 ) { - if (save->vertex_store->bufferobj) - ctx->Driver.DeleteBuffer( ctx, save->vertex_store->bufferobj ); - + _mesa_reference_buffer_object(ctx, + &save->vertex_store->bufferobj, NULL); FREE( save->vertex_store ); save->vertex_store = NULL; } } + + for (i = 0; i < VBO_ATTRIB_MAX; i++) { + _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL); + } } diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index f62be5c14c..88d573f128 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1,6 +1,6 @@ /************************************************************************** -Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. +Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas. All Rights Reserved. @@ -68,6 +68,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/glheader.h" +#include "main/bufferobj.h" #include "main/context.h" #include "main/dlist.h" #include "main/enums.h" @@ -85,6 +86,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #endif +/* An interesting VBO number/name to help with debugging */ +#define VBO_BUF_ID 12345 + + /* * NOTE: Old 'parity' issue is gone, but copying can still be * wrong-footed on replay. @@ -170,7 +175,9 @@ static struct vbo_save_vertex_store *alloc_vertex_store( GLcontext *ctx ) * user. Perhaps there could be a special number for internal * buffers: */ - vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB); + vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, + VBO_BUF_ID, + GL_ARRAY_BUFFER_ARB); ctx->Driver.BufferData( ctx, GL_ARRAY_BUFFER_ARB, @@ -190,8 +197,9 @@ static void free_vertex_store( GLcontext *ctx, struct vbo_save_vertex_store *ver { assert(!vertex_store->buffer); - if (vertex_store->bufferobj) - ctx->Driver.DeleteBuffer( ctx, vertex_store->bufferobj ); + if (vertex_store->bufferobj) { + _mesa_reference_buffer_object(ctx, &vertex_store->bufferobj, NULL); + } FREE( vertex_store ); } @@ -1139,6 +1147,7 @@ void vbo_save_api_init( struct vbo_save_context *save ) _save_vtxfmt_init( ctx ); _save_current_init( ctx ); + /* These will actually get set again when binding/drawing */ for (i = 0; i < VBO_ATTRIB_MAX; i++) save->inputs[i] = &save->arrays[i]; diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index bf5c6d4eef..ed82f09958 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 7.2 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 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"), @@ -27,6 +27,7 @@ */ #include "main/glheader.h" +#include "main/bufferobj.h" #include "main/context.h" #include "main/imports.h" #include "main/mtypes.h" @@ -115,8 +116,12 @@ static void vbo_bind_vertex_list( GLcontext *ctx, */ switch (get_program_mode(ctx)) { case VP_NONE: - memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); - memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0])); + for (attr = 0; attr < 16; attr++) { + save->inputs[attr] = &vbo->legacy_currval[attr]; + } + for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { + save->inputs[attr + 16] = &vbo->mat_currval[attr]; + } map = vbo->map_vp_none; break; case VP_NV: @@ -125,8 +130,10 @@ static void vbo_bind_vertex_list( GLcontext *ctx, * occurred. NV vertex programs cannot access material values, * nor attributes greater than VERT_ATTRIB_TEX7. */ - memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); - memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0])); + for (attr = 0; attr < 16; attr++) { + save->inputs[attr] = &vbo->legacy_currval[attr]; + save->inputs[attr + 16] = &vbo->generic_currval[attr]; + } map = vbo->map_vp_arb; break; } @@ -135,13 +142,18 @@ static void vbo_bind_vertex_list( GLcontext *ctx, GLuint src = map[attr]; if (node->attrsz[src]) { - arrays[attr].Ptr = (const GLubyte *)data; + /* override the default array set above */ + save->inputs[attr] = &arrays[attr]; + + arrays[attr].Ptr = (const GLubyte *) data; arrays[attr].Size = node->attrsz[src]; arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat); arrays[attr].Stride = node->vertex_size * sizeof(GLfloat); arrays[attr].Type = GL_FLOAT; arrays[attr].Enabled = 1; - arrays[attr].BufferObj = node->vertex_store->bufferobj; + _mesa_reference_buffer_object(ctx, + &arrays[attr].BufferObj, + node->vertex_store->bufferobj); arrays[attr]._MaxElement = node->count; /* ??? */ assert(arrays[attr].BufferObj->Name); -- cgit v1.2.3 From fa1b533012030cd67148b5bf1e018fd5e30c96f8 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 3 Oct 2008 13:55:40 +0100 Subject: mesa: add new internal state for tracking current vertex attribs --- src/mesa/main/mtypes.h | 1 + src/mesa/main/state.c | 4 ++++ src/mesa/shader/prog_statevars.c | 8 ++++++++ src/mesa/shader/prog_statevars.h | 1 + src/mesa/vbo/vbo_exec_api.c | 44 ++++++++++++++++++++++++---------------- src/mesa/vbo/vbo_save_draw.c | 24 ++++++++++++++-------- 6 files changed, 56 insertions(+), 26 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a5e1cf6a27..bc099dabeb 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2744,6 +2744,7 @@ struct gl_matrix_stack #define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */ #define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */ #define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */ +#define _NEW_CURRENT_ATTRIB 0x10000000 /**< __GLcontextRec::Current */ #define _NEW_ALL ~0 /*@}*/ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index d355f78a0e..eb8dc2a339 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -407,6 +407,9 @@ _mesa_update_state_locked( GLcontext *ctx ) GLbitfield new_state = ctx->NewState; GLbitfield prog_flags = _NEW_PROGRAM; + if (new_state == _NEW_CURRENT_ATTRIB) + goto out; + if (MESA_VERBOSE & VERBOSE_STATE) _mesa_print_state("_mesa_update_state", new_state); @@ -484,6 +487,7 @@ _mesa_update_state_locked( GLcontext *ctx ) * Set ctx->NewState to zero to avoid recursion if * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?) */ + out: new_state = ctx->NewState; ctx->NewState = 0; ctx->Driver.UpdateState(ctx, new_state); diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 47c46f63ec..9cc33fa2c1 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -395,6 +395,12 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], case STATE_INTERNAL: switch (state[1]) { + case STATE_CURRENT_ATTRIB: { + const GLuint idx = (GLuint) state[2]; + COPY_4V(value, ctx->Current.Attrib[idx]); + return; + } + case STATE_NORMAL_SCALE: ASSIGN_4V(value, ctx->_ModelViewInvScale, @@ -565,6 +571,8 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) case STATE_INTERNAL: switch (state[1]) { + case STATE_CURRENT_ATTRIB: + return _NEW_CURRENT_ATTRIB; case STATE_NORMAL_SCALE: return _NEW_MODELVIEW; diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h index 7b490e3d63..1f728c64e8 100644 --- a/src/mesa/shader/prog_statevars.h +++ b/src/mesa/shader/prog_statevars.h @@ -104,6 +104,7 @@ typedef enum gl_state_index_ { STATE_LOCAL, STATE_INTERNAL, /* Mesa additions */ + STATE_CURRENT_ATTRIB, /* ctx->Current vertex attrib value */ STATE_NORMAL_SCALE, STATE_TEXRECT_SCALE, STATE_FOG_PARAMS_OPTIMIZED, /* for faster fog calc */ diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index d70b4bb1a1..23f4f8331e 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -143,29 +143,37 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) 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(current, - exec->vtx.attrsz[i], - exec->vtx.attrptr[i]); + GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; + GLfloat tmp[4]; + + COPY_CLEAN_4V(tmp, + exec->vtx.attrsz[i], + exec->vtx.attrptr[i]); + + if (memcmp(current, tmp, sizeof(tmp)) != 0) + { + memcpy(current, tmp, sizeof(tmp)); - /* 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). - */ - if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && - i <= VBO_ATTRIB_MAT_BACK_INDEXES) - ctx->NewState |= _NEW_LIGHT; + /* 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). + */ + if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && + i <= VBO_ATTRIB_MAT_BACK_INDEXES) + ctx->NewState |= _NEW_LIGHT; + + ctx->NewState |= _NEW_CURRENT_ATTRIB; + } } } diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index ed82f09958..4c97acddb9 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -64,18 +64,26 @@ static void _playback_copy_to_current( GLcontext *ctx, for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { if (node->attrsz[i]) { GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; + GLfloat tmp[4]; - COPY_CLEAN_4V(current, - node->attrsz[i], - data); + COPY_CLEAN_4V(tmp, + node->attrsz[i], + data); + + if (memcmp(current, tmp, 4 * sizeof(GLfloat)) != 0) + { + memcpy(current, tmp, 4 * sizeof(GLfloat)); - vbo->currval[i].Size = node->attrsz[i]; + vbo->currval[i].Size = node->attrsz[i]; - data += node->attrsz[i]; + if (i >= VBO_ATTRIB_FIRST_MATERIAL && + i <= VBO_ATTRIB_LAST_MATERIAL) + ctx->NewState |= _NEW_LIGHT; + + ctx->NewState |= _NEW_CURRENT_ATTRIB; + } - if (i >= VBO_ATTRIB_FIRST_MATERIAL && - i <= VBO_ATTRIB_LAST_MATERIAL) - ctx->NewState |= _NEW_LIGHT; + data += node->attrsz[i]; } } -- cgit v1.2.3 From dea0d4d56326f148a42c766bdbaf1b5bb247cc59 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 2 Feb 2009 16:33:08 -0700 Subject: mesa: fix GLSL issue preventing use of all 16 generic vertex attributes Only 15 actually worked before since we always reserved generic[0] as an alias for vertex position. The case of vertex attribute 0 is tricky. The spec says that there is no aliasing between generic vertex attributes 0..MAX_VERTEX_ATTRIBS-1 and the conventional attributes. But it also says that calls to glVertexAttrib(0, v) are equivalent to glVertex(v). The distinction seems to be in glVertex-mode versus vertex array mode. So update the VBO code so that if the shader uses generic[0] but not gl_Vertex, route the attribute data set with glVertex() to go to shader input generic[0]. No change needed for the glDrawArrays/Elements() path. This is a potentially risky change so regressions are possible. All the usual tests seem OK though. --- src/mesa/shader/slang/slang_link.c | 13 +++++++++++-- src/mesa/vbo/vbo_exec_api.c | 5 ++++- src/mesa/vbo/vbo_exec_draw.c | 13 +++++++++++++ src/mesa/vbo/vbo_save_draw.c | 18 +++++++++++++++++- 4 files changed, 45 insertions(+), 4 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index c6d5cc0566..77bcda0871 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -318,7 +318,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, { GLint attribMap[MAX_VERTEX_ATTRIBS]; GLuint i, j; - GLbitfield usedAttributes; + GLbitfield usedAttributes; /* generics only, not legacy attributes */ assert(origProg != linkedProg); assert(origProg->Target == GL_VERTEX_PROGRAM_ARB); @@ -342,6 +342,15 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, usedAttributes |= (1 << attr); } + /* If gl_Vertex is used, that actually counts against the limit + * on generic vertex attributes. This avoids the ambiguity of + * whether glVertexAttrib4fv(0, v) sets legacy attribute 0 (vert pos) + * or generic attribute[0]. If gl_Vertex is used, we want the former. + */ + if (origProg->InputsRead & VERT_BIT_POS) { + usedAttributes |= 0x1; + } + /* initialize the generic attribute map entries to -1 */ for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) { attribMap[i] = -1; @@ -384,7 +393,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, * Start at 1 since generic attribute 0 always aliases * glVertex/position. */ - for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) { + for (attr = 0; attr < MAX_VERTEX_ATTRIBS; attr++) { if (((1 << attr) & usedAttributes) == 0) break; } diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index d48f5230cb..f6daa253fd 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -148,11 +148,14 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) /* Note: the exec->vtx.current[i] pointers point into the * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays. */ + if (exec->vtx.attrptr[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 diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 5b2e3550ca..7204aec1dc 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -175,7 +175,20 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr]; } map = vbo->map_vp_arb; + + /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read. + * In that case we effectively need to route the data from + * glVertexAttrib(0, val) calls to feed into the GENERIC0 input. + */ + if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 && + (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) { + exec->vtx.inputs[16] = exec->vtx.inputs[0]; + exec->vtx.attrsz[16] = exec->vtx.attrsz[0]; + exec->vtx.attrsz[0] = 0; + } break; + default: + assert(0); } /* Make all active attributes (including edgeflag) available as diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 6fa3f1a7e4..7ee0a9a33f 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -110,6 +110,9 @@ static void vbo_bind_vertex_list( GLcontext *ctx, GLuint data = node->buffer_offset; const GLuint *map; GLuint attr; + GLubyte node_attrsz[VBO_ATTRIB_MAX]; /* copy of node->attrsz[] */ + + memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz)); /* Install the default (ie Current) attributes first, then overlay * all active ones. @@ -135,13 +138,26 @@ static void vbo_bind_vertex_list( GLcontext *ctx, save->inputs[attr + 16] = &vbo->generic_currval[attr]; } map = vbo->map_vp_arb; + + /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read. + * In that case we effectively need to route the data from + * glVertexAttrib(0, val) calls to feed into the GENERIC0 input. + */ + if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 && + (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) { + save->inputs[16] = save->inputs[0]; + node_attrsz[16] = node_attrsz[0]; + node_attrsz[0] = 0; + } break; + default: + assert(0); } for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { GLuint src = map[attr]; - if (node->attrsz[src]) { + if (node_attrsz[src]) { /* override the default array set above */ save->inputs[attr] = &arrays[attr]; -- cgit v1.2.3 From c64a2b708944ec671b1104067245500fcfc6ed94 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 3 Mar 2009 10:41:57 +0000 Subject: mesa: Add BeginVertices driver call Provides notification to the VBO modules prior to the first immediate call. Pairs with FlushVertices() --- src/mesa/main/dd.h | 6 ++++++ src/mesa/main/vtxfmt.c | 9 ++++++--- src/mesa/vbo/vbo_exec.c | 1 + src/mesa/vbo/vbo_exec.h | 2 ++ src/mesa/vbo/vbo_exec_api.c | 10 ++++++++++ 5 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 7fb0a211d7..b1e006901b 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -947,6 +947,12 @@ struct dd_function_table { GLuint NeedFlush; GLuint SaveNeedFlush; + + /* Called prior to any of the GLvertexformat functions being + * called. Paired with Driver.FlushVertices(). + */ + void (*BeginVertices)( GLcontext *ctx ); + /** * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c index 0204979003..1f807dc3dc 100644 --- a/src/mesa/main/vtxfmt.c +++ b/src/mesa/main/vtxfmt.c @@ -54,9 +54,12 @@ ASSERT( tnl->Current ); \ ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES ); \ ASSERT( tmp_offset >= 0 ); \ - \ - /* Save the swapped function's dispatch entry so it can be */ \ - /* restored later. */ \ + \ + if (tnl->SwapCount == 0) \ + ctx->Driver.BeginVertices( ctx ); \ + \ + /* Save the swapped function's dispatch entry so it can be */ \ + /* restored later. */ \ tnl->Swapped[tnl->SwapCount].location = & (((_glapi_proc *)ctx->Exec)[tmp_offset]); \ tnl->Swapped[tnl->SwapCount].function = (_glapi_proc)TAG(FUNC); \ tnl->SwapCount++; \ diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index 635f239acc..e168a89ea5 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -57,6 +57,7 @@ void vbo_exec_init( GLcontext *ctx ) ctx->Driver.NeedFlush = 0; ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; + ctx->Driver.BeginVertices = vbo_exec_BeginVertices; ctx->Driver.FlushVertices = vbo_exec_FlushVertices; vbo_exec_invalidate_state( ctx, ~0 ); diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index ddbcbe1181..3ce36657bd 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -140,6 +140,8 @@ struct vbo_exec_context void vbo_exec_init( GLcontext *ctx ); void vbo_exec_destroy( GLcontext *ctx ); void vbo_exec_invalidate_state( GLcontext *ctx, GLuint new_state ); + +void vbo_exec_BeginVertices( GLcontext *ctx ); void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ); diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 23f4f8331e..093e3d2167 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -748,6 +748,12 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) } } +void vbo_exec_BeginVertices( GLcontext *ctx ) +{ + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + if (0) _mesa_printf("%s\n", __FUNCTION__); +// vbo_exec_vtx_map( exec ); +} void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ) { @@ -765,6 +771,10 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ) reset_attrfv( exec ); } + /* Need to do this to ensure BeginVertices gets called again: + */ + _mesa_restore_exec_vtxfmt( ctx ); + exec->ctx->Driver.NeedFlush = 0; } -- cgit v1.2.3 From c4d1f4607abf3dfbcfcffc5c67bb89d420d3381a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 3 Mar 2009 10:46:12 +0000 Subject: vbo: use MapBufferRange where available Previously would have to allocate a new VBO after firing a draw command as subsequent call to Map() on old VBO might block if the driver had submitted the commands to hardware. --- src/mesa/vbo/vbo_exec.h | 13 +++-- src/mesa/vbo/vbo_exec_api.c | 62 +++++++++++++---------- src/mesa/vbo/vbo_exec_draw.c | 118 ++++++++++++++++++++++++++++++++++++------- src/mesa/vbo/vbo_save.h | 2 +- src/mesa/vbo/vbo_save_api.c | 16 +++--- 5 files changed, 154 insertions(+), 57 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index 3ce36657bd..100bb8a5de 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -43,7 +43,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* Wierd implementation stuff: */ -#define VBO_VERT_BUFFER_SIZE (1024*16) /* dwords == 64k */ +#define VBO_VERT_BUFFER_SIZE (1024*64) /* bytes */ #define VBO_MAX_ATTR_CODEGEN 16 #define ERROR_ATTRIB 16 @@ -78,14 +78,15 @@ struct vbo_exec_context struct { struct gl_buffer_object *bufferobj; - GLubyte *buffer_map; - GLuint vertex_size; + GLuint vertex_size; /* in dwords */ struct _mesa_prim prim[VBO_MAX_PRIM]; GLuint prim_count; - GLfloat *vbptr; /* cursor, points into buffer */ + GLfloat *buffer_map; + GLfloat *buffer_ptr; /* cursor, points into buffer */ + GLuint buffer_used; /* in bytes */ GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current vertex */ GLuint vert_count; @@ -140,6 +141,7 @@ struct vbo_exec_context void vbo_exec_init( GLcontext *ctx ); void vbo_exec_destroy( GLcontext *ctx ); void vbo_exec_invalidate_state( GLcontext *ctx, GLuint new_state ); +void vbo_exec_FlushVertices_internal( GLcontext *ctx, GLboolean unmap ); void vbo_exec_BeginVertices( GLcontext *ctx ); void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ); @@ -153,7 +155,8 @@ void vbo_exec_array_destroy( struct vbo_exec_context *exec ); void vbo_exec_vtx_init( struct vbo_exec_context *exec ); void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ); -void vbo_exec_vtx_flush( struct vbo_exec_context *exec ); +void vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ); +void vbo_exec_vtx_map( struct vbo_exec_context *exec ); void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ); void vbo_exec_eval_update( struct vbo_exec_context *exec ); diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 093e3d2167..4c8d0c25a4 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -62,7 +62,7 @@ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) if (exec->vtx.prim_count == 0) { exec->vtx.copied.nr = 0; exec->vtx.vert_count = 0; - exec->vtx.vbptr = (GLfloat *)exec->vtx.buffer_map; + exec->vtx.buffer_ptr = exec->vtx.buffer_map; } else { GLuint last_begin = exec->vtx.prim[exec->vtx.prim_count-1].begin; @@ -80,7 +80,7 @@ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) /* Execute the buffer and save copied vertices. */ if (exec->vtx.vert_count) - vbo_exec_vtx_flush( exec ); + vbo_exec_vtx_flush( exec, GL_FALSE ); else { exec->vtx.prim_count = 0; exec->vtx.copied.nr = 0; @@ -121,9 +121,9 @@ void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ) assert(exec->vtx.max_vert - exec->vtx.vert_count > exec->vtx.copied.nr); for (i = 0 ; i < exec->vtx.copied.nr ; i++) { - _mesa_memcpy( exec->vtx.vbptr, data, + _mesa_memcpy( exec->vtx.buffer_ptr, data, exec->vtx.vertex_size * sizeof(GLfloat)); - exec->vtx.vbptr += exec->vtx.vertex_size; + exec->vtx.buffer_ptr += exec->vtx.vertex_size; data += exec->vtx.vertex_size; exec->vtx.vert_count++; } @@ -252,9 +252,10 @@ static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec, exec->vtx.attrsz[attr] = newsz; exec->vtx.vertex_size += newsz - oldsz; - exec->vtx.max_vert = VBO_VERT_BUFFER_SIZE / exec->vtx.vertex_size; + exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / + (exec->vtx.vertex_size * sizeof(GLfloat))); exec->vtx.vert_count = 0; - exec->vtx.vbptr = (GLfloat *)exec->vtx.buffer_map; + exec->vtx.buffer_ptr = exec->vtx.buffer_map; /* Recalculate all the attrptr[] values @@ -280,10 +281,10 @@ static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec, if (exec->vtx.copied.nr) { GLfloat *data = exec->vtx.copied.buffer; - GLfloat *dest = exec->vtx.vbptr; + GLfloat *dest = exec->vtx.buffer_ptr; GLuint j; - assert(exec->vtx.vbptr == (GLfloat *)exec->vtx.buffer_map); + assert(exec->vtx.buffer_ptr == exec->vtx.buffer_map); for (i = 0 ; i < exec->vtx.copied.nr ; i++) { for (j = 0 ; j < VBO_ATTRIB_MAX ; j++) { @@ -309,7 +310,7 @@ static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec, } } - exec->vtx.vbptr = dest; + exec->vtx.buffer_ptr = dest; exec->vtx.vert_count += exec->vtx.copied.nr; exec->vtx.copied.nr = 0; } @@ -374,9 +375,9 @@ do { \ GLuint i; \ \ for (i = 0; i < exec->vtx.vertex_size; i++) \ - exec->vtx.vbptr[i] = exec->vtx.vertex[i]; \ + exec->vtx.buffer_ptr[i] = exec->vtx.vertex[i]; \ \ - exec->vtx.vbptr += exec->vtx.vertex_size; \ + exec->vtx.buffer_ptr += exec->vtx.vertex_size; \ exec->ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; \ \ if (++exec->vtx.vert_count >= exec->vtx.max_vert) \ @@ -533,7 +534,7 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) * begin/end pairs. */ if (exec->vtx.vertex_size && !exec->vtx.attrsz[0]) - vbo_exec_FlushVertices( ctx, ~0 ); + vbo_exec_FlushVertices_internal( ctx, GL_FALSE ); i = exec->vtx.prim_count++; exec->vtx.prim[i].mode = mode; @@ -567,7 +568,7 @@ static void GLAPIENTRY vbo_exec_End( void ) ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; if (exec->vtx.prim_count == VBO_MAX_PRIM) - vbo_exec_vtx_flush( exec ); + vbo_exec_vtx_flush( exec, GL_FALSE ); } else _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" ); @@ -673,23 +674,19 @@ void vbo_use_buffer_objects(GLcontext *ctx) */ GLuint bufName = 0xaabbccdd; GLenum target = GL_ARRAY_BUFFER_ARB; - GLenum access = GL_READ_WRITE_ARB; GLenum usage = GL_STREAM_DRAW_ARB; - GLsizei size = VBO_VERT_BUFFER_SIZE * sizeof(GLfloat); + GLsizei size = VBO_VERT_BUFFER_SIZE; /* Make sure this func is only used once */ assert(exec->vtx.bufferobj == ctx->Array.NullBufferObj); if (exec->vtx.buffer_map) { _mesa_align_free(exec->vtx.buffer_map); + exec->vtx.buffer_map = NULL; } /* Allocate a real buffer object now */ exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName, target); ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); - - /* and map it */ - exec->vtx.buffer_map - = ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); } @@ -708,7 +705,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) &exec->vtx.bufferobj, ctx->Array.NullBufferObj); - exec->vtx.buffer_map = ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE * sizeof(GLfloat), 64); + exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64); vbo_exec_vtxfmt_init( exec ); @@ -755,21 +752,34 @@ void vbo_exec_BeginVertices( GLcontext *ctx ) // vbo_exec_vtx_map( exec ); } -void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ) +void vbo_exec_FlushVertices_internal( GLcontext *ctx, GLboolean unmap ) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) - return; - - if (exec->vtx.vert_count) { - vbo_exec_vtx_flush( exec ); + if (exec->vtx.vert_count || unmap) { + vbo_exec_vtx_flush( exec, unmap ); } if (exec->vtx.vertex_size) { vbo_exec_copy_to_current( exec ); reset_attrfv( exec ); } +} + + + +void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ) +{ + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + + if (0) _mesa_printf("%s\n", __FUNCTION__); + + if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { + if (0) _mesa_printf("%s - inside begin/end\n", __FUNCTION__); + return; + } + + vbo_exec_FlushVertices_internal( ctx, GL_TRUE ); /* Need to do this to ensure BeginVertices gets called again: */ diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index ae43857c8a..a89f150654 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -70,7 +70,7 @@ static GLuint vbo_copy_vertices( struct vbo_exec_context *exec ) GLuint ovf, i; GLuint sz = exec->vtx.vertex_size; GLfloat *dst = exec->vtx.copied.buffer; - GLfloat *src = ((GLfloat *)exec->vtx.buffer_map + + GLfloat *src = (exec->vtx.buffer_map + exec->vtx.prim[exec->vtx.prim_count-1].start * exec->vtx.vertex_size); @@ -147,7 +147,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) struct vbo_exec_context *exec = &vbo->exec; struct gl_client_array *arrays = exec->vtx.arrays; GLuint count = exec->vtx.vert_count; - GLubyte *data = exec->vtx.buffer_map; + GLubyte *data = (GLubyte *)exec->vtx.buffer_map; const GLuint *map; GLuint attr; GLbitfield varying_inputs = 0x0; @@ -220,10 +220,78 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) } +static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec ) +{ + GLenum target = GL_ARRAY_BUFFER_ARB; + + if (exec->vtx.bufferobj->Name) { + GLcontext *ctx = exec->ctx; + + exec->vtx.buffer_used += (exec->vtx.buffer_ptr - + exec->vtx.buffer_map) * sizeof(float); + + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); + exec->vtx.buffer_map = NULL; + exec->vtx.buffer_ptr = NULL; + exec->vtx.max_vert = 0; + } +} + +void vbo_exec_vtx_map( struct vbo_exec_context *exec ) +{ + GLcontext *ctx = exec->ctx; + GLenum target = GL_ARRAY_BUFFER_ARB; + GLenum access = GL_READ_WRITE_ARB; + GLenum usage = GL_STREAM_DRAW_ARB; + + if (exec->vtx.bufferobj->Name == 0) + return; + + if (exec->vtx.buffer_map != NULL) { + assert(0); + exec->vtx.buffer_map = NULL; + } + + if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024 && + ctx->Driver.MapBufferRange) + { + exec->vtx.buffer_map = + (GLfloat *)ctx->Driver.MapBufferRange(ctx, + target, + exec->vtx.buffer_used, + (VBO_VERT_BUFFER_SIZE - + exec->vtx.buffer_used), + (GL_MAP_WRITE_BIT | + GL_MAP_INVALIDATE_RANGE_BIT | + GL_MAP_UNSYNCHRONIZED_BIT | + MESA_MAP_NOWAIT_BIT), + exec->vtx.bufferobj); + } + + if (exec->vtx.buffer_map) { + exec->vtx.buffer_map += exec->vtx.buffer_used / sizeof(float); + } + else { + exec->vtx.buffer_used = 0; + + ctx->Driver.BufferData(ctx, target, + VBO_VERT_BUFFER_SIZE, + NULL, usage, exec->vtx.bufferobj); + + exec->vtx.buffer_map = + (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); + } + + if (0) _mesa_printf("map %d..\n", exec->vtx.buffer_used); +} + + + /** * Execute the buffer and save copied verts. */ -void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) +void vbo_exec_vtx_flush( struct vbo_exec_context *exec, + GLboolean unmap ) { if (0) vbo_exec_debug_verts( exec ); @@ -236,13 +304,9 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) if (exec->vtx.copied.nr != exec->vtx.vert_count) { GLcontext *ctx = exec->ctx; - - GLenum target = GL_ARRAY_BUFFER_ARB; - GLenum access = GL_READ_WRITE_ARB; - GLenum usage = GL_STREAM_DRAW_ARB; - GLsizei size = VBO_VERT_BUFFER_SIZE * sizeof(GLfloat); - /* Before the unmap (why?) + /* Before the update_state() as this may raise _NEW_ARRAY + * from _mesa_set_varying_vp_inputs(). */ vbo_exec_bind_arrays( ctx ); @@ -250,8 +314,12 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) _mesa_update_state( ctx ); - ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); - exec->vtx.buffer_map = NULL; + if (exec->vtx.bufferobj->Name) { + vbo_exec_vtx_unmap( exec ); + } + + if (0) _mesa_printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count, + exec->vtx.vert_count); vbo_context(ctx)->draw_prims( ctx, exec->vtx.inputs, @@ -261,15 +329,31 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) 0, exec->vtx.vert_count - 1); - /* Get new data: - */ - ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); - exec->vtx.buffer_map - = ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); + /* If using a real VBO, get new storage -- unless asked not to. + */ + if (exec->vtx.bufferobj->Name && !unmap) { + vbo_exec_vtx_map( exec ); + } } } + /* May have to unmap explicitly if we didn't draw: + */ + if (unmap && + exec->vtx.bufferobj->Name && + exec->vtx.buffer_map) { + vbo_exec_vtx_unmap( exec ); + } + + + if (unmap) + exec->vtx.max_vert = 0; + else + exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / + (exec->vtx.vertex_size * sizeof(GLfloat))); + + + exec->vtx.buffer_ptr = exec->vtx.buffer_map; exec->vtx.prim_count = 0; exec->vtx.vert_count = 0; - exec->vtx.vbptr = (GLfloat *)exec->vtx.buffer_map; } diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h index b7e9baabf8..de8fa19304 100644 --- a/src/mesa/vbo/vbo_save.h +++ b/src/mesa/vbo/vbo_save.h @@ -130,7 +130,7 @@ struct vbo_save_context { struct vbo_save_vertex_store *vertex_store; struct vbo_save_primitive_store *prim_store; - GLfloat *vbptr; /* cursor, points into buffer */ + GLfloat *buffer_ptr; /* cursor, points into buffer */ GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current values */ GLfloat *attrptr[VBO_ATTRIB_MAX]; GLuint vert_count; diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index f69a33d817..9326f7e228 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -241,7 +241,7 @@ static void _save_reset_counters( GLcontext *ctx ) save->buffer = (save->vertex_store->buffer + save->vertex_store->used); - assert(save->buffer == save->vbptr); + assert(save->buffer == save->buffer_ptr); if (save->vertex_size) save->max_vert = ((VBO_SAVE_BUFFER_SIZE - save->vertex_store->used) / @@ -343,7 +343,7 @@ static void _save_compile_vertex_list( GLcontext *ctx ) /* Allocate and map new store: */ save->vertex_store = alloc_vertex_store( ctx ); - save->vbptr = map_vertex_store( ctx, save->vertex_store ); + save->buffer_ptr = map_vertex_store( ctx, save->vertex_store ); } if (save->prim_store->used > VBO_SAVE_PRIM_SIZE - 6) { @@ -414,9 +414,9 @@ static void _save_wrap_filled_vertex( GLcontext *ctx ) assert(save->max_vert - save->vert_count > save->copied.nr); for (i = 0 ; i < save->copied.nr ; i++) { - _mesa_memcpy( save->vbptr, data, save->vertex_size * sizeof(GLfloat)); + _mesa_memcpy( save->buffer_ptr, data, save->vertex_size * sizeof(GLfloat)); data += save->vertex_size; - save->vbptr += save->vertex_size; + save->buffer_ptr += save->vertex_size; save->vert_count++; } } @@ -550,7 +550,7 @@ static void _save_upgrade_vertex( GLcontext *ctx, } } - save->vbptr = dest; + save->buffer_ptr = dest; save->vert_count += save->copied.nr; } } @@ -622,9 +622,9 @@ do { \ GLuint i; \ \ for (i = 0; i < save->vertex_size; i++) \ - save->vbptr[i] = save->vertex[i]; \ + save->buffer_ptr[i] = save->vertex[i]; \ \ - save->vbptr += save->vertex_size; \ + save->buffer_ptr += save->vertex_size; \ \ if (++save->vert_count >= save->max_vert) \ _save_wrap_filled_vertex( ctx ); \ @@ -1035,7 +1035,7 @@ void vbo_save_NewList( GLcontext *ctx, GLuint list, GLenum mode ) if (!save->vertex_store) save->vertex_store = alloc_vertex_store( ctx ); - save->vbptr = map_vertex_store( ctx, save->vertex_store ); + save->buffer_ptr = map_vertex_store( ctx, save->vertex_store ); _save_reset_vertex( ctx ); _save_reset_counters( ctx ); -- cgit v1.2.3 From 2785af803f7d6d64ff17c10645e5f10499289ed0 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 3 Mar 2009 10:55:25 +0000 Subject: vbo: missing line from previous commit --- src/mesa/vbo/vbo_exec_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 4c8d0c25a4..1ba39c8aa2 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -749,7 +749,7 @@ void vbo_exec_BeginVertices( GLcontext *ctx ) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; if (0) _mesa_printf("%s\n", __FUNCTION__); -// vbo_exec_vtx_map( exec ); + vbo_exec_vtx_map( exec ); } void vbo_exec_FlushVertices_internal( GLcontext *ctx, GLboolean unmap ) -- cgit v1.2.3 From f9ce417aaf14c00e72e92307b910de5dbed1bb6d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 4 Mar 2009 15:15:43 +0000 Subject: vbo: use FLUSH_UPDATE_CURRENT flag to indicate whether the vbo module is active Add asserts for expected values on wakeup and flush. Remove cases where this flag is set or cleared except when waking up and flushing vbo module. --- src/mesa/vbo/vbo_exec_api.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index c0ffdb55e4..9c2d065913 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -183,8 +183,6 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) _mesa_update_color_material(ctx, ctx->Current.Attrib[VBO_ATTRIB_COLOR0]); } - - ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; } @@ -204,8 +202,6 @@ static void vbo_exec_copy_from_current( struct vbo_exec_context *exec ) break; } } - - ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; } @@ -346,8 +342,6 @@ static void vbo_exec_fixup_vertex( GLcontext *ctx, */ if (attr == 0) exec->ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; - else - exec->ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; } @@ -750,6 +744,9 @@ void vbo_exec_BeginVertices( GLcontext *ctx ) struct vbo_exec_context *exec = &vbo_context(ctx)->exec; if (0) _mesa_printf("%s\n", __FUNCTION__); vbo_exec_vtx_map( exec ); + + assert(exec->ctx->Driver.NeedFlush == 0); + exec->ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT; } void vbo_exec_FlushVertices_internal( GLcontext *ctx, GLboolean unmap ) @@ -785,6 +782,7 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ) */ _mesa_restore_exec_vtxfmt( ctx ); + assert(exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT); exec->ctx->Driver.NeedFlush = 0; } -- cgit v1.2.3 From 579ef8ab1984d895867f547afa60b3bec4c4599a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 4 Mar 2009 16:06:05 +0000 Subject: vbo: avoid getting buffer_ptr and buffer_map out of sync --- src/mesa/vbo/vbo_exec_api.c | 3 +++ src/mesa/vbo/vbo_exec_draw.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 9c2d065913..a1e66aec63 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -675,6 +675,7 @@ void vbo_use_buffer_objects(GLcontext *ctx) if (exec->vtx.buffer_map) { _mesa_align_free(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; + exec->vtx.buffer_ptr = NULL; } /* Allocate a real buffer object now */ @@ -700,6 +701,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) ASSERT(!exec->vtx.buffer_map); exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64); + exec->vtx.buffer_ptr = exec->vtx.buffer_map; vbo_exec_vtxfmt_init( exec ); @@ -735,6 +737,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) if (exec->vtx.buffer_map) { ALIGN_FREE(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; + exec->vtx.buffer_ptr = NULL; } } } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 38b6c56f47..4b44b30b32 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -243,7 +243,10 @@ static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec ) exec->vtx.buffer_used += (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float); - + + + assert(exec->vtx.buffer_ptr != NULL); + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); exec->vtx.buffer_map = NULL; exec->vtx.buffer_ptr = NULL; @@ -296,6 +299,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec ) (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); } + exec->vtx.buffer_ptr = exec->vtx.buffer_map; if (0) _mesa_printf("map %d..\n", exec->vtx.buffer_used); } -- cgit v1.2.3 From fba923ff4415ce8a14c890dea65bcb07b2f87fb5 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 4 Mar 2009 16:09:14 +0000 Subject: Revert "vbo: avoid getting buffer_ptr and buffer_map out of sync" This fixed a minor bug but broke everything else. This reverts commit 579ef8ab1984d895867f547afa60b3bec4c4599a. --- src/mesa/vbo/vbo_exec_api.c | 3 --- src/mesa/vbo/vbo_exec_draw.c | 6 +----- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index a1e66aec63..9c2d065913 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -675,7 +675,6 @@ void vbo_use_buffer_objects(GLcontext *ctx) if (exec->vtx.buffer_map) { _mesa_align_free(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; - exec->vtx.buffer_ptr = NULL; } /* Allocate a real buffer object now */ @@ -701,7 +700,6 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) ASSERT(!exec->vtx.buffer_map); exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64); - exec->vtx.buffer_ptr = exec->vtx.buffer_map; vbo_exec_vtxfmt_init( exec ); @@ -737,7 +735,6 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) if (exec->vtx.buffer_map) { ALIGN_FREE(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; - exec->vtx.buffer_ptr = NULL; } } } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 4b44b30b32..38b6c56f47 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -243,10 +243,7 @@ static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec ) exec->vtx.buffer_used += (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float); - - - assert(exec->vtx.buffer_ptr != NULL); - + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); exec->vtx.buffer_map = NULL; exec->vtx.buffer_ptr = NULL; @@ -299,7 +296,6 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec ) (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); } - exec->vtx.buffer_ptr = exec->vtx.buffer_map; if (0) _mesa_printf("map %d..\n", exec->vtx.buffer_used); } -- cgit v1.2.3 From 368ca83a3fdfbe8dfe591ab73d29c500d1a91c0a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 4 Mar 2009 17:01:47 +0000 Subject: vbo: second attempt - avoid getting buffer_ptr and buffer_map out of sync --- src/mesa/vbo/vbo_exec_api.c | 3 +++ src/mesa/vbo/vbo_exec_draw.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 9c2d065913..a1e66aec63 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -675,6 +675,7 @@ void vbo_use_buffer_objects(GLcontext *ctx) if (exec->vtx.buffer_map) { _mesa_align_free(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; + exec->vtx.buffer_ptr = NULL; } /* Allocate a real buffer object now */ @@ -700,6 +701,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) ASSERT(!exec->vtx.buffer_map); exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64); + exec->vtx.buffer_ptr = exec->vtx.buffer_map; vbo_exec_vtxfmt_init( exec ); @@ -735,6 +737,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) if (exec->vtx.buffer_map) { ALIGN_FREE(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; + exec->vtx.buffer_ptr = NULL; } } } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 38b6c56f47..59e176b837 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -243,7 +243,10 @@ static void vbo_exec_vtx_unmap( struct vbo_exec_context *exec ) exec->vtx.buffer_used += (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float); - + + assert(exec->vtx.buffer_used <= VBO_VERT_BUFFER_SIZE); + assert(exec->vtx.buffer_ptr != NULL); + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); exec->vtx.buffer_map = NULL; exec->vtx.buffer_ptr = NULL; @@ -264,6 +267,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec ) if (exec->vtx.buffer_map != NULL) { assert(0); exec->vtx.buffer_map = NULL; + exec->vtx.buffer_ptr = NULL; } if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024 && @@ -280,6 +284,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec ) GL_MAP_UNSYNCHRONIZED_BIT | MESA_MAP_NOWAIT_BIT), exec->vtx.bufferobj); + exec->vtx.buffer_ptr = exec->vtx.buffer_map; } if (exec->vtx.buffer_map) { @@ -294,6 +299,7 @@ void vbo_exec_vtx_map( struct vbo_exec_context *exec ) exec->vtx.buffer_map = (GLfloat *)ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); + exec->vtx.buffer_ptr = exec->vtx.buffer_map; } if (0) _mesa_printf("map %d..\n", exec->vtx.buffer_used); -- cgit v1.2.3 From 0756dc876c01a3d07da34e2da1899b340b0fb819 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 9 Mar 2009 12:17:28 +0000 Subject: vbo: stricter checks on Driver.NeedFlush This variable is being used in the r300 driver to trigger a flush under circumstances unrelated to the use in the vbo module. Tighten up the checks in vbo so as to avoid conflict with r300. Reported by Maciej Cencora --- src/mesa/vbo/vbo_exec_api.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index a1e66aec63..6402745ab6 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -748,7 +748,7 @@ void vbo_exec_BeginVertices( GLcontext *ctx ) if (0) _mesa_printf("%s\n", __FUNCTION__); vbo_exec_vtx_map( exec ); - assert(exec->ctx->Driver.NeedFlush == 0); + assert((exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0); exec->ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT; } @@ -783,10 +783,12 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ) /* Need to do this to ensure BeginVertices gets called again: */ - _mesa_restore_exec_vtxfmt( ctx ); + if (flags & FLUSH_UPDATE_CURRENT) { + assert(exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT); + _mesa_restore_exec_vtxfmt( ctx ); + } - assert(exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT); - exec->ctx->Driver.NeedFlush = 0; + exec->ctx->Driver.NeedFlush &= ~flags; } -- cgit v1.2.3 From ef5fd0b66a0ddfa1df5c39a8711dd542107c61c3 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 9 Mar 2009 14:40:34 +0000 Subject: vbo: yet tighter still usage of FLUSH_NEED_CURRENT Previous change broke redbook/polys and probably others. I'm fairly sure that drivers like r300 don't need to touch ctx->Driver.NeedVertices, but this code is incredibly fragile and I'm not confident about removing it from there. Hopefully this gets things working again. --- src/mesa/vbo/vbo_exec_api.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 6402745ab6..5d35ec9c11 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -749,7 +749,7 @@ void vbo_exec_BeginVertices( GLcontext *ctx ) vbo_exec_vtx_map( exec ); assert((exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0); - exec->ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT; + exec->ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; } void vbo_exec_FlushVertices_internal( GLcontext *ctx, GLboolean unmap ) @@ -783,9 +783,9 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ) /* Need to do this to ensure BeginVertices gets called again: */ - if (flags & FLUSH_UPDATE_CURRENT) { - assert(exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT); + if (exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) { _mesa_restore_exec_vtxfmt( ctx ); + exec->ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; } exec->ctx->Driver.NeedFlush &= ~flags; -- cgit v1.2.3 From 4f6b704f9796775d8d9937c3cf75a2901b99b896 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 7 May 2009 13:30:39 -0600 Subject: mesa: move the NullBufferObj from GLcontext to gl_shared_state Since shared array objects may point to the null/default buffer object, the null/default buffer object should be part of the shared state. --- src/mesa/main/arrayobj.c | 5 +++-- src/mesa/main/bufferobj.c | 16 ++++------------ src/mesa/main/context.c | 3 --- src/mesa/main/mtypes.h | 3 ++- src/mesa/main/pixel.c | 12 ++++++------ src/mesa/main/pixelstore.c | 9 ++++++--- src/mesa/main/shared.c | 12 ++++++++++++ src/mesa/swrast/s_imaging.c | 10 +++++----- src/mesa/vbo/vbo_context.c | 9 ++++++--- src/mesa/vbo/vbo_exec_api.c | 4 ++-- src/mesa/vbo/vbo_rebase.c | 2 +- src/mesa/vbo/vbo_split_copy.c | 4 ++-- src/mesa/vbo/vbo_split_inplace.c | 2 +- 13 files changed, 50 insertions(+), 41 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index b04095fd16..2646c12ccc 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -112,7 +112,8 @@ init_array(GLcontext *ctx, array->Normalized = GL_FALSE; #if FEATURE_ARB_vertex_buffer_object /* Vertex array buffers */ - array->BufferObj = ctx->Array.NullBufferObj; + _mesa_reference_buffer_object(ctx, &array->BufferObj, + ctx->Shared->NullBufferObj); #endif } @@ -180,7 +181,7 @@ _mesa_remove_array_object( GLcontext *ctx, struct gl_array_object *obj ) static void unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) { - if (bufObj != ctx->Array.NullBufferObj) { + if (bufObj != ctx->Shared->NullBufferObj) { _mesa_reference_buffer_object(ctx, &bufObj, NULL); } } diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index a983376251..1f2070ef47 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -424,16 +424,8 @@ _mesa_buffer_unmap( GLcontext *ctx, GLenum target, void _mesa_init_buffer_objects( GLcontext *ctx ) { - /* Allocate the default buffer object and set refcount so high that - * it never gets deleted. - * XXX with recent/improved refcounting this may not longer be needed. - */ - ctx->Array.NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0); - if (ctx->Array.NullBufferObj) - ctx->Array.NullBufferObj->RefCount = 1000; - - ctx->Array.ArrayBufferObj = ctx->Array.NullBufferObj; - ctx->Array.ElementArrayBufferObj = ctx->Array.NullBufferObj; + ctx->Array.ArrayBufferObj = ctx->Shared->NullBufferObj; + ctx->Array.ElementArrayBufferObj = ctx->Shared->NullBufferObj; } @@ -477,7 +469,7 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer) /* The spec says there's not a buffer object named 0, but we use * one internally because it simplifies things. */ - newBufObj = ctx->Array.NullBufferObj; + newBufObj = ctx->Shared->NullBufferObj; } else { /* non-default buffer object */ @@ -744,7 +736,7 @@ unbind(GLcontext *ctx, struct gl_buffer_object *obj) { if (*ptr == obj) { - _mesa_reference_buffer_object(ctx, ptr, ctx->Array.NullBufferObj); + _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj); } } diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index d780f91f04..1a290f251a 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1005,9 +1005,6 @@ _mesa_free_context_data( GLcontext *ctx ) _mesa_free_query_data(ctx); #endif -#if FEATURE_ARB_vertex_buffer_object - _mesa_delete_buffer_object(ctx, ctx->Array.NullBufferObj); -#endif _mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj); /* free dispatch tables */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index affb000b8c..3debbe9f2d 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1593,7 +1593,6 @@ struct gl_array_attrib GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */ #if FEATURE_ARB_vertex_buffer_object - struct gl_buffer_object *NullBufferObj; struct gl_buffer_object *ArrayBufferObj; struct gl_buffer_object *ElementArrayBufferObj; #endif @@ -2064,6 +2063,8 @@ struct gl_shared_state GLuint TextureStateStamp; /**< state notification for shared tex */ /*@}*/ + /** Default buffer object for vertex arrays that aren't in VBOs */ + struct gl_buffer_object *NullBufferObj; /** * \name Vertex/fragment programs diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 57ae9c721a..d9f3e476e8 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -170,7 +170,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) return; } /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj; + ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, GL_READ_ONLY_ARB, ctx->Unpack.BufferObj); @@ -229,7 +229,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) return; } /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj; + ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, GL_READ_ONLY_ARB, ctx->Unpack.BufferObj); @@ -303,7 +303,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) return; } /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj; + ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, GL_READ_ONLY_ARB, ctx->Unpack.BufferObj); @@ -371,7 +371,7 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values ) return; } /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj; + ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj); @@ -432,7 +432,7 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values ) return; } /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj; + ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj); @@ -494,7 +494,7 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values ) return; } /* restore */ - ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj; + ctx->DefaultPacking.BufferObj = ctx->Shared->NullBufferObj; buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj); diff --git a/src/mesa/main/pixelstore.c b/src/mesa/main/pixelstore.c index ff1a6344cc..6a641f83f2 100644 --- a/src/mesa/main/pixelstore.c +++ b/src/mesa/main/pixelstore.c @@ -245,7 +245,8 @@ _mesa_init_pixelstore( GLcontext *ctx ) ctx->Pack.ClientStorage = GL_FALSE; ctx->Pack.Invert = GL_FALSE; #if FEATURE_EXT_pixel_buffer_object - ctx->Pack.BufferObj = ctx->Array.NullBufferObj; + _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, + ctx->Shared->NullBufferObj); #endif ctx->Unpack.Alignment = 4; ctx->Unpack.RowLength = 0; @@ -258,7 +259,8 @@ _mesa_init_pixelstore( GLcontext *ctx ) ctx->Unpack.ClientStorage = GL_FALSE; ctx->Unpack.Invert = GL_FALSE; #if FEATURE_EXT_pixel_buffer_object - ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; + _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, + ctx->Shared->NullBufferObj); #endif /* @@ -278,6 +280,7 @@ _mesa_init_pixelstore( GLcontext *ctx ) ctx->DefaultPacking.ClientStorage = GL_FALSE; ctx->DefaultPacking.Invert = GL_FALSE; #if FEATURE_EXT_pixel_buffer_object - ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj; + _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, + ctx->Shared->NullBufferObj); #endif } diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index ae8dd2a836..759883743d 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -33,6 +33,7 @@ #include "mtypes.h" #include "hash.h" #include "arrayobj.h" +#include "bufferobj.h" #include "shared.h" #include "shader/program.h" #include "shader/shader_api.h" @@ -92,6 +93,13 @@ _mesa_alloc_shared_state(GLcontext *ctx) shared->BufferObjects = _mesa_NewHashTable(); #endif + /* Allocate the default buffer object and set refcount so high that + * it never gets deleted. + * XXX with recent/improved refcounting this may not longer be needed. + */ + shared->NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0); + shared->NullBufferObj->RefCount = 1000; + shared->ArrayObjects = _mesa_NewHashTable(); /* Create default texture objects */ @@ -341,6 +349,10 @@ _mesa_free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) _mesa_DeleteHashTable(shared->RenderBuffers); #endif +#if FEATURE_ARB_vertex_buffer_object + _mesa_delete_buffer_object(ctx, shared->NullBufferObj); +#endif + /* * Free texture objects (after FBOs since some textures might have * been bound to FBOs). diff --git a/src/mesa/swrast/s_imaging.c b/src/mesa/swrast/s_imaging.c index d6be3aa022..3578b713f6 100644 --- a/src/mesa/swrast/s_imaging.c +++ b/src/mesa/swrast/s_imaging.c @@ -60,7 +60,7 @@ _swrast_CopyColorTable( GLcontext *ctx, /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; - ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; + ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; _mesa_ColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data); @@ -94,7 +94,7 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; - ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; + ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; _mesa_ColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data); @@ -126,7 +126,7 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; - ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; + ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; /* store as convolution filter */ _mesa_ConvolutionFilter1D(target, internalFormat, width, @@ -178,12 +178,12 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, ctx->Unpack.SkipImages = 0; ctx->Unpack.SwapBytes = GL_FALSE; ctx->Unpack.LsbFirst = GL_FALSE; - ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; + ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; ctx->NewState |= _NEW_PACKUNPACK; /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; - ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; + ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; _mesa_ConvolutionFilter2D(target, internalFormat, width, height, GL_RGBA, CHAN_TYPE, rgba); diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index ca8190fd05..f193a4bf1e 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -28,6 +28,7 @@ #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" @@ -81,7 +82,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); } } @@ -106,7 +108,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); } } @@ -150,7 +153,7 @@ static void init_mat_currval(GLcontext *ctx) cl->Stride = 0; cl->StrideB = 0; cl->Enabled = 1; - cl->BufferObj = ctx->Array.NullBufferObj; + cl->BufferObj = ctx->Shared->NullBufferObj; } } diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 5d35ec9c11..6871ee5cab 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -671,7 +671,7 @@ void vbo_use_buffer_objects(GLcontext *ctx) GLsizei size = VBO_VERT_BUFFER_SIZE; /* Make sure this func is only used once */ - assert(exec->vtx.bufferobj == ctx->Array.NullBufferObj); + assert(exec->vtx.bufferobj == ctx->Shared->NullBufferObj); if (exec->vtx.buffer_map) { _mesa_align_free(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; @@ -697,7 +697,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) */ _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, - ctx->Array.NullBufferObj); + ctx->Shared->NullBufferObj); ASSERT(!exec->vtx.buffer_map); exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64); diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c index dae778e741..ea87dede64 100644 --- a/src/mesa/vbo/vbo_rebase.c +++ b/src/mesa/vbo/vbo_rebase.c @@ -161,7 +161,7 @@ void vbo_rebase_prims( GLcontext *ctx, GL_ELEMENT_ARRAY_BUFFER, ib->obj); - tmp_ib.obj = ctx->Array.NullBufferObj; + tmp_ib.obj = ctx->Shared->NullBufferObj; tmp_ib.ptr = tmp_indices; tmp_ib.count = ib->count; tmp_ib.type = ib->type; diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index 56a9fafac4..2f6a1998ea 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -459,7 +459,7 @@ replay_init( struct copy_context *copy ) dst->Ptr = copy->dstbuf + offset; dst->Enabled = GL_TRUE; dst->Normalized = src->Normalized; - dst->BufferObj = ctx->Array.NullBufferObj; + dst->BufferObj = ctx->Shared->NullBufferObj; dst->_MaxElement = copy->dstbuf_size; /* may be less! */ offset += copy->varying[i].size; @@ -479,7 +479,7 @@ replay_init( struct copy_context *copy ) */ copy->dstib.count = 0; /* duplicates dstelt_nr */ copy->dstib.type = GL_UNSIGNED_INT; - copy->dstib.obj = ctx->Array.NullBufferObj; + copy->dstib.obj = ctx->Shared->NullBufferObj; copy->dstib.ptr = copy->dstelt; } diff --git a/src/mesa/vbo/vbo_split_inplace.c b/src/mesa/vbo/vbo_split_inplace.c index fbc856e93b..3ed6b34fbf 100644 --- a/src/mesa/vbo/vbo_split_inplace.c +++ b/src/mesa/vbo/vbo_split_inplace.c @@ -221,7 +221,7 @@ static void split_prims( struct split_context *split) ib.count = count; ib.type = GL_UNSIGNED_INT; - ib.obj = split->ctx->Array.NullBufferObj; + ib.obj = split->ctx->Shared->NullBufferObj; ib.ptr = elts; tmpprim = *prim; -- cgit v1.2.3 From 0d3c8fbf12289a8cc081c2d68e810c4bf29d1f8d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Jun 2009 16:11:29 +0100 Subject: mesa/vbo: drop all references to vbo on destroy We were adding references to the input arrays, but failing to drop them on destruction. This could lead to a 64kb buffer being leaked each context destruction. --- src/mesa/vbo/vbo_exec_api.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 5d35ec9c11..a8a09859a0 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -727,19 +727,32 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) { - if (exec->vtx.bufferobj->Name) { - /* using a real VBO for vertex data */ - GLcontext *ctx = exec->ctx; - _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); - } - else { - /* just using malloc'd space for vertex data */ - if (exec->vtx.buffer_map) { + /* using a real VBO for vertex data */ + GLcontext *ctx = exec->ctx; + unsigned i; + + /* True VBOs should already be unmapped + */ + if (exec->vtx.buffer_map) { + assert (exec->vtx.bufferobj->Name == 0); + if (exec->vtx.bufferobj->Name == 0) { ALIGN_FREE(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; exec->vtx.buffer_ptr = NULL; } } + + /* Drop any outstanding reference to the vertex buffer + */ + for (i = 0; i < Elements(exec->vtx.arrays); i++) { + _mesa_reference_buffer_object(ctx, + &exec->vtx.arrays[i].BufferObj, + NULL); + } + + /* Free the vertex buffer: + */ + _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); } void vbo_exec_BeginVertices( GLcontext *ctx ) -- cgit v1.2.3 From 9d5479eeeb84a0a8d909e329b1e8e9888d424900 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Jun 2009 13:00:35 -0600 Subject: vbo: fix assertion, #define IMM_BUFFER_NAME This was sometimes seen when Glean exited upon test failure when using Gallium. --- src/mesa/vbo/vbo_exec_api.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index a8a09859a0..34e849aaab 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -51,6 +51,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #endif +/** ID/name for immediate-mode VBO */ +#define IMM_BUFFER_NAME 0xaabbccdd + + static void reset_attrfv( struct vbo_exec_context *exec ); @@ -665,7 +669,7 @@ void vbo_use_buffer_objects(GLcontext *ctx) /* Any buffer name but 0 can be used here since this bufferobj won't * go into the bufferobj hashtable. */ - GLuint bufName = 0xaabbccdd; + GLuint bufName = IMM_BUFFER_NAME; GLenum target = GL_ARRAY_BUFFER_ARB; GLenum usage = GL_STREAM_DRAW_ARB; GLsizei size = VBO_VERT_BUFFER_SIZE; @@ -734,7 +738,8 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) /* True VBOs should already be unmapped */ if (exec->vtx.buffer_map) { - assert (exec->vtx.bufferobj->Name == 0); + ASSERT(exec->vtx.bufferobj->Name == 0 || + exec->vtx.bufferobj->Name == IMM_BUFFER_NAME); if (exec->vtx.bufferobj->Name == 0) { ALIGN_FREE(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; -- cgit v1.2.3 From d03dde16ebb5ab7f109c8ff6d710d54d50d4fa8f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 14 Aug 2009 10:46:04 -0600 Subject: vbo: call _mesa_valid_to_render() --- src/mesa/vbo/vbo_exec_api.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index b746a77bc1..387d4ee3d4 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -486,23 +486,6 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j ) } -/** - * Check if programs/shaders are enabled and valid at glBegin time. - */ -GLboolean -vbo_validate_shaders(GLcontext *ctx) -{ - if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) || - (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) { - return GL_FALSE; - } - if (ctx->Shader.CurrentProgram && !ctx->Shader.CurrentProgram->LinkStatus) { - return GL_FALSE; - } - return GL_TRUE; -} - - /* Build a list of primitives on the fly. Keep * ctx->Driver.CurrentExecPrimitive uptodate as well. */ @@ -521,9 +504,7 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) return; } - if (!vbo_validate_shaders(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBegin (invalid vertex/fragment program)"); + if (!_mesa_valid_to_render(ctx, "glBegin")) { return; } -- cgit v1.2.3 From 7f8045ab4e11dee0d80498187e96d38ce95c8ef4 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 8 Sep 2009 14:32:08 +0800 Subject: mesa/main: New feature FEATURE_arrayelt. This allows the removal of AEcontext. --- src/mesa/main/api_arrayelt.c | 18 +++++++++++++++-- src/mesa/main/api_arrayelt.h | 47 +++++++++++++++++++++++++++++++++++++++++--- src/mesa/main/api_noop.c | 3 ++- src/mesa/main/dlist.c | 3 ++- src/mesa/main/mfeatures.h | 3 ++- src/mesa/main/vtxfmt.c | 4 +++- src/mesa/vbo/vbo_exec_api.c | 3 ++- src/mesa/vbo/vbo_save_api.c | 3 ++- 8 files changed, 73 insertions(+), 11 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index 2462a1b003..a058227110 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -71,6 +71,10 @@ typedef struct { */ #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 ) + +#if FEATURE_arrayelt + + static const int ColorFuncs[2][8] = { { _gloffset_Color3bv, @@ -1160,7 +1164,7 @@ static void _ae_update_state( GLcontext *ctx ) at->array = attribArray; /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV * function pointer here (for float arrays) since the pointer may - * change from one execution of _ae_loopback_array_elt() to + * change from one execution of _ae_ArrayElement() to * the next. Doing so caused UT to break. */ if (ctx->VertexProgram._Enabled @@ -1254,7 +1258,7 @@ void _ae_unmap_vbos( GLcontext *ctx ) * for all enabled vertex arrays (for elt-th element). * Note: this may be called during display list construction. */ -void GLAPIENTRY _ae_loopback_array_elt( GLint elt ) +void GLAPIENTRY _ae_ArrayElement( GLint elt ) { GET_CURRENT_CONTEXT(ctx); const AEcontext *actx = AE_CONTEXT(ctx); @@ -1317,3 +1321,13 @@ void _ae_invalidate_state( GLcontext *ctx, GLuint new_state ) actx->NewState |= new_state; } } + + +void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_ArrayElement(disp, vfmt->ArrayElement); +} + + +#endif /* FEATURE_arrayelt */ diff --git a/src/mesa/main/api_arrayelt.h b/src/mesa/main/api_arrayelt.h index e621724fb2..d18c0792c3 100644 --- a/src/mesa/main/api_arrayelt.h +++ b/src/mesa/main/api_arrayelt.h @@ -27,16 +27,57 @@ #ifndef API_ARRAYELT_H #define API_ARRAYELT_H -#include "mtypes.h" + +#include "main/mtypes.h" + +#if FEATURE_arrayelt + +#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) \ + do { \ + (vfmt)->ArrayElement = impl ## ArrayElement; \ + } while (0) extern GLboolean _ae_create_context( GLcontext *ctx ); extern void _ae_destroy_context( GLcontext *ctx ); extern void _ae_invalidate_state( GLcontext *ctx, GLuint new_state ); -extern void GLAPIENTRY _ae_loopback_array_elt( GLint elt ); +extern void GLAPIENTRY _ae_ArrayElement( GLint elt ); /* May optionally be called before a batch of element calls: */ extern void _ae_map_vbos( GLcontext *ctx ); extern void _ae_unmap_vbos( GLcontext *ctx ); -#endif +extern void +_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt); + +#else /* FEATURE_arrayelt */ + +#define _MESA_INIT_ARRAYELT_VTXFMT(vfmt, impl) do { } while (0) + +static INLINE GLboolean +_ae_create_context( GLcontext *ctx ) +{ + return GL_TRUE; +} + +static INLINE void +_ae_destroy_context( GLcontext *ctx ) +{ +} + +static INLINE void +_ae_invalidate_state( GLcontext *ctx, GLuint new_state ) +{ +} + +static INLINE void +_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ +} + +#endif /* FEATURE_arrayelt */ + + +#endif /* API_ARRAYELT_H */ diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index 0b669e7e7f..162b685b02 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -992,7 +992,8 @@ _mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) void _mesa_noop_vtxfmt_init( GLvertexformat *vfmt ) { - vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */ + _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); + vfmt->Begin = _mesa_noop_Begin; #if FEATURE_dlist vfmt->CallList = _mesa_CallList; diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index d721f699fd..64617fbd79 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -8632,7 +8632,8 @@ mesa_print_display_list(GLuint list) void _mesa_save_vtxfmt_init(GLvertexformat * vfmt) { - vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */ + _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); + vfmt->Begin = save_Begin; vfmt->CallList = _mesa_save_CallList; vfmt->CallLists = _mesa_save_CallLists; diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h index cfffc2bf85..eb6a1b1215 100644 --- a/src/mesa/main/mfeatures.h +++ b/src/mesa/main/mfeatures.h @@ -70,11 +70,12 @@ */ #define FEATURE_accum _HAVE_FULL_GL +#define FEATURE_arrayelt _HAVE_FULL_GL #define FEATURE_attrib_stack _HAVE_FULL_GL #define FEATURE_colortable _HAVE_FULL_GL #define FEATURE_convolve _HAVE_FULL_GL #define FEATURE_dispatch _HAVE_FULL_GL -#define FEATURE_dlist _HAVE_FULL_GL +#define FEATURE_dlist (_HAVE_FULL_GL && FEATURE_arrayelt) #define FEATURE_draw_read_buffer _HAVE_FULL_GL #define FEATURE_drawpix _HAVE_FULL_GL #define FEATURE_evaluators _HAVE_FULL_GL diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c index 91412f138a..de9479d6b0 100644 --- a/src/mesa/main/vtxfmt.c +++ b/src/mesa/main/vtxfmt.c @@ -27,6 +27,7 @@ */ #include "glheader.h" +#include "api_arrayelt.h" #include "api_loopback.h" #include "context.h" #include "imports.h" @@ -82,7 +83,8 @@ static void install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) { - SET_ArrayElement(tab, vfmt->ArrayElement); + _mesa_install_arrayelt_vtxfmt(tab, vfmt); + SET_Color3f(tab, vfmt->Color3f); SET_Color3fv(tab, vfmt->Color3fv); SET_Color4f(tab, vfmt->Color4f); diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 387d4ee3d4..238beee030 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -557,7 +557,8 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) { GLvertexformat *vfmt = &exec->vtxfmt; - vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */ + _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); + vfmt->Begin = vbo_exec_Begin; #if FEATURE_dlist vfmt->CallList = _mesa_CallList; diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 41cd21d04b..6e11344380 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -988,7 +988,8 @@ static void _save_vtxfmt_init( GLcontext *ctx ) struct vbo_save_context *save = &vbo_context(ctx)->save; GLvertexformat *vfmt = &save->vtxfmt; - vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */ + _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); + vfmt->Begin = _save_Begin; vfmt->Color3f = _save_Color3f; vfmt->Color3fv = _save_Color3fv; -- cgit v1.2.3 From 17f2649e269b9d98abd6a66f687ffa29904bf4a0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 8 Sep 2009 10:25:22 +0800 Subject: mesa/main: Make FEATURE_evaluators follow feature conventions. As shown in mfeatures.h, this allows users of eval.h to work without knowing if the feature is available. It is renamed to FEATURE_eval along the way. --- src/mesa/main/api_exec.c | 18 +++-------------- src/mesa/main/api_noop.c | 18 ++++++----------- src/mesa/main/context.c | 6 ------ src/mesa/main/dlist.c | 19 +++++++----------- src/mesa/main/eval.c | 39 ++++++++++++++++++++++++++++++++++++ src/mesa/main/eval.h | 49 +++++++++++++++++++++++++++++++++++---------- src/mesa/main/mfeatures.h | 2 +- src/mesa/main/vtxfmt.c | 13 ++++-------- src/mesa/vbo/vbo_exec_api.c | 17 ++++++++-------- src/mesa/vbo/vbo_save_api.c | 11 +++------- 10 files changed, 109 insertions(+), 83 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c index 3fe10f1207..fc4de3c14c 100644 --- a/src/mesa/main/api_exec.c +++ b/src/mesa/main/api_exec.c @@ -60,9 +60,7 @@ #include "drawpix.h" #include "rastpos.h" #include "enable.h" -#if FEATURE_evaluators #include "eval.h" -#endif #include "get.h" #include "feedback.h" #include "fog.h" @@ -238,19 +236,9 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_Lighti(exec, _mesa_Lighti); SET_Lightiv(exec, _mesa_Lightiv); SET_LoadMatrixd(exec, _mesa_LoadMatrixd); -#if FEATURE_evaluators - SET_GetMapdv(exec, _mesa_GetMapdv); - SET_GetMapfv(exec, _mesa_GetMapfv); - SET_GetMapiv(exec, _mesa_GetMapiv); - SET_Map1d(exec, _mesa_Map1d); - SET_Map1f(exec, _mesa_Map1f); - SET_Map2d(exec, _mesa_Map2d); - SET_Map2f(exec, _mesa_Map2f); - SET_MapGrid1d(exec, _mesa_MapGrid1d); - SET_MapGrid1f(exec, _mesa_MapGrid1f); - SET_MapGrid2d(exec, _mesa_MapGrid2d); - SET_MapGrid2f(exec, _mesa_MapGrid2f); -#endif + + _mesa_init_eval_dispatch(exec); + SET_MultMatrixd(exec, _mesa_MultMatrixd); _mesa_init_pixel_dispatch(exec); diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index 162b685b02..f9ec69b511 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -33,6 +33,7 @@ #if FEATURE_dlist #include "dlist.h" #endif +#include "eval.h" #include "glapi/dispatch.h" @@ -624,7 +625,7 @@ static void GLAPIENTRY _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLf } -#if FEATURE_evaluators +#if FEATURE_eval /* Similarly, these have no effect outside begin/end: */ static void GLAPIENTRY _mesa_noop_EvalCoord1f( GLfloat a ) @@ -656,7 +657,7 @@ static void GLAPIENTRY _mesa_noop_EvalPoint2( GLint a, GLint b ) { (void) a; (void) b; } -#endif /* FEATURE_evaluators */ +#endif /* FEATURE_eval */ /* Begin -- call into driver, should result in the vtxfmt being @@ -1005,14 +1006,9 @@ _mesa_noop_vtxfmt_init( GLvertexformat *vfmt ) vfmt->Color4fv = _mesa_noop_Color4fv; vfmt->EdgeFlag = _mesa_noop_EdgeFlag; vfmt->End = _mesa_noop_End; -#if FEATURE_evaluators - vfmt->EvalCoord1f = _mesa_noop_EvalCoord1f; - vfmt->EvalCoord1fv = _mesa_noop_EvalCoord1fv; - vfmt->EvalCoord2f = _mesa_noop_EvalCoord2f; - vfmt->EvalCoord2fv = _mesa_noop_EvalCoord2fv; - vfmt->EvalPoint1 = _mesa_noop_EvalPoint1; - vfmt->EvalPoint2 = _mesa_noop_EvalPoint2; -#endif + + _MESA_INIT_EVAL_VTXFMT(vfmt, _mesa_noop_); + vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT; vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT; vfmt->Indexf = _mesa_noop_Indexf; @@ -1070,6 +1066,4 @@ _mesa_noop_vtxfmt_init( GLvertexformat *vfmt ) vfmt->DrawElementsBaseVertex = _mesa_noop_DrawElementsBaseVertex; vfmt->DrawRangeElementsBaseVertex = _mesa_noop_DrawRangeElementsBaseVertex; vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex; - vfmt->EvalMesh1 = _mesa_noop_EvalMesh1; - vfmt->EvalMesh2 = _mesa_noop_EvalMesh2; } diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 6994f98504..03ee7fb04d 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -94,9 +94,7 @@ #if FEATURE_dlist #include "dlist.h" #endif -#if FEATURE_evaluators #include "eval.h" -#endif #include "enums.h" #include "extensions.h" #include "fbobject.h" @@ -675,9 +673,7 @@ init_attrib_groups(GLcontext *ctx) #if FEATURE_dlist _mesa_init_display_list( ctx ); #endif -#if FEATURE_evaluators _mesa_init_eval( ctx ); -#endif _mesa_init_fbobjects( ctx ); _mesa_init_feedback( ctx ); _mesa_init_fog( ctx ); @@ -977,9 +973,7 @@ _mesa_free_context_data( GLcontext *ctx ) _mesa_free_attrib_data(ctx); _mesa_free_lighting_data( ctx ); -#if FEATURE_evaluators _mesa_free_eval_data( ctx ); -#endif _mesa_free_texture_data( ctx ); _mesa_free_matrix_data( ctx ); _mesa_free_viewport_data( ctx ); diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 25a2819783..b0dcfe9055 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -1824,7 +1824,7 @@ save_Enable(GLenum cap) static void GLAPIENTRY -_mesa_save_EvalMesh1(GLenum mode, GLint i1, GLint i2) +save_EvalMesh1(GLenum mode, GLint i1, GLint i2) { GET_CURRENT_CONTEXT(ctx); Node *n; @@ -1842,7 +1842,7 @@ _mesa_save_EvalMesh1(GLenum mode, GLint i1, GLint i2) static void GLAPIENTRY -_mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) +save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) { GET_CURRENT_CONTEXT(ctx); Node *n; @@ -7820,8 +7820,8 @@ _mesa_init_dlist_table(struct _glapi_table *table) SET_DrawPixels(table, save_DrawPixels); SET_Enable(table, save_Enable); SET_EndList(table, _mesa_EndList); - SET_EvalMesh1(table, _mesa_save_EvalMesh1); - SET_EvalMesh2(table, _mesa_save_EvalMesh2); + SET_EvalMesh1(table, save_EvalMesh1); + SET_EvalMesh2(table, save_EvalMesh2); SET_Finish(table, exec_Finish); SET_Flush(table, exec_Flush); SET_Fogf(table, save_Fogf); @@ -8643,12 +8643,9 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt) vfmt->Color4fv = save_Color4fv; vfmt->EdgeFlag = save_EdgeFlag; vfmt->End = save_End; - vfmt->EvalCoord1f = save_EvalCoord1f; - vfmt->EvalCoord1fv = save_EvalCoord1fv; - vfmt->EvalCoord2f = save_EvalCoord2f; - vfmt->EvalCoord2fv = save_EvalCoord2fv; - vfmt->EvalPoint1 = save_EvalPoint1; - vfmt->EvalPoint2 = save_EvalPoint2; + + _MESA_INIT_EVAL_VTXFMT(vfmt, save_); + vfmt->FogCoordfEXT = save_FogCoordfEXT; vfmt->FogCoordfvEXT = save_FogCoordfvEXT; vfmt->Indexf = save_Indexf; @@ -8697,8 +8694,6 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt) vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB; vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB; - vfmt->EvalMesh1 = _mesa_save_EvalMesh1; - vfmt->EvalMesh2 = _mesa_save_EvalMesh2; vfmt->Rectf = save_Rectf; /* The driver is required to implement these as diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c index 3f89f9c1ea..47f99270ce 100644 --- a/src/mesa/main/eval.c +++ b/src/mesa/main/eval.c @@ -44,6 +44,10 @@ #include "eval.h" #include "macros.h" #include "mtypes.h" +#include "glapi/dispatch.h" + + +#if FEATURE_eval /* @@ -797,6 +801,41 @@ _mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, } +void +_mesa_install_eval_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_EvalCoord1f(disp, vfmt->EvalCoord1f); + SET_EvalCoord1fv(disp, vfmt->EvalCoord1fv); + SET_EvalCoord2f(disp, vfmt->EvalCoord2f); + SET_EvalCoord2fv(disp, vfmt->EvalCoord2fv); + SET_EvalPoint1(disp, vfmt->EvalPoint1); + SET_EvalPoint2(disp, vfmt->EvalPoint2); + + SET_EvalMesh1(disp, vfmt->EvalMesh1); + SET_EvalMesh2(disp, vfmt->EvalMesh2); +} + + +void +_mesa_init_eval_dispatch(struct _glapi_table *disp) +{ + SET_GetMapdv(disp, _mesa_GetMapdv); + SET_GetMapfv(disp, _mesa_GetMapfv); + SET_GetMapiv(disp, _mesa_GetMapiv); + SET_Map1d(disp, _mesa_Map1d); + SET_Map1f(disp, _mesa_Map1f); + SET_Map2d(disp, _mesa_Map2d); + SET_Map2f(disp, _mesa_Map2f); + SET_MapGrid1d(disp, _mesa_MapGrid1d); + SET_MapGrid1f(disp, _mesa_MapGrid1f); + SET_MapGrid2d(disp, _mesa_MapGrid2d); + SET_MapGrid2f(disp, _mesa_MapGrid2f); +} + + +#endif /* FEATURE_eval */ + /**********************************************************************/ /***** Initialization *****/ diff --git a/src/mesa/main/eval.h b/src/mesa/main/eval.h index b3ff0a96f8..49fd37a057 100644 --- a/src/mesa/main/eval.h +++ b/src/mesa/main/eval.h @@ -37,13 +37,22 @@ #define EVAL_H -#include "mtypes.h" +#include "main/mtypes.h" -#if _HAVE_FULL_GL -extern void _mesa_init_eval( GLcontext *ctx ); -extern void _mesa_free_eval_data( GLcontext *ctx ); +#if FEATURE_eval +#define _MESA_INIT_EVAL_VTXFMT(vfmt, impl) \ + do { \ + (vfmt)->EvalCoord1f = impl ## EvalCoord1f; \ + (vfmt)->EvalCoord1fv = impl ## EvalCoord1fv; \ + (vfmt)->EvalCoord2f = impl ## EvalCoord2f; \ + (vfmt)->EvalCoord2fv = impl ## EvalCoord2fv; \ + (vfmt)->EvalPoint1 = impl ## EvalPoint1; \ + (vfmt)->EvalPoint2 = impl ## EvalPoint2; \ + (vfmt)->EvalMesh1 = impl ## EvalMesh1; \ + (vfmt)->EvalMesh2 = impl ## EvalMesh2; \ + } while (0) extern GLuint _mesa_evaluator_components( GLenum target ); @@ -115,14 +124,32 @@ _mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ); extern void GLAPIENTRY _mesa_GetMapiv( GLenum target, GLenum query, GLint *v ); -#else +extern void +_mesa_install_eval_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt); + +extern void +_mesa_init_eval_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_eval */ + +#define _MESA_INIT_EVAL_VTXFMT(vfmt, impl) do { } while (0) -/** No-op */ -#define _mesa_init_eval( c ) ((void)0) +static INLINE void +_mesa_install_eval_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ +} -/** No-op */ -#define _mesa_free_eval_data( c ) ((void)0) +static INLINE void +_mesa_init_eval_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_eval */ + +extern void _mesa_init_eval( GLcontext *ctx ); +extern void _mesa_free_eval_data( GLcontext *ctx ); -#endif -#endif +#endif /* EVAL_H */ diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h index cd39f5bd24..a89b760774 100644 --- a/src/mesa/main/mfeatures.h +++ b/src/mesa/main/mfeatures.h @@ -78,7 +78,7 @@ #define FEATURE_dlist (_HAVE_FULL_GL && FEATURE_arrayelt) #define FEATURE_draw_read_buffer _HAVE_FULL_GL #define FEATURE_drawpix _HAVE_FULL_GL -#define FEATURE_evaluators _HAVE_FULL_GL +#define FEATURE_eval _HAVE_FULL_GL #define FEATURE_feedback _HAVE_FULL_GL #define FEATURE_fixedpt 0 #define FEATURE_histogram _HAVE_FULL_GL diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c index de9479d6b0..c35e4dabe3 100644 --- a/src/mesa/main/vtxfmt.c +++ b/src/mesa/main/vtxfmt.c @@ -34,6 +34,7 @@ #include "mtypes.h" #include "state.h" #include "vtxfmt.h" +#include "eval.h" /* The neutral vertex format. This wraps all tnl module functions, @@ -90,12 +91,9 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) SET_Color4f(tab, vfmt->Color4f); SET_Color4fv(tab, vfmt->Color4fv); SET_EdgeFlag(tab, vfmt->EdgeFlag); - SET_EvalCoord1f(tab, vfmt->EvalCoord1f); - SET_EvalCoord1fv(tab, vfmt->EvalCoord1fv); - SET_EvalCoord2f(tab, vfmt->EvalCoord2f); - SET_EvalCoord2fv(tab, vfmt->EvalCoord2fv); - SET_EvalPoint1(tab, vfmt->EvalPoint1); - SET_EvalPoint2(tab, vfmt->EvalPoint2); + + _mesa_install_eval_vtxfmt(tab, vfmt); + SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT); SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT); SET_Indexf(tab, vfmt->Indexf); @@ -139,9 +137,6 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) SET_DrawElementsBaseVertex(tab, vfmt->DrawElementsBaseVertex); SET_DrawRangeElementsBaseVertex(tab, vfmt->DrawRangeElementsBaseVertex); SET_MultiDrawElementsBaseVertex(tab, vfmt->MultiDrawElementsBaseVertex); - SET_EvalMesh1(tab, vfmt->EvalMesh1); - SET_EvalMesh2(tab, vfmt->EvalMesh2); - ASSERT(tab->EvalMesh2); /* GL_NV_vertex_program */ SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 238beee030..27baebe3a7 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -38,6 +38,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #if FEATURE_dlist #include "main/dlist.h" #endif +#include "main/eval.h" #include "main/state.h" #include "main/light.h" #include "main/api_arrayelt.h" @@ -392,6 +393,7 @@ do { \ +#if FEATURE_eval /* Eval */ static void GLAPIENTRY vbo_exec_EvalCoord1f( GLfloat u ) @@ -484,6 +486,7 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j ) vbo_exec_EvalCoord2f( u, v ); } +#endif /* FEATURE_eval */ /* Build a list of primitives on the fly. Keep @@ -565,17 +568,13 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) vfmt->CallLists = _mesa_CallLists; #endif vfmt->End = vbo_exec_End; - vfmt->EvalCoord1f = vbo_exec_EvalCoord1f; - vfmt->EvalCoord1fv = vbo_exec_EvalCoord1fv; - vfmt->EvalCoord2f = vbo_exec_EvalCoord2f; - vfmt->EvalCoord2fv = vbo_exec_EvalCoord2fv; - vfmt->EvalPoint1 = vbo_exec_EvalPoint1; - vfmt->EvalPoint2 = vbo_exec_EvalPoint2; - vfmt->Rectf = _mesa_noop_Rectf; - vfmt->EvalMesh1 = _mesa_noop_EvalMesh1; - vfmt->EvalMesh2 = _mesa_noop_EvalMesh2; + /* use noop eval mesh */ +#define vbo_exec_EvalMesh1 _mesa_noop_EvalMesh1 +#define vbo_exec_EvalMesh2 _mesa_noop_EvalMesh2 + _MESA_INIT_EVAL_VTXFMT(vfmt, vbo_exec_); + vfmt->Rectf = _mesa_noop_Rectf; /* from attrib_tmp.h: */ diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 6e11344380..611460dc7b 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -72,6 +72,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/context.h" #include "main/dlist.h" #include "main/enums.h" +#include "main/eval.h" #include "main/macros.h" #include "main/api_noop.h" #include "main/api_validate.h" @@ -1050,18 +1051,12 @@ static void _save_vtxfmt_init( GLcontext *ctx ) */ vfmt->CallList = _save_CallList; /* inside begin/end */ vfmt->CallLists = _save_CallLists; /* inside begin/end */ - vfmt->EvalCoord1f = _save_EvalCoord1f; - vfmt->EvalCoord1fv = _save_EvalCoord1fv; - vfmt->EvalCoord2f = _save_EvalCoord2f; - vfmt->EvalCoord2fv = _save_EvalCoord2fv; - vfmt->EvalPoint1 = _save_EvalPoint1; - vfmt->EvalPoint2 = _save_EvalPoint2; + + _MESA_INIT_EVAL_VTXFMT(vfmt, _save_); /* These are all errors as we at least know we are in some sort of * begin/end pair: */ - vfmt->EvalMesh1 = _save_EvalMesh1; - vfmt->EvalMesh2 = _save_EvalMesh2; vfmt->Begin = _save_Begin; vfmt->Rectf = _save_Rectf; vfmt->DrawArrays = _save_DrawArrays; -- cgit v1.2.3 From 1c497bd4c652de95deaaed0c704c3b776b69aded Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 9 Sep 2009 15:00:08 +0800 Subject: mesa/main: Make FEATURE_dlist follow feature conventions. As shown in mfeatures.h, this allows users of dlist.h to work without knowing if the feature is available. --- src/mesa/main/api_exec.c | 13 +-------- src/mesa/main/api_noop.c | 9 ++---- src/mesa/main/context.c | 10 ++----- src/mesa/main/dlist.c | 40 +++++++++++++++++++++++-- src/mesa/main/dlist.h | 71 +++++++++++++++++++++++++++++++++------------ src/mesa/main/shared.c | 4 --- src/mesa/main/vtxfmt.c | 9 ++++-- src/mesa/vbo/vbo_exec_api.c | 8 ++--- src/mesa/vbo/vbo_save_api.c | 3 +- 9 files changed, 107 insertions(+), 60 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c index fc4de3c14c..1559984f43 100644 --- a/src/mesa/main/api_exec.c +++ b/src/mesa/main/api_exec.c @@ -54,9 +54,7 @@ #include "context.h" #include "convolve.h" #include "depth.h" -#if FEATURE_dlist #include "dlist.h" -#endif #include "drawpix.h" #include "rastpos.h" #include "enable.h" @@ -179,17 +177,8 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_Viewport(exec, _mesa_Viewport); _mesa_init_accum_dispatch(exec); + _mesa_init_dlist_dispatch(exec); -#if FEATURE_dlist - SET_CallList(exec, _mesa_CallList); - SET_CallLists(exec, _mesa_CallLists); - SET_DeleteLists(exec, _mesa_DeleteLists); - SET_EndList(exec, _mesa_EndList); - SET_GenLists(exec, _mesa_GenLists); - SET_IsList(exec, _mesa_IsList); - SET_ListBase(exec, _mesa_ListBase); - SET_NewList(exec, _mesa_NewList); -#endif SET_ClearDepth(exec, _mesa_ClearDepth); SET_ClearIndex(exec, _mesa_ClearIndex); SET_ClipPlane(exec, _mesa_ClipPlane); diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index f9ec69b511..a30c47da77 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -30,9 +30,7 @@ #include "context.h" #include "light.h" #include "macros.h" -#if FEATURE_dlist #include "dlist.h" -#endif #include "eval.h" #include "glapi/dispatch.h" @@ -996,10 +994,9 @@ _mesa_noop_vtxfmt_init( GLvertexformat *vfmt ) _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); vfmt->Begin = _mesa_noop_Begin; -#if FEATURE_dlist - vfmt->CallList = _mesa_CallList; - vfmt->CallLists = _mesa_CallLists; -#endif + + _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_); + vfmt->Color3f = _mesa_noop_Color3f; vfmt->Color3fv = _mesa_noop_Color3fv; vfmt->Color4f = _mesa_noop_Color4f; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 03ee7fb04d..2869a722ec 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -91,9 +91,7 @@ #include "cpuinfo.h" #include "debug.h" #include "depth.h" -#if FEATURE_dlist #include "dlist.h" -#endif #include "eval.h" #include "enums.h" #include "extensions.h" @@ -670,9 +668,7 @@ init_attrib_groups(GLcontext *ctx) _mesa_init_current( ctx ); _mesa_init_depth( ctx ); _mesa_init_debug( ctx ); -#if FEATURE_dlist _mesa_init_display_list( ctx ); -#endif _mesa_init_eval( ctx ); _mesa_init_fbobjects( ctx ); _mesa_init_feedback( ctx ); @@ -869,10 +865,10 @@ _mesa_initialize_context(GLcontext *ctx, _mesa_init_exec_table(ctx->Exec); #endif ctx->CurrentDispatch = ctx->Exec; -#if FEATURE_dlist - _mesa_init_dlist_table(ctx->Save); + + _mesa_init_save_table(ctx->Save); _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); -#endif + /* Neutral tnl module stuff */ _mesa_init_exec_vtxfmt( ctx ); ctx->TnlModule.Current = NULL; diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index b0dcfe9055..f793b60284 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -73,6 +73,7 @@ #include "texstate.h" #include "mtypes.h" #include "varray.h" +#include "vtxfmt.h" #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program #include "shader/arbprogram.h" #include "shader/program.h" @@ -410,6 +411,10 @@ typedef union gl_dlist_node Node; */ static GLuint InstSize[OPCODE_END_OF_LIST + 1]; + +#if FEATURE_dlist + + void mesa_print_display_list(GLuint list); @@ -7789,7 +7794,7 @@ exec_MultiModeDrawElementsIBM(const GLenum * mode, * struct. */ void -_mesa_init_dlist_table(struct _glapi_table *table) +_mesa_init_save_table(struct _glapi_table *table) { _mesa_loopback_init_api_table(table); @@ -8635,8 +8640,9 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt) _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); vfmt->Begin = save_Begin; - vfmt->CallList = _mesa_save_CallList; - vfmt->CallLists = _mesa_save_CallLists; + + _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_save_); + vfmt->Color3f = save_Color3f; vfmt->Color3fv = save_Color3fv; vfmt->Color4f = save_Color4f; @@ -8714,6 +8720,32 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt) } +void +_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_CallList(disp, vfmt->CallList); + SET_CallLists(disp, vfmt->CallLists); +} + + +void _mesa_init_dlist_dispatch(struct _glapi_table *disp) +{ + SET_CallList(disp, _mesa_CallList); + SET_CallLists(disp, _mesa_CallLists); + + SET_DeleteLists(disp, _mesa_DeleteLists); + SET_EndList(disp, _mesa_EndList); + SET_GenLists(disp, _mesa_GenLists); + SET_IsList(disp, _mesa_IsList); + SET_ListBase(disp, _mesa_ListBase); + SET_NewList(disp, _mesa_NewList); +} + + +#endif /* FEATURE_dlist */ + + /** * Initialize display list state for given context. */ @@ -8738,5 +8770,7 @@ _mesa_init_display_list(GLcontext *ctx) /* Display List group */ ctx->List.ListBase = 0; +#if FEATURE_dlist _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt); +#endif } diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h index ab7ec2c8db..6e1059eac2 100644 --- a/src/mesa/main/dlist.h +++ b/src/mesa/main/dlist.h @@ -33,13 +33,26 @@ #define DLIST_H -#include "mtypes.h" +#include "main/mtypes.h" -#if _HAVE_FULL_GL +#if FEATURE_dlist -extern void -_mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist); +#define _MESA_INIT_DLIST_FUNCTIONS(driver, impl) \ + do { \ + (driver)->NewList = impl ## NewList; \ + (driver)->EndList = impl ## EndList; \ + (driver)->BeginCallList = impl ## BeginCallList; \ + (driver)->EndCallList = impl ## EndCallList; \ + (driver)->SaveFlushVertices = impl ## SaveFlushVertices; \ + (driver)->NotifySaveBegin = impl ## NotifyBegin; \ + } while (0) + +#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) \ + do { \ + (vfmt)->CallList = impl ## CallList; \ + (vfmt)->CallLists = impl ## CallLists; \ + } while (0) extern void GLAPIENTRY _mesa_CallList( GLuint list ); @@ -62,12 +75,8 @@ extern void GLAPIENTRY _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoi extern void GLAPIENTRY _mesa_save_CallList( GLuint list ); - -extern void _mesa_init_dlist_table( struct _glapi_table *table ); - extern void _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s ); - extern void *_mesa_alloc_instruction(GLcontext *ctx, GLuint opcode, GLuint sz); extern GLint _mesa_alloc_opcode( GLcontext *ctx, GLuint sz, @@ -75,22 +84,48 @@ extern GLint _mesa_alloc_opcode( GLcontext *ctx, GLuint sz, void (*destroy)( GLcontext *, void * ), void (*print)( GLcontext *, void * ) ); -extern void _mesa_init_display_list( GLcontext * ctx ); +extern void _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist); extern void _mesa_save_vtxfmt_init( GLvertexformat *vfmt ); +extern void _mesa_init_save_table( struct _glapi_table *table ); + +extern void _mesa_install_dlist_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt); -#else +extern void _mesa_init_dlist_dispatch(struct _glapi_table *disp); -/** No-op */ -#define _mesa_init_dlist_table(t,ts) ((void)0) +#else /* FEATURE_dlist */ -/** No-op */ -#define _mesa_init_display_list(c) ((void)0) +#define _MESA_INIT_DLIST_FUNCTIONS(driver, impl) do { } while (0) +#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) do { } while (0) -/** No-op */ -#define _mesa_save_vtxfmt_init(v) ((void)0) +static INLINE void +_mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist) +{ + /* there should be no list to delete */ + ASSERT_NO_FEATURE(); +} + +static INLINE void +_mesa_init_save_table(struct _glapi_table *disp) +{ +} + +static INLINE void +_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ +} + +static INLINE void +_mesa_init_dlist_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_dlist */ + +extern void _mesa_init_display_list( GLcontext * ctx ); -#endif -#endif +#endif /* DLIST_H */ diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index 643ad3354e..4d01e8abc6 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -37,9 +37,7 @@ #include "shared.h" #include "shader/program.h" #include "shader/shader_api.h" -#if FEATURE_dlist #include "dlist.h" -#endif #if FEATURE_ATI_fragment_shader #include "shader/atifragshader.h" #endif @@ -143,11 +141,9 @@ _mesa_alloc_shared_state(GLcontext *ctx) static void delete_displaylist_cb(GLuint id, void *data, void *userData) { -#if FEATURE_dlist struct gl_display_list *list = (struct gl_display_list *) data; GLcontext *ctx = (GLcontext *) userData; _mesa_delete_list(ctx, list); -#endif } diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c index c35e4dabe3..8ba1af6de1 100644 --- a/src/mesa/main/vtxfmt.c +++ b/src/mesa/main/vtxfmt.c @@ -35,6 +35,7 @@ #include "state.h" #include "vtxfmt.h" #include "eval.h" +#include "dlist.h" /* The neutral vertex format. This wraps all tnl module functions, @@ -125,8 +126,9 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) SET_Vertex3fv(tab, vfmt->Vertex3fv); SET_Vertex4f(tab, vfmt->Vertex4f); SET_Vertex4fv(tab, vfmt->Vertex4fv); - SET_CallList(tab, vfmt->CallList); - SET_CallLists(tab, vfmt->CallLists); + + _mesa_install_dlist_vtxfmt(tab, vfmt); + SET_Begin(tab, vfmt->Begin); SET_End(tab, vfmt->End); SET_Rectf(tab, vfmt->Rectf); @@ -176,7 +178,10 @@ void _mesa_install_exec_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ) void _mesa_install_save_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ) { + /* vfmt is empty when dlist is disabled */ +#if FEATURE_dlist install_vtxfmt( ctx->Save, vfmt ); +#endif } diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 27baebe3a7..a81bd39eb1 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -35,9 +35,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/context.h" #include "main/macros.h" #include "main/vtxfmt.h" -#if FEATURE_dlist #include "main/dlist.h" -#endif #include "main/eval.h" #include "main/state.h" #include "main/light.h" @@ -563,12 +561,10 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); vfmt->Begin = vbo_exec_Begin; -#if FEATURE_dlist - vfmt->CallList = _mesa_CallList; - vfmt->CallLists = _mesa_CallLists; -#endif vfmt->End = vbo_exec_End; + _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_); + /* use noop eval mesh */ #define vbo_exec_EvalMesh1 _mesa_noop_EvalMesh1 #define vbo_exec_EvalMesh2 _mesa_noop_EvalMesh2 diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 611460dc7b..4da248e2b8 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1049,8 +1049,7 @@ static void _save_vtxfmt_init( GLcontext *ctx ) /* This will all require us to fallback to saving the list as opcodes: */ - vfmt->CallList = _save_CallList; /* inside begin/end */ - vfmt->CallLists = _save_CallLists; /* inside begin/end */ + _MESA_INIT_DLIST_VTXFMT(vfmt, _save_); /* inside begin/end */ _MESA_INIT_EVAL_VTXFMT(vfmt, _save_); -- cgit v1.2.3 From e6f4bc9d824223325f926cbe7ac1b6a55d2b3dba Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 12 Sep 2009 18:59:13 +0800 Subject: mesa: New feature FEATURE_beginend. This feature corresponds to the Begin/End paradigm. Disabling this feature also eliminates the use of GLvertexformat completely. --- src/mesa/main/api_loopback.c | 7 ++++ src/mesa/main/api_loopback.h | 14 ++++++- src/mesa/main/api_noop.c | 6 +++ src/mesa/main/api_noop.h | 9 +++-- src/mesa/main/mfeatures.h | 3 +- src/mesa/main/vtxfmt.c | 6 +++ src/mesa/main/vtxfmt.h | 29 +++++++++++++- src/mesa/vbo/vbo_exec.h | 18 +++++++++ src/mesa/vbo/vbo_exec_api.c | 94 +++++++++++++++++++++++++++++++++++++++++++- src/mesa/vbo/vbo_exec_draw.c | 6 +++ 10 files changed, 184 insertions(+), 8 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_api.c') diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c index 0e3f5ff957..3d466ac44a 100644 --- a/src/mesa/main/api_loopback.c +++ b/src/mesa/main/api_loopback.c @@ -77,6 +77,10 @@ #define FOGCOORDF(x) CALL_FogCoordfEXT(GET_DISPATCH(), (x)) #define SECONDARYCOLORF(a,b,c) CALL_SecondaryColor3fEXT(GET_DISPATCH(), (a,b,c)) + +#if FEATURE_beginend + + static void GLAPIENTRY loopback_Color3b_f( GLbyte red, GLbyte green, GLbyte blue ) { @@ -1655,3 +1659,6 @@ _mesa_loopback_init_api_table( struct _glapi_table *dest ) SET_VertexAttrib4NusvARB(dest, loopback_VertexAttrib4NusvARB); SET_VertexAttrib4NuivARB(dest, loopback_VertexAttrib4NuivARB); } + + +#endif /* FEATURE_beginend */ diff --git a/src/mesa/main/api_loopback.h b/src/mesa/main/api_loopback.h index 6f85bbc1d9..751cba2931 100644 --- a/src/mesa/main/api_loopback.h +++ b/src/mesa/main/api_loopback.h @@ -27,11 +27,21 @@ #ifndef API_LOOPBACK_H #define API_LOOPBACK_H -#include "glheader.h" +#include "main/mtypes.h" +#if FEATURE_beginend struct _glapi_table; extern void _mesa_loopback_init_api_table( struct _glapi_table *dest ); -#endif +#else /* FEATURE_beginend */ + +static INLINE void +_mesa_loopback_init_api_table( struct _glapi_table *dest ) +{ +} + +#endif /* FEATURE_beginend */ + +#endif /* API_LOOPBACK_H */ diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index a30c47da77..cd67661382 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -43,6 +43,9 @@ */ +#if FEATURE_beginend + + static void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b ) { GET_CURRENT_CONTEXT(ctx); @@ -1064,3 +1067,6 @@ _mesa_noop_vtxfmt_init( GLvertexformat *vfmt ) vfmt->DrawRangeElementsBaseVertex = _mesa_noop_DrawRangeElementsBaseVertex; vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex; } + + +#endif /* FEATURE_beginend */ diff --git a/src/mesa/main/api_noop.h b/src/mesa/main/api_noop.h index 1150984d64..e7fd49bafb 100644 --- a/src/mesa/main/api_noop.h +++ b/src/mesa/main/api_noop.h @@ -25,8 +25,9 @@ #ifndef _API_NOOP_H #define _API_NOOP_H -#include "mtypes.h" -#include "context.h" +#include "main/mtypes.h" + +#if FEATURE_beginend extern void GLAPIENTRY _mesa_noop_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); @@ -54,4 +55,6 @@ _mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, extern void _mesa_noop_vtxfmt_init(GLvertexformat *vfmt); -#endif +#endif /* FEATURE_beginend */ + +#endif /* _API_NOOP_H */ diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h index a89b760774..02083ecc3b 100644 --- a/src/mesa/main/mfeatures.h +++ b/src/mesa/main/mfeatures.h @@ -75,7 +75,7 @@ #define FEATURE_colortable _HAVE_FULL_GL #define FEATURE_convolve _HAVE_FULL_GL #define FEATURE_dispatch _HAVE_FULL_GL -#define FEATURE_dlist (_HAVE_FULL_GL && FEATURE_arrayelt) +#define FEATURE_dlist (_HAVE_FULL_GL && FEATURE_arrayelt && FEATURE_beginend) #define FEATURE_draw_read_buffer _HAVE_FULL_GL #define FEATURE_drawpix _HAVE_FULL_GL #define FEATURE_eval _HAVE_FULL_GL @@ -90,6 +90,7 @@ #define FEATURE_texture_fxt1 _HAVE_FULL_GL #define FEATURE_texture_s3tc _HAVE_FULL_GL #define FEATURE_userclip _HAVE_FULL_GL +#define FEATURE_beginend _HAVE_FULL_GL #define FEATURE_vertex_array_byte 0 #define FEATURE_es2_glsl 0 diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c index 8ba1af6de1..6e0581f62d 100644 --- a/src/mesa/main/vtxfmt.c +++ b/src/mesa/main/vtxfmt.c @@ -38,6 +38,9 @@ #include "dlist.h" +#if FEATURE_beginend + + /* The neutral vertex format. This wraps all tnl module functions, * verifying that the currently-installed module is valid and then * installing the function pointers in a lazy fashion. It records the @@ -198,3 +201,6 @@ void _mesa_restore_exec_vtxfmt( GLcontext *ctx ) tnl->SwapCount = 0; } + + +#endif /* FEATURE_beginend */ diff --git a/src/mesa/main/vtxfmt.h b/src/mesa/main/vtxfmt.h index 76f108e023..819a6ec218 100644 --- a/src/mesa/main/vtxfmt.h +++ b/src/mesa/main/vtxfmt.h @@ -33,6 +33,8 @@ #ifndef _VTXFMT_H_ #define _VTXFMT_H_ +#if FEATURE_beginend + extern void _mesa_init_exec_vtxfmt( GLcontext *ctx ); extern void _mesa_install_exec_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ); @@ -40,4 +42,29 @@ extern void _mesa_install_save_vtxfmt( GLcontext *ctx, const GLvertexformat *vfm extern void _mesa_restore_exec_vtxfmt( GLcontext *ctx ); -#endif +#else /* FEATURE_beginend */ + +static INLINE void +_mesa_init_exec_vtxfmt( GLcontext *ctx ) +{ +} + +static INLINE void +_mesa_install_exec_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ) +{ +} + +static INLINE void +_mesa_install_save_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt ) +{ +} + + +static INLINE void +_mesa_restore_exec_vtxfmt( GLcontext *ctx ) +{ +} + +#endif /* FEATURE_beginend */ + +#endif /* _VTXFMT_H_ */ diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index e0f44892cf..516be0995b 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -161,8 +161,26 @@ void vbo_exec_array_destroy( struct vbo_exec_context *exec ); void vbo_exec_vtx_init( struct vbo_exec_context *exec ); void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ); + +#if FEATURE_beginend + void vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ); void vbo_exec_vtx_map( struct vbo_exec_context *exec ); + +#else /* FEATURE_beginend */ + +static INLINE void +vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ) +{ +} + +static INLINE void +vbo_exec_vtx_map( struct vbo_exec_context *exec ) +{ +} + +#endif /* FEATURE_beginend */ + void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ); void vbo_exec_eval_update( struct vbo_exec_context *exec ); diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index a81bd39eb1..d105183bac 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -348,7 +348,7 @@ static void vbo_exec_fixup_vertex( GLcontext *ctx, } - +#if FEATURE_beginend /* */ @@ -634,6 +634,98 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) } +#else /* FEATURE_beginend */ + + +#define ATTR( A, N, V0, V1, V2, V3 ) \ +do { \ + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \ + \ + /* FLUSH_UPDATE_CURRENT needs to be set manually */ \ + exec->ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \ + \ + if (exec->vtx.active_sz[A] != N) \ + vbo_exec_fixup_vertex(ctx, A, N); \ + \ + { \ + GLfloat *dest = exec->vtx.attrptr[A]; \ + if (N>0) dest[0] = V0; \ + if (N>1) dest[1] = V1; \ + if (N>2) dest[2] = V2; \ + if (N>3) dest[3] = V3; \ + } \ +} while (0) + +#define ERROR() _mesa_error( ctx, GL_INVALID_ENUM, __FUNCTION__ ) +#define TAG(x) vbo_##x + +#include "vbo_attrib_tmp.h" + +static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) +{ + /* silence warnings */ + (void) vbo_Color3f; + (void) vbo_Color3fv; + (void) vbo_Color4f; + (void) vbo_Color4fv; + (void) vbo_FogCoordfEXT; + (void) vbo_FogCoordfvEXT; + (void) vbo_MultiTexCoord1f; + (void) vbo_MultiTexCoord1fv; + (void) vbo_MultiTexCoord2f; + (void) vbo_MultiTexCoord2fv; + (void) vbo_MultiTexCoord3f; + (void) vbo_MultiTexCoord3fv; + (void) vbo_MultiTexCoord4f; + (void) vbo_MultiTexCoord4fv; + (void) vbo_Normal3f; + (void) vbo_Normal3fv; + (void) vbo_SecondaryColor3fEXT; + (void) vbo_SecondaryColor3fvEXT; + (void) vbo_TexCoord1f; + (void) vbo_TexCoord1fv; + (void) vbo_TexCoord2f; + (void) vbo_TexCoord2fv; + (void) vbo_TexCoord3f; + (void) vbo_TexCoord3fv; + (void) vbo_TexCoord4f; + (void) vbo_TexCoord4fv; + (void) vbo_Vertex2f; + (void) vbo_Vertex2fv; + (void) vbo_Vertex3f; + (void) vbo_Vertex3fv; + (void) vbo_Vertex4f; + (void) vbo_Vertex4fv; + + (void) vbo_VertexAttrib1fARB; + (void) vbo_VertexAttrib1fvARB; + (void) vbo_VertexAttrib2fARB; + (void) vbo_VertexAttrib2fvARB; + (void) vbo_VertexAttrib3fARB; + (void) vbo_VertexAttrib3fvARB; + (void) vbo_VertexAttrib4fARB; + (void) vbo_VertexAttrib4fvARB; + + (void) vbo_VertexAttrib1fNV; + (void) vbo_VertexAttrib1fvNV; + (void) vbo_VertexAttrib2fNV; + (void) vbo_VertexAttrib2fvNV; + (void) vbo_VertexAttrib3fNV; + (void) vbo_VertexAttrib3fvNV; + (void) vbo_VertexAttrib4fNV; + (void) vbo_VertexAttrib4fvNV; + + (void) vbo_Materialfv; + + (void) vbo_EdgeFlag; + (void) vbo_Indexf; + (void) vbo_Indexfv; +} + + +#endif /* FEATURE_beginend */ + + /** * Tell the VBO module to use a real OpenGL vertex buffer object to * store accumulated immediate-mode vertex data. diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 0c258c535e..ee148df4a1 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -35,6 +35,9 @@ #include "vbo_context.h" +#if FEATURE_beginend + + static void vbo_exec_debug_verts( struct vbo_exec_context *exec ) { @@ -411,3 +414,6 @@ vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ) exec->vtx.prim_count = 0; exec->vtx.vert_count = 0; } + + +#endif /* FEATURE_beginend */ -- cgit v1.2.3