[OPENGL]
[reactos.git] / reactos / dll / opengl / mesa / src / gallium / include / pipe / p_screen.h
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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 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.
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 type */
54 struct winsys_handle;
55 /** Opaque type */
56 struct pipe_fence_handle;
57 struct pipe_winsys;
58 struct pipe_resource;
59 struct pipe_surface;
60 struct pipe_transfer;
61
62
63 /**
64 * Gallium screen/adapter context. Basically everything
65 * hardware-specific that doesn't actually require a rendering
66 * context.
67 */
68 struct pipe_screen {
69 struct pipe_winsys *winsys;
70
71 void (*destroy)( struct pipe_screen * );
72
73
74 const char *(*get_name)( struct pipe_screen * );
75
76 const char *(*get_vendor)( struct pipe_screen * );
77
78 /**
79 * Query an integer-valued capability/parameter/limit
80 * \param param one of PIPE_CAP_x
81 */
82 int (*get_param)( struct pipe_screen *, enum pipe_cap param );
83
84 /**
85 * Query a float-valued capability/parameter/limit
86 * \param param one of PIPE_CAP_x
87 */
88 float (*get_paramf)( struct pipe_screen *, enum pipe_capf param );
89
90 /**
91 * Query a per-shader-stage integer-valued capability/parameter/limit
92 * \param param one of PIPE_CAP_x
93 */
94 int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param );
95
96 /**
97 * Query an integer-valued capability/parameter/limit for a codec/profile
98 * \param param one of PIPE_VIDEO_CAP_x
99 */
100 int (*get_video_param)( struct pipe_screen *,
101 enum pipe_video_profile profile,
102 enum pipe_video_cap param );
103
104 struct pipe_context * (*context_create)( struct pipe_screen *,
105 void *priv );
106
107 /**
108 * Check if the given pipe_format is supported as a texture or
109 * drawing surface.
110 * \param bindings bitmask of PIPE_BIND_*
111 */
112 boolean (*is_format_supported)( struct pipe_screen *,
113 enum pipe_format format,
114 enum pipe_texture_target target,
115 unsigned sample_count,
116 unsigned bindings );
117
118 /**
119 * Check if the given pipe_format is supported as output for this codec/profile.
120 * \param profile profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN
121 */
122 boolean (*is_video_format_supported)( struct pipe_screen *,
123 enum pipe_format format,
124 enum pipe_video_profile profile );
125
126 /**
127 * Create a new texture object, using the given template info.
128 */
129 struct pipe_resource * (*resource_create)(struct pipe_screen *,
130 const struct pipe_resource *templat);
131
132 /**
133 * Create a texture from a winsys_handle. The handle is often created in
134 * another process by first creating a pipe texture and then calling
135 * resource_get_handle.
136 */
137 struct pipe_resource * (*resource_from_handle)(struct pipe_screen *,
138 const struct pipe_resource *templat,
139 struct winsys_handle *handle);
140
141 /**
142 * Get a winsys_handle from a texture. Some platforms/winsys requires
143 * that the texture is created with a special usage flag like
144 * DISPLAYTARGET or PRIMARY.
145 */
146 boolean (*resource_get_handle)(struct pipe_screen *,
147 struct pipe_resource *tex,
148 struct winsys_handle *handle);
149
150
151 void (*resource_destroy)(struct pipe_screen *,
152 struct pipe_resource *pt);
153
154
155 /**
156 * Create a buffer that wraps user-space data.
157 *
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.
162 *
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.
166 *
167 * Common example is OpenGL vertex buffers that are subsequently
168 * processed either by software TNL in the driver or by passing to
169 * hardware.
170 *
171 * XXX: What happens if the delayed call to buffer_create() fails?
172 *
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.
175 */
176 struct pipe_resource *(*user_buffer_create)(struct pipe_screen *screen,
177 void *ptr,
178 unsigned bytes,
179 unsigned bind_flags);
180
181 /**
182 * Do any special operations to ensure frontbuffer contents are
183 * displayed, eg copy fake frontbuffer.
184 * \param winsys_drawable_handle an opaque handle that the calling context
185 * gets out-of-band
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
192
193
194 /** Set ptr = fence, with reference counting */
195 void (*fence_reference)( struct pipe_screen *screen,
196 struct pipe_fence_handle **ptr,
197 struct pipe_fence_handle *fence );
198
199 /**
200 * Checks whether the fence has been signalled.
201 */
202 boolean (*fence_signalled)( struct pipe_screen *screen,
203 struct pipe_fence_handle *fence );
204
205 /**
206 * Wait for the fence to finish.
207 * \param timeout in nanoseconds
208 */
209 boolean (*fence_finish)( struct pipe_screen *screen,
210 struct pipe_fence_handle *fence,
211 uint64_t timeout );
212
213 };
214
215
216 #ifdef __cplusplus
217 }
218 #endif
219
220 #endif /* P_SCREEN_H */