egl_ext_stubs.cpp (38604B)
1 // 2 // Copyright 2020 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // egl_ext_stubs.cpp: Stubs for EXT extension entry points. 7 // 8 9 #include "libGLESv2/egl_ext_stubs_autogen.h" 10 11 #include "libANGLE/Device.h" 12 #include "libANGLE/Display.h" 13 #include "libANGLE/EGLSync.h" 14 #include "libANGLE/Surface.h" 15 #include "libANGLE/Thread.h" 16 #include "libANGLE/capture/capture_egl.h" 17 #include "libANGLE/capture/frame_capture_utils_autogen.h" 18 #include "libANGLE/entry_points_utils.h" 19 #include "libANGLE/queryutils.h" 20 #include "libANGLE/renderer/DisplayImpl.h" 21 #include "libANGLE/validationEGL.h" 22 #include "libANGLE/validationEGL_autogen.h" 23 #include "libGLESv2/global_state.h" 24 25 namespace egl 26 { 27 EGLint ClientWaitSyncKHR(Thread *thread, 28 Display *display, 29 Sync *syncObject, 30 EGLint flags, 31 EGLTimeKHR timeout) 32 { 33 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglClientWaitSync", 34 GetDisplayIfValid(display), EGL_FALSE); 35 gl::Context *currentContext = thread->getContext(); 36 EGLint syncStatus = EGL_FALSE; 37 ANGLE_EGL_TRY_RETURN( 38 thread, syncObject->clientWait(display, currentContext, flags, timeout, &syncStatus), 39 "eglClientWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); 40 41 thread->setSuccess(); 42 return syncStatus; 43 } 44 45 EGLImageKHR CreateImageKHR(Thread *thread, 46 Display *display, 47 gl::Context *context, 48 EGLenum target, 49 EGLClientBuffer buffer, 50 const AttributeMap &attributes) 51 { 52 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglCreateImageKHR", 53 GetDisplayIfValid(display), EGL_NO_IMAGE); 54 Image *image = nullptr; 55 ANGLE_EGL_TRY_RETURN(thread, display->createImage(context, target, buffer, attributes, &image), 56 "", GetDisplayIfValid(display), EGL_NO_IMAGE); 57 58 ANGLE_CAPTURE_EGL(EGLCreateImage, thread, context, target, buffer, attributes, image); 59 60 thread->setSuccess(); 61 return static_cast<EGLImage>(image); 62 } 63 64 EGLClientBuffer CreateNativeClientBufferANDROID(Thread *thread, const AttributeMap &attribMap) 65 { 66 EGLClientBuffer eglClientBuffer = nullptr; 67 ANGLE_EGL_TRY_RETURN(thread, 68 egl::Display::CreateNativeClientBuffer(attribMap, &eglClientBuffer), 69 "eglCreateNativeClientBufferANDROID", nullptr, nullptr); 70 71 ANGLE_CAPTURE_EGL(CreateNativeClientBufferANDROID, thread, attribMap, eglClientBuffer); 72 73 thread->setSuccess(); 74 return eglClientBuffer; 75 } 76 77 EGLSurface CreatePlatformPixmapSurfaceEXT(Thread *thread, 78 Display *display, 79 Config *configPacked, 80 void *native_pixmap, 81 const AttributeMap &attributes) 82 { 83 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglCreatePlatformPixmapSurfaceEXT", 84 GetDisplayIfValid(display), EGL_NO_SURFACE); 85 thread->setError(EGL_BAD_DISPLAY, "eglCreatePlatformPixmapSurfaceEXT", 86 GetDisplayIfValid(display), "CreatePlatformPixmapSurfaceEXT unimplemented."); 87 return EGL_NO_SURFACE; 88 } 89 90 EGLSurface CreatePlatformWindowSurfaceEXT(Thread *thread, 91 Display *display, 92 Config *configPacked, 93 void *native_window, 94 const AttributeMap &attributes) 95 { 96 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglCreatePlatformWindowSurfaceEXT", 97 GetDisplayIfValid(display), EGL_NO_SURFACE); 98 Surface *surface = nullptr; 99 100 // In X11, eglCreatePlatformWindowSurfaceEXT expects the native_window argument to be a pointer 101 // to a Window while the EGLNativeWindowType for X11 is its actual value. 102 // https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_platform_x11.txt 103 void *actualNativeWindow = display->getImplementation()->isX11() 104 ? *reinterpret_cast<void **>(native_window) 105 : native_window; 106 EGLNativeWindowType nativeWindow = reinterpret_cast<EGLNativeWindowType>(actualNativeWindow); 107 108 ANGLE_EGL_TRY_RETURN( 109 thread, display->createWindowSurface(configPacked, nativeWindow, attributes, &surface), 110 "eglPlatformCreateWindowSurfaceEXT", GetDisplayIfValid(display), EGL_NO_SURFACE); 111 112 return static_cast<EGLSurface>(surface); 113 } 114 115 EGLStreamKHR CreateStreamKHR(Thread *thread, Display *display, const AttributeMap &attributes) 116 { 117 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglCreateStreamKHR", 118 GetDisplayIfValid(display), EGL_NO_STREAM_KHR); 119 Stream *stream; 120 ANGLE_EGL_TRY_RETURN(thread, display->createStream(attributes, &stream), "eglCreateStreamKHR", 121 GetDisplayIfValid(display), EGL_NO_STREAM_KHR); 122 123 thread->setSuccess(); 124 return static_cast<EGLStreamKHR>(stream); 125 } 126 127 EGLSyncKHR CreateSyncKHR(Thread *thread, 128 Display *display, 129 EGLenum type, 130 const AttributeMap &attributes) 131 { 132 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglCreateSyncKHR", 133 GetDisplayIfValid(display), EGL_NO_SYNC); 134 egl::Sync *syncObject = nullptr; 135 ANGLE_EGL_TRY_RETURN(thread, 136 display->createSync(thread->getContext(), type, attributes, &syncObject), 137 "eglCreateSyncKHR", GetDisplayIfValid(display), EGL_NO_SYNC); 138 139 thread->setSuccess(); 140 return static_cast<EGLSync>(syncObject); 141 } 142 143 EGLint DebugMessageControlKHR(Thread *thread, 144 EGLDEBUGPROCKHR callback, 145 const AttributeMap &attributes) 146 { 147 Debug *debug = GetDebug(); 148 debug->setCallback(callback, attributes); 149 150 thread->setSuccess(); 151 return EGL_SUCCESS; 152 } 153 154 EGLBoolean DestroyImageKHR(Thread *thread, Display *display, Image *img) 155 { 156 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglDestroyImageKHR", 157 GetDisplayIfValid(display), EGL_FALSE); 158 display->destroyImage(img); 159 160 ANGLE_CAPTURE_EGL(EGLDestroyImage, thread, display, img); 161 162 thread->setSuccess(); 163 return EGL_TRUE; 164 } 165 166 EGLBoolean DestroyStreamKHR(Thread *thread, Display *display, Stream *streamObject) 167 { 168 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglDestroyStreamKHR", 169 GetDisplayIfValid(display), EGL_FALSE); 170 display->destroyStream(streamObject); 171 172 thread->setSuccess(); 173 return EGL_TRUE; 174 } 175 176 EGLBoolean DestroySyncKHR(Thread *thread, Display *display, Sync *syncObject) 177 { 178 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglDestroySync", 179 GetDisplayIfValid(display), EGL_FALSE); 180 display->destroySync(syncObject); 181 182 thread->setSuccess(); 183 return EGL_TRUE; 184 } 185 186 EGLint DupNativeFenceFDANDROID(Thread *thread, Display *display, Sync *syncObject) 187 { 188 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglDupNativeFenceFDANDROID", 189 GetDisplayIfValid(display), EGL_NO_NATIVE_FENCE_FD_ANDROID); 190 EGLint result = EGL_NO_NATIVE_FENCE_FD_ANDROID; 191 ANGLE_EGL_TRY_RETURN(thread, syncObject->dupNativeFenceFD(display, &result), 192 "eglDupNativeFenceFDANDROID", GetSyncIfValid(display, syncObject), 193 EGL_NO_NATIVE_FENCE_FD_ANDROID); 194 195 thread->setSuccess(); 196 return result; 197 } 198 199 EGLClientBuffer GetNativeClientBufferANDROID(Thread *thread, const struct AHardwareBuffer *buffer) 200 { 201 thread->setSuccess(); 202 return egl::Display::GetNativeClientBuffer(buffer); 203 } 204 205 EGLDisplay GetPlatformDisplayEXT(Thread *thread, 206 EGLenum platform, 207 void *native_display, 208 const AttributeMap &attribMap) 209 { 210 switch (platform) 211 { 212 case EGL_PLATFORM_ANGLE_ANGLE: 213 case EGL_PLATFORM_GBM_KHR: 214 case EGL_PLATFORM_WAYLAND_EXT: 215 { 216 return egl::Display::GetDisplayFromNativeDisplay( 217 platform, gl::bitCast<EGLNativeDisplayType>(native_display), attribMap); 218 } 219 case EGL_PLATFORM_DEVICE_EXT: 220 { 221 Device *eglDevice = static_cast<Device *>(native_display); 222 return egl::Display::GetDisplayFromDevice(eglDevice, attribMap); 223 } 224 default: 225 { 226 UNREACHABLE(); 227 return EGL_NO_DISPLAY; 228 } 229 } 230 } 231 232 EGLBoolean GetSyncAttribKHR(Thread *thread, 233 Display *display, 234 Sync *syncObject, 235 EGLint attribute, 236 EGLint *value) 237 { 238 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglGetSyncAttrib", 239 GetDisplayIfValid(display), EGL_FALSE); 240 ANGLE_EGL_TRY_RETURN(thread, GetSyncAttrib(display, syncObject, attribute, value), 241 "eglGetSyncAttrib", GetSyncIfValid(display, syncObject), EGL_FALSE); 242 243 thread->setSuccess(); 244 return EGL_TRUE; 245 } 246 247 EGLint LabelObjectKHR(Thread *thread, 248 Display *display, 249 ObjectType objectTypePacked, 250 EGLObjectKHR object, 251 EGLLabelKHR label) 252 { 253 LabeledObject *labeledObject = 254 GetLabeledObjectIfValid(thread, display, objectTypePacked, object); 255 ASSERT(labeledObject != nullptr); 256 labeledObject->setLabel(label); 257 258 thread->setSuccess(); 259 return EGL_SUCCESS; 260 } 261 262 EGLBoolean PostSubBufferNV(Thread *thread, 263 Display *display, 264 Surface *eglSurface, 265 EGLint x, 266 EGLint y, 267 EGLint width, 268 EGLint height) 269 { 270 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglPostSubBufferNV", 271 GetDisplayIfValid(display), EGL_FALSE); 272 Error error = eglSurface->postSubBuffer(thread->getContext(), x, y, width, height); 273 if (error.isError()) 274 { 275 thread->setError(error, "eglPostSubBufferNV", GetSurfaceIfValid(display, eglSurface)); 276 return EGL_FALSE; 277 } 278 279 thread->setSuccess(); 280 return EGL_TRUE; 281 } 282 283 EGLBoolean PresentationTimeANDROID(Thread *thread, 284 Display *display, 285 Surface *eglSurface, 286 EGLnsecsANDROID time) 287 { 288 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglPresentationTimeANDROID", 289 GetDisplayIfValid(display), EGL_FALSE); 290 ANGLE_EGL_TRY_RETURN(thread, eglSurface->setPresentationTime(time), 291 "eglPresentationTimeANDROID", GetSurfaceIfValid(display, eglSurface), 292 EGL_FALSE); 293 294 return EGL_TRUE; 295 } 296 297 EGLBoolean GetCompositorTimingSupportedANDROID(Thread *thread, 298 Display *display, 299 Surface *eglSurface, 300 CompositorTiming nameInternal) 301 { 302 thread->setSuccess(); 303 return eglSurface->getSupportedCompositorTimings().test(nameInternal); 304 } 305 306 EGLBoolean GetCompositorTimingANDROID(Thread *thread, 307 Display *display, 308 Surface *eglSurface, 309 EGLint numTimestamps, 310 const EGLint *names, 311 EGLnsecsANDROID *values) 312 { 313 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglGetCompositorTimingANDROIDD", 314 GetDisplayIfValid(display), EGL_FALSE); 315 ANGLE_EGL_TRY_RETURN(thread, eglSurface->getCompositorTiming(numTimestamps, names, values), 316 "eglGetCompositorTimingANDROIDD", GetSurfaceIfValid(display, eglSurface), 317 EGL_FALSE); 318 319 thread->setSuccess(); 320 return EGL_TRUE; 321 } 322 323 EGLBoolean GetNextFrameIdANDROID(Thread *thread, 324 Display *display, 325 Surface *eglSurface, 326 EGLuint64KHR *frameId) 327 { 328 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglGetNextFrameIdANDROID", 329 GetDisplayIfValid(display), EGL_FALSE); 330 ANGLE_EGL_TRY_RETURN(thread, eglSurface->getNextFrameId(frameId), "eglGetNextFrameIdANDROID", 331 GetSurfaceIfValid(display, eglSurface), EGL_FALSE); 332 333 thread->setSuccess(); 334 return EGL_TRUE; 335 } 336 337 EGLBoolean GetFrameTimestampSupportedANDROID(Thread *thread, 338 Display *display, 339 Surface *eglSurface, 340 Timestamp timestampInternal) 341 { 342 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQueryTimestampSupportedANDROID", 343 GetDisplayIfValid(display), EGL_FALSE); 344 thread->setSuccess(); 345 return eglSurface->getSupportedTimestamps().test(timestampInternal); 346 } 347 348 EGLBoolean GetFrameTimestampsANDROID(Thread *thread, 349 Display *display, 350 Surface *eglSurface, 351 EGLuint64KHR frameId, 352 EGLint numTimestamps, 353 const EGLint *timestamps, 354 EGLnsecsANDROID *values) 355 { 356 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglGetFrameTimestampsANDROID", 357 GetDisplayIfValid(display), EGL_FALSE); 358 ANGLE_EGL_TRY_RETURN( 359 thread, eglSurface->getFrameTimestamps(frameId, numTimestamps, timestamps, values), 360 "eglGetFrameTimestampsANDROID", GetSurfaceIfValid(display, eglSurface), EGL_FALSE); 361 362 thread->setSuccess(); 363 return EGL_TRUE; 364 } 365 366 EGLBoolean QueryDebugKHR(Thread *thread, EGLint attribute, EGLAttrib *value) 367 { 368 Debug *debug = GetDebug(); 369 switch (attribute) 370 { 371 case EGL_DEBUG_MSG_CRITICAL_KHR: 372 case EGL_DEBUG_MSG_ERROR_KHR: 373 case EGL_DEBUG_MSG_WARN_KHR: 374 case EGL_DEBUG_MSG_INFO_KHR: 375 *value = debug->isMessageTypeEnabled(FromEGLenum<MessageType>(attribute)) ? EGL_TRUE 376 : EGL_FALSE; 377 break; 378 case EGL_DEBUG_CALLBACK_KHR: 379 *value = reinterpret_cast<EGLAttrib>(debug->getCallback()); 380 break; 381 382 default: 383 UNREACHABLE(); 384 } 385 386 thread->setSuccess(); 387 return EGL_TRUE; 388 } 389 390 EGLBoolean QueryDeviceAttribEXT(Thread *thread, Device *dev, EGLint attribute, EGLAttrib *value) 391 { 392 ANGLE_EGL_TRY_RETURN(thread, dev->getAttribute(attribute, value), "eglQueryDeviceAttribEXT", 393 GetDeviceIfValid(dev), EGL_FALSE); 394 395 thread->setSuccess(); 396 return EGL_TRUE; 397 } 398 399 const char *QueryDeviceStringEXT(Thread *thread, Device *dev, EGLint name) 400 { 401 egl::Display *owningDisplay = dev->getOwningDisplay(); 402 ANGLE_EGL_TRY_RETURN(thread, owningDisplay->prepareForCall(), "eglQueryDeviceStringEXT", 403 GetDisplayIfValid(owningDisplay), EGL_FALSE); 404 const char *result; 405 switch (name) 406 { 407 case EGL_EXTENSIONS: 408 result = dev->getExtensionString().c_str(); 409 break; 410 default: 411 thread->setError(EglBadDevice(), "eglQueryDeviceStringEXT", GetDeviceIfValid(dev)); 412 return nullptr; 413 } 414 415 thread->setSuccess(); 416 return result; 417 } 418 419 EGLBoolean QueryDisplayAttribEXT(Thread *thread, 420 Display *display, 421 EGLint attribute, 422 EGLAttrib *value) 423 { 424 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQueryDisplayAttribEXT", 425 GetDisplayIfValid(display), EGL_FALSE); 426 *value = display->queryAttrib(attribute); 427 thread->setSuccess(); 428 return EGL_TRUE; 429 } 430 431 EGLBoolean QueryStreamKHR(Thread *thread, 432 Display *display, 433 Stream *streamObject, 434 EGLenum attribute, 435 EGLint *value) 436 { 437 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQueryStreamKHR", 438 GetDisplayIfValid(display), EGL_FALSE); 439 switch (attribute) 440 { 441 case EGL_STREAM_STATE_KHR: 442 *value = streamObject->getState(); 443 break; 444 case EGL_CONSUMER_LATENCY_USEC_KHR: 445 *value = streamObject->getConsumerLatency(); 446 break; 447 case EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR: 448 *value = streamObject->getConsumerAcquireTimeout(); 449 break; 450 default: 451 UNREACHABLE(); 452 } 453 454 thread->setSuccess(); 455 return EGL_TRUE; 456 } 457 458 EGLBoolean QueryStreamu64KHR(Thread *thread, 459 Display *display, 460 Stream *streamObject, 461 EGLenum attribute, 462 EGLuint64KHR *value) 463 { 464 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQueryStreamu64KHR", 465 GetDisplayIfValid(display), EGL_FALSE); 466 switch (attribute) 467 { 468 case EGL_PRODUCER_FRAME_KHR: 469 *value = streamObject->getProducerFrame(); 470 break; 471 case EGL_CONSUMER_FRAME_KHR: 472 *value = streamObject->getConsumerFrame(); 473 break; 474 default: 475 UNREACHABLE(); 476 } 477 478 thread->setSuccess(); 479 return EGL_TRUE; 480 } 481 482 EGLBoolean QuerySurfacePointerANGLE(Thread *thread, 483 Display *display, 484 Surface *eglSurface, 485 EGLint attribute, 486 void **value) 487 { 488 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQuerySurfacePointerANGLE", 489 GetDisplayIfValid(display), EGL_FALSE); 490 Error error = eglSurface->querySurfacePointerANGLE(attribute, value); 491 if (error.isError()) 492 { 493 thread->setError(error, "eglQuerySurfacePointerANGLE", 494 GetSurfaceIfValid(display, eglSurface)); 495 return EGL_FALSE; 496 } 497 498 thread->setSuccess(); 499 return EGL_TRUE; 500 } 501 502 void SetBlobCacheFuncsANDROID(Thread *thread, 503 Display *display, 504 EGLSetBlobFuncANDROID set, 505 EGLGetBlobFuncANDROID get) 506 { 507 ANGLE_EGL_TRY(thread, display->prepareForCall(), "eglSetBlobCacheFuncsANDROID", 508 GetDisplayIfValid(display)); 509 thread->setSuccess(); 510 display->setBlobCacheFuncs(set, get); 511 } 512 513 EGLBoolean SignalSyncKHR(Thread *thread, Display *display, Sync *syncObject, EGLenum mode) 514 { 515 gl::Context *currentContext = thread->getContext(); 516 ANGLE_EGL_TRY_RETURN(thread, syncObject->signal(display, currentContext, mode), 517 "eglSignalSyncKHR", GetSyncIfValid(display, syncObject), EGL_FALSE); 518 519 thread->setSuccess(); 520 return EGL_TRUE; 521 } 522 523 EGLBoolean StreamAttribKHR(Thread *thread, 524 Display *display, 525 Stream *streamObject, 526 EGLenum attribute, 527 EGLint value) 528 { 529 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglStreamAttribKHR", 530 GetDisplayIfValid(display), EGL_FALSE); 531 switch (attribute) 532 { 533 case EGL_CONSUMER_LATENCY_USEC_KHR: 534 streamObject->setConsumerLatency(value); 535 break; 536 case EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR: 537 streamObject->setConsumerAcquireTimeout(value); 538 break; 539 default: 540 UNREACHABLE(); 541 } 542 543 thread->setSuccess(); 544 return EGL_TRUE; 545 } 546 547 EGLBoolean StreamConsumerAcquireKHR(Thread *thread, Display *display, Stream *streamObject) 548 { 549 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglStreamConsumerAcquireKHR", 550 GetDisplayIfValid(display), EGL_FALSE); 551 ANGLE_EGL_TRY_RETURN(thread, streamObject->consumerAcquire(thread->getContext()), 552 "eglStreamConsumerAcquireKHR", GetStreamIfValid(display, streamObject), 553 EGL_FALSE); 554 thread->setSuccess(); 555 return EGL_TRUE; 556 } 557 558 EGLBoolean StreamConsumerGLTextureExternalKHR(Thread *thread, 559 Display *display, 560 Stream *streamObject) 561 { 562 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglStreamConsumerGLTextureExternalKHR", 563 GetDisplayIfValid(display), EGL_FALSE); 564 ANGLE_EGL_TRY_RETURN( 565 thread, streamObject->createConsumerGLTextureExternal(AttributeMap(), thread->getContext()), 566 "eglStreamConsumerGLTextureExternalKHR", GetStreamIfValid(display, streamObject), 567 EGL_FALSE); 568 thread->setSuccess(); 569 return EGL_TRUE; 570 } 571 572 EGLBoolean StreamConsumerGLTextureExternalAttribsNV(Thread *thread, 573 Display *display, 574 Stream *streamObject, 575 const AttributeMap &attributes) 576 { 577 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), 578 "eglStreamConsumerGLTextureExternalAttribsNV", GetDisplayIfValid(display), 579 EGL_FALSE); 580 581 gl::Context *context = gl::GetValidGlobalContext(); 582 ANGLE_EGL_TRY_RETURN(thread, streamObject->createConsumerGLTextureExternal(attributes, context), 583 "eglStreamConsumerGLTextureExternalAttribsNV", 584 GetStreamIfValid(display, streamObject), EGL_FALSE); 585 thread->setSuccess(); 586 return EGL_TRUE; 587 } 588 589 EGLBoolean StreamConsumerReleaseKHR(Thread *thread, Display *display, Stream *streamObject) 590 { 591 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglStreamConsumerReleaseKHR", 592 GetDisplayIfValid(display), EGL_FALSE); 593 594 gl::Context *context = gl::GetValidGlobalContext(); 595 ANGLE_EGL_TRY_RETURN(thread, streamObject->consumerRelease(context), 596 "eglStreamConsumerReleaseKHR", GetStreamIfValid(display, streamObject), 597 EGL_FALSE); 598 thread->setSuccess(); 599 return EGL_TRUE; 600 } 601 602 EGLBoolean SwapBuffersWithDamageKHR(Thread *thread, 603 Display *display, 604 Surface *eglSurface, 605 const EGLint *rects, 606 EGLint n_rects) 607 { 608 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglSwapBuffersWithDamageEXT", 609 GetDisplayIfValid(display), EGL_FALSE); 610 ANGLE_EGL_TRY_RETURN(thread, eglSurface->swapWithDamage(thread->getContext(), rects, n_rects), 611 "eglSwapBuffersWithDamageEXT", GetSurfaceIfValid(display, eglSurface), 612 EGL_FALSE); 613 614 thread->setSuccess(); 615 return EGL_TRUE; 616 } 617 618 EGLBoolean PrepareSwapBuffersANGLE(EGLDisplay dpy, EGLSurface surface) 619 620 { 621 ANGLE_SCOPED_GLOBAL_SURFACE_LOCK(); 622 623 egl::Display *dpyPacked = PackParam<egl::Display *>(dpy); 624 Surface *surfacePacked = PackParam<Surface *>(surface); 625 Thread *thread = egl::GetCurrentThread(); 626 { 627 ANGLE_SCOPED_GLOBAL_LOCK(); 628 629 EGL_EVENT(PrepareSwapBuffersANGLE, "dpy = 0x%016" PRIxPTR ", surface = 0x%016" PRIxPTR "", 630 (uintptr_t)dpy, (uintptr_t)surface); 631 632 ANGLE_EGL_VALIDATE(thread, PrepareSwapBuffersANGLE, GetDisplayIfValid(dpyPacked), 633 EGLBoolean, dpyPacked, surfacePacked); 634 635 ANGLE_EGL_TRY_RETURN(thread, dpyPacked->prepareForCall(), "eglPrepareSwapBuffersANGLE", 636 GetDisplayIfValid(dpyPacked), EGL_FALSE); 637 } 638 ANGLE_EGL_TRY_RETURN(thread, surfacePacked->prepareSwap(thread->getContext()), "prepareSwap", 639 GetSurfaceIfValid(dpyPacked, surfacePacked), EGL_FALSE); 640 641 thread->setSuccess(); 642 return EGL_TRUE; 643 } 644 645 EGLint WaitSyncKHR(Thread *thread, Display *display, Sync *syncObject, EGLint flags) 646 { 647 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglWaitSync", 648 GetDisplayIfValid(display), EGL_FALSE); 649 gl::Context *currentContext = thread->getContext(); 650 ANGLE_EGL_TRY_RETURN(thread, syncObject->serverWait(display, currentContext, flags), 651 "eglWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); 652 653 thread->setSuccess(); 654 return EGL_TRUE; 655 } 656 657 EGLDeviceEXT CreateDeviceANGLE(Thread *thread, 658 EGLint device_type, 659 void *native_device, 660 const EGLAttrib *attrib_list) 661 { 662 Device *device = nullptr; 663 ANGLE_EGL_TRY_RETURN(thread, Device::CreateDevice(device_type, native_device, &device), 664 "eglCreateDeviceANGLE", GetThreadIfValid(thread), EGL_NO_DEVICE_EXT); 665 666 thread->setSuccess(); 667 return device; 668 } 669 670 EGLBoolean ReleaseDeviceANGLE(Thread *thread, Device *dev) 671 { 672 SafeDelete(dev); 673 674 thread->setSuccess(); 675 return EGL_TRUE; 676 } 677 678 EGLBoolean CreateStreamProducerD3DTextureANGLE(Thread *thread, 679 Display *display, 680 Stream *streamObject, 681 const AttributeMap &attributes) 682 { 683 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), 684 "eglCreateStreamProducerD3DTextureANGLE", GetDisplayIfValid(display), 685 EGL_FALSE); 686 ANGLE_EGL_TRY_RETURN(thread, streamObject->createProducerD3D11Texture(attributes), 687 "eglCreateStreamProducerD3DTextureANGLE", 688 GetStreamIfValid(display, streamObject), EGL_FALSE); 689 thread->setSuccess(); 690 return EGL_TRUE; 691 } 692 693 EGLBoolean StreamPostD3DTextureANGLE(Thread *thread, 694 Display *display, 695 Stream *streamObject, 696 void *texture, 697 const AttributeMap &attributes) 698 { 699 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglStreamPostD3DTextureANGLE", 700 GetDisplayIfValid(display), EGL_FALSE); 701 ANGLE_EGL_TRY_RETURN(thread, streamObject->postD3D11Texture(texture, attributes), 702 "eglStreamPostD3DTextureANGLE", GetStreamIfValid(display, streamObject), 703 EGL_FALSE); 704 thread->setSuccess(); 705 return EGL_TRUE; 706 } 707 708 EGLBoolean GetMscRateANGLE(Thread *thread, 709 Display *display, 710 Surface *eglSurface, 711 EGLint *numerator, 712 EGLint *denominator) 713 { 714 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglGetMscRateANGLE", 715 GetDisplayIfValid(display), EGL_FALSE); 716 ANGLE_EGL_TRY_RETURN(thread, eglSurface->getMscRate(numerator, denominator), 717 "eglGetMscRateANGLE", GetSurfaceIfValid(display, eglSurface), EGL_FALSE); 718 719 thread->setSuccess(); 720 return EGL_TRUE; 721 } 722 723 EGLBoolean GetSyncValuesCHROMIUM(Thread *thread, 724 Display *display, 725 Surface *eglSurface, 726 EGLuint64KHR *ust, 727 EGLuint64KHR *msc, 728 EGLuint64KHR *sbc) 729 { 730 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglGetSyncValuesCHROMIUM", 731 GetDisplayIfValid(display), EGL_FALSE); 732 ANGLE_EGL_TRY_RETURN(thread, eglSurface->getSyncValues(ust, msc, sbc), 733 "eglGetSyncValuesCHROMIUM", GetSurfaceIfValid(display, eglSurface), 734 EGL_FALSE); 735 736 thread->setSuccess(); 737 return EGL_TRUE; 738 } 739 740 EGLint ProgramCacheGetAttribANGLE(Thread *thread, Display *display, EGLenum attrib) 741 { 742 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglProgramCacheGetAttribANGLE", 743 GetDisplayIfValid(display), 0); 744 thread->setSuccess(); 745 return display->programCacheGetAttrib(attrib); 746 } 747 748 void ProgramCacheQueryANGLE(Thread *thread, 749 Display *display, 750 EGLint index, 751 void *key, 752 EGLint *keysize, 753 void *binary, 754 EGLint *binarysize) 755 { 756 ANGLE_EGL_TRY(thread, display->prepareForCall(), "eglProgramCacheQueryANGLE", 757 GetDisplayIfValid(display)); 758 ANGLE_EGL_TRY(thread, display->programCacheQuery(index, key, keysize, binary, binarysize), 759 "eglProgramCacheQueryANGLE", GetDisplayIfValid(display)); 760 761 thread->setSuccess(); 762 } 763 764 void ProgramCachePopulateANGLE(Thread *thread, 765 Display *display, 766 const void *key, 767 EGLint keysize, 768 const void *binary, 769 EGLint binarysize) 770 { 771 ANGLE_EGL_TRY(thread, display->prepareForCall(), "eglProgramCachePopulateANGLE", 772 GetDisplayIfValid(display)); 773 ANGLE_EGL_TRY(thread, display->programCachePopulate(key, keysize, binary, binarysize), 774 "eglProgramCachePopulateANGLE", GetDisplayIfValid(display)); 775 776 thread->setSuccess(); 777 } 778 779 EGLint ProgramCacheResizeANGLE(Thread *thread, Display *display, EGLint limit, EGLint mode) 780 { 781 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglProgramCacheResizeANGLE", 782 GetDisplayIfValid(display), 0); 783 thread->setSuccess(); 784 return display->programCacheResize(limit, mode); 785 } 786 787 const char *QueryStringiANGLE(Thread *thread, Display *display, EGLint name, EGLint index) 788 { 789 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQueryStringiANGLE", 790 GetDisplayIfValid(display), nullptr); 791 thread->setSuccess(); 792 return display->queryStringi(name, index); 793 } 794 795 EGLBoolean SwapBuffersWithFrameTokenANGLE(Thread *thread, 796 Display *display, 797 Surface *eglSurface, 798 EGLFrameTokenANGLE frametoken) 799 { 800 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglSwapBuffersWithFrameTokenANGLE", 801 GetDisplayIfValid(display), EGL_FALSE); 802 ANGLE_EGL_TRY_RETURN(thread, eglSurface->swapWithFrameToken(thread->getContext(), frametoken), 803 "eglSwapBuffersWithFrameTokenANGLE", GetDisplayIfValid(display), 804 EGL_FALSE); 805 806 thread->setSuccess(); 807 return EGL_TRUE; 808 } 809 810 void ReleaseHighPowerGPUANGLE(Thread *thread, Display *display, gl::Context *context) 811 { 812 ANGLE_EGL_TRY(thread, display->prepareForCall(), "eglReleaseHighPowerGPUANGLE", 813 GetDisplayIfValid(display)); 814 ANGLE_EGL_TRY(thread, context->releaseHighPowerGPU(), "eglReleaseHighPowerGPUANGLE", 815 GetDisplayIfValid(display)); 816 817 thread->setSuccess(); 818 } 819 820 void ReacquireHighPowerGPUANGLE(Thread *thread, Display *display, gl::Context *context) 821 { 822 ANGLE_EGL_TRY(thread, display->prepareForCall(), "eglReacquireHighPowerGPUANGLE", 823 GetDisplayIfValid(display)); 824 ANGLE_EGL_TRY(thread, context->reacquireHighPowerGPU(), "eglReacquireHighPowerGPUANGLE", 825 GetDisplayIfValid(display)); 826 827 thread->setSuccess(); 828 } 829 830 void HandleGPUSwitchANGLE(Thread *thread, Display *display) 831 { 832 ANGLE_EGL_TRY(thread, display->prepareForCall(), "eglHandleGPUSwitchANGLE", 833 GetDisplayIfValid(display)); 834 ANGLE_EGL_TRY(thread, display->handleGPUSwitch(), "eglHandleGPUSwitchANGLE", 835 GetDisplayIfValid(display)); 836 837 thread->setSuccess(); 838 } 839 840 void ForceGPUSwitchANGLE(Thread *thread, Display *display, EGLint gpuIDHigh, EGLint gpuIDLow) 841 { 842 ANGLE_EGL_TRY(thread, display->prepareForCall(), "eglForceGPUSwitchANGLE", 843 GetDisplayIfValid(display)); 844 ANGLE_EGL_TRY(thread, display->forceGPUSwitch(gpuIDHigh, gpuIDLow), "eglForceGPUSwitchANGLE", 845 GetDisplayIfValid(display)); 846 847 thread->setSuccess(); 848 } 849 850 EGLBoolean QueryDisplayAttribANGLE(Thread *thread, 851 Display *display, 852 EGLint attribute, 853 EGLAttrib *value) 854 { 855 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQueryDisplayAttribEXT", 856 GetDisplayIfValid(display), EGL_FALSE); 857 *value = display->queryAttrib(attribute); 858 thread->setSuccess(); 859 return EGL_TRUE; 860 } 861 862 EGLBoolean LockSurfaceKHR(Thread *thread, 863 egl::Display *display, 864 Surface *surface, 865 const AttributeMap &attributes) 866 { 867 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglLockSurfaceKHR", 868 GetDisplayIfValid(display), EGL_FALSE); 869 ANGLE_EGL_TRY_RETURN(thread, surface->lockSurfaceKHR(display, attributes), "eglLockSurfaceKHR", 870 GetSurfaceIfValid(display, surface), EGL_FALSE); 871 thread->setSuccess(); 872 return EGL_TRUE; 873 } 874 875 EGLBoolean UnlockSurfaceKHR(Thread *thread, egl::Display *display, Surface *surface) 876 { 877 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglUnlockSurfaceKHR", 878 GetDisplayIfValid(display), EGL_FALSE); 879 ANGLE_EGL_TRY_RETURN(thread, surface->unlockSurfaceKHR(display), "eglQuerySurface64KHR", 880 GetSurfaceIfValid(display, surface), EGL_FALSE); 881 thread->setSuccess(); 882 return EGL_TRUE; 883 } 884 885 EGLBoolean QuerySurface64KHR(Thread *thread, 886 egl::Display *display, 887 Surface *surface, 888 EGLint attribute, 889 EGLAttribKHR *value) 890 { 891 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQuerySurface64KHR", 892 GetDisplayIfValid(display), EGL_FALSE); 893 ANGLE_EGL_TRY_RETURN( 894 thread, QuerySurfaceAttrib64KHR(display, thread->getContext(), surface, attribute, value), 895 "eglQuerySurface64KHR", GetSurfaceIfValid(display, surface), EGL_FALSE); 896 thread->setSuccess(); 897 return EGL_TRUE; 898 } 899 900 EGLBoolean ExportVkImageANGLE(Thread *thread, 901 egl::Display *display, 902 Image *image, 903 void *vk_image, 904 void *vk_image_create_info) 905 { 906 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglExportVkImageANGLE", 907 GetDisplayIfValid(display), EGL_FALSE); 908 ANGLE_EGL_TRY_RETURN(thread, image->exportVkImage(vk_image, vk_image_create_info), 909 "eglExportVkImageANGLE", GetImageIfValid(display, image), EGL_FALSE); 910 911 thread->setSuccess(); 912 return EGL_TRUE; 913 } 914 915 EGLBoolean SetDamageRegionKHR(Thread *thread, 916 egl::Display *display, 917 egl::Surface *surface, 918 EGLint *rects, 919 EGLint n_rects) 920 { 921 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglSetDamageRegionKHR", 922 GetDisplayIfValid(display), EGL_FALSE); 923 surface->setDamageRegion(rects, n_rects); 924 925 thread->setSuccess(); 926 return EGL_TRUE; 927 } 928 929 EGLBoolean QueryDmaBufFormatsEXT(Thread *thread, 930 egl::Display *display, 931 EGLint max_formats, 932 EGLint *formats, 933 EGLint *num_formats) 934 { 935 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQueryDmaBufFormatsEXT", 936 GetDisplayIfValid(display), EGL_FALSE); 937 ANGLE_EGL_TRY_RETURN(thread, display->queryDmaBufFormats(max_formats, formats, num_formats), 938 "eglQueryDmaBufFormatsEXT", GetDisplayIfValid(display), EGL_FALSE); 939 thread->setSuccess(); 940 return EGL_TRUE; 941 } 942 943 EGLBoolean QueryDmaBufModifiersEXT(Thread *thread, 944 egl::Display *display, 945 EGLint format, 946 EGLint max_modifiers, 947 EGLuint64KHR *modifiers, 948 EGLBoolean *external_only, 949 EGLint *num_modifiers) 950 { 951 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglQueryDmaBufModifiersEXT", 952 GetDisplayIfValid(display), EGL_FALSE); 953 ANGLE_EGL_TRY_RETURN(thread, 954 display->queryDmaBufModifiers(format, max_modifiers, modifiers, 955 external_only, num_modifiers), 956 "eglQueryDmaBufModifiersEXT", GetDisplayIfValid(display), EGL_FALSE); 957 thread->setSuccess(); 958 return EGL_TRUE; 959 } 960 961 void *CopyMetalSharedEventANGLE(Thread *thread, Display *display, Sync *syncObject) 962 { 963 ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglCopyMetalSharedEventANGLE", 964 GetDisplayIfValid(display), nullptr); 965 void *result = nullptr; 966 ANGLE_EGL_TRY_RETURN(thread, syncObject->copyMetalSharedEventANGLE(display, &result), 967 "eglCopyMetalSharedEventANGLE", GetSyncIfValid(display, syncObject), 968 nullptr); 969 970 thread->setSuccess(); 971 return result; 972 } 973 974 } // namespace egl