From: Chia-I Wu Date: Mon, 22 Sep 2014 04:34:05 +0000 (+0800) Subject: ilo: handle conditional rendering in the context X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d69faf851fff5d41086c9940b2fcf2aa72c40e60;p=mesa.git ilo: handle conditional rendering in the context 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(). --- diff --git a/src/gallium/drivers/ilo/ilo_3d.c b/src/gallium/drivers/ilo/ilo_3d.c index 3ac05ad45f7..75b2afacc3e 100644 --- a/src/gallium/drivers/ilo/ilo_3d.c +++ b/src/gallium/drivers/ilo/ilo_3d.c @@ -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; } diff --git a/src/gallium/drivers/ilo/ilo_3d.h b/src/gallium/drivers/ilo/ilo_3d.h index e4a805627b0..56502383074 100644 --- a/src/gallium/drivers/ilo/ilo_3d.h +++ b/src/gallium/drivers/ilo/ilo_3d.h @@ -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); diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c index c68e4f264eb..dbfc9935940 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c @@ -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" diff --git a/src/gallium/drivers/ilo/ilo_blitter_blt.c b/src/gallium/drivers/ilo/ilo_blitter_blt.c index c58cad4d5a3..86ca1e9b337 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_blt.c +++ b/src/gallium/drivers/ilo/ilo_blitter_blt.c @@ -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) { diff --git a/src/gallium/drivers/ilo/ilo_blitter_pipe.c b/src/gallium/drivers/ilo/ilo_blitter_pipe.c index 72024a701b6..d9d50ead9c5 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_pipe.c +++ b/src/gallium/drivers/ilo/ilo_blitter_pipe.c @@ -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: /* diff --git a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c index eabb483f63d..989b2f377ce 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c +++ b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c @@ -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() */ diff --git a/src/gallium/drivers/ilo/ilo_context.c b/src/gallium/drivers/ilo/ilo_context.c index 4bd2ee86ecb..a4a4dc2986b 100644 --- a/src/gallium/drivers/ilo/ilo_context.c +++ b/src/gallium/drivers/ilo/ilo_context.c @@ -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); diff --git a/src/gallium/drivers/ilo/ilo_context.h b/src/gallium/drivers/ilo/ilo_context.h index 92c2c6ca718..ce6050dee19 100644 --- a/src/gallium/drivers/ilo/ilo_context.h +++ b/src/gallium/drivers/ilo/ilo_context.h @@ -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 */