From fd12b37dbada6f945a94b93ecf332d0b6a8eef06 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 29 Oct 2006 09:46:11 +0000 Subject: Checkpoint of new vbo-building code. Currently builds regular arrays rather than VBO's - VBOs are easy but need to look closer at the driver interface. The trivial/tri demo works. --- src/mesa/vbo/vbo_exec_array.c | 367 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 367 insertions(+) create mode 100644 src/mesa/vbo/vbo_exec_array.c (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c new file mode 100644 index 0000000000..5cfa7a01a9 --- /dev/null +++ b/src/mesa/vbo/vbo_exec_array.c @@ -0,0 +1,367 @@ +/************************************************************************** + * + * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#include "glheader.h" +#include "context.h" +#include "state.h" +#include "api_validate.h" +#include "api_noop.h" +#include "dispatch.h" + +#include "vbo_context.h" + +static GLuint get_max_index( GLuint count, GLuint type, + const GLvoid *indices ) +{ + GLint i; + + /* Compute max element. This is only needed for upload of non-VBO, + * non-constant data elements. + * + * XXX: Postpone this calculation until it is known that it is + * needed. Otherwise could scan this pointlessly in the all-vbo + * case. + */ + switch(type) { + case GL_UNSIGNED_INT: { + const GLuint *ui_indices = (const GLuint *)indices; + GLuint max_ui = 0; + for (i = 0; i < count; i++) + if (ui_indices[i] > max_ui) + max_ui = ui_indices[i]; + return max_ui; + } + case GL_UNSIGNED_SHORT: { + const GLushort *us_indices = (const GLushort *)indices; + GLuint max_us = 0; + for (i = 0; i < count; i++) + if (us_indices[i] > max_us) + max_us = us_indices[i]; + return max_us; + } + case GL_UNSIGNED_BYTE: { + const GLubyte *ub_indices = (const GLubyte *)indices; + GLuint max_ub = 0; + for (i = 0; i < count; i++) + if (ub_indices[i] > max_ub) + max_ub = ub_indices[i]; + return max_ub; + } + default: + return 0; + } +} + + +/* Just translate the arrayobj into a sane layout. + */ +static void bind_array_obj( GLcontext *ctx ) +{ + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + GLuint i; + + /* TODO: Fix the ArrayObj struct to keep legacy arrays in an array + * rather than as individual named arrays. Then this function can + * go away. + */ + exec->array.legacy_array[VERT_ATTRIB_POS] = &ctx->Array.ArrayObj->Vertex; + exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &ctx->Array.ArrayObj->Normal; + exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &ctx->Array.ArrayObj->Color; + exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &ctx->Array.ArrayObj->SecondaryColor; + exec->array.legacy_array[VERT_ATTRIB_FOG] = &ctx->Array.ArrayObj->FogCoord; + exec->array.legacy_array[VERT_ATTRIB_COLOR_INDEX] = &ctx->Array.ArrayObj->Index; + exec->array.legacy_array[VBO_ATTRIB_EDGEFLAG] = &ctx->Array.ArrayObj->EdgeFlag; + + for (i = 0; i < 8; i++) + exec->array.legacy_array[VBO_ATTRIB_TEX0 + i] = &ctx->Array.ArrayObj->TexCoord[i]; + + for (i = 0; i < VERT_ATTRIB_MAX; i++) + exec->array.generic_array[i] = &ctx->Array.ArrayObj->VertexAttrib[i]; + + exec->array.array_obj = ctx->Array.ArrayObj->Name; +} + +static void recalculate_input_bindings( GLcontext *ctx ) +{ + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + const struct gl_client_array **inputs = &exec->array.inputs[0]; + GLuint i; + + exec->array.program_mode = get_program_mode(ctx); + exec->array.enabled_flags = ctx->Array.ArrayObj->_Enabled; + + /* TODO: Get rid of NV_program (please!). + */ + switch (exec->array.program_mode) { + case VP_NONE: + /* When no vertex program is active, we put the material values + * into the generic slots. This is the only situation where + * material values are available as per-vertex attributes. + */ + for (i = 0; i <= VERT_ATTRIB_TEX7; i++) { + if (exec->array.legacy_array[i]->Enabled) + inputs[i] = exec->array.legacy_array[i]; + else + inputs[i] = &exec->legacy_currval[i]; + } + + for (i = 0; i < MAT_ATTRIB_MAX; i++) { + inputs[VERT_ATTRIB_GENERIC0 + i] = &exec->mat_currval[i]; + } + break; + case VP_NV: + /* NV_vertex_program - attribute arrays alias and override + * conventional, legacy arrays. No materials, and the generic + * slots are vacant. + */ + for (i = 0; i <= VERT_ATTRIB_TEX7; i++) { + if (exec->array.generic_array[i]->Enabled) + inputs[i] = exec->array.generic_array[i]; + else if (exec->array.legacy_array[i]->Enabled) + inputs[i] = exec->array.legacy_array[i]; + else + inputs[i] = &exec->legacy_currval[i]; + } + break; + case VP_ARB: + /* ARB_vertex_program - Only the attribute zero (position) array + * aliases and overrides the legacy position array. + * + * Otherwise, legacy attributes available in the legacy slots, + * generic attributes in the generic slots and materials are not + * available as per-vertex attributes. + */ + if (exec->array.generic_array[0]->Enabled) + inputs[0] = exec->array.generic_array[0]; + else if (exec->array.legacy_array[0]->Enabled) + inputs[0] = exec->array.legacy_array[0]; + else + inputs[0] = &exec->legacy_currval[0]; + + + for (i = 1; i <= VERT_ATTRIB_TEX7; i++) { + if (exec->array.legacy_array[i]->Enabled) + inputs[i] = exec->array.legacy_array[i]; + else + inputs[i] = &exec->legacy_currval[i]; + } + + for (i = 0; i < 16; i++) { + if (exec->array.generic_array[0]->Enabled) + inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i]; + else + inputs[VERT_ATTRIB_GENERIC0 + i] = &exec->generic_currval[i]; + } + break; + } +} + +static void bind_arrays( GLcontext *ctx ) +{ +#if 0 + if (ctx->Array.ArrayObj.Name != exec->array.array_obj) { + bind_array_obj(ctx); + recalculate_input_bindings(ctx); + } + else if (exec->array.program_mode != get_program_mode(ctx) || + exec->array.enabled_flags != ctx->Array.ArrayObj->_Enabled) { + + recalculate_input_bindings(ctx); + } +#else + bind_array_obj(ctx); + recalculate_input_bindings(ctx); +#endif +} + + + +/*********************************************************************** + * API functions. + */ + +static void GLAPIENTRY +vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) +{ + GET_CURRENT_CONTEXT(ctx); + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; + struct _mesa_prim prim[1]; + + if (!_mesa_validate_DrawArrays( ctx, mode, start, count )) + return; + + FLUSH_CURRENT( ctx, 0 ); + + if (ctx->NewState) + _mesa_update_state( ctx ); + + bind_arrays( ctx ); + + prim[0].begin = 1; + prim[0].end = 1; + prim[0].weak = 0; + prim[0].pad = 0; + + if (exec->array.inputs[0]->BufferObj->Name) { + /* Use vertex attribute as a hint to tell us if we expect all + * arrays to be in VBO's and if so, don't worry about avoiding + * the upload of elements < start. + */ + prim[0].mode = mode; + prim[0].start = start; + prim[0].count = count; + prim[0].indexed = 0; + + vbo->draw_prims( ctx, exec->array.inputs, prim, 1, NULL, 0, start + count ); + } + else { + /* If not using VBO's, we don't want to upload any more elements + * than necessary from the arrays as they will not be valid next + * time the application tries to draw with them. + */ + prim[0].mode = mode; + prim[0].start = 0; + prim[0].count = count; + prim[0].indexed = 0; + + vbo->draw_prims( ctx, exec->array.inputs, prim, 1, NULL, start, start + count ); + } +} + + + +static void GLAPIENTRY +vbo_exec_DrawRangeElements(GLenum mode, + GLuint start, GLuint end, + GLsizei count, GLenum type, const GLvoid *indices) +{ + GET_CURRENT_CONTEXT(ctx); + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; + struct _mesa_index_buffer ib; + struct _mesa_prim prim[1]; + + if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count, type, indices )) + return; + + FLUSH_CURRENT( ctx, 0 ); + + if (ctx->NewState) + _mesa_update_state( ctx ); + + ib.count = count; + ib.type = type; + ib.obj = ctx->Array.ElementArrayBufferObj; + ib.ptr = indices; + + if (ctx->Array.ElementArrayBufferObj->Name) { + /* Use the fact that indices are in a VBO as a hint that the + * program has put all the arrays in VBO's and we don't have to + * worry about performance implications of start > 0. + * + * XXX: consider passing start as min_index to draw_prims instead. + */ + ib.rebase = 0; + } + else { + ib.rebase = start; + } + + prim[0].begin = 1; + prim[0].end = 1; + prim[0].weak = 0; + prim[0].pad = 0; + prim[0].mode = mode; + prim[0].start = 0; + prim[0].count = count; + prim[0].indexed = 1; + + vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, ib.rebase, end+1 ); +} + + +static void GLAPIENTRY +vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint max_index; + + if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices )) + return; + + if (ctx->Array.ElementArrayBufferObj->Name) { + const GLvoid *map = ctx->Driver.MapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + GL_DYNAMIC_READ_ARB, + ctx->Array.ElementArrayBufferObj); + + max_index = get_max_index(count, type, ADD_POINTERS(map, indices)); + + ctx->Driver.UnmapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Array.ElementArrayBufferObj); + } + else { + max_index = get_max_index(count, type, indices); + } + + vbo_exec_DrawRangeElements(mode, 0, max_index, count, type, indices); +} + + +/*********************************************************************** + * Initialization + */ + + + + +void vbo_exec_array_init( struct vbo_exec_context *exec ) +{ + GLcontext *ctx = exec->ctx; + +#if 1 + exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays; + exec->vtxfmt.DrawElements = vbo_exec_DrawElements; + exec->vtxfmt.DrawRangeElements = vbo_exec_DrawRangeElements; +#else + exec->vtxfmt.DrawArrays = _mesa_noop_DrawArrays; + exec->vtxfmt.DrawElements = _mesa_noop_DrawElements; + exec->vtxfmt.DrawRangeElements = _mesa_noop_DrawRangeElements; +#endif + + exec->array.index_obj = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB); +} + + +void vbo_exec_array_destroy( struct vbo_exec_context *exec ) +{ + GLcontext *ctx = exec->ctx; + + ctx->Driver.DeleteBuffer(ctx, exec->array.index_obj); +} -- cgit v1.2.3 From 99efde461d3b8615863bdb7308e05289e0db0422 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 30 Oct 2006 16:44:13 +0000 Subject: better handling of current attributes. Trivial dlist and varray tests work --- src/mesa/Makefile | 2 +- src/mesa/main/arrayobj.c | 9 --- src/mesa/main/enable.c | 2 +- src/mesa/main/mtypes.h | 10 +-- src/mesa/sources | 30 ++++----- src/mesa/tnl/t_context.c | 2 + src/mesa/vbo/vbo_context.c | 144 +++++++++++++++++++++++++++++++++++++++++- src/mesa/vbo/vbo_context.h | 7 ++ src/mesa/vbo/vbo_exec.c | 117 ---------------------------------- src/mesa/vbo/vbo_exec.h | 4 -- src/mesa/vbo/vbo_exec_array.c | 15 +++-- src/mesa/vbo/vbo_exec_draw.c | 38 +++++++++-- src/mesa/vbo/vbo_save_draw.c | 28 +++++++- 13 files changed, 235 insertions(+), 173 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/Makefile b/src/mesa/Makefile index 3f65ecf5cc..e06607b0f8 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -142,7 +142,7 @@ depend: $(ALL_SOURCES) @ echo "running $(MKDEP)" @ touch depend @$(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \ - > /dev/null + > /dev/null 2>/dev/null subdirs: diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 852b9aaee9..d601ee461e 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -114,40 +114,34 @@ _mesa_initialize_array_object( GLcontext *ctx, obj->Vertex.StrideB = 0; obj->Vertex.Ptr = NULL; obj->Vertex.Enabled = GL_FALSE; - obj->Vertex.Flags = CA_CLIENT_DATA; obj->Normal.Type = GL_FLOAT; obj->Normal.Stride = 0; obj->Normal.StrideB = 0; obj->Normal.Ptr = NULL; obj->Normal.Enabled = GL_FALSE; - obj->Normal.Flags = CA_CLIENT_DATA; obj->Color.Size = 4; obj->Color.Type = GL_FLOAT; obj->Color.Stride = 0; obj->Color.StrideB = 0; obj->Color.Ptr = NULL; obj->Color.Enabled = GL_FALSE; - obj->Color.Flags = CA_CLIENT_DATA; obj->SecondaryColor.Size = 4; obj->SecondaryColor.Type = GL_FLOAT; obj->SecondaryColor.Stride = 0; obj->SecondaryColor.StrideB = 0; obj->SecondaryColor.Ptr = NULL; obj->SecondaryColor.Enabled = GL_FALSE; - obj->SecondaryColor.Flags = CA_CLIENT_DATA; obj->FogCoord.Size = 1; obj->FogCoord.Type = GL_FLOAT; obj->FogCoord.Stride = 0; obj->FogCoord.StrideB = 0; obj->FogCoord.Ptr = NULL; obj->FogCoord.Enabled = GL_FALSE; - obj->FogCoord.Flags = CA_CLIENT_DATA; obj->Index.Type = GL_FLOAT; obj->Index.Stride = 0; obj->Index.StrideB = 0; obj->Index.Ptr = NULL; obj->Index.Enabled = GL_FALSE; - obj->Index.Flags = CA_CLIENT_DATA; for (i = 0; i < MAX_TEXTURE_UNITS; i++) { obj->TexCoord[i].Size = 4; obj->TexCoord[i].Type = GL_FLOAT; @@ -155,13 +149,11 @@ _mesa_initialize_array_object( GLcontext *ctx, obj->TexCoord[i].StrideB = 0; obj->TexCoord[i].Ptr = NULL; obj->TexCoord[i].Enabled = GL_FALSE; - obj->TexCoord[i].Flags = CA_CLIENT_DATA; } obj->EdgeFlag.Stride = 0; obj->EdgeFlag.StrideB = 0; obj->EdgeFlag.Ptr = NULL; obj->EdgeFlag.Enabled = GL_FALSE; - obj->EdgeFlag.Flags = CA_CLIENT_DATA; for (i = 0; i < VERT_ATTRIB_MAX; i++) { obj->VertexAttrib[i].Size = 4; obj->VertexAttrib[i].Type = GL_FLOAT; @@ -170,7 +162,6 @@ _mesa_initialize_array_object( GLcontext *ctx, obj->VertexAttrib[i].Ptr = NULL; obj->VertexAttrib[i].Enabled = GL_FALSE; obj->VertexAttrib[i].Normalized = GL_FALSE; - obj->VertexAttrib[i].Flags = CA_CLIENT_DATA; } #if FEATURE_ARB_vertex_buffer_object diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 91268b596d..bf86e6db7d 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -53,7 +53,7 @@ static void client_state( GLcontext *ctx, GLenum cap, GLboolean state ) { GLuint flag; - GLuint *var; + GLboolean *var; switch (cap) { case GL_VERTEX_ARRAY: diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 5a326ff0dc..903779edae 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1640,8 +1640,6 @@ struct gl_pixelstore_attrib }; -#define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */ - /** * Client vertex array attributes @@ -1653,14 +1651,12 @@ struct gl_client_array GLsizei Stride; /**< user-specified stride */ GLsizei StrideB; /**< actual stride in bytes */ const GLubyte *Ptr; /**< Points to array data */ - GLbitfield Enabled; /**< one of the _NEW_ARRAY_ bits */ + GLboolean Enabled; /**< Enabled flag is a boolean */ GLboolean Normalized; /**< GL_ARB_vertex_program */ /**< GL_ARB_vertex_buffer_object */ struct gl_buffer_object *BufferObj; GLuint _MaxElement; - - GLbitfield Flags; }; @@ -1681,8 +1677,8 @@ struct gl_array_object struct gl_client_array SecondaryColor; struct gl_client_array FogCoord; struct gl_client_array Index; - struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS]; struct gl_client_array EdgeFlag; + struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS]; /*@}*/ /** Generic arrays for vertex programs/shaders */ @@ -2617,7 +2613,7 @@ struct matrix_stack #define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5 #define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6 #define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7 -#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */ +#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */ #define _NEW_ARRAY_ALL 0xffffffff diff --git a/src/mesa/sources b/src/mesa/sources index 09692c6f15..b589111a19 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -78,10 +78,6 @@ MATH_SOURCES = \ math/m_vector.c \ math/m_xform.c -ARRAY_CACHE_SOURCES = \ - array_cache/ac_context.c \ - array_cache/ac_import.c - SWRAST_SOURCES = \ swrast/s_aaline.c \ swrast/s_aatriangle.c \ @@ -119,13 +115,9 @@ SWRAST_SETUP_SOURCES = \ swrast_setup/ss_triangle.c TNL_SOURCES = \ - tnl/t_array_api.c \ - tnl/t_array_import.c \ tnl/t_context.c \ tnl/t_pipeline.c \ - tnl/t_save_api.c \ - tnl/t_save_loopback.c \ - tnl/t_save_playback.c \ + tnl/t_draw.c \ tnl/t_vb_arbprogram.c \ tnl/t_vb_arbprogram_sse.c \ tnl/t_vb_arbshader.c\ @@ -142,13 +134,19 @@ TNL_SOURCES = \ tnl/t_vp_build.c \ tnl/t_vertex.c \ tnl/t_vertex_sse.c \ - tnl/t_vertex_generic.c \ - tnl/t_vtx_api.c \ - tnl/t_vtx_generic.c \ - tnl/t_vtx_x86.c \ - tnl/t_vtx_eval.c \ - tnl/t_vtx_exec.c + tnl/t_vertex_generic.c +VBO_SOURCES = \ + vbo/vbo_context.c \ + vbo/vbo_exec.c \ + vbo/vbo_exec_api.c \ + vbo/vbo_exec_array.c \ + vbo/vbo_exec_draw.c \ + vbo/vbo_exec_eval.c \ + vbo/vbo_save.c \ + vbo/vbo_save_api.c \ + vbo/vbo_save_draw.c \ + vbo/vbo_save_loopback.c SHADER_SOURCES = \ @@ -317,7 +315,7 @@ ALL_SOURCES = \ SOLO_SOURCES = \ $(MAIN_SOURCES) \ $(MATH_SOURCES) \ - $(ARRAY_CACHE_SOURCES) \ + $(VBO_SOURCES) \ $(TNL_SOURCES) \ $(SHADER_SOURCES) \ $(SWRAST_SOURCES) \ diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index ff05ac0318..851a0672d4 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -77,6 +77,8 @@ _tnl_CreateContext( GLcontext *ctx ) tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; tnl->Driver.NotifyMaterialChange = _mesa_validate_all_lighting_tables; + tnl->nr_blocks = 0; + return GL_TRUE; } diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index 5f28e6b0e0..29dfe09d99 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -40,6 +40,123 @@ extern void _tnl_draw_prims( GLcontext *ctx, GLuint min_index, GLuint max_index ); + + +#define NR_LEGACY_ATTRIBS 16 +#define NR_GENERIC_ATTRIBS 16 +#define NR_MAT_ATTRIBS 12 + +static void init_legacy_currval(GLcontext *ctx) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct gl_client_array *arrays = vbo->legacy_currval; + GLuint i; + + memset(arrays, 0, sizeof(*arrays) * NR_LEGACY_ATTRIBS); + + /* Set up a constant (StrideB == 0) array for each current + * attribute: + */ + for (i = 0; i < NR_LEGACY_ATTRIBS; i++) { + struct gl_client_array *cl = &arrays[i]; + + switch (i) { + case VBO_ATTRIB_EDGEFLAG: + cl->Type = GL_UNSIGNED_BYTE; + cl->Ptr = (const void *)&ctx->Current.EdgeFlag; + break; + case VBO_ATTRIB_INDEX: + cl->Type = GL_FLOAT; + cl->Ptr = (const void *)&ctx->Current.Index; + break; + default: + cl->Type = GL_FLOAT; + cl->Ptr = (const void *)ctx->Current.Attrib[i]; + break; + } + + /* This will have to be determined at runtime: + */ + cl->Size = 1; + cl->Stride = 0; + cl->StrideB = 0; + cl->Enabled = 1; + cl->BufferObj = ctx->Array.NullBufferObj; + } +} + + +static void init_generic_currval(GLcontext *ctx) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct gl_client_array *arrays = vbo->generic_currval; + GLuint i; + + memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS); + + for (i = 0; i < NR_GENERIC_ATTRIBS; i++) { + struct gl_client_array *cl = &arrays[i]; + + /* This will have to be determined at runtime: + */ + cl->Size = 1; + + cl->Type = GL_FLOAT; + cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]; + cl->Stride = 0; + cl->StrideB = 0; + cl->Enabled = 1; + cl->BufferObj = ctx->Array.NullBufferObj; + } +} + + +static void init_mat_currval(GLcontext *ctx) +{ + struct vbo_context *vbo = vbo_context(ctx); + struct gl_client_array *arrays = vbo->mat_currval; + GLuint i; + + memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS); + + /* Set up a constant (StrideB == 0) array for each current + * attribute: + */ + for (i = 0; i < NR_GENERIC_ATTRIBS; i++) { + struct gl_client_array *cl = &arrays[i]; + + /* Size is fixed for the material attributes, for others will + * be determined at runtime: + */ + switch (i - VERT_ATTRIB_GENERIC0) { + case MAT_ATTRIB_FRONT_SHININESS: + case MAT_ATTRIB_BACK_SHININESS: + cl->Size = 1; + break; + case MAT_ATTRIB_FRONT_INDEXES: + case MAT_ATTRIB_BACK_INDEXES: + cl->Size = 3; + break; + default: + cl->Size = 4; + break; + } + + if (i < MAT_ATTRIB_MAX) + cl->Ptr = (const void *)ctx->Light.Material.Attrib[i]; + else + cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]; + + cl->Type = GL_FLOAT; + cl->Stride = 0; + cl->StrideB = 0; + cl->Enabled = 1; + cl->BufferObj = ctx->Array.NullBufferObj; + } +} + + + GLboolean _vbo_CreateContext( GLcontext *ctx ) { struct vbo_context *vbo = CALLOC_STRUCT(vbo_context); @@ -60,6 +177,32 @@ GLboolean _vbo_CreateContext( GLcontext *ctx ) vbo_exec_init( ctx ); vbo_save_init( ctx ); + + init_legacy_currval( ctx ); + init_generic_currval( ctx ); + init_mat_currval( ctx ); + + /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type + * of vertex program active. + */ + { + GLuint i; + + /* When no vertex program, pull in the material attributes in + * the 16..32 generic range. + */ + for (i = 0; i < 16; i++) + vbo->map_vp_none[i] = i; + for (i = 0; i < 12; i++) + vbo->map_vp_none[16+i] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i; + for (i = 0; i < 4; i++) + vbo->map_vp_none[28+i] = i; + + for (i = 0; i < VERT_ATTRIB_MAX; i++) + vbo->map_vp_arb[i] = i; + } + + /* By default: */ vbo->draw_prims = _tnl_draw_prims; @@ -82,5 +225,4 @@ void _vbo_DestroyContext( GLcontext *ctx ) 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 6b0f14d70e..a20bfbd518 100644 --- a/src/mesa/vbo/vbo_context.h +++ b/src/mesa/vbo/vbo_context.h @@ -60,6 +60,13 @@ void _vbo_DestroyContext( GLcontext *ctx ); struct vbo_context { + struct gl_client_array legacy_currval[16]; + struct gl_client_array generic_currval[16]; + struct gl_client_array mat_currval[16]; + + GLuint map_vp_none[32]; + GLuint map_vp_arb[32]; + struct vbo_exec_context exec; struct vbo_save_context save; diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index 4499803b8c..270e5201d3 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -38,119 +38,6 @@ #include "vbo_context.h" -#define NR_LEGACY_ATTRIBS 16 -#define NR_GENERIC_ATTRIBS 16 -#define NR_MAT_ATTRIBS 12 - -static void init_legacy_currval(GLcontext *ctx) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - struct gl_client_array *arrays = exec->legacy_currval; - GLuint i; - - memset(arrays, 0, sizeof(*arrays) * NR_LEGACY_ATTRIBS); - - /* Set up a constant (StrideB == 0) array for each current - * attribute: - */ - for (i = 0; i < NR_LEGACY_ATTRIBS; i++) { - struct gl_client_array *cl = &arrays[i]; - - switch (i) { - case VBO_ATTRIB_EDGEFLAG: - cl->Type = GL_UNSIGNED_BYTE; - cl->Ptr = (const void *)&ctx->Current.EdgeFlag; - break; - case VBO_ATTRIB_INDEX: - cl->Type = GL_FLOAT; - cl->Ptr = (const void *)&ctx->Current.Index; - break; - default: - cl->Type = GL_FLOAT; - cl->Ptr = (const void *)ctx->Current.Attrib[i]; - break; - } - - /* This will have to be determined at runtime: - */ - cl->Size = 1; - cl->Stride = 0; - cl->StrideB = 0; - cl->Enabled = 1; - cl->BufferObj = ctx->Array.NullBufferObj; - } -} - - -static void init_generic_currval(GLcontext *ctx) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - struct gl_client_array *arrays = exec->generic_currval; - GLuint i; - - memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS); - - for (i = 0; i < NR_GENERIC_ATTRIBS; i++) { - struct gl_client_array *cl = &arrays[i]; - - /* This will have to be determined at runtime: - */ - cl->Size = 1; - - cl->Type = GL_FLOAT; - cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]; - cl->Stride = 0; - cl->StrideB = 0; - cl->Enabled = 1; - cl->BufferObj = ctx->Array.NullBufferObj; - } -} - - -static void init_mat_currval(GLcontext *ctx) -{ - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - struct gl_client_array *arrays = exec->mat_currval; - GLuint i; - - memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS); - - /* Set up a constant (StrideB == 0) array for each current - * attribute: - */ - for (i = 0; i < NR_GENERIC_ATTRIBS; i++) { - struct gl_client_array *cl = &arrays[i]; - - /* Size is fixed for the material attributes, for others will - * be determined at runtime: - */ - switch (i - VERT_ATTRIB_GENERIC0) { - case MAT_ATTRIB_FRONT_SHININESS: - case MAT_ATTRIB_BACK_SHININESS: - cl->Size = 1; - break; - case MAT_ATTRIB_FRONT_INDEXES: - case MAT_ATTRIB_BACK_INDEXES: - cl->Size = 3; - break; - default: - cl->Size = 4; - break; - } - - if (i < MAT_ATTRIB_MAX) - cl->Ptr = (const void *)ctx->Light.Material.Attrib[i]; - else - cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]; - - cl->Type = GL_FLOAT; - cl->Stride = 0; - cl->StrideB = 0; - cl->Enabled = 1; - cl->BufferObj = ctx->Array.NullBufferObj; - } -} - void vbo_exec_init( GLcontext *ctx ) { @@ -167,10 +54,6 @@ void vbo_exec_init( GLcontext *ctx ) vbo_exec_vtx_init( exec ); vbo_exec_array_init( exec ); - init_legacy_currval( ctx ); - init_generic_currval( ctx ); - init_mat_currval( ctx ); - ctx->Driver.NeedFlush = 0; ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; ctx->Driver.FlushVertices = vbo_exec_FlushVertices; diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index 4542d2807c..72855d267e 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -75,10 +75,6 @@ struct vbo_exec_context GLcontext *ctx; GLvertexformat vtxfmt; - struct gl_client_array legacy_currval[16]; - struct gl_client_array generic_currval[16]; - struct gl_client_array mat_currval[16]; - struct { struct gl_buffer_object *bufferobj; GLubyte *buffer_map; diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 5cfa7a01a9..b3650e2697 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -107,7 +107,8 @@ static void bind_array_obj( GLcontext *ctx ) static void recalculate_input_bindings( GLcontext *ctx ) { - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; const struct gl_client_array **inputs = &exec->array.inputs[0]; GLuint i; @@ -126,11 +127,11 @@ static void recalculate_input_bindings( GLcontext *ctx ) if (exec->array.legacy_array[i]->Enabled) inputs[i] = exec->array.legacy_array[i]; else - inputs[i] = &exec->legacy_currval[i]; + inputs[i] = &vbo->legacy_currval[i]; } for (i = 0; i < MAT_ATTRIB_MAX; i++) { - inputs[VERT_ATTRIB_GENERIC0 + i] = &exec->mat_currval[i]; + inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i]; } break; case VP_NV: @@ -144,7 +145,7 @@ static void recalculate_input_bindings( GLcontext *ctx ) else if (exec->array.legacy_array[i]->Enabled) inputs[i] = exec->array.legacy_array[i]; else - inputs[i] = &exec->legacy_currval[i]; + inputs[i] = &vbo->legacy_currval[i]; } break; case VP_ARB: @@ -160,21 +161,21 @@ static void recalculate_input_bindings( GLcontext *ctx ) else if (exec->array.legacy_array[0]->Enabled) inputs[0] = exec->array.legacy_array[0]; else - inputs[0] = &exec->legacy_currval[0]; + inputs[0] = &vbo->legacy_currval[0]; for (i = 1; i <= VERT_ATTRIB_TEX7; i++) { if (exec->array.legacy_array[i]->Enabled) inputs[i] = exec->array.legacy_array[i]; else - inputs[i] = &exec->legacy_currval[i]; + inputs[i] = &vbo->legacy_currval[i]; } for (i = 0; i < 16; i++) { if (exec->array.generic_array[0]->Enabled) inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i]; else - inputs[VERT_ATTRIB_GENERIC0 + i] = &exec->generic_currval[i]; + inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i]; } break; } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index f665c64c7a..c1898aea49 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -132,25 +132,49 @@ static GLuint vbo_copy_vertices( struct vbo_exec_context *exec ) } + /* TODO: populate these as the vertex is defined: */ -static void vbo_exec_bind_arrays( struct vbo_exec_context *exec ) +static void vbo_exec_bind_arrays( GLcontext *ctx ) { + struct vbo_context *vbo = vbo_context(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; + const GLuint *map; GLuint attr; - memcpy(arrays, exec->legacy_currval, 16 * sizeof(arrays[0])); - memcpy(arrays + 16, exec->mat_currval, 16 * sizeof(arrays[0])); + /* Install the default (ie Current) attributes first, then overlay + * all active ones. + */ + switch (get_program_mode(exec->ctx)) { + case VP_NONE: + memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); + memcpy(arrays + 16, vbo->mat_currval, 16 * sizeof(arrays[0])); + map = vbo->map_vp_none; + break; + case VP_NV: + case VP_ARB: + /* The aliasing of attributes for NV vertex programs has already + * 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])); + map = vbo->map_vp_arb; + break; + } /* Make all active attributes (including edgeflag) available as * arrays of floats. */ - for (attr = 0; attr < VBO_ATTRIB_MAX ; attr++) { - if (exec->vtx.attrsz[attr]) { + for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) { + GLuint src = map[attr]; + + if (exec->vtx.attrsz[src]) { arrays[attr].Ptr = (void *)data; - arrays[attr].Size = exec->vtx.attrsz[attr]; + arrays[attr].Size = exec->vtx.attrsz[src]; arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat); arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat); arrays[attr].Type = GL_FLOAT; @@ -181,7 +205,7 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) if (exec->vtx.copied.nr != exec->vtx.vert_count) { GLcontext *ctx = exec->ctx; - vbo_exec_bind_arrays( exec ); + vbo_exec_bind_arrays( ctx ); vbo_context(ctx)->draw_prims( ctx, exec->vtx.inputs, diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 44e0171233..18c770a41c 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -95,14 +95,36 @@ static void _playback_copy_to_current( GLcontext *ctx, /* Treat the vertex storage as a VBO, define vertex arrays pointing * into it: */ -static void vbo_bind_vertex_list( struct vbo_save_context *save, +static void vbo_bind_vertex_list( GLcontext *ctx, const struct vbo_save_vertex_list *node ) { + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_save_context *save = &vbo->save; struct gl_client_array *arrays = save->arrays; GLuint data = node->buffer_offset; + const GLuint *map; GLuint attr; - memset(arrays, 0, VBO_ATTRIB_MAX * sizeof(arrays[0])); + /* Install the default (ie Current) attributes first, then overlay + * all active ones. + */ + switch (get_program_mode(ctx)) { + case VP_NONE: + memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0])); + memcpy(arrays + 16, vbo->mat_currval, 16 * sizeof(arrays[0])); + map = vbo->map_vp_none; + break; + case VP_NV: + case VP_ARB: + /* The aliasing of attributes for NV vertex programs has already + * 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])); + map = vbo->map_vp_arb; + break; + } for (attr = 0; attr <= VBO_ATTRIB_INDEX; attr++) { if (node->attrsz[attr]) { @@ -185,7 +207,7 @@ void vbo_save_playback_vertex_list( GLcontext *ctx, void *data ) return; } - vbo_bind_vertex_list( save, node ); + vbo_bind_vertex_list( ctx, node ); vbo_context(ctx)->draw_prims( ctx, save->inputs, -- cgit v1.2.3 From 5a652f595716a82ebd79e33011f6082199c4b0d0 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 2 Nov 2006 18:00:43 +0000 Subject: Fill in missing input slots in the vertex-array + no-vertex-program path. --- src/mesa/vbo/vbo_exec_array.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index b3650e2697..481c4ee546 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -81,7 +81,8 @@ static GLuint get_max_index( GLuint count, GLuint type, */ static void bind_array_obj( GLcontext *ctx ) { - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + struct vbo_context *vbo = vbo_context(ctx); + struct vbo_exec_context *exec = &vbo->exec; GLuint i; /* TODO: Fix the ArrayObj struct to keep legacy arrays in an array @@ -89,6 +90,7 @@ static void bind_array_obj( GLcontext *ctx ) * go away. */ exec->array.legacy_array[VERT_ATTRIB_POS] = &ctx->Array.ArrayObj->Vertex; + exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &vbo->legacy_currval[i]; exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &ctx->Array.ArrayObj->Normal; exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &ctx->Array.ArrayObj->Color; exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &ctx->Array.ArrayObj->SecondaryColor; @@ -133,6 +135,13 @@ static void recalculate_input_bindings( GLcontext *ctx ) for (i = 0; i < MAT_ATTRIB_MAX; i++) { inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i]; } + + /* Could use just about anything, just to fill in the empty + * slots: + */ + for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX; i++) + inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0]; + break; case VP_NV: /* NV_vertex_program - attribute arrays alias and override -- cgit v1.2.3 From 301acdf34ad01315f41c14638d92aa7fe0c2d2dc Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 2 Nov 2006 18:02:17 +0000 Subject: Similarly, fill in missing input slots in the vertex-array + NV_vertex_program path. --- src/mesa/vbo/vbo_exec_array.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 481c4ee546..aab5748626 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -156,6 +156,13 @@ static void recalculate_input_bindings( GLcontext *ctx ) else inputs[i] = &vbo->legacy_currval[i]; } + + /* Could use just about anything, just to fill in the empty + * slots: + */ + for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) + inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0]; + break; case VP_ARB: /* ARB_vertex_program - Only the attribute zero (position) array -- cgit v1.2.3 From 01e238e5d51dabd28646356de825aa43a7290373 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 2 Nov 2006 19:02:04 +0000 Subject: Fix typo in last commit --- src/mesa/vbo/vbo_exec_array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index aab5748626..8f5c26920b 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -90,7 +90,7 @@ static void bind_array_obj( GLcontext *ctx ) * go away. */ exec->array.legacy_array[VERT_ATTRIB_POS] = &ctx->Array.ArrayObj->Vertex; - exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &vbo->legacy_currval[i]; + exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &vbo->legacy_currval[VERT_ATTRIB_WEIGHT]; exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &ctx->Array.ArrayObj->Normal; exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &ctx->Array.ArrayObj->Color; exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &ctx->Array.ArrayObj->SecondaryColor; -- cgit v1.2.3 From c3da1501b81a31e92f485ee9fbd99e60cc3a4337 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 3 Nov 2006 12:33:29 +0000 Subject: need to call bind_arrays() in vbo_exec_DrawRangeElements. --- src/mesa/vbo/vbo_exec_array.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 8f5c26920b..803e58c148 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -290,7 +290,9 @@ vbo_exec_DrawRangeElements(GLenum mode, if (ctx->NewState) _mesa_update_state( ctx ); - + + bind_arrays( ctx ); + ib.count = count; ib.type = type; ib.obj = ctx->Array.ElementArrayBufferObj; -- cgit v1.2.3 From 2421b25dd777ebfd614ae45907fd4af8c2713102 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 15 Jan 2007 13:40:38 +0000 Subject: Remove special-case handling for index and edgeflag This isn't required with the changes to core mesa and the new attribute layout. --- src/mesa/vbo/vbo_attrib_tmp.h | 5 +- src/mesa/vbo/vbo_exec_array.c | 6 +- src/mesa/vbo/vbo_save.h | 2 - src/mesa/vbo/vbo_save_api.c | 44 ++++-------- src/mesa/vbo/vbo_save_loopback.c | 148 ++------------------------------------- 5 files changed, 24 insertions(+), 181 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h index 72a8b04aca..ff11c7d59a 100644 --- a/src/mesa/vbo/vbo_attrib_tmp.h +++ b/src/mesa/vbo/vbo_attrib_tmp.h @@ -357,9 +357,10 @@ static void GLAPIENTRY TAG(VertexAttrib4fvARB)( GLuint index, } -/* Although we don't export NV_vertex_program, these entrypoints are +/* In addition to supporting NV_vertex_program, these entrypoints are * used by the display list and other code specifically because of - * their property of aliasing with other attributes. + * their property of aliasing with other attributes. (See + * vbo_save_loopback.c) */ static void GLAPIENTRY TAG(VertexAttrib1fNV)( GLuint index, GLfloat x ) { diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 803e58c148..15fbdcf8a5 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -96,10 +96,10 @@ static void bind_array_obj( GLcontext *ctx ) exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &ctx->Array.ArrayObj->SecondaryColor; exec->array.legacy_array[VERT_ATTRIB_FOG] = &ctx->Array.ArrayObj->FogCoord; exec->array.legacy_array[VERT_ATTRIB_COLOR_INDEX] = &ctx->Array.ArrayObj->Index; - exec->array.legacy_array[VBO_ATTRIB_EDGEFLAG] = &ctx->Array.ArrayObj->EdgeFlag; + exec->array.legacy_array[VERT_ATTRIB_EDGEFLAG] = &ctx->Array.ArrayObj->EdgeFlag; for (i = 0; i < 8; i++) - exec->array.legacy_array[VBO_ATTRIB_TEX0 + i] = &ctx->Array.ArrayObj->TexCoord[i]; + exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &ctx->Array.ArrayObj->TexCoord[i]; for (i = 0; i < VERT_ATTRIB_MAX; i++) exec->array.generic_array[i] = &ctx->Array.ArrayObj->VertexAttrib[i]; @@ -117,8 +117,6 @@ static void recalculate_input_bindings( GLcontext *ctx ) exec->array.program_mode = get_program_mode(ctx); exec->array.enabled_flags = ctx->Array.ArrayObj->_Enabled; - /* TODO: Get rid of NV_program (please!). - */ switch (exec->array.program_mode) { case VP_NONE: /* When no vertex program is active, we put the material values diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h index 3051f5c59a..b81f275a60 100644 --- a/src/mesa/vbo/vbo_save.h +++ b/src/mesa/vbo/vbo_save.h @@ -142,8 +142,6 @@ struct vbo_save_context { struct vbo_save_copied_vtx copied; - GLfloat CurrentFloatEdgeFlag; - GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */ GLubyte *currentsz[VBO_ATTRIB_MAX]; }; diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index efe018b09e..f339436f84 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -415,26 +415,14 @@ static void _save_copy_to_current( GLcontext *ctx ) struct vbo_save_context *save = &vbo_context(ctx)->save; GLuint i; - for (i = VBO_ATTRIB_POS+1 ; i <= VBO_ATTRIB_INDEX ; i++) { + for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { if (save->attrsz[i]) { save->currentsz[i][0] = save->attrsz[i]; COPY_CLEAN_4V(save->current[i], - save->attrsz[i], - save->attrptr[i]); + save->attrsz[i], + save->attrptr[i]); } } - - /* Edgeflag requires special treatment: - * - * TODO: change edgeflag to GLfloat in Mesa. - */ - if (save->attrsz[VBO_ATTRIB_EDGEFLAG]) { - ctx->ListState.ActiveEdgeFlag = 1; - save->CurrentFloatEdgeFlag = - save->attrptr[VBO_ATTRIB_EDGEFLAG][0]; - ctx->ListState.CurrentEdgeFlag = - (save->CurrentFloatEdgeFlag == 1.0); - } } @@ -443,7 +431,7 @@ static void _save_copy_from_current( GLcontext *ctx ) struct vbo_save_context *save = &vbo_context(ctx)->save; GLint i; - for (i = VBO_ATTRIB_POS+1 ; i <= VBO_ATTRIB_INDEX ; i++) + for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { switch (save->attrsz[i]) { case 4: save->attrptr[i][3] = save->current[i][3]; case 3: save->attrptr[i][2] = save->current[i][2]; @@ -451,12 +439,6 @@ static void _save_copy_from_current( GLcontext *ctx ) case 1: save->attrptr[i][0] = save->current[i][0]; case 0: break; } - - /* Edgeflag requires special treatment: - */ - if (save->attrsz[VBO_ATTRIB_EDGEFLAG]) { - save->CurrentFloatEdgeFlag = (GLfloat)ctx->ListState.CurrentEdgeFlag; - save->attrptr[VBO_ATTRIB_EDGEFLAG][0] = save->CurrentFloatEdgeFlag; } } @@ -616,6 +598,8 @@ do { \ if (save->active_sz[A] != N) \ save_fixup_vertex(ctx, A, N); \ \ + _mesa_printf("Attr %d, sz %d: %f %f %f %f\n", A, N, V0, V1, V2, V3 ); \ + \ { \ GLfloat *dest = save->attrptr[A]; \ if (N>0) dest[0] = V0; \ @@ -1106,23 +1090,19 @@ static void _save_current_init( GLcontext *ctx ) struct vbo_save_context *save = &vbo_context(ctx)->save; GLint i; - for (i = 0; i < VBO_ATTRIB_FIRST_MATERIAL; i++) { - save->currentsz[i] = &ctx->ListState.ActiveAttribSize[i]; - save->current[i] = ctx->ListState.CurrentAttrib[i]; + for (i = VBO_ATTRIB_POS; i <= VBO_ATTRIB_GENERIC15; i++) { + const GLuint j = i - VBO_ATTRIB_POS; + ASSERT(j < VERT_ATTRIB_MAX); + save->currentsz[i] = &ctx->ListState.ActiveAttribSize[j]; + save->current[i] = ctx->ListState.CurrentAttrib[j]; } - for (i = VBO_ATTRIB_FIRST_MATERIAL; i < VBO_ATTRIB_INDEX; i++) { + for (i = VBO_ATTRIB_FIRST_MATERIAL; i <= VBO_ATTRIB_MAT_FRONT_AMBIENT; i++) { const GLuint j = i - VBO_ATTRIB_FIRST_MATERIAL; ASSERT(j < MAT_ATTRIB_MAX); save->currentsz[i] = &ctx->ListState.ActiveMaterialSize[j]; save->current[i] = ctx->ListState.CurrentMaterial[j]; } - - save->currentsz[VBO_ATTRIB_INDEX] = &ctx->ListState.ActiveIndex; - save->current[VBO_ATTRIB_INDEX] = &ctx->ListState.CurrentIndex; - - save->currentsz[VBO_ATTRIB_EDGEFLAG] = &ctx->ListState.ActiveEdgeFlag; - save->current[VBO_ATTRIB_EDGEFLAG] = &save->CurrentFloatEdgeFlag; } /** diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c index 941c4beea9..2c28126cab 100644 --- a/src/mesa/vbo/vbo_save_loopback.c +++ b/src/mesa/vbo/vbo_save_loopback.c @@ -44,7 +44,9 @@ typedef void (*attr_func)( GLcontext *ctx, GLint target, const GLfloat * ); -/* Wrapper functions in case glVertexAttrib*fvNV doesn't exist */ +/* This file makes heavy use of the aliasing of NV vertex attributes + * with the legacy attributes. + */ static void VertexAttrib1fvNV(GLcontext *ctx, GLint target, const GLfloat *v) { CALL_VertexAttrib1fvNV(ctx->Exec, (target, v)); @@ -72,118 +74,6 @@ static attr_func vert_attrfunc[4] = { VertexAttrib4fvNV }; -#if 0 -static void VertexAttrib1fvARB(GLcontext *ctx, GLint target, const GLfloat *v) -{ - CALL_VertexAttrib1fvARB(ctx->Exec, (target, v)); -} - -static void VertexAttrib2fvARB(GLcontext *ctx, GLint target, const GLfloat *v) -{ - CALL_VertexAttrib2fvARB(ctx->Exec, (target, v)); -} - -static void VertexAttrib3fvARB(GLcontext *ctx, GLint target, const GLfloat *v) -{ - CALL_VertexAttrib3fvARB(ctx->Exec, (target, v)); -} - -static void VertexAttrib4fvARB(GLcontext *ctx, GLint target, const GLfloat *v) -{ - CALL_VertexAttrib4fvARB(ctx->Exec, (target, v)); -} - - -static attr_func vert_attrfunc_arb[4] = { - VertexAttrib1fvARB, - VertexAttrib2fvARB, - VertexAttrib3fvARB, - VertexAttrib4fvARB -}; -#endif - - - - - - -static void mat_attr1fv( GLcontext *ctx, GLint target, const GLfloat *v ) -{ - switch (target) { - case VBO_ATTRIB_MAT_FRONT_SHININESS: - CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SHININESS, v )); - break; - case VBO_ATTRIB_MAT_BACK_SHININESS: - CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SHININESS, v )); - break; - } -} - - -static void mat_attr3fv( GLcontext *ctx, GLint target, const GLfloat *v ) -{ - switch (target) { - case VBO_ATTRIB_MAT_FRONT_INDEXES: - CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_COLOR_INDEXES, v )); - break; - case VBO_ATTRIB_MAT_BACK_INDEXES: - CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_COLOR_INDEXES, v )); - break; - } -} - - -static void mat_attr4fv( GLcontext *ctx, GLint target, const GLfloat *v ) -{ - switch (target) { - case VBO_ATTRIB_MAT_FRONT_EMISSION: - CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_EMISSION, v )); - break; - case VBO_ATTRIB_MAT_BACK_EMISSION: - CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_EMISSION, v )); - break; - case VBO_ATTRIB_MAT_FRONT_AMBIENT: - CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_AMBIENT, v )); - break; - case VBO_ATTRIB_MAT_BACK_AMBIENT: - CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_AMBIENT, v )); - break; - case VBO_ATTRIB_MAT_FRONT_DIFFUSE: - CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_DIFFUSE, v )); - break; - case VBO_ATTRIB_MAT_BACK_DIFFUSE: - CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_DIFFUSE, v )); - break; - case VBO_ATTRIB_MAT_FRONT_SPECULAR: - CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SPECULAR, v )); - break; - case VBO_ATTRIB_MAT_BACK_SPECULAR: - CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SPECULAR, v )); - break; - } -} - - -static attr_func mat_attrfunc[4] = { - mat_attr1fv, - NULL, - mat_attr3fv, - mat_attr4fv -}; - - -static void index_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v) -{ - (void) target; - CALL_Indexf(ctx->Exec, (v[0])); -} - -static void edgeflag_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v) -{ - (void) target; - CALL_EdgeFlag(ctx->Exec, ((GLboolean)(v[0] == 1.0))); -} - struct loopback_attr { GLint target; GLint sz; @@ -277,7 +167,10 @@ void vbo_loopback_vertex_list( GLcontext *ctx, struct loopback_attr la[VBO_ATTRIB_MAX]; GLuint i, nr = 0; - for (i = 0 ; i <= VBO_ATTRIB_TEX7 ; i++) { + /* All Legacy, NV, ARB and Material attributes are routed through + * the NV attributes entrypoints: + */ + for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { if (attrsz[i]) { la[nr].target = i; la[nr].sz = attrsz[i]; @@ -286,33 +179,6 @@ void vbo_loopback_vertex_list( GLcontext *ctx, } } - for (i = VBO_ATTRIB_MAT_FRONT_AMBIENT ; - i <= VBO_ATTRIB_MAT_BACK_INDEXES ; - i++) { - if (attrsz[i]) { - la[nr].target = i; - la[nr].sz = attrsz[i]; - la[nr].func = mat_attrfunc[attrsz[i]-1]; - nr++; - } - } - - if (attrsz[VBO_ATTRIB_EDGEFLAG]) { - la[nr].target = VBO_ATTRIB_EDGEFLAG; - la[nr].sz = attrsz[VBO_ATTRIB_EDGEFLAG]; - la[nr].func = edgeflag_attr1fv; - nr++; - } - - if (attrsz[VBO_ATTRIB_INDEX]) { - la[nr].target = VBO_ATTRIB_INDEX; - la[nr].sz = attrsz[VBO_ATTRIB_INDEX]; - la[nr].func = index_attr1fv; - nr++; - } - - /* XXX ARB vertex attribs */ - for (i = 0 ; i < prim_count ; i++) { if ((prim[i].mode & VBO_SAVE_PRIM_WEAK) && (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END)) -- cgit v1.2.3 From 584def75ad8dd13add5b4ed7e364d13202539539 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 15 Jan 2007 16:57:01 +0000 Subject: Remove unused index buffer. --- src/mesa/vbo/vbo_exec.h | 3 --- src/mesa/vbo/vbo_exec_array.c | 8 +------- 2 files changed, 1 insertion(+), 10 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index e28913b22a..a9b01e08e6 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -130,9 +130,6 @@ struct vbo_exec_context * programs: */ const struct gl_client_array *inputs[VERT_ATTRIB_MAX]; - - - struct gl_buffer_object *index_obj; } array; }; diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 15fbdcf8a5..cec353cf43 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -360,8 +360,6 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *ind void vbo_exec_array_init( struct vbo_exec_context *exec ) { - GLcontext *ctx = exec->ctx; - #if 1 exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays; exec->vtxfmt.DrawElements = vbo_exec_DrawElements; @@ -371,14 +369,10 @@ void vbo_exec_array_init( struct vbo_exec_context *exec ) exec->vtxfmt.DrawElements = _mesa_noop_DrawElements; exec->vtxfmt.DrawRangeElements = _mesa_noop_DrawRangeElements; #endif - - exec->array.index_obj = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB); } void vbo_exec_array_destroy( struct vbo_exec_context *exec ) { - GLcontext *ctx = exec->ctx; - - ctx->Driver.DeleteBuffer(ctx, exec->array.index_obj); + /* nothing to do */ } -- cgit v1.2.3 From 2cb3594af9cd1434aa2c408cd6f8d51bcd12e8ea Mon Sep 17 00:00:00 2001 From: Aapo Tahkola Date: Thu, 18 Jan 2007 04:17:56 +0200 Subject: Fix invalid enums passed to MapBuffer --- src/mesa/vbo/vbo_exec_array.c | 2 +- src/mesa/vbo/vbo_save_api.c | 2 +- src/mesa/vbo/vbo_split_copy.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index cec353cf43..e0a6240c2a 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -334,7 +334,7 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *ind if (ctx->Array.ElementArrayBufferObj->Name) { const GLvoid *map = ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, - GL_DYNAMIC_READ_ARB, + GL_READ_ONLY, ctx->Array.ElementArrayBufferObj); max_index = get_max_index(count, type, ADD_POINTERS(map, indices)); diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index f718cdd91a..c08fd1fe55 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -198,7 +198,7 @@ static GLfloat *map_vertex_store( GLcontext *ctx, struct vbo_save_vertex_store * assert(!vertex_store->buffer); vertex_store->buffer = (GLfloat *)ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, /* not used */ - GL_STATIC_DRAW_ARB, /* not used */ + GL_WRITE_ONLY, /* not used */ vertex_store->bufferobj); assert(vertex_store->buffer); diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index 08eae2db40..fff733ccb5 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -382,7 +382,7 @@ static void replay_init( struct copy_context *copy ) if (vbo->Name && !vbo->Pointer) ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, - GL_DYNAMIC_DRAW_ARB, /* XXX */ + GL_WRITE_ONLY, /* XXX */ vbo); copy->varying[j].src_ptr = ADD_POINTERS(vbo->Pointer, @@ -399,7 +399,7 @@ static void replay_init( struct copy_context *copy ) if (copy->ib->obj->Name && !copy->ib->obj->Pointer) ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, /* XXX */ - GL_DYNAMIC_DRAW_ARB, /* XXX */ + GL_WRITE_ONLY, /* XXX */ copy->ib->obj); switch (copy->ib->type) { -- cgit v1.2.3 From 38e9f8b6f297bafba639ce192fc9926c8e890271 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 25 Jan 2007 18:52:40 +0100 Subject: do not rebase index buffers as it does not work currently (tested with r200 and sw mesa) --- src/mesa/vbo/vbo_exec_array.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index e0a6240c2a..5a3a7488ed 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -302,11 +302,12 @@ vbo_exec_DrawRangeElements(GLenum mode, * worry about performance implications of start > 0. * * XXX: consider passing start as min_index to draw_prims instead. + * XXX: don't rebase because it didn't work. */ ib.rebase = 0; } else { - ib.rebase = start; + ib.rebase = /*start*/ 0; } prim[0].begin = 1; @@ -318,7 +319,7 @@ vbo_exec_DrawRangeElements(GLenum mode, prim[0].count = count; prim[0].indexed = 1; - vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, ib.rebase, end+1 ); + vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, /*ib.rebase*/ start, end+1 ); } -- cgit v1.2.3 From 893526b8a823fe1b88f2b46376155afb91c84016 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jan 2007 20:22:55 +0000 Subject: Use new rebase helper. Remove other rebase code. --- src/mesa/drivers/dri/i965/brw_draw.c | 53 +++++++++- src/mesa/drivers/dri/i965/brw_draw_upload.c | 105 ++++---------------- src/mesa/tnl/t_draw.c | 108 ++++++++------------ src/mesa/vbo/vbo.h | 1 - src/mesa/vbo/vbo_exec_array.c | 146 +++++++++++++++------------- src/mesa/vbo/vbo_rebase.c | 3 +- src/mesa/vbo/vbo_split_copy.c | 1 - src/mesa/vbo/vbo_split_inplace.c | 1 - 8 files changed, 185 insertions(+), 233 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 63cb079ec9..7d8f837093 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -198,7 +198,9 @@ static void brw_merge_inputs( struct brw_context *brw, brw->state.dirty.brw |= BRW_NEW_INPUT_VARYING; } - +/* XXX: could split the primitive list to fallback only on the + * non-conformant primitives. + */ static GLboolean check_fallbacks( struct brw_context *brw, const struct _mesa_prim *prim, GLuint nr_prims ) @@ -251,7 +253,9 @@ static GLboolean check_fallbacks( struct brw_context *brw, return GL_FALSE; } - +/* May fail if out of video memory for texture or vbo upload, or on + * fallback conditions. + */ static GLboolean brw_try_draw_prims( GLcontext *ctx, const struct gl_client_array *arrays[], const struct _mesa_prim *prim, @@ -376,6 +380,33 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx, return retval; } +static GLboolean brw_need_rebase( GLcontext *ctx, + const struct gl_client_array *arrays[], + const struct _mesa_index_buffer *ib, + GLuint min_index ) +{ + if (min_index == 0) + return GL_FALSE; + + if (ib) { + if (!vbo_all_varyings_in_vbos(arrays)) + return GL_TRUE; + else + return GL_FALSE; + } + else { + /* Hmm. This isn't quite what I wanted. BRW can actually + * handle the mixed case well enough that we shouldn't need to + * rebase. However, it's probably not very common, nor hugely + * expensive to do it this way: + */ + if (!vbo_all_varyings_in_vbos(arrays)) + return GL_TRUE; + else + return GL_FALSE; + } +} + void brw_draw_prims( GLcontext *ctx, const struct gl_client_array *arrays[], @@ -388,6 +419,21 @@ void brw_draw_prims( GLcontext *ctx, struct intel_context *intel = intel_context(ctx); GLboolean retval; + /* Decide if we want to rebase. If so we end up recursing once + * only into this function. + */ + if (brw_need_rebase( ctx, arrays, ib, min_index )) { + vbo_rebase_prims( ctx, arrays, + prim, nr_prims, + ib, min_index, max_index, + brw_draw_prims ); + + return; + } + + + /* Make a first attempt at drawing: + */ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); @@ -440,14 +486,13 @@ void brw_draw_init( struct brw_context *brw ) for (i = 0; i < BRW_NR_UPLOAD_BUFS; i++) { brw->vb.upload.vbo[i] = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB); - /* XXX: Set these to no-backing-store + /* NOTE: These are set to no-backing-store. */ bmBufferSetInvalidateCB(&brw->intel, intel_bufferobj_buffer(intel_buffer_object(brw->vb.upload.vbo[i])), brw_invalidate_vbo_cb, &brw->intel, GL_TRUE); - } ctx->Driver.BufferData( ctx, diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 90637d16ea..6968d745c1 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -309,7 +309,6 @@ copy_array_to_vbo_array( struct brw_context *brw, GLuint i, const struct gl_client_array *array, GLuint element_size, - GLuint min_index, GLuint count) { GLcontext *ctx = &brw->intel.ctx; @@ -347,7 +346,7 @@ copy_array_to_vbo_array( struct brw_context *brw, map += offset; copy_strided_array( map, - array->Ptr + min_index * array->StrideB, + array->Ptr, element_size, array->StrideB, count); @@ -438,10 +437,8 @@ GLboolean brw_upload_vertices( struct brw_context *brw, } upload[nr_uploads++] = input; - input->vbo_rebase_offset = 0; + assert(min_index == 0); } - else - input->vbo_rebase_offset = min_index * input->glarray->StrideB; } /* Upload interleaved arrays if all uploads are interleaved @@ -454,7 +451,6 @@ GLboolean brw_upload_vertices( struct brw_context *brw, input0->glarray = copy_array_to_vbo_array(brw, 0, input0->glarray, interleave, - min_index, input0->count); for (i = 1; i < nr_uploads; i++) { @@ -472,7 +468,6 @@ GLboolean brw_upload_vertices( struct brw_context *brw, input->glarray = copy_array_to_vbo_array(brw, i, input->glarray, input->element_size, - min_index, input->count); } @@ -520,9 +515,9 @@ GLboolean brw_upload_vertices( struct brw_context *brw, vbp.vb[i].vb0.bits.pad = 0; vbp.vb[i].vb0.bits.access_type = BRW_VERTEXBUFFER_ACCESS_VERTEXDATA; vbp.vb[i].vb0.bits.vb_index = i; - vbp.vb[i].offset = (GLuint)input->glarray->Ptr + input->vbo_rebase_offset; + vbp.vb[i].offset = (GLuint)input->glarray->Ptr; vbp.vb[i].buffer = array_buffer(input->glarray); - vbp.vb[i].max_index = max_index - min_index; + vbp.vb[i].max_index = max_index; } @@ -563,94 +558,32 @@ static GLuint element_size( GLenum type ) - -static void rebase_indices_to_vbo_indices( struct brw_context *brw, - const struct _mesa_index_buffer *index_buffer, - struct gl_buffer_object **vbo_return, - GLuint *offset_return ) +void brw_upload_indices( struct brw_context *brw, + const struct _mesa_index_buffer *index_buffer ) { GLcontext *ctx = &brw->intel.ctx; - GLuint min_index = index_buffer->rebase; - const void *indices = index_buffer->ptr; - GLsizei count = index_buffer->count; - GLenum type = index_buffer->type; - GLuint size = element_size(type) * count; - struct gl_buffer_object *bufferobj; - GLuint offset; - GLuint i; - - get_space(brw, size, &bufferobj, &offset); + struct intel_context *intel = &brw->intel; + GLuint ib_size = get_size(index_buffer->type) * index_buffer->count; + struct gl_buffer_object *bufferobj = index_buffer->obj; + GLuint offset = (GLuint)index_buffer->ptr; - *vbo_return = bufferobj; - *offset_return = offset; + /* Turn into a proper VBO: + */ + if (!bufferobj->Name) { + + /* Get new bufferobj, offset: + */ + get_space(brw, ib_size, &bufferobj, &offset); - if (min_index == 0) { /* Straight upload */ ctx->Driver.BufferSubData( ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, offset, - size, - indices, + ib_size, + index_buffer->ptr, bufferobj); } - else { - void *map = ctx->Driver.MapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - GL_DYNAMIC_DRAW_ARB, - bufferobj); - - map += offset; - - switch (type) { - case GL_UNSIGNED_INT: { - GLuint *ui_map = (GLuint *)map; - const GLuint *ui_indices = (const GLuint *)indices; - - for (i = 0; i < count; i++) - ui_map[i] = ui_indices[i] - min_index; - break; - } - case GL_UNSIGNED_SHORT: { - GLushort *us_map = (GLushort *)map; - const GLushort *us_indices = (const GLushort *)indices; - - for (i = 0; i < count; i++) - us_map[i] = us_indices[i] - min_index; - break; - } - case GL_UNSIGNED_BYTE: { - GLubyte *ub_map = (GLubyte *)map; - const GLubyte *ub_indices = (const GLubyte *)indices; - - for (i = 0; i < count; i++) - ub_map[i] = ub_indices[i] - min_index; - break; - } - } - - ctx->Driver.UnmapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - bufferobj); - - } -} - - - -void brw_upload_indices( struct brw_context *brw, - const struct _mesa_index_buffer *index_buffer) -{ - struct intel_context *intel = &brw->intel; - GLuint ib_size = get_size(index_buffer->type) * index_buffer->count; - struct gl_buffer_object *bufferobj = index_buffer->obj; - GLuint offset = (GLuint)index_buffer->ptr; - - /* Already turned into a proper VBO: - */ - if (!index_buffer->obj->Name) { - rebase_indices_to_vbo_indices(brw, index_buffer, &bufferobj, &offset ); - } /* Emit the indexbuffer packet: */ diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index 0e7c2b6a68..c97cf5f7b2 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -95,18 +95,14 @@ static void free_space(GLcontext *ctx) */ static void _tnl_import_array( GLcontext *ctx, GLuint attrib, - GLuint start, - GLuint end, + GLuint count, const struct gl_client_array *input, const GLubyte *ptr ) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - const GLuint count = end - start; GLuint stride = input->StrideB; - ptr += start * stride; - if (input->Type != GL_FLOAT) { const GLuint sz = input->Size; GLubyte *buf = get_space(ctx, count * sz * sizeof(GLfloat)); @@ -183,7 +179,7 @@ static GLboolean *_tnl_import_edgeflag( GLcontext *ctx, static void bind_inputs( GLcontext *ctx, const struct gl_client_array *inputs[], - GLint min_index, GLint max_index, + GLint count, struct gl_buffer_object **bo, GLuint *nr_bo ) { @@ -215,18 +211,17 @@ static void bind_inputs( GLcontext *ctx, ptr = inputs[i]->Ptr; /* Just make sure the array is floating point, otherwise convert to - * temporary storage. Rebase arrays so that 'min_index' becomes - * element zero. + * temporary storage. * * XXX: remove the GLvector4f type at some stage and just use * client arrays. */ - _tnl_import_array(ctx, i, min_index, max_index, inputs[i], ptr); + _tnl_import_array(ctx, i, count, inputs[i], ptr); } /* We process only the vertices between min & max index: */ - VB->Count = max_index - min_index; + VB->Count = count; /* Legacy pointers -- remove one day. @@ -264,7 +259,6 @@ static void bind_inputs( GLcontext *ctx, */ static void bind_indices( GLcontext *ctx, const struct _mesa_index_buffer *ib, - GLuint min_index, struct gl_buffer_object **bo, GLuint *nr_bo) { @@ -273,8 +267,10 @@ static void bind_indices( GLcontext *ctx, GLuint i; void *ptr; - if (!ib) + if (!ib) { + VB->Elts = NULL; return; + } if (ib->obj->Name && !ib->obj->Pointer) { bo[*nr_bo] = ib->obj; @@ -289,60 +285,34 @@ static void bind_indices( GLcontext *ctx, ptr = ADD_POINTERS(ib->obj->Pointer, ib->ptr); - if (ib->type == GL_UNSIGNED_INT && min_index == 0) { + if (ib->type == GL_UNSIGNED_INT) { VB->Elts = (GLuint *) ptr; - VB->Elts += ib->rebase; } else { GLuint *elts = (GLuint *)get_space(ctx, ib->count * sizeof(GLuint)); VB->Elts = elts; - switch (ib->type) { - case GL_UNSIGNED_INT: { - const GLuint *in = ((GLuint *)ptr) + ib->rebase; - for (i = 0; i < ib->count; i++) - *elts++ = *in++ - min_index; - break; - } - case GL_UNSIGNED_SHORT: { - const GLushort *in = ((GLushort *)ptr) + ib->rebase; + if (ib->type == GL_UNSIGNED_SHORT) { + const GLushort *in = (GLushort *)ptr; for (i = 0; i < ib->count; i++) - *elts++ = (GLuint)(*in++) - min_index; - break; + *elts++ = (GLuint)(*in++); } - case GL_UNSIGNED_BYTE: { - const GLubyte *in = ((GLubyte *)ptr) + ib->rebase; + else { + const GLubyte *in = (GLubyte *)ptr; for (i = 0; i < ib->count; i++) - *elts++ = (GLuint)(*in++) - min_index; - break; + *elts++ = (GLuint)(*in++); } - } } } static void bind_prims( GLcontext *ctx, const struct _mesa_prim *prim, - GLuint nr_prims, - GLuint min_index ) + GLuint nr_prims ) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - GLuint i; - - if (min_index != 0) { - struct _mesa_prim *tmp = (struct _mesa_prim *)get_space(ctx, nr_prims * sizeof(*prim)); - - for (i = 0; i < nr_prims; i++) { - tmp[i] = prim[i]; - tmp[i].start -= min_index; - } - - VB->Primitive = tmp; - } - else { - VB->Primitive = prim; - } + VB->Primitive = prim; VB->PrimitiveCount = nr_prims; } @@ -373,19 +343,10 @@ void _tnl_draw_prims( GLcontext *ctx, GLuint max_index) { TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLint max = VB->Size; - -#ifdef TEST_SPLIT - max = 8 + MAX_CLIPPED_VERTICES; -#endif - - assert(max_index > min_index); - assert(!(max_index & 0x80000000)); + const GLuint TEST_SPLIT = 0; + const GLint max = TEST_SPLIT ? 8 : tnl->vb.Size - MAX_CLIPPED_VERTICES; - VB->Elts = NULL; - -#if 0 + if (0) { GLuint i; _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); @@ -395,15 +356,22 @@ void _tnl_draw_prims( GLcontext *ctx, prim[i].start, prim[i].count); } -#endif - /* The software TNL pipeline has a fixed amount of storage for - * vertices and it is necessary to split incoming drawing commands - * if they exceed that limit. - */ - if (max_index - min_index >= max - MAX_CLIPPED_VERTICES) { + if (min_index) { + /* We always translate away calls with min_index != 0. + */ + vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, + min_index, max_index, + _tnl_draw_prims ); + return; + } + else if (max_index >= max) { + /* The software TNL pipeline has a fixed amount of storage for + * vertices and it is necessary to split incoming drawing commands + * if they exceed that limit. + */ struct split_limits limits; - limits.max_verts = max - MAX_CLIPPED_VERTICES; + limits.max_verts = max; limits.max_vb_size = ~0; limits.max_indices = ~0; @@ -411,7 +379,7 @@ void _tnl_draw_prims( GLcontext *ctx, * recursively call back into this function. */ vbo_split_prims( ctx, arrays, prim, nr_prims, ib, - min_index, max_index, + 0, max_index, _tnl_draw_prims, &limits ); } @@ -425,9 +393,9 @@ void _tnl_draw_prims( GLcontext *ctx, /* Binding inputs may imply mapping some vertex buffer objects. * They will need to be unmapped below. */ - bind_inputs(ctx, arrays, min_index, max_index+1, bo, &nr_bo); - bind_indices(ctx, ib, min_index, bo, &nr_bo); - bind_prims(ctx, prim, nr_prims, VB->Elts ? 0 : min_index ); + bind_inputs(ctx, arrays, max_index+1, bo, &nr_bo); + bind_indices(ctx, ib, bo, &nr_bo); + bind_prims(ctx, prim, nr_prims ); TNL_CONTEXT(ctx)->Driver.RunPipeline(ctx); diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 6a6fb28173..874a5f9e0e 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -55,7 +55,6 @@ struct _mesa_index_buffer { GLenum type; struct gl_buffer_object *obj; const void *ptr; - GLuint rebase; }; diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 5a3a7488ed..f96df5f164 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -34,45 +34,55 @@ #include "vbo_context.h" -static GLuint get_max_index( GLuint count, GLuint type, - const GLvoid *indices ) +/* Compute min and max elements for drawelements calls. + */ +static void get_minmax_index( GLuint count, GLuint type, + const GLvoid *indices, + GLuint *min_index, + GLuint *max_index) { GLint i; - /* Compute max element. This is only needed for upload of non-VBO, - * non-constant data elements. - * - * XXX: Postpone this calculation until it is known that it is - * needed. Otherwise could scan this pointlessly in the all-vbo - * case. - */ switch(type) { case GL_UNSIGNED_INT: { const GLuint *ui_indices = (const GLuint *)indices; - GLuint max_ui = 0; - for (i = 0; i < count; i++) - if (ui_indices[i] > max_ui) - max_ui = ui_indices[i]; - return max_ui; + GLuint max_ui = ui_indices[0]; + GLuint min_ui = ui_indices[0]; + for (i = 1; i < count; i++) { + if (ui_indices[i] > max_ui) max_ui = ui_indices[i]; + if (ui_indices[i] < min_ui) min_ui = ui_indices[i]; + } + *min_index = min_ui; + *max_index = max_ui; + break; } case GL_UNSIGNED_SHORT: { const GLushort *us_indices = (const GLushort *)indices; - GLuint max_us = 0; - for (i = 0; i < count; i++) - if (us_indices[i] > max_us) - max_us = us_indices[i]; - return max_us; + GLuint max_us = us_indices[0]; + GLuint min_us = us_indices[0]; + for (i = 1; i < count; i++) { + if (us_indices[i] > max_us) max_us = us_indices[i]; + if (us_indices[i] < min_us) min_us = us_indices[i]; + } + *min_index = min_us; + *max_index = max_us; + break; } case GL_UNSIGNED_BYTE: { const GLubyte *ub_indices = (const GLubyte *)indices; - GLuint max_ub = 0; - for (i = 0; i < count; i++) - if (ub_indices[i] > max_ub) - max_ub = ub_indices[i]; - return max_ub; + GLuint max_ub = ub_indices[0]; + GLuint min_ub = ub_indices[0]; + for (i = 1; i < count; i++) { + if (ub_indices[i] > max_ub) max_ub = ub_indices[i]; + if (ub_indices[i] < min_ub) min_ub = ub_indices[i]; + } + *min_index = min_ub; + *max_index = max_ub; + break; } default: - return 0; + assert(0); + break; } } @@ -241,31 +251,12 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) prim[0].end = 1; prim[0].weak = 0; prim[0].pad = 0; + prim[0].mode = mode; + prim[0].start = start; + prim[0].count = count; + prim[0].indexed = 0; - if (exec->array.inputs[0]->BufferObj->Name) { - /* Use vertex attribute as a hint to tell us if we expect all - * arrays to be in VBO's and if so, don't worry about avoiding - * the upload of elements < start. - */ - prim[0].mode = mode; - prim[0].start = start; - prim[0].count = count; - prim[0].indexed = 0; - - vbo->draw_prims( ctx, exec->array.inputs, prim, 1, NULL, 0, start + count ); - } - else { - /* If not using VBO's, we don't want to upload any more elements - * than necessary from the arrays as they will not be valid next - * time the application tries to draw with them. - */ - prim[0].mode = mode; - prim[0].start = 0; - prim[0].count = count; - prim[0].indexed = 0; - - vbo->draw_prims( ctx, exec->array.inputs, prim, 1, NULL, start, start + count ); - } + vbo->draw_prims( ctx, exec->array.inputs, prim, 1, NULL, start, start + count - 1 ); } @@ -296,20 +287,6 @@ vbo_exec_DrawRangeElements(GLenum mode, ib.obj = ctx->Array.ElementArrayBufferObj; ib.ptr = indices; - if (ctx->Array.ElementArrayBufferObj->Name) { - /* Use the fact that indices are in a VBO as a hint that the - * program has put all the arrays in VBO's and we don't have to - * worry about performance implications of start > 0. - * - * XXX: consider passing start as min_index to draw_prims instead. - * XXX: don't rebase because it didn't work. - */ - ib.rebase = 0; - } - else { - ib.rebase = /*start*/ 0; - } - prim[0].begin = 1; prim[0].end = 1; prim[0].weak = 0; @@ -319,15 +296,46 @@ vbo_exec_DrawRangeElements(GLenum mode, prim[0].count = count; prim[0].indexed = 1; - vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, /*ib.rebase*/ start, end+1 ); -} + /* Need to give special consideration to rendering a range of + * indices starting somewhere above zero. Typically the + * application is issuing multiple DrawRangeElements() to draw + * successive primitives layed out linearly in the vertex arrays. + * Unless the vertex arrays are all in a VBO (or locked as with + * CVA), the OpenGL semantics imply that we need to re-read or + * re-upload the vertex data on each draw call. + * + * In the case of hardware tnl, we want to avoid starting the + * upload at zero, as it will mean every draw call uploads an + * increasing amount of not-used vertex data. Worse - in the + * software tnl module, all those vertices might be transformed and + * lit but never rendered. + * + * If we just upload or transform the vertices in start..end, + * however, the indices will be incorrect. + * + * At this level, we don't know exactly what the requirements of + * the backend are going to be, though it will likely boil down to + * either: + * + * 1) Do nothing, everything is in a VBO and is processed once + * only. + * + * 2) Adjust the indices and vertex arrays so that start becomes + * zero. + * + * Rather than doing anything here, I'll provide a helper function + * for the latter case elsewhere. + */ + vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib, start, end ); +} static void GLAPIENTRY vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { GET_CURRENT_CONTEXT(ctx); - GLuint max_index; + GLuint min_index = 0; + GLuint max_index = 0; if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices )) return; @@ -338,17 +346,17 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *ind GL_READ_ONLY, ctx->Array.ElementArrayBufferObj); - max_index = get_max_index(count, type, ADD_POINTERS(map, indices)); + get_minmax_index(count, type, ADD_POINTERS(map, indices), &min_index, &max_index); ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, ctx->Array.ElementArrayBufferObj); } else { - max_index = get_max_index(count, type, indices); + get_minmax_index(count, type, indices, &min_index, &max_index); } - vbo_exec_DrawRangeElements(mode, 0, max_index, count, type, indices); + vbo_exec_DrawRangeElements(mode, min_index, max_index, count, type, indices); } diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c index 2a6f03797a..bc4211d852 100644 --- a/src/mesa/vbo/vbo_rebase.c +++ b/src/mesa/vbo/vbo_rebase.c @@ -123,7 +123,8 @@ void vbo_rebase_prims( GLcontext *ctx, assert(min_index != 0); - _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); + if (0) + _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); if (ib) { /* Unfortunately need to adjust each index individually. diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index d9c5853782..ef97acbce7 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -479,7 +479,6 @@ static void replay_init( struct copy_context *copy ) copy->dstib.type = GL_UNSIGNED_INT; copy->dstib.obj = ctx->Array.NullBufferObj; copy->dstib.ptr = copy->dstelt; - copy->dstib.rebase = 0; } diff --git a/src/mesa/vbo/vbo_split_inplace.c b/src/mesa/vbo/vbo_split_inplace.c index d3649c59db..ea62866e7c 100644 --- a/src/mesa/vbo/vbo_split_inplace.c +++ b/src/mesa/vbo/vbo_split_inplace.c @@ -223,7 +223,6 @@ static void split_prims( struct split_context *split) ib.type = GL_UNSIGNED_INT; ib.obj = split->ctx->Array.NullBufferObj; ib.ptr = elts; - ib.rebase = 0; /* ? */ tmpprim = *prim; tmpprim.indexed = 1; -- cgit v1.2.3 From fcccf8943213a20957f305161e8aae7fef55baab Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Fri, 9 Feb 2007 13:28:56 +0800 Subject: array overflow fix --- src/mesa/vbo/vbo_exec_array.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index f96df5f164..7ea55470ac 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -147,8 +147,8 @@ static void recalculate_input_bindings( GLcontext *ctx ) /* Could use just about anything, just to fill in the empty * slots: */ - for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX; i++) - inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0]; + for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX - VERT_ATTRIB_GENERIC0; i++) + inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i]; break; case VP_NV: -- cgit v1.2.3 From 7d8ed0f5f5960a492734cb415b8a85ef4ad79846 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 14 Feb 2007 20:34:52 +0100 Subject: fix typo preventing generic arrays from working with ARB_vp (bug #9952) --- src/mesa/vbo/vbo_exec_array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/vbo/vbo_exec_array.c') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 7ea55470ac..1e4c310203 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -196,7 +196,7 @@ static void recalculate_input_bindings( GLcontext *ctx ) } for (i = 0; i < 16; i++) { - if (exec->array.generic_array[0]->Enabled) + if (exec->array.generic_array[i]->Enabled) inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i]; else inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i]; -- cgit v1.2.3