summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-06-07 19:13:09 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-06-07 19:13:09 +0100
commit0a25fc68c5cd82cad4b99b0f2357f430c8783c3f (patch)
tree7da412925ac7edade416acc1e5637011476aa631
parentc58d137d3eeb0e97bfd53e68404e04d9012b5697 (diff)
sna: Actually create Y-tiled source pixmaps
An inconsistency highlighted by 7c51cabaecac revealed that we had a mismatch between the check in move_to_gpu() and how we created the pixmap. This mismatch resulted in us creating and uploading tiled pixmaps for single shot textures, and the increase aperture pressure was causing a regression in firefox-fishbowl on pnv, for example. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna.h2
-rw-r--r--src/sna/sna_accel.c37
-rw-r--r--src/sna/sna_render.c56
3 files changed, 47 insertions, 48 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h
index f8ec7964..6aa54d1c 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -270,7 +270,6 @@ struct sna {
struct gen7_render_state gen7;
} render_state;
uint32_t have_render;
- uint32_t default_tiling;
Bool directRenderingOpen;
char *deviceName;
@@ -418,6 +417,7 @@ struct kgem_bo *sna_pixmap_change_tiling(PixmapPtr pixmap, uint32_t tiling);
#define MOVE_READ 0x2
#define MOVE_INPLACE_HINT 0x4
#define MOVE_ASYNC_HINT 0x8
+#define MOVE_SOURCE_HINT 0x10
bool must_check _sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned flags);
static inline bool must_check sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned flags)
{
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 4a7d55e5..08400561 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -59,6 +59,8 @@
#define FORCE_FALLBACK 0
#define FORCE_FLUSH 0
+#define DEFAULT_TILING I915_TILING_X
+
#define USE_INPLACE 1
#define USE_WIDE_SPANS 0 /* -1 force CPU, 1 force GPU */
#define USE_ZERO_SPANS 1 /* -1 force CPU, 1 force GPU */
@@ -442,7 +444,8 @@ static Bool sna_destroy_private(PixmapPtr pixmap, struct sna_pixmap *priv)
return true;
}
-static inline uint32_t default_tiling(PixmapPtr pixmap)
+static inline uint32_t default_tiling(PixmapPtr pixmap,
+ uint32_t tiling)
{
struct sna_pixmap *priv = sna_pixmap(pixmap);
struct sna *sna = to_sna_from_pixmap(pixmap);
@@ -471,20 +474,21 @@ static inline uint32_t default_tiling(PixmapPtr pixmap)
return I915_TILING_Y;
}
- return sna->default_tiling;
+ return tiling;
}
-constant static uint32_t sna_pixmap_choose_tiling(PixmapPtr pixmap)
+constant static uint32_t sna_pixmap_choose_tiling(PixmapPtr pixmap,
+ uint32_t tiling)
{
struct sna *sna = to_sna_from_pixmap(pixmap);
- uint32_t tiling, bit;
+ uint32_t bit;
/* Use tiling by default, but disable per user request */
if (pixmap->usage_hint == SNA_CREATE_FB) {
tiling = -I915_TILING_X;
bit = SNA_TILING_FB;
} else {
- tiling = default_tiling(pixmap);
+ tiling = default_tiling(pixmap, tiling);
bit = SNA_TILING_2D;
}
if ((sna->tiling && (1 << bit)) == 0)
@@ -924,7 +928,7 @@ sna_pixmap_create_mappable_gpu(PixmapPtr pixmap)
pixmap->drawable.width,
pixmap->drawable.height,
pixmap->drawable.bitsPerPixel,
- sna_pixmap_choose_tiling(pixmap),
+ sna_pixmap_choose_tiling(pixmap, DEFAULT_TILING),
CREATE_GTT_MAP | CREATE_INACTIVE);
return priv->gpu_bo && kgem_bo_is_mappable(&sna->kgem, priv->gpu_bo);
@@ -1396,7 +1400,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
}
if (priv->gpu_bo == NULL && priv->stride &&
- sna_pixmap_choose_tiling(pixmap) != I915_TILING_NONE &&
+ sna_pixmap_choose_tiling(pixmap, DEFAULT_TILING) != I915_TILING_NONE &&
region_inplace(sna, pixmap, region, priv) &&
sna_pixmap_create_mappable_gpu(pixmap)) {
pixmap->devPrivate.ptr =
@@ -1833,7 +1837,7 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box, unsigned int flags)
}
if (priv->gpu_bo == NULL) {
- unsigned create;
+ unsigned create, tiling;
create = 0;
if (priv->cpu_damage)
@@ -1841,11 +1845,14 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box, unsigned int flags)
if (pixmap->usage_hint == SNA_CREATE_FB)
create |= CREATE_EXACT | CREATE_SCANOUT;
+ tiling = (flags & MOVE_SOURCE_HINT) ? I915_TILING_Y : DEFAULT_TILING;
+
priv->gpu_bo = kgem_create_2d(&sna->kgem,
pixmap->drawable.width,
pixmap->drawable.height,
pixmap->drawable.bitsPerPixel,
- sna_pixmap_choose_tiling(pixmap),
+ sna_pixmap_choose_tiling(pixmap,
+ tiling),
create);
if (priv->gpu_bo == NULL)
return false;
@@ -2307,7 +2314,8 @@ sna_pixmap_force_to_gpu(PixmapPtr pixmap, unsigned flags)
pixmap->drawable.width,
pixmap->drawable.height,
pixmap->drawable.bitsPerPixel,
- sna_pixmap_choose_tiling(pixmap),
+ sna_pixmap_choose_tiling(pixmap,
+ DEFAULT_TILING),
mode);
if (priv->gpu_bo == NULL)
return NULL;
@@ -2401,7 +2409,8 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
pixmap->drawable.width,
pixmap->drawable.height,
pixmap->drawable.bitsPerPixel,
- sna_pixmap_choose_tiling(pixmap),
+ sna_pixmap_choose_tiling(pixmap,
+ DEFAULT_TILING),
(priv->cpu_damage && priv->cpu_bo == NULL) ? CREATE_GTT_MAP | CREATE_INACTIVE : 0);
}
if (priv->gpu_bo == NULL) {
@@ -3387,7 +3396,7 @@ move_to_gpu(PixmapPtr pixmap, struct sna_pixmap *priv,
return FALSE;
if (priv->cpu_bo) {
- if (sna_pixmap_choose_tiling(pixmap) == I915_TILING_NONE)
+ if (sna_pixmap_choose_tiling(pixmap, DEFAULT_TILING) == I915_TILING_NONE)
return FALSE;
return (priv->source_count++-SOURCE_BIAS) * w*h >=
@@ -3636,7 +3645,8 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
if (dst_priv->gpu_bo == NULL &&
((dst_priv->cpu_damage == NULL && copy_use_gpu_bo(sna, dst_priv, &region)) ||
(src_priv && (src_priv->gpu_bo != NULL || (src_priv->cpu_bo && kgem_bo_is_busy(src_priv->cpu_bo)))))) {
- uint32_t tiling = sna_pixmap_choose_tiling(dst_pixmap);
+ uint32_t tiling = sna_pixmap_choose_tiling(dst_pixmap,
+ DEFAULT_TILING);
DBG(("%s: create dst GPU bo for upload\n", __FUNCTION__));
@@ -12362,7 +12372,6 @@ Bool sna_accel_init(ScreenPtr screen, struct sna *sna)
backend = "no";
sna->have_render = false;
- sna->default_tiling = I915_TILING_X;
no_render_init(sna);
#if !DEBUG_NO_RENDER
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index e28823f3..8d61f401 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -388,49 +388,38 @@ move_to_gpu(PixmapPtr pixmap, const BoxRec *box)
}
if (DBG_FORCE_UPLOAD < 0)
- migrate = true;
+ return sna_pixmap_force_to_gpu(pixmap,
+ MOVE_SOURCE_HINT | MOVE_READ);
w = box->x2 - box->x1;
h = box->y2 - box->y1;
if (w == pixmap->drawable.width && h == pixmap->drawable.height) {
- migrate = true;
- if ((priv->create & KGEM_CAN_CREATE_GPU) == 0 ||
- kgem_choose_tiling(&to_sna_from_pixmap(pixmap)->kgem,
- I915_TILING_Y,
- pixmap->drawable.width,
- pixmap->drawable.height,
- pixmap->drawable.bitsPerPixel) == I915_TILING_NONE)
- migrate = priv->source_count++ > SOURCE_BIAS;
+ migrate = priv->source_count++ > SOURCE_BIAS;
DBG(("%s: migrating whole pixmap (%dx%d) for source (%d,%d),(%d,%d), count %d? %d\n",
__FUNCTION__,
pixmap->drawable.width, pixmap->drawable.height,
box->x1, box->y1, box->x2, box->y2, priv->source_count,
migrate));
- } else {
- /* ignore tiny fractions */
- if (64*w*h > pixmap->drawable.width * pixmap->drawable.height) {
- count = priv->source_count++;
- if ((priv->create & KGEM_CAN_CREATE_GPU) == 0 ||
- kgem_choose_tiling(&to_sna_from_pixmap(pixmap)->kgem,
- I915_TILING_Y,
- pixmap->drawable.width,
- pixmap->drawable.height,
- pixmap->drawable.bitsPerPixel) == I915_TILING_NONE)
- count -= SOURCE_BIAS;
-
- DBG(("%s: migrate box (%d, %d), (%d, %d)? source count=%d, fraction=%d/%d [%d]\n",
- __FUNCTION__,
- box->x1, box->y1, box->x2, box->y2,
- count, w*h,
- pixmap->drawable.width * pixmap->drawable.height,
- pixmap->drawable.width * pixmap->drawable.height / (w*h)));
-
- migrate = count*w*h > pixmap->drawable.width * pixmap->drawable.height;
- }
+ } else if (kgem_choose_tiling(&to_sna_from_pixmap(pixmap)->kgem,
+ I915_TILING_Y, w, h,
+ pixmap->drawable.bitsPerPixel) != I915_TILING_NONE) {
+ count = priv->source_count++;
+ if ((priv->create & KGEM_CAN_CREATE_GPU) == 0)
+ count -= SOURCE_BIAS;
+
+ DBG(("%s: migrate box (%d, %d), (%d, %d)? source count=%d, fraction=%d/%d [%d]\n",
+ __FUNCTION__,
+ box->x1, box->y1, box->x2, box->y2,
+ count, w*h,
+ pixmap->drawable.width * pixmap->drawable.height,
+ pixmap->drawable.width * pixmap->drawable.height / (w*h)));
+
+ migrate = count*w*h > pixmap->drawable.width * pixmap->drawable.height;
}
- if (migrate && !sna_pixmap_force_to_gpu(pixmap, MOVE_READ))
+ if (migrate && !sna_pixmap_force_to_gpu(pixmap,
+ MOVE_SOURCE_HINT | MOVE_READ))
return NULL;
return priv->gpu_bo;
@@ -680,7 +669,7 @@ static int sna_render_picture_downsample(struct sna *sna,
DBG(("%s: creating temporary GPU bo %dx%d\n",
__FUNCTION__, width, height));
- if (!sna_pixmap_force_to_gpu(pixmap, MOVE_READ))
+ if (!sna_pixmap_force_to_gpu(pixmap, MOVE_SOURCE_HINT | MOVE_READ))
return sna_render_picture_fixup(sna, picture, channel,
x, y, ow, oh,
dst_x, dst_y);
@@ -943,7 +932,8 @@ sna_render_picture_partial(struct sna *sna,
bo = sna_pixmap(pixmap)->cpu_bo;
} else {
- if (!sna_pixmap_force_to_gpu(pixmap, MOVE_READ))
+ if (!sna_pixmap_force_to_gpu(pixmap,
+ MOVE_SOURCE_HINT | MOVE_READ))
return 0;
bo = sna_pixmap(pixmap)->gpu_bo;