diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-03 16:48:52 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-01-03 21:35:03 +0000 |
commit | 5576afc7d12ec0f028e416f4b4a076fc6d3c29d9 (patch) | |
tree | 8a30d275f067b241ea8dc949169ada94ac580999 /src/sna/sna_accel.c | |
parent | b2dc17678fa3a548be61e1055d4d321dbd6494c3 (diff) |
sna: Inline checks for over-sized buffers during pixmap creation
Make the tests for acceptable GPU pixmaps explicit and upfront.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_accel.c')
-rw-r--r-- | src/sna/sna_accel.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index e2e90c1e..f4f3521b 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -556,6 +556,7 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, int width, int height, int depth, unsigned int usage) { + struct sna *sna = to_sna_from_screen(screen); PixmapPtr pixmap; int pad, size; @@ -568,7 +569,7 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, width, height, depth, I915_TILING_X); #else - return create_pixmap(to_sna_from_screen(screen), screen, + return create_pixmap(sna, screen, width, height, depth, usage); #endif @@ -583,22 +584,26 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, width, height, depth, I915_TILING_X); + if (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE || + !kgem_can_create_2d(&sna->kgem, width, height, + BitsPerPixel(depth), I915_TILING_NONE)) + return create_pixmap(sna, screen, width, height, depth, usage); + #if FAKE_CREATE_PIXMAP_USAGE_SCRATCH_HEADER if (width == 0 || height == 0) - usage = CREATE_PIXMAP_USAGE_SCRATCH_HEADER; + return create_pixmap(sna, screen, width, height, depth, usage); #endif pad = PixmapBytePad(width, depth); size = pad * height; if (size <= 4096) { - pixmap = create_pixmap(to_sna_from_screen(screen), screen, + pixmap = create_pixmap(sna, screen, width, height, depth, usage); if (pixmap == NullPixmap) return NullPixmap; sna_pixmap_attach(pixmap); } else { - struct sna *sna = to_sna_from_screen(screen); struct sna_pixmap *priv; pixmap = create_pixmap(sna, screen, 0, 0, depth, usage); @@ -610,12 +615,11 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, pixmap->devKind = pad; pixmap->devPrivate.ptr = NULL; - priv = sna_pixmap_attach(pixmap); + priv = _sna_pixmap_attach(sna, pixmap); if (priv == NULL) { free(pixmap); return create_pixmap(sna, screen, - width, height, depth, - usage); + width, height, depth, usage); } priv->stride = pad; |