diff options
-rw-r--r-- | src/sna/kgem.c | 9 | ||||
-rw-r--r-- | src/sna/kgem.h | 4 | ||||
-rw-r--r-- | src/sna/sna_accel.c | 24 |
3 files changed, 33 insertions, 4 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c index f7404dfb..788b710d 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -6743,14 +6743,19 @@ kgem_replace_bo(struct kgem *kgem, return dst; } -bool kgem_bo_convert_to_gpu(struct kgem *kgem, struct kgem_bo *bo) +bool kgem_bo_convert_to_gpu(struct kgem *kgem, + struct kgem_bo *bo, + unsigned flags) { - DBG(("%s: converting handle=%d from CPU to GPU\n", __FUNCTION__, bo->handle)); + DBG(("%s: converting handle=%d from CPU to GPU, flags=%x\n", __FUNCTION__, bo->handle)); assert(bo->tiling == I915_TILING_NONE); if (kgem->has_llc) return true; + if (flags & MOVE_ASYNC_HINT && __kgem_bo_is_busy(kgem, bo)) + return false; + assert(bo->snoop); kgem_bo_submit(kgem, bo); diff --git a/src/sna/kgem.h b/src/sna/kgem.h index f670b604..4c4996ff 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -301,7 +301,9 @@ struct kgem_bo *kgem_create_cpu_2d(struct kgem *kgem, int bpp, uint32_t flags); -bool kgem_bo_convert_to_gpu(struct kgem *kgem, struct kgem_bo *bo); +bool kgem_bo_convert_to_gpu(struct kgem *kgem, + struct kgem_bo *bo, + unsigned flags); uint32_t kgem_bo_get_binding(struct kgem_bo *bo, uint32_t format); void kgem_bo_set_binding(struct kgem_bo *bo, uint32_t format, uint16_t offset); diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index d654660b..9d7dec45 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3868,7 +3868,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags) if (tiling == I915_TILING_NONE && priv->cpu_bo && !priv->shm && - kgem_bo_convert_to_gpu(&sna->kgem, priv->cpu_bo)) { + kgem_bo_convert_to_gpu(&sna->kgem, priv->cpu_bo, flags)) { assert(!priv->mapped); assert(!IS_STATIC_PTR(priv->ptr)); #ifdef DEBUG_MEMORY @@ -3933,6 +3933,28 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags) if (priv->cpu_damage == NULL) goto done; + if (DAMAGE_IS_ALL(priv->cpu_damage) && + priv->gpu_bo->tiling == I915_TILING_NONE && + priv->cpu_bo && !priv->shm && + kgem_bo_convert_to_gpu(&sna->kgem, priv->cpu_bo, flags)) { + assert(!priv->mapped); + assert(!IS_STATIC_PTR(priv->ptr)); +#ifdef DEBUG_MEMORY + sna->debug_memory.cpu_bo_allocs--; + sna->debug_memory.cpu_bo_bytes -= kgem_bo_size(priv->cpu_bo); +#endif + sna_pixmap_free_gpu(sna, priv); + priv->gpu_bo = priv->cpu_bo; + priv->cpu_bo = NULL; + priv->ptr = NULL; + pixmap->devPrivate.ptr = NULL; + sna_damage_all(&priv->gpu_damage, + pixmap->drawable.width, + pixmap->drawable.height); + sna_damage_destroy(&priv->cpu_damage); + goto done; + } + if (priv->shm) { assert(!priv->flush); sna_add_flush_pixmap(sna, priv, priv->cpu_bo); |