Merge remote branch 'main/master' into radeon-rewrite
[mesa.git] / src / gallium / state_trackers / egl / egl_tracker.h
1
2 #ifndef _EGL_TRACKER_H_
3 #define _EGL_TRACKER_H_
4
5 #include <stdint.h>
6
7 #include "eglconfig.h"
8 #include "eglcontext.h"
9 #include "egldisplay.h"
10 #include "egldriver.h"
11 #include "eglglobals.h"
12 #include "eglmode.h"
13 #include "eglscreen.h"
14 #include "eglsurface.h"
15
16 #include "xf86drm.h"
17 #include "xf86drmMode.h"
18
19 #include "pipe/p_compiler.h"
20
21 #include "state_tracker/st_public.h"
22
23 #define MAX_SCREENS 16
24
25 struct pipe_winsys;
26 struct pipe_screen;
27 struct pipe_context;
28 struct state_tracker;
29
30 struct drm_screen;
31 struct drm_context;
32
33 struct drm_device
34 {
35 _EGLDriver base; /* base class/object */
36
37 /*
38 * pipe
39 */
40
41 struct pipe_winsys *winsys;
42 struct pipe_screen *screen;
43
44 /*
45 * drm
46 */
47
48 int drmFD;
49 drmVersionPtr version;
50 int deviceID;
51
52 drmModeResPtr res;
53
54 struct drm_screen *screens[MAX_SCREENS];
55 size_t count_screens;
56 };
57
58 struct drm_surface
59 {
60 _EGLSurface base; /* base class/object */
61
62 /*
63 * pipe
64 */
65
66
67 struct st_framebuffer *stfb;
68
69 /*
70 * drm
71 */
72
73 struct drm_context *user;
74 struct drm_screen *screen;
75
76 int w;
77 int h;
78 };
79
80 struct drm_context
81 {
82 _EGLContext base; /* base class/object */
83
84 /* pipe */
85
86 struct pipe_context *pipe;
87 struct st_context *st;
88 };
89
90 struct drm_screen
91 {
92 _EGLScreen base;
93
94 /*
95 * pipe
96 */
97
98 struct pipe_buffer *buffer;
99 struct pipe_texture *tex;
100 struct pipe_surface *surface;
101
102 /*
103 * drm
104 */
105
106 struct {
107 unsigned height;
108 unsigned width;
109 unsigned pitch;
110 unsigned handle;
111 } front;
112
113 /* currently only support one connector */
114 drmModeConnectorPtr connector;
115 uint32_t connectorID;
116
117 /* Has this screen been shown */
118 int shown;
119
120 /* Surface that is currently attached to this screen */
121 struct drm_surface *surf;
122
123 /* framebuffer */
124 drmModeFBPtr fb;
125 uint32_t fbID;
126
127 /* crtc and mode used */
128 /*drmModeCrtcPtr crtc;*/
129 uint32_t crtcID;
130
131 drmModeModeInfoPtr mode;
132 };
133
134
135 static INLINE struct drm_context *
136 lookup_drm_context(EGLContext context)
137 {
138 _EGLContext *c = _eglLookupContext(context);
139 return (struct drm_context *) c;
140 }
141
142
143 static INLINE struct drm_surface *
144 lookup_drm_surface(EGLSurface surface)
145 {
146 _EGLSurface *s = _eglLookupSurface(surface);
147 return (struct drm_surface *) s;
148 }
149
150 static INLINE struct drm_screen *
151 lookup_drm_screen(EGLDisplay dpy, EGLScreenMESA screen)
152 {
153 _EGLScreen *s = _eglLookupScreen(dpy, screen);
154 return (struct drm_screen *) s;
155 }
156
157 /**
158 * egl_visual.h
159 */
160 /*@{*/
161 void drm_visual_modes_destroy(__GLcontextModes *modes);
162 __GLcontextModes* drm_visual_modes_create(unsigned count, size_t minimum_size);
163 __GLcontextModes* drm_visual_from_config(_EGLConfig *conf);
164 /*@}*/
165
166 /**
167 * egl_surface.h
168 */
169 /*@{*/
170 void drm_takedown_shown_screen(_EGLDriver *drv, struct drm_screen *screen);
171 /*@}*/
172
173 /**
174 * All function exported to the egl side.
175 */
176 /*@{*/
177 EGLBoolean drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor);
178 EGLBoolean drm_terminate(_EGLDriver *drv, EGLDisplay dpy);
179 EGLContext drm_create_context(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
180 EGLBoolean drm_destroy_context(_EGLDriver *drv, EGLDisplay dpy, EGLContext context);
181 EGLSurface drm_create_window_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
182 EGLSurface drm_create_pixmap_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list);
183 EGLSurface drm_create_pbuffer_surface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
184 EGLSurface drm_create_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, const EGLint *attrib_list);
185 EGLBoolean drm_show_screen_surface_mesa(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface, EGLModeMESA m);
186 EGLBoolean drm_destroy_surface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface);
187 EGLBoolean drm_make_current(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext context);
188 EGLBoolean drm_swap_buffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw);
189 /*@}*/
190
191 #endif