draw: make sure that the stages setup outputs
authorZack Rusin <zackr@vmware.com>
Fri, 9 Aug 2013 14:11:31 +0000 (10:11 -0400)
committerZack Rusin <zackr@vmware.com>
Wed, 14 Aug 2013 22:23:35 +0000 (18:23 -0400)
Calling the prepare outputs cleans up the slot assignments
for outputs, unfortunately aapoint and aaline didn't have
code to reset their slots after the initial setup, this
was messing up our slot assignments. The unfilled stage
was just missing the initial assignment of the face slot.
This fixes all of the reported piglit failures.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_pipe.h
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_aapoint.c
src/gallium/auxiliary/draw/draw_pipe_unfilled.c

index 2d4843ebe252310ed28dfe6007c0eaf1e4379023..d1fac0c6c1d8d39782eb9eeaf11bcaed1a90e788 100644 (file)
@@ -564,6 +564,8 @@ draw_prepare_shader_outputs(struct draw_context *draw)
    draw_remove_extra_vertex_attribs(draw);
    draw_prim_assembler_prepare_outputs(draw->ia);
    draw_unfilled_prepare_outputs(draw, draw->pipeline.unfilled);
+   draw_aapoint_prepare_outputs(draw, draw->pipeline.aapoint);
+   draw_aaline_prepare_outputs(draw, draw->pipeline.aaline);
 }
 
 /**
index 7c9ed6c31d928b3d3ad1534497ba74cb2dab3720..ad3165fd29bd7de3ab5c7e170f38e8974133cf87 100644 (file)
@@ -101,7 +101,10 @@ void draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *hea
 void draw_pipe_passthrough_line(struct draw_stage *stage, struct prim_header *header);
 void draw_pipe_passthrough_point(struct draw_stage *stage, struct prim_header *header);
 
-
+void draw_aapoint_prepare_outputs(struct draw_context *context,
+                                  struct draw_stage *stage);
+void draw_aaline_prepare_outputs(struct draw_context *context,
+                                 struct draw_stage *stage);
 void draw_unfilled_prepare_outputs(struct draw_context *context,
                                    struct draw_stage *stage);
 
index aa884596b357b6592ff033b76d2eed23309b8af3..c44c236bc58104cbcef9e1d260b8c1fbaa43fe93 100644 (file)
@@ -692,13 +692,7 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
       return;
    }
 
-   /* update vertex attrib info */
-   aaline->pos_slot = draw_current_shader_position_output(draw);;
-
-   /* allocate the extra post-transformed vertex attribute */
-   aaline->tex_slot = draw_alloc_extra_vertex_attrib(draw,
-                                                     TGSI_SEMANTIC_GENERIC,
-                                                     aaline->fs->generic_attrib);
+   draw_aaline_prepare_outputs(draw, draw->pipeline.aaline);
 
    /* how many samplers? */
    /* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
@@ -953,6 +947,25 @@ aaline_set_sampler_views(struct pipe_context *pipe,
 }
 
 
+void
+draw_aaline_prepare_outputs(struct draw_context *draw,
+                            struct draw_stage *stage)
+{
+   struct aaline_stage *aaline = aaline_stage(stage);
+   const struct pipe_rasterizer_state *rast = draw->rasterizer;
+
+   /* update vertex attrib info */
+   aaline->pos_slot = draw_current_shader_position_output(draw);;
+
+   if (!rast->line_smooth)
+      return;
+
+   /* allocate the extra post-transformed vertex attribute */
+   aaline->tex_slot = draw_alloc_extra_vertex_attrib(draw,
+                                                     TGSI_SEMANTIC_GENERIC,
+                                                     aaline->fs->generic_attrib);
+}
+
 /**
  * Called by drivers that want to install this AA line prim stage
  * into the draw module's pipeline.  This will not be used if the
index 0d7b88ee7d12127c5146bdfa961a3320c5bae064..7ae1ddd24cea018bda21e13f4a2317e99173d612 100644 (file)
@@ -696,28 +696,7 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
     */
    bind_aapoint_fragment_shader(aapoint);
 
-   /* update vertex attrib info */
-   aapoint->pos_slot = draw_current_shader_position_output(draw);
-
-   /* allocate the extra post-transformed vertex attribute */
-   aapoint->tex_slot = draw_alloc_extra_vertex_attrib(draw,
-                                                      TGSI_SEMANTIC_GENERIC,
-                                                      aapoint->fs->generic_attrib);
-   assert(aapoint->tex_slot > 0); /* output[0] is vertex pos */
-
-   /* find psize slot in post-transform vertex */
-   aapoint->psize_slot = -1;
-   if (draw->rasterizer->point_size_per_vertex) {
-      const struct tgsi_shader_info *info = draw_get_shader_info(draw);
-      uint i;
-      /* find PSIZ vertex output */
-      for (i = 0; i < info->num_outputs; i++) {
-         if (info->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
-            aapoint->psize_slot = i;
-            break;
-         }
-      }
-   }
+   draw_aapoint_prepare_outputs(draw, draw->pipeline.aapoint);
 
    draw->suspend_flushing = TRUE;
 
@@ -781,6 +760,39 @@ aapoint_destroy(struct draw_stage *stage)
    FREE( stage );
 }
 
+void
+draw_aapoint_prepare_outputs(struct draw_context *draw,
+                             struct draw_stage *stage)
+{
+   struct aapoint_stage *aapoint = aapoint_stage(stage);
+   const struct pipe_rasterizer_state *rast = draw->rasterizer;
+
+   /* update vertex attrib info */
+   aapoint->pos_slot = draw_current_shader_position_output(draw);
+
+   if (!rast->point_smooth)
+      return;
+
+   /* allocate the extra post-transformed vertex attribute */
+   aapoint->tex_slot = draw_alloc_extra_vertex_attrib(draw,
+                                                      TGSI_SEMANTIC_GENERIC,
+                                                      aapoint->fs->generic_attrib);
+   assert(aapoint->tex_slot > 0); /* output[0] is vertex pos */
+
+   /* find psize slot in post-transform vertex */
+   aapoint->psize_slot = -1;
+   if (draw->rasterizer->point_size_per_vertex) {
+      const struct tgsi_shader_info *info = draw_get_shader_info(draw);
+      uint i;
+      /* find PSIZ vertex output */
+      for (i = 0; i < info->num_outputs; i++) {
+         if (info->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
+            aapoint->psize_slot = i;
+            break;
+         }
+      }
+   }
+}
 
 static struct aapoint_stage *
 draw_aapoint_stage(struct draw_context *draw)
index 68bab72265e2734b04b08bf9d754b16acb7353ce..7a88ce0f6d70f0b4a71120f26cd2248f663601e1 100644 (file)
@@ -268,6 +268,8 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
    unfilled->stage.reset_stipple_counter = unfilled_reset_stipple_counter;
    unfilled->stage.destroy = unfilled_destroy;
 
+   unfilled->face_slot = -1;
+
    if (!draw_alloc_temp_verts( &unfilled->stage, 0 ))
       goto fail;