summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sna/gen2_render.c2
-rw-r--r--src/sna/gen3_render.c2
-rw-r--r--src/sna/gen4_render.c4
-rw-r--r--src/sna/gen5_render.c4
-rw-r--r--src/sna/gen6_render.c4
-rw-r--r--src/sna/gen7_render.c4
-rw-r--r--src/sna/sna.h10
-rw-r--r--src/sna/sna_accel.c32
-rw-r--r--src/sna/sna_blt.c4
-rw-r--r--src/sna/sna_composite.c4
-rw-r--r--src/sna/sna_dri.c2
-rw-r--r--src/sna/sna_driver.c2
-rw-r--r--src/sna/sna_render.c8
-rw-r--r--src/sna/sna_trapezoids.c4
14 files changed, 45 insertions, 41 deletions
diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c
index f1fdfd6f..97716932 100644
--- a/src/sna/gen2_render.c
+++ b/src/sna/gen2_render.c
@@ -1220,7 +1220,7 @@ gen2_composite_set_target(struct sna *sna,
op->dst.width = op->dst.pixmap->drawable.width;
op->dst.height = op->dst.pixmap->drawable.height;
- priv = sna_pixmap_force_to_gpu(op->dst.pixmap);
+ priv = sna_pixmap_force_to_gpu(op->dst.pixmap, MOVE_WRITE | MOVE_READ);
if (priv == NULL)
return FALSE;
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index 5833c1fc..61742575 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -2230,7 +2230,7 @@ gen3_composite_set_target(struct sna *sna,
op->dst.height = op->dst.pixmap->drawable.height;
priv = sna_pixmap(op->dst.pixmap);
- priv = sna_pixmap_force_to_gpu(op->dst.pixmap);
+ priv = sna_pixmap_force_to_gpu(op->dst.pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return FALSE;
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 9f15b3c4..cf6d947b 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -1610,7 +1610,7 @@ gen4_render_video(struct sna *sna,
DBG(("%s: %dx%d -> %dx%d\n", __FUNCTION__, src_w, src_h, drw_w, drw_h));
- priv = sna_pixmap_force_to_gpu(pixmap);
+ priv = sna_pixmap_force_to_gpu(pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return FALSE;
@@ -1837,7 +1837,7 @@ gen4_composite_set_target(PicturePtr dst, struct sna_composite_op *op)
op->dst.width = op->dst.pixmap->drawable.width;
op->dst.height = op->dst.pixmap->drawable.height;
op->dst.format = dst->format;
- priv = sna_pixmap_force_to_gpu(op->dst.pixmap);
+ priv = sna_pixmap_force_to_gpu(op->dst.pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return FALSE;
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 0b422726..f0bb1875 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -1654,7 +1654,7 @@ gen5_render_video(struct sna *sna,
DBG(("%s: %dx%d -> %dx%d\n", __FUNCTION__, src_w, src_h, drw_w, drw_h));
- priv = sna_pixmap_force_to_gpu(pixmap);
+ priv = sna_pixmap_force_to_gpu(pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return FALSE;
@@ -1883,7 +1883,7 @@ gen5_composite_set_target(PicturePtr dst, struct sna_composite_op *op)
op->damage = &priv->cpu_damage;
}
if (op->dst.bo == NULL) {
- priv = sna_pixmap_force_to_gpu(op->dst.pixmap);
+ priv = sna_pixmap_force_to_gpu(op->dst.pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return FALSE;
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 985bb90b..2cd4173b 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -1814,7 +1814,7 @@ gen6_render_video(struct sna *sna,
REGION_EXTENTS(NULL, dstRegion)->x2,
REGION_EXTENTS(NULL, dstRegion)->y2));
- priv = sna_pixmap_force_to_gpu(pixmap);
+ priv = sna_pixmap_force_to_gpu(pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return FALSE;
@@ -2060,7 +2060,7 @@ gen6_composite_set_target(struct sna *sna,
op->damage = &priv->cpu_damage;
}
if (op->dst.bo == NULL) {
- priv = sna_pixmap_force_to_gpu(op->dst.pixmap);
+ priv = sna_pixmap_force_to_gpu(op->dst.pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return FALSE;
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index 5eac9bf6..dd93ae99 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -1927,7 +1927,7 @@ gen7_render_video(struct sna *sna,
REGION_EXTENTS(NULL, dstRegion)->x2,
REGION_EXTENTS(NULL, dstRegion)->y2));
- priv = sna_pixmap_force_to_gpu(pixmap);
+ priv = sna_pixmap_force_to_gpu(pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return FALSE;
@@ -2172,7 +2172,7 @@ gen7_composite_set_target(struct sna_composite_op *op, PicturePtr dst)
op->damage = &priv->cpu_damage;
}
if (op->dst.bo == NULL) {
- priv = sna_pixmap_force_to_gpu(op->dst.pixmap);
+ priv = sna_pixmap_force_to_gpu(op->dst.pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return FALSE;
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 1ee4da20..b99d0fd4 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -426,8 +426,8 @@ struct sna_pixmap *sna_pixmap_attach(PixmapPtr pixmap);
PixmapPtr sna_pixmap_create_upload(ScreenPtr screen,
int width, int height, int depth);
-struct sna_pixmap *sna_pixmap_move_to_gpu(PixmapPtr pixmap);
-struct sna_pixmap *sna_pixmap_force_to_gpu(PixmapPtr pixmap);
+struct sna_pixmap *sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags);
+struct sna_pixmap *sna_pixmap_force_to_gpu(PixmapPtr pixmap, unsigned flags);
struct kgem_bo *sna_pixmap_change_tiling(PixmapPtr pixmap, uint32_t tiling);
#define MOVE_WRITE 0x1
@@ -448,9 +448,9 @@ sna_drawable_move_to_cpu(DrawablePtr drawable, unsigned flags)
}
static inline bool must_check
-sna_drawable_move_to_gpu(DrawablePtr drawable)
+sna_drawable_move_to_gpu(DrawablePtr drawable, unsigned flags)
{
- return sna_pixmap_move_to_gpu(get_drawable_pixmap(drawable)) != NULL;
+ return sna_pixmap_move_to_gpu(get_drawable_pixmap(drawable), flags) != NULL;
}
static inline Bool
@@ -469,7 +469,7 @@ static inline struct kgem_bo *sna_pixmap_pin(PixmapPtr pixmap)
{
struct sna_pixmap *priv;
- priv = sna_pixmap_force_to_gpu(pixmap);
+ priv = sna_pixmap_force_to_gpu(pixmap, MOVE_READ | MOVE_WRITE);
if (!priv)
return NULL;
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 910d32ee..a95490df 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -685,7 +685,7 @@ sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned int flags)
if (kgem_bo_is_busy(priv->gpu_bo)) {
sna_pixmap_destroy_gpu_bo(sna, priv);
- if (!sna_pixmap_move_to_gpu(pixmap))
+ if (!sna_pixmap_move_to_gpu(pixmap, MOVE_WRITE))
goto skip_inplace_map;
}
@@ -882,7 +882,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
kgem_retire(&sna->kgem);
if (sync_will_stall(priv->cpu_bo)) {
sna_damage_subtract(&priv->cpu_damage, region);
- if (!sna_pixmap_move_to_gpu(pixmap))
+ if (!sna_pixmap_move_to_gpu(pixmap, MOVE_WRITE))
return false;
sna_pixmap_free_cpu(sna, priv);
@@ -1091,7 +1091,7 @@ _sna_drawable_use_gpu_bo(DrawablePtr drawable,
return FALSE;
if (pixmap->devPrivate.ptr == NULL &&
- !sna_pixmap_move_to_gpu(pixmap))
+ !sna_pixmap_move_to_gpu(pixmap, MOVE_READ | MOVE_WRITE))
return FALSE;
if (priv->gpu_bo == NULL)
@@ -1270,7 +1270,7 @@ sna_pixmap_create_upload(ScreenPtr screen,
}
struct sna_pixmap *
-sna_pixmap_force_to_gpu(PixmapPtr pixmap)
+sna_pixmap_force_to_gpu(PixmapPtr pixmap, unsigned flags)
{
struct sna_pixmap *priv;
@@ -1311,14 +1311,14 @@ sna_pixmap_force_to_gpu(PixmapPtr pixmap)
DBG(("%s: created gpu bo\n", __FUNCTION__));
}
- if (!sna_pixmap_move_to_gpu(pixmap))
+ if (!sna_pixmap_move_to_gpu(pixmap, flags))
return NULL;
return priv;
}
struct sna_pixmap *
-sna_pixmap_move_to_gpu(PixmapPtr pixmap)
+sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
{
struct sna *sna = to_sna_from_pixmap(pixmap);
struct sna_pixmap *priv;
@@ -1348,7 +1348,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap)
return NULL;
}
- if (priv->cpu_damage == NULL) {
+ if (flags & MOVE_WRITE && priv->cpu_damage == NULL) {
/* Presume that we will only ever write to the GPU
* bo. Readbacks are expensive but fairly constant
* in cost for all sizes i.e. it is the act of
@@ -1361,6 +1361,9 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap)
}
}
+ if ((flags & MOVE_READ) == 0)
+ sna_damage_destroy(&priv->cpu_damage);
+
if (priv->cpu_damage == NULL)
goto done;
@@ -1741,7 +1744,8 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
} else {
if (!region_subsumes_drawable(region, &pixmap->drawable)) {
sna_damage_subtract(&priv->cpu_damage, region);
- if (!sna_pixmap_move_to_gpu(pixmap))
+ if (!sna_pixmap_move_to_gpu(pixmap,
+ MOVE_WRITE))
return false;
}
@@ -2220,7 +2224,7 @@ sna_self_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
get_drawable_deltas(dst, pixmap, &tx, &ty);
if (priv && priv->gpu_bo) {
- if (!sna_pixmap_move_to_gpu(pixmap)) {
+ if (!sna_pixmap_move_to_gpu(pixmap, MOVE_WRITE | MOVE_READ)) {
DBG(("%s: fallback - not a pure copy and failed to move dst to GPU\n",
__FUNCTION__));
goto fallback;
@@ -2401,7 +2405,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
goto fallback;
}
- if (alu != GXcopy && !sna_pixmap_move_to_gpu(dst_pixmap)) {
+ if (alu != GXcopy && !sna_pixmap_move_to_gpu(dst_pixmap, MOVE_READ | MOVE_WRITE)) {
DBG(("%s: fallback - not a pure copy and failed to move dst to GPU\n",
__FUNCTION__));
goto fallback;
@@ -2409,7 +2413,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
if (src_priv &&
move_to_gpu(src_pixmap, src_priv, &region.extents, alu) &&
- sna_pixmap_move_to_gpu(src_pixmap)) {
+ sna_pixmap_move_to_gpu(src_pixmap, MOVE_READ)) {
if (!sna->render.copy_boxes(sna, alu,
src_pixmap, src_priv->gpu_bo, src_dx, src_dy,
dst_pixmap, dst_priv->gpu_bo, dst_dx, dst_dy,
@@ -6477,7 +6481,7 @@ sna_poly_fill_rect_tiled_blt(DrawablePtr drawable,
n, rect,
extents, clipped);
- if (!sna_pixmap_move_to_gpu(tile))
+ if (!sna_pixmap_move_to_gpu(tile, MOVE_READ))
return FALSE;
if (!sna_copy_init_blt(&copy, sna,
@@ -8811,7 +8815,7 @@ sna_accel_flush_callback(CallbackListPtr *list,
struct sna_pixmap *priv = list_first_entry(&sna->dirty_pixmaps,
struct sna_pixmap,
list);
- sna_pixmap_move_to_gpu(priv->pixmap);
+ sna_pixmap_move_to_gpu(priv->pixmap, MOVE_READ);
}
kgem_submit(&sna->kgem);
@@ -9029,7 +9033,7 @@ static bool sna_accel_flush(struct sna *sna)
if (nothing_to_do && !sna->kgem.busy)
_sna_accel_disarm_timer(sna, FLUSH_TIMER);
else
- sna_pixmap_move_to_gpu(priv->pixmap);
+ sna_pixmap_move_to_gpu(priv->pixmap, MOVE_READ);
sna->kgem.busy = !nothing_to_do;
kgem_bo_flush(&sna->kgem, priv->gpu_bo);
sna->kgem.flush_now = 0;
diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c
index 02ddf3ff..053b3571 100644
--- a/src/sna/sna_blt.c
+++ b/src/sna/sna_blt.c
@@ -1247,7 +1247,7 @@ sna_blt_composite(struct sna *sna,
}
tmp->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
- priv = sna_pixmap_move_to_gpu(tmp->dst.pixmap);
+ priv = sna_pixmap_move_to_gpu(tmp->dst.pixmap, MOVE_WRITE | MOVE_READ);
if (priv == NULL || priv->gpu_bo->tiling == I915_TILING_Y) {
DBG(("%s: dst not on the gpu or using Y-tiling\n",
__FUNCTION__));
@@ -1360,7 +1360,7 @@ sna_blt_composite(struct sna *sna,
ret = prepare_blt_copy(sna, tmp);
else if (has_cpu_area(blt->src_pixmap, x, y, width, height))
ret = prepare_blt_put(sna, tmp);
- else if (sna_pixmap_move_to_gpu(blt->src_pixmap))
+ else if (sna_pixmap_move_to_gpu(blt->src_pixmap, MOVE_READ))
ret = prepare_blt_copy(sna, tmp);
else
ret = prepare_blt_put(sna, tmp);
diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c
index 98bf8716..84b633d0 100644
--- a/src/sna/sna_composite.c
+++ b/src/sna/sna_composite.c
@@ -717,7 +717,7 @@ sna_composite_rectangles(CARD8 op,
* operation, then we may as well delete it without moving it
* first to the GPU.
*/
- if (op == PictOpSrc || op == PictOpClear) {
+ if (op <= PictOpSrc) {
priv = sna_pixmap_attach(pixmap);
if (priv)
sna_damage_subtract(&priv->cpu_damage, &region);
@@ -728,7 +728,7 @@ sna_composite_rectangles(CARD8 op,
goto fallback;
}
- priv = sna_pixmap_move_to_gpu(pixmap);
+ priv = sna_pixmap_move_to_gpu(pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL) {
DBG(("%s: fallback due to no GPU bo\n", __FUNCTION__));
goto fallback;
diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c
index dd94d96a..d0e7ae7c 100644
--- a/src/sna/sna_dri.c
+++ b/src/sna/sna_dri.c
@@ -127,7 +127,7 @@ static struct kgem_bo *sna_pixmap_set_dri(struct sna *sna,
{
struct sna_pixmap *priv;
- priv = sna_pixmap_force_to_gpu(pixmap);
+ priv = sna_pixmap_force_to_gpu(pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return NULL;
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 45e8fb20..770a5bd2 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -198,7 +198,7 @@ static Bool sna_create_screen_resources(ScreenPtr screen)
return FALSE;
}
- if (!sna_pixmap_force_to_gpu(sna->front)) {
+ if (!sna_pixmap_force_to_gpu(sna->front, MOVE_READ)) {
xf86DrvMsg(screen->myNum, X_ERROR,
"[intel] Failed to allocate video resources for front buffer %dx%d at depth %d\n",
screen->width,
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index 89d1d812..c859244f 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -508,7 +508,7 @@ sna_render_pixmap_bo(struct sna *sna,
}
if (bo == NULL) {
- priv = sna_pixmap_force_to_gpu(pixmap);
+ priv = sna_pixmap_move_to_gpu(pixmap, MOVE_READ);
if (priv) {
bo = kgem_bo_reference(priv->gpu_bo);
} else {
@@ -617,7 +617,7 @@ static int sna_render_picture_downsample(struct sna *sna,
PixmapPtr tmp;
int error, i, j, ww, hh, ni, nj;
- if (!sna_pixmap_force_to_gpu(pixmap))
+ if (!sna_pixmap_move_to_gpu(pixmap, MOVE_READ))
goto fixup;
tmp = screen->CreatePixmap(screen,
@@ -862,7 +862,7 @@ sna_render_picture_extract(struct sna *sna,
return 0;
}
} else {
- if (!sna_pixmap_move_to_gpu(pixmap)) {
+ if (!sna_pixmap_move_to_gpu(pixmap, MOVE_READ)) {
DBG(("%s: falback -- pixmap is not on the GPU\n",
__FUNCTION__));
return sna_render_picture_fixup(sna, picture, channel,
@@ -1376,7 +1376,7 @@ sna_render_composite_redirect(struct sna *sna,
return FALSE;
}
- if (!sna_pixmap_move_to_gpu(op->dst.pixmap))
+ if (!sna_pixmap_move_to_gpu(op->dst.pixmap, MOVE_READ | MOVE_WRITE))
return FALSE;
/* We can process the operation in a single pass,
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index 3837532a..83e03351 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -3698,7 +3698,7 @@ trap_mask_converter(PicturePtr picture,
return false;
pixmap = get_drawable_pixmap(picture->pDrawable);
- priv = sna_pixmap_move_to_gpu(pixmap);
+ priv = sna_pixmap_move_to_gpu(pixmap, MOVE_READ | MOVE_WRITE);
/* XXX strict adherence to the Render specification */
if (picture->polyMode == PolyModePrecise) {
@@ -3811,7 +3811,7 @@ trap_upload(PicturePtr picture,
int width, height, depth;
int n;
- priv = sna_pixmap_move_to_gpu(pixmap);
+ priv = sna_pixmap_move_to_gpu(pixmap, MOVE_READ | MOVE_WRITE);
if (priv == NULL)
return false;