Fix up some point size breakage. Start on fogcoord too.
authorBrian <brian.paul@tungstengraphics.com>
Fri, 21 Sep 2007 18:06:08 +0000 (12:06 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Fri, 21 Sep 2007 18:06:08 +0000 (12:06 -0600)
src/mesa/pipe/softpipe/sp_prim_setup.c
src/mesa/pipe/softpipe/sp_state_derived.c
src/mesa/pipe/tgsi/exec/tgsi_token.h
src/mesa/state_tracker/st_atom_fs.c
src/mesa/state_tracker/st_atom_vs.c
src/mesa/state_tracker/st_cb_rasterpos.c

index f0f9cf5..6d63cc9 100644 (file)
@@ -907,15 +907,13 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
    const struct vertex_header *v0 = prim->v[0];
    const int sizeAttr = setup->softpipe->psize_slot;
    const float halfSize
-      = sizeAttr ? (0.5f * v0->data[sizeAttr][0])
+      = sizeAttr > 0 ? (0.5f * v0->data[sizeAttr][0])
         : (0.5f * setup->softpipe->rasterizer->point_size);
    const boolean round = setup->softpipe->rasterizer->point_smooth;
    const float x = v0->data[0][0];  /* Note: data[0] is always position */
    const float y = v0->data[0][1];
    unsigned slot, j;
 
-   assert(sizeAttr >= 0);
-
    /* For points, all interpolants are constant-valued.
     * However, for point sprites, we'll need to setup texcoords appropriately.
     * XXX: which coefficients are the texcoords???
index 0e78209..35ba32c 100644 (file)
@@ -43,6 +43,7 @@
  */
 static void calculate_vertex_layout( struct softpipe_context *softpipe )
 {
+   const struct pipe_shader_state *vs = softpipe->vs;
    const struct pipe_shader_state *fs = softpipe->fs;
    const interp_mode colorInterp
       = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
@@ -58,47 +59,68 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
       softpipe->need_z = FALSE;
    softpipe->need_w = FALSE;
 
+   if (fs->input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
+      /* Need Z if depth test is enabled or the fragment program uses the
+       * fragment position (XYZW).
+       */
+      softpipe->need_z = TRUE;
+      softpipe->need_w = TRUE;
+   }
+
    softpipe->psize_slot = -1;
 
    /* always emit vertex pos */
-   /* TODO - Figure out if we need to do perspective divide, etc. */
    draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR);
 
-   for (i = 0; i < fs->num_inputs; i++) {
-      switch (fs->input_semantic_name[i]) {
+   /*
+    * XXX I think we need to reconcile the vertex shader outputs with
+    * the fragment shader inputs here to make sure the slots line up.
+    * Might just be getting lucky so far.
+    * Or maybe do that in the state tracker?
+    */
+
+   for (i = 0; i < vs->num_outputs; i++) {
+      switch (vs->output_semantic_name[i]) {
+
       case TGSI_SEMANTIC_POSITION:
-         /* Need Z if depth test is enabled or the fragment program uses the
-          * fragment position (XYZW).
+         /* vertex programs always emit position, but might not be
+          * needed for fragment progs.
           */
-         softpipe->need_z = TRUE;
-         softpipe->need_w = TRUE;
+         /* no-op */
          break;
+
       case TGSI_SEMANTIC_COLOR:
          if (fs->input_semantic_index[i] == 0) {
-            front0 = draw_emit_vertex_attr(vinfo,
-                                           FORMAT_4F, colorInterp);
+            front0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
+         }
+         else {
+            assert(fs->input_semantic_index[i] == 1);
+            front1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
+         }
+         break;
+
+      case TGSI_SEMANTIC_BCOLOR:
+         if (fs->input_semantic_index[i] == 0) {
+            back0 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
          }
          else {
             assert(fs->input_semantic_index[i] == 1);
-            front1 = draw_emit_vertex_attr(vinfo,
-                                           FORMAT_4F, colorInterp);
+            back1 = draw_emit_vertex_attr(vinfo, FORMAT_4F, colorInterp);
          }
          break;
+
       case TGSI_SEMANTIC_FOG:
-         draw_emit_vertex_attr(vinfo,
-                               FORMAT_1F, INTERP_PERSPECTIVE);
+         draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_PERSPECTIVE);
          break;
-#if 0
+
       case TGSI_SEMANTIC_PSIZE:
          /* XXX only emit if drawing points or front/back polygon mode
           * is point mode
           */
-         draw_emit_vertex_attr(vinfo,
-                               FORMAT_4F, INTERP_CONSTANT);
-         break;
-#endif
+         draw_emit_vertex_attr(vinfo, FORMAT_1F, INTERP_CONSTANT);
          softpipe->psize_slot = i;
-         /*case TGSI_SEMANTIC_TEXCOORD:*/
+         break;
+
       case TGSI_SEMANTIC_GENERIC:
          /* this includes texcoords and varying vars */
          draw_emit_vertex_attr(vinfo, FORMAT_4F, INTERP_PERSPECTIVE);
@@ -112,6 +134,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
 
    softpipe->nr_frag_attrs = vinfo->num_attribs;
 
+#if 0
    /* Additional attributes required for setup: Just twosided
     * lighting.  Edgeflag is dealt with specially by setting bits in
     * the vertex header.
@@ -124,6 +147,7 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
          back1 = draw_emit_vertex_attr(vinfo, FORMAT_OMIT, colorInterp);
       }
    }
+#endif
 
    /* If the attributes have changed, tell the draw module about
     * the new vertex layout.
index e6f884c..1d99a50 100644 (file)
@@ -107,8 +107,9 @@ struct tgsi_declaration_interpolation
 #define TGSI_SEMANTIC_COLOR    1
 #define TGSI_SEMANTIC_BCOLOR   2 /**< back-face color */
 #define TGSI_SEMANTIC_FOG      3
-#define TGSI_SEMANTIC_GENERIC  4
-#define TGSI_SEMANTIC_COUNT    5 /**< number of semantic values */
+#define TGSI_SEMANTIC_PSIZE    4
+#define TGSI_SEMANTIC_GENERIC  5
+#define TGSI_SEMANTIC_COUNT    6 /**< number of semantic values */
 
 struct tgsi_declaration_semantic
 {
index 1e7886a..f8a1dc8 100644 (file)
@@ -95,7 +95,9 @@ st_translate_fragment_shader(struct st_context *st,
             interpMode[fs.num_inputs] = TGSI_INTERPOLATE_LINEAR;
             break;
          case FRAG_ATTRIB_FOGC:
-            assert(0);
+            fs.input_semantic_name[fs.num_inputs] = TGSI_SEMANTIC_FOG;
+            fs.input_semantic_index[fs.num_inputs] = 0;
+            interpMode[fs.num_inputs] = TGSI_INTERPOLATE_PERSPECTIVE;
             break;
          case FRAG_ATTRIB_TEX0:
          case FRAG_ATTRIB_TEX1:
index e4e9902..ae51e97 100644 (file)
@@ -91,6 +91,10 @@ st_translate_vertex_shader(struct st_context *st,
             vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_COLOR;
             vs.input_semantic_index[vs.num_inputs] = 1;
             break;
+         case VERT_ATTRIB_FOG:
+            vs.input_semantic_name[vs.num_inputs] = TGSI_SEMANTIC_FOG;
+            vs.input_semantic_index[vs.num_inputs] = 0;
+            break;
          case VERT_ATTRIB_TEX0:
          case VERT_ATTRIB_TEX1:
          case VERT_ATTRIB_TEX2:
@@ -152,7 +156,13 @@ st_translate_vertex_shader(struct st_context *st,
             vs.output_semantic_index[vs.num_outputs] = 1;
             break;
          case VERT_RESULT_FOGC:
+            vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_FOG;
+            vs.output_semantic_index[vs.num_outputs] = 0;
+            break;
          case VERT_RESULT_PSIZ:
+            vs.output_semantic_name[vs.num_outputs] = TGSI_SEMANTIC_PSIZE;
+            vs.output_semantic_index[vs.num_outputs] = 0;
+            break;
          case VERT_RESULT_EDGE:
             assert(0);
             break;
index 56c9891..2311bdd 100644 (file)
@@ -265,6 +265,9 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4])
    float *buf_map;
    struct pipe_feedback_buffer fb_buf;
 
+   /** XXX TEMPORARILY DISABLE */
+   return;
+
    st_validate_state(ctx->st);
 
    /* setup vertex buffers */