Minor r200 vertex program cleanups. Remove disabled leftovers from r300 vertex progra...
[mesa.git] / src / mesa / drivers / dri / i965 / bufmgr.h
1 /**************************************************************************
2 *
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 #ifndef BUFMGR_H
29 #define BUFMGR_H
30
31 #include "intel_context.h"
32
33
34 /* The buffer manager context. Opaque.
35 */
36 struct bufmgr;
37 struct buffer;
38
39
40 struct bufmgr *bm_fake_intel_Attach( struct intel_context *intel );
41
42 /* Flags for validate and other calls. If both NO_UPLOAD and NO_EVICT
43 * are specified, ValidateBuffers is essentially a query.
44 */
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
55 * without dri lock */
56
57 #define BM_MEM_MASK (BM_MEM_LOCAL|BM_MEM_AGP|BM_MEM_VRAM)
58
59
60
61
62 /* Create a pool of a given memory type, from a certain offset and a
63 * certain size.
64 *
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.
68 *
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.
73 *
74 * Returns -1 for failure, pool number for success.
75 */
76 int bmInitPool( struct intel_context *,
77 unsigned long low_offset,
78 void *low_virtual,
79 unsigned long size,
80 unsigned flags);
81
82
83 /* Stick closely to ARB_vbo semantics - they're well defined and
84 * understood, and drivers can just pass the calls through without too
85 * much thunking.
86 */
87 void bmGenBuffers(struct intel_context *, const char *, unsigned n, struct buffer **buffers);
88 void bmDeleteBuffers(struct intel_context *, unsigned n, struct buffer **buffers);
89
90
91 /* Hook to inform faked buffer manager about fixed-position
92 * front,depth,back buffers. These may move to a fully memory-managed
93 * scheme, or they may continue to be managed as is.
94 */
95 struct buffer *bmGenBufferStatic(struct intel_context *,
96 unsigned pool);
97
98 /* On evict, buffer manager will call invalidate_cb() to note that the
99 * buffer needs to be reloaded.
100 *
101 * Buffer is uploaded by calling bmMapBuffer() and copying data into
102 * the returned pointer.
103 *
104 * This is basically a big hack to get some more performance by
105 * turning off backing store for buffers where we either have it
106 * already (textures) or don't need it (batch buffers, temporary
107 * vbo's).
108 */
109 void bmBufferSetInvalidateCB(struct intel_context *,
110 struct buffer *buf,
111 void (*invalidate_cb)( struct intel_context *, void *ptr ),
112 void *ptr,
113 GLboolean dont_fence_subdata);
114
115
116 /* The driver has more intimate knowledge of the hardare than a GL
117 * client would, so flags here is more proscriptive than the usage
118 * values in the ARB_vbo interface:
119 */
120 void bmBufferData(struct intel_context *,
121 struct buffer *buf,
122 unsigned size,
123 const void *data,
124 unsigned flags );
125
126 void bmBufferSubData(struct intel_context *,
127 struct buffer *buf,
128 unsigned offset,
129 unsigned size,
130 const void *data );
131
132
133 void bmBufferDataAUB(struct intel_context *,
134 struct buffer *buf,
135 unsigned size,
136 const void *data,
137 unsigned flags,
138 unsigned aubtype,
139 unsigned aubsubtype );
140
141 void bmBufferSubDataAUB(struct intel_context *,
142 struct buffer *buf,
143 unsigned offset,
144 unsigned size,
145 const void *data,
146 unsigned aubtype,
147 unsigned aubsubtype );
148
149
150 /* In this version, taking the offset will provoke an upload on
151 * buffers not already resident in AGP:
152 */
153 unsigned bmBufferOffset(struct intel_context *,
154 struct buffer *buf);
155
156
157 /* Extract data from the buffer:
158 */
159 void bmBufferGetSubData(struct intel_context *,
160 struct buffer *buf,
161 unsigned offset,
162 unsigned size,
163 void *data );
164
165 void *bmMapBuffer( struct intel_context *,
166 struct buffer *buf,
167 unsigned access );
168
169 void bmUnmapBuffer( struct intel_context *,
170 struct buffer *buf );
171
172 void bmUnmapBufferAUB( struct intel_context *,
173 struct buffer *buf,
174 unsigned aubtype,
175 unsigned aubsubtype );
176
177
178 /* Pertains to all buffers who's offset has been taken since the last
179 * fence or release.
180 */
181 int bmValidateBuffers( struct intel_context * );
182 void bmReleaseBuffers( struct intel_context * );
183
184
185 /* This functionality is used by the buffer manager, not really sure
186 * if we need to be exposing it in this way, probably libdrm will
187 * offer equivalent calls.
188 *
189 * For now they can stay, but will likely change/move before final:
190 */
191 unsigned bmSetFence( struct intel_context * );
192 unsigned bmLockAndFence( struct intel_context *intel );
193 int bmTestFence( struct intel_context *, unsigned fence );
194 void bmFinishFence( struct intel_context *, unsigned fence );
195
196 void bm_fake_NotifyContendedLockTake( struct intel_context * );
197
198 extern int INTEL_DEBUG;
199 #define DEBUG_BUFMGR 0x10000000
200
201 #define DBG(...) do { if (INTEL_DEBUG & DEBUG_BUFMGR) _mesa_printf(__VA_ARGS__); } while(0)
202
203 #endif