sna: Pass usage-hint to move-to-gpu

When simply creating a source GPU bo it is preferrable not to mark it as
all-damaged.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2011-12-23 19:11:43 +00:00
parent 98f15fc613
commit 9580ae8490
14 changed files with 45 additions and 41 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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,

View File

@ -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;