summaryrefslogtreecommitdiff
path: root/src/amdgpu_dri2.c
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2016-06-08 16:44:26 +0900
committerMichel Dänzer <michel@daenzer.net>2016-06-14 18:25:16 +0900
commit5518bf5d793439b5bab369e5fc18de9a4a3b9dd6 (patch)
tree4217b941b234d6baf46d7ee5ce32420bbfd8604b /src/amdgpu_dri2.c
parent641f4647b7f51dfd2da330376cd10fa9702b6423 (diff)
Move DRI2's local fixup_glamor helper to amdgpu_glamor_set_pixmap_bo v2
So it can be used outside of the DRI2 code. v2: Keep pixmap refcnt increment in amdgpu_dri2_create_buffer2 (Qiang Yu) Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Tested-by: Qiang Yu <qiang.yu@amd.com> (v1)
Diffstat (limited to 'src/amdgpu_dri2.c')
-rw-r--r--src/amdgpu_dri2.c54
1 files changed, 4 insertions, 50 deletions
diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index 5f978c9..9cdcf28 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,
@@ -217,8 +169,10 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen,
goto error;
if (pixmap) {
- if (is_glamor_pixmap)
- pixmap = fixup_glamor(drawable, pixmap);
+ if (is_glamor_pixmap) {
+ pixmap = amdgpu_glamor_set_pixmap_bo(drawable, pixmap);
+ pixmap->refcnt++;
+ }
if (!amdgpu_get_flink_name(pAMDGPUEnt, pixmap, &buffers->name))
goto error;