summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-03-05 13:30:37 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-03-05 13:30:37 +0000
commitd31dc1343d59f8ef8876e1dc8ddfec9c6be1a602 (patch)
tree895b7c5fc1955e9a38e0aff6c84d3363af10eb2d /src
parent9fa9234c7061be3cff9a65aac0702f4c3caac40d (diff)
sna: Refactor the is-mappable test for inplace operations
By moving the test into the common function for creating a mappable GPU bo, we can also consider recreating that bo when desirable. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/sna/sna_accel.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 924a88f2..a2e5be3b 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1377,15 +1377,13 @@ static inline bool pixmap_inplace(struct sna *sna,
if (!write_only && priv->cpu_damage)
return false;
- if (priv->gpu_bo && !kgem_bo_is_mappable(&sna->kgem, priv->gpu_bo))
- return false;
-
return (pixmap->devKind * pixmap->drawable.height >> 12) >
sna->kgem.half_cpu_cache_pages;
}
static bool
-sna_pixmap_create_mappable_gpu(PixmapPtr pixmap)
+sna_pixmap_create_mappable_gpu(PixmapPtr pixmap,
+ bool can_replace)
{
struct sna *sna = to_sna_from_pixmap(pixmap);
struct sna_pixmap *priv = sna_pixmap(pixmap);
@@ -1399,6 +1397,22 @@ sna_pixmap_create_mappable_gpu(PixmapPtr pixmap)
assert_pixmap_damage(pixmap);
+ if (priv->gpu_bo) {
+ if (can_replace &&
+ (!kgem_bo_is_mappable(&sna->kgem, priv->gpu_bo) ||
+ __kgem_bo_is_busy(&sna->kgem, priv->gpu_bo))) {
+ if (priv->pinned)
+ return false;
+
+ DBG(("%s: discard busy GPU bo\n", __FUNCTION__));
+ sna_pixmap_free_gpu(sna, priv);
+ }
+
+ return kgem_bo_is_mappable(&sna->kgem, priv->gpu_bo);
+ }
+
+ assert_pixmap_damage(pixmap);
+
assert(priv->gpu_damage == NULL);
assert(priv->gpu_bo == NULL);
@@ -1538,22 +1552,11 @@ _sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned int flags)
__FUNCTION__, priv->gpu_damage != NULL, priv->clear));
if (priv->create & KGEM_CAN_CREATE_GPU &&
- pixmap_inplace(sna, pixmap, priv, true)) {
- assert(!priv->shm);
+ pixmap_inplace(sna, pixmap, priv, true) &&
+ sna_pixmap_create_mappable_gpu(pixmap, true)) {
DBG(("%s: write inplace\n", __FUNCTION__));
- if (priv->gpu_bo) {
- if (__kgem_bo_is_busy(&sna->kgem,
- priv->gpu_bo)) {
- if (priv->pinned)
- goto skip_inplace_map;
-
- DBG(("%s: discard busy GPU bo\n", __FUNCTION__));
- sna_pixmap_free_gpu(sna, priv);
- }
- }
- if (priv->gpu_bo == NULL &&
- !sna_pixmap_create_mappable_gpu(pixmap))
- goto skip_inplace_map;
+ assert(!priv->shm);
+ assert(priv->gpu_bo->exec == NULL);
pixmap->devPrivate.ptr =
kgem_bo_map(&sna->kgem, priv->gpu_bo);
@@ -1609,11 +1612,10 @@ skip_inplace_map:
if (operate_inplace(priv, flags) &&
pixmap_inplace(sna, pixmap, priv, (flags & MOVE_READ) == 0) &&
- (priv->gpu_bo || sna_pixmap_create_mappable_gpu(pixmap))) {
- kgem_bo_submit(&sna->kgem, priv->gpu_bo);
-
+ sna_pixmap_create_mappable_gpu(pixmap, (flags & MOVE_READ) == 0)) {
DBG(("%s: try to operate inplace (GTT)\n", __FUNCTION__));
assert((flags & MOVE_READ) == 0 || priv->cpu == false);
+ assert(priv->gpu_bo->exec == NULL);
pixmap->devPrivate.ptr = kgem_bo_map(&sna->kgem, priv->gpu_bo);
priv->mapped = pixmap->devPrivate.ptr != NULL;
@@ -1968,10 +1970,9 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
if (operate_inplace(priv, flags) &&
region_inplace(sna, pixmap, region, priv, (flags & MOVE_READ) == 0) &&
- (priv->gpu_bo || sna_pixmap_create_mappable_gpu(pixmap))) {
- kgem_bo_submit(&sna->kgem, priv->gpu_bo);
-
+ sna_pixmap_create_mappable_gpu(pixmap, false)) {
DBG(("%s: try to operate inplace\n", __FUNCTION__));
+ assert(priv->gpu_bo->exec == NULL);
pixmap->devPrivate.ptr = kgem_bo_map(&sna->kgem, priv->gpu_bo);
priv->mapped = pixmap->devPrivate.ptr != NULL;