summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2010-06-10 18:55:38 +0100
committerKeith Whitwell <keithw@vmware.com>2010-06-10 18:55:38 +0100
commit01202aafb6cb1c77332e8938de88f6f081070bf2 (patch)
tree8bb5430dc4dceab9158767a61ea6a31be7eb41c4
parent9ef6d34f7e03f3d33c0ebad4191f3300a9062c4a (diff)
gallium: add a predicate value to render_condition()gallium-render-condition-predicate
This can be used to invert the condition under which we render / do not render subsequent commands. The old behaviour matches the case where the predicate is FALSE.
-rw-r--r--src/gallium/drivers/nv50/nv50_query.c8
-rw-r--r--src/gallium/drivers/r300/r300_query.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h1
-rw-r--r--src/gallium/drivers/softpipe/sp_query.c11
-rw-r--r--src/gallium/include/pipe/p_context.h2
-rw-r--r--src/mesa/state_tracker/st_cb_condrender.c2
7 files changed, 24 insertions, 5 deletions
diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c
index 53f94820ce0..59aa2f98a48 100644
--- a/src/gallium/drivers/nv50/nv50_query.c
+++ b/src/gallium/drivers/nv50/nv50_query.c
@@ -128,13 +128,19 @@ nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq,
static void
nv50_render_condition(struct pipe_context *pipe,
- struct pipe_query *pq, uint mode)
+ struct pipe_query *pq,
+ boolean predicate,
+ uint mode)
{
struct nv50_context *nv50 = nv50_context(pipe);
struct nouveau_channel *chan = nv50->screen->base.channel;
struct nouveau_grobj *tesla = nv50->screen->tesla;
struct nv50_query *q;
+ /* Mesa state tracker only uses FALSE so far:
+ */
+ assert(predicate == FALSE);
+
if (!pq) {
BEGIN_RING(chan, tesla, NV50TCL_COND_MODE, 1);
OUT_RING (chan, NV50TCL_COND_MODE_ALWAYS);
diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c
index 7c088063683..d0a430b23fa 100644
--- a/src/gallium/drivers/r300/r300_query.c
+++ b/src/gallium/drivers/r300/r300_query.c
@@ -172,6 +172,7 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
static void r300_render_condition(struct pipe_context *pipe,
struct pipe_query *query,
+ boolean predicate,
uint mode)
{
struct r300_context *r300 = r300_context(pipe);
@@ -186,7 +187,7 @@ static void r300_render_condition(struct pipe_context *pipe,
r300->skip_rendering = FALSE;
}
- r300->skip_rendering = result == 0;
+ r300->skip_rendering = (result > 0) == predicate;
} else {
r300->skip_rendering = FALSE;
}
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 401a28ad312..13ae91c9d59 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -184,11 +184,13 @@ softpipe_is_resource_referenced( struct pipe_context *pipe,
static void
softpipe_render_condition( struct pipe_context *pipe,
struct pipe_query *query,
+ boolean predicate,
uint mode )
{
struct softpipe_context *softpipe = softpipe_context( pipe );
softpipe->render_cond_query = query;
+ softpipe->render_cond_predicate = predicate;
softpipe->render_cond_mode = mode;
}
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index e641a81d1fb..bd0141dc5a4 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -135,6 +135,7 @@ struct softpipe_context {
/** Conditional query object and mode */
struct pipe_query *render_cond_query;
+ boolean render_cond_predicate;
uint render_cond_mode;
/** Software quad rendering pipeline */
diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c
index 245f1b554c9..23f65ef147a 100644
--- a/src/gallium/drivers/softpipe/sp_query.c
+++ b/src/gallium/drivers/softpipe/sp_query.c
@@ -168,8 +168,15 @@ softpipe_check_render_cond(struct softpipe_context *sp)
sp->render_cond_mode == PIPE_RENDER_COND_BY_REGION_WAIT);
b = pipe->get_query_result(pipe, sp->render_cond_query, wait, &result);
- if (b)
- return result > 0;
+ if (b) {
+ /* Consider the condition TRUE if any fragments were rasterized.
+ */
+ boolean predicate = (result > 0);
+
+ /* Permit rendering if condition does not match render_cond_predicate.
+ */
+ return predicate != sp->render_cond_predicate;
+ }
else
return TRUE;
}
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 72afad60ba9..8732eabe066 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -111,10 +111,12 @@ struct pipe_context {
/**
* Predicate subsequent rendering on occlusion query result
* \param query the query predicate, or NULL if no predicate
+ * \param value the condition on which to permit rendering
* \param mode one of PIPE_RENDER_COND_x
*/
void (*render_condition)( struct pipe_context *pipe,
struct pipe_query *query,
+ boolean predicate_value,
uint mode );
/**
diff --git a/src/mesa/state_tracker/st_cb_condrender.c b/src/mesa/state_tracker/st_cb_condrender.c
index b509d43b7c6..f65f71ef82e 100644
--- a/src/mesa/state_tracker/st_cb_condrender.c
+++ b/src/mesa/state_tracker/st_cb_condrender.c
@@ -72,7 +72,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q,
m = PIPE_RENDER_COND_WAIT;
}
- pipe->render_condition(pipe, stq->pq, m);
+ pipe->render_condition(pipe, stq->pq, FALSE, m);
}