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"
55 struct pipe_fence_handle
;
63 * Gallium screen/adapter context. Basically everything
64 * hardware-specific that doesn't actually require a rendering
68 struct pipe_winsys
*winsys
;
70 void (*destroy
)( struct pipe_screen
* );
73 const char *(*get_name
)( struct pipe_screen
* );
75 const char *(*get_vendor
)( struct pipe_screen
* );
78 * Query an integer-valued capability/parameter/limit
79 * \param param one of PIPE_CAP_x
81 int (*get_param
)( struct pipe_screen
*, enum pipe_cap param
);
84 * Query a float-valued capability/parameter/limit
85 * \param param one of PIPE_CAP_x
87 float (*get_paramf
)( struct pipe_screen
*, enum pipe_cap param
);
90 * Query a per-shader-stage integer-valued capability/parameter/limit
91 * \param param one of PIPE_CAP_x
93 int (*get_shader_param
)( struct pipe_screen
*, unsigned shader
, enum pipe_shader_cap param
);
96 * Query an integer-valued capability/parameter/limit for a codec/profile
97 * \param param one of PIPE_VIDEO_CAP_x
99 int (*get_video_param
)( struct pipe_screen
*, enum pipe_video_profile profile
, enum pipe_video_cap param
);
101 struct pipe_context
* (*context_create
)( struct pipe_screen
*, void *priv
);
103 struct pipe_video_context
* (*video_context_create
)( struct pipe_screen
*screen
, void *priv
);
106 * Check if the given pipe_format is supported as a texture or
108 * \param bindings bitmask of PIPE_BIND_*
110 boolean (*is_format_supported
)( struct pipe_screen
*,
111 enum pipe_format format
,
112 enum pipe_texture_target target
,
113 unsigned sample_count
,
117 * Check if the given pipe_format is supported as output for this codec/profile.
118 * \param profile profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN
120 boolean (*is_video_format_supported
)( struct pipe_screen
*,
121 enum pipe_format format
,
122 enum pipe_video_profile profile
);
125 * Create a new texture object, using the given template info.
127 struct pipe_resource
* (*resource_create
)(struct pipe_screen
*,
128 const struct pipe_resource
*templat
);
131 * Create a texture from a winsys_handle. The handle is often created in
132 * another process by first creating a pipe texture and then calling
133 * resource_get_handle.
135 struct pipe_resource
* (*resource_from_handle
)(struct pipe_screen
*,
136 const struct pipe_resource
*templat
,
137 struct winsys_handle
*handle
);
140 * Get a winsys_handle from a texture. Some platforms/winsys requires
141 * that the texture is created with a special usage flag like
142 * DISPLAYTARGET or PRIMARY.
144 boolean (*resource_get_handle
)(struct pipe_screen
*,
145 struct pipe_resource
*tex
,
146 struct winsys_handle
*handle
);
149 void (*resource_destroy
)(struct pipe_screen
*,
150 struct pipe_resource
*pt
);
154 * Create a buffer that wraps user-space data.
156 * Effectively this schedules a delayed call to buffer_create
157 * followed by an upload of the data at *some point in the future*,
158 * or perhaps never. Basically the allocate/upload is delayed
159 * until the buffer is actually passed to hardware.
161 * The intention is to provide a quick way to turn regular data
162 * into a buffer, and secondly to avoid a copy operation if that
163 * data subsequently turns out to be only accessed by the CPU.
165 * Common example is OpenGL vertex buffers that are subsequently
166 * processed either by software TNL in the driver or by passing to
169 * XXX: What happens if the delayed call to buffer_create() fails?
171 * Note that ptr may be accessed at any time upto the time when the
172 * buffer is destroyed, so the data must not be freed before then.
174 struct pipe_resource
*(*user_buffer_create
)(struct pipe_screen
*screen
,
177 unsigned bind_flags
);
180 * Do any special operations to ensure frontbuffer contents are
181 * displayed, eg copy fake frontbuffer.
182 * \param winsys_drawable_handle an opaque handle that the calling context
185 void (*flush_frontbuffer
)( struct pipe_screen
*screen
,
186 struct pipe_resource
*resource
,
187 unsigned level
, unsigned layer
,
188 void *winsys_drawable_handle
);
192 /** Set ptr = fence, with reference counting */
193 void (*fence_reference
)( struct pipe_screen
*screen
,
194 struct pipe_fence_handle
**ptr
,
195 struct pipe_fence_handle
*fence
);
198 * Checks whether the fence has been signalled.
200 boolean (*fence_signalled
)( struct pipe_screen
*screen
,
201 struct pipe_fence_handle
*fence
);
204 * Wait for the fence to finish.
205 * \param timeout in nanoseconds
207 boolean (*fence_finish
)( struct pipe_screen
*screen
,
208 struct pipe_fence_handle
*fence
,
218 #endif /* P_SCREEN_H */