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