Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // main.cpp: DLL entry point and management of thread-local data. |
| 16 | |
| 17 | #include "main.h" |
| 18 | |
| 19 | #include "libEGL.hpp" |
| 20 | #include "Context.hpp" |
Alexis Hetu | 2f48bcb | 2016-12-05 12:43:27 -0500 | [diff] [blame] | 21 | #include "EGLSurface.h" |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 22 | |
| 23 | #include "resource.h" |
| 24 | #include "Common/Thread.hpp" |
| 25 | #include "Common/SharedLibrary.hpp" |
| 26 | #include "common/debug.h" |
| 27 | |
| 28 | #include <EGL/eglext.h> |
| 29 | |
| 30 | static sw::Thread::LocalStorageKey currentTLS = TLS_OUT_OF_INDEXES; |
| 31 | |
| 32 | #if !defined(_MSC_VER) |
| 33 | #define CONSTRUCTOR __attribute__((constructor)) |
| 34 | #define DESTRUCTOR __attribute__((destructor)) |
| 35 | #else |
| 36 | #define CONSTRUCTOR |
| 37 | #define DESTRUCTOR |
| 38 | #endif |
| 39 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 40 | namespace egl |
| 41 | { |
| 42 | void attachThread() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 43 | { |
| 44 | TRACE("()"); |
| 45 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 46 | Current *current = new Current; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 47 | |
| 48 | if(current) |
| 49 | { |
| 50 | sw::Thread::setLocalStorage(currentTLS, current); |
| 51 | |
| 52 | current->error = EGL_SUCCESS; |
| 53 | current->API = EGL_OPENGL_ES_API; |
| 54 | current->display = EGL_NO_DISPLAY; |
| 55 | current->context = nullptr; |
| 56 | current->drawSurface = nullptr; |
| 57 | current->readSurface = nullptr; |
| 58 | } |
| 59 | } |
| 60 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 61 | void detachThread() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 62 | { |
| 63 | TRACE("()"); |
| 64 | |
Nicolas Capens | cc5c7d9 | 2016-06-13 14:35:11 -0400 | [diff] [blame] | 65 | eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE); |
| 66 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 67 | delete (Current*)sw::Thread::getLocalStorage(currentTLS); |
Nicolas Capens | cc5c7d9 | 2016-06-13 14:35:11 -0400 | [diff] [blame] | 68 | sw::Thread::setLocalStorage(currentTLS, nullptr); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 69 | } |
| 70 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 71 | CONSTRUCTOR void attachProcess() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 72 | { |
| 73 | TRACE("()"); |
| 74 | |
| 75 | #if !defined(ANGLE_DISABLE_TRACE) && defined(TRACE_OUTPUT_FILE) |
| 76 | FILE *debug = fopen(TRACE_OUTPUT_FILE, "rt"); |
| 77 | |
| 78 | if(debug) |
| 79 | { |
| 80 | fclose(debug); |
| 81 | debug = fopen(TRACE_OUTPUT_FILE, "wt"); // Erase |
| 82 | fclose(debug); |
| 83 | } |
| 84 | #endif |
| 85 | |
| 86 | currentTLS = sw::Thread::allocateLocalStorageKey(); |
| 87 | |
| 88 | if(currentTLS == TLS_OUT_OF_INDEXES) |
| 89 | { |
| 90 | return; |
| 91 | } |
| 92 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 93 | attachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 94 | } |
| 95 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 96 | DESTRUCTOR void detachProcess() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 97 | { |
| 98 | TRACE("()"); |
| 99 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 100 | detachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 101 | sw::Thread::freeLocalStorageKey(currentTLS); |
| 102 | } |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 103 | } |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 104 | |
| 105 | #if defined(_WIN32) |
Alexis Hetu | 8e942eb | 2017-03-16 10:53:01 -0400 | [diff] [blame^] | 106 | #ifdef DEBUGGER_WAIT_DIALOG |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 107 | static INT_PTR CALLBACK DebuggerWaitDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 108 | { |
| 109 | RECT rect; |
| 110 | |
| 111 | switch(uMsg) |
| 112 | { |
| 113 | case WM_INITDIALOG: |
| 114 | GetWindowRect(GetDesktopWindow(), &rect); |
| 115 | SetWindowPos(hwnd, HWND_TOP, rect.right / 2, rect.bottom / 2, 0, 0, SWP_NOSIZE); |
| 116 | SetTimer(hwnd, 1, 100, NULL); |
| 117 | return TRUE; |
| 118 | case WM_COMMAND: |
| 119 | if(LOWORD(wParam) == IDCANCEL) |
| 120 | { |
| 121 | EndDialog(hwnd, 0); |
| 122 | } |
| 123 | break; |
| 124 | case WM_TIMER: |
| 125 | if(IsDebuggerPresent()) |
| 126 | { |
| 127 | EndDialog(hwnd, 0); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return FALSE; |
| 132 | } |
| 133 | |
| 134 | static void WaitForDebugger(HINSTANCE instance) |
| 135 | { |
| 136 | if(!IsDebuggerPresent()) |
| 137 | { |
| 138 | HRSRC dialog = FindResource(instance, MAKEINTRESOURCE(IDD_DIALOG1), RT_DIALOG); |
| 139 | DLGTEMPLATE *dialogTemplate = (DLGTEMPLATE*)LoadResource(instance, dialog); |
| 140 | DialogBoxIndirect(instance, dialogTemplate, NULL, DebuggerWaitDialogProc); |
| 141 | } |
| 142 | } |
Alexis Hetu | e97a31e | 2016-11-14 14:10:47 -0500 | [diff] [blame] | 143 | #endif |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 144 | |
| 145 | extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) |
| 146 | { |
| 147 | switch(reason) |
| 148 | { |
| 149 | case DLL_PROCESS_ATTACH: |
| 150 | #ifndef NDEBUG |
| 151 | WaitForDebugger(instance); |
| 152 | #endif |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 153 | egl::attachProcess(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 154 | break; |
| 155 | case DLL_THREAD_ATTACH: |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 156 | egl::attachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 157 | break; |
| 158 | case DLL_THREAD_DETACH: |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 159 | egl::detachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 160 | break; |
| 161 | case DLL_PROCESS_DETACH: |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 162 | egl::detachProcess(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 163 | break; |
| 164 | default: |
| 165 | break; |
| 166 | } |
| 167 | |
| 168 | return TRUE; |
| 169 | } |
| 170 | #endif |
| 171 | |
| 172 | namespace egl |
| 173 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 174 | static Current *getCurrent(void) |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 175 | { |
| 176 | Current *current = (Current*)sw::Thread::getLocalStorage(currentTLS); |
| 177 | |
| 178 | if(!current) |
| 179 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 180 | attachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | return (Current*)sw::Thread::getLocalStorage(currentTLS); |
| 184 | } |
| 185 | |
| 186 | void setCurrentError(EGLint error) |
| 187 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 188 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 189 | |
| 190 | current->error = error; |
| 191 | } |
| 192 | |
| 193 | EGLint getCurrentError() |
| 194 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 195 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 196 | |
| 197 | return current->error; |
| 198 | } |
| 199 | |
| 200 | void setCurrentAPI(EGLenum API) |
| 201 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 202 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 203 | |
| 204 | current->API = API; |
| 205 | } |
| 206 | |
| 207 | EGLenum getCurrentAPI() |
| 208 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 209 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 210 | |
| 211 | return current->API; |
| 212 | } |
| 213 | |
| 214 | void setCurrentDisplay(EGLDisplay dpy) |
| 215 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 216 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 217 | |
| 218 | current->display = dpy; |
| 219 | } |
| 220 | |
| 221 | EGLDisplay getCurrentDisplay() |
| 222 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 223 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 224 | |
| 225 | return current->display; |
| 226 | } |
| 227 | |
| 228 | void setCurrentContext(egl::Context *ctx) |
| 229 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 230 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 231 | |
| 232 | if(ctx) |
| 233 | { |
| 234 | ctx->addRef(); |
| 235 | } |
| 236 | |
| 237 | if(current->context) |
| 238 | { |
| 239 | current->context->release(); |
| 240 | } |
| 241 | |
| 242 | current->context = ctx; |
| 243 | } |
| 244 | |
| 245 | egl::Context *getCurrentContext() |
| 246 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 247 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 248 | |
| 249 | return current->context; |
| 250 | } |
| 251 | |
| 252 | void setCurrentDrawSurface(egl::Surface *surface) |
| 253 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 254 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 255 | |
| 256 | if(surface) |
| 257 | { |
| 258 | surface->addRef(); |
| 259 | } |
| 260 | |
| 261 | if(current->drawSurface) |
| 262 | { |
| 263 | current->drawSurface->release(); |
| 264 | } |
| 265 | |
| 266 | current->drawSurface = surface; |
| 267 | } |
| 268 | |
| 269 | egl::Surface *getCurrentDrawSurface() |
| 270 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 271 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 272 | |
| 273 | return current->drawSurface; |
| 274 | } |
| 275 | |
| 276 | void setCurrentReadSurface(egl::Surface *surface) |
| 277 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 278 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 279 | |
| 280 | if(surface) |
| 281 | { |
| 282 | surface->addRef(); |
| 283 | } |
| 284 | |
| 285 | if(current->readSurface) |
| 286 | { |
| 287 | current->readSurface->release(); |
| 288 | } |
| 289 | |
| 290 | current->readSurface = surface; |
| 291 | } |
| 292 | |
| 293 | egl::Surface *getCurrentReadSurface() |
| 294 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 295 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 296 | |
| 297 | return current->readSurface; |
| 298 | } |
| 299 | |
| 300 | void error(EGLint errorCode) |
| 301 | { |
| 302 | egl::setCurrentError(errorCode); |
| 303 | |
| 304 | if(errorCode != EGL_SUCCESS) |
| 305 | { |
| 306 | switch(errorCode) |
| 307 | { |
| 308 | case EGL_NOT_INITIALIZED: TRACE("\t! Error generated: not initialized\n"); break; |
| 309 | case EGL_BAD_ACCESS: TRACE("\t! Error generated: bad access\n"); break; |
| 310 | case EGL_BAD_ALLOC: TRACE("\t! Error generated: bad alloc\n"); break; |
| 311 | case EGL_BAD_ATTRIBUTE: TRACE("\t! Error generated: bad attribute\n"); break; |
| 312 | case EGL_BAD_CONFIG: TRACE("\t! Error generated: bad config\n"); break; |
| 313 | case EGL_BAD_CONTEXT: TRACE("\t! Error generated: bad context\n"); break; |
| 314 | case EGL_BAD_CURRENT_SURFACE: TRACE("\t! Error generated: bad current surface\n"); break; |
| 315 | case EGL_BAD_DISPLAY: TRACE("\t! Error generated: bad display\n"); break; |
| 316 | case EGL_BAD_MATCH: TRACE("\t! Error generated: bad match\n"); break; |
| 317 | case EGL_BAD_NATIVE_PIXMAP: TRACE("\t! Error generated: bad native pixmap\n"); break; |
| 318 | case EGL_BAD_NATIVE_WINDOW: TRACE("\t! Error generated: bad native window\n"); break; |
| 319 | case EGL_BAD_PARAMETER: TRACE("\t! Error generated: bad parameter\n"); break; |
| 320 | case EGL_BAD_SURFACE: TRACE("\t! Error generated: bad surface\n"); break; |
| 321 | case EGL_CONTEXT_LOST: TRACE("\t! Error generated: context lost\n"); break; |
| 322 | default: TRACE("\t! Error generated: <0x%X>\n", errorCode); break; |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | namespace egl |
| 329 | { |
| 330 | EGLint GetError(void); |
| 331 | EGLDisplay GetDisplay(EGLNativeDisplayType display_id); |
| 332 | EGLBoolean Initialize(EGLDisplay dpy, EGLint *major, EGLint *minor); |
| 333 | EGLBoolean Terminate(EGLDisplay dpy); |
| 334 | const char *QueryString(EGLDisplay dpy, EGLint name); |
| 335 | EGLBoolean GetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
| 336 | EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
| 337 | EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); |
| 338 | EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType window, const EGLint *attrib_list); |
| 339 | EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); |
| 340 | EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); |
| 341 | EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface); |
| 342 | EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); |
| 343 | EGLBoolean BindAPI(EGLenum api); |
| 344 | EGLenum QueryAPI(void); |
| 345 | EGLBoolean WaitClient(void); |
| 346 | EGLBoolean ReleaseThread(void); |
| 347 | EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); |
| 348 | EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); |
| 349 | EGLBoolean BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); |
| 350 | EGLBoolean ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); |
| 351 | EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval); |
| 352 | EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); |
| 353 | EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx); |
| 354 | EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); |
| 355 | EGLContext GetCurrentContext(void); |
| 356 | EGLSurface GetCurrentSurface(EGLint readdraw); |
| 357 | EGLDisplay GetCurrentDisplay(void); |
| 358 | EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); |
| 359 | EGLBoolean WaitGL(void); |
| 360 | EGLBoolean WaitNative(EGLint engine); |
| 361 | EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface surface); |
| 362 | EGLBoolean CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); |
| 363 | EGLImageKHR CreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); |
| 364 | EGLBoolean DestroyImageKHR(EGLDisplay dpy, EGLImageKHR image); |
| 365 | EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list); |
| 366 | EGLSurface CreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); |
| 367 | EGLSurface CreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); |
| 368 | EGLSyncKHR CreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); |
| 369 | EGLBoolean DestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync); |
| 370 | EGLint ClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); |
| 371 | EGLBoolean GetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); |
| 372 | __eglMustCastToProperFunctionPointerType GetProcAddress(const char *procname); |
| 373 | } |
| 374 | |
| 375 | extern "C" |
| 376 | { |
| 377 | EGLAPI EGLint EGLAPIENTRY eglGetError(void) |
| 378 | { |
| 379 | return egl::GetError(); |
| 380 | } |
| 381 | |
| 382 | EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) |
| 383 | { |
| 384 | return egl::GetDisplay(display_id); |
| 385 | } |
| 386 | |
| 387 | EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) |
| 388 | { |
| 389 | return egl::Initialize(dpy, major, minor); |
| 390 | } |
| 391 | |
| 392 | EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) |
| 393 | { |
| 394 | return egl::Terminate(dpy); |
| 395 | } |
| 396 | |
| 397 | EGLAPI const char *EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) |
| 398 | { |
| 399 | return egl::QueryString(dpy, name); |
| 400 | } |
| 401 | |
| 402 | EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
| 403 | { |
| 404 | return egl::GetConfigs(dpy, configs, config_size, num_config); |
| 405 | } |
| 406 | |
| 407 | EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
| 408 | { |
| 409 | return egl::ChooseConfig(dpy, attrib_list, configs, config_size, num_config); |
| 410 | } |
| 411 | |
| 412 | EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) |
| 413 | { |
| 414 | return egl::GetConfigAttrib(dpy, config, attribute, value); |
| 415 | } |
| 416 | |
| 417 | EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType window, const EGLint *attrib_list) |
| 418 | { |
| 419 | return egl::CreateWindowSurface(dpy, config, window, attrib_list); |
| 420 | } |
| 421 | |
| 422 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) |
| 423 | { |
| 424 | return egl::CreatePbufferSurface(dpy, config, attrib_list); |
| 425 | } |
| 426 | |
| 427 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) |
| 428 | { |
| 429 | return egl::CreatePixmapSurface(dpy, config, pixmap, attrib_list); |
| 430 | } |
| 431 | |
| 432 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface) |
| 433 | { |
| 434 | return egl::DestroySurface(dpy, surface); |
| 435 | } |
| 436 | |
| 437 | EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) |
| 438 | { |
| 439 | return egl::QuerySurface(dpy, surface, attribute, value); |
| 440 | } |
| 441 | |
| 442 | EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api) |
| 443 | { |
| 444 | return egl::BindAPI(api); |
| 445 | } |
| 446 | |
| 447 | EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void) |
| 448 | { |
| 449 | return egl::QueryAPI(); |
| 450 | } |
| 451 | |
| 452 | EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void) |
| 453 | { |
| 454 | return egl::WaitClient(); |
| 455 | } |
| 456 | |
| 457 | EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) |
| 458 | { |
| 459 | return egl::ReleaseThread(); |
| 460 | } |
| 461 | |
| 462 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) |
| 463 | { |
| 464 | return egl::CreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list); |
| 465 | } |
| 466 | |
| 467 | EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) |
| 468 | { |
| 469 | return egl::SurfaceAttrib(dpy, surface, attribute, value); |
| 470 | } |
| 471 | |
| 472 | EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) |
| 473 | { |
| 474 | return egl::BindTexImage(dpy, surface, buffer); |
| 475 | } |
| 476 | |
| 477 | EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) |
| 478 | { |
| 479 | return egl::ReleaseTexImage(dpy, surface, buffer); |
| 480 | } |
| 481 | |
| 482 | EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) |
| 483 | { |
| 484 | return egl::SwapInterval(dpy, interval); |
| 485 | } |
| 486 | |
| 487 | EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) |
| 488 | { |
| 489 | return egl::CreateContext(dpy, config, share_context, attrib_list); |
| 490 | } |
| 491 | |
| 492 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx) |
| 493 | { |
| 494 | return egl::DestroyContext(dpy, ctx); |
| 495 | } |
| 496 | |
| 497 | EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) |
| 498 | { |
| 499 | return egl::MakeCurrent(dpy, draw, read, ctx); |
| 500 | } |
| 501 | |
| 502 | EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void) |
| 503 | { |
| 504 | return egl::GetCurrentContext(); |
| 505 | } |
| 506 | |
| 507 | EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) |
| 508 | { |
| 509 | return egl::GetCurrentSurface(readdraw); |
| 510 | } |
| 511 | |
| 512 | EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) |
| 513 | { |
| 514 | return egl::GetCurrentDisplay(); |
| 515 | } |
| 516 | |
| 517 | EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) |
| 518 | { |
| 519 | return egl::QueryContext(dpy, ctx, attribute, value); |
| 520 | } |
| 521 | |
| 522 | EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void) |
| 523 | { |
| 524 | return egl::WaitClient(); |
| 525 | } |
| 526 | |
| 527 | EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) |
| 528 | { |
| 529 | return egl::WaitNative(engine); |
| 530 | } |
| 531 | |
| 532 | EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) |
| 533 | { |
| 534 | return egl::SwapBuffers(dpy, surface); |
| 535 | } |
| 536 | |
| 537 | EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) |
| 538 | { |
| 539 | return egl::CopyBuffers(dpy, surface, target); |
| 540 | } |
| 541 | |
| 542 | EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) |
| 543 | { |
| 544 | return egl::CreateImageKHR(dpy, ctx, target, buffer, attrib_list); |
| 545 | } |
| 546 | |
| 547 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) |
| 548 | { |
| 549 | return egl::DestroyImageKHR(dpy, image); |
| 550 | } |
| 551 | |
| 552 | EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list) |
| 553 | { |
| 554 | return egl::GetPlatformDisplayEXT(platform, native_display, attrib_list); |
| 555 | } |
| 556 | |
| 557 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list) |
| 558 | { |
| 559 | return egl::CreatePlatformWindowSurfaceEXT(dpy, config, native_window, attrib_list); |
| 560 | } |
| 561 | |
| 562 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list) |
| 563 | { |
| 564 | return egl::CreatePlatformPixmapSurfaceEXT(dpy, config, native_pixmap, attrib_list); |
| 565 | } |
| 566 | |
| 567 | EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) |
| 568 | { |
| 569 | return egl::CreateSyncKHR(dpy, type, attrib_list); |
| 570 | } |
| 571 | |
| 572 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) |
| 573 | { |
| 574 | return egl::DestroySyncKHR(dpy, sync); |
| 575 | } |
| 576 | |
| 577 | EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) |
| 578 | { |
| 579 | return egl::ClientWaitSyncKHR(dpy, sync, flags, timeout); |
| 580 | } |
| 581 | |
| 582 | EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) |
| 583 | { |
| 584 | return egl::GetSyncAttribKHR(dpy, sync, attribute, value); |
| 585 | } |
| 586 | |
| 587 | EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname) |
| 588 | { |
| 589 | return egl::GetProcAddress(procname); |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | LibEGLexports::LibEGLexports() |
| 594 | { |
| 595 | this->eglGetError = egl::GetError; |
| 596 | this->eglGetDisplay = egl::GetDisplay; |
| 597 | this->eglInitialize = egl::Initialize; |
| 598 | this->eglTerminate = egl::Terminate; |
| 599 | this->eglQueryString = egl::QueryString; |
| 600 | this->eglGetConfigs = egl::GetConfigs; |
| 601 | this->eglChooseConfig = egl::ChooseConfig; |
| 602 | this->eglGetConfigAttrib = egl::GetConfigAttrib; |
| 603 | this->eglCreateWindowSurface = egl::CreateWindowSurface; |
| 604 | this->eglCreatePbufferSurface = egl::CreatePbufferSurface; |
| 605 | this->eglCreatePixmapSurface = egl::CreatePixmapSurface; |
| 606 | this->eglDestroySurface = egl::DestroySurface; |
| 607 | this->eglQuerySurface = egl::QuerySurface; |
| 608 | this->eglBindAPI = egl::BindAPI; |
| 609 | this->eglQueryAPI = egl::QueryAPI; |
| 610 | this->eglWaitClient = egl::WaitClient; |
| 611 | this->eglReleaseThread = egl::ReleaseThread; |
| 612 | this->eglCreatePbufferFromClientBuffer = egl::CreatePbufferFromClientBuffer; |
| 613 | this->eglSurfaceAttrib = egl::SurfaceAttrib; |
| 614 | this->eglBindTexImage = egl::BindTexImage; |
| 615 | this->eglReleaseTexImage = egl::ReleaseTexImage; |
| 616 | this->eglSwapInterval = egl::SwapInterval; |
| 617 | this->eglCreateContext = egl::CreateContext; |
| 618 | this->eglDestroyContext = egl::DestroyContext; |
| 619 | this->eglMakeCurrent = egl::MakeCurrent; |
| 620 | this->eglGetCurrentContext = egl::GetCurrentContext; |
| 621 | this->eglGetCurrentSurface = egl::GetCurrentSurface; |
| 622 | this->eglGetCurrentDisplay = egl::GetCurrentDisplay; |
| 623 | this->eglQueryContext = egl::QueryContext; |
| 624 | this->eglWaitGL = egl::WaitGL; |
| 625 | this->eglWaitNative = egl::WaitNative; |
| 626 | this->eglSwapBuffers = egl::SwapBuffers; |
| 627 | this->eglCopyBuffers = egl::CopyBuffers; |
| 628 | this->eglCreateImageKHR = egl::CreateImageKHR; |
| 629 | this->eglDestroyImageKHR = egl::DestroyImageKHR; |
| 630 | this->eglGetProcAddress = egl::GetProcAddress; |
| 631 | this->eglCreateSyncKHR = egl::CreateSyncKHR; |
| 632 | this->eglDestroySyncKHR = egl::DestroySyncKHR; |
| 633 | this->eglClientWaitSyncKHR = egl::ClientWaitSyncKHR; |
| 634 | this->eglGetSyncAttribKHR = egl::GetSyncAttribKHR; |
| 635 | |
| 636 | this->clientGetCurrentContext = egl::getCurrentContext; |
| 637 | } |
| 638 | |
| 639 | extern "C" EGLAPI LibEGLexports *libEGL_swiftshader() |
| 640 | { |
| 641 | static LibEGLexports libEGL; |
| 642 | return &libEGL; |
| 643 | } |
| 644 | |
| 645 | LibGLES_CM libGLES_CM; |
| 646 | LibGLESv2 libGLESv2; |