[RFC xserver 02/12] sync: Move fence destroy call to object specific function
Louis-Francis Ratté-Boulianne
lfrb at collabora.com
Wed Aug 30 05:16:51 UTC 2017
Needed so multiple types of sync fences can exist (SHM and DMA).
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
---
miext/sync/misync.c | 25 +++++++++++++++----------
miext/sync/misync.h | 10 +++++-----
miext/sync/misyncshm.c | 30 +++++++++++++++---------------
3 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/miext/sync/misync.c b/miext/sync/misync.c
index 3d03d1b59..5c26ae1d1 100644
--- a/miext/sync/misync.c
+++ b/miext/sync/misync.c
@@ -41,11 +41,10 @@ miSyncScreenCreateFence(ScreenPtr pScreen, SyncFence * pFence,
pFence->triggered = initially_triggered;
}
-void
-miSyncScreenDestroyFence(ScreenPtr pScreen, SyncFence * pFence)
+int
+miSyncGetFenceType(SyncFence *pFence)
{
- (void) pScreen;
- (void) pFence;
+ return pFence->type;
}
/* Default implementations of the per-object functions */
@@ -83,6 +82,14 @@ miSyncFenceDeleteTrigger(SyncTrigger * pTrigger)
return;
}
+void
+miSyncFenceDestroy(SyncFence * pFence)
+{
+ (void) pFence;
+
+ return;
+}
+
/* Machine independent portion of the fence sync object implementation */
void
miSyncInitFence(ScreenPtr pScreen, SyncFence * pFence, Bool initially_triggered)
@@ -94,7 +101,8 @@ miSyncInitFence(ScreenPtr pScreen, SyncFence * pFence, Bool initially_triggered)
&miSyncFenceReset,
&miSyncFenceCheckTriggered,
&miSyncFenceAddTrigger,
- &miSyncFenceDeleteTrigger
+ &miSyncFenceDeleteTrigger,
+ &miSyncFenceDestroy
};
pFence->pScreen = pScreen;
@@ -106,8 +114,6 @@ miSyncInitFence(ScreenPtr pScreen, SyncFence * pFence, Bool initially_triggered)
void
miSyncDestroyFence(SyncFence * pFence)
{
- ScreenPtr pScreen = pFence->pScreen;
- SyncScreenPrivPtr pScreenPriv = SYNC_SCREEN_PRIV(pScreen);
SyncTriggerList *ptl, *pNext;
pFence->sync.beingDestroyed = TRUE;
@@ -118,7 +124,7 @@ miSyncDestroyFence(SyncFence * pFence)
free(ptl); /* destroy the trigger list as we go */
}
- pScreenPriv->funcs.DestroyFence(pScreen, pFence);
+ pFence->funcs.Destroy(pFence);
dixFreeObjectWithPrivates(pFence, PRIVATE_SYNC_FENCE);
}
@@ -165,8 +171,7 @@ miSyncSetup(ScreenPtr pScreen)
SyncScreenPrivPtr pScreenPriv;
static const SyncScreenFuncsRec miSyncScreenFuncs = {
- &miSyncScreenCreateFence,
- &miSyncScreenDestroyFence
+ &miSyncScreenCreateFence
};
if (!dixPrivateKeyRegistered(&miSyncScreenPrivateKey)) {
diff --git a/miext/sync/misync.h b/miext/sync/misync.h
index dc78c5fdb..b3838f1e2 100644
--- a/miext/sync/misync.h
+++ b/miext/sync/misync.h
@@ -34,26 +34,22 @@ typedef struct _SyncTrigger SyncTrigger;
typedef void (*SyncScreenCreateFenceFunc) (ScreenPtr pScreen,
SyncFence * pFence,
Bool initially_triggered);
-typedef void (*SyncScreenDestroyFenceFunc) (ScreenPtr pScreen,
- SyncFence * pFence);
typedef struct _syncScreenFuncs {
SyncScreenCreateFenceFunc CreateFence;
- SyncScreenDestroyFenceFunc DestroyFence;
} SyncScreenFuncsRec, *SyncScreenFuncsPtr;
extern _X_EXPORT void
miSyncScreenCreateFence(ScreenPtr pScreen, SyncFence * pFence,
Bool initially_triggered);
-extern _X_EXPORT void
- miSyncScreenDestroyFence(ScreenPtr pScreen, SyncFence * pFence);
typedef void (*SyncFenceSetTriggeredFunc) (SyncFence * pFence);
typedef void (*SyncFenceResetFunc) (SyncFence * pFence);
typedef Bool (*SyncFenceCheckTriggeredFunc) (SyncFence * pFence);
typedef void (*SyncFenceAddTriggerFunc) (SyncTrigger * pTrigger);
typedef void (*SyncFenceDeleteTriggerFunc) (SyncTrigger * pTrigger);
+typedef void (*SyncFenceDestroyFunc) (SyncFence * pFence);
typedef struct _syncFenceFuncs {
SyncFenceSetTriggeredFunc SetTriggered;
@@ -61,6 +57,7 @@ typedef struct _syncFenceFuncs {
SyncFenceCheckTriggeredFunc CheckTriggered;
SyncFenceAddTriggerFunc AddTrigger;
SyncFenceDeleteTriggerFunc DeleteTrigger;
+ SyncFenceDestroyFunc Destroy;
} SyncFenceFuncsRec, *SyncFenceFuncsPtr;
extern _X_EXPORT void
@@ -91,6 +88,9 @@ miSyncFenceAddTrigger(SyncTrigger * pTrigger);
void
miSyncFenceDeleteTrigger(SyncTrigger * pTrigger);
+void
+miSyncFenceDestroy(SyncFence * pFence);
+
int
miSyncInitFenceFromFD(DrawablePtr pDraw, SyncFence *pFence, int fd, BOOL initially_triggered);
diff --git a/miext/sync/misyncshm.c b/miext/sync/misyncshm.c
index 01f82fc00..f55a3f8a5 100644
--- a/miext/sync/misyncshm.c
+++ b/miext/sync/misyncshm.c
@@ -88,12 +88,26 @@ miSyncShmFenceDeleteTrigger(SyncTrigger * pTrigger)
miSyncFenceDeleteTrigger(pTrigger);
}
+static void
+miSyncShmFenceDestroy(SyncFence * pFence)
+{
+ SyncShmFencePrivatePtr pPriv = SYNC_FENCE_PRIV(pFence);
+
+ if (pPriv->fence) {
+ xshmfence_trigger(pPriv->fence);
+ xshmfence_unmap_shm(pPriv->fence);
+ close(pPriv->fd);
+ }
+ miSyncFenceDestroy(pFence);
+}
+
static const SyncFenceFuncsRec miSyncShmFenceFuncs = {
&miSyncShmFenceSetTriggered,
&miSyncShmFenceReset,
&miSyncShmFenceCheckTriggered,
&miSyncShmFenceAddTrigger,
- &miSyncShmFenceDeleteTrigger
+ &miSyncShmFenceDeleteTrigger,
+ &miSyncShmFenceDestroy
};
static void
@@ -107,19 +121,6 @@ miSyncShmScreenCreateFence(ScreenPtr pScreen, SyncFence * pFence,
pFence->funcs = miSyncShmFenceFuncs;
}
-static void
-miSyncShmScreenDestroyFence(ScreenPtr pScreen, SyncFence * pFence)
-{
- SyncShmFencePrivatePtr pPriv = SYNC_FENCE_PRIV(pFence);
-
- if (pPriv->fence) {
- xshmfence_trigger(pPriv->fence);
- xshmfence_unmap_shm(pPriv->fence);
- close(pPriv->fd);
- }
- miSyncScreenDestroyFence(pScreen, pFence);
-}
-
static int
miSyncShmCreateFenceFromFd(ScreenPtr pScreen, SyncFence *pFence, int fd, Bool initially_triggered)
{
@@ -179,7 +180,6 @@ _X_EXPORT Bool miSyncShmScreenInit(ScreenPtr pScreen)
funcs = miSyncGetScreenFuncs(pScreen);
funcs->CreateFence = miSyncShmScreenCreateFence;
- funcs->DestroyFence = miSyncShmScreenDestroyFence;
return TRUE;
}
--
2.13.0
More information about the xorg-devel
mailing list