void *velements, *velements_saved;
struct pipe_query *render_condition, *render_condition_saved;
uint render_condition_mode, render_condition_mode_saved;
+ boolean render_condition_cond, render_condition_cond_saved;
struct pipe_clip_state clip;
struct pipe_clip_state clip_saved;
}
void cso_set_render_condition(struct cso_context *ctx,
- struct pipe_query *query, uint mode)
+ struct pipe_query *query,
+ boolean condition, uint mode)
{
struct pipe_context *pipe = ctx->pipe;
- if (ctx->render_condition != query || ctx->render_condition_mode != mode) {
- pipe->render_condition(pipe, query, mode);
+ if (ctx->render_condition != query ||
+ ctx->render_condition_mode != mode ||
+ ctx->render_condition_cond != condition) {
+ pipe->render_condition(pipe, query, condition, mode);
ctx->render_condition = query;
+ ctx->render_condition_cond = condition;
ctx->render_condition_mode = mode;
}
}
void cso_save_render_condition(struct cso_context *ctx)
{
ctx->render_condition_saved = ctx->render_condition;
+ ctx->render_condition_cond_saved = ctx->render_condition_cond;
ctx->render_condition_mode_saved = ctx->render_condition_mode;
}
void cso_restore_render_condition(struct cso_context *ctx)
{
cso_set_render_condition(ctx, ctx->render_condition_saved,
+ ctx->render_condition_cond_saved,
ctx->render_condition_mode_saved);
}
void cso_restore_stencil_ref(struct cso_context *cso);
void cso_set_render_condition(struct cso_context *cso,
- struct pipe_query *query, uint mode);
+ struct pipe_query *query,
+ boolean condition, uint mode);
void cso_save_render_condition(struct cso_context *cso);
void cso_restore_render_condition(struct cso_context *cso);
cso_set_geometry_shader_handle(cso, NULL);
cso_set_vertex_shader_handle(cso, hud->vs);
cso_set_vertex_elements(cso, 2, hud->velems);
- cso_set_render_condition(cso, NULL, 0);
+ cso_set_render_condition(cso, NULL, FALSE, 0);
cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, 1,
&hud->font_sampler_view);
cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, 1, sampler_states);
cso_set_sample_mask(cso, ~0);
cso_set_stream_outputs(cso, 0, NULL, 0);
cso_set_geometry_shader_handle(cso, NULL);
- cso_set_render_condition(cso, NULL, 0);
+ cso_set_render_condition(cso, NULL, FALSE, 0);
// Kept only for this frame.
pipe_resource_reference(&ppq->depth, indepth);
cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
- cso_set_render_condition(ctx->cso, NULL, 0);
+ cso_set_render_condition(ctx->cso, NULL, FALSE, 0);
/* default sampler state */
ctx->sampler.normalized_coords = normalized;
struct pipe_context *pipe = ctx->base.pipe;
if (ctx->base.saved_render_cond_query) {
- pipe->render_condition(pipe, NULL, 0);
+ pipe->render_condition(pipe, NULL, FALSE, 0);
}
}
if (ctx->base.saved_render_cond_query) {
pipe->render_condition(pipe, ctx->base.saved_render_cond_query,
+ ctx->base.saved_render_cond_cond,
ctx->base.saved_render_cond_mode);
ctx->base.saved_render_cond_query = NULL;
}
struct pipe_query *saved_render_cond_query;
uint saved_render_cond_mode;
+ boolean saved_render_cond_cond;
};
/**
static INLINE void
util_blitter_save_render_condition(struct blitter_context *blitter,
struct pipe_query *query,
+ boolean condition,
uint mode)
{
blitter->saved_render_cond_query = query;
blitter->saved_render_cond_mode = mode;
+ blitter->saved_render_cond_cond = condition;
}
#ifdef __cplusplus
cso_set_sample_mask(ctx->cso, ~0);
cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
- cso_set_render_condition(ctx->cso, NULL, 0);
+ cso_set_render_condition(ctx->cso, NULL, FALSE, 0);
set_fragment_shader(ctx, type, is_depth);
set_vertex_shader(ctx);
^^^^^^^^^^^^^^^^^^^^^
A drawing command can be skipped depending on the outcome of a query
-(typically an occlusion query). The ``render_condition`` function specifies
-the query which should be checked prior to rendering anything.
+(typically an occlusion query, or streamout overflow predicate).
+The ``render_condition`` function specifies the query which should be checked
+prior to rendering anything. Functions honoring render_condition include
+(and are limited to) draw_vbo, clear, clear_render_target, clear_depth_stencil.
If ``render_condition`` is called with ``query`` = NULL, conditional
rendering is disabled and drawing takes place normally.
If ``render_condition`` is called with a non-null ``query`` subsequent
-drawing commands will be predicated on the outcome of the query. If
-the query result is zero subsequent drawing commands will be skipped.
+drawing commands will be predicated on the outcome of the query.
+Commands will be skipped if ``condition`` is equal to the predicate result
+(for non-boolean queries such as OCCLUSION_QUERY, zero counts as FALSE,
+non-zero as TRUE).
If ``mode`` is PIPE_RENDER_COND_WAIT the driver will wait for the
query to complete before deciding whether to render.
If ``mode`` is PIPE_RENDER_COND_BY_REGION_WAIT or
PIPE_RENDER_COND_BY_REGION_NO_WAIT rendering will be predicated as above
-for the non-REGION modes but in the case that an occulusion query returns
+for the non-REGION modes but in the case that an occlusion query returns
a non-zero result, regions which were occluded may be ommitted by subsequent
drawing commands. This can result in better performance with some GPUs.
Normally, if the occlusion query returned a non-zero result subsequent
static void
galahad_context_render_condition(struct pipe_context *_context,
struct pipe_query *query,
+ boolean condition,
uint mode)
{
struct galahad_context *glhd_context = galahad_context(_context);
struct pipe_context *context = glhd_context->pipe;
- context->render_condition(context, query, mode);
+ context->render_condition(context, query, condition, mode);
}
if (pipe->get_query_result(pipe, hw3d->render_condition.query,
wait, (union pipe_query_result *) &result)) {
- return (result > 0);
+ return (!result == hw3d->render_condition.cond);
}
else {
return true;
static void
ilo_render_condition(struct pipe_context *pipe,
struct pipe_query *query,
+ boolean condition,
uint mode)
{
struct ilo_context *ilo = ilo_context(pipe);
/* reference count? */
hw3d->render_condition.query = query;
hw3d->render_condition.mode = mode;
+ hw3d->render_condition.cond = condition;
}
static void
struct {
struct pipe_query *query;
unsigned mode;
+ boolean cond;
} render_condition;
struct list_head occlusion_queries;
static void
llvmpipe_render_condition ( struct pipe_context *pipe,
struct pipe_query *query,
+ boolean condition,
uint mode )
{
struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe );
llvmpipe->render_cond_query = query;
llvmpipe->render_cond_mode = mode;
+ llvmpipe->render_cond_cond = condition;
}
struct pipe_context *
/** Conditional query object and mode */
struct pipe_query *render_cond_query;
uint render_cond_mode;
+ boolean render_cond_cond;
};
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, (void*)&result);
if (b)
- return result > 0;
+ return (!result == lp->render_cond_cond);
else
return TRUE;
}
lp->num_sampler_views[PIPE_SHADER_FRAGMENT],
lp->sampler_views[PIPE_SHADER_FRAGMENT]);
util_blitter_save_render_condition(lp->blitter, lp->render_cond_query,
- lp->render_cond_mode);
+ lp->render_cond_cond, lp->render_cond_mode);
util_blitter_blit(lp->blitter, &info);
}
struct pipe_query *render_cond_query;
unsigned render_cond_mode;
+ boolean render_cond_cond;
};
static INLINE struct nv30_context *
util_blitter_save_fragment_sampler_views(nv30->blitter,
nv30->fragprog.num_textures, nv30->fragprog.textures);
util_blitter_save_render_condition(nv30->blitter, nv30->render_cond_query,
- nv30->render_cond_mode);
+ nv30->render_cond_cond, nv30->render_cond_mode);
util_blitter_blit(nv30->blitter, &info);
}
static void
nv40_query_render_condition(struct pipe_context *pipe,
- struct pipe_query *pq, uint mode)
+ struct pipe_query *pq,
+ boolean condition, uint mode)
{
struct nv30_context *nv30 = nv30_context(pipe);
struct nv30_query *q = nv30_query(pq);
nv30->render_cond_query = pq;
nv30->render_cond_mode = mode;
+ nv30->render_cond_cond = condition;
if (!pq) {
BEGIN_NV04(push, SUBC_3D(0x1e98), 1);
boolean vbo_push_hint;
struct pipe_query *cond_query;
+ boolean cond_cond;
uint cond_mode;
struct nv50_blitctx *blit;
static void
nv50_render_condition(struct pipe_context *pipe,
- struct pipe_query *pq, uint mode)
+ struct pipe_query *pq,
+ boolean condition, uint mode)
{
struct nv50_context *nv50 = nv50_context(pipe);
struct nouveau_pushbuf *push = nv50->base.pushbuf;
struct nv50_query *q;
nv50->cond_query = pq;
+ nv50->cond_cond = condition;
nv50->cond_mode = mode;
PUSH_SPACE(push, 6);
if (nv50->cond_query)
nv50->base.pipe.render_condition(&nv50->base.pipe, nv50->cond_query,
- nv50->cond_mode);
+ nv50->cond_cond, nv50->cond_mode);
nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_FB);
nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_TEXTURES);
unsigned num_tfbbufs;
struct pipe_query *cond_query;
+ boolean cond_cond;
uint cond_mode;
struct nvc0_blitctx *blit;
static void
nvc0_render_condition(struct pipe_context *pipe,
- struct pipe_query *pq, uint mode)
+ struct pipe_query *pq,
+ boolean condition, uint mode)
{
struct nvc0_context *nvc0 = nvc0_context(pipe);
struct nouveau_pushbuf *push = nvc0->base.pushbuf;
mode != PIPE_RENDER_COND_BY_REGION_NO_WAIT;
nvc0->cond_query = pq;
+ nvc0->cond_cond = condition;
nvc0->cond_mode = mode;
if (!pq) {
if (nvc0->cond_query)
nvc0->base.pipe.render_condition(&nvc0->base.pipe, nvc0->cond_query,
- nvc0->cond_mode);
+ nvc0->cond_cond, nvc0->cond_mode);
nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_FB);
nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_TEX(4, 0));
static void r300_render_condition(struct pipe_context *pipe,
struct pipe_query *query,
+ boolean condition,
uint mode)
{
struct r300_context *r300 = r300_context(pipe);
if (r300_get_query_result(pipe, query, wait, &result)) {
if (r300_query(query)->type == PIPE_QUERY_OCCLUSION_PREDICATE) {
- r300->skip_rendering = !result.b;
+ r300->skip_rendering = condition == result.b;
} else {
- r300->skip_rendering = !result.u64;
- }
+ r300->skip_rendering = condition == !!result.u64;
+ }
}
}
}
if ((op & R600_DISABLE_RENDER_COND) && rctx->current_render_cond) {
util_blitter_save_render_condition(rctx->blitter,
rctx->current_render_cond,
+ rctx->current_render_cond_cond,
rctx->current_render_cond_mode);
}
}
struct r600_context *rctx = (struct r600_context *)ctx;
struct pipe_query *render_cond = NULL;
unsigned render_cond_mode = 0;
+ boolean render_cond_cond = FALSE;
rctx->rings.gfx.flushing = true;
/* Disable render condition. */
if (rctx->current_render_cond) {
render_cond = rctx->current_render_cond;
+ render_cond_cond = rctx->current_render_cond_cond;
render_cond_mode = rctx->current_render_cond_mode;
- ctx->render_condition(ctx, NULL, 0);
+ ctx->render_condition(ctx, NULL, FALSE, 0);
}
r600_context_flush(rctx, flags);
/* Re-enable render condition. */
if (render_cond) {
- ctx->render_condition(ctx, render_cond, render_cond_mode);
+ ctx->render_condition(ctx, render_cond, render_cond_cond, render_cond_mode);
}
}
/* Render condition. */
struct pipe_query *current_render_cond;
unsigned current_render_cond_mode;
+ boolean current_render_cond_cond;
boolean predicate_drawing;
void *sb_context;
static void r600_render_condition(struct pipe_context *ctx,
struct pipe_query *query,
+ boolean condition,
uint mode)
{
struct r600_context *rctx = (struct r600_context *)ctx;
bool wait_flag = false;
rctx->current_render_cond = query;
+ rctx->current_render_cond_cond = condition;
rctx->current_render_cond_mode = mode;
if (query == NULL) {
if ((op & R600_DISABLE_RENDER_COND) && rctx->current_render_cond) {
rctx->saved_render_cond = rctx->current_render_cond;
+ rctx->saved_render_cond_cond = rctx->current_render_cond_cond;
rctx->saved_render_cond_mode = rctx->current_render_cond_mode;
- rctx->context.render_condition(&rctx->context, NULL, 0);
+ rctx->context.render_condition(&rctx->context, NULL, FALSE, 0);
}
}
if (rctx->saved_render_cond) {
rctx->context.render_condition(&rctx->context,
rctx->saved_render_cond,
+ rctx->saved_render_cond_cond,
rctx->saved_render_cond_mode);
rctx->saved_render_cond = NULL;
}
static void r600_render_condition(struct pipe_context *ctx,
struct pipe_query *query,
+ boolean condition,
uint mode)
{
struct r600_context *rctx = (struct r600_context *)ctx;
/* If we already have nonzero result, render unconditionally */
if (query != NULL && rquery->result.u64 != 0) {
if (rctx->current_render_cond) {
- r600_render_condition(ctx, NULL, 0);
+ r600_render_condition(ctx, NULL, FALSE, 0);
}
return;
}
rctx->current_render_cond = query;
+ rctx->current_render_cond_cond = condition;
rctx->current_render_cond_mode = mode;
if (query == NULL) {
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_fence **rfence = (struct r600_fence**)fence;
struct pipe_query *render_cond = NULL;
+ boolean render_cond_cond = FALSE;
unsigned render_cond_mode = 0;
if (rfence)
/* Disable render condition. */
if (rctx->current_render_cond) {
render_cond = rctx->current_render_cond;
+ render_cond_cond = rctx->current_render_cond_cond;
render_cond_mode = rctx->current_render_cond_mode;
- ctx->render_condition(ctx, NULL, 0);
+ ctx->render_condition(ctx, NULL, FALSE, 0);
}
si_context_flush(rctx, flags);
/* Re-enable render condition. */
if (render_cond) {
- ctx->render_condition(ctx, render_cond, render_cond_mode);
+ ctx->render_condition(ctx, render_cond, render_cond_cond, render_cond_mode);
}
}
struct si_cs_shader_state cs_shader_state;
struct pipe_query *current_render_cond;
unsigned current_render_cond_mode;
+ boolean current_render_cond_cond;
struct pipe_query *saved_render_cond;
unsigned saved_render_cond_mode;
+ boolean saved_render_cond_cond;
/* shader information */
unsigned sprite_coord_enable;
unsigned export_16bpc;
static void
softpipe_render_condition( struct pipe_context *pipe,
struct pipe_query *query,
+ boolean condition,
uint mode )
{
struct softpipe_context *softpipe = softpipe_context( pipe );
softpipe->render_cond_query = query;
softpipe->render_cond_mode = mode;
+ softpipe->render_cond_cond = condition;
}
/** Conditional query object and mode */
struct pipe_query *render_cond_query;
uint render_cond_mode;
+ boolean render_cond_cond;
/** Polygon stipple items */
struct {
b = pipe->get_query_result(pipe, sp->render_cond_query, wait,
(void*)&result);
if (b)
- return result > 0;
+ return (!result == sp->render_cond_cond);
else
return TRUE;
}
sp->num_sampler_views[PIPE_SHADER_FRAGMENT],
sp->sampler_views[PIPE_SHADER_FRAGMENT]);
util_blitter_save_render_condition(sp->blitter, sp->render_cond_query,
- sp->render_cond_mode);
+ sp->render_cond_cond, sp->render_cond_mode);
util_blitter_blit(sp->blitter, info);
}
svga->curr.num_sampler_views,
svga->curr.sampler_views);
/*util_blitter_save_render_condition(svga->blitter, svga->render_cond_query,
- svga->render_cond_mode);*/
+ svga->render_cond_cond, svga->render_cond_mode);*/
util_blitter_blit(svga->blitter, &info);
}
static void trace_context_render_condition(struct pipe_context *_context,
struct pipe_query *query,
+ boolean condition,
uint mode)
{
struct trace_context *tr_context = trace_context(_context);
trace_dump_arg(ptr, context);
trace_dump_arg(ptr, query);
+ trace_dump_arg(bool, condition);
trace_dump_arg(uint, mode);
trace_dump_call_end();
- context->render_condition(context, query, mode);
+ context->render_condition(context, query, condition, mode);
}
/**
* Predicate subsequent rendering on occlusion query result
* \param query the query predicate, or NULL if no predicate
+ * \param condition whether to skip on FALSE or TRUE query results
* \param mode one of PIPE_RENDER_COND_x
*/
void (*render_condition)( struct pipe_context *pipe,
struct pipe_query *query,
+ boolean condition,
uint mode );
/**
m = PIPE_RENDER_COND_WAIT;
}
- cso_set_render_condition(st->cso_context, stq->pq, m);
+ cso_set_render_condition(st->cso_context, stq->pq, FALSE, m);
}
/**
- * Called via ctx->Driver.BeginConditionalRender()
+ * Called via ctx->Driver.EndConditionalRender()
*/
static void
st_EndConditionalRender(struct gl_context *ctx, struct gl_query_object *q)
st_flush_bitmap_cache(st);
- cso_set_render_condition(st->cso_context, NULL, 0);
+ cso_set_render_condition(st->cso_context, NULL, FALSE, 0);
}