From: Mathias Fröhlich Date: Sun, 1 Apr 2018 18:18:36 +0000 (+0200) Subject: mesa/vbo/tnl: Move gl_vertex_array related stuff to tnl. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f6606830271192dc0232b54b776ec263235c0688;p=mesa.git mesa/vbo/tnl: Move gl_vertex_array related stuff to tnl. The only remaining users of gl_vertex_array are tnl based drivers. So move everything related to that into tnl and rename it accordingly. Reviewed-by: Brian Paul Signed-off-by: Mathias Fröhlich --- diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c index d031ebeabd3..3900c770cbe 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c @@ -41,7 +41,7 @@ * structures. */ static int -get_array_stride(struct gl_context *ctx, const struct gl_vertex_array *a) +get_array_stride(struct gl_context *ctx, const struct tnl_vertex_array *a) { struct nouveau_render_state *render = to_render_state(ctx); const struct gl_vertex_buffer_binding *binding = a->BufferBinding; @@ -57,7 +57,7 @@ get_array_stride(struct gl_context *ctx, const struct gl_vertex_array *a) static void vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib, - const struct gl_vertex_array *arrays) + const struct tnl_vertex_array *arrays) { struct nouveau_render_state *render = to_render_state(ctx); GLboolean imm = (render->mode == IMM); @@ -78,7 +78,7 @@ vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib, } FOR_EACH_BOUND_ATTR(render, i, attr) { - const struct gl_vertex_array *array = &arrays[attr]; + const struct tnl_vertex_array *array = &arrays[attr]; const struct gl_vertex_buffer_binding *binding = array->BufferBinding; const struct gl_array_attributes *attrib = array->VertexAttrib; @@ -94,7 +94,7 @@ vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib, static void vbo_deinit_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib, - const struct gl_vertex_array *arrays) + const struct tnl_vertex_array *arrays) { struct nouveau_render_state *render = to_render_state(ctx); int i, attr; @@ -118,7 +118,7 @@ vbo_deinit_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib, /* Make some rendering decisions from the GL context. */ static void -vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array *arrays) +vbo_choose_render_mode(struct gl_context *ctx, const struct tnl_vertex_array *arrays) { struct nouveau_render_state *render = to_render_state(ctx); int i; @@ -136,12 +136,12 @@ vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array *arr } static void -vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array *arrays, +vbo_emit_attr(struct gl_context *ctx, const struct tnl_vertex_array *arrays, int attr) { struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_render_state *render = to_render_state(ctx); - const struct gl_vertex_array *array = &arrays[attr]; + const struct tnl_vertex_array *array = &arrays[attr]; const struct gl_vertex_buffer_binding *binding = array->BufferBinding; const struct gl_array_attributes *attrib = array->VertexAttrib; const GLubyte *p = _mesa_vertex_attrib_address(attrib, binding); @@ -179,7 +179,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array *arrays, #define MAT(a) VERT_ATTRIB_MAT(MAT_ATTRIB_##a) static void -vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array *arrays) +vbo_choose_attrs(struct gl_context *ctx, const struct tnl_vertex_array *arrays) { struct nouveau_render_state *render = to_render_state(ctx); int i; @@ -222,13 +222,13 @@ vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array *arrays) } static int -get_max_client_stride(struct gl_context *ctx, const struct gl_vertex_array *arrays) +get_max_client_stride(struct gl_context *ctx, const struct tnl_vertex_array *arrays) { struct nouveau_render_state *render = to_render_state(ctx); int i, attr, s = 0; FOR_EACH_BOUND_ATTR(render, i, attr) { - const struct gl_vertex_array *a = &arrays[attr]; + const struct tnl_vertex_array *a = &arrays[attr]; if (!_mesa_is_bufferobj(a->BufferBinding->BufferObj)) s = MAX2(s, get_array_stride(ctx, a)); @@ -239,7 +239,7 @@ get_max_client_stride(struct gl_context *ctx, const struct gl_vertex_array *arra static void TAG(vbo_render_prims)(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, GLboolean index_bounds_valid, @@ -249,7 +249,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx, struct gl_buffer_object *indirect); static GLboolean -vbo_maybe_split(struct gl_context *ctx, const struct gl_vertex_array *arrays, +vbo_maybe_split(struct gl_context *ctx, const struct tnl_vertex_array *arrays, const struct _mesa_prim *prims, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLuint min_index, GLuint max_index) @@ -309,7 +309,7 @@ check_update_array(struct nouveau_array *a, unsigned offset, } static void -vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array *arrays, +vbo_bind_vertices(struct gl_context *ctx, const struct tnl_vertex_array *arrays, int base, unsigned min_index, unsigned max_index, int *pdelta) { struct nouveau_render_state *render = to_render_state(ctx); @@ -323,7 +323,7 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array *arrays, *pdelta = -1; FOR_EACH_BOUND_ATTR(render, i, attr) { - const struct gl_vertex_array *array = &arrays[attr]; + const struct tnl_vertex_array *array = &arrays[attr]; const struct gl_vertex_buffer_binding *binding = array->BufferBinding; const struct gl_array_attributes *attrib = array->VertexAttrib; @@ -381,7 +381,7 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array *arrays, } static void -vbo_draw_vbo(struct gl_context *ctx, const struct gl_vertex_array *arrays, +vbo_draw_vbo(struct gl_context *ctx, const struct tnl_vertex_array *arrays, const struct _mesa_prim *prims, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLuint min_index, GLuint max_index) @@ -431,7 +431,7 @@ extract_id(struct nouveau_array *a, int i, int j) } static void -vbo_draw_imm(struct gl_context *ctx, const struct gl_vertex_array *arrays, +vbo_draw_imm(struct gl_context *ctx, const struct tnl_vertex_array *arrays, const struct _mesa_prim *prims, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLuint min_index, GLuint max_index) @@ -477,7 +477,7 @@ vbo_draw_imm(struct gl_context *ctx, const struct gl_vertex_array *arrays, static void TAG(vbo_render_prims)(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, GLboolean index_bounds_valid, @@ -515,7 +515,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx, static void TAG(vbo_check_render_prims)(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, GLboolean index_bounds_valid, @@ -550,7 +550,7 @@ TAG(vbo_draw)(struct gl_context *ctx, struct gl_buffer_object *indirect) { /* Borrow and update the inputs list from the tnl context */ - const struct gl_vertex_array* arrays = _tnl_bind_inputs(ctx); + const struct tnl_vertex_array* arrays = _tnl_bind_inputs(ctx); TAG(vbo_check_render_prims)(ctx, arrays, prims, nr_prims, ib, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 0b55a510b08..2ef12a444ea 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1499,20 +1499,6 @@ struct gl_vertex_buffer_binding }; -/** - * Vertex array information which is derived from gl_array_attributes - * and gl_vertex_buffer_binding information. Used by the VBO module and - * device drivers. - */ -struct gl_vertex_array -{ - /** Vertex attribute array */ - const struct gl_array_attributes *VertexAttrib; - /** Vertex buffer binding */ - const struct gl_vertex_buffer_binding *BufferBinding; -}; - - /** * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ / * the GL_ARB_vertex_array_object extension. diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index 6ab55ed36ae..1f01fdd5b10 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -449,18 +449,6 @@ _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint divisor); -/** - * Shallow copy one vertex array to another. - */ -static inline void -_mesa_copy_vertex_array(struct gl_vertex_array *dst, - const struct gl_vertex_array *src) -{ - dst->VertexAttrib = src->VertexAttrib; - dst->BufferBinding = src->BufferBinding; -} - - extern void _mesa_copy_vertex_attrib_array(struct gl_context *ctx, struct gl_array_attributes *dst, diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h index c1ebcd9f748..5b897bda118 100644 --- a/src/mesa/state_tracker/st_draw.h +++ b/src/mesa/state_tracker/st_draw.h @@ -38,7 +38,6 @@ struct _mesa_index_buffer; struct _mesa_prim; -struct gl_vertex_array; struct gl_context; struct st_context; 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 /* @@ -496,6 +498,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. */ @@ -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 #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; @@ -112,6 +112,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 @@ -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, diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index ca46f9baa79..4e3f15999c0 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -38,9 +38,7 @@ extern "C" { #endif -struct gl_vertex_array; struct gl_context; -struct gl_transform_feedback_object; struct _mesa_prim { @@ -151,41 +149,6 @@ vbo_sw_primitive_restart(struct gl_context *ctx, struct gl_buffer_object *indirect); -/** - * Utility that tracks and updates the current array entries. - */ -struct vbo_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 gl_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 -_vbo_init_inputs(struct vbo_inputs *inputs); - - -/** - * Update the gl_vertex_array array inside the vbo_inputs structure - * provided the current _VPMode, the provided vao and - * the vao's enabled arrays filtered by the filter bitmask. - */ -void -_vbo_update_inputs(struct gl_context *ctx, struct vbo_inputs *inputs); - - const struct gl_array_attributes* _vbo_current_attrib(const struct gl_context *ctx, gl_vert_attrib attr); diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index 357ec1da767..34dbc001c92 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -239,89 +239,3 @@ vbo_merge_prims(struct _mesa_prim *p0, const struct _mesa_prim *p1) p0->count += p1->count; p0->end = p1->end; } - - -void -_vbo_init_inputs(struct vbo_inputs *inputs) -{ - inputs->current = 0; - inputs->vertex_processing_mode = VP_MODE_FF; -} - - -/** - * Update the vbo_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 vbo_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 GLubyte *const map = _mesa_vao_attribute_map[vao->_AttributeMapMode]; - const struct gl_array_attributes *attribs = &vao->VertexAttrib[0]; - const struct gl_vertex_buffer_binding *bindings = &vao->BufferBinding[0]; - while (enable) { - const int attr = u_bit_scan(&enable); - struct gl_vertex_array *input = &inputs->inputs[attr]; - const struct gl_array_attributes *attrib = &attribs[map[attr]]; - input->VertexAttrib = attrib; - input->BufferBinding = &bindings[attrib->BufferBindingIndex]; - } -} - - -/** - * Update the vbo_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 vbo_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; - - struct vbo_context *vbo = vbo_context(ctx); - const struct gl_array_attributes *const currval = &vbo->current[0]; - const GLubyte *const map = _vbo_attribute_alias_map[mode]; - while (mask) { - const int attr = u_bit_scan(&mask); - struct gl_vertex_array *input = &inputs->inputs[attr]; - input->VertexAttrib = &currval[map[attr]]; - input->BufferBinding = &vbo->binding; - } - - inputs->current = current; - inputs->vertex_processing_mode = mode; -} - - -/** - * Update the vbo_inputs's arrays to point to the vao->_VertexArray and - * vbo->currval arrays according to Array._DrawVAO and - * Array._DrawVAOEnableAttribs. - */ -void -_vbo_update_inputs(struct gl_context *ctx, struct vbo_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); -}