Commit 01202aaf authored by Keith Whitwell's avatar Keith Whitwell

gallium: add a predicate value to render_condition()

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.
parent 9ef6d34f
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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 */
......
......@@ -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;
}
......
......@@ -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 );
/**
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment