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 **************************************************************************/
31 * Screen, Adapter or GPU
33 * These are driver functions/facilities that are context independent.
41 #include "pipe/p_compiler.h"
42 #include "pipe/p_format.h"
43 #include "pipe/p_defines.h"
53 struct pipe_fence_handle
;
58 struct pipe_video_surface
;
63 * Gallium screen/adapter context. Basically everything
64 * hardware-specific that doesn't actually require a rendering
68 struct pipe_winsys
*winsys
;
70 void (*destroy
)( struct pipe_screen
* );
73 const char *(*get_name
)( struct pipe_screen
* );
75 const char *(*get_vendor
)( struct pipe_screen
* );
78 * Query an integer-valued capability/parameter/limit
79 * \param param one of PIPE_CAP_x
81 int (*get_param
)( struct pipe_screen
*, int param
);
84 * Query a float-valued capability/parameter/limit
85 * \param param one of PIPE_CAP_x
87 float (*get_paramf
)( struct pipe_screen
*, int param
);
89 struct pipe_context
* (*context_create
)( struct pipe_screen
*,
93 * Check if the given pipe_format is supported as a texture or
95 * \param tex_usage bitmask of PIPE_TEXTURE_USAGE_*
96 * \param geom_flags bitmask of PIPE_TEXTURE_GEOM_*
98 boolean (*is_format_supported
)( struct pipe_screen
*,
99 enum pipe_format format
,
100 enum pipe_texture_target target
,
102 unsigned geom_flags
);
105 * Create a new texture object, using the given template info.
107 struct pipe_texture
* (*texture_create
)(struct pipe_screen
*,
108 const struct pipe_texture
*templat
);
111 * Create a new texture object, using the given template info, but on top of
114 * It is assumed that the buffer data is layed out according to the expected
115 * by the hardware. NULL will be returned if any inconsistency is found.
117 struct pipe_texture
* (*texture_blanket
)(struct pipe_screen
*,
118 const struct pipe_texture
*templat
,
119 const unsigned *stride
,
120 struct pipe_buffer
*buffer
);
122 void (*texture_destroy
)(struct pipe_texture
*pt
);
124 /** Get a 2D surface which is a "view" into a texture
125 * \param usage bitmaks of PIPE_BUFFER_USAGE_* read/write flags
127 struct pipe_surface
*(*get_tex_surface
)(struct pipe_screen
*,
128 struct pipe_texture
*texture
,
129 unsigned face
, unsigned level
,
133 void (*tex_surface_destroy
)(struct pipe_surface
*);
136 /** Get a transfer object for transferring data to/from a texture */
137 struct pipe_transfer
*(*get_tex_transfer
)(struct pipe_screen
*,
138 struct pipe_texture
*texture
,
139 unsigned face
, unsigned level
,
141 enum pipe_transfer_usage usage
,
142 unsigned x
, unsigned y
,
143 unsigned w
, unsigned h
);
145 void (*tex_transfer_destroy
)(struct pipe_transfer
*);
147 void *(*transfer_map
)( struct pipe_screen
*,
148 struct pipe_transfer
*transfer
);
150 void (*transfer_unmap
)( struct pipe_screen
*,
151 struct pipe_transfer
*transfer
);
155 * Create a new buffer.
156 * \param alignment buffer start address alignment in bytes
157 * \param usage bitmask of PIPE_BUFFER_USAGE_x
158 * \param size size in bytes
160 struct pipe_buffer
*(*buffer_create
)( struct pipe_screen
*screen
,
166 * Create a buffer that wraps user-space data.
168 * Effectively this schedules a delayed call to buffer_create
169 * followed by an upload of the data at *some point in the future*,
170 * or perhaps never. Basically the allocate/upload is delayed
171 * until the buffer is actually passed to hardware.
173 * The intention is to provide a quick way to turn regular data
174 * into a buffer, and secondly to avoid a copy operation if that
175 * data subsequently turns out to be only accessed by the CPU.
177 * Common example is OpenGL vertex buffers that are subsequently
178 * processed either by software TNL in the driver or by passing to
181 * XXX: What happens if the delayed call to buffer_create() fails?
183 * Note that ptr may be accessed at any time upto the time when the
184 * buffer is destroyed, so the data must not be freed before then.
186 struct pipe_buffer
*(*user_buffer_create
)(struct pipe_screen
*screen
,
191 * Allocate storage for a display target surface.
193 * Often surfaces which are meant to be blitted to the front screen (i.e.,
194 * display targets) must be allocated with special characteristics, memory
195 * pools, or obtained directly from the windowing system.
197 * This callback is invoked by the pipe_screenwhen creating a texture marked
198 * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying
201 struct pipe_buffer
*(*surface_buffer_create
)(struct pipe_screen
*screen
,
202 unsigned width
, unsigned height
,
203 enum pipe_format format
,
210 * Map the entire data store of a buffer object into the client's address.
211 * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
213 void *(*buffer_map
)( struct pipe_screen
*screen
,
214 struct pipe_buffer
*buf
,
217 * Map a subrange of the buffer data store into the client's address space.
219 * The returned pointer is always relative to buffer start, regardless of
220 * the specified range. This is different from the ARB_map_buffer_range
221 * semantics because we don't forbid multiple mappings of the same buffer
224 void *(*buffer_map_range
)( struct pipe_screen
*screen
,
225 struct pipe_buffer
*buf
,
231 * Notify a range that was actually written into.
233 * Can only be used if the buffer was mapped with the
234 * PIPE_BUFFER_USAGE_CPU_WRITE and PIPE_BUFFER_USAGE_FLUSH_EXPLICIT flags
237 * The range is relative to the buffer start, regardless of the range
238 * specified to buffer_map_range. This is different from the
239 * ARB_map_buffer_range semantics because we don't forbid multiple mappings
240 * of the same buffer (yet).
243 void (*buffer_flush_mapped_range
)( struct pipe_screen
*screen
,
244 struct pipe_buffer
*buf
,
251 * If the buffer was mapped with PIPE_BUFFER_USAGE_CPU_WRITE flag but not
252 * PIPE_BUFFER_USAGE_FLUSH_EXPLICIT then the pipe driver will
253 * assume that the whole buffer was written. This is mostly for backward
254 * compatibility purposes and may affect performance -- the state tracker
255 * should always specify exactly what got written while the buffer was
258 void (*buffer_unmap
)( struct pipe_screen
*screen
,
259 struct pipe_buffer
*buf
);
261 void (*buffer_destroy
)( struct pipe_buffer
*buf
);
264 * Create a video surface suitable for use as a decoding target by the
265 * driver's pipe_video_context.
267 struct pipe_video_surface
*
268 (*video_surface_create
)( struct pipe_screen
*screen
,
269 enum pipe_video_chroma_format chroma_format
,
270 unsigned width
, unsigned height
);
272 void (*video_surface_destroy
)( struct pipe_video_surface
*vsfc
);
275 * Do any special operations to ensure buffer size is correct
277 void (*update_buffer
)( struct pipe_screen
*ws
,
278 void *context_private
);
281 * Do any special operations to ensure frontbuffer contents are
282 * displayed, eg copy fake frontbuffer.
284 void (*flush_frontbuffer
)( struct pipe_screen
*screen
,
285 struct pipe_surface
*surf
,
286 void *context_private
);
290 /** Set ptr = fence, with reference counting */
291 void (*fence_reference
)( struct pipe_screen
*screen
,
292 struct pipe_fence_handle
**ptr
,
293 struct pipe_fence_handle
*fence
);
296 * Checks whether the fence has been signalled.
297 * \param flags driver-specific meaning
298 * \return zero on success.
300 int (*fence_signalled
)( struct pipe_screen
*screen
,
301 struct pipe_fence_handle
*fence
,
305 * Wait for the fence to finish.
306 * \param flags driver-specific meaning
307 * \return zero on success.
309 int (*fence_finish
)( struct pipe_screen
*screen
,
310 struct pipe_fence_handle
*fence
,
320 #endif /* P_SCREEN_H */