From 571a1ac6eead573777b990b31fce16987d894adb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 6 Jan 2002 20:39:03 +0000 Subject: [PATCH] implemented vertex program point size control --- src/mesa/main/enable.c | 8 ++++---- src/mesa/main/mtypes.h | 5 ++++- src/mesa/swrast/s_points.c | 6 +++--- src/mesa/swrast_setup/ss_vb.c | 5 +++-- src/mesa/tnl/t_vb_points.c | 4 ++-- src/mesa/tnl/t_vb_program.c | 15 ++++++++++++--- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index f82897fa463..b3c804d3fc0 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1,4 +1,4 @@ -/* $Id: enable.c,v 1.53 2002/01/05 21:53:20 brianp Exp $ */ +/* $Id: enable.c,v 1.54 2002/01/06 20:39:19 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -802,21 +802,21 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) CHECK_EXTENSION(NV_vertex_program); if (ctx->VertexProgram.Enabled == state) return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); /* XXX OK? */ + FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_PROGRAM); /* XXX OK? */ ctx->VertexProgram.Enabled = state; break; case GL_VERTEX_PROGRAM_POINT_SIZE_NV: CHECK_EXTENSION(NV_vertex_program); if (ctx->VertexProgram.PointSizeEnabled == state) return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); /* XXX OK? */ + FLUSH_VERTICES(ctx, _NEW_POINT | _NEW_PROGRAM); ctx->VertexProgram.PointSizeEnabled = state; break; case GL_VERTEX_PROGRAM_TWO_SIDE_NV: CHECK_EXTENSION(NV_vertex_program); if (ctx->VertexProgram.TwoSideEnabled == state) return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); /* XXX OK? */ + FLUSH_VERTICES(ctx, _NEW_PROGRAM); /* XXX OK? */ ctx->VertexProgram.TwoSideEnabled = state; break; case GL_MAP1_VERTEX_ATTRIB0_4_NV: diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 6c9684ebeba..dcf9d4bcf2c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.59 2002/01/06 03:54:12 brianp Exp $ */ +/* $Id: mtypes.h,v 1.60 2002/01/06 20:39:19 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1225,6 +1225,8 @@ struct vp_program GLint ErrorPos; /* Position in string where error was detected */ GLint RefCount; /* Since programs can be shared among contexts */ GLboolean Resident; + GLbitfield InputsRead; /* Bitmask of which input regs are read */ + GLbitfield OutputsWritten; /* Bitmask of which output regs are written to */ }; @@ -1478,6 +1480,7 @@ struct matrix_stack #define _NEW_BUFFERS 0x1000000 /* ctx->Visual, ctx->DrawBuffer, */ #define _NEW_MULTISAMPLE 0x2000000 /* ctx->Multisample */ #define _NEW_TRACK_MATRIX 0x4000000 /* ctx->VertexProgram */ +#define _NEW_PROGRAM 0x8000000 /* ctx->VertexProgram */ #define _NEW_ALL ~0 diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 0c3b4d0f084..d2b9a24c4f8 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -1,4 +1,4 @@ -/* $Id: s_points.c,v 1.15 2001/03/12 00:48:42 gareth Exp $ */ +/* $Id: s_points.c,v 1.16 2002/01/06 20:39:19 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -212,7 +212,7 @@ _swrast_choose_point( GLcontext *ctx ) else if (ctx->Point.SmoothFlag) { /* Smooth points */ if (rgbMode) { - if (ctx->Point._Attenuated) { + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { USE(atten_antialiased_rgba_point); } else if (ctx->Texture._ReallyEnabled) { @@ -226,7 +226,7 @@ _swrast_choose_point( GLcontext *ctx ) USE(antialiased_ci_point); } } - else if (ctx->Point._Attenuated) { + else if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { if (rgbMode) { if (ctx->Texture._ReallyEnabled) { if (ctx->Point.SmoothFlag) { diff --git a/src/mesa/swrast_setup/ss_vb.c b/src/mesa/swrast_setup/ss_vb.c index d77f5f1e198..f071216801e 100644 --- a/src/mesa/swrast_setup/ss_vb.c +++ b/src/mesa/swrast_setup/ss_vb.c @@ -1,4 +1,4 @@ -/* $Id: ss_vb.c,v 1.14 2001/07/17 19:39:32 keithw Exp $ */ +/* $Id: ss_vb.c,v 1.15 2002/01/06 20:39:03 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -398,7 +398,8 @@ _swsetup_choose_rastersetup_func(GLcontext *ctx) funcindex = INDEX; } - if (ctx->Point._Attenuated) + if (ctx->Point._Attenuated || + (ctx->VertexProgram.Enabled && ctx->VertexProgram.PointSizeEnabled)) funcindex |= POINT; if (ctx->Fog.Enabled) diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c index 429a0ab7cb4..a6757a8bf0b 100644 --- a/src/mesa/tnl/t_vb_points.c +++ b/src/mesa/tnl/t_vb_points.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_points.c,v 1.6 2002/01/06 03:54:12 brianp Exp $ */ +/* $Id: t_vb_points.c,v 1.7 2002/01/06 20:39:19 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -76,7 +76,7 @@ static GLboolean run_point_stage( GLcontext *ctx, */ static void check_point_size( GLcontext *ctx, struct gl_pipeline_stage *d ) { - d->active = ctx->Point._Attenuated; + d->active = ctx->Point._Attenuated && !ctx->VertexProgram.Enabled; } static GLboolean alloc_point_data( GLcontext *ctx, diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index cfa1397d70e..4dc5becb28f 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_program.c,v 1.7 2002/01/06 03:54:12 brianp Exp $ */ +/* $Id: t_vb_program.c,v 1.8 2002/01/06 20:39:20 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -141,10 +141,17 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) struct vp_stage_data *store = VP_STAGE_DATA(stage); struct vertex_buffer *VB = &tnl->vb; struct vp_machine *machine = &(ctx->VertexProgram.Machine); + struct vp_program *program = ctx->VertexProgram.Current; GLint i; _mesa_init_tracked_matrices(ctx); _mesa_init_vp_registers(ctx); /* init temp and result regs */ + /* XXX if GL_FOG is enabled but the program doesn't write to the + * o[FOGC] register, set the fog result to 1.0 + */ + /* XXX if GL_VERTEX_PROGRAM_POINT_SIZE_NV is enabled but the program + * doesn't write the PSIZ variable then use ctx->Point.Size + */ for (i = 0; i < VB->Count; i++) { GLuint attr; @@ -176,8 +183,8 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) } /* execute the program */ - ASSERT(ctx->VertexProgram.Current); - _mesa_exec_program(ctx, ctx->VertexProgram.Current); + ASSERT(program); + _mesa_exec_program(ctx, program); #if 0 printf("Output %d: %f, %f, %f, %f\n", i, @@ -190,6 +197,8 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) machine->Registers[VP_OUT_COL0][1], machine->Registers[VP_OUT_COL0][2], machine->Registers[VP_OUT_COL0][3]); + printf("PointSize[%d]: %g\n", i, + machine->Registers[VP_OUTPUT_REG_START + VERT_RESULT_PSIZ][0]); #endif /* copy the output registers into the VB->attribs arrays */ -- 2.30.2