diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2014-06-19 14:54:20 +1000 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2014-06-19 16:03:27 +1000 |
commit | 81148bb1dbc7007c021c59411d56cb31cfc74ef2 (patch) | |
tree | e761f9ae198df5b7a312f56082e5f22b8f5c195e | |
parent | 86024ceef015ffe31a204cc5bc6c326a19363ff1 (diff) | |
download | xorg-driver-xf86-video-nouveau-81148bb1dbc7007c021c59411d56cb31cfc74ef2.tar.gz |
glamor: provide dri3 support when enabled
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/nouveau_glamor.c | 3 | ||||
-rw-r--r-- | src/nouveau_sync.c | 117 | ||||
-rw-r--r-- | src/nouveau_sync.h | 34 | ||||
-rw-r--r-- | src/nv_driver.c | 3 | ||||
-rw-r--r-- | src/nv_type.h | 3 |
6 files changed, 160 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 9fe8000..a787db0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -37,6 +37,7 @@ nouveau_drv_la_SOURCES = \ nouveau_exa.c nouveau_xv.c nouveau_dri2.c \ nouveau_glamor.c \ nouveau_wfb.c \ + nouveau_sync.c \ nv_accel_common.c \ nv_driver.c \ nv_shadow.c \ @@ -122,6 +123,7 @@ EXTRA_DIST = hwdefs/nv_3ddefs.xml.h \ nouveau_local.h \ nouveau_copy.h \ nouveau_glamor.h \ + nouveau_sync.h \ nv_const.h \ nv_dma.h \ nv_include.h \ diff --git a/src/nouveau_glamor.c b/src/nouveau_glamor.c index 688fc76..db5a00e 100644 --- a/src/nouveau_glamor.c +++ b/src/nouveau_glamor.c @@ -210,8 +210,7 @@ nouveau_glamor_init(ScreenPtr screen) if (!glamor_init(screen, GLAMOR_INVERTED_Y_AXIS | GLAMOR_USE_EGL_SCREEN | GLAMOR_USE_SCREEN | - GLAMOR_USE_PICTURE_SCREEN | - GLAMOR_NO_DRI3)) { + GLAMOR_USE_PICTURE_SCREEN)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "[GLAMOR] failed to initialise\n"); return FALSE; diff --git a/src/nouveau_sync.c b/src/nouveau_sync.c new file mode 100644 index 0000000..95fa82c --- /dev/null +++ b/src/nouveau_sync.c @@ -0,0 +1,117 @@ +/* + * Copyright © 2013-2014 Intel Corporation + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "nouveau_sync.h" +#ifdef DRI3 +#include "nv_include.h" + +static DevPrivateKeyRec nouveau_syncobj_key; + +struct nouveau_syncobj { + SyncFenceSetTriggeredFunc SetTriggered; +}; + +#define nouveau_syncobj(fence) \ + dixLookupPrivate(&(fence)->devPrivates, &nouveau_syncobj_key) + +struct nouveau_syncctx { + SyncScreenCreateFenceFunc CreateFence; +}; + +#define nouveau_syncctx(screen) ({ \ + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); \ + NVPtr pNv = NVPTR(scrn); \ + pNv->sync; \ +}) + +static void +nouveau_syncobj_flush(SyncFence *fence) +{ + struct nouveau_syncobj *pobj = nouveau_syncobj(fence); + ScrnInfoPtr scrn = xf86ScreenToScrn(fence->pScreen); + NVPtr pNv = NVPTR(scrn); + SyncFenceFuncsPtr func = &fence->funcs; + + if (pNv->Flush) + pNv->Flush(scrn); + + swap(pobj, func, SetTriggered); + func->SetTriggered(fence); + swap(pobj, func, SetTriggered); +} + +static void +nouveau_syncobj_new(ScreenPtr screen, SyncFence *fence, Bool triggered) +{ + struct nouveau_syncctx *priv = nouveau_syncctx(screen); + struct nouveau_syncobj *pobj = nouveau_syncobj(fence); + SyncScreenFuncsPtr sync = miSyncGetScreenFuncs(screen); + SyncFenceFuncsPtr func = &fence->funcs; + + swap(priv, sync, CreateFence); + sync->CreateFence(screen, fence, triggered); + swap(priv, sync, CreateFence); + + wrap(pobj, func, SetTriggered, nouveau_syncobj_flush); +} + +void +nouveau_sync_fini(ScreenPtr screen) +{ + struct nouveau_syncctx *priv = nouveau_syncctx(screen); + SyncScreenFuncsPtr sync = miSyncGetScreenFuncs(screen); + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + NVPtr pNv = NVPTR(scrn); + + unwrap(priv, sync, CreateFence); + + pNv->sync = NULL; + free(priv); +} + +Bool +nouveau_sync_init(ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + NVPtr pNv = NVPTR(scrn); + struct nouveau_syncctx *priv; + SyncScreenFuncsPtr sync; + + priv = pNv->sync = calloc(1, sizeof(*priv)); + if (!priv) + return FALSE; + + if (!miSyncShmScreenInit(screen)) + return FALSE; + + if (!dixPrivateKeyRegistered(&nouveau_syncobj_key)) { + if (!dixRegisterPrivateKey(&nouveau_syncobj_key, + PRIVATE_SYNC_FENCE, + sizeof(struct nouveau_syncobj))) + return FALSE; + } + + sync = miSyncGetScreenFuncs(screen); + wrap(priv, sync, CreateFence, nouveau_syncobj_new); + return TRUE; +} +#endif diff --git a/src/nouveau_sync.h b/src/nouveau_sync.h new file mode 100644 index 0000000..2d72b3b --- /dev/null +++ b/src/nouveau_sync.h @@ -0,0 +1,34 @@ +#ifndef __NOUVEAU_SYNC_H__ +#define __NOUVEAU_SYNC_H__ + +#include "xorg-server.h" + +#ifdef DRI3 +#include "scrnintstr.h" +#include "misync.h" +#include "misyncshm.h" +#include "misyncstr.h" + +#define wrap(priv, parn, name, func) { \ + priv->name = parn->name; \ + parn->name = func; \ +} + +#define unwrap(priv, parn, name) { \ + if (priv && priv->name) \ + parn->name = priv->name; \ +} + +#define swap(priv, parn, name) { \ + void *tmp = priv->name; \ + priv->name = parn->name; \ + parn->name = tmp; \ +} + +Bool nouveau_sync_init(ScreenPtr pScreen); +void nouveau_sync_fini(ScreenPtr pScreen); +#else +static inline Bool nouveau_sync_init(ScreenPtr pScreen) { return FALSE; } +static inline void nouveau_sync_fini(ScreenPtr pScreen) { } +#endif +#endif diff --git a/src/nv_driver.c b/src/nv_driver.c index 9396958..9d202b8 100644 --- a/src/nv_driver.c +++ b/src/nv_driver.c @@ -34,6 +34,7 @@ #include "nouveau_copy.h" #include "nouveau_glamor.h" +#include "nouveau_sync.h" /* * Forward definitions for the functions that make up the driver. @@ -620,6 +621,7 @@ NVCloseScreen(CLOSE_SCREEN_ARGS_DECL) drmmode_screen_fini(pScreen); nouveau_dri2_fini(pScreen); + nouveau_sync_fini(pScreen); nouveau_copy_fini(pScreen); if (pScrn->vtSema) { @@ -1316,6 +1318,7 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL) } nouveau_copy_init(pScreen); + nouveau_sync_init(pScreen); nouveau_dri2_init(pScreen); /* Allocate and map memory areas we need */ diff --git a/src/nv_type.h b/src/nv_type.h index 263da91..6485ee0 100644 --- a/src/nv_type.h +++ b/src/nv_type.h @@ -125,6 +125,9 @@ typedef struct _NVRec { struct nouveau_bo *, uint32_t, int, int, int, int, int, struct nouveau_bo *, uint32_t, int, int, int, int, int); + /* SYNC extension private */ + void *sync; + /* Acceleration context */ PixmapPtr pspix, pmpix, pdpix; PicturePtr pspict, pmpict; |