diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-09-04 11:05:43 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-09-04 11:07:26 +0100 |
commit | d0684d55e3a62c231c92a68403cf100c9e18351b (patch) | |
tree | a68376bdb4079a0e5b950a38ac6566bb6a605985 | |
parent | b6ced7a2267f9429ad38949dda39c843e2119e99 (diff) |
sna: Fixup CREATE_USAGE_SHARED
The DRI2 code tries to create pixmaps with non-zero width/height,
whoops.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/kgem.c | 44 | ||||
-rw-r--r-- | src/sna/kgem.h | 1 | ||||
-rw-r--r-- | src/sna/sna_accel.c | 19 |
3 files changed, 55 insertions, 9 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c index d073c9f4..ae0a6044 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -3808,6 +3808,48 @@ static void kgem_trim_vma_cache(struct kgem *kgem, int type, int bucket) } } +void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo) +{ + void *ptr; + + DBG(("%s: handle=%d, offset=%d, tiling=%d, map=%p, domain=%d\n", __FUNCTION__, + bo->handle, bo->presumed_offset, bo->tiling, bo->map, bo->domain)); + + assert(!bo->purged); + assert(bo->proxy == NULL); + assert(list_is_empty(&bo->list)); + + if (bo->tiling == I915_TILING_NONE && !bo->scanout && kgem->has_llc) { + DBG(("%s: converting request for GTT map into CPU map\n", + __FUNCTION__)); + return kgem_bo_map__cpu(kgem, bo); + } + + if (IS_CPU_MAP(bo->map)) + kgem_bo_release_map(kgem, bo); + + ptr = bo->map; + if (ptr == NULL) { + assert(kgem_bo_size(bo) <= kgem->aperture_mappable / 2); + + kgem_trim_vma_cache(kgem, MAP_GTT, bucket(bo)); + + ptr = __kgem_bo_map__gtt(kgem, bo); + if (ptr == NULL) + return NULL; + + /* Cache this mapping to avoid the overhead of an + * excruciatingly slow GTT pagefault. This is more an + * issue with compositing managers which need to frequently + * flush CPU damage to their GPU bo. + */ + bo->map = ptr; + DBG(("%s: caching GTT vma for %d\n", __FUNCTION__, bo->handle)); + } + + return ptr; +} + void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo) { void *ptr; @@ -3817,8 +3859,8 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo) assert(!bo->purged); assert(bo->proxy == NULL); - assert(bo->exec == NULL); assert(list_is_empty(&bo->list)); + assert(bo->exec == NULL); if (bo->tiling == I915_TILING_NONE && !bo->scanout && (kgem->has_llc || bo->domain == DOMAIN_CPU)) { diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 33cd3ff3..0d5384b0 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -410,6 +410,7 @@ uint32_t kgem_add_reloc(struct kgem *kgem, uint32_t delta); void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo); +void *kgem_bo_map__async(struct kgem *kgem, struct kgem_bo *bo); void *kgem_bo_map__gtt(struct kgem *kgem, struct kgem_bo *bo); void kgem_bo_sync__gtt(struct kgem *kgem, struct kgem_bo *bo); void *kgem_bo_map__debug(struct kgem *kgem, struct kgem_bo *bo); diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index b9bf93b6..21d0ef8c 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -943,8 +943,7 @@ sna_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave, void **fd_handle) assert(priv->gpu_bo->tiling == I915_TILING_NONE); /* And export the bo->pitch via pixmap->devKind */ - pixmap->devPrivate.ptr = - kgem_bo_map(&sna->kgem, priv->gpu_bo); + pixmap->devPrivate.ptr = kgem_bo_map__async(&sna->kgem, priv->gpu_bo); if (pixmap->devPrivate.ptr == NULL) return FALSE; @@ -1038,19 +1037,23 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, DBG(("%s(%d, %d, %d, usage=%x)\n", __FUNCTION__, width, height, depth, usage)); + if ((width|height) == 0) { #ifdef CREATE_PIXMAP_USAGE_SHARED - if (usage == CREATE_PIXMAP_USAGE_SHARED) { - assert((width|height) == 0); - return sna_create_pixmap_shared(sna, screen, depth); - } + if (usage == CREATE_PIXMAP_USAGE_SHARED) + return sna_create_pixmap_shared(sna, screen, depth); #endif - - if ((width|height) == 0) { usage = -1; goto fallback; } assert(width && height); +#ifdef CREATE_PIXMAP_USAGE_SHARED + if (usage == CREATE_PIXMAP_USAGE_SHARED) + return sna_pixmap_create_scratch(screen, + width, height, depth, + I915_TILING_NONE); +#endif + flags = kgem_can_create_2d(&sna->kgem, width, height, depth); if (flags == 0) { DBG(("%s: can not use GPU, just creating shadow\n", |