diff options
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_context.c | 2 | ||||
-rw-r--r-- | src/mesa/tnl/t_draw.c | 18 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_cliptmp.h | 35 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_program.c | 32 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_rendertmp.h | 101 | ||||
-rw-r--r-- | src/mesa/tnl/tnl.h | 10 |
6 files changed, 166 insertions, 32 deletions
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index f69b122046..f2771cde09 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -81,7 +81,7 @@ _tnl_CreateContext( GLcontext *ctx ) tnl->nr_blocks = 0; /* plug in the VBO drawing function */ - vbo_set_draw_func(ctx, _tnl_draw_prims); + vbo_set_draw_func(ctx, _tnl_vbo_draw_prims); _math_init_transformation(); _math_init_translate(); diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index 2ec65d5323..c64c2c2077 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -360,6 +360,20 @@ static void unmap_vbos( GLcontext *ctx, } +void _tnl_vbo_draw_prims(GLcontext *ctx, + const struct gl_client_array *arrays[], + const struct _mesa_prim *prim, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLboolean index_bounds_valid, + GLuint min_index, + GLuint max_index) +{ + if (!index_bounds_valid) + vbo_get_minmax_index(ctx, prim, ib, &min_index, &max_index); + + _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); +} /* This is the main entrypoint into the slimmed-down software tnl * module. In a regular swtnl driver, this can be plugged straight @@ -393,7 +407,7 @@ void _tnl_draw_prims( GLcontext *ctx, */ vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, min_index, max_index, - _tnl_draw_prims ); + _tnl_vbo_draw_prims ); return; } else if (max_index > max) { @@ -411,7 +425,7 @@ void _tnl_draw_prims( GLcontext *ctx, */ vbo_split_prims( ctx, arrays, prim, nr_prims, ib, 0, max_index, - _tnl_draw_prims, + _tnl_vbo_draw_prims, &limits ); } else { diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index 788fe329ed..618b8b3130 100644 --- a/src/mesa/tnl/t_vb_cliptmp.h +++ b/src/mesa/tnl/t_vb_cliptmp.h @@ -127,7 +127,7 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask ) GLuint p; const GLuint v0_orig = v0; - if (mask & 0x3f) { + if (mask & CLIP_FRUSTUM_BITS) { LINE_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 ); LINE_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 ); LINE_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 ); @@ -199,7 +199,24 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask ) ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */ - if (mask & 0x3f) { + if (0) { + /* print pre-clip vertex coords */ + GLuint i, j; + _mesa_printf("pre clip:\n"); + for (i = 0; i < n; i++) { + j = inlist[i]; + _mesa_printf(" %u: %u: %f, %f, %f, %f\n", + i, j, + coord[j][0], coord[j][1], coord[j][2], coord[j][3]); + assert(!IS_INF_OR_NAN(coord[j][0])); + assert(!IS_INF_OR_NAN(coord[j][1])); + assert(!IS_INF_OR_NAN(coord[j][2])); + assert(!IS_INF_OR_NAN(coord[j][3])); + } + } + + + if (mask & CLIP_FRUSTUM_BITS) { POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 ); POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 ); POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 ); @@ -227,6 +244,18 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask ) } } + if (0) { + /* print post-clip vertex coords */ + GLuint i, j; + _mesa_printf("post clip:\n"); + for (i = 0; i < n; i++) { + j = inlist[i]; + _mesa_printf(" %u: %u: %f, %f, %f, %f\n", + i, j, + coord[j][0], coord[j][1], coord[j][2], coord[j][3]); + } + } + tnl->Driver.Render.ClippedPolygon( ctx, inlist, n ); } @@ -250,7 +279,7 @@ TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, ASSIGN_4V(inlist, v3, v0, v1, v2 ); /* pv rotated to slot zero */ - if (mask & 0x3f) { + if (mask & CLIP_FRUSTUM_BITS) { POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 ); POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 ); POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 ); diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 1795f62c32..dc954bcba1 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.6 * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. 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"), @@ -46,6 +47,16 @@ #include "tnl/t_pipeline.h" +#ifdef NAN_CHECK +/** Check for NaNs and very large values */ +static INLINE void +check_float(float x) +{ + assert(!IS_INF_OR_NAN(x)); + assert(1.0e-15 <= x && x <= 1.0e15); +} +#endif + /*! * Private storage for the vertex program pipeline stage. @@ -207,7 +218,7 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine) { /* Input registers get initialized from the current vertex attribs */ MEMCPY(machine->VertAttribs, ctx->Current.Attrib, - MAX_VERTEX_PROGRAM_ATTRIBS * 4 * sizeof(GLfloat)); + MAX_VERTEX_GENERIC_ATTRIBS * 4 * sizeof(GLfloat)); if (ctx->VertexProgram._Current->IsNVProgram) { GLuint i; @@ -351,6 +362,12 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) const GLuint size = VB->AttribPtr[attr]->size; const GLuint stride = VB->AttribPtr[attr]->stride; const GLfloat *data = (GLfloat *) (ptr + stride * i); +#ifdef NAN_CHECK + check_float(data[0]); + check_float(data[1]); + check_float(data[2]); + check_float(data[3]); +#endif COPY_CLEAN_4V(machine.VertAttribs[attr], size, data); } } @@ -361,8 +378,17 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) /* copy the output registers into the VB->attribs arrays */ for (j = 0; j < numOutputs; j++) { const GLuint attr = outputs[j]; +#ifdef NAN_CHECK + check_float(machine.Outputs[attr][0]); + check_float(machine.Outputs[attr][1]); + check_float(machine.Outputs[attr][2]); + check_float(machine.Outputs[attr][3]); +#endif COPY_4V(store->results[attr].data[i], machine.Outputs[attr]); } +#ifdef NAN_CHECK + ASSERT(machine.Outputs[0][3] != 0.0F); +#endif #if 0 printf("HPOS: %f %f %f %f\n", machine.Outputs[0][0], diff --git a/src/mesa/tnl/t_vb_rendertmp.h b/src/mesa/tnl/t_vb_rendertmp.h index 2b5f4e93b2..75f6f55bdc 100644 --- a/src/mesa/tnl/t_vb_rendertmp.h +++ b/src/mesa/tnl/t_vb_rendertmp.h @@ -82,7 +82,10 @@ static void TAG(render_lines)( GLcontext *ctx, INIT(GL_LINES); for (j=start+1; j<count; j+=2 ) { RESET_STIPPLE; - RENDER_LINE( ELT(j-1), ELT(j) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_LINE( ELT(j-1), ELT(j) ); + else + RENDER_LINE( ELT(j), ELT(j-1) ); } POSTFIX; } @@ -103,9 +106,12 @@ static void TAG(render_line_strip)( GLcontext *ctx, RESET_STIPPLE; } - for (j=start+1; j<count; j++ ) - RENDER_LINE( ELT(j-1), ELT(j) ); - + for (j=start+1; j<count; j++ ) { + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_LINE( ELT(j-1), ELT(j) ); + else + RENDER_LINE( ELT(j), ELT(j-1) ); + } POSTFIX; } @@ -125,15 +131,24 @@ static void TAG(render_line_loop)( GLcontext *ctx, if (start+1 < count) { if (TEST_PRIM_BEGIN(flags)) { RESET_STIPPLE; - RENDER_LINE( ELT(start), ELT(start+1) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_LINE( ELT(start), ELT(start+1) ); + else + RENDER_LINE( ELT(start+1), ELT(start) ); } for ( i = start+2 ; i < count ; i++) { - RENDER_LINE( ELT(i-1), ELT(i) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_LINE( ELT(i-1), ELT(i) ); + else + RENDER_LINE( ELT(i), ELT(i-1) ); } if ( TEST_PRIM_END(flags)) { - RENDER_LINE( ELT(count-1), ELT(start) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_LINE( ELT(count-1), ELT(start) ); + else + RENDER_LINE( ELT(start), ELT(count-1) ); } } @@ -156,11 +171,17 @@ static void TAG(render_triangles)( GLcontext *ctx, /* Leave the edgeflags as supplied by the user. */ RESET_STIPPLE; - RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) ); + else + RENDER_TRI( ELT(j-1), ELT(j), ELT(j-2) ); } } else { for (j=start+2; j<count; j+=3) { - RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) ); + else + RENDER_TRI( ELT(j-1), ELT(j), ELT(j-2) ); } } POSTFIX; @@ -180,26 +201,38 @@ static void TAG(render_tri_strip)( GLcontext *ctx, INIT(GL_TRIANGLE_STRIP); if (NEED_EDGEFLAG_SETUP) { for (j=start+2;j<count;j++,parity^=1) { - GLuint ej2 = ELT(j-2+parity); - GLuint ej1 = ELT(j-1-parity); - GLuint ej = ELT(j); - GLboolean ef2 = EDGEFLAG_GET( ej2 ); - GLboolean ef1 = EDGEFLAG_GET( ej1 ); - GLboolean ef = EDGEFLAG_GET( ej ); + GLuint ej2, ej1, ej; + GLboolean ef2, ef1, ef; + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) { + ej2 = ELT(j-2+parity); + ej1 = ELT(j-1-parity); + ej = ELT(j); + } + else { + ej2 = ELT(j-1+parity); + ej1 = ELT(j-parity); + ej = ELT(j-2); + } + ef2 = EDGEFLAG_GET( ej2 ); + ef1 = EDGEFLAG_GET( ej1 ); + ef = EDGEFLAG_GET( ej ); if (TEST_PRIM_BEGIN(flags)) { RESET_STIPPLE; } EDGEFLAG_SET( ej2, GL_TRUE ); EDGEFLAG_SET( ej1, GL_TRUE ); EDGEFLAG_SET( ej, GL_TRUE ); - RENDER_TRI( ej2, ej1, ej ); + RENDER_TRI( ej2, ej1, ej ); EDGEFLAG_SET( ej2, ef2 ); EDGEFLAG_SET( ej1, ef1 ); EDGEFLAG_SET( ej, ef ); } } else { for (j=start+2; j<count ; j++, parity^=1) { - RENDER_TRI( ELT(j-2+parity), ELT(j-1-parity), ELT(j) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_TRI( ELT(j-2+parity), ELT(j-1-parity), ELT(j) ); + else + RENDER_TRI( ELT(j-1+parity), ELT(j-parity), ELT(j-2) ); } } POSTFIX; @@ -232,14 +265,20 @@ static void TAG(render_tri_fan)( GLcontext *ctx, EDGEFLAG_SET( ejs, GL_TRUE ); EDGEFLAG_SET( ej1, GL_TRUE ); EDGEFLAG_SET( ej, GL_TRUE ); - RENDER_TRI( ejs, ej1, ej); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_TRI( ejs, ej1, ej); + else + RENDER_TRI( ej, ejs, ej1); EDGEFLAG_SET( ejs, efs ); EDGEFLAG_SET( ej1, ef1 ); EDGEFLAG_SET( ej, ef ); } } else { for (j=start+2;j<count;j++) { - RENDER_TRI( ELT(start), ELT(j-1), ELT(j) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) + RENDER_TRI( ELT(start), ELT(j-1), ELT(j) ); + else + RENDER_TRI( ELT(j), ELT(start), ELT(j-1) ); } } @@ -331,11 +370,19 @@ static void TAG(render_quads)( GLcontext *ctx, /* Use user-specified edgeflags for quads. */ RESET_STIPPLE; - RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT || + !ctx->Const.QuadsFollowProvokingVertexConvention) + RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) ); + else + RENDER_QUAD( ELT(j-2), ELT(j-1), ELT(j), ELT(j-3) ); } } else { for (j=start+3; j<count; j+=4) { - RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT || + !ctx->Const.QuadsFollowProvokingVertexConvention) + RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) ); + else + RENDER_QUAD( ELT(j-2), ELT(j-1), ELT(j), ELT(j-3) ); } } POSTFIX; @@ -367,7 +414,11 @@ static void TAG(render_quad_strip)( GLcontext *ctx, EDGEFLAG_SET( ELT(j-2), GL_TRUE ); EDGEFLAG_SET( ELT(j-1), GL_TRUE ); EDGEFLAG_SET( ELT(j), GL_TRUE ); - RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT || + !ctx->Const.QuadsFollowProvokingVertexConvention) + RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) ); + else + RENDER_QUAD( ELT(j-2), ELT(j), ELT(j-1), ELT(j-3) ); EDGEFLAG_SET( ELT(j-3), ef3 ); EDGEFLAG_SET( ELT(j-2), ef2 ); EDGEFLAG_SET( ELT(j-1), ef1 ); @@ -375,7 +426,11 @@ static void TAG(render_quad_strip)( GLcontext *ctx, } } else { for (j=start+3;j<count;j+=2) { - RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) ); + if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT || + !ctx->Const.QuadsFollowProvokingVertexConvention) + RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) ); + else + RENDER_QUAD( ELT(j-2), ELT(j), ELT(j-1), ELT(j-3) ); } } POSTFIX; diff --git a/src/mesa/tnl/tnl.h b/src/mesa/tnl/tnl.h index 4d628aa9a6..9c66d3b019 100644 --- a/src/mesa/tnl/tnl.h +++ b/src/mesa/tnl/tnl.h @@ -81,6 +81,16 @@ _tnl_draw_prims( GLcontext *ctx, GLuint min_index, GLuint max_index); +void +_tnl_vbo_draw_prims( GLcontext *ctx, + const struct gl_client_array *arrays[], + const struct _mesa_prim *prim, + GLuint nr_prims, + const struct _mesa_index_buffer *ib, + GLboolean index_bounds_valid, + GLuint min_index, + GLuint max_index); + extern void _mesa_load_tracked_matrices(GLcontext *ctx); |