Update EGL_ANGLE_metal_shared_event_sync implementation.

Rename the extension's .txt file to match the current name of the
extension.

Update function signatures to take EGLSync rather than EGLSyncKHR. The
two types are conceptually incompatible. This extension requires the
use of eglCreateSync rather than eglCreateSyncKHR because the latter
takes an array of EGLInt, but EGLAttrib is needed to express pointers
(to MTLSharedEvents) in the attribute list.

Revise ContextMtl::flush to use WaitUntilScheduled on older operating
systems not supporting MTLSharedEvent.

Bug: angleproject:7809
Change-Id: I39197616dc3e1e7ec6dc68dd83b4fde05184debf
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4000941
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
This commit is contained in:
Kenneth Russell 2022-11-02 16:02:46 -07:00 коммит произвёл Angle LUCI CQ
Родитель e449439e00
Коммит 3226cce3a6
4 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -407,9 +407,9 @@ EGLAPI EGLBoolean EGLAPIENTRY eglExportVkImageANGLE(EGLDisplay dpy, EGLImage ima
#define EGL_SYNC_METAL_SHARED_EVENT_OBJECT_ANGLE 0x34D9
#define EGL_SYNC_METAL_SHARED_EVENT_SIGNAL_VALUE_LO_ANGLE 0x34DA
#define EGL_SYNC_METAL_SHARED_EVENT_SIGNAL_VALUE_HI_ANGLE 0x34DB
typedef void* (EGLAPIENTRYP PFNEGLCOPYMETALSHAREDEVENTANGLEPROC)(EGLDisplay dpy, EGLSyncKHR sync);
typedef void* (EGLAPIENTRYP PFNEGLCOPYMETALSHAREDEVENTANGLEPROC)(EGLDisplay dpy, EGLSync sync);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI void *EGLAPIENTRY eglCopyMetalSharedEventANGLE(EGLDisplay dpy, EGLSyncKHR sync);
EGLAPI void *EGLAPIENTRY eglCopyMetalSharedEventANGLE(EGLDisplay dpy, EGLSync sync);
#endif
#endif /* EGL_ANGLE_metal_shared_event_sync */

Просмотреть файл

@ -576,6 +576,7 @@ class ContextMtl : public ContextImpl, public mtl::Context
mtl::RenderCommandEncoder mRenderEncoder;
mtl::BlitCommandEncoder mBlitEncoder;
mtl::ComputeCommandEncoder mComputeEncoder;
bool mHasMetalSharedEvents = false;
// Cached back-end objects
FramebufferMtl *mDrawFramebuffer = nullptr;

Просмотреть файл

@ -216,7 +216,12 @@ ContextMtl::ContextMtl(const gl::State &state,
mDriverUniforms{},
mProvokingVertexHelper(this),
mContextDevice(GetOwnershipIdentity(attribs))
{}
{
if (@available(iOS 12.0, macOS 10.14, *))
{
mHasMetalSharedEvents = true;
}
}
ContextMtl::~ContextMtl() {}
@ -285,7 +290,22 @@ angle::Result ContextMtl::ensureIncompleteTexturesCreated(const gl::Context *con
// Flush and finish.
angle::Result ContextMtl::flush(const gl::Context *context)
{
if (mHasMetalSharedEvents)
{
// MTLSharedEvent is available on these platforms, and callers
// are expected to use the EGL_ANGLE_metal_shared_event_sync
// extension to synchronize with ANGLE's Metal backend, if
// needed. This is typically required if two MTLDevices are
// operating on the same IOSurface.
flushCommandBuffer(mtl::NoWait);
}
else
{
// Older operating systems do not have this primitive available.
// Make every flush operation wait until it's scheduled in order to
// achieve callers' expected synchronization behavior.
flushCommandBuffer(mtl::WaitUntilScheduled);
}
return angle::Result::Continue;
}
angle::Result ContextMtl::finish(const gl::Context *context)