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 **************************************************************************/
30 * This is the interface that Gallium3D requires any window system
31 * hosting it to implement. This is the only include file in Gallium3D
48 struct pipe_fence_handle
;
54 * Gallium3D drivers are (meant to be!) independent of both GL and the
55 * window system. The window system provides a buffer manager and a
56 * set of additional hooks for things like command buffer submission,
59 * There clearly has to be some agreement between the window system
60 * driver and the hardware driver about the format of command buffers,
65 void (*destroy
)( struct pipe_winsys
*ws
);
67 /** Returns name of this winsys interface */
68 const char *(*get_name
)( struct pipe_winsys
*ws
);
71 * Do any special operations to ensure frontbuffer contents are
72 * displayed, eg copy fake frontbuffer.
74 void (*flush_frontbuffer
)( struct pipe_winsys
*ws
,
75 struct pipe_surface
*surf
,
76 void *context_private
);
79 /** allocate a new surface (no context dependency) */
80 struct pipe_surface
*(*surface_alloc
)(struct pipe_winsys
*ws
);
83 * Allocate storage for a pipe_surface.
84 * \param flags XXX unused, remove someday
85 * \return 0 if succeeds.
87 int (*surface_alloc_storage
)(struct pipe_winsys
*ws
,
88 struct pipe_surface
*surf
,
89 unsigned width
, unsigned height
,
90 enum pipe_format format
,
94 void (*surface_release
)(struct pipe_winsys
*ws
, struct pipe_surface
**s
);
98 * Buffer management. Buffer attributes are mostly fixed over its lifetime.
100 * Remember that gallium gets to choose the interface it needs, and the
101 * window systems must then implement that interface (rather than the
102 * other way around...).
104 * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
105 * usage argument is only an optimization hint, not a guarantee, therefore
106 * proper behavior must be observed in all circumstances.
108 * alignment indicates the client's alignment requirements, eg for
111 struct pipe_buffer
*(*buffer_create
)( struct pipe_winsys
*ws
,
117 * Create a buffer that wraps user-space data.
119 * Effectively this schedules a delayed call to buffer_create
120 * followed by an upload of the data at *some point in the future*,
121 * or perhaps never. Basically the allocate/upload is delayed
122 * until the buffer is actually passed to hardware.
124 * The intention is to provide a quick way to turn regular data
125 * into a buffer, and secondly to avoid a copy operation if that
126 * data subsequently turns out to be only accessed by the CPU.
128 * Common example is OpenGL vertex buffers that are subsequently
129 * processed either by software TNL in the driver or by passing to
132 * XXX: What happens if the delayed call to buffer_create() fails?
134 * Note that ptr may be accessed at any time upto the time when the
135 * buffer is destroyed, so the data must not be freed before then.
137 struct pipe_buffer
*(*user_buffer_create
)(struct pipe_winsys
*ws
,
142 * Map the entire data store of a buffer object into the client's address.
143 * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
145 void *(*buffer_map
)( struct pipe_winsys
*ws
,
146 struct pipe_buffer
*buf
,
149 void (*buffer_unmap
)( struct pipe_winsys
*ws
,
150 struct pipe_buffer
*buf
);
152 void (*buffer_destroy
)( struct pipe_winsys
*ws
,
153 struct pipe_buffer
*buf
);
156 /** Set ptr = fence, with reference counting */
157 void (*fence_reference
)( struct pipe_winsys
*ws
,
158 struct pipe_fence_handle
**ptr
,
159 struct pipe_fence_handle
*fence
);
162 * Checks whether the fence has been signalled.
163 * \param flags driver-specific meaning
164 * \return zero on success.
166 int (*fence_signalled
)( struct pipe_winsys
*ws
,
167 struct pipe_fence_handle
*fence
,
171 * Wait for the fence to finish.
172 * \param flags driver-specific meaning
173 * \return zero on success.
175 int (*fence_finish
)( struct pipe_winsys
*ws
,
176 struct pipe_fence_handle
*fence
,
186 #endif /* P_WINSYS_H */