VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.18.0/glamor.h@ 74087

Last change on this file since 74087 was 58634, checked in by vboxsync, 9 years ago

Additions/x11: added header files for building X.Org video driver against X.Org Server 1.18.

  • Property svn:eol-style set to native
File size: 13.6 KB
Line 
1/*
2 * Copyright © 2008 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Eric Anholt <[email protected]>
25 * Zhigang Gong <[email protected]>
26 *
27 */
28
29#ifndef GLAMOR_H
30#define GLAMOR_H
31
32#include <scrnintstr.h>
33#include <pixmapstr.h>
34#include <gcstruct.h>
35#include <picturestr.h>
36#include <fb.h>
37#include <fbpict.h>
38#ifdef GLAMOR_FOR_XORG
39#include <xf86xv.h>
40#endif
41
42struct glamor_context;
43
44/*
45 * glamor_pixmap_type : glamor pixmap's type.
46 * @MEMORY: pixmap is in memory.
47 * @TEXTURE_DRM: pixmap is in a texture created from a DRM buffer.
48 * @SEPARATE_TEXTURE: The texture is created from a DRM buffer, but
49 * the format is incompatible, so this type of pixmap
50 * will never fallback to DDX layer.
51 * @DRM_ONLY: pixmap is in a external DRM buffer.
52 * @TEXTURE_ONLY: pixmap is in an internal texture.
53 */
54typedef enum glamor_pixmap_type {
55 GLAMOR_MEMORY = 0, /* Newly calloc()ed pixmaps are memory. */
56 GLAMOR_TEXTURE_DRM,
57 GLAMOR_DRM_ONLY,
58 GLAMOR_TEXTURE_ONLY,
59} glamor_pixmap_type_t;
60
61#define GLAMOR_EGL_EXTERNAL_BUFFER 3
62#define GLAMOR_USE_EGL_SCREEN (1 << 0)
63#define GLAMOR_NO_DRI3 (1 << 1)
64#define GLAMOR_VALID_FLAGS (GLAMOR_USE_EGL_SCREEN \
65 | GLAMOR_NO_DRI3)
66
67/* @glamor_init: Initialize glamor internal data structure.
68 *
69 * @screen: Current screen pointer.
70 * @flags: Please refer the flags description above.
71 *
72 * @GLAMOR_USE_EGL_SCREEN:
73 * If you are using EGL layer, then please set this bit
74 * on, otherwise, clear it.
75 *
76 * @GLAMOR_NO_DRI3
77 * Disable the built-in DRI3 support
78 *
79 * This function initializes necessary internal data structure
80 * for glamor. And before calling into this function, the OpenGL
81 * environment should be ready. Should be called before any real
82 * glamor rendering or texture allocation functions. And should
83 * be called after the DDX's screen initialization or at the last
84 * step of the DDX's screen initialization.
85 */
86extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags);
87extern _X_EXPORT void glamor_fini(ScreenPtr screen);
88
89/* This function is used to free the glamor private screen's
90 * resources. If the DDX driver is not set GLAMOR_USE_SCREEN,
91 * then, DDX need to call this function at proper stage, if
92 * it is the xorg DDX driver,then it should be called at free
93 * screen stage not the close screen stage. The reason is after
94 * call to this function, the xorg DDX may need to destroy the
95 * screen pixmap which must be a glamor pixmap and requires
96 * the internal data structure still exist at that time.
97 * Otherwise, the glamor internal structure will not be freed.*/
98extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen);
99
100/* Let glamor to know the screen's fbo. The low level
101 * driver should already assign a tex
102 * to this pixmap through the set_pixmap_texture. */
103extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap,
104 PixmapPtr *back_pixmap);
105
106extern _X_EXPORT uint32_t glamor_get_pixmap_texture(PixmapPtr pixmap);
107
108extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
109 unsigned int tex);
110
111extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
112 glamor_pixmap_type_t type);
113extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
114extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
115
116extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
117 int depth, unsigned int usage);
118extern _X_EXPORT Bool glamor_destroy_pixmap(PixmapPtr pixmap);
119
120#define GLAMOR_CREATE_PIXMAP_CPU 0x100
121#define GLAMOR_CREATE_PIXMAP_FIXUP 0x101
122#define GLAMOR_CREATE_FBO_NO_FBO 0x103
123#define GLAMOR_CREATE_NO_LARGE 0x105
124#define GLAMOR_CREATE_PIXMAP_NO_TEXTURE 0x106
125
126/* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo).
127 *
128 * @front: front pixmap.
129 * @back: back pixmap.
130 *
131 * Used by the DRI2 page flip. This function will exchange the KHR images and
132 * fbos of the two pixmaps.
133 * */
134extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front,
135 PixmapPtr back);
136
137extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front,
138 PixmapPtr back);
139
140/* The DDX is not supposed to call these three functions */
141extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
142extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr
143 screen,
144 int w,
145 int h,
146 Bool linear);
147extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
148 unsigned int, Bool,
149 CARD16 *, CARD32 *);
150
151extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap);
152
153extern _X_EXPORT void *glamor_egl_get_gbm_device(ScreenPtr screen);
154
155/* @glamor_supports_pixmap_import_export: Returns whether
156 * glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and
157 * glamor_pixmap_from_fd() are supported.
158 *
159 * @screen: Current screen pointer.
160 *
161 * To have DRI3 support enabled, glamor and glamor_egl need to be
162 * initialized. glamor also has to be compiled with gbm support.
163 *
164 * The EGL layer needs to have the following extensions working:
165 *
166 * .EGL_KHR_gl_texture_2D_image
167 * .EGL_EXT_image_dma_buf_import
168 * */
169extern _X_EXPORT Bool glamor_supports_pixmap_import_export(ScreenPtr screen);
170
171/* @glamor_fd_from_pixmap: Get a dma-buf fd from a pixmap.
172 *
173 * @screen: Current screen pointer.
174 * @pixmap: The pixmap from which we want the fd.
175 * @stride, @size: Pointers to fill the stride and size of the
176 * buffer associated to the fd.
177 *
178 * the pixmap and the buffer associated by the fd will share the same
179 * content.
180 * Returns the fd on success, -1 on error.
181 * */
182extern _X_EXPORT int glamor_fd_from_pixmap(ScreenPtr screen,
183 PixmapPtr pixmap,
184 CARD16 *stride, CARD32 *size);
185
186/**
187 * @glamor_name_from_pixmap: Gets a gem name from a pixmap.
188 *
189 * @pixmap: The pixmap from which we want the gem name.
190 *
191 * the pixmap and the buffer associated by the gem name will share the
192 * same content. This function can be used by the DDX to support DRI2,
193 * and needs the same set of buffer export GL extensions as DRI3
194 * support.
195 *
196 * Returns the name on success, -1 on error.
197 * */
198extern _X_EXPORT int glamor_name_from_pixmap(PixmapPtr pixmap,
199 CARD16 *stride, CARD32 *size);
200
201/* @glamor_gbm_bo_from_pixmap: Get a GBM bo from a pixmap.
202 *
203 * @screen: Current screen pointer.
204 * @pixmap: The pixmap from which we want the fd.
205 * @stride, @size: Pointers to fill the stride and size of the
206 * buffer associated to the fd.
207 *
208 * the pixmap and the buffer represented by the gbm_bo will share the same
209 * content.
210 *
211 * Returns the gbm_bo on success, NULL on error.
212 * */
213extern _X_EXPORT void *glamor_gbm_bo_from_pixmap(ScreenPtr screen,
214 PixmapPtr pixmap);
215
216/* @glamor_pixmap_from_fd: Creates a pixmap to wrap a dma-buf fd.
217 *
218 * @screen: Current screen pointer.
219 * @fd: The dma-buf fd to import.
220 * @width: The width of the buffer.
221 * @height: The height of the buffer.
222 * @stride: The stride of the buffer.
223 * @depth: The depth of the buffer.
224 * @bpp: The number of bpp of the buffer.
225 *
226 * Returns a valid pixmap if the import succeeded, else NULL.
227 * */
228extern _X_EXPORT PixmapPtr glamor_pixmap_from_fd(ScreenPtr screen,
229 int fd,
230 CARD16 width,
231 CARD16 height,
232 CARD16 stride,
233 CARD8 depth,
234 CARD8 bpp);
235
236/* @glamor_back_pixmap_from_fd: Backs an existing pixmap with a dma-buf fd.
237 *
238 * @pixmap: Pixmap to change backing for
239 * @fd: The dma-buf fd to import.
240 * @width: The width of the buffer.
241 * @height: The height of the buffer.
242 * @stride: The stride of the buffer.
243 * @depth: The depth of the buffer.
244 * @bpp: The number of bpp of the buffer.
245 *
246 * Returns TRUE if successful, FALSE on failure.
247 * */
248extern _X_EXPORT Bool glamor_back_pixmap_from_fd(PixmapPtr pixmap,
249 int fd,
250 CARD16 width,
251 CARD16 height,
252 CARD16 stride,
253 CARD8 depth,
254 CARD8 bpp);
255#ifdef GLAMOR_FOR_XORG
256
257#define GLAMOR_EGL_MODULE_NAME "glamoregl"
258
259/* @glamor_egl_init: Initialize EGL environment.
260 *
261 * @scrn: Current screen info pointer.
262 * @fd: Current drm fd.
263 *
264 * This function creates and intialize EGL contexts.
265 * Should be called from DDX's preInit function.
266 * Return TRUE if success, otherwise return FALSE.
267 * */
268extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd);
269
270extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
271
272/* @glamor_egl_create_textured_screen: Create textured screen pixmap.
273 *
274 * @screen: screen pointer to be processed.
275 * @handle: screen pixmap's BO handle.
276 * @stride: screen pixmap's stride in bytes.
277 *
278 * This function is similar with the create_textured_pixmap. As the
279 * screen pixmap is a special, we handle it separately in this function.
280 */
281extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
282 int handle, int stride);
283
284/* @glamor_egl_create_textured_screen_ext:
285 *
286 * extent one parameter to track the pointer of the DDX layer's back pixmap.
287 * We need this pointer during the closing screen stage. As before back to
288 * the DDX's close screen, we have to free all the glamor related resources.
289 */
290extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
291 int handle,
292 int stride,
293 PixmapPtr
294 *back_pixmap);
295
296/*
297 * @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from
298 * a BO handle.
299 *
300 * @pixmap: The pixmap need to be processed.
301 * @handle: The BO's handle attached to this pixmap at DDX layer.
302 * @stride: Stride in bytes for this pixmap.
303 *
304 * This function try to create a texture from the handle and attach
305 * the texture to the pixmap , thus glamor can render to this pixmap
306 * as well. Return true if successful, otherwise return FALSE.
307 */
308extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
309 int handle, int stride);
310
311/*
312 * @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap
313 * from a gbm_bo.
314 *
315 * @pixmap: The pixmap need to be processed.
316 * @bo: a pointer on a gbm_bo structure attached to this pixmap at DDX layer.
317 *
318 * This function is similar to glamor_egl_create_textured_pixmap.
319 */
320extern _X_EXPORT Bool
321 glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo);
322
323#endif
324
325extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
326 struct glamor_context *glamor_ctx);
327extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
328
329extern _X_EXPORT int glamor_create_gc(GCPtr gc);
330
331extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes,
332 DrawablePtr drawable);
333
334extern _X_EXPORT void glamor_destroy_gc(GCPtr gc);
335
336#define HAS_GLAMOR_DESTROY_GC 1
337
338extern Bool _X_EXPORT glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
339extern void _X_EXPORT glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_region);
340
341#define HAS_GLAMOR_TEXT 1
342
343#ifdef GLAMOR_FOR_XORG
344extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen,
345 int num_texture_ports);
346#endif
347
348#endif /* GLAMOR_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette