X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Ftnl%2Ft_vertex.c;h=fe4209ae577f0491e4c6984749154d14abd6ef95;hb=9b70c33e735ff060ddad7d0b501d19c670f41618;hp=f4847f757814c1810b0c2c6cea7751789a78adb2;hpb=9557401a98b9585289fe8f65be33b6c5fda79095;p=mesa.git diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index f4847f75781..fe4209ae577 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -25,9 +25,9 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" #include "t_context.h" #include "t_vertex.h" @@ -46,7 +46,9 @@ static GLboolean match_fastpath( struct tnl_clipspace *vtx, return GL_FALSE; for (j = 0; j < vtx->attr_count; j++) - if (vtx->attr[j].format != fp->attr[j].format) + if (vtx->attr[j].format != fp->attr[j].format || + vtx->attr[j].inputsize != fp->attr[j].size || + vtx->attr[j].vertoffset != fp->attr[j].offset) return GL_FALSE; if (fp->match_strides) { @@ -85,11 +87,14 @@ void _tnl_register_fastpath( struct tnl_clipspace *vtx, fastpath->attr_count = vtx->attr_count; fastpath->match_strides = match_strides; fastpath->func = vtx->emit; - fastpath->attr = MALLOC(vtx->attr_count * sizeof(fastpath->attr[0])); + fastpath->attr = (struct tnl_attr_type *) + _mesa_malloc(vtx->attr_count * sizeof(fastpath->attr[0])); for (i = 0; i < vtx->attr_count; i++) { fastpath->attr[i].format = vtx->attr[i].format; fastpath->attr[i].stride = vtx->attr[i].inputstride; + fastpath->attr[i].size = vtx->attr[i].inputsize; + fastpath->attr[i].offset = vtx->attr[i].vertoffset; } fastpath->next = vtx->fastpath; @@ -224,7 +229,15 @@ void _tnl_get_attr( GLcontext *ctx, const void *vin, /* Else return the value from ctx->Current. */ - _mesa_memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat)); + if (attr == _TNL_ATTRIB_POINTSIZE) { + /* If the hardware vertex doesn't have point size then use size from + * GLcontext. XXX this will be wrong if drawing attenuated points! + */ + dest[0] = ctx->Point.Size; + } + else { + _mesa_memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat)); + } } @@ -363,6 +376,22 @@ void _tnl_notify_pipeline_output_change( GLcontext *ctx ) invalidate_funcs(vtx); } + +static void adjust_input_ptrs( GLcontext *ctx, GLint diff) +{ + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); + struct tnl_clipspace_attr *a = vtx->attr; + const GLuint count = vtx->attr_count; + int j; + + diff -= 1; + for (j=0; jAttribPtr[a->attrib]; + (a++)->inputptr += diff*vptr->stride; + } +} + static void update_input_ptrs( GLcontext *ctx, GLuint start ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; @@ -418,13 +447,40 @@ void *_tnl_emit_vertices_to_buffer( GLcontext *ctx, struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); update_input_ptrs(ctx, start); - /* Note: dest should not be adjusted for non-zero 'start' values: */ - vtx->emit( ctx, end - start, dest ); + vtx->emit( ctx, end - start, (GLubyte*) dest ); return (void *)((GLubyte *)dest + vtx->vertex_size * (end - start)); } +/* Emit indexed VB vertices start..end to dest. Note that VB vertex at + * postion start will be emitted to dest at position zero. + */ + +void *_tnl_emit_indexed_vertices_to_buffer( GLcontext *ctx, + const GLuint *elts, + GLuint start, + GLuint end, + void *dest ) +{ + struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); + GLuint oldIndex; + GLubyte *cdest = dest; + + update_input_ptrs(ctx, oldIndex = elts[start++]); + vtx->emit( ctx, 1, cdest ); + cdest += vtx->vertex_size; + + for (; start < end; ++start) { + adjust_input_ptrs(ctx, elts[start] - oldIndex); + oldIndex = elts[start]; + vtx->emit( ctx, 1, cdest); + cdest += vtx->vertex_size; + } + + return (void *) cdest; +} + void _tnl_init_vertices( GLcontext *ctx, GLuint vb_size, @@ -470,8 +526,8 @@ void _tnl_init_vertices( GLcontext *ctx, vtx->codegen_emit = NULL; -#ifdef __i386__ - if (getenv("MESA_EXPERIMENTAL")) +#ifdef USE_SSE_ASM + if (!_mesa_getenv("MESA_NO_CODEGEN")) vtx->codegen_emit = _tnl_generate_sse_emit; #endif } @@ -479,20 +535,30 @@ void _tnl_init_vertices( GLcontext *ctx, void _tnl_free_vertices( GLcontext *ctx ) { - struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); - struct tnl_clipspace_fastpath *fp, *tmp; + TNLcontext *tnl = TNL_CONTEXT(ctx); + if (tnl) { + struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); + struct tnl_clipspace_fastpath *fp, *tmp; - if (vtx->vertex_buf) { - ALIGN_FREE(vtx->vertex_buf); - vtx->vertex_buf = NULL; - } - - for (fp = vtx->fastpath ; fp ; fp = tmp) { - tmp = fp->next; - FREE(fp->attr); - FREE((void *)fp->func); - FREE(fp); + if (vtx->vertex_buf) { + ALIGN_FREE(vtx->vertex_buf); + vtx->vertex_buf = NULL; + } + + for (fp = vtx->fastpath ; fp ; fp = tmp) { + tmp = fp->next; + FREE(fp->attr); + + /* KW: At the moment, fp->func is constrained to be allocated by + * _mesa_exec_alloc(), as the hardwired fastpaths in + * t_vertex_generic.c are handled specially. It would be nice + * to unify them, but this probably won't change until this + * module gets another overhaul. + */ + _mesa_exec_free((void *) fp->func); + FREE(fp); + } + + vtx->fastpath = NULL; } - - vtx->fastpath = NULL; }