gitlab-ci: enable sanitizers for the meson builds
[mesa-waffle.git] / src / waffle / egl / wegl_platform.h
bloba1bbde0302069aa3a0539d7da5fdff0e24bc4fa0
1 // SPDX-FileCopyrightText: Copyright 2014 Emil Velikov
2 // SPDX-License-Identifier: BSD-2-Clause
4 #pragma once
6 #include <EGL/egl.h>
8 #include "wcore_platform.h"
9 #include "wcore_util.h"
11 #include "wegl_imports.h"
13 struct wegl_platform {
14 struct wcore_platform wcore;
16 // An EGL_PLATFORM_* enum, such as EGL_PLATFORM_GBM_KHR.
17 EGLenum egl_platform;
19 /// @brief Value of EGLConfig attribute EGL_SURFACE_TYPE
20 ///
21 /// When calling eglChooseConfig, Waffle sets the EGL_SURFACE_TYPE attribute
22 /// to this value. Since most Waffle EGL platforms call
23 /// eglCreatePlatformWindowSurface() from waffle_window_create(),
24 /// wegl_platform_init() initializes this to EGL_WINDOW_BIT.
25 ///
26 /// This field exists because not all EGL platforms support EGL_WINDOW_BIT;
27 /// namely, Mesa's "surfaceless" platform.
28 EGLint egl_surface_type_mask;
30 // EGL function pointers
31 void *eglHandle;
33 // See https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_client_extensions.txt
34 const char *client_extensions;
36 EGLBoolean (*eglMakeCurrent)(EGLDisplay dpy, EGLSurface draw,
37 EGLSurface read, EGLContext ctx);
38 __eglMustCastToProperFunctionPointerType
39 (*eglGetProcAddress)(const char *procname);
41 // EGL 1.5
42 EGLDisplay (*eglGetPlatformDisplay)(EGLenum platform, void *native_display,
43 const EGLAttrib *attrib_list);
45 // display
46 EGLDisplay (*eglGetDisplay)(EGLNativeDisplayType display_id);
47 EGLBoolean (*eglInitialize)(EGLDisplay dpy, EGLint *major, EGLint *minor);
48 const char * (*eglQueryString)(EGLDisplay dpy, EGLint name);
49 EGLint (*eglGetError)(void);
50 EGLBoolean (*eglTerminate)(EGLDisplay dpy);
52 // config
53 EGLBoolean (*eglChooseConfig)(EGLDisplay dpy, const EGLint *attrib_list,
54 EGLConfig *configs, EGLint config_size,
55 EGLint *num_config);
57 // context
58 EGLBoolean (*eglBindAPI)(EGLenum api);
59 EGLContext (*eglCreateContext)(EGLDisplay dpy, EGLConfig config,
60 EGLContext share_context,
61 const EGLint *attrib_list);
62 EGLBoolean (*eglDestroyContext)(EGLDisplay dpy, EGLContext ctx);
64 // window
65 EGLBoolean (*eglGetConfigAttrib)(EGLDisplay dpy, EGLConfig config,
66 EGLint attribute, EGLint *value);
67 EGLSurface (*eglCreateWindowSurface)(EGLDisplay dpy, EGLConfig config,
68 EGLNativeWindowType win,
69 const EGLint *attrib_list);
70 EGLSurface (*eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
71 const EGLint *attrib_list);
72 EGLBoolean (*eglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
73 EGLBoolean (*eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
75 // EGL_EXT_platform_display
76 EGLDisplay (*eglGetPlatformDisplayEXT)(EGLenum platform, void *native_display,
77 const EGLint *attrib_list);
79 // EGL_EXT_image_dma_buf_import_modifiers
80 EGLBoolean (*eglQueryDmaBufFormatsEXT)(EGLDisplay dpy,
81 EGLint max_formats,
82 EGLint *formats,
83 EGLint *num_formats);
84 EGLBoolean (*eglQueryDmaBufModifiersEXT)(EGLDisplay dpy, EGLint format,
85 EGLint max_modifiers,
86 EGLuint64KHR *modifiers,
87 EGLBoolean *external_only,
88 EGLint *num_modifiers);
91 DEFINE_CONTAINER_CAST_FUNC(wegl_platform,
92 struct wegl_platform,
93 struct wcore_platform,
94 wcore)
96 bool
97 wegl_platform_teardown(struct wegl_platform *self);
99 bool
100 wegl_platform_init(struct wegl_platform *self, EGLenum egl_platform);
103 // Can eglGetPlatformDisplay can be used for this platform?
105 // True if libEGL exposes the eglGetPlatformDisplay function; and if EGL
106 // supports the needed platform extension.
107 bool
108 wegl_platform_can_use_eglGetPlatformDisplay(const struct wegl_platform *plat);
110 // Can eglGetPlatformDisplayEXT can be used for this platform?
112 // True if libEGL exposes the eglGetPlatformDisplayEXT function; and if EGL
113 // supports the needed platform extension.
114 bool
115 wegl_platform_can_use_eglGetPlatformDisplayEXT(const struct wegl_platform *plat);