llvmpipe: add NV_conditional_render support.
authorDave Airlie <airlied@redhat.com>
Mon, 7 Nov 2011 17:31:49 +0000 (17:31 +0000)
committerDave Airlie <airlied@redhat.com>
Thu, 10 Nov 2011 20:32:13 +0000 (20:32 +0000)
This ports the softpipe NV_conditional_render support to llvmpipe.

This passes the nv_conditional_render-* piglit tests.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/llvmpipe/lp_clear.c
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_draw_arrays.c
src/gallium/drivers/llvmpipe/lp_query.c
src/gallium/drivers/llvmpipe/lp_query.h
src/gallium/drivers/llvmpipe/lp_screen.c

index be2fce1307ccaa159a169263228cbc5bcde545a8..dbcfd9cf6c83a75ba0a87e773091ab3108bc3d59 100644 (file)
@@ -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;
 
index 8a5655d49965ba4c3b5a5702dba99bc105288c34..b6ac068f02713b8fb756e423f45bd40c57048b40 100644 (file)
@@ -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);
index 503f09d810c770ec058ffafdee0ed6229a9ca1dc..70fba21309564dcc0625e1e2049260bea1beb3cd 100644 (file)
@@ -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;
 };
 
 
index 3af5c8d5c55e2bc213959b1177095ffb85e6fcd8..83045d22b5b46539babdad8bd61d8d78b2ff8870 100644 (file)
@@ -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 );
 
index 1e2401fa84d62ddf950858b136bcff325c64621d..42eb8566ef41a3403402aa975c5caea5d93f0dfb 100644 (file)
@@ -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 )
 {
index e93842a2fd060bef3f6ce6be163930a4641fb3d9..ef1bc3070372c62486c8f8ccb3c2be061dbe5c93 100644 (file)
@@ -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 */
index db3fbb9471889134202d795678079977ec8bca32..0bf0a02004c22d1df3148bf342f70ac969864bd6 100644 (file)
@@ -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;