1 /**************************************************************************
3 * Copyright 2007 VMware, Inc.
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 VMWARE 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"
44 #include "pipe/p_video_enums.h"
55 struct pipe_fence_handle
;
60 struct pipe_memory_info
;
64 * Gallium screen/adapter context. Basically everything
65 * hardware-specific that doesn't actually require a rendering
69 void (*destroy
)( struct pipe_screen
* );
71 const char *(*get_name
)( struct pipe_screen
* );
73 const char *(*get_vendor
)( struct pipe_screen
* );
76 * Returns the device vendor.
78 * The returned value should return the actual device vendor/manufacturer,
79 * rather than a potentially generic driver string.
81 const char *(*get_device_vendor
)( struct pipe_screen
* );
84 * Query an integer-valued capability/parameter/limit
85 * \param param one of PIPE_CAP_x
87 int (*get_param
)( struct pipe_screen
*, enum pipe_cap param
);
90 * Query a float-valued capability/parameter/limit
91 * \param param one of PIPE_CAP_x
93 float (*get_paramf
)( struct pipe_screen
*, enum pipe_capf param
);
96 * Query a per-shader-stage integer-valued capability/parameter/limit
97 * \param param one of PIPE_CAP_x
99 int (*get_shader_param
)( struct pipe_screen
*, unsigned shader
, enum pipe_shader_cap param
);
102 * Query an integer-valued capability/parameter/limit for a codec/profile
103 * \param param one of PIPE_VIDEO_CAP_x
105 int (*get_video_param
)( struct pipe_screen
*,
106 enum pipe_video_profile profile
,
107 enum pipe_video_entrypoint entrypoint
,
108 enum pipe_video_cap param
);
111 * Query a compute-specific capability/parameter/limit.
112 * \param param one of PIPE_COMPUTE_CAP_x
113 * \param ret pointer to a preallocated buffer that will be
114 * initialized to the parameter value, or NULL.
115 * \return size in bytes of the parameter value that would be
118 int (*get_compute_param
)(struct pipe_screen
*,
119 enum pipe_compute_cap param
,
123 * Query a timestamp in nanoseconds. The returned value should match
124 * PIPE_QUERY_TIMESTAMP. This function returns immediately and doesn't
125 * wait for rendering to complete (which cannot be achieved with queries).
127 uint64_t (*get_timestamp
)(struct pipe_screen
*);
132 * \param screen pipe screen
133 * \param priv a pointer to set in pipe_context::priv
134 * \param flags a mask of PIPE_CONTEXT_* flags
136 struct pipe_context
* (*context_create
)(struct pipe_screen
*screen
,
137 void *priv
, unsigned flags
);
140 * Check if the given pipe_format is supported as a texture or
142 * \param bindings bitmask of PIPE_BIND_*
144 boolean (*is_format_supported
)( struct pipe_screen
*,
145 enum pipe_format format
,
146 enum pipe_texture_target target
,
147 unsigned sample_count
,
151 * Check if the given pipe_format is supported as output for this codec/profile.
152 * \param profile profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN
154 boolean (*is_video_format_supported
)( struct pipe_screen
*,
155 enum pipe_format format
,
156 enum pipe_video_profile profile
,
157 enum pipe_video_entrypoint entrypoint
);
160 * Check if we can actually create the given resource (test the dimension,
161 * overall size, etc). Used to implement proxy textures.
162 * \return TRUE if size is OK, FALSE if too large.
164 boolean (*can_create_resource
)(struct pipe_screen
*screen
,
165 const struct pipe_resource
*templat
);
168 * Create a new texture object, using the given template info.
170 struct pipe_resource
* (*resource_create
)(struct pipe_screen
*,
171 const struct pipe_resource
*templat
);
173 struct pipe_resource
* (*resource_create_front
)(struct pipe_screen
*,
174 const struct pipe_resource
*templat
,
175 const void *map_front_private
);
178 * Create a texture from a winsys_handle. The handle is often created in
179 * another process by first creating a pipe texture and then calling
180 * resource_get_handle.
182 * NOTE: in the case of DRM_API_HANDLE_TYPE_FD handles, the caller
183 * retains ownership of the FD. (This is consistent with
184 * EGL_EXT_image_dma_buf_import)
186 * \param usage A combination of PIPE_HANDLE_USAGE_* flags.
188 struct pipe_resource
* (*resource_from_handle
)(struct pipe_screen
*,
189 const struct pipe_resource
*templat
,
190 struct winsys_handle
*handle
,
194 * Create a resource from user memory. This maps the user memory into
195 * the device address space.
197 struct pipe_resource
* (*resource_from_user_memory
)(struct pipe_screen
*,
198 const struct pipe_resource
*t
,
202 * Get a winsys_handle from a texture. Some platforms/winsys requires
203 * that the texture is created with a special usage flag like
204 * DISPLAYTARGET or PRIMARY.
206 * NOTE: in the case of DRM_API_HANDLE_TYPE_FD handles, the caller
207 * takes ownership of the FD. (This is consistent with
208 * EGL_MESA_image_dma_buf_export)
210 * \param usage A combination of PIPE_HANDLE_USAGE_* flags.
212 boolean (*resource_get_handle
)(struct pipe_screen
*,
213 struct pipe_resource
*tex
,
214 struct winsys_handle
*handle
,
218 void (*resource_destroy
)(struct pipe_screen
*,
219 struct pipe_resource
*pt
);
223 * Do any special operations to ensure frontbuffer contents are
224 * displayed, eg copy fake frontbuffer.
225 * \param winsys_drawable_handle an opaque handle that the calling context
227 * \param subbox an optional sub region to flush
229 void (*flush_frontbuffer
)( struct pipe_screen
*screen
,
230 struct pipe_resource
*resource
,
231 unsigned level
, unsigned layer
,
232 void *winsys_drawable_handle
,
233 struct pipe_box
*subbox
);
235 /** Set ptr = fence, with reference counting */
236 void (*fence_reference
)( struct pipe_screen
*screen
,
237 struct pipe_fence_handle
**ptr
,
238 struct pipe_fence_handle
*fence
);
241 * Wait for the fence to finish.
242 * \param timeout in nanoseconds (may be PIPE_TIMEOUT_INFINITE).
244 boolean (*fence_finish
)( struct pipe_screen
*screen
,
245 struct pipe_fence_handle
*fence
,
249 * Returns a driver-specific query.
251 * If \p info is NULL, the number of available queries is returned.
252 * Otherwise, the driver query at the specified \p index is returned
253 * in \p info. The function returns non-zero on success.
255 int (*get_driver_query_info
)(struct pipe_screen
*screen
,
257 struct pipe_driver_query_info
*info
);
260 * Returns a driver-specific query group.
262 * If \p info is NULL, the number of available groups is returned.
263 * Otherwise, the driver query group at the specified \p index is returned
264 * in \p info. The function returns non-zero on success.
266 int (*get_driver_query_group_info
)(struct pipe_screen
*screen
,
268 struct pipe_driver_query_group_info
*info
);
271 * Query information about memory usage.
273 void (*query_memory_info
)(struct pipe_screen
*screen
,
274 struct pipe_memory_info
*info
);
282 #endif /* P_SCREEN_H */