ilo: handle conditional rendering in the context
authorChia-I Wu <olvaffe@gmail.com>
Mon, 22 Sep 2014 04:34:05 +0000 (12:34 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 22 Sep 2014 04:51:42 +0000 (12:51 +0800)
Conditional rendering is not limited to draw_vbo().  Move the support to
ilo_context, and replace ilo_3d_pass_render_condition() by
ilo_skip_rendering().

src/gallium/drivers/ilo/ilo_3d.c
src/gallium/drivers/ilo/ilo_3d.h
src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
src/gallium/drivers/ilo/ilo_blitter_blt.c
src/gallium/drivers/ilo/ilo_blitter_pipe.c
src/gallium/drivers/ilo/ilo_blitter_rectlist.c
src/gallium/drivers/ilo/ilo_context.c
src/gallium/drivers/ilo/ilo_context.h

index 3ac05ad45f76522f4962db4084469b5ded4683f7..75b2afacc3eb20468616a2487c3997514e287827 100644 (file)
@@ -433,35 +433,6 @@ draw_vbo(struct ilo_3d *hw3d, const struct ilo_state_vector *vec)
    return success;
 }
 
-bool
-ilo_3d_pass_render_condition(struct ilo_context *ilo)
-{
-   struct ilo_3d *hw3d = ilo->hw3d;
-   uint64_t result;
-   bool wait;
-
-   if (!hw3d->render_condition.query)
-      return true;
-
-   switch (hw3d->render_condition.mode) {
-   case PIPE_RENDER_COND_WAIT:
-   case PIPE_RENDER_COND_BY_REGION_WAIT:
-      wait = true;
-      break;
-   case PIPE_RENDER_COND_NO_WAIT:
-   case PIPE_RENDER_COND_BY_REGION_NO_WAIT:
-   default:
-      wait = false;
-      break;
-   }
-
-   if (ilo->base.get_query_result(&ilo->base, hw3d->render_condition.query,
-            wait, (union pipe_query_result *) &result))
-      return (!result == hw3d->render_condition.cond);
-   else
-      return true;
-}
-
 void
 ilo_3d_draw_rectlist(struct ilo_3d *hw3d, const struct ilo_blitter *blitter)
 {
@@ -738,7 +709,7 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
       ilo_state_vector_dump_dirty(&ilo->state_vector);
    }
 
-   if (!ilo_3d_pass_render_condition(ilo))
+   if (ilo_skip_rendering(ilo))
       return;
 
    if (info->primitive_restart && info->indexed) {
@@ -774,21 +745,6 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
       ilo_3d_pipeline_emit_flush(hw3d->pipeline);
 }
 
-static void
-ilo_render_condition(struct pipe_context *pipe,
-                     struct pipe_query *query,
-                     boolean condition,
-                     uint mode)
-{
-   struct ilo_context *ilo = ilo_context(pipe);
-   struct ilo_3d *hw3d = ilo->hw3d;
-
-   /* reference count? */
-   hw3d->render_condition.query = query;
-   hw3d->render_condition.mode = mode;
-   hw3d->render_condition.cond = condition;
-}
-
 static void
 ilo_texture_barrier(struct pipe_context *pipe)
 {
@@ -826,7 +782,6 @@ void
 ilo_init_3d_functions(struct ilo_context *ilo)
 {
    ilo->base.draw_vbo = ilo_draw_vbo;
-   ilo->base.render_condition = ilo_render_condition;
    ilo->base.texture_barrier = ilo_texture_barrier;
    ilo->base.get_sample_position = ilo_get_sample_position;
 }
index e4a805627b0f1f14ee08f2259952e90a12c6dc4e..565023830748f937c10e020cda2db5fc4bb301ac 100644 (file)
@@ -45,12 +45,6 @@ struct ilo_3d {
 
    bool new_batch;
 
-   struct {
-      struct pipe_query *query;
-      unsigned mode;
-      bool cond;
-   } render_condition;
-
    struct list_head queries;
 
    struct ilo_3d_pipeline *pipeline;
@@ -80,9 +74,6 @@ ilo_3d_end_query(struct pipe_context *pipe, struct ilo_query *q);
 void
 ilo_3d_process_query(struct pipe_context *pipe, struct ilo_query *q);
 
-bool
-ilo_3d_pass_render_condition(struct ilo_context *ilo);
-
 void
 ilo_init_3d_functions(struct ilo_context *ilo);
 
index c68e4f264eb1b14b026dbb4694842d60b396ad2b..dbfc993594058bb5af20313f39837a6c05fc6707 100644 (file)
@@ -29,7 +29,6 @@
 #include "util/u_dual_blend.h"
 #include "util/u_prim.h"
 
-#include "ilo_3d.h"
 #include "ilo_blitter.h"
 #include "ilo_builder_3d.h"
 #include "ilo_builder_mi.h"
index c58cad4d5a3f265f084004e58586495b4e0f0b32..86ca1e9b33780d5fb1e4b998a5c91e2ccb7783af 100644 (file)
@@ -28,7 +28,6 @@
 #include "genhw/genhw.h"
 #include "util/u_pack_color.h"
 
-#include "ilo_3d.h"
 #include "ilo_builder_mi.h"
 #include "ilo_builder_blt.h"
 #include "ilo_context.h"
@@ -441,7 +440,7 @@ ilo_blitter_blt_clear_rt(struct ilo_blitter *blitter,
    union util_color packed;
    bool success;
 
-   if (!ilo_3d_pass_render_condition(blitter->ilo))
+   if (ilo_skip_rendering(blitter->ilo))
       return true;
 
    switch (cpp) {
@@ -507,7 +506,7 @@ ilo_blitter_blt_clear_zs(struct ilo_blitter *blitter,
    struct pipe_box box;
    uint32_t val;
 
-   if (!ilo_3d_pass_render_condition(blitter->ilo))
+   if (ilo_skip_rendering(blitter->ilo))
       return true;
 
    switch (zs->format) {
index 72024a701b60a9b518cc03c0c9cfb8e9fca1438a..d9d50ead9c5a7e99d1731cd05dc7c1133efd75aa 100644 (file)
@@ -28,7 +28,6 @@
 #include "util/u_blitter.h"
 #include "util/u_surface.h"
 
-#include "ilo_3d.h"
 #include "ilo_context.h"
 #include "ilo_blitter.h"
 
@@ -46,7 +45,6 @@ ilo_blitter_pipe_begin(struct ilo_blitter *blitter,
 {
    struct blitter_context *b = blitter->pipe_blitter;
    struct ilo_state_vector *vec = &blitter->ilo->state_vector;
-   struct ilo_3d *hw3d = blitter->ilo->hw3d;
 
    /* vertex states */
    util_blitter_save_vertex_buffer_slot(b, vec->vb.states);
@@ -86,9 +84,9 @@ ilo_blitter_pipe_begin(struct ilo_blitter *blitter,
 
       /* resource_copy_region() or blit() does not honor render condition */
       util_blitter_save_render_condition(b,
-            hw3d->render_condition.query,
-            hw3d->render_condition.cond,
-            hw3d->render_condition.mode);
+            blitter->ilo->render_condition.query,
+            blitter->ilo->render_condition.condition,
+            blitter->ilo->render_condition.mode);
       break;
    case ILO_BLITTER_PIPE_CLEAR:
       /*
index eabb483f63d3c57f544736fc6d7ec90f316c9b58..989b2f377cefb279612eae4fe84daa8cf24ebcf9 100644 (file)
@@ -29,7 +29,6 @@
 #include "util/u_pack_color.h"
 
 #include "ilo_3d.h"
-#include "ilo_3d_pipeline.h"
 #include "ilo_builder_3d_top.h" /* for ve_init_cso_with_components() */
 #include "ilo_state.h"
 #include "ilo_state_gen.h" /* for zs_align_surface() */
index 4bd2ee86ecbdd65492db1112012e6b222110e043..a4a4dc2986b43b4637d9ac4cb9d4d93485a970fd 100644 (file)
@@ -65,6 +65,48 @@ ilo_flush(struct pipe_context *pipe,
    }
 }
 
+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? */
+   ilo->render_condition.query = query;
+   ilo->render_condition.condition = condition;
+   ilo->render_condition.mode = mode;
+}
+
+bool
+ilo_skip_rendering(struct ilo_context *ilo)
+{
+   uint64_t result;
+   bool wait;
+
+   if (!ilo->render_condition.query)
+      return false;
+
+   switch (ilo->render_condition.mode) {
+   case PIPE_RENDER_COND_WAIT:
+   case PIPE_RENDER_COND_BY_REGION_WAIT:
+      wait = true;
+      break;
+   case PIPE_RENDER_COND_NO_WAIT:
+   case PIPE_RENDER_COND_BY_REGION_NO_WAIT:
+   default:
+      wait = false;
+      break;
+   }
+
+   if (ilo->base.get_query_result(&ilo->base, ilo->render_condition.query,
+            wait, (union pipe_query_result *) &result))
+      return ((bool) result == ilo->render_condition.condition);
+   else
+      return false;
+}
+
 static void
 ilo_context_destroy(struct pipe_context *pipe)
 {
@@ -127,6 +169,7 @@ ilo_context_create(struct pipe_screen *screen, void *priv)
 
    ilo->base.destroy = ilo_context_destroy;
    ilo->base.flush = ilo_flush;
+   ilo->base.render_condition = ilo_render_condition;
 
    ilo_init_3d_functions(ilo);
    ilo_init_query_functions(ilo);
index 92c2c6ca7189267d7f648c170b0b7036acdd6e34..ce6050dee190a74ca54912b6eba8c23c86245e1f 100644 (file)
@@ -60,6 +60,12 @@ struct ilo_context {
    struct u_upload_mgr *uploader;
 
    struct ilo_state_vector state_vector;
+
+   struct {
+      struct pipe_query *query;
+      bool condition;
+      unsigned mode;
+   } render_condition;
 };
 
 static inline struct ilo_context *
@@ -71,4 +77,7 @@ ilo_context(struct pipe_context *pipe)
 void
 ilo_init_context_functions(struct ilo_screen *is);
 
+bool
+ilo_skip_rendering(struct ilo_context *ilo);
+
 #endif /* ILO_CONTEXT_H */