[Mesa-dev] [PATCH] llvmpipe: add NV_conditional_render support.

Jose Fonseca jfonseca at vmware.com
Mon Nov 7 14:55:29 PST 2011


I'm not very familar with conditional rendering, but I don't see anything wrong FWIW.

Jose

----- Original Message -----
> From: Dave Airlie <airlied at redhat.com>
> 
> This ports the softpipe NV_conditional_render support to llvmpipe.
> 
> This passes the nv_conditional_render-* piglit tests.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/gallium/drivers/llvmpipe/lp_clear.c       |    3 +++
>  src/gallium/drivers/llvmpipe/lp_context.c     |   13 +++++++++++++
>  src/gallium/drivers/llvmpipe/lp_context.h     |    4 ++++
>  src/gallium/drivers/llvmpipe/lp_draw_arrays.c |    3 +++
>  src/gallium/drivers/llvmpipe/lp_query.c       |   18
>  ++++++++++++++++++
>  src/gallium/drivers/llvmpipe/lp_query.h       |    1 +
>  src/gallium/drivers/llvmpipe/lp_screen.c      |    1 +
>  7 files changed, 43 insertions(+), 0 deletions(-)
> 
> diff --git a/src/gallium/drivers/llvmpipe/lp_clear.c
> b/src/gallium/drivers/llvmpipe/lp_clear.c
> index be2fce1..dbcfd9c 100644
> --- a/src/gallium/drivers/llvmpipe/lp_clear.c
> +++ b/src/gallium/drivers/llvmpipe/lp_clear.c
> @@ -55,6 +55,9 @@ llvmpipe_clear(struct pipe_context *pipe,
>     if (llvmpipe->no_rast)
>        return;
>  
> +   if (!llvmpipe_check_render_cond(llvmpipe))
> +      return;
> +
>     if (LP_PERF & PERF_NO_DEPTH)
>        buffers &= ~PIPE_CLEAR_DEPTHSTENCIL;
>  
> diff --git a/src/gallium/drivers/llvmpipe/lp_context.c
> b/src/gallium/drivers/llvmpipe/lp_context.c
> index 8a5655d..b6ac068 100644
> --- a/src/gallium/drivers/llvmpipe/lp_context.c
> +++ b/src/gallium/drivers/llvmpipe/lp_context.c
> @@ -142,6 +142,17 @@ do_flush( struct pipe_context *pipe,
>  }
>  
>  
> +static void
> +llvmpipe_render_condition ( struct pipe_context *pipe,
> +                            struct pipe_query *query,
> +                            uint mode )
> +{
> +   struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe );
> +
> +   llvmpipe->render_cond_query = query;
> +   llvmpipe->render_cond_mode = mode;
> +}
> +
>  struct pipe_context *
>  llvmpipe_create_context( struct pipe_screen *screen, void *priv )
>  {
> @@ -170,6 +181,8 @@ llvmpipe_create_context( struct pipe_screen
> *screen, void *priv )
>     llvmpipe->pipe.clear = llvmpipe_clear;
>     llvmpipe->pipe.flush = do_flush;
>  
> +   llvmpipe->pipe.render_condition = llvmpipe_render_condition;
> +
>     llvmpipe_init_blend_funcs(llvmpipe);
>     llvmpipe_init_clip_funcs(llvmpipe);
>     llvmpipe_init_draw_funcs(llvmpipe);
> diff --git a/src/gallium/drivers/llvmpipe/lp_context.h
> b/src/gallium/drivers/llvmpipe/lp_context.h
> index 503f09d..70fba21 100644
> --- a/src/gallium/drivers/llvmpipe/lp_context.h
> +++ b/src/gallium/drivers/llvmpipe/lp_context.h
> @@ -136,6 +136,10 @@ struct llvmpipe_context {
>  
>     struct lp_setup_variant_list_item setup_variants_list;
>     unsigned nr_setup_variants;
> +
> +   /** Conditional query object and mode */
> +   struct pipe_query *render_cond_query;
> +   uint render_cond_mode;
>  };
>  
>  
> diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
> b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
> index 3af5c8d..83045d2 100644
> --- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
> +++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
> @@ -56,6 +56,9 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const
> struct pipe_draw_info *info)
>     void *mapped_indices = NULL;
>     unsigned i;
>  
> +   if (!llvmpipe_check_render_cond(lp))
> +      return;
> +
>     if (lp->dirty)
>        llvmpipe_update_derived( lp );
>  
> diff --git a/src/gallium/drivers/llvmpipe/lp_query.c
> b/src/gallium/drivers/llvmpipe/lp_query.c
> index 1e2401f..42eb856 100644
> --- a/src/gallium/drivers/llvmpipe/lp_query.c
> +++ b/src/gallium/drivers/llvmpipe/lp_query.c
> @@ -154,6 +154,24 @@ llvmpipe_end_query(struct pipe_context *pipe,
> struct pipe_query *q)
>     llvmpipe->dirty |= LP_NEW_QUERY;
>  }
>  
> +boolean
> +llvmpipe_check_render_cond(struct llvmpipe_context *lp)
> +{
> +   struct pipe_context *pipe = &lp->pipe;
> +   boolean b, wait;
> +   uint64_t result;
> +
> +   if (!lp->render_cond_query)
> +      return TRUE; /* no query predicate, draw normally */
> +   wait = (lp->render_cond_mode == PIPE_RENDER_COND_WAIT ||
> +           lp->render_cond_mode == PIPE_RENDER_COND_BY_REGION_WAIT);
> +
> +   b = pipe->get_query_result(pipe, lp->render_cond_query, wait,
> &result);
> +   if (b)
> +      return result > 0;
> +   else
> +      return TRUE;
> +}
>  
>  void llvmpipe_init_query_funcs(struct llvmpipe_context *llvmpipe )
>  {
> diff --git a/src/gallium/drivers/llvmpipe/lp_query.h
> b/src/gallium/drivers/llvmpipe/lp_query.h
> index e93842a..ef1bc30 100644
> --- a/src/gallium/drivers/llvmpipe/lp_query.h
> +++ b/src/gallium/drivers/llvmpipe/lp_query.h
> @@ -49,5 +49,6 @@ struct llvmpipe_query {
>  
>  extern void llvmpipe_init_query_funcs(struct llvmpipe_context * );
>  
> +extern boolean llvmpipe_check_render_cond(struct llvmpipe_context
> *);
>  
>  #endif /* LP_QUERY_H */
> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c
> b/src/gallium/drivers/llvmpipe/lp_screen.c
> index db3fbb9..0bf0a02 100644
> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
> @@ -157,6 +157,7 @@ llvmpipe_get_param(struct pipe_screen *screen,
> enum pipe_cap param)
>     case PIPE_CAP_TGSI_INSTANCEID:
>     case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
>     case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
> +   case PIPE_CAP_CONDITIONAL_RENDER:
>        return 1;
>     default:
>        return 0;
> --
> 1.7.6.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list