summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-05-03 11:00:30 +0100
committerDave Airlie <airlied@redhat.com>2012-05-03 11:43:19 +0100
commita6172c86abf118e59c9e07d59a320252f94f2321 (patch)
tree2afa74768e6b25ec6b5be12adad39d61ed388275
parent812609a7041a7f55023f704211c10364614c3270 (diff)
exa: add pixmap sharing support
-rw-r--r--src/nouveau_exa.c38
-rw-r--r--src/nv_type.h1
2 files changed, 39 insertions, 0 deletions
diff --git a/src/nouveau_exa.c b/src/nouveau_exa.c
index 7b3b086..a756e89 100644
--- a/src/nouveau_exa.c
+++ b/src/nouveau_exa.c
@@ -145,6 +145,42 @@ nouveau_exa_destroy_pixmap(ScreenPtr pScreen, void *priv)
free(nvpix);
}
+static Bool
+nouveau_exa_share_pixmap_backing(PixmapPtr ppix, int *handle_p)
+{
+ struct nouveau_bo *bo = nouveau_pixmap_bo(ppix);
+ struct nouveau_pixmap *nvpix = nouveau_pixmap(ppix);
+ int ret;
+
+ ret = nouveau_bo_set_prime(bo, handle_p);
+ if (ret != 0) {
+ ErrorF("%s: ret is %d errno is %d\n", __func__, ret, errno);
+ return FALSE;
+ }
+ nvpix->shared = TRUE;
+ return TRUE;
+}
+
+static Bool
+nouveau_exa_set_shared_pixmap_backing(PixmapPtr ppix, int handle)
+{
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(ppix->drawable.pScreen);
+ NVPtr pNv = NVPTR(pScrn);
+ struct nouveau_bo *bo = nouveau_pixmap_bo(ppix);
+ struct nouveau_pixmap *nvpix = nouveau_pixmap(ppix);
+ int ret;
+
+ ret = nouveau_bo_prime_handle_ref(pNv->dev, handle, &bo);
+ if (ret) {
+ ErrorF("failed to get BO with handle %d\n", handle);
+ return FALSE;
+ }
+ nvpix->bo = bo;
+ nvpix->shared = TRUE;
+ close(handle);
+ return TRUE;
+}
+
bool
nv50_style_tiled_pixmap(PixmapPtr ppix)
{
@@ -345,6 +381,8 @@ nouveau_exa_init(ScreenPtr pScreen)
exa->CreatePixmap2 = nouveau_exa_create_pixmap;
exa->DestroyPixmap = nouveau_exa_destroy_pixmap;
+ exa->SharePixmapBacking = nouveau_exa_share_pixmap_backing;
+ exa->SetSharedPixmapBacking = nouveau_exa_set_shared_pixmap_backing;
if (pNv->Architecture >= NV_ARCH_50) {
exa->maxX = 8192;
diff --git a/src/nv_type.h b/src/nv_type.h
index 49150ba..43f146b 100644
--- a/src/nv_type.h
+++ b/src/nv_type.h
@@ -161,6 +161,7 @@ struct nouveau_pixmap {
struct nouveau_bo *bo;
void *linear;
unsigned size;
+ Bool shared;
};
static inline struct nouveau_pixmap *