[Mesa-dev] [PATCH] Remove gallium draw_arrays() and draw_arrays_instanced() functions

Brian Paul brianp at vmware.com
Wed Jun 5 18:21:48 PDT 2013


On 06/05/2013 01:57 PM, Arnas Milasevicius wrote:
>
> Because these 2 functions are only used in state_tracker's st_draw_feedback.c file, I moved them there from draw_pt.c and made them static.
> ---
>   src/gallium/auxiliary/draw/draw_context.h | 10 --------
>   src/gallium/auxiliary/draw/draw_pt.c      | 40 ------------------------------
>   src/mesa/state_tracker/st_draw_feedback.c | 41 +++++++++++++++++++++++++++++++
>   3 files changed, 41 insertions(+), 50 deletions(-)
>
> diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
> index 2d843b7..6d39da9 100644
> --- a/src/gallium/auxiliary/draw/draw_context.h
> +++ b/src/gallium/auxiliary/draw/draw_context.h
> @@ -241,16 +241,6 @@ draw_set_mapped_so_targets(struct draw_context *draw,
>   void draw_vbo(struct draw_context *draw,
>                 const struct pipe_draw_info *info);
>
> -void draw_arrays(struct draw_context *draw, unsigned prim,
> -		 unsigned start, unsigned count);
> -
> -void
> -draw_arrays_instanced(struct draw_context *draw,
> -                      unsigned mode,
> -                      unsigned start,
> -                      unsigned count,
> -                      unsigned startInstance,
> -                      unsigned instanceCount);
>
>
>   /*******************************************************************************
> diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
> index ce36ed0..131bd13 100644
> --- a/src/gallium/auxiliary/draw/draw_pt.c
> +++ b/src/gallium/auxiliary/draw/draw_pt.c
> @@ -413,46 +413,6 @@ draw_pt_arrays_restart(struct draw_context *draw,
>   }
>
>
> -
> -/**
> - * Non-instanced drawing.
> - * \sa draw_arrays_instanced
> - */
> -void
> -draw_arrays(struct draw_context *draw, unsigned prim,
> -            unsigned start, unsigned count)
> -{
> -   draw_arrays_instanced(draw, prim, start, count, 0, 1);
> -}
> -
> -
> -/**
> - * Instanced drawing.
> - * \sa draw_vbo
> - */
> -void
> -draw_arrays_instanced(struct draw_context *draw,
> -                      unsigned mode,
> -                      unsigned start,
> -                      unsigned count,
> -                      unsigned startInstance,
> -                      unsigned instanceCount)
> -{
> -   struct pipe_draw_info info;
> -
> -   util_draw_init_info(&info);
> -
> -   info.mode = mode;
> -   info.start = start;
> -   info.count = count;
> -   info.start_instance = startInstance;
> -   info.instance_count = instanceCount;
> -   info.min_index = start;
> -   info.max_index = start + count - 1;
> -
> -   draw_vbo(draw, &info);
> -}
> -
>   /**
>    * Resolve true values within pipe_draw_info.
>    * If we're rendering from transform feedback/stream output
> diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
> index b19d913..56e3018 100644
> --- a/src/mesa/state_tracker/st_draw_feedback.c
> +++ b/src/mesa/state_tracker/st_draw_feedback.c
> @@ -40,6 +40,7 @@
>   #include "pipe/p_context.h"
>   #include "pipe/p_defines.h"
>   #include "util/u_inlines.h"
> +#include "util/u_draw.h"
>
>   #include "draw/draw_private.h"
>   #include "draw/draw_context.h"
> @@ -81,6 +82,46 @@ set_feedback_vertex_format(struct gl_context *ctx)
>
>
>   /**
> + * Instanced drawing.
> + * \sa draw_vbo
> + */
> +static void
> +draw_arrays_instanced(struct draw_context *draw,
> +                      unsigned mode,
> +                      unsigned start,
> +                      unsigned count,
> +                      unsigned startInstance,
> +                      unsigned instanceCount)
> +{
> +   struct pipe_draw_info info;
> +
> +   util_draw_init_info(&info);
> +
> +   info.mode = mode;
> +   info.start = start;
> +   info.count = count;
> +   info.start_instance = startInstance;
> +   info.instance_count = instanceCount;
> +   info.min_index = start;
> +   info.max_index = start + count - 1;
> +
> +   draw_vbo(draw, &info);
> +}
> +
> +
> +/**
> + * Non-instanced drawing.
> + * \sa draw_arrays_instanced
> + */
> +static void
> +draw_arrays(struct draw_context *draw, unsigned prim,
> +            unsigned start, unsigned count)
> +{
> +   draw_arrays_instanced(draw, prim, start, count, 0, 1);
> +}

It's kind of silly to keep the draw_arrays_instanced() function if it's 
only called by draw_arrays() like this.  See my suggested solution in 
the bug report.

-Brian



More information about the mesa-dev mailing list