pb_bufmgr_fenced.c File Reference

A buffer manager that wraps buffers in fenced buffers. More...

Include dependency graph for pb_bufmgr_fenced.c:

Go to the source code of this file.

Data Structures

struct  fenced_pb_manager

Functions

static struct fenced_pb_managerfenced_pb_manager (struct pb_manager *mgr)
static struct pb_bufferfenced_bufmgr_create_buffer (struct pb_manager *mgr, size_t size, const struct pb_desc *desc)
static void fenced_bufmgr_flush (struct pb_manager *mgr)
static void fenced_bufmgr_destroy (struct pb_manager *mgr)
struct pb_managerfenced_bufmgr_create (struct pb_manager *provider, struct pipe_winsys *winsys)
 Fenced buffer manager.


Detailed Description

A buffer manager that wraps buffers in fenced buffers.

Author:
José Fonseca <jrfonseca@tungstengraphics.dot.com>

Definition in file pb_bufmgr_fenced.c.


Function Documentation

struct pb_manager* fenced_bufmgr_create ( struct pb_manager provider,
struct pipe_winsys winsys 
) [read]

Fenced buffer manager.

This manager is just meant for convenience. It wraps the buffers returned by another manager in fenced buffers, so that

NOTE: the buffer manager that provides the buffers will be destroyed at the same time.

Definition at line 129 of file pb_bufmgr_fenced.c.

References fenced_pb_manager::base, CALLOC_STRUCT, pb_manager::create_buffer, pb_manager::destroy, fenced_buffer_list_create(), fenced_bufmgr_create_buffer(), fenced_bufmgr_destroy(), fenced_bufmgr_flush(), fenced_pb_manager::fenced_list, pb_manager::flush, FREE, and fenced_pb_manager::provider.

00131 {
00132    struct fenced_pb_manager *fenced_mgr;
00133 
00134    if(!provider)
00135       return NULL;
00136    
00137    fenced_mgr = CALLOC_STRUCT(fenced_pb_manager);
00138    if (!fenced_mgr)
00139       return NULL;
00140 
00141    fenced_mgr->base.destroy = fenced_bufmgr_destroy;
00142    fenced_mgr->base.create_buffer = fenced_bufmgr_create_buffer;
00143    fenced_mgr->base.flush = fenced_bufmgr_flush;
00144 
00145    fenced_mgr->provider = provider;
00146    fenced_mgr->fenced_list = fenced_buffer_list_create(winsys);
00147    if(!fenced_mgr->fenced_list) {
00148       FREE(fenced_mgr);
00149       return NULL;
00150    }
00151       
00152    return &fenced_mgr->base;
00153 }

static struct pb_buffer* fenced_bufmgr_create_buffer ( struct pb_manager mgr,
size_t  size,
const struct pb_desc desc 
) [static, read]

Definition at line 64 of file pb_bufmgr_fenced.c.

References assert, pb_buffer::base, pb_manager::create_buffer, fenced_buffer_create(), fenced_buffer_list_check_free(), fenced_pb_manager::fenced_list, fenced_pb_manager(), pb_destroy(), fenced_pb_manager::provider, and pipe_buffer::refcount.

00067 {
00068    struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
00069    struct pb_buffer *buf;
00070    struct pb_buffer *fenced_buf;
00071 
00072    /* check for free buffers before allocating new ones */
00073    fenced_buffer_list_check_free(fenced_mgr->fenced_list, 0);
00074    
00075    buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size, desc);
00076    if(!buf) {
00077       /* try harder to get a buffer */
00078       fenced_buffer_list_check_free(fenced_mgr->fenced_list, 1);
00079       
00080       buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size, desc);
00081       if(!buf) {
00082 #if 0
00083          fenced_buffer_list_dump(fenced_mgr->fenced_list);
00084 #endif
00085          
00086          /* give up */
00087          return NULL;
00088       }
00089    }
00090    
00091    fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf);
00092    if(!fenced_buf) {
00093       assert(buf->base.refcount == 1);
00094       pb_destroy(buf);
00095    }
00096    
00097    return fenced_buf;
00098 }

static void fenced_bufmgr_destroy ( struct pb_manager mgr  )  [static]

Definition at line 115 of file pb_bufmgr_fenced.c.

References pb_manager::destroy, fenced_buffer_list_destroy(), fenced_pb_manager::fenced_list, fenced_pb_manager(), FREE, and fenced_pb_manager::provider.

00116 {
00117    struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
00118 
00119    fenced_buffer_list_destroy(fenced_mgr->fenced_list);
00120 
00121    if(fenced_mgr->provider)
00122       fenced_mgr->provider->destroy(fenced_mgr->provider);
00123    
00124    FREE(fenced_mgr);
00125 }

static void fenced_bufmgr_flush ( struct pb_manager mgr  )  [static]

Definition at line 102 of file pb_bufmgr_fenced.c.

References assert, fenced_buffer_list_check_free(), fenced_pb_manager::fenced_list, fenced_pb_manager(), pb_manager::flush, fenced_pb_manager::provider, and TRUE.

00103 {
00104    struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
00105 
00106    fenced_buffer_list_check_free(fenced_mgr->fenced_list, TRUE);
00107 
00108    assert(fenced_mgr->provider->flush);
00109    if(fenced_mgr->provider->flush)
00110       fenced_mgr->provider->flush(fenced_mgr->provider);
00111 }

static struct fenced_pb_manager* fenced_pb_manager ( struct pb_manager mgr  )  [static, read]

Definition at line 56 of file pb_bufmgr_fenced.c.

References assert.

00057 {
00058    assert(mgr);
00059    return (struct fenced_pb_manager *)mgr;
00060 }


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