diff options
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_context.c | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 41 | ||||
-rw-r--r-- | src/mesa/tnl/t_draw.c | 95 | ||||
-rw-r--r-- | src/mesa/tnl/t_rebase.c | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_rebase.h | 2 | ||||
-rw-r--r-- | src/mesa/tnl/t_split.c | 2 | ||||
-rw-r--r-- | src/mesa/tnl/t_split.h | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_split_copy.c | 34 | ||||
-rw-r--r-- | src/mesa/tnl/t_split_inplace.c | 4 | ||||
-rw-r--r-- | src/mesa/tnl/tnl.h | 24 |
10 files changed, 180 insertions, 34 deletions
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 345f0bf8584..3383b235250 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -99,8 +99,8 @@ _tnl_CreateContext( struct gl_context *ctx ) _math_init_transformation(); _math_init_translate(); - /* Keep our list of gl_vertex_array inputs */ - _vbo_init_inputs(&tnl->draw_arrays); + /* Keep our list of tnl_vertex_array inputs */ + _tnl_init_inputs(&tnl->draw_arrays); return GL_TRUE; } diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 4827480e1a7..eca9f66037a 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -57,6 +57,8 @@ #include "vbo/vbo.h" +#include "tnl.h" + #define MAX_PIPELINE_STAGES 30 /* @@ -497,6 +499,41 @@ struct tnl_device_driver /** + * Utility that tracks and updates the current array entries. + */ +struct tnl_inputs +{ + /** + * Array of inputs to be set to the _DrawArrays pointer. + * The array contains pointers into the _DrawVAO and to the vbo modules + * current values. The array of pointers is updated incrementally + * based on the current and vertex_processing_mode values below. + */ + struct tnl_vertex_array inputs[VERT_ATTRIB_MAX]; + /** Those VERT_BIT_'s where the inputs array point to current values. */ + GLbitfield current; + /** Store which aliasing current values - generics or materials - are set. */ + gl_vertex_processing_mode vertex_processing_mode; +}; + + +/** + * Initialize inputs. + */ +void +_tnl_init_inputs(struct tnl_inputs *inputs); + + +/** + * Update the tnl_vertex_array array inside the tnl_inputs structure + * provided the current _VPMode, the provided vao and + * the vao's enabled arrays filtered by the filter bitmask. + */ +void +_tnl_update_inputs(struct gl_context *ctx, struct tnl_inputs *inputs); + + +/** * Context state for T&L context. */ typedef struct @@ -537,8 +574,8 @@ typedef struct struct tnl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ /**@}*/ - /* The list of gl_vertex_array inputs. */ - struct vbo_inputs draw_arrays; + /* The list of tnl_vertex_array inputs. */ + struct tnl_inputs draw_arrays; } TNLcontext; diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index 9814cdcec18..1fe2d405cb6 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -28,6 +28,7 @@ #include <stdio.h> #include "main/glheader.h" +#include "main/arrayobj.h" #include "main/bufferobj.h" #include "main/condrender.h" #include "main/context.h" @@ -273,7 +274,7 @@ static GLboolean *_tnl_import_edgeflag( struct gl_context *ctx, static void bind_inputs( struct gl_context *ctx, - const struct gl_vertex_array *inputs, + const struct tnl_vertex_array *inputs, GLint count, struct gl_buffer_object **bo, GLuint *nr_bo ) @@ -285,7 +286,7 @@ static void bind_inputs( struct gl_context *ctx, /* Map all the VBOs */ for (i = 0; i < VERT_ATTRIB_MAX; i++) { - const struct gl_vertex_array *array = &inputs[i]; + const struct tnl_vertex_array *array = &inputs[i]; const struct gl_vertex_buffer_binding *binding = array->BufferBinding; const struct gl_array_attributes *attrib = array->VertexAttrib; const void *ptr; @@ -426,7 +427,7 @@ static void unmap_vbos( struct gl_context *ctx, /* This is the main workhorse doing all the rendering work. */ void _tnl_draw_prims(struct gl_context *ctx, - const struct gl_vertex_array *arrays, + const struct tnl_vertex_array *arrays, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, @@ -537,11 +538,93 @@ void _tnl_draw_prims(struct gl_context *ctx, } -const struct gl_vertex_array* +void +_tnl_init_inputs(struct tnl_inputs *inputs) +{ + inputs->current = 0; + inputs->vertex_processing_mode = VP_MODE_FF; +} + + +/** + * Update the tnl_inputs's arrays to point to the vao->_VertexArray arrays + * according to the 'enable' bitmask. + * \param enable bitfield of VERT_BIT_x flags. + */ +static inline void +update_vao_inputs(struct gl_context *ctx, + struct tnl_inputs *inputs, GLbitfield enable) +{ + const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO; + + /* Make sure we process only arrays enabled in the VAO */ + assert((enable & ~_mesa_get_vao_vp_inputs(vao)) == 0); + + /* Fill in the client arrays from the VAO */ + const struct gl_vertex_buffer_binding *bindings = &vao->BufferBinding[0]; + while (enable) { + const int attr = u_bit_scan(&enable); + struct tnl_vertex_array *input = &inputs->inputs[attr]; + const struct gl_array_attributes *attrib; + attrib = _mesa_draw_array_attrib(vao, attr); + input->VertexAttrib = attrib; + input->BufferBinding = &bindings[attrib->BufferBindingIndex]; + } +} + + +/** + * Update the tnl_inputs's arrays to point to the vbo->currval arrays + * according to the 'current' bitmask. + * \param current bitfield of VERT_BIT_x flags. + */ +static inline void +update_current_inputs(struct gl_context *ctx, + struct tnl_inputs *inputs, GLbitfield current) +{ + gl_vertex_processing_mode mode = ctx->VertexProgram._VPMode; + + /* All previously non current array pointers need update. */ + GLbitfield mask = current & ~inputs->current; + /* On mode change, the slots aliasing with materials need update too */ + if (mode != inputs->vertex_processing_mode) + mask |= current & VERT_BIT_MAT_ALL; + + while (mask) { + const int attr = u_bit_scan(&mask); + struct tnl_vertex_array *input = &inputs->inputs[attr]; + input->VertexAttrib = _vbo_current_attrib(ctx, attr); + input->BufferBinding = _vbo_current_binding(ctx); + } + + inputs->current = current; + inputs->vertex_processing_mode = mode; +} + + +/** + * Update the tnl_inputs's arrays to point to the vao->_VertexArray and + * vbo->currval arrays according to Array._DrawVAO and + * Array._DrawVAOEnableAttribs. + */ +void +_tnl_update_inputs(struct gl_context *ctx, struct tnl_inputs *inputs) +{ + const GLbitfield enable = ctx->Array._DrawVAOEnabledAttribs; + + /* Update array input pointers */ + update_vao_inputs(ctx, inputs, enable); + + /* The rest must be current inputs. */ + update_current_inputs(ctx, inputs, ~enable & VERT_BIT_ALL); +} + + +const struct tnl_vertex_array* _tnl_bind_inputs( struct gl_context *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - _vbo_update_inputs(ctx, &tnl->draw_arrays); + _tnl_update_inputs(ctx, &tnl->draw_arrays); return tnl->draw_arrays.inputs; } @@ -560,7 +643,7 @@ _tnl_draw(struct gl_context *ctx, { /* Update TNLcontext::draw_arrays and return that pointer. */ - const struct gl_vertex_array* arrays = _tnl_bind_inputs(ctx); + const struct tnl_vertex_array* arrays = _tnl_bind_inputs(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, index_bounds_valid, min_index, max_index, diff --git a/src/mesa/tnl/t_rebase.c b/src/mesa/tnl/t_rebase.c index 09a8a3da720..b6950e04fec 100644 --- a/src/mesa/tnl/t_rebase.c +++ b/src/mesa/tnl/t_rebase.c @@ -104,7 +104,7 @@ REBASE(GLubyte) * all or nothing. */ void t_rebase_prims( struct gl_context *ctx, - const struct gl_vertex_array *arrays, + const struct tnl_vertex_array *arrays, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, @@ -113,7 +113,7 @@ void t_rebase_prims( struct gl_context *ctx, tnl_draw_func draw ) { struct gl_array_attributes tmp_attribs[VERT_ATTRIB_MAX]; - struct gl_vertex_array tmp_arrays[VERT_ATTRIB_MAX]; + struct tnl_vertex_array tmp_arrays[VERT_ATTRIB_MAX]; struct _mesa_index_buffer tmp_ib; struct _mesa_prim *tmp_prims = NULL; diff --git a/src/mesa/tnl/t_rebase.h b/src/mesa/tnl/t_rebase.h index ce2e8b0590e..d0aa9e18905 100644 --- a/src/mesa/tnl/t_rebase.h +++ b/src/mesa/tnl/t_rebase.h @@ -28,7 +28,7 @@ #include "tnl.h" void t_rebase_prims( struct gl_context *ctx, - const struct gl_vertex_array *arrays, + const struct tnl_vertex_array *arrays, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, diff --git a/src/mesa/tnl/t_split.c b/src/mesa/tnl/t_split.c index b98bd404d52..d7aac10e4c8 100644 --- a/src/mesa/tnl/t_split.c +++ b/src/mesa/tnl/t_split.c @@ -100,7 +100,7 @@ _tnl_split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr) void _tnl_split_prims(struct gl_context *ctx, - const struct gl_vertex_array arrays[], + const struct tnl_vertex_array arrays[], const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, diff --git a/src/mesa/tnl/t_split.h b/src/mesa/tnl/t_split.h index ced7d30bdf1..49017e5dfb8 100644 --- a/src/mesa/tnl/t_split.h +++ b/src/mesa/tnl/t_split.h @@ -51,7 +51,7 @@ _tnl_split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr); void _tnl_split_inplace(struct gl_context *ctx, - const struct gl_vertex_array arrays[], + const struct tnl_vertex_array arrays[], const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, @@ -64,7 +64,7 @@ _tnl_split_inplace(struct gl_context *ctx, */ void _tnl_split_copy(struct gl_context *ctx, - const struct gl_vertex_array arrays[], + const struct tnl_vertex_array arrays[], const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, diff --git a/src/mesa/tnl/t_split_copy.c b/src/mesa/tnl/t_split_copy.c index f76a470b5ff..cbb7eb409f9 100644 --- a/src/mesa/tnl/t_split_copy.c +++ b/src/mesa/tnl/t_split_copy.c @@ -53,7 +53,7 @@ */ struct copy_context { struct gl_context *ctx; - const struct gl_vertex_array *array; + const struct tnl_vertex_array *array; const struct _mesa_prim *prim; GLuint nr_prims; const struct _mesa_index_buffer *ib; @@ -64,7 +64,7 @@ struct copy_context { struct { GLuint attr; GLuint size; - const struct gl_vertex_array *array; + const struct tnl_vertex_array *array; const GLubyte *src_ptr; struct gl_vertex_buffer_binding dstbinding; @@ -73,7 +73,7 @@ struct copy_context { } varying[VERT_ATTRIB_MAX]; GLuint nr_varying; - struct gl_vertex_array dstarray[VERT_ATTRIB_MAX]; + struct tnl_vertex_array dstarray[VERT_ATTRIB_MAX]; struct _mesa_index_buffer dstib; GLuint *translated_elt_buf; @@ -113,6 +113,18 @@ attr_size(const struct gl_array_attributes *attrib) /** + * Shallow copy one vertex array to another. + */ +static inline void +copy_vertex_array(struct tnl_vertex_array *dst, + const struct tnl_vertex_array *src) +{ + dst->VertexAttrib = src->VertexAttrib; + dst->BufferBinding = src->BufferBinding; +} + + +/** * Starts returning true slightly before the buffer fills, to ensure * that there is sufficient room for any remaining vertices to finish * off the prim: @@ -142,7 +154,7 @@ check_flush(struct copy_context *copy) */ static void dump_draw_info(struct gl_context *ctx, - const struct gl_vertex_array *arrays, + const struct tnl_vertex_array *arrays, const struct _mesa_prim *prims, GLuint nr_prims, const struct _mesa_index_buffer *ib, @@ -157,7 +169,7 @@ dump_draw_info(struct gl_context *ctx, printf(" Prim mode 0x%x\n", prims[i].mode); printf(" IB: %p\n", (void*) ib); for (j = 0; j < VERT_ATTRIB_MAX; j++) { - const struct gl_vertex_array *array = &arrays[j]; + const struct tnl_vertex_array *array = &arrays[j]; const struct gl_vertex_buffer_binding *binding = array->BufferBinding; const struct gl_array_attributes *attrib = array->VertexAttrib; @@ -254,7 +266,7 @@ elt(struct copy_context *copy, GLuint elt_idx) GLuint i; for (i = 0; i < copy->nr_varying; i++) { - const struct gl_vertex_array *srcarray = copy->varying[i].array; + const struct tnl_vertex_array *srcarray = copy->varying[i].array; const struct gl_vertex_buffer_binding* srcbinding = srcarray->BufferBinding; const GLubyte *srcptr @@ -432,11 +444,11 @@ replay_init(struct copy_context *copy) */ copy->vertex_size = 0; for (i = 0; i < VERT_ATTRIB_MAX; i++) { - const struct gl_vertex_array *array = ©->array[i]; + const struct tnl_vertex_array *array = ©->array[i]; const struct gl_vertex_buffer_binding *binding = array->BufferBinding; if (binding->Stride == 0) { - _mesa_copy_vertex_array(©->dstarray[i], array); + copy_vertex_array(©->dstarray[i], array); } else { const struct gl_array_attributes *attrib = array->VertexAttrib; @@ -517,9 +529,9 @@ replay_init(struct copy_context *copy) /* Setup new vertex arrays to point into the output buffer: */ for (offset = 0, i = 0; i < copy->nr_varying; i++) { - const struct gl_vertex_array *src = copy->varying[i].array; + const struct tnl_vertex_array *src = copy->varying[i].array; const struct gl_array_attributes *srcattr = src->VertexAttrib; - struct gl_vertex_array *dst = ©->dstarray[i]; + struct tnl_vertex_array *dst = ©->dstarray[i]; struct gl_vertex_buffer_binding *dstbind = ©->varying[i].dstbinding; struct gl_array_attributes *dstattr = ©->varying[i].dstattribs; @@ -591,7 +603,7 @@ replay_finish(struct copy_context *copy) */ void _tnl_split_copy(struct gl_context *ctx, - const struct gl_vertex_array *arrays, + const struct tnl_vertex_array *arrays, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, diff --git a/src/mesa/tnl/t_split_inplace.c b/src/mesa/tnl/t_split_inplace.c index 15a09861c73..8e9ecb70468 100644 --- a/src/mesa/tnl/t_split_inplace.c +++ b/src/mesa/tnl/t_split_inplace.c @@ -43,7 +43,7 @@ */ struct split_context { struct gl_context *ctx; - const struct gl_vertex_array *array; + const struct tnl_vertex_array *array; const struct _mesa_prim *prim; GLuint nr_prims; const struct _mesa_index_buffer *ib; @@ -265,7 +265,7 @@ split_prims(struct split_context *split) void _tnl_split_inplace(struct gl_context *ctx, - const struct gl_vertex_array *arrays, + const struct tnl_vertex_array *arrays, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, diff --git a/src/mesa/tnl/tnl.h b/src/mesa/tnl/tnl.h index 4b6d5ec3919..5d84a1c8a7d 100644 --- a/src/mesa/tnl/tnl.h +++ b/src/mesa/tnl/tnl.h @@ -30,7 +30,6 @@ #include "main/glheader.h" -struct gl_vertex_array; struct gl_context; struct gl_program; struct gl_buffer_object; @@ -66,7 +65,22 @@ _tnl_wakeup( struct gl_context *ctx ); extern void _tnl_need_projected_coords( struct gl_context *ctx, GLboolean flag ); -extern const struct gl_vertex_array* + +/** + * Vertex array information which is derived from gl_array_attributes + * and gl_vertex_buffer_binding information. Used by the TNL module and + * device drivers. + */ +struct tnl_vertex_array +{ + /** Vertex attribute array */ + const struct gl_array_attributes *VertexAttrib; + /** Vertex buffer binding */ + const struct gl_vertex_buffer_binding *BufferBinding; +}; + + +extern const struct tnl_vertex_array* _tnl_bind_inputs( struct gl_context *ctx ); @@ -86,7 +100,7 @@ struct _mesa_index_buffer; void _tnl_draw_prims(struct gl_context *ctx, - const struct gl_vertex_array *arrays, + const struct tnl_vertex_array *arrays, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, @@ -153,7 +167,7 @@ _tnl_validate_shine_tables( struct gl_context *ctx ); * This may be deprecated in the future */ typedef void (*tnl_draw_func)(struct gl_context *ctx, - const struct gl_vertex_array* arrays, + const struct tnl_vertex_array* arrays, const struct _mesa_prim *prims, GLuint nr_prims, const struct _mesa_index_buffer *ib, @@ -181,7 +195,7 @@ struct split_limits void _tnl_split_prims(struct gl_context *ctx, - const struct gl_vertex_array *arrays, + const struct tnl_vertex_array *arrays, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, |