OSDN Git Service

implemented vertex program point size control
authorBrian Paul <brian.paul@tungstengraphics.com>
Sun, 6 Jan 2002 20:39:03 +0000 (20:39 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Sun, 6 Jan 2002 20:39:03 +0000 (20:39 +0000)
src/mesa/main/enable.c
src/mesa/main/mtypes.h
src/mesa/swrast/s_points.c
src/mesa/swrast_setup/ss_vb.c
src/mesa/tnl/t_vb_points.c
src/mesa/tnl/t_vb_program.c

index f82897f..b3c804d 100644 (file)
@@ -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:
index 6c9684e..dcf9d4b 100644 (file)
@@ -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
 
 
index 0c3b4d0..d2b9a24 100644 (file)
@@ -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) {
index d77f5f1..f071216 100644 (file)
@@ -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)
index 429a0ab..a6757a8 100644 (file)
@@ -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,
index cfa1397..4dc5bec 100644 (file)
@@ -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 */