summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-14 18:28:24 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-14 22:07:57 +0000
commit5d5da35c9fab4e7154921861ecbb83befb8840e5 (patch)
tree8542a8bdb7b84329f214a6c0998a760581d51814
parentf7e4799687d5010ea0b56aeb6fbbb2e854b1b363 (diff)
sna/gen[23]: Check for room in the batch before emitting pipeline flushes
Use a single idiom and reuse the check built into the state emission, for both spans/boxes paths. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/gen2_render.c39
-rw-r--r--src/sna/gen3_render.c19
2 files changed, 21 insertions, 37 deletions
diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c
index 2513307e..b448145e 100644
--- a/src/sna/gen2_render.c
+++ b/src/sna/gen2_render.c
@@ -492,14 +492,6 @@ static void gen2_emit_invariant(struct sna *sna)
sna->render_state.gen2.need_invariant = FALSE;
}
-static bool
-gen2_check_batch(struct sna *sna)
-{
- return (kgem_check_batch(&sna->kgem, 30+40) &&
- kgem_check_reloc(&sna->kgem, 3) &&
- kgem_check_exec(&sna->kgem, 3));
-}
-
static void
gen2_get_batch(struct sna *sna)
{
@@ -1780,19 +1772,18 @@ gen2_render_composite(struct sna *sna,
NULL))
kgem_submit(&sna->kgem);
+ gen2_emit_composite_state(sna, tmp);
if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) {
if (tmp->src.bo == tmp->dst.bo || tmp->mask.bo == tmp->dst.bo) {
kgem_emit_flush(&sna->kgem);
- } else if (gen2_check_batch(sna)) {
+ } else {
BATCH(_3DSTATE_MODES_5_CMD |
PIPELINE_FLUSH_RENDER_CACHE |
PIPELINE_FLUSH_TEXTURE_CACHE);
kgem_clear_dirty(&sna->kgem);
- } else
- kgem_submit(&sna->kgem);
+ }
+ assert(sna->kgem.mode == KGEM_RENDER);
}
-
- gen2_emit_composite_state(sna, tmp);
return TRUE;
cleanup_src:
@@ -2190,17 +2181,6 @@ gen2_render_composite_spans(struct sna *sna,
tmp->prim_emit = gen2_emit_composite_spans_primitive_identity_source;
else if (tmp->base.src.is_affine)
tmp->prim_emit = gen2_emit_composite_spans_primitive_affine_source;
-
- if (kgem_bo_is_dirty(tmp->base.src.bo)) {
- if (tmp->base.src.bo == tmp->base.dst.bo) {
- kgem_emit_flush(&sna->kgem);
- } else {
- BATCH(_3DSTATE_MODES_5_CMD |
- PIPELINE_FLUSH_RENDER_CACHE |
- PIPELINE_FLUSH_TEXTURE_CACHE);
- kgem_clear_dirty(&sna->kgem);
- }
- }
}
tmp->base.floats_per_rect = 3*tmp->base.floats_per_vertex;
@@ -2214,6 +2194,17 @@ gen2_render_composite_spans(struct sna *sna,
kgem_submit(&sna->kgem);
gen2_emit_composite_spans_state(sna, tmp);
+ if (kgem_bo_is_dirty(tmp->base.src.bo)) {
+ if (tmp->base.src.bo == tmp->base.dst.bo) {
+ kgem_emit_flush(&sna->kgem);
+ } else {
+ BATCH(_3DSTATE_MODES_5_CMD |
+ PIPELINE_FLUSH_RENDER_CACHE |
+ PIPELINE_FLUSH_TEXTURE_CACHE);
+ kgem_clear_dirty(&sna->kgem);
+ }
+ assert(sna->kgem.mode == KGEM_RENDER);
+ }
return TRUE;
cleanup_dst:
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index 8b7dbbdc..a3db4bb1 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -1200,14 +1200,6 @@ static void gen3_emit_invariant(struct sna *sna)
#define MAX_OBJECTS 3 /* worst case: dst + src + mask */
-static bool
-gen3_check_batch(struct sna *sna)
-{
- return (kgem_check_batch(&sna->kgem, 200) &&
- kgem_check_reloc(&sna->kgem, MAX_OBJECTS) &&
- kgem_check_exec(&sna->kgem, MAX_OBJECTS));
-}
-
static void
gen3_get_batch(struct sna *sna)
{
@@ -2752,19 +2744,19 @@ gen3_render_composite(struct sna *sna,
NULL))
kgem_submit(&sna->kgem);
+ gen3_emit_composite_state(sna, tmp);
if (kgem_bo_is_dirty(tmp->src.bo) || kgem_bo_is_dirty(tmp->mask.bo)) {
if (tmp->src.bo == tmp->dst.bo || tmp->mask.bo == tmp->dst.bo) {
kgem_emit_flush(&sna->kgem);
- } else if (gen3_check_batch(sna)) {
+ } else {
OUT_BATCH(_3DSTATE_MODES_5_CMD |
PIPELINE_FLUSH_RENDER_CACHE |
PIPELINE_FLUSH_TEXTURE_CACHE);
kgem_clear_dirty(&sna->kgem);
- } else
- kgem_submit(&sna->kgem);
+ }
+ assert(sna->kgem.mode == KGEM_RENDER);
}
- gen3_emit_composite_state(sna, tmp);
gen3_align_vertex(sna, tmp);
return TRUE;
@@ -3193,6 +3185,7 @@ gen3_render_composite_spans(struct sna *sna,
NULL))
kgem_submit(&sna->kgem);
+ gen3_emit_composite_state(sna, &tmp->base);
if (kgem_bo_is_dirty(tmp->base.src.bo)) {
if (tmp->base.src.bo == tmp->base.dst.bo) {
kgem_emit_flush(&sna->kgem);
@@ -3202,9 +3195,9 @@ gen3_render_composite_spans(struct sna *sna,
PIPELINE_FLUSH_TEXTURE_CACHE);
kgem_clear_dirty(&sna->kgem);
}
+ assert(sna->kgem.mode == KGEM_RENDER);
}
- gen3_emit_composite_state(sna, &tmp->base);
gen3_align_vertex(sna, &tmp->base);
return TRUE;