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_state.h"
52 struct pipe_fence_handle
;
55 * Gallium screen/adapter context. Basically everything
56 * hardware-specific that doesn't actually require a rendering
60 struct pipe_winsys
*winsys
;
62 void (*destroy
)( struct pipe_screen
* );
65 const char *(*get_name
)( struct pipe_screen
* );
67 const char *(*get_vendor
)( struct pipe_screen
* );
70 * Query an integer-valued capability/parameter/limit
71 * \param param one of PIPE_CAP_x
73 int (*get_param
)( struct pipe_screen
*, int param
);
76 * Query a float-valued capability/parameter/limit
77 * \param param one of PIPE_CAP_x
79 float (*get_paramf
)( struct pipe_screen
*, int param
);
82 * Check if the given pipe_format is supported as a texture or
84 * \param tex_usage bitmask of PIPE_TEXTURE_USAGE_*
85 * \param flags bitmask of PIPE_TEXTURE_GEOM_*
87 boolean (*is_format_supported
)( struct pipe_screen
*,
88 enum pipe_format format
,
89 enum pipe_texture_target target
,
91 unsigned geom_flags
);
94 * Create a new texture object, using the given template info.
96 struct pipe_texture
* (*texture_create
)(struct pipe_screen
*,
97 const struct pipe_texture
*templat
);
100 * Create a new texture object, using the given template info, but on top of
103 * It is assumed that the buffer data is layed out according to the expected
104 * by the hardware. NULL will be returned if any inconsistency is found.
106 struct pipe_texture
* (*texture_blanket
)(struct pipe_screen
*,
107 const struct pipe_texture
*templat
,
108 const unsigned *stride
,
109 struct pipe_buffer
*buffer
);
111 void (*texture_release
)(struct pipe_screen
*,
112 struct pipe_texture
**pt
);
114 /** Get a surface which is a "view" into a texture */
115 struct pipe_surface
*(*get_tex_surface
)(struct pipe_screen
*,
116 struct pipe_texture
*texture
,
117 unsigned face
, unsigned level
,
121 /* Surfaces allocated by the above must be released here:
123 void (*tex_surface_release
)( struct pipe_screen
*,
124 struct pipe_surface
** );
127 void *(*surface_map
)( struct pipe_screen
*,
128 struct pipe_surface
*surface
,
131 void (*surface_unmap
)( struct pipe_screen
*,
132 struct pipe_surface
*surface
);
136 * Buffer management. Buffer attributes are mostly fixed over its lifetime.
140 struct pipe_buffer
*(*buffer_create
)( struct pipe_screen
*screen
,
146 * Create a buffer that wraps user-space data.
148 * Effectively this schedules a delayed call to buffer_create
149 * followed by an upload of the data at *some point in the future*,
150 * or perhaps never. Basically the allocate/upload is delayed
151 * until the buffer is actually passed to hardware.
153 * The intention is to provide a quick way to turn regular data
154 * into a buffer, and secondly to avoid a copy operation if that
155 * data subsequently turns out to be only accessed by the CPU.
157 * Common example is OpenGL vertex buffers that are subsequently
158 * processed either by software TNL in the driver or by passing to
161 * XXX: What happens if the delayed call to buffer_create() fails?
163 * Note that ptr may be accessed at any time upto the time when the
164 * buffer is destroyed, so the data must not be freed before then.
166 struct pipe_buffer
*(*user_buffer_create
)(struct pipe_screen
*screen
,
171 * Allocate storage for a display target surface.
173 * Often surfaces which are meant to be blitted to the front screen (i.e.,
174 * display targets) must be allocated with special characteristics, memory
175 * pools, or obtained directly from the windowing system.
177 * This callback is invoked by the pipe_screenwhen creating a texture marked
178 * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying
181 struct pipe_buffer
*(*surface_buffer_create
)(struct pipe_screen
*screen
,
182 unsigned width
, unsigned height
,
183 enum pipe_format format
,
189 * Map the entire data store of a buffer object into the client's address.
190 * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
192 void *(*buffer_map
)( struct pipe_screen
*screen
,
193 struct pipe_buffer
*buf
,
196 void (*buffer_unmap
)( struct pipe_screen
*screen
,
197 struct pipe_buffer
*buf
);
199 void (*buffer_destroy
)( struct pipe_screen
*screen
,
200 struct pipe_buffer
*buf
);
204 * Do any special operations to ensure frontbuffer contents are
205 * displayed, eg copy fake frontbuffer.
207 void (*flush_frontbuffer
)( struct pipe_screen
*screen
,
208 struct pipe_surface
*surf
,
209 void *context_private
);
213 /** Set ptr = fence, with reference counting */
214 void (*fence_reference
)( struct pipe_screen
*screen
,
215 struct pipe_fence_handle
**ptr
,
216 struct pipe_fence_handle
*fence
);
219 * Checks whether the fence has been signalled.
220 * \param flags driver-specific meaning
221 * \return zero on success.
223 int (*fence_signalled
)( struct pipe_screen
*screen
,
224 struct pipe_fence_handle
*fence
,
228 * Wait for the fence to finish.
229 * \param flags driver-specific meaning
230 * \return zero on success.
232 int (*fence_finish
)( struct pipe_screen
*screen
,
233 struct pipe_fence_handle
*fence
,
243 #endif /* P_SCREEN_H */