1b8e80941Smrg#!/usr/bin/env python
2b8e80941Smrg
3b8e80941Smrg"""
4b8e80941SmrgContains a list of EGL functions to generate dispatch functions for.
5b8e80941Smrg
6b8e80941SmrgThis is used from gen_egl_dispatch.py.
7b8e80941Smrg
8b8e80941SmrgEGL_FUNCTIONS is a sequence of (name, eglData) pairs, where name is the name
9b8e80941Smrgof the function, and eglData is a dictionary containing data about that
10b8e80941Smrgfunction.
11b8e80941Smrg
12b8e80941SmrgThe values in the eglData dictionary are:
13b8e80941Smrg- method (string):
14b8e80941Smrg    How to select a vendor library. See "Method values" below.
15b8e80941Smrg
16b8e80941Smrg- prefix (string):
17b8e80941Smrg    This string is prepended to the name of the dispatch function. If
18b8e80941Smrg    unspecified, the default is "" (an empty string).
19b8e80941Smrg
20b8e80941Smrg- static (boolean)
21b8e80941Smrg  If True, this function should be declared static.
22b8e80941Smrg
23b8e80941Smrg- "public" (boolean)
24b8e80941Smrg    If True, the function should be exported from the library. Vendor libraries
25b8e80941Smrg    generally should not use this.
26b8e80941Smrg
27b8e80941Smrg- extension (string):
28b8e80941Smrg    If specified, this is the name of a macro to check for before defining a
29b8e80941Smrg    function. Used for checking for extension macros and such.
30b8e80941Smrg
31b8e80941Smrg- retval (string):
32b8e80941Smrg    If specified, this is a C expression with the default value to return if we
33b8e80941Smrg    can't find a function to call. By default, it will try to guess from the
34b8e80941Smrg    return type: EGL_NO_whatever for the various handle types, NULL for
35b8e80941Smrg    pointers, and zero for everything else.
36b8e80941Smrg
37b8e80941Smrgmethod values:
38b8e80941Smrg- "custom"
39b8e80941Smrg    The dispatch stub will be hand-written instead of generated.
40b8e80941Smrg
41b8e80941Smrg- "none"
42b8e80941Smrg    No dispatch function exists at all, but the function should still have an
43b8e80941Smrg    entry in the index array. This is for other functions that a stub may need
44b8e80941Smrg    to call that are implemented in libEGL itself.
45b8e80941Smrg
46b8e80941Smrg- "display"
47b8e80941Smrg    Select a vendor from an EGLDisplay argument.
48b8e80941Smrg
49b8e80941Smrg- "device"
50b8e80941Smrg    Select a vendor from an EGLDeviceEXT argument.
51b8e80941Smrg
52b8e80941Smrg- "current"
53b8e80941Smrg    Select the vendor that owns the current context.
54b8e80941Smrg"""
55b8e80941Smrg
56b8e80941Smrgdef _eglFunc(name, method, static=None, public=False, inheader=None, prefix="dispatch_", extension=None, retval=None):
57b8e80941Smrg    """
58b8e80941Smrg    A convenience function to define an entry in the EGL function list.
59b8e80941Smrg    """
60b8e80941Smrg    if static is None:
61b8e80941Smrg        static = (not public and method != "custom")
62b8e80941Smrg    if inheader is None:
63b8e80941Smrg        inheader = (not static)
64b8e80941Smrg    values = {
65b8e80941Smrg        "method" : method,
66b8e80941Smrg        "prefix" : prefix,
67b8e80941Smrg        "extension" : extension,
68b8e80941Smrg        "retval" : retval,
69b8e80941Smrg        "static" : static,
70b8e80941Smrg        "public" : public,
71b8e80941Smrg        "inheader" : inheader,
72b8e80941Smrg    }
73b8e80941Smrg    return (name, values)
74b8e80941Smrg
75b8e80941SmrgEGL_FUNCTIONS = (
76b8e80941Smrg    # EGL_VERSION_1_0
77b8e80941Smrg    _eglFunc("eglChooseConfig",                      "none"),
78b8e80941Smrg    _eglFunc("eglCopyBuffers",                       "none"),
79b8e80941Smrg    _eglFunc("eglCreateContext",                     "none"),
80b8e80941Smrg    _eglFunc("eglCreatePbufferSurface",              "none"),
81b8e80941Smrg    _eglFunc("eglCreatePixmapSurface",               "none"),
82b8e80941Smrg    _eglFunc("eglCreateWindowSurface",               "none"),
83b8e80941Smrg    _eglFunc("eglDestroyContext",                    "none"),
84b8e80941Smrg    _eglFunc("eglDestroySurface",                    "none"),
85b8e80941Smrg    _eglFunc("eglGetConfigAttrib",                   "none"),
86b8e80941Smrg    _eglFunc("eglGetConfigs",                        "none"),
87b8e80941Smrg    _eglFunc("eglQueryContext",                      "none"),
88b8e80941Smrg    _eglFunc("eglQuerySurface",                      "none"),
89b8e80941Smrg    _eglFunc("eglSwapBuffers",                       "none"),
90b8e80941Smrg    _eglFunc("eglWaitGL",                            "none"),
91b8e80941Smrg    _eglFunc("eglWaitNative",                        "none"),
92b8e80941Smrg    _eglFunc("eglTerminate",                         "none"),
93b8e80941Smrg    _eglFunc("eglInitialize",                        "none"),
94b8e80941Smrg
95b8e80941Smrg    _eglFunc("eglGetCurrentDisplay",                 "none"),
96b8e80941Smrg    _eglFunc("eglGetCurrentSurface",                 "none"),
97b8e80941Smrg    _eglFunc("eglGetDisplay",                        "none"),
98b8e80941Smrg    _eglFunc("eglGetError",                          "none"),
99b8e80941Smrg    _eglFunc("eglGetProcAddress",                    "none"),
100b8e80941Smrg    _eglFunc("eglMakeCurrent",                       "none"),
101b8e80941Smrg    _eglFunc("eglQueryString",                       "none"),
102b8e80941Smrg
103b8e80941Smrg    # EGL_VERSION_1_1
104b8e80941Smrg    _eglFunc("eglBindTexImage",                      "none"),
105b8e80941Smrg    _eglFunc("eglReleaseTexImage",                   "none"),
106b8e80941Smrg    _eglFunc("eglSurfaceAttrib",                     "none"),
107b8e80941Smrg    _eglFunc("eglSwapInterval",                      "none"),
108b8e80941Smrg
109b8e80941Smrg    # EGL_VERSION_1_2
110b8e80941Smrg    _eglFunc("eglCreatePbufferFromClientBuffer",     "none"),
111b8e80941Smrg    _eglFunc("eglWaitClient",                        "none"),
112b8e80941Smrg    _eglFunc("eglBindAPI",                           "none"),
113b8e80941Smrg    _eglFunc("eglQueryAPI",                          "none"),
114b8e80941Smrg    _eglFunc("eglReleaseThread",                     "none"),
115b8e80941Smrg
116b8e80941Smrg    # EGL_VERSION_1_4
117b8e80941Smrg    _eglFunc("eglGetCurrentContext",                 "none"),
118b8e80941Smrg
119b8e80941Smrg    # EGL_VERSION_1_5
120b8e80941Smrg    _eglFunc("eglCreateSync",                        "none"),
121b8e80941Smrg    _eglFunc("eglDestroySync",                       "none"),
122b8e80941Smrg    _eglFunc("eglClientWaitSync",                    "none"),
123b8e80941Smrg    _eglFunc("eglGetSyncAttrib",                     "none"),
124b8e80941Smrg    _eglFunc("eglCreateImage",                       "none"),
125b8e80941Smrg    _eglFunc("eglDestroyImage",                      "none"),
126b8e80941Smrg    _eglFunc("eglCreatePlatformWindowSurface",       "none"),
127b8e80941Smrg    _eglFunc("eglCreatePlatformPixmapSurface",       "none"),
128b8e80941Smrg    _eglFunc("eglWaitSync",                          "none"),
129b8e80941Smrg    _eglFunc("eglGetPlatformDisplay",                "none"),
130b8e80941Smrg
131b8e80941Smrg    # EGL_EXT_platform_base
132b8e80941Smrg    _eglFunc("eglCreatePlatformWindowSurfaceEXT",    "display"),
133b8e80941Smrg    _eglFunc("eglCreatePlatformPixmapSurfaceEXT",    "display"),
134b8e80941Smrg    _eglFunc("eglGetPlatformDisplayEXT",             "none"),
135b8e80941Smrg
136b8e80941Smrg    # TODO: Most of these extensions should be provided by the vendor
137b8e80941Smrg    # libraries, not by libEGL. They're here now to make testing everything
138b8e80941Smrg    # else easier.
139b8e80941Smrg
140b8e80941Smrg    # EGL_EXT_swap_buffers_with_damage
141b8e80941Smrg    _eglFunc("eglSwapBuffersWithDamageEXT",          "display"),
142b8e80941Smrg
143b8e80941Smrg    # KHR_EXT_swap_buffers_with_damage
144b8e80941Smrg    _eglFunc("eglSwapBuffersWithDamageKHR",          "display"),
145b8e80941Smrg
146b8e80941Smrg    # EGL_KHR_cl_event2
147b8e80941Smrg    _eglFunc("eglCreateSync64KHR",                   "display"),
148b8e80941Smrg
149b8e80941Smrg    # EGL_KHR_fence_sync
150b8e80941Smrg    _eglFunc("eglCreateSyncKHR",                     "display"),
151b8e80941Smrg    _eglFunc("eglDestroySyncKHR",                    "display"),
152b8e80941Smrg    _eglFunc("eglClientWaitSyncKHR",                 "display"),
153b8e80941Smrg    _eglFunc("eglGetSyncAttribKHR",                  "display"),
154b8e80941Smrg
155b8e80941Smrg    # EGL_KHR_image
156b8e80941Smrg    _eglFunc("eglCreateImageKHR",                    "display"),
157b8e80941Smrg    _eglFunc("eglDestroyImageKHR",                   "display"),
158b8e80941Smrg
159b8e80941Smrg    # EGL_KHR_image_base
160b8e80941Smrg    # eglCreateImageKHR already defined in EGL_KHR_image
161b8e80941Smrg    # eglDestroyImageKHR already defined in EGL_KHR_image
162b8e80941Smrg
163b8e80941Smrg    # EGL_KHR_reusable_sync
164b8e80941Smrg    _eglFunc("eglSignalSyncKHR",                     "display"),
165b8e80941Smrg    # eglCreateSyncKHR already defined in EGL_KHR_fence_sync
166b8e80941Smrg    # eglDestroySyncKHR already defined in EGL_KHR_fence_sync
167b8e80941Smrg    # eglClientWaitSyncKHR already defined in EGL_KHR_fence_sync
168b8e80941Smrg    # eglGetSyncAttribKHR already defined in EGL_KHR_fence_sync
169b8e80941Smrg
170b8e80941Smrg    # EGL_KHR_wait_sync
171b8e80941Smrg    _eglFunc("eglWaitSyncKHR",                       "display"),
172b8e80941Smrg
173b8e80941Smrg    # EGL_MESA_drm_image
174b8e80941Smrg    _eglFunc("eglCreateDRMImageMESA",                "display"),
175b8e80941Smrg    _eglFunc("eglExportDRMImageMESA",                "display"),
176b8e80941Smrg
177b8e80941Smrg    # EGL_MESA_image_dma_buf_export
178b8e80941Smrg    _eglFunc("eglExportDMABUFImageQueryMESA",        "display"),
179b8e80941Smrg    _eglFunc("eglExportDMABUFImageMESA",             "display"),
180b8e80941Smrg
181b8e80941Smrg    # EGL_NOK_swap_region
182b8e80941Smrg    _eglFunc("eglSwapBuffersRegionNOK",              "display"),
183b8e80941Smrg
184b8e80941Smrg    # EGL_NV_post_sub_buffer
185b8e80941Smrg    _eglFunc("eglPostSubBufferNV",                   "display"),
186b8e80941Smrg
187b8e80941Smrg    # EGL_WL_bind_wayland_display
188b8e80941Smrg    _eglFunc("eglCreateWaylandBufferFromImageWL",    "display"),
189b8e80941Smrg    _eglFunc("eglUnbindWaylandDisplayWL",            "display"),
190b8e80941Smrg    _eglFunc("eglQueryWaylandBufferWL",              "display"),
191b8e80941Smrg    _eglFunc("eglBindWaylandDisplayWL",              "display"),
192b8e80941Smrg
193b8e80941Smrg    # EGL_CHROMIUM_get_sync_values
194b8e80941Smrg    _eglFunc("eglGetSyncValuesCHROMIUM",             "display"),
195b8e80941Smrg
196b8e80941Smrg    # EGL_ANDROID_native_fence_sync
197b8e80941Smrg    _eglFunc("eglDupNativeFenceFDANDROID",           "display"),
198b8e80941Smrg
199b8e80941Smrg    # EGL_ANDROID_blob_cache
200b8e80941Smrg    _eglFunc("eglSetBlobCacheFuncsANDROID",          "display"),
201b8e80941Smrg
202b8e80941Smrg    # EGL_EXT_image_dma_buf_import_modifiers
203b8e80941Smrg    _eglFunc("eglQueryDmaBufFormatsEXT",             "display"),
204b8e80941Smrg    _eglFunc("eglQueryDmaBufModifiersEXT",           "display"),
205b8e80941Smrg
206b8e80941Smrg    # EGL_EXT_device_base
207b8e80941Smrg    _eglFunc("eglQueryDeviceAttribEXT",              "device"),
208b8e80941Smrg    _eglFunc("eglQueryDeviceStringEXT",              "device"),
209b8e80941Smrg    _eglFunc("eglQueryDevicesEXT",                   "none"),
210b8e80941Smrg    _eglFunc("eglQueryDisplayAttribEXT",             "display"),
211b8e80941Smrg
212b8e80941Smrg    # EGL_MESA_query_driver
213b8e80941Smrg    _eglFunc("eglGetDisplayDriverName",              "display"),
214b8e80941Smrg    _eglFunc("eglGetDisplayDriverConfig",            "display"),
215b8e80941Smrg
216b8e80941Smrg)
217b8e80941Smrg
218