1 /**************************************************************************
3 * Copyright 2006 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 **************************************************************************/
31 #include "intel_context.h"
34 /* The buffer manager context. Opaque.
40 struct bufmgr
*bm_fake_intel_Attach( struct intel_context
*intel
);
42 /* Flags for validate and other calls. If both NO_UPLOAD and NO_EVICT
43 * are specified, ValidateBuffers is essentially a query.
45 #define BM_MEM_LOCAL 0x1
46 #define BM_MEM_AGP 0x2
47 #define BM_MEM_VRAM 0x4 /* not yet used */
48 #define BM_WRITE 0x8 /* not yet used */
49 #define BM_READ 0x10 /* not yet used */
50 #define BM_NO_UPLOAD 0x20
51 #define BM_NO_EVICT 0x40
52 #define BM_NO_MOVE 0x80 /* not yet used */
53 #define BM_NO_ALLOC 0x100 /* legacy "fixed" buffers only */
54 #define BM_CLIENT 0x200 /* for map - pointer will be accessed
57 #define BM_MEM_MASK (BM_MEM_LOCAL|BM_MEM_AGP|BM_MEM_VRAM)
62 /* Create a pool of a given memory type, from a certain offset and a
65 * Also passed in is a virtual pointer to the start of the pool. This
66 * is useful in the faked-out version in i915 so that MapBuffer can
67 * return a pointer to a buffer residing in AGP space.
69 * Flags passed into a pool are inherited by all buffers allocated in
70 * that pool. So pools representing the static front,back,depth
71 * buffer allocations should have MEM_AGP|NO_UPLOAD|NO_EVICT|NO_MOVE to match
72 * the behaviour of the legacy allocations.
74 * Returns -1 for failure, pool number for success.
76 int bmInitPool( struct intel_context
*,
77 unsigned long low_offset
,
83 /* Stick closely to ARB_vbo semantics - they're well defined and
84 * understood, and drivers can just pass the calls through without too
87 void bmGenBuffers(struct intel_context
*, const char *, unsigned n
, struct buffer
**buffers
,
89 void bmDeleteBuffers(struct intel_context
*, unsigned n
, struct buffer
**buffers
);
92 /* Hook to inform faked buffer manager about fixed-position
93 * front,depth,back buffers. These may move to a fully memory-managed
94 * scheme, or they may continue to be managed as is.
96 struct buffer
*bmGenBufferStatic(struct intel_context
*,
99 /* On evict, buffer manager will call invalidate_cb() to note that the
100 * buffer needs to be reloaded.
102 * Buffer is uploaded by calling bmMapBuffer() and copying data into
103 * the returned pointer.
105 * This is basically a big hack to get some more performance by
106 * turning off backing store for buffers where we either have it
107 * already (textures) or don't need it (batch buffers, temporary
110 void bmBufferSetInvalidateCB(struct intel_context
*,
112 void (*invalidate_cb
)( struct intel_context
*, void *ptr
),
114 GLboolean dont_fence_subdata
);
117 /* The driver has more intimate knowledge of the hardare than a GL
118 * client would, so flags here is more proscriptive than the usage
119 * values in the ARB_vbo interface:
121 int bmBufferData(struct intel_context
*,
127 int bmBufferSubData(struct intel_context
*,
134 int bmBufferDataAUB(struct intel_context
*,
140 unsigned aubsubtype
);
142 int bmBufferSubDataAUB(struct intel_context
*,
148 unsigned aubsubtype
);
151 /* In this version, taking the offset will provoke an upload on
152 * buffers not already resident in AGP:
154 unsigned bmBufferOffset(struct intel_context
*,
158 /* Extract data from the buffer:
160 void bmBufferGetSubData(struct intel_context
*,
166 void *bmMapBuffer( struct intel_context
*,
170 void bmUnmapBuffer( struct intel_context
*,
171 struct buffer
*buf
);
173 void bmUnmapBufferAUB( struct intel_context
*,
176 unsigned aubsubtype
);
179 /* Pertains to all buffers who's offset has been taken since the last
182 int bmValidateBuffers( struct intel_context
* );
183 void bmReleaseBuffers( struct intel_context
* );
185 GLuint
bmCtxId( struct intel_context
*intel
);
188 GLboolean
bmError( struct intel_context
* );
189 void bmEvictAll( struct intel_context
* );
191 void *bmFindVirtual( struct intel_context
*intel
,
195 /* This functionality is used by the buffer manager, not really sure
196 * if we need to be exposing it in this way, probably libdrm will
197 * offer equivalent calls.
199 * For now they can stay, but will likely change/move before final:
201 unsigned bmSetFence( struct intel_context
* );
202 unsigned bmSetFenceLock( struct intel_context
* );
203 unsigned bmLockAndFence( struct intel_context
*intel
);
204 int bmTestFence( struct intel_context
*, unsigned fence
);
205 void bmFinishFence( struct intel_context
*, unsigned fence
);
206 void bmFinishFenceLock( struct intel_context
*, unsigned fence
);
208 void bm_fake_NotifyContendedLockTake( struct intel_context
* );
210 extern int INTEL_DEBUG
;
211 #define DEBUG_BUFMGR 0x10000000
213 #define DBG(...) do { if (INTEL_DEBUG & DEBUG_BUFMGR) _mesa_printf(__VA_ARGS__); } while(0)