[PATCH] exa: fix CreatePixmap2 to be useful for tiling.
Dave Airlie
airlied at redhat.com
Mon Aug 10 22:13:01 PDT 2009
This adds a pitch return so that the driver can align the pitch to any
value it wishes and not just the one it gave to EXA at startup.
---
exa/exa.h | 6 ++++--
exa/exa_driver.c | 31 +++++++++++++++++--------------
exa/exa_migration_mixed.c | 16 +++++++++-------
3 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/exa/exa.h b/exa/exa.h
index 46d12b7..9c3e8d7 100644
--- a/exa/exa.h
+++ b/exa/exa.h
@@ -707,9 +707,11 @@ typedef struct _ExaDriver {
Bool (*ModifyPixmapHeader)(PixmapPtr pPixmap, int width, int height,
int depth, int bitsPerPixel, int devKind,
pointer pPixData);
-
+
+ /* if the driver is going to tile the buffer it may need to adjust the pitch alignment */
void *(*CreatePixmap2)(ScreenPtr pScreen, int width, int height,
- int depth, int usage_hint, int bitsPerPixel);
+ int depth, int usage_hint, int bitsPerPixel,
+ int *new_fb_pitch);
/** @} */
} ExaDriverRec, *ExaDriverPtr;
diff --git a/exa/exa_driver.c b/exa/exa_driver.c
index b4ca426..25aab29 100644
--- a/exa/exa_driver.c
+++ b/exa/exa_driver.c
@@ -71,26 +71,29 @@ exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth,
bpp = pPixmap->drawable.bitsPerPixel;
- paddedWidth = ((w * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
- if (paddedWidth / 4 > 32767 || h > 32767)
- return NullPixmap;
-
- exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp);
-
- if (paddedWidth < pExaPixmap->fb_pitch)
- paddedWidth = pExaPixmap->fb_pitch;
-
- datasize = h * paddedWidth;
-
/* Set this before driver hooks, to allow for !offscreen pixmaps.
* !offscreen pixmaps have a valid pointer at all times.
*/
pPixmap->devPrivate.ptr = NULL;
- if (pExaScr->info->CreatePixmap2)
- pExaPixmap->driverPriv = pExaScr->info->CreatePixmap2(pScreen, w, h, depth, usage_hint, bpp);
- else
+ if (pExaScr->info->CreatePixmap2) {
+ int new_pitch = 0;
+ pExaPixmap->driverPriv = pExaScr->info->CreatePixmap2(pScreen, w, h, depth, usage_hint, bpp, &new_pitch);
+ paddedWidth = pExaPixmap->fb_pitch = new_pitch;
+ }
+ else {
+ paddedWidth = ((w * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
+ if (paddedWidth / 4 > 32767 || h > 32767)
+ return NullPixmap;
+
+ exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp);
+
+ if (paddedWidth < pExaPixmap->fb_pitch)
+ paddedWidth = pExaPixmap->fb_pitch;
+ datasize = h * paddedWidth;
pExaPixmap->driverPriv = pExaScr->info->CreatePixmap(pScreen, datasize, 0);
+ }
+
if (!pExaPixmap->driverPriv) {
swap(pExaScr, pScreen, DestroyPixmap);
pScreen->DestroyPixmap (pPixmap);
diff --git a/exa/exa_migration_mixed.c b/exa/exa_migration_mixed.c
index ed0cc14..38e67e1 100644
--- a/exa/exa_migration_mixed.c
+++ b/exa/exa_migration_mixed.c
@@ -77,8 +77,8 @@ exaCreateDriverPixmap_mixed(PixmapPtr pPixmap)
int depth = pPixmap->drawable.depth, bpp = pPixmap->drawable.bitsPerPixel;
int usage_hint = pPixmap->usage_hint;
int sys_pitch = pExaPixmap->sys_pitch;
- int paddedWidth = sys_pitch;
int nbox;
+ int paddedWidth = sys_pitch;
BoxPtr pbox;
/* Already done. */
@@ -92,13 +92,15 @@ exaCreateDriverPixmap_mixed(PixmapPtr pPixmap)
if (pExaPixmap->accel_blocked || bpp < 8)
return;
- if (paddedWidth < pExaPixmap->fb_pitch)
- paddedWidth = pExaPixmap->fb_pitch;
-
- if (pExaScr->info->CreatePixmap2)
- pExaPixmap->driverPriv = pExaScr->info->CreatePixmap2(pScreen, w, h, depth, usage_hint, bpp);
- else
+ if (pExaScr->info->CreatePixmap2) {
+ int new_pitch = 0;
+ pExaPixmap->driverPriv = pExaScr->info->CreatePixmap2(pScreen, w, h, depth, usage_hint, bpp, &new_pitch);
+ paddedWidth = pExaPixmap->fb_pitch = new_pitch;
+ } else {
+ if (paddedWidth < pExaPixmap->fb_pitch)
+ paddedWidth = pExaPixmap->fb_pitch;
pExaPixmap->driverPriv = pExaScr->info->CreatePixmap(pScreen, paddedWidth*h, 0);
+ }
if (!pExaPixmap->driverPriv)
return;
--
1.6.2.5
More information about the xorg-devel
mailing list