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