s/Tungsten Graphics/VMware/
[mesa.git] / src / gallium / include / pipe / p_screen.h
1 /**************************************************************************
2 *
3 * Copyright 2007 VMware, Inc.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 /**
29 * @file
30 *
31 * Screen, Adapter or GPU
32 *
33 * These are driver functions/facilities that are context independent.
34 */
35
36
37 #ifndef P_SCREEN_H
38 #define P_SCREEN_H
39
40
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"
45
46
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52
53 /** Opaque types */
54 struct winsys_handle;
55 struct pipe_fence_handle;
56 struct pipe_resource;
57 struct pipe_surface;
58 struct pipe_transfer;
59 struct pipe_box;
60
61
62 /**
63 * Gallium screen/adapter context. Basically everything
64 * hardware-specific that doesn't actually require a rendering
65 * context.
66 */
67 struct pipe_screen {
68 void (*destroy)( struct pipe_screen * );
69
70 const char *(*get_name)( struct pipe_screen * );
71
72 const char *(*get_vendor)( struct pipe_screen * );
73
74 /**
75 * Query an integer-valued capability/parameter/limit
76 * \param param one of PIPE_CAP_x
77 */
78 int (*get_param)( struct pipe_screen *, enum pipe_cap param );
79
80 /**
81 * Query a float-valued capability/parameter/limit
82 * \param param one of PIPE_CAP_x
83 */
84 float (*get_paramf)( struct pipe_screen *, enum pipe_capf param );
85
86 /**
87 * Query a per-shader-stage integer-valued capability/parameter/limit
88 * \param param one of PIPE_CAP_x
89 */
90 int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param );
91
92 /**
93 * Query an integer-valued capability/parameter/limit for a codec/profile
94 * \param param one of PIPE_VIDEO_CAP_x
95 */
96 int (*get_video_param)( struct pipe_screen *,
97 enum pipe_video_profile profile,
98 enum pipe_video_entrypoint entrypoint,
99 enum pipe_video_cap param );
100
101 /**
102 * Query a compute-specific capability/parameter/limit.
103 * \param param one of PIPE_COMPUTE_CAP_x
104 * \param ret pointer to a preallocated buffer that will be
105 * initialized to the parameter value, or NULL.
106 * \return size in bytes of the parameter value that would be
107 * returned.
108 */
109 int (*get_compute_param)(struct pipe_screen *,
110 enum pipe_compute_cap param,
111 void *ret);
112
113 /**
114 * Query a timestamp in nanoseconds. The returned value should match
115 * PIPE_QUERY_TIMESTAMP. This function returns immediately and doesn't
116 * wait for rendering to complete (which cannot be achieved with queries).
117 */
118 uint64_t (*get_timestamp)(struct pipe_screen *);
119
120 struct pipe_context * (*context_create)( struct pipe_screen *,
121 void *priv );
122
123 /**
124 * Check if the given pipe_format is supported as a texture or
125 * drawing surface.
126 * \param bindings bitmask of PIPE_BIND_*
127 */
128 boolean (*is_format_supported)( struct pipe_screen *,
129 enum pipe_format format,
130 enum pipe_texture_target target,
131 unsigned sample_count,
132 unsigned bindings );
133
134 /**
135 * Check if the given pipe_format is supported as output for this codec/profile.
136 * \param profile profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN
137 */
138 boolean (*is_video_format_supported)( struct pipe_screen *,
139 enum pipe_format format,
140 enum pipe_video_profile profile,
141 enum pipe_video_entrypoint entrypoint );
142
143 /**
144 * Check if we can actually create the given resource (test the dimension,
145 * overall size, etc). Used to implement proxy textures.
146 * \return TRUE if size is OK, FALSE if too large.
147 */
148 boolean (*can_create_resource)(struct pipe_screen *screen,
149 const struct pipe_resource *templat);
150
151 /**
152 * Create a new texture object, using the given template info.
153 */
154 struct pipe_resource * (*resource_create)(struct pipe_screen *,
155 const struct pipe_resource *templat);
156
157 /**
158 * Create a texture from a winsys_handle. The handle is often created in
159 * another process by first creating a pipe texture and then calling
160 * resource_get_handle.
161 */
162 struct pipe_resource * (*resource_from_handle)(struct pipe_screen *,
163 const struct pipe_resource *templat,
164 struct winsys_handle *handle);
165
166 /**
167 * Get a winsys_handle from a texture. Some platforms/winsys requires
168 * that the texture is created with a special usage flag like
169 * DISPLAYTARGET or PRIMARY.
170 */
171 boolean (*resource_get_handle)(struct pipe_screen *,
172 struct pipe_resource *tex,
173 struct winsys_handle *handle);
174
175
176 void (*resource_destroy)(struct pipe_screen *,
177 struct pipe_resource *pt);
178
179
180 /**
181 * Do any special operations to ensure frontbuffer contents are
182 * displayed, eg copy fake frontbuffer.
183 * \param winsys_drawable_handle an opaque handle that the calling context
184 * gets out-of-band
185 * \param subbox an optional sub region to flush
186 */
187 void (*flush_frontbuffer)( struct pipe_screen *screen,
188 struct pipe_resource *resource,
189 unsigned level, unsigned layer,
190 void *winsys_drawable_handle,
191 struct pipe_box *subbox );
192
193 /** Set ptr = fence, with reference counting */
194 void (*fence_reference)( struct pipe_screen *screen,
195 struct pipe_fence_handle **ptr,
196 struct pipe_fence_handle *fence );
197
198 /**
199 * Checks whether the fence has been signalled.
200 */
201 boolean (*fence_signalled)( struct pipe_screen *screen,
202 struct pipe_fence_handle *fence );
203
204 /**
205 * Wait for the fence to finish.
206 * \param timeout in nanoseconds (may be PIPE_TIMEOUT_INFINITE).
207 */
208 boolean (*fence_finish)( struct pipe_screen *screen,
209 struct pipe_fence_handle *fence,
210 uint64_t timeout );
211
212 /**
213 * Returns a driver-specific query.
214 *
215 * If \p info is NULL, the number of available queries is returned.
216 * Otherwise, the driver query at the specified \p index is returned
217 * in \p info. The function returns non-zero on success.
218 */
219 int (*get_driver_query_info)(struct pipe_screen *screen,
220 unsigned index,
221 struct pipe_driver_query_info *info);
222
223 };
224
225
226 #ifdef __cplusplus
227 }
228 #endif
229
230 #endif /* P_SCREEN_H */