summaryrefslogtreecommitdiff
path: root/src/sna/sna_render.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-25 23:21:36 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-26 12:55:22 +0000
commitcff6a1a2e4648eb211a1789ae9f711e2f16e9d4d (patch)
treec0e6a7aa480478337bbbc9ec286c3beefc5e9ed1 /src/sna/sna_render.c
parente583af9cca4ad2e5643317447c6b065d3ee7d11e (diff)
sna: Use the cpu bo where possible as the source for texture extraction
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_render.c')
-rw-r--r--src/sna/sna_render.c95
1 files changed, 48 insertions, 47 deletions
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index d1cb60b0..28b93a25 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -295,7 +295,7 @@ use_cpu_bo(struct sna *sna, PixmapPtr pixmap, const BoxRec *box)
if (DBG_NO_CPU_BO)
return NULL;
- priv = sna_pixmap_attach(pixmap);
+ priv = sna_pixmap(pixmap);
if (priv == NULL || priv->cpu_bo == NULL) {
DBG(("%s: no cpu bo\n", __FUNCTION__));
return NULL;
@@ -332,7 +332,7 @@ use_cpu_bo(struct sna *sna, PixmapPtr pixmap, const BoxRec *box)
int w = box->x2 - box->x1;
int h = box->y2 - box->y1;
- if (pixmap->usage_hint)
+ if (!priv->gpu)
goto done;
if (priv->source_count*w*h >= pixmap->drawable.width * pixmap->drawable.height &&
@@ -349,7 +349,7 @@ use_cpu_bo(struct sna *sna, PixmapPtr pixmap, const BoxRec *box)
done:
DBG(("%s for box=(%d, %d), (%d, %d)\n",
__FUNCTION__, box->x1, box->y1, box->x2, box->y2));
- return kgem_bo_reference(priv->cpu_bo);
+ return priv->cpu_bo;
}
static Bool
@@ -583,23 +583,25 @@ sna_render_pixmap_bo(struct sna *sna,
pixmap->drawable.width, pixmap->drawable.height));
bo = use_cpu_bo(sna, pixmap, &box);
- if (bo == NULL &&
- texture_is_cpu(pixmap, &box) &&
- !move_to_gpu(pixmap, &box)) {
- DBG(("%s: uploading CPU box (%d, %d), (%d, %d)\n",
- __FUNCTION__, box.x1, box.y1, box.x2, box.y2));
- bo = upload(sna, channel, pixmap, &box);
- }
-
- if (bo == NULL) {
- priv = sna_pixmap_move_to_gpu(pixmap, MOVE_READ);
- if (priv) {
- bo = kgem_bo_reference(priv->gpu_bo);
- } else {
- DBG(("%s: failed to upload pixmap to gpu, uploading CPU box (%d, %d), (%d, %d) instead\n",
+ if (bo) {
+ bo = kgem_bo_reference(bo);
+ } else {
+ if (texture_is_cpu(pixmap, &box) && !move_to_gpu(pixmap, &box)) {
+ DBG(("%s: uploading CPU box (%d, %d), (%d, %d)\n",
__FUNCTION__, box.x1, box.y1, box.x2, box.y2));
bo = upload(sna, channel, pixmap, &box);
}
+
+ if (bo == NULL) {
+ priv = sna_pixmap_move_to_gpu(pixmap, MOVE_READ);
+ if (priv) {
+ bo = kgem_bo_reference(priv->gpu_bo);
+ } else {
+ DBG(("%s: failed to upload pixmap to gpu, uploading CPU box (%d, %d), (%d, %d) instead\n",
+ __FUNCTION__, box.x1, box.y1, box.x2, box.y2));
+ bo = upload(sna, channel, pixmap, &box);
+ }
+ }
}
channel->bo = bo;
@@ -870,7 +872,7 @@ sna_render_picture_extract(struct sna *sna,
int16_t w, int16_t h,
int16_t dst_x, int16_t dst_y)
{
- struct kgem_bo *bo = NULL;
+ struct kgem_bo *bo = NULL, *src_bo;
PixmapPtr pixmap = get_drawable_pixmap(picture->pDrawable);
int16_t ox, oy, ow, oh;
BoxRec box;
@@ -962,49 +964,48 @@ sna_render_picture_extract(struct sna *sna,
dst_x, dst_y);
}
- if (texture_is_cpu(pixmap, &box) && !move_to_gpu(pixmap, &box)) {
- bo = kgem_upload_source_image(&sna->kgem,
- pixmap->devPrivate.ptr,
- &box,
- pixmap->devKind,
- pixmap->drawable.bitsPerPixel);
- if (bo == NULL) {
- DBG(("%s: failed to upload source image, using clear\n",
- __FUNCTION__));
- return 0;
- }
- } else {
- 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,
- x, y, ow, oh, dst_x, dst_y);
+ src_bo = use_cpu_bo(sna, pixmap, &box);
+ if (src_bo == NULL) {
+ if (texture_is_cpu(pixmap, &box) &&
+ !move_to_gpu(pixmap, &box)) {
+ bo = kgem_upload_source_image(&sna->kgem,
+ pixmap->devPrivate.ptr,
+ &box,
+ pixmap->devKind,
+ pixmap->drawable.bitsPerPixel);
+ } else {
+ struct sna_pixmap *priv;
+
+ priv = sna_pixmap_move_to_gpu(pixmap, MOVE_READ);
+ if (priv)
+ src_bo = priv->gpu_bo;
}
+ }
+ if (src_bo) {
bo = kgem_create_2d(&sna->kgem, w, h,
pixmap->drawable.bitsPerPixel,
kgem_choose_tiling(&sna->kgem,
I915_TILING_X, w, h,
pixmap->drawable.bitsPerPixel),
0);
- if (!bo) {
- DBG(("%s: failed to create bo, using clear\n",
- __FUNCTION__));
- return 0;
- }
-
- if (!sna_blt_copy_boxes(sna, GXcopy,
- sna_pixmap_get_bo(pixmap), 0, 0,
+ if (bo && !sna_blt_copy_boxes(sna, GXcopy,
+ src_bo, 0, 0,
bo, -box.x1, -box.y1,
pixmap->drawable.bitsPerPixel,
&box, 1)) {
- DBG(("%s: fallback -- unable to copy boxes\n",
- __FUNCTION__));
- return sna_render_picture_fixup(sna, picture, channel,
- x, y, ow, oh, dst_x, dst_y);
+ kgem_bo_destroy(&sna->kgem, bo);
+ bo = NULL;
}
}
+ if (bo == NULL) {
+ DBG(("%s: falback -- pixmap is not on the GPU\n",
+ __FUNCTION__));
+ return sna_render_picture_fixup(sna, picture, channel,
+ x, y, ow, oh, dst_x, dst_y);
+ }
+
if (ox == x && oy == y) {
x = y = 0;
} else if (channel->transform) {