Remove stray references to struct pipe_region.
[mesa.git] / src / mesa / pipe / p_winsys.h
1 /**************************************************************************
2 *
3 * Copyright 2007 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 P_WINSYS_H
29 #define P_WINSYS_H
30
31
32 #include "p_format.h"
33
34 /**
35 * \file
36 * This is the interface that Gallium3D requires any window system
37 * hosting it to implement. This is the only include file in Gallium3D
38 * which is public.
39 */
40
41
42 /** Opaque type for a buffer */
43 struct pipe_buffer_handle;
44
45 /** Opaque type */
46 struct pipe_fence_handle;
47
48 struct pipe_surface;
49
50
51 /**
52 * Gallium3D drivers are (meant to be!) independent of both GL and the
53 * window system. The window system provides a buffer manager and a
54 * set of additional hooks for things like command buffer submission,
55 * etc.
56 *
57 * There clearly has to be some agreement between the window system
58 * driver and the hardware driver about the format of command buffers,
59 * etc.
60 */
61 struct pipe_winsys
62 {
63 /** Returns name of this winsys interface */
64 const char *(*get_name)( struct pipe_winsys *sws );
65
66 /**
67 * Do any special operations to ensure frontbuffer contents are
68 * displayed, eg copy fake frontbuffer.
69 */
70 void (*flush_frontbuffer)( struct pipe_winsys *sws,
71 struct pipe_surface *surf,
72 void *context_private );
73
74 /** Debug output */
75 void (*printf)( struct pipe_winsys *sws,
76 const char *, ... );
77
78
79 /**
80 * flags is bitmask of PIPE_SURFACE_FLAG_RENDER, PIPE_SURFACE_FLAG_TEXTURE
81 */
82 unsigned (*surface_pitch)(struct pipe_winsys *ws, unsigned cpp,
83 unsigned with, unsigned flags);
84
85 /** allocate a new surface (no context dependency) */
86 struct pipe_surface *(*surface_alloc)(struct pipe_winsys *ws,
87 enum pipe_format format);
88
89 void (*surface_release)(struct pipe_winsys *ws, struct pipe_surface **s);
90
91
92 /**
93 * The buffer manager is modeled after the dri_bufmgr interface, which
94 * in turn is modeled after the ARB_vertex_buffer_object extension,
95 * but this is the subset that gallium cares about. Remember that
96 * gallium gets to choose the interface it needs, and the window
97 * systems must then implement that interface (rather than the
98 * other way around...).
99 */
100 struct pipe_buffer_handle *(*buffer_create)( struct pipe_winsys *sws,
101 unsigned alignment,
102 unsigned flags,
103 unsigned hint );
104
105 /** Create a buffer that wraps user-space data */
106 struct pipe_buffer_handle *(*user_buffer_create)(struct pipe_winsys *sws,
107 void *ptr,
108 unsigned bytes);
109
110 /**
111 * Map the entire data store of a buffer object into the client's address.
112 * flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE.
113 */
114 void *(*buffer_map)( struct pipe_winsys *sws,
115 struct pipe_buffer_handle *buf,
116 unsigned flags );
117
118 void (*buffer_unmap)( struct pipe_winsys *sws,
119 struct pipe_buffer_handle *buf );
120
121 /** Set ptr = buf, with reference counting */
122 void (*buffer_reference)( struct pipe_winsys *sws,
123 struct pipe_buffer_handle **ptr,
124 struct pipe_buffer_handle *buf );
125
126 /**
127 * Create the data store of a buffer and optionally initialize it.
128 *
129 * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
130 * usage argument is only an optimization hint, not a guarantee, therefore
131 * proper behavior must be observed in all circumstances.
132 *
133 * Returns zero on success.
134 */
135 int (*buffer_data)(struct pipe_winsys *sws,
136 struct pipe_buffer_handle *buf,
137 unsigned size, const void *data,
138 unsigned usage);
139
140 /**
141 * Modify some or all of the data contained in a buffer's data store.
142 *
143 * Returns zero on success.
144 */
145 int (*buffer_subdata)(struct pipe_winsys *sws,
146 struct pipe_buffer_handle *buf,
147 unsigned long offset,
148 unsigned long size,
149 const void *data);
150
151 /**
152 * Query some or all of the data contained in a buffer's data store.
153 *
154 * Returns zero on success.
155 */
156 int (*buffer_get_subdata)(struct pipe_winsys *sws,
157 struct pipe_buffer_handle *buf,
158 unsigned long offset,
159 unsigned long size,
160 void *data);
161
162
163 /** Set ptr = buf, with reference counting */
164 void (*fence_reference)( struct pipe_winsys *sws,
165 struct pipe_fence_handle **ptr,
166 struct pipe_fence_handle *fence );
167
168 /**
169 * Checks whether the fence has been signalled.
170 *
171 * The meaning of flag is pipe-driver specific.
172 *
173 * Returns zero if it has.
174 */
175 int (*fence_signalled)( struct pipe_winsys *sws,
176 struct pipe_fence_handle *fence,
177 unsigned flag );
178
179 /**
180 * Wait for the fence to finish.
181 *
182 * The meaning of flag is pipe-driver specific.
183 *
184 * Returns zero on success.
185 */
186 int (*fence_finish)( struct pipe_winsys *sws,
187 struct pipe_fence_handle *fence,
188 unsigned flag );
189
190
191 };
192
193
194
195 #endif /* P_WINSYS_H */