1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
32 * A buffer manager does only one basic thing: it creates buffers. Actually,
33 * "buffer factory" would probably a more accurate description.
35 * You can chain buffer managers so that you can have a finer grained memory
36 * management and pooling.
38 * For example, for a simple batch buffer manager you would chain:
39 * - the native buffer manager, which provides DMA memory from the graphics
41 * - the pool buffer manager, which keep around a pool of equally sized buffers
42 * to avoid latency associated with the native buffer manager;
43 * - the fenced buffer manager, which will delay buffer destruction until the
44 * the moment the card finishing processing it.
46 * \author José Fonseca <jrfonseca@tungstengraphics.com>
67 * Abstract base class for all buffer managers.
71 /* XXX: we will likely need more allocation flags */
73 (*create_buffer
)( struct pb_manager
*mgr
,
75 const struct pb_desc
*desc
);
78 (*destroy
)( struct pb_manager
*mgr
);
83 * Static buffer pool manager.
85 * Manages the allocation of equally sized buffers. It does so by allocating
86 * a single big buffer and divide it equally sized buffers.
88 * It is meant to manage the allocation of batch buffer pools.
91 pool_bufmgr_create(struct pb_manager
*provider
,
92 size_t n
, size_t size
,
93 const struct pb_desc
*desc
);
97 * Wraper around the old memory manager.
99 * It managers buffers of different sizes. It does so by allocating a buffer
100 * with the size of the heap, and then using the old mm memory manager to manage
104 mm_bufmgr_create(struct pb_manager
*provider
,
105 size_t size
, size_t align2
);
108 * Same as mm_bufmgr_create.
110 * Buffer will be release when the manager is destroyed.
113 mm_bufmgr_create_from_buffer(struct pb_buffer
*buffer
,
114 size_t size
, size_t align2
);
118 * Fenced buffer manager.
120 * This manager is just meant for convenience. It wraps the buffers returned
121 * by another manager in fenced buffers, so that
123 * NOTE: the buffer manager that provides the buffers will be destroyed
127 fenced_bufmgr_create(struct pb_manager
*provider
,
128 struct pipe_winsys
*winsys
);
135 #endif /*PB_BUFMGR_H_*/