ilo: move aperture checks out of pipeline

They can be done outside of the pipeline.  Move them and let the pipeline
focus on building commands.
This commit is contained in:
Chia-I Wu 2014-09-22 10:46:15 +08:00
parent 672592de7e
commit 61c6a294dd
3 changed files with 69 additions and 72 deletions

View File

@ -357,7 +357,7 @@ static bool
draw_vbo(struct ilo_3d *hw3d, const struct ilo_state_vector *vec)
{
bool need_flush = false;
bool success;
bool success = true;
int max_len, before_space;
/* on GEN7+, we need SOL_RESET to reset the SO write offsets */
@ -402,7 +402,30 @@ draw_vbo(struct ilo_3d *hw3d, const struct ilo_state_vector *vec)
if (need_flush)
ilo_3d_pipeline_emit_flush(hw3d->pipeline);
success = ilo_3d_pipeline_emit_draw(hw3d->pipeline, vec);
while (true) {
struct ilo_builder_snapshot snapshot;
ilo_builder_batch_snapshot(&hw3d->cp->builder, &snapshot);
ilo_3d_pipeline_emit_draw(hw3d->pipeline, vec);
if (!ilo_builder_validate(&hw3d->cp->builder, 0, NULL)) {
ilo_builder_batch_restore(&hw3d->cp->builder, &snapshot);
/* flush and try again */
if (ilo_builder_batch_used(&hw3d->cp->builder)) {
ilo_cp_submit(hw3d->cp, "out of aperture");
continue;
}
success = false;
}
break;
}
hw3d->pipeline->invalidate_flags = 0x0;
/* sanity check size estimation */
assert(before_space - ilo_cp_space(hw3d->cp) <= max_len);
@ -442,8 +465,22 @@ ilo_3d_pass_render_condition(struct ilo_context *ilo)
void
ilo_3d_draw_rectlist(struct ilo_3d *hw3d, const struct ilo_blitter *blitter)
{
int max_len, before_space;
ilo_3d_own_render_ring(hw3d);
max_len = ilo_3d_pipeline_estimate_size(hw3d->pipeline,
ILO_3D_PIPELINE_RECTLIST, blitter);
max_len += ilo_3d_pipeline_estimate_size(hw3d->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));
}
before_space = ilo_cp_space(hw3d->cp);
/*
* From the Sandy Bridge PRM, volume 2 part 1, page 313:
*
@ -465,16 +502,37 @@ ilo_3d_draw_rectlist(struct ilo_3d *hw3d, const struct ilo_blitter *blitter)
* - we may sample from the fb shortly after
*
* Skip checking blitter->op and do the flushes.
*
* XXX need space check
*/
if (!hw3d->new_batch)
ilo_3d_pipeline_emit_flush(hw3d->pipeline);
ilo_3d_pipeline_emit_rectlist(hw3d->pipeline, blitter);
while (true) {
struct ilo_builder_snapshot snapshot;
ilo_builder_batch_snapshot(&hw3d->cp->builder, &snapshot);
ilo_3d_pipeline_emit_rectlist(hw3d->pipeline, blitter);
if (!ilo_builder_validate(&hw3d->cp->builder, 0, NULL)) {
ilo_builder_batch_restore(&hw3d->cp->builder, &snapshot);
/* flush and try again */
if (ilo_builder_batch_used(&hw3d->cp->builder)) {
ilo_cp_submit(hw3d->cp, "out of aperture");
continue;
}
}
break;
}
ilo_3d_pipeline_invalidate(hw3d->pipeline, ILO_3D_PIPELINE_INVALIDATE_HW);
ilo_3d_pipeline_emit_flush(hw3d->pipeline);
/* sanity check size estimation */
assert(before_space - ilo_cp_space(hw3d->cp) <= max_len);
hw3d->new_batch = false;
}

View File

@ -148,44 +148,12 @@ handle_invalid_batch_bo(struct ilo_3d_pipeline *p, bool unset)
/**
* Emit context states and 3DPRIMITIVE.
*/
bool
void
ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
const struct ilo_state_vector *vec)
{
bool success;
while (true) {
struct ilo_builder_snapshot snapshot;
/* we will rewind if aperture check below fails */
ilo_builder_batch_snapshot(&p->cp->builder, &snapshot);
handle_invalid_batch_bo(p, false);
/* draw! */
p->emit_draw(p, vec);
if (ilo_builder_validate(&p->cp->builder, 0, NULL)) {
success = true;
} else {
/* rewind */
ilo_builder_batch_restore(&p->cp->builder, &snapshot);
/* flush and try again */
if (ilo_builder_batch_used(&p->cp->builder)) {
ilo_cp_submit(p->cp, "out of aperture");
continue;
}
success = false;
}
break;
}
p->invalidate_flags = 0x0;
return success;
handle_invalid_batch_bo(p, false);
p->emit_draw(p, vec);
}
/**
@ -213,37 +181,8 @@ void
ilo_3d_pipeline_emit_rectlist(struct ilo_3d_pipeline *p,
const struct ilo_blitter *blitter)
{
const int max_len = ilo_3d_pipeline_estimate_size(p,
ILO_3D_PIPELINE_RECTLIST, blitter);
if (max_len > ilo_cp_space(p->cp))
ilo_cp_submit(p->cp, "out of space");
while (true) {
struct ilo_builder_snapshot snapshot;
/* we will rewind if aperture check below fails */
ilo_builder_batch_snapshot(&p->cp->builder, &snapshot);
handle_invalid_batch_bo(p, false);
p->emit_rectlist(p, blitter);
if (!ilo_builder_validate(&p->cp->builder, 0, NULL)) {
/* rewind */
ilo_builder_batch_restore(&p->cp->builder, &snapshot);
/* flush and try again */
if (ilo_builder_batch_used(&p->cp->builder)) {
ilo_cp_submit(p->cp, "out of aperture");
continue;
}
}
break;
}
ilo_3d_pipeline_invalidate(p, ILO_3D_PIPELINE_INVALIDATE_HW);
handle_invalid_batch_bo(p, false);
p->emit_rectlist(p, blitter);
}
void

View File

@ -159,7 +159,7 @@ ilo_3d_pipeline_estimate_size(struct ilo_3d_pipeline *pipeline,
return pipeline->estimate_size(pipeline, action, arg);
}
bool
void
ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
const struct ilo_state_vector *vec);