[PATCH xf86-video-amdgpu 5/6] Move DRI2's local fixup_glamor helper to amdgpu_glamor_set_pixmap_bo
Yu, Qiang
Qiang.Yu at amd.com
Sun Jun 12 09:57:40 UTC 2016
Hi Michel,
Grep [yuq].
Regards,
Qiang
________________________________
From: Michel Dänzer <michel at daenzer.net>
Sent: Wednesday, June 8, 2016 4:45 PM
To: xorg-driver-ati at lists.x.org
Cc: Yu, Qiang
Subject: [PATCH xf86-video-amdgpu 5/6] Move DRI2's local fixup_glamor helper to amdgpu_glamor_set_pixmap_bo
From: Michel Dänzer <michel.daenzer at amd.com>
So it can be used outside of the DRI2 code.
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
src/amdgpu_dri2.c | 50 +-------------------------------------------------
src/amdgpu_glamor.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
src/amdgpu_glamor.h | 1 +
3 files changed, 51 insertions(+), 49 deletions(-)
diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index 5f978c9..ec63904 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -98,54 +98,6 @@ amdgpu_get_flink_name(AMDGPUEntPtr pAMDGPUEnt, PixmapPtr pixmap, uint32_t *name)
return TRUE;
}
-static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
-{
- PixmapPtr old = get_drawable_pixmap(drawable);
- ScreenPtr screen = drawable->pScreen;
- struct amdgpu_pixmap *priv = amdgpu_get_pixmap_private(pixmap);
- GCPtr gc;
-
- /* With a glamor pixmap, 2D pixmaps are created in texture
- * and without a static BO attached to it. To support DRI,
- * we need to create a new textured-drm pixmap and
- * need to copy the original content to this new textured-drm
- * pixmap, and then convert the old pixmap to a coherent
- * textured-drm pixmap which has a valid BO attached to it
- * and also has a valid texture, thus both glamor and DRI2
- * can access it.
- *
- */
-
- /* Copy the current contents of the pixmap to the bo. */
- gc = GetScratchGC(drawable->depth, screen);
- if (gc) {
- ValidateGC(&pixmap->drawable, gc);
- gc->ops->CopyArea(&old->drawable, &pixmap->drawable,
- gc,
- 0, 0,
- old->drawable.width,
- old->drawable.height, 0, 0);
- FreeScratchGC(gc);
- }
-
- amdgpu_set_pixmap_private(pixmap, NULL);
-
- /* And redirect the pixmap to the new bo (for 3D). */
- glamor_egl_exchange_buffers(old, pixmap);
- amdgpu_set_pixmap_private(old, priv);
- old->refcnt++;
-
- screen->ModifyPixmapHeader(old,
- old->drawable.width,
- old->drawable.height,
- 0, 0, pixmap->devKind, NULL);
- old->devPrivate.ptr = NULL;
-
- screen->DestroyPixmap(pixmap);
-
- return old;
-}
-
static BufferPtr
amdgpu_dri2_create_buffer2(ScreenPtr pScreen,
DrawablePtr drawable,
@@ -218,7 +170,7 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen,
if (pixmap) {
if (is_glamor_pixmap)
- pixmap = fixup_glamor(drawable, pixmap);
+ pixmap = amdgpu_glamor_set_pixmap_bo(drawable, pixmap);
if (!amdgpu_get_flink_name(pAMDGPUEnt, pixmap, &buffers->name))
goto error;
diff --git a/src/amdgpu_glamor.c b/src/amdgpu_glamor.c
index b6ec98f..1159e29 100644
--- a/src/amdgpu_glamor.c
+++ b/src/amdgpu_glamor.c
@@ -272,6 +272,55 @@ fallback_pixmap:
return fbCreatePixmap(screen, w, h, depth, usage);
}
+PixmapPtr
+amdgpu_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap)
+{
+ PixmapPtr old = get_drawable_pixmap(drawable);
+ ScreenPtr screen = drawable->pScreen;
+ struct amdgpu_pixmap *priv = amdgpu_get_pixmap_private(pixmap);
+ GCPtr gc;
+
+ /* With a glamor pixmap, 2D pixmaps are created in texture
+ * and without a static BO attached to it. To support DRI,
+ * we need to create a new textured-drm pixmap and
+ * need to copy the original content to this new textured-drm
+ * pixmap, and then convert the old pixmap to a coherent
+ * textured-drm pixmap which has a valid BO attached to it
+ * and also has a valid texture, thus both glamor and DRI2
+ * can access it.
+ *
+ */
+
+ /* Copy the current contents of the pixmap to the bo. */
+ gc = GetScratchGC(drawable->depth, screen);
+ if (gc) {
+ ValidateGC(&pixmap->drawable, gc);
+ gc->ops->CopyArea(&old->drawable, &pixmap->drawable,
+ gc,
+ 0, 0,
+ old->drawable.width,
+ old->drawable.height, 0, 0);
+ FreeScratchGC(gc);
+ }
+
+ amdgpu_set_pixmap_private(pixmap, NULL);
+
+ /* And redirect the pixmap to the new bo (for 3D). */
+ glamor_egl_exchange_buffers(old, pixmap);
+ amdgpu_set_pixmap_private(old, priv);
[yuq] this set the old pixmap with new priv, but the old priv is not freed. We can
also switch the priv to make it freed in the DestroyPixmap callback.
+ old->refcnt++;
[yuq] Why increase the refcnt of the old pixmap?
+
+ screen->ModifyPixmapHeader(old,
+ old->drawable.width,
+ old->drawable.height,
+ 0, 0, pixmap->devKind, NULL);
+ old->devPrivate.ptr = NULL;
+
+ screen->DestroyPixmap(pixmap);
+
+ return old;
+}
+
#ifdef AMDGPU_PIXMAP_SHARING
static Bool
diff --git a/src/amdgpu_glamor.h b/src/amdgpu_glamor.h
index 77e0c21..05ca5cf 100644
--- a/src/amdgpu_glamor.h
+++ b/src/amdgpu_glamor.h
@@ -71,6 +71,7 @@ void amdgpu_glamor_finish(ScrnInfoPtr pScrn);
Bool
amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap, struct amdgpu_pixmap *priv);
void amdgpu_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst);
+PixmapPtr amdgpu_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap);
XF86VideoAdaptorPtr amdgpu_glamor_xv_init(ScreenPtr pScreen, int num_adapt);
--
2.8.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg-driver-ati/attachments/20160612/8c2dd997/attachment.html>
More information about the xorg-driver-ati
mailing list