[Mesa-dev] [PATCH v2 1/6] vbo: add software primitive restart support

Brian Paul brianp at vmware.com
Mon May 14 06:55:32 PDT 2012


On 05/13/2012 08:00 AM, Jordan Justen wrote:
> vbo_sw_primitive_restart implements primitive restart in software
> by splitting primitive draws apart.
>
> This is based on similar support in mesa/state_tracker/st_draw.c.
>
> Signed-off-by: Jordan Justen<jordan.l.justen at intel.com>
> ---
>   src/mesa/SConscript                  |    1 +
>   src/mesa/sources.mak                 |    1 +
>   src/mesa/vbo/vbo.h                   |    5 +
>   src/mesa/vbo/vbo_primitive_restart.c |  225 ++++++++++++++++++++++++++++++++++
>   4 files changed, 232 insertions(+)
>   create mode 100644 src/mesa/vbo/vbo_primitive_restart.c
>
> diff --git a/src/mesa/SConscript b/src/mesa/SConscript
> index dc37a67..d7932c7 100644
> --- a/src/mesa/SConscript
> +++ b/src/mesa/SConscript
> @@ -215,6 +215,7 @@ vbo_sources = [
>       'vbo/vbo_exec_draw.c',
>       'vbo/vbo_exec_eval.c',
>       'vbo/vbo_noop.c',
> +    'vbo/vbo_primitive_restart.c',
>       'vbo/vbo_rebase.c',
>       'vbo/vbo_split.c',
>       'vbo/vbo_split_copy.c',
> diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
> index c746b8a..19a05ec 100644
> --- a/src/mesa/sources.mak
> +++ b/src/mesa/sources.mak
> @@ -184,6 +184,7 @@ VBO_SOURCES = \
>   	vbo/vbo_exec_draw.c \
>   	vbo/vbo_exec_eval.c \
>   	vbo/vbo_noop.c \
> +	vbo/vbo_primitive_restart.c \
>   	vbo/vbo_rebase.c \
>   	vbo/vbo_split.c \
>   	vbo/vbo_split_copy.c \
> diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
> index 3cff898..9cd38f9 100644
> --- a/src/mesa/vbo/vbo.h
> +++ b/src/mesa/vbo/vbo.h
> @@ -157,6 +157,11 @@ void vbo_bind_arrays(struct gl_context *ctx);
>   size_t
>   count_tessellated_primitives(const struct _mesa_prim *prim);
>
> +void vbo_sw_primitive_restart(struct gl_context *ctx,
> +                              const struct _mesa_prim *prim,
> +                              GLuint nr_prims,
> +                              const struct _mesa_index_buffer *ib);
> +
>   void GLAPIENTRY
>   _es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
>
> diff --git a/src/mesa/vbo/vbo_primitive_restart.c b/src/mesa/vbo/vbo_primitive_restart.c
> new file mode 100644
> index 0000000..55f7063
> --- /dev/null
> +++ b/src/mesa/vbo/vbo_primitive_restart.c
> @@ -0,0 +1,225 @@
> +/*
> + * Copyright © 2012 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + * Authors:
> + *    Jordan Justen<jordan.l.justen at intel.com>
> + *
> + */
> +
> +#include "main/imports.h"
> +#include "main/bufferobj.h"
> +
> +#include "vbo.h"
> +#include "vbo_context.h"
> +
> +#define MIN(a, b) (((a)<  (b)) ? (a) : (b))
> +#define MAX(a, b) (((a)>  (b)) ? (a) : (b))

You could use the MIN2, MAX2 macros from macros.h instead.

-Brian


More information about the mesa-dev mailing list