diff options
author | Chia-I Wu <[email protected]> | 2014-09-24 13:11:25 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-09-26 21:15:55 +0800 |
commit | 3afe30e64be7f4686398f826389159d87d8ae096 (patch) | |
tree | 99b0c56d4537cbbbb5fb397094ec4179809d88b6 /src/gallium | |
parent | b6443ae969f613458635f043f322ba362e671254 (diff) |
ilo: remove struct ilo_3d
Move members of ilo_3d that still make sense to ilo_context. With ilo_3d
gone, rename functions whose names begin with ilo_3d to something more
appropriate.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blitter_rectlist.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_context.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_context.h | 14 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_draw.c | 280 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_draw.h | 37 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_query.c | 48 |
6 files changed, 167 insertions, 232 deletions
diff --git a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c index 3b988682058..aafb5f10443 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c +++ b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c @@ -308,7 +308,7 @@ hiz_emit_rectlist(struct ilo_blitter *blitter) ilo_blitter_set_rectlist(blitter, 0, 0, blitter->fb.width, blitter->fb.height); - ilo_3d_draw_rectlist(blitter->ilo->hw3d, blitter); + ilo_draw_rectlist(blitter->ilo); } static bool diff --git a/src/gallium/drivers/ilo/ilo_context.c b/src/gallium/drivers/ilo/ilo_context.c index 7b6b27e74d0..ca991e16338 100644 --- a/src/gallium/drivers/ilo/ilo_context.c +++ b/src/gallium/drivers/ilo/ilo_context.c @@ -33,6 +33,7 @@ #include "ilo_draw.h" #include "ilo_gpgpu.h" #include "ilo_query.h" +#include "ilo_render.h" #include "ilo_resource.h" #include "ilo_screen.h" #include "ilo_shader.h" @@ -46,7 +47,11 @@ ilo_context_cp_submitted(struct ilo_cp *cp, void *data) { struct ilo_context *ilo = ilo_context(data); - ilo_3d_cp_submitted(ilo->hw3d); + /* invalidate the pipeline */ + ilo_3d_pipeline_invalidate(ilo->pipeline, + ILO_3D_PIPELINE_INVALIDATE_BATCH_BO | + ILO_3D_PIPELINE_INVALIDATE_STATE_BO | + ILO_3D_PIPELINE_INVALIDATE_KERNEL_BO); } static void @@ -119,8 +124,8 @@ ilo_context_destroy(struct pipe_context *pipe) if (ilo->blitter) ilo_blitter_destroy(ilo->blitter); - if (ilo->hw3d) - ilo_3d_destroy(ilo->hw3d); + if (ilo->pipeline) + ilo_3d_pipeline_destroy(ilo->pipeline); if (ilo->shader_cache) ilo_shader_cache_destroy(ilo->shader_cache); if (ilo->cp) @@ -154,9 +159,9 @@ ilo_context_create(struct pipe_screen *screen, void *priv) ilo->shader_cache = ilo_shader_cache_create(); ilo->cp = ilo_cp_create(ilo->dev, ilo->winsys, ilo->shader_cache); if (ilo->cp) - ilo->hw3d = ilo_3d_create(ilo->cp, ilo->dev); + ilo->pipeline = ilo_3d_pipeline_create(&ilo->cp->builder); - if (!ilo->cp || !ilo->shader_cache || !ilo->hw3d) { + if (!ilo->cp || !ilo->shader_cache || !ilo->pipeline) { ilo_context_destroy(&ilo->base); return NULL; } @@ -171,7 +176,7 @@ ilo_context_create(struct pipe_screen *screen, void *priv) ilo->base.flush = ilo_flush; ilo->base.render_condition = ilo_render_condition; - ilo_init_3d_functions(ilo); + ilo_init_draw_functions(ilo); ilo_init_query_functions(ilo); ilo_init_state_functions(ilo); ilo_init_blit_functions(ilo); @@ -179,6 +184,7 @@ ilo_context_create(struct pipe_screen *screen, void *priv) ilo_init_video_functions(ilo); ilo_init_gpgpu_functions(ilo); + ilo_init_draw(ilo); ilo_state_vector_init(ilo->dev, &ilo->state_vector); /* diff --git a/src/gallium/drivers/ilo/ilo_context.h b/src/gallium/drivers/ilo/ilo_context.h index ce6050dee19..4c8c6ff6840 100644 --- a/src/gallium/drivers/ilo/ilo_context.h +++ b/src/gallium/drivers/ilo/ilo_context.h @@ -32,14 +32,15 @@ #include "util/u_slab.h" #include "ilo_common.h" +#include "ilo_cp.h" +#include "ilo_draw.h" #include "ilo_state.h" struct u_upload_mgr; - struct intel_winsys; -struct ilo_3d; + +struct ilo_3d_pipeline; struct ilo_blitter; -struct ilo_cp; struct ilo_screen; struct ilo_shader_cache; @@ -54,8 +55,8 @@ struct ilo_context { struct ilo_cp *cp; struct ilo_shader_cache *shader_cache; - struct ilo_3d *hw3d; struct ilo_blitter *blitter; + struct ilo_3d_pipeline *pipeline; struct u_upload_mgr *uploader; @@ -66,6 +67,11 @@ struct ilo_context { bool condition; unsigned mode; } render_condition; + + struct { + struct ilo_cp_owner cp_owner; + struct list_head queries; + } draw; }; static inline struct ilo_context * diff --git a/src/gallium/drivers/ilo/ilo_draw.c b/src/gallium/drivers/ilo/ilo_draw.c index 19ea6a7d080..3d2b128804e 100644 --- a/src/gallium/drivers/ilo/ilo_draw.c +++ b/src/gallium/drivers/ilo/ilo_draw.c @@ -38,13 +38,13 @@ #include "ilo_draw.h" static void -ilo_3d_own_render_ring(struct ilo_3d *hw3d) +ilo_draw_set_owner(struct ilo_context *ilo) { - ilo_cp_set_owner(hw3d->cp, INTEL_RING_RENDER, &hw3d->owner); + ilo_cp_set_owner(ilo->cp, INTEL_RING_RENDER, &ilo->draw.cp_owner); } static uint64_t -query_timestamp_to_ns(const struct ilo_3d *hw3d, uint64_t timestamp) +query_timestamp_to_ns(const struct ilo_context *ilo, uint64_t timestamp) { /* see ilo_get_timestamp() */ return (timestamp & 0xffffffff) * 80; @@ -54,7 +54,7 @@ query_timestamp_to_ns(const struct ilo_3d *hw3d, uint64_t timestamp) * Process the bo and accumulate the result. The bo is emptied. */ static void -query_process_bo(const struct ilo_3d *hw3d, struct ilo_query *q) +query_process_bo(const struct ilo_context *ilo, struct ilo_query *q) { const uint64_t *vals; uint64_t tmp; @@ -81,14 +81,14 @@ query_process_bo(const struct ilo_3d *hw3d, struct ilo_query *q) tmp += vals[2 * i + 1] - vals[2 * i]; if (q->type == PIPE_QUERY_TIME_ELAPSED) - tmp = query_timestamp_to_ns(hw3d, tmp); + tmp = query_timestamp_to_ns(ilo, tmp); q->result.u64 += tmp; break; case PIPE_QUERY_TIMESTAMP: assert(q->stride == sizeof(*vals)); - q->result.u64 = query_timestamp_to_ns(hw3d, vals[q->used - 1]); + q->result.u64 = query_timestamp_to_ns(ilo, vals[q->used - 1]); break; case PIPE_QUERY_PIPELINE_STATISTICS: assert(q->stride == sizeof(*vals) * 22); @@ -122,19 +122,19 @@ query_process_bo(const struct ilo_3d *hw3d, struct ilo_query *q) } static void -query_begin_bo(struct ilo_3d *hw3d, struct ilo_query *q) +query_begin_bo(struct ilo_context *ilo, struct ilo_query *q) { /* bo is full */ if (q->used >= q->count) - query_process_bo(hw3d, q); + query_process_bo(ilo, q); /* write the beginning value to the bo */ if (q->in_pairs) - ilo_3d_pipeline_emit_query(hw3d->pipeline, q, q->stride * q->used); + ilo_3d_pipeline_emit_query(ilo->pipeline, q, q->stride * q->used); } static void -query_end_bo(struct ilo_3d *hw3d, struct ilo_query *q) +query_end_bo(struct ilo_context *ilo, struct ilo_query *q) { uint32_t offset; @@ -147,13 +147,12 @@ query_end_bo(struct ilo_3d *hw3d, struct ilo_query *q) q->used++; /* write the ending value to the bo */ - ilo_3d_pipeline_emit_query(hw3d->pipeline, q, offset); + ilo_3d_pipeline_emit_query(ilo->pipeline, q, offset); } bool -ilo_3d_init_query(struct pipe_context *pipe, struct ilo_query *q) +ilo_init_draw_query(struct ilo_context *ilo, struct ilo_query *q) { - struct ilo_context *ilo = ilo_context(pipe); unsigned bo_size; switch (q->type) { @@ -177,7 +176,7 @@ ilo_3d_init_query(struct pipe_context *pipe, struct ilo_query *q) break; } - q->cmd_len = ilo_3d_pipeline_estimate_size(ilo->hw3d->pipeline, + q->cmd_len = ilo_3d_pipeline_estimate_size(ilo->pipeline, ILO_3D_PIPELINE_QUERY, q); /* double cmd_len and stride if in pairs */ @@ -195,44 +194,40 @@ ilo_3d_init_query(struct pipe_context *pipe, struct ilo_query *q) } void -ilo_3d_begin_query(struct pipe_context *pipe, struct ilo_query *q) +ilo_begin_draw_query(struct ilo_context *ilo, struct ilo_query *q) { - struct ilo_3d *hw3d = ilo_context(pipe)->hw3d; - - ilo_3d_own_render_ring(hw3d); + ilo_draw_set_owner(ilo); /* 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"); + if (!ilo_builder_validate(&ilo->cp->builder, 1, &q->bo) || + ilo_cp_space(ilo->cp) < q->cmd_len) { + ilo_cp_submit(ilo->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(&ilo->cp->builder, 1, &q->bo)); + assert(ilo_cp_space(ilo->cp) >= q->cmd_len); - ilo_3d_own_render_ring(hw3d); + ilo_draw_set_owner(ilo); } /* reserve the space for ending/pausing the query */ - hw3d->owner.reserve += q->cmd_len >> q->in_pairs; + ilo->draw.cp_owner.reserve += q->cmd_len >> q->in_pairs; - query_begin_bo(hw3d, q); + query_begin_bo(ilo, q); if (q->in_pairs) - list_add(&q->list, &hw3d->queries); + list_add(&q->list, &ilo->draw.queries); } void -ilo_3d_end_query(struct pipe_context *pipe, struct ilo_query *q) +ilo_end_draw_query(struct ilo_context *ilo, struct ilo_query *q) { - struct ilo_3d *hw3d = ilo_context(pipe)->hw3d; - - ilo_3d_own_render_ring(hw3d); + ilo_draw_set_owner(ilo); /* reclaim the reserved space */ - hw3d->owner.reserve -= q->cmd_len >> q->in_pairs; - assert(hw3d->owner.reserve >= 0); + ilo->draw.cp_owner.reserve -= q->cmd_len >> q->in_pairs; + assert(ilo->draw.cp_owner.reserve >= 0); - query_end_bo(hw3d, q); + query_end_bo(ilo, q); list_delinit(&q->list); } @@ -241,39 +236,37 @@ ilo_3d_end_query(struct pipe_context *pipe, struct ilo_query *q) * Process the raw query data. */ void -ilo_3d_process_query(struct pipe_context *pipe, struct ilo_query *q) +ilo_process_draw_query(struct ilo_context *ilo, struct ilo_query *q) { - struct ilo_3d *hw3d = ilo_context(pipe)->hw3d; - - query_process_bo(hw3d, q); + query_process_bo(ilo, q); } static void -ilo_3d_own_cp(struct ilo_cp *cp, void *data) +ilo_draw_own_cp(struct ilo_cp *cp, void *data) { - struct ilo_3d *hw3d = data; + struct ilo_context *ilo = data; /* multiply by 2 for both resuming and pausing */ - if (ilo_cp_space(hw3d->cp) < hw3d->owner.reserve * 2) { - ilo_cp_submit(hw3d->cp, "out of space"); - assert(ilo_cp_space(hw3d->cp) >= hw3d->owner.reserve * 2); + if (ilo_cp_space(ilo->cp) < ilo->draw.cp_owner.reserve * 2) { + ilo_cp_submit(ilo->cp, "out of space"); + assert(ilo_cp_space(ilo->cp) >= ilo->draw.cp_owner.reserve * 2); } while (true) { struct ilo_builder_snapshot snapshot; struct ilo_query *q; - ilo_builder_batch_snapshot(&hw3d->cp->builder, &snapshot); + ilo_builder_batch_snapshot(&ilo->cp->builder, &snapshot); /* resume queries */ - LIST_FOR_EACH_ENTRY(q, &hw3d->queries, list) - query_begin_bo(hw3d, q); + LIST_FOR_EACH_ENTRY(q, &ilo->draw.queries, list) + query_begin_bo(ilo, q); - if (!ilo_builder_validate(&hw3d->cp->builder, 0, NULL)) { - ilo_builder_batch_restore(&hw3d->cp->builder, &snapshot); + if (!ilo_builder_validate(&ilo->cp->builder, 0, NULL)) { + ilo_builder_batch_restore(&ilo->cp->builder, &snapshot); - if (ilo_builder_batch_used(&hw3d->cp->builder)) { - ilo_cp_submit(hw3d->cp, "out of aperture"); + if (ilo_builder_batch_used(&ilo->cp->builder)) { + ilo_cp_submit(ilo->cp, "out of aperture"); continue; } } @@ -281,96 +274,38 @@ ilo_3d_own_cp(struct ilo_cp *cp, void *data) break; } - assert(ilo_cp_space(hw3d->cp) >= hw3d->owner.reserve); + assert(ilo_cp_space(ilo->cp) >= ilo->draw.cp_owner.reserve); } static void -ilo_3d_release_cp(struct ilo_cp *cp, void *data) +ilo_draw_release_cp(struct ilo_cp *cp, void *data) { - struct ilo_3d *hw3d = data; + struct ilo_context *ilo = data; struct ilo_query *q; - assert(ilo_cp_space(hw3d->cp) >= hw3d->owner.reserve); + assert(ilo_cp_space(ilo->cp) >= ilo->draw.cp_owner.reserve); /* pause queries */ - LIST_FOR_EACH_ENTRY(q, &hw3d->queries, list) - query_end_bo(hw3d, q); -} - -/** - * Hook for CP new-batch. - */ -void -ilo_3d_cp_submitted(struct ilo_3d *hw3d) -{ - /* invalidate the pipeline */ - ilo_3d_pipeline_invalidate(hw3d->pipeline, - ILO_3D_PIPELINE_INVALIDATE_BATCH_BO | - ILO_3D_PIPELINE_INVALIDATE_STATE_BO | - ILO_3D_PIPELINE_INVALIDATE_KERNEL_BO); - - hw3d->new_batch = true; -} - -/** - * Create a 3D context. - */ -struct ilo_3d * -ilo_3d_create(struct ilo_cp *cp, const struct ilo_dev_info *dev) -{ - struct ilo_3d *hw3d; - - hw3d = CALLOC_STRUCT(ilo_3d); - if (!hw3d) - return NULL; - - hw3d->cp = cp; - hw3d->owner.own = ilo_3d_own_cp; - hw3d->owner.release = ilo_3d_release_cp; - hw3d->owner.data = hw3d; - hw3d->owner.reserve = 0; - - hw3d->new_batch = true; - - list_inithead(&hw3d->queries); - - hw3d->pipeline = ilo_3d_pipeline_create(&cp->builder); - if (!hw3d->pipeline) { - FREE(hw3d); - return NULL; - } - - return hw3d; -} - -/** - * Destroy a 3D context. - */ -void -ilo_3d_destroy(struct ilo_3d *hw3d) -{ - ilo_3d_pipeline_destroy(hw3d->pipeline); - FREE(hw3d); + LIST_FOR_EACH_ENTRY(q, &ilo->draw.queries, list) + query_end_bo(ilo, q); } static bool -draw_vbo(struct ilo_3d *hw3d, const struct ilo_state_vector *vec) +draw_vbo(struct ilo_context *ilo, const struct ilo_state_vector *vec) { bool need_flush = false; bool success = true; int max_len, before_space; /* on GEN7+, we need SOL_RESET to reset the SO write offsets */ - if (ilo_dev_gen(hw3d->pipeline->dev) >= ILO_GEN(7) && + if (ilo_dev_gen(ilo->dev) >= ILO_GEN(7) && (vec->dirty & ILO_DIRTY_SO) && vec->so.enabled && !vec->so.append_bitmask) { - ilo_cp_submit(hw3d->cp, "SOL_RESET"); - ilo_cp_set_one_off_flags(hw3d->cp, INTEL_EXEC_GEN7_SOL_RESET); + ilo_cp_submit(ilo->cp, "SOL_RESET"); + ilo_cp_set_one_off_flags(ilo->cp, INTEL_EXEC_GEN7_SOL_RESET); } - ilo_3d_own_render_ring(hw3d); - - if (!hw3d->new_batch) { + if (ilo_builder_batch_used(&ilo->cp->builder)) { /* * Without a better tracking mechanism, when the framebuffer changes, we * have to assume that the old framebuffer may be sampled from. If that @@ -383,39 +318,41 @@ draw_vbo(struct ilo_3d *hw3d, const struct ilo_state_vector *vec) need_flush |= (vec->dirty & ILO_DIRTY_SO); } + ilo_draw_set_owner(ilo); + /* make sure there is enough room first */ - max_len = ilo_3d_pipeline_estimate_size(hw3d->pipeline, + max_len = ilo_3d_pipeline_estimate_size(ilo->pipeline, ILO_3D_PIPELINE_DRAW, vec); if (need_flush) { - max_len += ilo_3d_pipeline_estimate_size(hw3d->pipeline, + max_len += ilo_3d_pipeline_estimate_size(ilo->pipeline, ILO_3D_PIPELINE_FLUSH, NULL); } - if (max_len > ilo_cp_space(hw3d->cp)) { - ilo_cp_submit(hw3d->cp, "out of space"); + if (max_len > ilo_cp_space(ilo->cp)) { + ilo_cp_submit(ilo->cp, "out of space"); need_flush = false; - assert(max_len <= ilo_cp_space(hw3d->cp)); + assert(max_len <= ilo_cp_space(ilo->cp)); } /* space available before emission */ - before_space = ilo_cp_space(hw3d->cp); + before_space = ilo_cp_space(ilo->cp); if (need_flush) - ilo_3d_pipeline_emit_flush(hw3d->pipeline); + ilo_3d_pipeline_emit_flush(ilo->pipeline); while (true) { struct ilo_builder_snapshot snapshot; - ilo_builder_batch_snapshot(&hw3d->cp->builder, &snapshot); + ilo_builder_batch_snapshot(&ilo->cp->builder, &snapshot); - ilo_3d_pipeline_emit_draw(hw3d->pipeline, vec); + ilo_3d_pipeline_emit_draw(ilo->pipeline, vec); - if (!ilo_builder_validate(&hw3d->cp->builder, 0, NULL)) { - ilo_builder_batch_restore(&hw3d->cp->builder, &snapshot); + if (!ilo_builder_validate(&ilo->cp->builder, 0, NULL)) { + ilo_builder_batch_restore(&ilo->cp->builder, &snapshot); /* flush and try again */ - if (ilo_builder_batch_used(&hw3d->cp->builder)) { - ilo_cp_submit(hw3d->cp, "out of aperture"); + if (ilo_builder_batch_used(&ilo->cp->builder)) { + ilo_cp_submit(ilo->cp, "out of aperture"); continue; } @@ -425,32 +362,36 @@ draw_vbo(struct ilo_3d *hw3d, const struct ilo_state_vector *vec) break; } - hw3d->pipeline->invalidate_flags = 0x0; + ilo->pipeline->invalidate_flags = 0x0; /* sanity check size estimation */ - assert(before_space - ilo_cp_space(hw3d->cp) <= max_len); + assert(before_space - ilo_cp_space(ilo->cp) <= max_len); return success; } void -ilo_3d_draw_rectlist(struct ilo_3d *hw3d, const struct ilo_blitter *blitter) +ilo_draw_rectlist(struct ilo_context *ilo) { int max_len, before_space; + bool need_flush; + + need_flush = ilo_builder_batch_used(&ilo->cp->builder); - ilo_3d_own_render_ring(hw3d); + ilo_draw_set_owner(ilo); - max_len = ilo_3d_pipeline_estimate_size(hw3d->pipeline, - ILO_3D_PIPELINE_RECTLIST, blitter); - max_len += ilo_3d_pipeline_estimate_size(hw3d->pipeline, + max_len = ilo_3d_pipeline_estimate_size(ilo->pipeline, + ILO_3D_PIPELINE_RECTLIST, ilo->blitter); + max_len += ilo_3d_pipeline_estimate_size(ilo->pipeline, ILO_3D_PIPELINE_FLUSH, NULL) * 2; - if (max_len > ilo_cp_space(hw3d->cp)) { - ilo_cp_submit(hw3d->cp, "out of space"); - assert(max_len <= ilo_cp_space(hw3d->cp)); + if (max_len > ilo_cp_space(ilo->cp)) { + ilo_cp_submit(ilo->cp, "out of space"); + need_flush = false; + assert(max_len <= ilo_cp_space(ilo->cp)); } - before_space = ilo_cp_space(hw3d->cp); + before_space = ilo_cp_space(ilo->cp); /* * From the Sandy Bridge PRM, volume 2 part 1, page 313: @@ -474,22 +415,22 @@ ilo_3d_draw_rectlist(struct ilo_3d *hw3d, const struct ilo_blitter *blitter) * * Skip checking blitter->op and do the flushes. */ - if (!hw3d->new_batch) - ilo_3d_pipeline_emit_flush(hw3d->pipeline); + if (need_flush) + ilo_3d_pipeline_emit_flush(ilo->pipeline); while (true) { struct ilo_builder_snapshot snapshot; - ilo_builder_batch_snapshot(&hw3d->cp->builder, &snapshot); + ilo_builder_batch_snapshot(&ilo->cp->builder, &snapshot); - ilo_3d_pipeline_emit_rectlist(hw3d->pipeline, blitter); + ilo_3d_pipeline_emit_rectlist(ilo->pipeline, ilo->blitter); - if (!ilo_builder_validate(&hw3d->cp->builder, 0, NULL)) { - ilo_builder_batch_restore(&hw3d->cp->builder, &snapshot); + if (!ilo_builder_validate(&ilo->cp->builder, 0, NULL)) { + ilo_builder_batch_restore(&ilo->cp->builder, &snapshot); /* flush and try again */ - if (ilo_builder_batch_used(&hw3d->cp->builder)) { - ilo_cp_submit(hw3d->cp, "out of aperture"); + if (ilo_builder_batch_used(&ilo->cp->builder)) { + ilo_cp_submit(ilo->cp, "out of aperture"); continue; } } @@ -497,14 +438,12 @@ ilo_3d_draw_rectlist(struct ilo_3d *hw3d, const struct ilo_blitter *blitter) break; } - ilo_3d_pipeline_invalidate(hw3d->pipeline, ILO_3D_PIPELINE_INVALIDATE_HW); + ilo_3d_pipeline_invalidate(ilo->pipeline, ILO_3D_PIPELINE_INVALIDATE_HW); - ilo_3d_pipeline_emit_flush(hw3d->pipeline); + ilo_3d_pipeline_emit_flush(ilo->pipeline); /* sanity check size estimation */ - assert(before_space - ilo_cp_space(hw3d->cp) <= max_len); - - hw3d->new_batch = false; + assert(before_space - ilo_cp_space(ilo->cp) <= max_len); } static void @@ -612,7 +551,6 @@ static void 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; if (ilo_debug & ILO_DEBUG_DRAW) { if (info->indexed) { @@ -640,39 +578,37 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) ilo_finalize_3d_states(ilo, info); - ilo_shader_cache_upload(ilo->shader_cache, &hw3d->cp->builder); + ilo_shader_cache_upload(ilo->shader_cache, &ilo->cp->builder); ilo_blit_resolve_framebuffer(ilo); /* If draw_vbo ever fails, return immediately. */ - if (!draw_vbo(hw3d, &ilo->state_vector)) + if (!draw_vbo(ilo, &ilo->state_vector)) return; /* clear dirty status */ ilo->state_vector.dirty = 0x0; - hw3d->new_batch = false; /* avoid dangling pointer reference */ ilo->state_vector.draw = NULL; if (ilo_debug & ILO_DEBUG_NOCACHE) - ilo_3d_pipeline_emit_flush(hw3d->pipeline); + ilo_3d_pipeline_emit_flush(ilo->pipeline); } static void ilo_texture_barrier(struct pipe_context *pipe) { struct ilo_context *ilo = ilo_context(pipe); - struct ilo_3d *hw3d = ilo->hw3d; if (ilo->cp->ring != INTEL_RING_RENDER) return; - ilo_3d_pipeline_emit_flush(hw3d->pipeline); + ilo_3d_pipeline_emit_flush(ilo->pipeline); /* don't know why */ if (ilo_dev_gen(ilo->dev) >= ILO_GEN(7)) - ilo_cp_submit(hw3d->cp, "texture barrier"); + ilo_cp_submit(ilo->cp, "texture barrier"); } static void @@ -682,18 +618,28 @@ ilo_get_sample_position(struct pipe_context *pipe, float *out_value) { struct ilo_context *ilo = ilo_context(pipe); - struct ilo_3d *hw3d = ilo->hw3d; - ilo_3d_pipeline_get_sample_position(hw3d->pipeline, + ilo_3d_pipeline_get_sample_position(ilo->pipeline, sample_count, sample_index, &out_value[0], &out_value[1]); } +void +ilo_init_draw(struct ilo_context *ilo) +{ + ilo->draw.cp_owner.own = ilo_draw_own_cp; + ilo->draw.cp_owner.release = ilo_draw_release_cp; + ilo->draw.cp_owner.data = (void *) ilo; + ilo->draw.cp_owner.reserve = 0; + + list_inithead(&ilo->draw.queries); +} + /** * Initialize 3D-related functions. */ void -ilo_init_3d_functions(struct ilo_context *ilo) +ilo_init_draw_functions(struct ilo_context *ilo) { ilo->base.draw_vbo = ilo_draw_vbo; ilo->base.texture_barrier = ilo_texture_barrier; diff --git a/src/gallium/drivers/ilo/ilo_draw.h b/src/gallium/drivers/ilo/ilo_draw.h index 2f68c5ea091..1c5388746ee 100644 --- a/src/gallium/drivers/ilo/ilo_draw.h +++ b/src/gallium/drivers/ilo/ilo_draw.h @@ -29,52 +29,29 @@ #define ILO_DRAW_H #include "ilo_common.h" -#include "ilo_cp.h" -struct ilo_3d_pipeline; -struct ilo_blitter; struct ilo_context; struct ilo_query; -/** - * 3D context. - */ -struct ilo_3d { - struct ilo_cp *cp; - struct ilo_cp_owner owner; - - bool new_batch; - - struct list_head queries; - - struct ilo_3d_pipeline *pipeline; -}; - -struct ilo_3d * -ilo_3d_create(struct ilo_cp *cp, const struct ilo_dev_info *dev); - -void -ilo_3d_destroy(struct ilo_3d *hw3d); - void -ilo_3d_cp_submitted(struct ilo_3d *hw3d); +ilo_init_draw_functions(struct ilo_context *ilo); void -ilo_3d_draw_rectlist(struct ilo_3d *hw3d, const struct ilo_blitter *blitter); +ilo_init_draw(struct ilo_context *ilo); bool -ilo_3d_init_query(struct pipe_context *pipe, struct ilo_query *q); +ilo_init_draw_query(struct ilo_context *ilo, struct ilo_query *q); void -ilo_3d_begin_query(struct pipe_context *pipe, struct ilo_query *q); +ilo_begin_draw_query(struct ilo_context *ilo, struct ilo_query *q); void -ilo_3d_end_query(struct pipe_context *pipe, struct ilo_query *q); +ilo_end_draw_query(struct ilo_context *ilo, struct ilo_query *q); void -ilo_3d_process_query(struct pipe_context *pipe, struct ilo_query *q); +ilo_process_draw_query(struct ilo_context *ilo, struct ilo_query *q); void -ilo_init_3d_functions(struct ilo_context *ilo); +ilo_draw_rectlist(struct ilo_context *ilo); #endif /* ILO_DRAW_H */ diff --git a/src/gallium/drivers/ilo/ilo_query.c b/src/gallium/drivers/ilo/ilo_query.c index 8ab333e43c6..942df2d683d 100644 --- a/src/gallium/drivers/ilo/ilo_query.c +++ b/src/gallium/drivers/ilo/ilo_query.c @@ -33,30 +33,30 @@ #include "ilo_query.h" static const struct { - bool (*init)(struct pipe_context *pipe, struct ilo_query *q); - void (*begin)(struct pipe_context *pipe, struct ilo_query *q); - void (*end)(struct pipe_context *pipe, struct ilo_query *q); - void (*process)(struct pipe_context *pipe, struct ilo_query *q); + bool (*init)(struct ilo_context *ilo, struct ilo_query *q); + void (*begin)(struct ilo_context *ilo, struct ilo_query *q); + void (*end)(struct ilo_context *ilo, struct ilo_query *q); + void (*process)(struct ilo_context *ilo, struct ilo_query *q); } ilo_query_table[PIPE_QUERY_TYPES] = { -#define INFO(prefix) { \ - .init = prefix ## _init_query, \ - .begin = prefix ## _begin_query, \ - .end = prefix ## _end_query, \ - .process = prefix ## _process_query, \ +#define INFO(mod) { \ + .init = ilo_init_ ## mod ## _query, \ + .begin = ilo_begin_ ## mod ## _query, \ + .end = ilo_end_ ## mod ## _query, \ + .process = ilo_process_ ## mod ## _query, \ } #define INFOX(prefix) { NULL, NULL, NULL, NULL, } - [PIPE_QUERY_OCCLUSION_COUNTER] = INFO(ilo_3d), - [PIPE_QUERY_OCCLUSION_PREDICATE] = INFOX(ilo_3d), - [PIPE_QUERY_TIMESTAMP] = INFO(ilo_3d), - [PIPE_QUERY_TIMESTAMP_DISJOINT] = INFOX(ilo_3d), - [PIPE_QUERY_TIME_ELAPSED] = INFO(ilo_3d), - [PIPE_QUERY_PRIMITIVES_GENERATED] = INFO(ilo_3d), - [PIPE_QUERY_PRIMITIVES_EMITTED] = INFO(ilo_3d), - [PIPE_QUERY_SO_STATISTICS] = INFOX(ilo_3d), - [PIPE_QUERY_SO_OVERFLOW_PREDICATE] = INFOX(ilo_3d), - [PIPE_QUERY_GPU_FINISHED] = INFOX(ilo_3d), - [PIPE_QUERY_PIPELINE_STATISTICS] = INFO(ilo_3d), + [PIPE_QUERY_OCCLUSION_COUNTER] = INFO(draw), + [PIPE_QUERY_OCCLUSION_PREDICATE] = INFOX(draw), + [PIPE_QUERY_TIMESTAMP] = INFO(draw), + [PIPE_QUERY_TIMESTAMP_DISJOINT] = INFOX(draw), + [PIPE_QUERY_TIME_ELAPSED] = INFO(draw), + [PIPE_QUERY_PRIMITIVES_GENERATED] = INFO(draw), + [PIPE_QUERY_PRIMITIVES_EMITTED] = INFO(draw), + [PIPE_QUERY_SO_STATISTICS] = INFOX(draw), + [PIPE_QUERY_SO_OVERFLOW_PREDICATE] = INFOX(draw), + [PIPE_QUERY_GPU_FINISHED] = INFOX(draw), + [PIPE_QUERY_PIPELINE_STATISTICS] = INFO(draw), #undef INFO #undef INFOX @@ -94,7 +94,7 @@ ilo_create_query(struct pipe_context *pipe, unsigned query_type, unsigned index) list_inithead(&q->list); - if (!ilo_query_table[q->type].init(pipe, q)) { + if (!ilo_query_table[q->type].init(ilo_context(pipe), q)) { FREE(q); return NULL; } @@ -125,7 +125,7 @@ ilo_begin_query(struct pipe_context *pipe, struct pipe_query *query) q->used = 0; q->active = true; - ilo_query_table[q->type].begin(pipe, q); + ilo_query_table[q->type].begin(ilo_context(pipe), q); } static void @@ -143,7 +143,7 @@ ilo_end_query(struct pipe_context *pipe, struct pipe_query *query) q->active = false; - ilo_query_table[q->type].end(pipe, q); + ilo_query_table[q->type].end(ilo_context(pipe), q); } /** @@ -208,7 +208,7 @@ ilo_get_query_result(struct pipe_context *pipe, struct pipe_query *query, return false; } - ilo_query_table[q->type].process(pipe, q); + ilo_query_table[q->type].process(ilo_context(pipe), q); if (result) query_serialize(q, (void *) result); |