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