aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2011-11-07 17:31:49 +0000
committerDave Airlie <[email protected]>2011-11-10 20:32:13 +0000
commitab14915dce41b26faabba878446b0ec0c8734434 (patch)
tree4d592760e7d4c621fc4098e5a1e6dd70eebb5feb
parentdbd24b5df6739b85638020c0e5ab1cc9ff84a4b7 (diff)
llvmpipe: add NV_conditional_render support.
This ports the softpipe NV_conditional_render support to llvmpipe. This passes the nv_conditional_render-* piglit tests. Signed-off-by: Dave Airlie <[email protected]>
-rw-r--r--src/gallium/drivers/llvmpipe/lp_clear.c3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.c13
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.h4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_draw_arrays.c3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_query.c18
-rw-r--r--src/gallium/drivers/llvmpipe/lp_query.h1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_screen.c1
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 be2fce1307c..dbcfd9cf6c8 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 8a5655d4996..b6ac068f027 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 503f09d810c..70fba213095 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 3af5c8d5c55..83045d22b5b 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 1e2401fa84d..42eb8566ef4 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 e93842a2fd0..ef1bc307037 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 db3fbb94718..0bf0a02004c 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;