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
;
60 * Gallium screen/adapter context. Basically everything
61 * hardware-specific that doesn't actually require a rendering
65 struct pipe_winsys
*winsys
;
67 void (*destroy
)( struct pipe_screen
* );
70 const char *(*get_name
)( struct pipe_screen
* );
72 const char *(*get_vendor
)( struct pipe_screen
* );
75 * Query an integer-valued capability/parameter/limit
76 * \param param one of PIPE_CAP_x
78 int (*get_param
)( struct pipe_screen
*, int param
);
81 * Query a float-valued capability/parameter/limit
82 * \param param one of PIPE_CAP_x
84 float (*get_paramf
)( struct pipe_screen
*, int param
);
87 * Check if the given pipe_format is supported as a texture or
89 * \param tex_usage bitmask of PIPE_TEXTURE_USAGE_*
90 * \param flags bitmask of PIPE_TEXTURE_GEOM_*
92 boolean (*is_format_supported
)( struct pipe_screen
*,
93 enum pipe_format format
,
94 enum pipe_texture_target target
,
96 unsigned geom_flags
);
99 * Create a new texture object, using the given template info.
101 struct pipe_texture
* (*texture_create
)(struct pipe_screen
*,
102 const struct pipe_texture
*templat
);
105 * Create a new texture object, using the given template info, but on top of
108 * It is assumed that the buffer data is layed out according to the expected
109 * by the hardware. NULL will be returned if any inconsistency is found.
111 struct pipe_texture
* (*texture_blanket
)(struct pipe_screen
*,
112 const struct pipe_texture
*templat
,
113 const unsigned *stride
,
114 struct pipe_buffer
*buffer
);
116 void (*texture_destroy
)(struct pipe_texture
*pt
);
118 /** Get a surface which is a "view" into a texture */
119 struct pipe_surface
*(*get_tex_surface
)(struct pipe_screen
*,
120 struct pipe_texture
*texture
,
121 unsigned face
, unsigned level
,
125 void (*tex_surface_destroy
)(struct pipe_surface
*);
128 /** Get a transfer object for transferring data to/from a texture */
129 struct pipe_transfer
*(*get_tex_transfer
)(struct pipe_screen
*,
130 struct pipe_texture
*texture
,
131 unsigned face
, unsigned level
,
133 enum pipe_transfer_usage usage
,
134 unsigned x
, unsigned y
,
135 unsigned w
, unsigned h
);
137 void (*tex_transfer_destroy
)(struct pipe_transfer
*);
139 void *(*transfer_map
)( struct pipe_screen
*,
140 struct pipe_transfer
*transfer
);
142 void (*transfer_unmap
)( struct pipe_screen
*,
143 struct pipe_transfer
*transfer
);
147 * Buffer management. Buffer attributes are mostly fixed over its lifetime.
150 struct pipe_buffer
*(*buffer_create
)( struct pipe_screen
*screen
,
156 * Create a buffer that wraps user-space data.
158 * Effectively this schedules a delayed call to buffer_create
159 * followed by an upload of the data at *some point in the future*,
160 * or perhaps never. Basically the allocate/upload is delayed
161 * until the buffer is actually passed to hardware.
163 * The intention is to provide a quick way to turn regular data
164 * into a buffer, and secondly to avoid a copy operation if that
165 * data subsequently turns out to be only accessed by the CPU.
167 * Common example is OpenGL vertex buffers that are subsequently
168 * processed either by software TNL in the driver or by passing to
171 * XXX: What happens if the delayed call to buffer_create() fails?
173 * Note that ptr may be accessed at any time upto the time when the
174 * buffer is destroyed, so the data must not be freed before then.
176 struct pipe_buffer
*(*user_buffer_create
)(struct pipe_screen
*screen
,
181 * Allocate storage for a display target surface.
183 * Often surfaces which are meant to be blitted to the front screen (i.e.,
184 * display targets) must be allocated with special characteristics, memory
185 * pools, or obtained directly from the windowing system.
187 * This callback is invoked by the pipe_screenwhen creating a texture marked
188 * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying
191 struct pipe_buffer
*(*surface_buffer_create
)(struct pipe_screen
*screen
,
192 unsigned width
, unsigned height
,
193 enum pipe_format format
,
199 * Map the entire data store of a buffer object into the client's address.
200 * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
202 void *(*buffer_map
)( struct pipe_screen
*screen
,
203 struct pipe_buffer
*buf
,
206 * Map a subrange of the buffer data store into the client's address space.
208 * The returned pointer is always relative to buffer start, regardless of
209 * the specified range. This is different from the ARB_map_buffer_range
210 * semantics because we don't forbid multiple mappings of the same buffer
213 void *(*buffer_map_range
)( struct pipe_screen
*screen
,
214 struct pipe_buffer
*buf
,
220 * Notify a range that was actually written into.
222 * The range is relative to the buffer start, regardless of the range
223 * specified to buffer_map_range. This is different from the
224 * ARB_map_buffer_range semantics because we don't forbid multiple mappings
225 * of the same buffer (yet).
227 void (*buffer_flush_mapped_range
)( struct pipe_screen
*screen
,
228 struct pipe_buffer
*buf
,
232 void (*buffer_unmap
)( struct pipe_screen
*screen
,
233 struct pipe_buffer
*buf
);
235 void (*buffer_destroy
)( struct pipe_buffer
*buf
);
239 * Do any special operations to ensure frontbuffer contents are
240 * displayed, eg copy fake frontbuffer.
242 void (*flush_frontbuffer
)( struct pipe_screen
*screen
,
243 struct pipe_surface
*surf
,
244 void *context_private
);
248 /** Set ptr = fence, with reference counting */
249 void (*fence_reference
)( struct pipe_screen
*screen
,
250 struct pipe_fence_handle
**ptr
,
251 struct pipe_fence_handle
*fence
);
254 * Checks whether the fence has been signalled.
255 * \param flags driver-specific meaning
256 * \return zero on success.
258 int (*fence_signalled
)( struct pipe_screen
*screen
,
259 struct pipe_fence_handle
*fence
,
263 * Wait for the fence to finish.
264 * \param flags driver-specific meaning
265 * \return zero on success.
267 int (*fence_finish
)( struct pipe_screen
*screen
,
268 struct pipe_fence_handle
*fence
,
278 #endif /* P_SCREEN_H */