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