radeon_glamor.h revision 39413783
1/*
2 * Copyright © 2011 Intel Corporation.
3 *             2012 Advanced Micro Devices, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use, copy,
9 * modify, merge, publish, distribute, sublicense, and/or sell copies
10 * of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including
14 * the next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 */
26
27#ifndef RADEON_GLAMOR_H
28#define RADEON_GLAMOR_H
29
30#include "xf86xv.h"
31
32struct radeon_pixmap;
33
34#ifdef USE_GLAMOR
35
36#ifndef HAVE_GLAMOR_FINISH
37#include <GL/gl.h>
38#endif
39
40#include <gbm.h>
41
42#define GLAMOR_FOR_XORG  1
43#include <glamor.h>
44
45#include "radeon_surface.h"
46
47#define RADEON_CREATE_PIXMAP_SHARED(usage) \
48	(((usage) & ~RADEON_CREATE_PIXMAP_TILING_FLAGS) == RADEON_CREATE_PIXMAP_DRI2 || \
49	 (usage) == CREATE_PIXMAP_USAGE_SHARED)
50
51#ifndef GLAMOR_NO_DRI3
52#define GLAMOR_NO_DRI3 0
53#define glamor_fd_from_pixmap glamor_dri3_fd_from_pixmap
54#define glamor_pixmap_from_fd glamor_egl_dri3_pixmap_from_fd
55#endif
56
57#ifndef GLAMOR_INVERTED_Y_AXIS
58#define GLAMOR_INVERTED_Y_AXIS 0
59#endif
60#ifndef GLAMOR_USE_SCREEN
61#define GLAMOR_USE_SCREEN 0
62#endif
63#ifndef GLAMOR_USE_PICTURE_SCREEN
64#define GLAMOR_USE_PICTURE_SCREEN 0
65#endif
66
67Bool radeon_glamor_pre_init(ScrnInfoPtr scrn);
68Bool radeon_glamor_init(ScreenPtr screen);
69void radeon_glamor_fini(ScreenPtr screen);
70void radeon_glamor_screen_init(ScreenPtr screen);
71Bool radeon_glamor_create_screen_resources(ScreenPtr screen);
72void radeon_glamor_free_screen(int scrnIndex, int flags);
73
74Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_buffer *bo);
75void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst);
76PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap);
77
78XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt);
79
80static inline void
81radeon_glamor_finish(ScrnInfoPtr scrn)
82{
83	RADEONInfoPtr info = RADEONPTR(scrn);
84
85#if HAVE_GLAMOR_FINISH
86	glamor_finish(scrn->pScreen);
87#else
88	glamor_block_handler(scrn->pScreen);
89	glFinish();
90#endif
91
92	info->gpu_flushed++;
93}
94
95#else
96
97static inline Bool radeon_glamor_pre_init(ScrnInfoPtr scrn) { return FALSE; }
98static inline Bool radeon_glamor_init(ScreenPtr screen) { return FALSE; }
99static inline void radeon_glamor_fini(ScreenPtr screen) { }
100static inline Bool radeon_glamor_create_screen_resources(ScreenPtr screen) { return FALSE; }
101static inline void radeon_glamor_free_screen(int scrnIndex, int flags) { }
102
103static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_buffer *bo) { return TRUE; }
104
105static inline void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {}
106static inline PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap) { return pixmap; }
107
108static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap) { return NULL; }
109
110static inline XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt) { return NULL; }
111
112static inline void radeon_glamor_finish(ScrnInfoPtr pScrn) { }
113
114#endif
115
116#endif /* RADEON_GLAMOR_H */
117