diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2016-09-12 18:12:06 +0900 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2016-09-14 16:30:39 +0900 |
commit | b3e5259e60157fdbdf46ee59b1b78995c2b15f72 (patch) | |
tree | 7deb7528336bb8714de1c7054be3c27713a0975b /src | |
parent | 38632bbd5ff80a9cf8ce584b2bc499d17d15befe (diff) |
Move DRI2's local fixup_glamor helper to radeon_glamor_set_pixmap_bo
So it can be used outside of the DRI2 code.
(Ported from amdgpu commit 5518bf5d793439b5bab369e5fc18de9a4a3b9dd6)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/radeon_dri2.c | 59 | ||||
-rw-r--r-- | src/radeon_glamor.c | 48 | ||||
-rw-r--r-- | src/radeon_glamor.h | 2 |
3 files changed, 53 insertions, 56 deletions
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 069e4462..74d580ab 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -78,60 +78,6 @@ static DevPrivateKeyRec dri2_window_private_key_rec; dixLookupPrivate(&(window)->devPrivates, dri2_window_private_key)) -static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap) -{ - PixmapPtr old = get_drawable_pixmap(drawable); -#ifdef USE_GLAMOR - ScreenPtr screen = drawable->pScreen; - struct radeon_pixmap *priv = radeon_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); - } - - radeon_set_pixmap_private(pixmap, NULL); - - /* And redirect the pixmap to the new bo (for 3D). */ - glamor_egl_exchange_buffers(old, pixmap); - radeon_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); - -#endif /* USE_GLAMOR*/ - - return old; -} - /* Get GEM flink name for a pixmap */ static Bool radeon_get_flink_name(RADEONInfoPtr info, PixmapPtr pixmap, uint32_t *name) @@ -301,10 +247,11 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen, /* this happen if pixmap is non accelerable */ goto error; } + } else if (is_glamor_pixmap) { + pixmap = radeon_glamor_set_pixmap_bo(drawable, pixmap); + pixmap->refcnt++; } - if (is_glamor_pixmap) - pixmap = fixup_glamor(drawable, pixmap); if (!radeon_get_flink_name(info, pixmap, &buffers->name)) goto error; } diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index 5c4191b5..f46e8bad 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -283,6 +283,54 @@ fallback_pixmap: return fbCreatePixmap(screen, w, h, depth, usage); } +PixmapPtr +radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap) +{ + PixmapPtr old = get_drawable_pixmap(drawable); + ScreenPtr screen = drawable->pScreen; + struct radeon_pixmap *priv = radeon_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); + } + + radeon_set_pixmap_private(pixmap, NULL); + + /* And redirect the pixmap to the new bo (for 3D). */ + glamor_egl_exchange_buffers(old, pixmap); + radeon_set_pixmap_private(old, priv); + + screen->ModifyPixmapHeader(old, + old->drawable.width, + old->drawable.height, + 0, 0, pixmap->devKind, NULL); + old->devPrivate.ptr = NULL; + + screen->DestroyPixmap(pixmap); + + return old; +} + #ifdef RADEON_PIXMAP_SHARING static Bool diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index 75129f8c..fdc4e577 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -71,6 +71,7 @@ void radeon_glamor_free_screen(int scrnIndex, int flags); Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv); void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst); +PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap); XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt); @@ -85,6 +86,7 @@ static inline void radeon_glamor_free_screen(int scrnIndex, int flags) { } static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv) { return TRUE; } static inline void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {} +static inline PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap) { return pixmap; } static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap) { return NULL; } |