diff options
author | Chia-I Wu <[email protected]> | 2014-09-21 22:39:16 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-09-21 23:31:41 +0800 |
commit | 6b79d894d7c22523ee1ccdee73f4bab79c0cf76d (patch) | |
tree | 9b8921685c0a26483072d34e241e9c0f43b86a1d | |
parent | 154972700d54f83827dbccad1ef09077a63c8a59 (diff) |
ilo: replace software queries by hardware ones
Read PIPE_QUERY_PRIMITIVES_GENERATED and PIPE_QUERY_PRIMITIVES_EMITTED from
hardware registers. Because all queries now have a bo, remove unnecessary
checks for q->bo.
Signed-off-by: Chia-I Wu <[email protected]>
-rw-r--r-- | src/gallium/drivers/ilo/ilo_3d.c | 84 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_3d_pipeline.c | 39 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_3d_pipeline.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c | 2 |
4 files changed, 47 insertions, 83 deletions
diff --git a/src/gallium/drivers/ilo/ilo_3d.c b/src/gallium/drivers/ilo/ilo_3d.c index e30db260a8c..ded5c6ce464 100644 --- a/src/gallium/drivers/ilo/ilo_3d.c +++ b/src/gallium/drivers/ilo/ilo_3d.c @@ -72,6 +72,8 @@ query_process_bo(const struct ilo_3d *hw3d, struct ilo_query *q) switch (q->type) { case PIPE_QUERY_OCCLUSION_COUNTER: case PIPE_QUERY_TIME_ELAPSED: + case PIPE_QUERY_PRIMITIVES_GENERATED: + case PIPE_QUERY_PRIMITIVES_EMITTED: assert(q->stride == sizeof(*vals) * 2); tmp = 0; @@ -157,6 +159,8 @@ ilo_3d_init_query(struct pipe_context *pipe, struct ilo_query *q) switch (q->type) { case PIPE_QUERY_OCCLUSION_COUNTER: case PIPE_QUERY_TIME_ELAPSED: + case PIPE_QUERY_PRIMITIVES_GENERATED: + case PIPE_QUERY_PRIMITIVES_EMITTED: q->stride = sizeof(uint64_t); q->in_pairs = true; break; @@ -168,10 +172,6 @@ ilo_3d_init_query(struct pipe_context *pipe, struct ilo_query *q) q->stride = sizeof(uint64_t) * 11; q->in_pairs = true; break; - case PIPE_QUERY_PRIMITIVES_GENERATED: - case PIPE_QUERY_PRIMITIVES_EMITTED: - return true; - break; default: return false; break; @@ -201,23 +201,21 @@ ilo_3d_begin_query(struct pipe_context *pipe, struct ilo_query *q) ilo_3d_own_render_ring(hw3d); - if (q->bo) { - /* need to submit first */ - if (!ilo_builder_validate(&hw3d->cp->builder, 1, &q->bo) || - ilo_cp_space(hw3d->cp) < q->cmd_len) { - ilo_cp_submit(hw3d->cp, "out of aperture or space"); + /* need to submit first */ + if (!ilo_builder_validate(&hw3d->cp->builder, 1, &q->bo) || + ilo_cp_space(hw3d->cp) < q->cmd_len) { + ilo_cp_submit(hw3d->cp, "out of aperture or space"); - assert(ilo_builder_validate(&hw3d->cp->builder, 1, &q->bo)); - assert(ilo_cp_space(hw3d->cp) >= q->cmd_len); + assert(ilo_builder_validate(&hw3d->cp->builder, 1, &q->bo)); + assert(ilo_cp_space(hw3d->cp) >= q->cmd_len); - ilo_3d_own_render_ring(hw3d); - } + ilo_3d_own_render_ring(hw3d); + } - /* reserve the space for ending/pausing the query */ - hw3d->owner.reserve += q->cmd_len >> q->in_pairs; + /* reserve the space for ending/pausing the query */ + hw3d->owner.reserve += q->cmd_len >> q->in_pairs; - query_begin_bo(hw3d, q); - } + query_begin_bo(hw3d, q); switch (q->type) { case PIPE_QUERY_OCCLUSION_COUNTER: @@ -251,13 +249,11 @@ ilo_3d_end_query(struct pipe_context *pipe, struct ilo_query *q) ilo_3d_own_render_ring(hw3d); - if (q->bo) { - /* reclaim the reserved space */ - hw3d->owner.reserve -= q->cmd_len >> q->in_pairs; - assert(hw3d->owner.reserve >= 0); + /* reclaim the reserved space */ + hw3d->owner.reserve -= q->cmd_len >> q->in_pairs; + assert(hw3d->owner.reserve >= 0); - query_end_bo(hw3d, q); - } + query_end_bo(hw3d, q); list_delinit(&q->list); } @@ -270,8 +266,7 @@ ilo_3d_process_query(struct pipe_context *pipe, struct ilo_query *q) { struct ilo_3d *hw3d = ilo_context(pipe)->hw3d; - if (q->bo) - query_process_bo(hw3d, q); + query_process_bo(hw3d, q); } static void @@ -299,6 +294,14 @@ ilo_3d_own_cp(struct ilo_cp *cp, void *data) LIST_FOR_EACH_ENTRY(q, &hw3d->time_elapsed_queries, list) query_begin_bo(hw3d, q); + /* resume prim generated queries */ + LIST_FOR_EACH_ENTRY(q, &hw3d->prim_generated_queries, list) + query_begin_bo(hw3d, q); + + /* resume prim emitted queries */ + LIST_FOR_EACH_ENTRY(q, &hw3d->prim_emitted_queries, list) + query_begin_bo(hw3d, q); + /* resume pipeline statistics queries */ LIST_FOR_EACH_ENTRY(q, &hw3d->pipeline_statistics_queries, list) query_begin_bo(hw3d, q); @@ -334,6 +337,14 @@ ilo_3d_release_cp(struct ilo_cp *cp, void *data) LIST_FOR_EACH_ENTRY(q, &hw3d->time_elapsed_queries, list) query_end_bo(hw3d, q); + /* pause prim generated queries */ + LIST_FOR_EACH_ENTRY(q, &hw3d->prim_generated_queries, list) + query_end_bo(hw3d, q); + + /* pause prim emitted queries */ + LIST_FOR_EACH_ENTRY(q, &hw3d->prim_emitted_queries, list) + query_end_bo(hw3d, q); + /* pause pipeline statistics queries */ LIST_FOR_EACH_ENTRY(q, &hw3d->pipeline_statistics_queries, list) query_end_bo(hw3d, q); @@ -400,8 +411,7 @@ ilo_3d_destroy(struct ilo_3d *hw3d) } static bool -draw_vbo(struct ilo_3d *hw3d, const struct ilo_state_vector *vec, - int *prim_generated, int *prim_emitted) +draw_vbo(struct ilo_3d *hw3d, const struct ilo_state_vector *vec) { bool need_flush = false; int max_len; @@ -438,20 +448,7 @@ draw_vbo(struct ilo_3d *hw3d, const struct ilo_state_vector *vec, if (need_flush) ilo_3d_pipeline_emit_flush(hw3d->pipeline); - return ilo_3d_pipeline_emit_draw(hw3d->pipeline, vec, - prim_generated, prim_emitted); -} - -static void -update_prim_count(struct ilo_3d *hw3d, int generated, int emitted) -{ - struct ilo_query *q; - - LIST_FOR_EACH_ENTRY(q, &hw3d->prim_generated_queries, list) - q->result.u64 += generated; - - LIST_FOR_EACH_ENTRY(q, &hw3d->prim_emitted_queries, list) - q->result.u64 += emitted; + return ilo_3d_pipeline_emit_draw(hw3d->pipeline, vec); } bool @@ -708,7 +705,6 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) { struct ilo_context *ilo = ilo_context(pipe); struct ilo_3d *hw3d = ilo->hw3d; - int prim_generated, prim_emitted; if (ilo_debug & ILO_DEBUG_DRAW) { if (info->indexed) { @@ -747,7 +743,7 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) ilo_blit_resolve_framebuffer(ilo); /* If draw_vbo ever fails, return immediately. */ - if (!draw_vbo(hw3d, &ilo->state_vector, &prim_generated, &prim_emitted)) + if (!draw_vbo(hw3d, &ilo->state_vector)) return; /* clear dirty status */ @@ -757,8 +753,6 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) /* avoid dangling pointer reference */ ilo->state_vector.draw = NULL; - update_prim_count(hw3d, prim_generated, prim_emitted); - if (ilo_debug & ILO_DEBUG_NOCACHE) ilo_3d_pipeline_emit_flush(hw3d->pipeline); } diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline.c b/src/gallium/drivers/ilo/ilo_3d_pipeline.c index a14da4beb9c..cfe3c5d7977 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline.c @@ -150,25 +150,14 @@ handle_invalid_batch_bo(struct ilo_3d_pipeline *p, bool unset) */ bool ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p, - const struct ilo_state_vector *vec, - int *prim_generated, int *prim_emitted) + const struct ilo_state_vector *vec) { bool success; - if (vec->dirty & ILO_DIRTY_SO && - vec->so.enabled && !vec->so.append_bitmask) { - /* - * We keep track of the SVBI in the driver, so that we can restore it - * when the HW context is invalidated (by another process). The value - * needs to be reset when stream output is enabled and the targets are - * changed. - */ - p->state.so_num_vertices = 0; - - /* on GEN7+, we need SOL_RESET to reset the SO write offsets */ - if (ilo_dev_gen(p->dev) >= ILO_GEN(7)) - ilo_cp_set_one_off_flags(p->cp, INTEL_EXEC_GEN7_SOL_RESET); - } + /* on GEN7+, we need SOL_RESET to reset the SO write offsets */ + if (ilo_dev_gen(p->dev) >= ILO_GEN(7) && (vec->dirty & ILO_DIRTY_SO) && + vec->so.enabled && !vec->so.append_bitmask) + ilo_cp_set_one_off_flags(p->cp, INTEL_EXEC_GEN7_SOL_RESET); while (true) { struct ilo_builder_snapshot snapshot; @@ -199,24 +188,6 @@ ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p, break; } - if (success) { - const int num_verts = - u_vertices_per_prim(u_reduced_prim(vec->draw->mode)); - const int max_emit = - (p->state.so_max_vertices - p->state.so_num_vertices) / num_verts; - const int generated = - u_reduced_prims_for_vertices(vec->draw->mode, vec->draw->count); - const int emitted = MIN2(generated, max_emit); - - p->state.so_num_vertices += emitted * num_verts; - - if (prim_generated) - *prim_generated = generated; - - if (prim_emitted) - *prim_emitted = emitted; - } - p->invalidate_flags = 0x0; return success; diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline.h b/src/gallium/drivers/ilo/ilo_3d_pipeline.h index cf3e846aa21..802c965a8c4 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline.h +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline.h @@ -93,7 +93,7 @@ struct ilo_3d_pipeline { bool primitive_restart; int reduced_prim; - int so_num_vertices, so_max_vertices; + int so_max_vertices; uint32_t SF_VIEWPORT; uint32_t CLIP_VIEWPORT; @@ -161,8 +161,7 @@ ilo_3d_pipeline_estimate_size(struct ilo_3d_pipeline *pipeline, bool ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p, - const struct ilo_state_vector *vec, - int *prim_generated, int *prim_emitted); + const struct ilo_state_vector *vec); void ilo_3d_pipeline_emit_flush(struct ilo_3d_pipeline *p); diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c index 718afe71219..49bd7e79cbd 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c @@ -583,7 +583,7 @@ gen6_pipeline_gs_svbi(struct ilo_3d_pipeline *p, gen6_wa_pipe_control_post_sync(p, false); gen6_3DSTATE_GS_SVB_INDEX(p->builder, - 0, p->state.so_num_vertices, p->state.so_max_vertices, + 0, 0, p->state.so_max_vertices, false); if (session->hw_ctx_changed) { |