[Mesa-dev] [PATCH] draw: make sure that the stages setup outputs

Roland Scheidegger sroland at vmware.com
Tue Aug 13 05:04:21 PDT 2013


Am 09.08.2013 16:13, schrieb Zack Rusin:
> 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 at vmware.com>
> ---
>  src/gallium/auxiliary/draw/draw_context.c       |    2 +
>  src/gallium/auxiliary/draw/draw_pipe.h          |    5 +-
>  src/gallium/auxiliary/draw/draw_pipe_aaline.c   |   27 ++++++++---
>  src/gallium/auxiliary/draw/draw_pipe_aapoint.c  |   56 ++++++++++++++---------
>  src/gallium/auxiliary/draw/draw_pipe_unfilled.c |    2 +
>  5 files changed, 62 insertions(+), 30 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
> index 2d4843e..d1fac0c 100644
> --- a/src/gallium/auxiliary/draw/draw_context.c
> +++ b/src/gallium/auxiliary/draw/draw_context.c
> @@ -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);
>  }
>  
>  /**
> diff --git a/src/gallium/auxiliary/draw/draw_pipe.h b/src/gallium/auxiliary/draw/draw_pipe.h
> index 7c9ed6c..ad3165f 100644
> --- a/src/gallium/auxiliary/draw/draw_pipe.h
> +++ b/src/gallium/auxiliary/draw/draw_pipe.h
> @@ -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);
>  
> diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
> index aa88459..c44c236 100644
> --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
> +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
> @@ -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
> diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
> index 0d7b88e..7ae1ddd 100644
> --- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
> +++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
> @@ -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)
> diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
> index 68bab72..7a88ce0 100644
> --- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
> +++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
> @@ -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;
>  
> 

Reviewed-by: Roland Scheidegger <sroland at vmware.com>


More information about the mesa-dev mailing list