[PATCH] DRI2: use ConfigNotify to re-allocate buffers if root window changes
Jesse Barnes
jbarnes at virtuousgeek.org
Thu Jul 8 14:55:34 PDT 2010
On Thu, 08 Jul 2010 14:19:23 -0700
Keith Packard <keithp at keithp.com> wrote:
> On Thu, 8 Jul 2010 14:06:01 -0700, Jesse Barnes <jbarnes at virtuousgeek.org> wrote:
> > Ok, back to tracking serials then.
> >
> > Unfortunately, using the pixmap serial for windows doesn't actually fix
> > this bug. See below, maybe something is wrong with my
> > DRI2DrawableSerial function. Using the drawable serial unconditionally
> > lets things work (just like the old patch).
>
> I'm betting the screen pixmap serial doesn't get bumped when it gets
> resized. Fixing ModifyPixmapHeader might help here?
Ah yep, looks like that was it. Fixed patch below. Kristian and
Keith, if it looks ok I'll resubmit with changelog and your reviewed-by
tags.
Thanks,
--
Jesse Barnes, Intel Open Source Technology Center
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index f9ba8e7..34f735f 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -82,6 +82,7 @@ typedef struct _DRI2Drawable {
CARD64 last_swap_msc; /* msc at completion of most recent swap */
CARD64 last_swap_ust; /* ust at completion of most recent swap */
int swap_limit; /* for N-buffering */
+ unsigned long serialNumber;
} DRI2DrawableRec, *DRI2DrawablePtr;
typedef struct _DRI2Screen {
@@ -130,6 +131,19 @@ DRI2GetDrawable(DrawablePtr pDraw)
}
}
+static unsigned long
+DRI2DrawableSerial(DrawablePtr pDraw)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ PixmapPtr pPix;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return pDraw->serialNumber;
+
+ pPix = pScreen->GetWindowPixmap((WindowPtr)pDraw);
+ return pPix->drawable.serialNumber;
+}
+
static DRI2DrawablePtr
DRI2AllocateDrawable(DrawablePtr pDraw)
{
@@ -163,6 +177,7 @@ DRI2AllocateDrawable(DrawablePtr pDraw)
pPriv->last_swap_msc = 0;
pPriv->last_swap_ust = 0;
list_init(&pPriv->reference_list);
+ pPriv->serialNumber = DRI2DrawableSerial(pDraw);
if (pDraw->type == DRAWABLE_WINDOW) {
pWin = (WindowPtr) pDraw;
@@ -326,6 +341,7 @@ allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
|| !dimensions_match
|| (pPriv->buffers[old_buf]->format != format)) {
*buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
+ pPriv->serialNumber = DRI2DrawableSerial(pDraw);
return TRUE;
} else {
@@ -384,7 +400,8 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
}
dimensions_match = (pDraw->width == pPriv->width)
- && (pDraw->height == pPriv->height);
+ && (pDraw->height == pPriv->height)
+ && (pPriv->serialNumber == DRI2DrawableSerial(pDraw));
buffers = malloc((count + 1) * sizeof(buffers[0]));
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index ea2a0c1..661ecb2 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -76,7 +76,6 @@ miModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
pPixmap->drawable.depth = depth;
pPixmap->drawable.bitsPerPixel = bitsPerPixel;
pPixmap->drawable.id = 0;
- pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pPixmap->drawable.x = 0;
pPixmap->drawable.y = 0;
pPixmap->drawable.width = width;
@@ -116,6 +115,7 @@ miModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
if (pPixData)
pPixmap->devPrivate.ptr = pPixData;
}
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
return TRUE;
}
More information about the xorg-devel
mailing list