summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-10-06 08:47:20 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-10-06 12:17:14 +0100
commit707901bf98073fb56179a0b61c806f85ef8f413c (patch)
tree0055aeffb0b721cf24cfc77c8b59b85c953cde51
parent54f545e0631a287f421ef6a6f20831624b212cf2 (diff)
uxa: Re-enable acceleration.
A side-effect of discriminating offscreen based on the devPrivate.ptr was that it broke uxa_finish_access and so after any fallback to s/w on a Pixmap, it remained in software for the reminder of its life. Introduce an explicit boolean to mark whether or not hardware acceleration is enabled for a pixmap (with a GEM buffer). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/intel.h1
-rw-r--r--src/intel_dri.c38
-rw-r--r--src/intel_uxa.c64
3 files changed, 48 insertions, 55 deletions
diff --git a/src/intel.h b/src/intel.h
index 83d541e0..b74a0618 100644
--- a/src/intel.h
+++ b/src/intel.h
@@ -169,6 +169,7 @@ struct intel_pixmap {
uint8_t tiling;
int8_t busy :2;
int8_t batch_write :1;
+ int8_t offscreen :1;
};
#if HAS_DEVPRIVATEKEYREC
diff --git a/src/intel_dri.c b/src/intel_dri.c
index 1527dba1..fe46a118 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -90,8 +90,9 @@ static PixmapPtr get_front_buffer(DrawablePtr drawable, DrawablePtr *ret)
drawable->height,
0, 0,
intel->front_pitch,
- NULL);
+ intel->front_buffer->virtual);
intel_set_pixmap_bo(pixmap, intel->front_buffer);
+ intel_get_pixmap_private(pixmap)->offscreen = 0;
}
} else if (intel_get_pixmap_bo(pixmap)) {
pixmap->refcnt++;
@@ -124,20 +125,21 @@ static PixmapPtr fixup_shadow(DrawablePtr drawable, PixmapPtr pixmap)
* accelerated.
*/
- drm_intel_gem_bo_map_gtt(priv->bo);
+ if (drm_intel_gem_bo_map_gtt(priv->bo))
+ return pixmap;
+
+ screen->ModifyPixmapHeader(pixmap,
+ drawable->width,
+ drawable->height,
+ 0, 0,
+ priv->stride,
+ priv->bo->virtual);
+ priv->offscreen = 0;
/* Copy the current contents of the pixmap to the bo. */
gc = GetScratchGC(drawable->depth, screen);
if (gc) {
ValidateGC(&pixmap->drawable, gc);
-
- screen->ModifyPixmapHeader(pixmap,
- drawable->width,
- drawable->height,
- 0, 0,
- priv->stride,
- priv->bo->virtual);
-
gc->ops->CopyArea(drawable, &pixmap->drawable,
gc,
0, 0,
@@ -407,7 +409,7 @@ I830DRI2CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
DrawablePtr src = srcPrivate->drawable;
DrawablePtr dst = dstPrivate->drawable;
RegionPtr pCopyClip;
- PixmapPtr src_pixmap, dst_pixmap;
+ struct intel_pixmap *src_pixmap, *dst_pixmap;
GCPtr gc;
gc = GetScratchGC(dst->depth, screen);
@@ -505,11 +507,13 @@ I830DRI2CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
* again. */
/* Re-enable 2D acceleration... */
- src_pixmap = get_drawable_pixmap(src);
- src_pixmap->devPrivate.ptr = NULL;
+ src_pixmap = intel_get_pixmap_private(get_drawable_pixmap(src));
+ src_pixmap->offscreen = 1;
+ src_pixmap->busy = 1;
- dst_pixmap = get_drawable_pixmap(dst);
- dst_pixmap->devPrivate.ptr = NULL;
+ dst_pixmap = intel_get_pixmap_private(get_drawable_pixmap(dst));
+ dst_pixmap->offscreen = 1;
+ dst_pixmap->busy = 1;
gc->ops->CopyArea(src, dst, gc,
0, 0,
@@ -518,8 +522,8 @@ I830DRI2CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
FreeScratchGC(gc);
/* and restore 2D/3D coherency */
- src_pixmap->devPrivate.ptr = intel_get_pixmap_bo(src_pixmap)->virtual;
- dst_pixmap->devPrivate.ptr = intel_get_pixmap_bo(dst_pixmap)->virtual;
+ src_pixmap->offscreen = 0;
+ dst_pixmap->offscreen = 0;
}
#if DRI2INFOREC_VERSION >= 4
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index d964a951..fd7ca23c 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -666,6 +666,7 @@ void intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo)
priv->tiling = tiling;
priv->busy = -1;
+ priv->offscreen = 1;
} else {
if (priv != NULL) {
free(priv);
@@ -677,6 +678,12 @@ void intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo)
intel_set_pixmap_private(pixmap, priv);
}
+static Bool intel_uxa_pixmap_is_offscreen(PixmapPtr pixmap)
+{
+ struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+ return priv && priv->offscreen;
+}
+
static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
{
ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum];
@@ -707,22 +714,6 @@ static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
return TRUE;
}
-static void intel_uxa_finish_access(PixmapPtr pixmap)
-{
- ScreenPtr screen = pixmap->drawable.pScreen;
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- intel_screen_private *intel = intel_get_screen_private(scrn);
- struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
- dri_bo *bo = priv->bo;
-
- if (priv->tiling || bo->size <= intel->max_gtt_map_size)
- drm_intel_gem_bo_unmap_gtt(bo);
- else
- dri_bo_unmap(bo);
-
- pixmap->devPrivate.ptr = NULL;
-}
-
static Bool intel_uxa_pixmap_put_image(PixmapPtr pixmap,
char *src, int src_pitch,
int x, int y, int w, int h)
@@ -813,6 +804,11 @@ static Bool intel_uxa_put_image(PixmapPtr pixmap,
if (!scratch)
return FALSE;
+ if (!intel_uxa_pixmap_is_offscreen(scratch)) {
+ screen->DestroyPixmap(scratch);
+ return FALSE;
+ }
+
ret = intel_uxa_pixmap_put_image(scratch, src, src_pitch, 0, 0, w, h);
if (ret) {
GCPtr gc = GetScratchGC(pixmap->drawable.depth, screen);
@@ -893,7 +889,7 @@ static Bool intel_uxa_get_image(PixmapPtr pixmap,
if (!scratch)
return FALSE;
- if (!intel_get_pixmap_bo(scratch)) {
+ if (!intel_uxa_pixmap_is_offscreen(scratch)) {
screen->DestroyPixmap(scratch);
return FALSE;
}
@@ -941,14 +937,6 @@ void intel_uxa_block_handler(intel_screen_private *intel)
}
}
-static Bool intel_uxa_pixmap_is_offscreen(PixmapPtr pixmap)
-{
- if (pixmap->devPrivate.ptr)
- return FALSE;
-
- return intel_get_pixmap_bo(pixmap) != NULL;
-}
-
static PixmapPtr
intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
unsigned usage)
@@ -1070,6 +1058,7 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
drm_intel_bo_set_tiling(priv->bo, &tiling, stride);
priv->stride = stride;
priv->tiling = tiling;
+ priv->offscreen = 1;
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
@@ -1093,22 +1082,22 @@ void intel_uxa_create_screen_resources(ScreenPtr screen)
{
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
intel_screen_private *intel = intel_get_screen_private(scrn);
+ dri_bo *bo = intel->front_buffer;
+
+ drm_intel_gem_bo_map_gtt(bo);
if (intel->use_shadow) {
intel_shadow_create(intel);
} else {
- dri_bo *bo = intel->front_buffer;
- if (bo != NULL) {
- PixmapPtr pixmap = screen->GetScreenPixmap(screen);
- intel_set_pixmap_bo(pixmap, bo);
- intel_get_pixmap_private(pixmap)->busy = 1;
- screen->ModifyPixmapHeader(pixmap,
- scrn->virtualX,
- scrn->virtualY,
- -1, -1,
- intel->front_pitch,
- NULL);
- }
+ PixmapPtr pixmap = screen->GetScreenPixmap(screen);
+ intel_set_pixmap_bo(pixmap, bo);
+ intel_get_pixmap_private(pixmap)->busy = 1;
+ screen->ModifyPixmapHeader(pixmap,
+ scrn->virtualX,
+ scrn->virtualY,
+ -1, -1,
+ intel->front_pitch,
+ NULL);
scrn->displayWidth = intel->front_pitch / intel->cpp;
}
}
@@ -1244,7 +1233,6 @@ Bool intel_uxa_init(ScreenPtr screen)
intel->uxa_driver->get_image = intel_uxa_get_image;
intel->uxa_driver->prepare_access = intel_uxa_prepare_access;
- intel->uxa_driver->finish_access = intel_uxa_finish_access;
intel->uxa_driver->pixmap_is_offscreen = intel_uxa_pixmap_is_offscreen;
screen->CreatePixmap = intel_uxa_create_pixmap;