gallium: add condition parameter to render_condition
authorRoland Scheidegger <sroland@vmware.com>
Fri, 14 Jun 2013 17:48:57 +0000 (19:48 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 18 Jun 2013 16:01:24 +0000 (18:01 +0200)
For conditional rendering this makes it possible to skip rendering
if either the predicate is true or false, as supported by d3d10
(in fact previously it was sort of implied skip rendering if predicate
is false for occlusion predicate, and true for so_overflow predicate).
There's no cap bit for this as presumably all drivers could do it trivially
(but this patch does not implement it for the drivers using true
hw predicates, nvxx, r600, radeonsi, no change is expected for OpenGL
functionality).

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
42 files changed:
src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/auxiliary/cso_cache/cso_context.h
src/gallium/auxiliary/hud/hud_context.c
src/gallium/auxiliary/postprocess/pp_run.c
src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h
src/gallium/auxiliary/util/u_gen_mipmap.c
src/gallium/docs/source/context.rst
src/gallium/drivers/galahad/glhd_context.c
src/gallium/drivers/ilo/ilo_3d.c
src/gallium/drivers/ilo/ilo_3d.h
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_query.c
src/gallium/drivers/llvmpipe/lp_surface.c
src/gallium/drivers/nv30/nv30_context.h
src/gallium/drivers/nv30/nv30_miptree.c
src/gallium/drivers/nv30/nv30_query.c
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_query.c
src/gallium/drivers/nv50/nv50_surface.c
src/gallium/drivers/nvc0/nvc0_context.h
src/gallium/drivers/nvc0/nvc0_query.c
src/gallium/drivers/nvc0/nvc0_surface.c
src/gallium/drivers/r300/r300_query.c
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_query.c
src/gallium/drivers/radeonsi/r600_blit.c
src/gallium/drivers/radeonsi/r600_query.c
src/gallium/drivers/radeonsi/radeonsi_pipe.c
src/gallium/drivers/radeonsi/radeonsi_pipe.h
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_query.c
src/gallium/drivers/softpipe/sp_surface.c
src/gallium/drivers/svga/svga_pipe_blit.c
src/gallium/drivers/trace/tr_context.c
src/gallium/include/pipe/p_context.h
src/mesa/state_tracker/st_cb_condrender.c

index b06a070ad83f83df5b88ba50ba151fabe5e92595..6805427b816124a476ce2e03764b6efd4b5b832b 100644 (file)
@@ -111,6 +111,7 @@ struct cso_context {
    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;
@@ -723,13 +724,17 @@ void cso_restore_stencil_ref(struct cso_context *ctx)
 }
 
 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;
    }
 }
@@ -737,12 +742,14 @@ void cso_set_render_condition(struct cso_context *ctx,
 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);
 }
 
index 20ab4ef1aaa19c5751cc2f542581771d48076d65..82c8e18def088aa2173ddd684a34b1212955f0ab 100644 (file)
@@ -170,7 +170,8 @@ void cso_save_stencil_ref(struct cso_context *cso);
 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);
 
index cbd00a9614aa2feccf5f5805a0e3d7edadf2898a..9817083144eee0d6e686d6c1ecd1aa80304b3642 100644 (file)
@@ -456,7 +456,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
    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);
index 8b3f451640ae80ba9c13315a4d4cfb43aaa6b034..54253f418286e1fa965291d1b6139284f09f93fb 100644 (file)
@@ -90,7 +90,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
    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);
index cda66d15749d61188e881f347117747114bbdaa5..07418be45e81c9bdfbda961562852c48426e45b5 100644 (file)
@@ -679,7 +679,7 @@ util_blit_pixels(struct blit_state *ctx,
    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;
index e9ac170f79616a382e270c5ddc4e995a3946ddc6..be839d4390eb521329a19b305c0a9692a71e3421 100644 (file)
@@ -492,7 +492,7 @@ static void blitter_disable_render_cond(struct blitter_context_priv *ctx)
    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);
    }
 }
 
@@ -502,6 +502,7 @@ static void blitter_restore_render_cond(struct blitter_context_priv *ctx)
 
    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;
    }
index e52d5acc95ffcef9ebb5276a1f045fef9c214b3f..d9cefde500a6efb40161b784c2cbbe105b597002 100644 (file)
@@ -125,6 +125,7 @@ struct blitter_context
 
    struct pipe_query *saved_render_cond_query;
    uint saved_render_cond_mode;
+   boolean saved_render_cond_cond;
 };
 
 /**
@@ -515,10 +516,12 @@ util_blitter_save_sample_mask(struct blitter_context *blitter,
 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
index 7974b1d7612b1af50b37ed4f70fd3c2a4c1badc8..a885f2b0f28883b36dc9c56404a149fd9311fd55 100644 (file)
@@ -1578,7 +1578,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    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);
index 6a8238e77799a450e863f366013b73b910de3bd6..ede89be6ed6ccd75b1904a6c4221df664819a7e8 100644 (file)
@@ -382,15 +382,19 @@ Conditional Rendering
 ^^^^^^^^^^^^^^^^^^^^^
 
 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.
@@ -401,7 +405,7 @@ has completed, drawing will be predicated on the outcome of the query.
 
 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
index 7e8af565c138fd32b960b6e08375999931b886a5..ee9de058bb03aeef8e53e8d4650284197211e78c 100644 (file)
@@ -1011,12 +1011,13 @@ galahad_context_transfer_inline_write(struct pipe_context *_context,
 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);
 }
 
 
index b2cbcf04e0ca208af5ff86ea6daec20f9aae8885..17dd5b125e9ff82daa4a94aa69c0452ff429d835 100644 (file)
@@ -445,7 +445,7 @@ pass_render_condition(struct ilo_3d *hw3d, struct pipe_context *pipe)
 
    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;
@@ -679,6 +679,7 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 static void
 ilo_render_condition(struct pipe_context *pipe,
                      struct pipe_query *query,
+                     boolean condition,
                      uint mode)
 {
    struct ilo_context *ilo = ilo_context(pipe);
@@ -687,6 +688,7 @@ ilo_render_condition(struct pipe_context *pipe,
    /* reference count? */
    hw3d->render_condition.query = query;
    hw3d->render_condition.mode = mode;
+   hw3d->render_condition.cond = condition;
 }
 
 static void
index 3e67c8521d6103097be2278e2043dfda87a011a6..a1a0efc5e961d110139789a7625ce27f31a5afad 100644 (file)
@@ -49,6 +49,7 @@ struct ilo_3d {
    struct {
       struct pipe_query *query;
       unsigned mode;
+      boolean cond;
    } render_condition;
 
    struct list_head occlusion_queries;
index a6d7e594cd6dd92815df7917e4fbc82c48caa2cd..9a6d13b5bf0b13c4e924dd6beade69aaca03be1f 100644 (file)
@@ -112,12 +112,14 @@ do_flush( struct pipe_context *pipe,
 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 *
index 051596878d91ccdc280f6f6e9e61e62c9f686244..27e8b0134d07645687b8e4165a6e296873c4599e 100644 (file)
@@ -149,6 +149,7 @@ struct llvmpipe_context {
    /** Conditional query object and mode */
    struct pipe_query *render_cond_query;
    uint render_cond_mode;
+   boolean render_cond_cond;
 };
 
 
index 0fd91c044a88e8ca47be2ec46f0c0b905c8d156c..973c6898dd6f1233bef10f85a3edcb55cb2147fc 100644 (file)
@@ -284,12 +284,13 @@ llvmpipe_check_render_cond(struct llvmpipe_context *lp)
 
    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;
 }
index a40fe1be99af1e525015cb66e280744fa5e957dc..7b1f9391b7e45d59ae5b62f14bcc4074c4aac4f6 100644 (file)
@@ -227,7 +227,7 @@ static void lp_blit(struct pipe_context *pipe,
                      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);
 }
 
index c90dd3c1061704a93ad60072b931a69eca6658f8..3009a0c901a92d1fd5a1252ed78aaabb78170818 100644 (file)
@@ -129,6 +129,7 @@ struct nv30_context {
 
    struct pipe_query *render_cond_query;
    unsigned render_cond_mode;
+   boolean render_cond_cond;
 };
 
 static INLINE struct nv30_context *
index 4f5c445879aafd2eaef3c5031aad9aca19075c3a..c038d708a5f597a9ce18f0c7620de97de51c7b41 100644 (file)
@@ -213,7 +213,7 @@ nv30_blit(struct pipe_context *pipe,
    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);
 }
 
index 877408648e0e2ee563f76fa554b93f6e0510174f..a0a4c67a3d440d433dfbbd45e7ecc2f258fab910 100644 (file)
@@ -232,7 +232,8 @@ nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq,
 
 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);
@@ -240,6 +241,7 @@ nv40_query_render_condition(struct pipe_context *pipe,
 
    nv30->render_cond_query = pq;
    nv30->render_cond_mode = mode;
+   nv30->render_cond_cond = condition;
 
    if (!pq) {
       BEGIN_NV04(push, SUBC_3D(0x1e98), 1);
index 043ed898913c38c5d56084c9195e84b0f5fa4b1f..0a83131fefd736b0f044618f82237a8bdb5407be 100644 (file)
@@ -156,6 +156,7 @@ struct nv50_context {
    boolean vbo_push_hint;
 
    struct pipe_query *cond_query;
+   boolean cond_cond;
    uint cond_mode;
 
    struct nv50_blitctx *blit;
index f434f5f7939d7b5f3ec2b3bdd7651bd491eeec0a..656ff9daa438c7fe43750edc807172fefc767905 100644 (file)
@@ -321,13 +321,15 @@ nv84_query_fifo_wait(struct nouveau_pushbuf *push, struct pipe_query *pq)
 
 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);
index 2bfd8556c669125e5b435588ad75c3499ded3f14..d6066f2ae961e03e68c50413a064429cb3c5c3ea 100644 (file)
@@ -902,7 +902,7 @@ nv50_blitctx_post_blit(struct nv50_blitctx *blit)
 
    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);
index 799d9b9460a1740b951015b927c7528d18e5c694..0431b89e1514d9f10916eb02c85d4ba373ff0be2 100644 (file)
@@ -189,6 +189,7 @@ struct nvc0_context {
    unsigned num_tfbbufs;
 
    struct pipe_query *cond_query;
+   boolean cond_cond;
    uint cond_mode;
 
    struct nvc0_blitctx *blit;
index d905f1a8115480780a39223f9f0aac05eacc2873..8e584c900a6e655d1223f5de8572e7352967fc42 100644 (file)
@@ -518,7 +518,8 @@ nvc0_query_fifo_wait(struct nouveau_pushbuf *push, struct pipe_query *pq)
 
 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;
@@ -530,6 +531,7 @@ nvc0_render_condition(struct pipe_context *pipe,
       mode != PIPE_RENDER_COND_BY_REGION_NO_WAIT;
 
    nvc0->cond_query = pq;
+   nvc0->cond_cond = condition;
    nvc0->cond_mode = mode;
 
    if (!pq) {
index e02cf22f506e6fdfeb935638752b39b7bdafb26e..c8d26f5a12462dfd86365a02cfaed9a07384c220 100644 (file)
@@ -801,7 +801,7 @@ nvc0_blitctx_post_blit(struct nvc0_blitctx *blit)
 
    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));
index e338c57ed80ae884fa5ed5490a395f2b6133fc02..fbf44c68419d6ff958a623dc3034d81f16fa5ace 100644 (file)
@@ -178,6 +178,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 condition,
                                   uint mode)
 {
     struct r300_context *r300 = r300_context(pipe);
@@ -192,10 +193,10 @@ static void r300_render_condition(struct pipe_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;
+            }
         }
     }
 }
index 660f4f9aa96f8bd6428eb92aaed7e4f8b8bca68a..dcc397851fc84a3af33f02b053d1d7dd0a9b4d46 100644 (file)
@@ -88,6 +88,7 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum r600_blitter_op op
        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);
         }
 }
index 71f555b0eab087e288bfbd67c38f0884deff0211..74a650a01e773a3715c5c4af74958e40f63b99b9 100644 (file)
@@ -162,13 +162,15 @@ static void r600_flush(struct pipe_context *ctx, unsigned flags)
        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);
@@ -177,7 +179,7 @@ static void r600_flush(struct pipe_context *ctx, unsigned 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);
        }
 }
 
index 2a81434155e189ca93f281eed3f7540d7d16273b..1dc346f049fa41297e6f8b280c41e0eef829449c 100644 (file)
@@ -629,6 +629,7 @@ struct r600_context {
        /* Render condition. */
        struct pipe_query               *current_render_cond;
        unsigned                        current_render_cond_mode;
+       boolean                         current_render_cond_cond;
        boolean                         predicate_drawing;
 
        void                            *sb_context;
index d264b7f3970b192708b3804619da6e3783e1b5ad..f77e1a8f52db7e0afed7ff61d4735b2f8e7775c3 100644 (file)
@@ -669,6 +669,7 @@ static boolean r600_get_query_result(struct pipe_context *ctx,
 
 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;
@@ -676,6 +677,7 @@ static void r600_render_condition(struct pipe_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) {
index 724d481daad910204971e805b34ecb092818ea2c..34f14bae03479349679fb4e8bdd49041aea235e4 100644 (file)
@@ -80,8 +80,9 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum r600_blitter_op op
 
        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);
        }
 
 }
@@ -92,6 +93,7 @@ static void r600_blitter_end(struct pipe_context *ctx)
        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;
        }
index bbf7c046f5774528bef1069f5c205f1efe875c1f..0162cce894a2eaed038f91c29e34642e7261b3ba 100644 (file)
@@ -69,6 +69,7 @@ static boolean r600_get_query_result(struct pipe_context *ctx,
 
 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;
@@ -78,12 +79,13 @@ static void r600_render_condition(struct pipe_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) {
index 382311f39bdb04adf29366ccd3d9e96066542406..3f4cd78cd5796f832795b62fa45d2a16301adbaa 100644 (file)
@@ -139,6 +139,7 @@ void radeonsi_flush(struct pipe_context *ctx, struct pipe_fence_handle **fence,
        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)
@@ -147,15 +148,16 @@ void radeonsi_flush(struct pipe_context *ctx, struct pipe_fence_handle **fence,
        /* 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);
        }
 }
 
index 67cb14b7cc0db19b7ffb7c9cd6e85d92964b4e97..90d67e28d21047110e3cc6ec8a3e86efc0c4009b 100644 (file)
@@ -153,8 +153,10 @@ struct r600_context {
        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;
index 141b7a8b18520d5ed2c7b2cf7e244dd719fd0fb7..14cfdc8c23bfffd172c65a2d5fe3678ff7e4d593 100644 (file)
@@ -175,12 +175,14 @@ softpipe_is_resource_referenced( struct pipe_context *pipe,
 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;
 }
 
 
index ea6c0f929c52970e137a67c95720d9e95dc0a01a..d7a00b95b25491a97a9dc32124cf32dbae9b89d0 100644 (file)
@@ -144,6 +144,7 @@ struct softpipe_context {
    /** Conditional query object and mode */
    struct pipe_query *render_cond_query;
    uint render_cond_mode;
+   boolean render_cond_cond;
 
    /** Polygon stipple items */
    struct {
index b444e378085ca99295f2ed158482affbcabdae16..b5bc0db44901520d0d501816d4146e250f9294ac 100644 (file)
@@ -261,7 +261,7 @@ softpipe_check_render_cond(struct softpipe_context *sp)
    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;
 }
index 911c34df1b806a6c994f7121ce232d86220c9d2c..52c85be2e3f05bcc54b3a3d85db46e2a7221c2f3 100644 (file)
@@ -78,7 +78,7 @@ static void sp_blit(struct pipe_context *pipe,
                      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);
 }
 
index a44ed12adf7a73e769d70b6c24736ff1831d0ee3..05930d0ec519d01d69fd8002cdfb8a6fd3308440 100644 (file)
@@ -206,7 +206,7 @@ static void svga_blit(struct pipe_context *pipe,
                      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);
 }
 
index ee23077d960fd1fb18136226118c76bab69f1cfd..d78dd3ed3479533645c9bdca3b496cf8c4c5e9bc 100644 (file)
@@ -1482,6 +1482,7 @@ trace_context_transfer_inline_write(struct pipe_context *_context,
 
 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);
@@ -1491,11 +1492,12 @@ static void trace_context_render_condition(struct pipe_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);
 }
 
 
index 0403d3b3d7fd63c29d1244f07a7b5fe71aca8b50..aa18cbf5d61b4c27d71f8c7f80a4da1c8f24f609 100644 (file)
@@ -96,10 +96,12 @@ struct pipe_context {
    /**
     * 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 );
 
    /**
index 3a5835ecdc6ff6e4a073835e1501d144ec715a98..8776985f961277a4d24946f4fc0938f0aab1d2c8 100644 (file)
@@ -76,12 +76,12 @@ st_BeginConditionalRender(struct gl_context *ctx, struct gl_query_object *q,
       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)
@@ -91,7 +91,7 @@ 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);
 }