ws_dri_fencemgr.h File Reference

Include dependency graph for ws_dri_fencemgr.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _DriFenceMgrCreateInfo

Defines

#define DRI_FENCE_CLASS_ORDERED   (1 << 0)

Functions

uint32_t driFenceSignaledTypeCached (struct _DriFenceObject *fence)
int driFenceSignaledType (struct _DriFenceObject *fence, uint32_t flush_type, uint32_t *signaled)
static int driFenceSignaled (struct _DriFenceObject *fence, uint32_t flush_type)
static int driFenceSignaledCached (struct _DriFenceObject *fence, uint32_t flush_type)
struct _DriFenceObjectdriFenceReference (struct _DriFenceObject *fence)
void driFenceUnReference (struct _DriFenceObject **pFence)
int driFenceFinish (struct _DriFenceObject *fence, uint32_t fence_type, int lazy_hint)
struct _DriFenceObjectdriFenceCreate (struct _DriFenceMgr *mgr, uint32_t fence_class, uint32_t fence_type, void *private, size_t private_size)
uint32_t driFenceType (struct _DriFenceObject *fence)
struct _DriFenceMgrdriFenceMgrCreate (const struct _DriFenceMgrCreateInfo *info)
void driFenceMgrUnReference (struct _DriFenceMgr **pMgr)
struct _DriFenceMgrdriFenceMgrTTMInit (int fd)


Define Documentation

#define DRI_FENCE_CLASS_ORDERED   (1 << 0)

Definition at line 95 of file ws_dri_fencemgr.h.


Function Documentation

struct _DriFenceObject* driFenceCreate ( struct _DriFenceMgr mgr,
uint32_t  fence_class,
uint32_t  fence_type,
void *  private,
size_t  private_size 
) [read]

Definition at line 277 of file ws_dri_fencemgr.c.

References _DriFenceObject::fence_class, _DriFenceObject::fence_type, _DriFenceMgrCreateInfo::finish, _DriFenceObject::head, _DriFenceMgr::heads, _DriFenceMgr::info, _DriFenceObject::mgr, _DriFenceMgr::mutex, _DriFenceObject::mutex, _DriFenceMgr::num_fences, pipe_mutex_init, pipe_mutex_lock, pipe_mutex_unlock, _DriFenceObject::private, _DriFenceMgr::refCount, _DriFenceObject::refCount, and _DriFenceObject::signaled_type.

00279 {
00280     struct _DriFenceObject *fence;
00281     size_t fence_size = sizeof(*fence);
00282 
00283     if (private_size)
00284         fence_size = ((fence_size + 15) & ~15);
00285 
00286     fence = calloc(1, fence_size + private_size);
00287 
00288     if (!fence) {
00289         int ret = mgr->info.finish(mgr, private, fence_type, 0);
00290 
00291         if (ret)
00292             usleep(10000000);
00293 
00294         return NULL;
00295     }
00296 
00297     pipe_mutex_init(fence->mutex);
00298     pipe_mutex_lock(fence->mutex);
00299     pipe_mutex_lock(mgr->mutex);
00300     fence->refCount = 1;
00301     DRMLISTADDTAIL(&fence->head, &mgr->heads[fence_class]);
00302     fence->mgr = mgr;
00303     ++mgr->refCount;
00304     ++mgr->num_fences;
00305     pipe_mutex_unlock(mgr->mutex);
00306     fence->fence_class = fence_class;
00307     fence->fence_type = fence_type;
00308     fence->signaled_type = 0;
00309     fence->private = private;
00310     if (private_size) {
00311         fence->private = (void *)(((uint8_t *) fence) + fence_size);
00312         memcpy(fence->private, private, private_size);
00313     }
00314 
00315     pipe_mutex_unlock(fence->mutex);
00316     return fence;
00317 }

int driFenceFinish ( struct _DriFenceObject fence,
uint32_t  fence_type,
int  lazy_hint 
)

Definition at line 178 of file ws_dri_fencemgr.c.

References driSignalPreviousFencesLocked(), _DriFenceObject::fence_class, _DriFenceMgrCreateInfo::finish, _DriFenceObject::head, _DriFenceMgr::info, _DriFenceObject::mgr, _DriFenceMgr::mutex, _DriFenceObject::mutex, pipe_mutex_lock, pipe_mutex_unlock, _DriFenceObject::private, and _DriFenceObject::signaled_type.

00180 {
00181     struct _DriFenceMgr *mgr = fence->mgr;
00182     int ret = 0;
00183 
00184     pipe_mutex_lock(fence->mutex);
00185 
00186     if ((fence->signaled_type & fence_type) == fence_type)
00187         goto out0;
00188 
00189     ret = mgr->info.finish(mgr, fence->private, fence_type, lazy_hint);
00190     if (ret)
00191         goto out0;
00192 
00193     pipe_mutex_lock(mgr->mutex);
00194     pipe_mutex_unlock(fence->mutex);
00195 
00196     driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
00197                                   fence_type);
00198     pipe_mutex_unlock(mgr->mutex);
00199     return 0;
00200 
00201   out0:
00202     pipe_mutex_unlock(fence->mutex);
00203     return ret;
00204 }

struct _DriFenceMgr* driFenceMgrCreate ( const struct _DriFenceMgrCreateInfo info  )  [read]

Definition at line 59 of file ws_dri_fencemgr.c.

References _DriFenceMgr::heads, _DriFenceMgr::info, _DriFenceMgr::mutex, _DriFenceMgrCreateInfo::num_classes, _DriFenceMgr::num_fences, pipe_mutex_init, pipe_mutex_lock, pipe_mutex_unlock, and _DriFenceMgr::refCount.

00060 {
00061   struct _DriFenceMgr *tmp;
00062   uint32_t i;
00063 
00064   tmp = calloc(1, sizeof(*tmp));
00065   if (!tmp)
00066       return NULL;
00067 
00068   pipe_mutex_init(tmp->mutex);
00069   pipe_mutex_lock(tmp->mutex);
00070   tmp->refCount = 1;
00071   tmp->info = *info;
00072   tmp->num_fences = 0;
00073   tmp->heads = calloc(tmp->info.num_classes, sizeof(*tmp->heads));
00074   if (!tmp->heads)
00075       goto out_err;
00076 
00077   for (i=0; i<tmp->info.num_classes; ++i) {
00078       DRMINITLISTHEAD(&tmp->heads[i]);
00079   }
00080   pipe_mutex_unlock(tmp->mutex);
00081   return tmp;
00082 
00083   out_err:
00084   if (tmp)
00085       free(tmp);
00086   return NULL;
00087 }

struct _DriFenceMgr* driFenceMgrTTMInit ( int  fd  )  [read]

Definition at line 359 of file ws_dri_fencemgr.c.

References DRI_FENCE_CLASS_ORDERED, driFenceMgrCreate(), _DriFenceMgrCreateInfo::finish, _DriFenceMgrCreateInfo::flags, _DriFenceMgrCreateInfo::num_classes, _DriFenceMgr::private, _DriFenceMgrCreateInfo::signaled, tFinish(), tSignaled(), tUnref(), and _DriFenceMgrCreateInfo::unreference.

00360 {
00361   struct _DriFenceMgrCreateInfo info;
00362   struct _DriFenceMgr *mgr;
00363 
00364   info.flags = DRI_FENCE_CLASS_ORDERED;
00365   info.num_classes = 4;
00366   info.signaled = tSignaled;
00367   info.finish = tFinish;
00368   info.unreference = tUnref;
00369 
00370   mgr = driFenceMgrCreate(&info);
00371   if (mgr == NULL)
00372     return NULL;
00373 
00374   mgr->private = (void *) (long) fd;
00375   return mgr;
00376 }

void driFenceMgrUnReference ( struct _DriFenceMgr **  pMgr  ) 

Definition at line 102 of file ws_dri_fencemgr.c.

References driFenceMgrUnrefUnlock(), and pipe_mutex_lock.

00103 {
00104     pipe_mutex_lock((*pMgr)->mutex);
00105     driFenceMgrUnrefUnlock(pMgr);
00106 }

struct _DriFenceObject* driFenceReference ( struct _DriFenceObject fence  )  [read]

Definition at line 253 of file ws_dri_fencemgr.c.

References _DriFenceObject::mgr, _DriFenceMgr::mutex, pipe_mutex_lock, pipe_mutex_unlock, and _DriFenceObject::refCount.

00254 {
00255     pipe_mutex_lock(fence->mgr->mutex);
00256     ++fence->refCount;
00257     pipe_mutex_unlock(fence->mgr->mutex);
00258     return fence;
00259 }

static int driFenceSignaled ( struct _DriFenceObject fence,
uint32_t  flush_type 
) [static]

Definition at line 30 of file ws_dri_fencemgr.h.

References driFenceSignaledType().

00032 {
00033     uint32_t signaled_types;
00034     int ret = driFenceSignaledType(fence, flush_type, &signaled_types);
00035     if (ret)
00036         return 0;
00037     return ((signaled_types & flush_type) == flush_type);
00038 }

static int driFenceSignaledCached ( struct _DriFenceObject fence,
uint32_t  flush_type 
) [static]

Definition at line 40 of file ws_dri_fencemgr.h.

References driFenceSignaledTypeCached().

00042 {
00043     uint32_t signaled_types =
00044         driFenceSignaledTypeCached(fence);
00045 
00046     return ((signaled_types & flush_type) == flush_type);
00047 }

int driFenceSignaledType ( struct _DriFenceObject fence,
uint32_t  flush_type,
uint32_t *  signaled 
)

Definition at line 218 of file ws_dri_fencemgr.c.

References driSignalPreviousFencesLocked(), _DriFenceObject::fence_class, _DriFenceObject::head, _DriFenceMgr::info, _DriFenceObject::mgr, _DriFenceMgr::mutex, _DriFenceObject::mutex, pipe_mutex_lock, pipe_mutex_unlock, _DriFenceObject::private, _DriFenceMgrCreateInfo::signaled, and _DriFenceObject::signaled_type.

00220 {
00221     int ret = 0;
00222     struct _DriFenceMgr *mgr;
00223 
00224     pipe_mutex_lock(fence->mutex);
00225     mgr = fence->mgr;
00226     *signaled = fence->signaled_type;
00227     if ((fence->signaled_type & flush_type) == flush_type)
00228         goto out0;
00229 
00230     ret = mgr->info.signaled(mgr, fence->private, flush_type, signaled);
00231     if (ret) {
00232         *signaled = fence->signaled_type;
00233         goto out0;
00234     }
00235 
00236     if ((fence->signaled_type | *signaled) == fence->signaled_type)
00237         goto out0;
00238 
00239     pipe_mutex_lock(mgr->mutex);
00240     pipe_mutex_unlock(fence->mutex);
00241 
00242     driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
00243                                   *signaled);
00244 
00245     pipe_mutex_unlock(mgr->mutex);
00246     return 0;
00247   out0:
00248     pipe_mutex_unlock(fence->mutex);
00249     return ret;
00250 }

uint32_t driFenceSignaledTypeCached ( struct _DriFenceObject fence  ) 

Definition at line 206 of file ws_dri_fencemgr.c.

References _DriFenceObject::mutex, pipe_mutex_lock, pipe_mutex_unlock, and _DriFenceObject::signaled_type.

00207 {
00208     uint32_t ret;
00209 
00210     pipe_mutex_lock(fence->mutex);
00211     ret = fence->signaled_type;
00212     pipe_mutex_unlock(fence->mutex);
00213 
00214     return ret;
00215 }

uint32_t driFenceType ( struct _DriFenceObject fence  ) 

Definition at line 53 of file ws_dri_fencemgr.c.

References _DriFenceObject::fence_type.

00054 {
00055   return fence->fence_type;
00056 }

void driFenceUnReference ( struct _DriFenceObject **  pFence  ) 

Definition at line 262 of file ws_dri_fencemgr.c.

References driFenceMgrUnrefUnlock(), driFenceUnReferenceLocked(), _DriFenceMgr::mutex, pipe_mutex_lock, and _DriFenceMgr::refCount.

00263 {
00264     struct _DriFenceMgr *mgr;
00265 
00266     if (*pFence == NULL)
00267         return;
00268 
00269     mgr = (*pFence)->mgr;
00270     pipe_mutex_lock(mgr->mutex);
00271     ++mgr->refCount;
00272     driFenceUnReferenceLocked(pFence);
00273     driFenceMgrUnrefUnlock(&mgr);
00274 }


Generated on Tue Sep 29 06:25:45 2009 for Gallium3D by  doxygen 1.5.4