summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-01-24 11:29:26 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2014-01-24 11:32:43 +0000
commit4385724dc49dd090e0a5956e287f80b92ebd70e8 (patch)
tree7f0ec16e51d18acf2a2682808080f2ae108f327e
parentc9e9c85fc7b21e231c2532fe1c75b92307e112ed (diff)
sna/gen2+: Inspect composite flags to discard unneeded CPU damage
We can now check whether the Composite operation will require existing CPU damage and if not discard it. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/gen2_render.c54
-rw-r--r--src/sna/gen3_render.c43
-rw-r--r--src/sna/gen4_render.c14
-rw-r--r--src/sna/gen5_render.c14
-rw-r--r--src/sna/gen6_render.c14
-rw-r--r--src/sna/gen7_render.c14
-rw-r--r--src/sna/gen8_render.c14
7 files changed, 97 insertions, 70 deletions
diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c
index 0cb72074..da7049c1 100644
--- a/src/sna/gen2_render.c
+++ b/src/sna/gen2_render.c
@@ -1570,9 +1570,11 @@ static bool
gen2_composite_set_target(struct sna *sna,
struct sna_composite_op *op,
PicturePtr dst,
- int x, int y, int w, int h)
+ int x, int y, int w, int h,
+ bool partial)
{
BoxRec box;
+ unsigned hint;
op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
op->dst.format = dst->format;
@@ -1587,9 +1589,14 @@ gen2_composite_set_target(struct sna *sna,
} else
sna_render_picture_extents(dst, &box);
- op->dst.bo = sna_drawable_use_bo (dst->pDrawable,
- PREFER_GPU | FORCE_GPU | RENDER_GPU,
- &box, &op->damage);
+ hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+ if (!partial) {
+ hint |= IGNORE_CPU;
+ if (w == op->dst.width && h == op->dst.height)
+ hint |= REPLACES;
+ }
+
+ op->dst.bo = sna_drawable_use_bo(dst->pDrawable, hint, &box, &op->damage);
if (op->dst.bo == NULL)
return false;
@@ -1607,6 +1614,12 @@ gen2_composite_set_target(struct sna *sna,
op->damage ? *op->damage : (void *)-1));
assert(op->dst.bo->proxy == NULL);
+
+ if (((too_large(op->dst.width, op->dst.height) ||
+ op->dst.bo->pitch > MAX_3D_PITCH)) &&
+ !sna_render_composite_redirect(sna, op, x, y, w, h, partial))
+ return false;
+
return true;
}
@@ -1856,24 +1869,17 @@ gen2_render_composite(struct sna *sna,
width, height,
tmp);
+ tmp->op = op;
+ sna_render_composite_redirect_init(tmp);
+
if (!gen2_composite_set_target(sna, tmp, dst,
- dst_x, dst_y, width, height)) {
+ dst_x, dst_y, width, height,
+ flags & COMPOSITE_PARTIAL || op > PictOpSrc || dst->pCompositeClip->data != NULL)) {
DBG(("%s: unable to set render target\n",
__FUNCTION__));
goto fallback;
}
- tmp->op = op;
-
- sna_render_composite_redirect_init(tmp);
- if (too_large(tmp->dst.width, tmp->dst.height) ||
- tmp->dst.bo->pitch > MAX_3D_PITCH) {
- if (!sna_render_composite_redirect(sna, tmp,
- dst_x, dst_y, width, height,
- op > PictOpSrc || dst->pCompositeClip->data != NULL))
- goto fallback;
- }
-
switch (gen2_composite_picture(sna, src, &tmp->src,
src_x, src_y,
width, height,
@@ -2531,24 +2537,16 @@ gen2_render_composite_spans(struct sna *sna,
width, height, flags, tmp);
}
+ tmp->base.op = op;
+ sna_render_composite_redirect_init(&tmp->base);
if (!gen2_composite_set_target(sna, &tmp->base, dst,
- dst_x, dst_y, width, height)) {
+ dst_x, dst_y, width, height,
+ true)) {
DBG(("%s: unable to set render target\n",
__FUNCTION__));
return false;
}
- tmp->base.op = op;
-
- sna_render_composite_redirect_init(&tmp->base);
- if (too_large(tmp->base.dst.width, tmp->base.dst.height) ||
- tmp->base.dst.bo->pitch > MAX_3D_PITCH) {
- if (!sna_render_composite_redirect(sna, &tmp->base,
- dst_x, dst_y, width, height,
- true))
- return false;
- }
-
switch (gen2_composite_picture(sna, src, &tmp->base.src,
src_x, src_y,
width, height,
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index 0079bada..941b633f 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -3151,9 +3151,11 @@ static bool
gen3_composite_set_target(struct sna *sna,
struct sna_composite_op *op,
PicturePtr dst,
- int x, int y, int w, int h)
+ int x, int y, int w, int h,
+ bool partial)
{
BoxRec box;
+ unsigned hint;
op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
op->dst.format = dst->format;
@@ -3168,9 +3170,14 @@ gen3_composite_set_target(struct sna *sna,
} else
sna_render_picture_extents(dst, &box);
- op->dst.bo = sna_drawable_use_bo(dst->pDrawable,
- PREFER_GPU | FORCE_GPU | RENDER_GPU,
- &box, &op->damage);
+ hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+ if (!partial) {
+ hint |= IGNORE_CPU;
+ if (w == op->dst.width && h == op->dst.height)
+ hint |= REPLACES;
+ }
+
+ op->dst.bo = sna_drawable_use_bo(dst->pDrawable, hint, &box, &op->damage);
if (op->dst.bo == NULL)
return false;
@@ -3196,6 +3203,12 @@ gen3_composite_set_target(struct sna *sna,
op->damage ? *op->damage : (void *)-1));
assert(op->dst.bo->proxy == NULL);
+
+ if ((too_large(op->dst.width, op->dst.height) ||
+ !gen3_check_pitch_3d(op->dst.bo)) &&
+ !sna_render_composite_redirect(sna, op, x, y, w, h, partial))
+ return false;
+
return true;
}
@@ -3489,7 +3502,8 @@ gen3_render_composite(struct sna *sna,
tmp);
if (!gen3_composite_set_target(sna, tmp, dst,
- dst_x, dst_y, width, height)) {
+ dst_x, dst_y, width, height,
+ flags & COMPOSITE_PARTIAL || op > PictOpSrc || dst->pCompositeClip->data)) {
DBG(("%s: unable to set render target\n",
__FUNCTION__));
goto fallback;
@@ -3497,14 +3511,6 @@ gen3_render_composite(struct sna *sna,
tmp->op = op;
tmp->rb_reversed = gen3_dst_rb_reversed(tmp->dst.format);
- if (too_large(tmp->dst.width, tmp->dst.height) ||
- !gen3_check_pitch_3d(tmp->dst.bo)) {
- if (!sna_render_composite_redirect(sna, tmp,
- dst_x, dst_y, width, height,
- op > PictOpSrc || dst->pCompositeClip->data))
- goto fallback;
- }
-
tmp->u.gen3.num_constants = 0;
tmp->src.u.gen3.type = SHADER_TEXTURE;
tmp->src.is_affine = true;
@@ -4848,7 +4854,8 @@ gen3_render_composite_spans(struct sna *sna,
}
if (!gen3_composite_set_target(sna, &tmp->base, dst,
- dst_x, dst_y, width, height)) {
+ dst_x, dst_y, width, height,
+ true)) {
DBG(("%s: unable to set render target\n",
__FUNCTION__));
return false;
@@ -4856,14 +4863,6 @@ gen3_render_composite_spans(struct sna *sna,
tmp->base.op = op;
tmp->base.rb_reversed = gen3_dst_rb_reversed(tmp->base.dst.format);
- if (too_large(tmp->base.dst.width, tmp->base.dst.height) ||
- !gen3_check_pitch_3d(tmp->base.dst.bo)) {
- if (!sna_render_composite_redirect(sna, &tmp->base,
- dst_x, dst_y, width, height,
- true))
- return false;
- }
-
tmp->base.src.u.gen3.type = SHADER_TEXTURE;
tmp->base.src.is_affine = true;
DBG(("%s: preparing source\n", __FUNCTION__));
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 1a559f06..4f4a4c80 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -1635,6 +1635,7 @@ gen4_composite_set_target(struct sna *sna,
bool partial)
{
BoxRec box;
+ unsigned hint;
op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
op->dst.width = op->dst.pixmap->drawable.width;
@@ -1648,9 +1649,14 @@ gen4_composite_set_target(struct sna *sna,
} else
sna_render_picture_extents(dst, &box);
- op->dst.bo = sna_drawable_use_bo (dst->pDrawable,
- PREFER_GPU | FORCE_GPU | RENDER_GPU,
- &box, &op->damage);
+ hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+ if (!partial) {
+ hint |= IGNORE_CPU;
+ if (w == op->dst.width && h == op->dst.height)
+ hint |= REPLACES;
+ }
+
+ op->dst.bo = sna_drawable_use_bo(dst->pDrawable, hint, &box, &op->damage);
if (op->dst.bo == NULL)
return false;
@@ -1924,7 +1930,7 @@ gen4_render_composite(struct sna *sna,
if (!gen4_composite_set_target(sna, tmp, dst,
dst_x, dst_y, width, height,
- op > PictOpSrc || dst->pCompositeClip->data)) {
+ flags & COMPOSITE_PARTIAL || op > PictOpSrc || dst->pCompositeClip->data)) {
DBG(("%s: failed to set composite target\n", __FUNCTION__));
goto fallback;
}
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 23b0c147..3396acd0 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -1571,6 +1571,7 @@ gen5_composite_set_target(struct sna *sna,
bool partial)
{
BoxRec box;
+ unsigned hint;
op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
op->dst.width = op->dst.pixmap->drawable.width;
@@ -1584,9 +1585,14 @@ gen5_composite_set_target(struct sna *sna,
} else
sna_render_picture_extents(dst, &box);
- op->dst.bo = sna_drawable_use_bo (dst->pDrawable,
- PREFER_GPU | FORCE_GPU | RENDER_GPU,
- &box, &op->damage);
+ hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+ if (!partial) {
+ hint |= IGNORE_CPU;
+ if (w == op->dst.width && h == op->dst.height)
+ hint |= REPLACES;
+ }
+
+ op->dst.bo = sna_drawable_use_bo(dst->pDrawable, hint, &box, &op->damage);
if (op->dst.bo == NULL)
return false;
@@ -1863,7 +1869,7 @@ gen5_render_composite(struct sna *sna,
if (!gen5_composite_set_target(sna, tmp, dst,
dst_x, dst_y, width, height,
- op > PictOpSrc || dst->pCompositeClip->data)) {
+ flags & COMPOSITE_PARTIAL || op > PictOpSrc || dst->pCompositeClip->data)) {
DBG(("%s: failed to set composite target\n", __FUNCTION__));
goto fallback;
}
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index d0e202f6..a117bf80 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -1828,6 +1828,7 @@ gen6_composite_set_target(struct sna *sna,
bool partial)
{
BoxRec box;
+ unsigned int hint;
op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
op->dst.format = dst->format;
@@ -1842,9 +1843,14 @@ gen6_composite_set_target(struct sna *sna,
} else
sna_render_picture_extents(dst, &box);
- op->dst.bo = sna_drawable_use_bo(dst->pDrawable,
- PREFER_GPU | FORCE_GPU | RENDER_GPU,
- &box, &op->damage);
+ hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+ if (!partial) {
+ hint |= IGNORE_CPU;
+ if (w == op->dst.width && h == op->dst.height)
+ hint |= REPLACES;
+ }
+
+ op->dst.bo = sna_drawable_use_bo(dst->pDrawable, hint, &box, &op->damage);
if (op->dst.bo == NULL)
return false;
@@ -2159,7 +2165,7 @@ gen6_render_composite(struct sna *sna,
tmp->op = op;
if (!gen6_composite_set_target(sna, tmp, dst,
dst_x, dst_y, width, height,
- op > PictOpSrc || dst->pCompositeClip->data))
+ flags & COMPOSITE_PARTIAL || op > PictOpSrc || dst->pCompositeClip->data))
goto fallback;
switch (gen6_composite_picture(sna, src, &tmp->src,
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index 1ea7392c..eec6d650 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -2108,6 +2108,7 @@ gen7_composite_set_target(struct sna *sna,
bool partial)
{
BoxRec box;
+ unsigned int hint;
op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
op->dst.format = dst->format;
@@ -2123,9 +2124,14 @@ gen7_composite_set_target(struct sna *sna,
} else
sna_render_picture_extents(dst, &box);
- op->dst.bo = sna_drawable_use_bo(dst->pDrawable,
- PREFER_GPU | FORCE_GPU | RENDER_GPU,
- &box, &op->damage);
+ hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+ if (!partial) {
+ hint |= IGNORE_CPU;
+ if (w == op->dst.width && h == op->dst.height)
+ hint |= REPLACES;
+ }
+
+ op->dst.bo = sna_drawable_use_bo(dst->pDrawable, hint, &box, &op->damage);
if (op->dst.bo == NULL)
return false;
@@ -2440,7 +2446,7 @@ gen7_render_composite(struct sna *sna,
tmp->op = op;
if (!gen7_composite_set_target(sna, tmp, dst,
dst_x, dst_y, width, height,
- op > PictOpSrc || dst->pCompositeClip->data))
+ flags & COMPOSITE_PARTIAL || op > PictOpSrc || dst->pCompositeClip->data))
goto fallback;
switch (gen7_composite_picture(sna, src, &tmp->src,
diff --git a/src/sna/gen8_render.c b/src/sna/gen8_render.c
index 13e1662c..fcc37abd 100644
--- a/src/sna/gen8_render.c
+++ b/src/sna/gen8_render.c
@@ -1859,6 +1859,7 @@ gen8_composite_set_target(struct sna *sna,
bool partial)
{
BoxRec box;
+ unsigned int hint;
op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
op->dst.format = dst->format;
@@ -1874,9 +1875,14 @@ gen8_composite_set_target(struct sna *sna,
} else
sna_render_picture_extents(dst, &box);
- op->dst.bo = sna_drawable_use_bo(dst->pDrawable,
- PREFER_GPU | FORCE_GPU | RENDER_GPU,
- &box, &op->damage);
+ hint = PREFER_GPU | FORCE_GPU | RENDER_GPU;
+ if (!partial) {
+ hint |= IGNORE_CPU;
+ if (w == op->dst.width && h == op->dst.height)
+ hint |= REPLACES;
+ }
+
+ op->dst.bo = sna_drawable_use_bo(dst->pDrawable, hint, &box, &op->damage);
if (op->dst.bo == NULL)
return false;
@@ -2191,7 +2197,7 @@ gen8_render_composite(struct sna *sna,
tmp->op = op;
if (!gen8_composite_set_target(sna, tmp, dst,
dst_x, dst_y, width, height,
- op > PictOpSrc || dst->pCompositeClip->data))
+ flags & COMPOSITE_PARTIAL || op > PictOpSrc || dst->pCompositeClip->data))
goto fallback;
switch (gen8_composite_picture(sna, src, &tmp->src,