EGL: Implement eglCopyMetalSharedEventANGLE

Add eglCopyMetalSharedEventANGLE function to the
ANGLE_metal_shared_event_sync extension. This brings the extension on
par with the EGL_ANDROID_native_fence_sync extension.

eglCopyMetalSharedEventANGLE allows for copying the Metal event object
from EGLSync objects implemented by the ANGLE Metal renderer. This
function follows Objective-C convention for "copy" methods and increases
the retain count of the Metal event object. The EGL API user is thus
responsible for ensuring to release the returned object to avoid memory
leaks.

Test: angle_end2end_tests --gtest_filter=EGLSyncTestMetalSharedEvent.*
Bug: angleproject:7561
Change-Id: I8c35b559014b85cb8c6a0e76ac2ab7891eed5da0
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3881423
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Quyen Le <lehoangquyen@chromium.org>
This commit is contained in:
Dan Glastonbury 2022-09-08 14:19:21 +10:00 коммит произвёл Angle LUCI CQ
Родитель 655cc456c3
Коммит d2a58f00af
35 изменённых файлов: 228 добавлений и 50 удалений

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

@ -20,7 +20,7 @@ Status
Version
Version 1, 2022-05-17
Version 2, 2022-09-08
Number
@ -50,7 +50,9 @@ New Types
New Procedures and Functions
None.
void* eglCopyMetalSharedEventANGLE(
EGLDisplay dpy,
EGLSync sync);
New Tokens
@ -75,10 +77,15 @@ Additions to the EGL Specification
object is created. In this case the
EGL_SYNC_METAL_SHARED_EVENT_OBJECT_ANGLE,
EGL_SYNC_METAL_SHARED_EVENT_SIGNAL_VALUE_LO_ANGLE, and
EGL_SYNC_METAL_SHARED_EVENT_SIGNAL_VALUE_HI_ANGLE may be specified. If
EGL_SYNC_METAL_SHARED_EVENT_OBJECT_ANGLE is specified, it must be set to
either a valid MTLSharedEvent else EGL_NO_SYNC is returned and an
EGL_BAD_ATTRIBUTE error is generated.
EGL_SYNC_METAL_SHARED_EVENT_SIGNAL_VALUE_HI_ANGLE may be specified.
If EGL_SYNC_METAL_SHARED_EVENT_OBJECT_ANGLE attribute is specified, it must
be set to a pointer to a valid id<MTLSharedEvent>, or to a NULL pointer. If
EGL_SYNC_METAL_SHARED_EVENT_OBJECT_ANGLE is not specified, or is a NULL
pointer, the EGL implementation will create a Metal event
object. Additionally, the EGL implementation assumes ownership of the Metal
event object and will follow Objective-C behavior and increase the Metal
event object's retain count.
EGL_SYNC_METAL_SHARED_EVENT_SIGNAL_VALUE_LO_ANGLE and
EGL_SYNC_METAL_SHARED_EVENT_HI_ANGLE are optional attributes specifying the
@ -104,13 +111,27 @@ Additions to the EGL Specification
------
..."
Add the following after the last paragraph of Section 3.8.1 (Sync Objects):
"The command
void* eglCopyMetalSharedEventANGLE(
EGLDisplay dpy,
EGLSync sync);
increases the retain count of the id<MTLSharedEvent> stored in the
EGL_SYNC_METAL_SHARED_EVENT_OBJECT_ANGLE attribute of an EGL metal shared
event sync object and returns a pointer to the event as a void* pointer. If
this returns a non-null value, the caller is responsible for releasing the
MTLSharedEvent once after calling this function."
Issues
1. What should the name be? METAL_EVENT_ANGLE? MTL or METAL?
2. Add language describing the behaviour of
EGL_SYNC_METAL_SHARED_EVENT_SIGNAL_VALUE_ANGLE.
Revision History
Version 1, 2022-05-17
- Initial draft
Version 2, 2022-09-08
- Add eglCopyMetalSharedEventANGLE function

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

@ -404,6 +404,7 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTVKIMAGEANGLEPROC)(EGLDisplay dpy, E
#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);
#endif /* EGL_ANGLE_metal_shared_event_sync */
// clang-format on

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

@ -2,7 +2,7 @@
"doc/ExtensionSupport.md":
"4f886f94c6c7be460217ee237ee2afc2",
"scripts/egl_angle_ext.xml":
"4aea648b79c2c17ad4641903a52b942c",
"a325465cb2fd6e5bad81ab508e51885a",
"scripts/extension_data/intel_630_linux.json":
"d51f8d2a84b768c3fc6549d921d663b6",
"scripts/extension_data/intel_630_win10.json":

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

@ -1,6 +1,6 @@
{
"scripts/egl_angle_ext.xml":
"4aea648b79c2c17ad4641903a52b942c",
"a325465cb2fd6e5bad81ab508e51885a",
"scripts/generate_loader.py":
"101c7ad1f8f1bcd7c1afee3b854913af",
"scripts/gl.xml":
@ -10,9 +10,9 @@
"scripts/registry_xml.py":
"179f63c3ceb5081e649a7ed3700dfa25",
"src/libEGL/egl_loader_autogen.cpp":
"f8e305c5b9defa9ec419cac1a4c2247c",
"1903851e2f4b144ea50a909ec72e5a34",
"src/libEGL/egl_loader_autogen.h":
"6e1f48d3358bd57cb17e9ca7c8d0f13a",
"b5e2940d4320a251c1de1617d3e7fe11",
"third_party/EGL-Registry/src/api/egl.xml":
"2056d54ea07156f1988ca1366bdee21a",
"third_party/OpenCL-Docs/src/xml/cl.xml":
@ -22,17 +22,17 @@
"third_party/OpenGL-Registry/src/xml/wgl.xml":
"eae784bf4d1b983a42af5671b140b7c4",
"util/capture/trace_egl_loader_autogen.cpp":
"757d54a7afc30f8aa3d285ad2318f68c",
"39fe3e36337b75554ca7f614ede5b049",
"util/capture/trace_egl_loader_autogen.h":
"08ec72ee2cf70c590a6683b5c6f07c8b",
"67dcfacfb96f56f092eb42efd2ddabec",
"util/capture/trace_gles_loader_autogen.cpp":
"8bf975d96c15179f79ec19fb782dd2f7",
"util/capture/trace_gles_loader_autogen.h":
"fa8476f5dc0fc2393f3722de151fb655",
"util/egl_loader_autogen.cpp":
"6afbbc553222705dd77c48e7510250dd",
"bc2e8da82fc4b47586fdc52926582340",
"util/egl_loader_autogen.h":
"3e1e6ea983aa952601d1b6de83161a8a",
"09dc5e4fcaaf56615eba6ec06c9fe3fa",
"util/gles_loader_autogen.cpp":
"3d4a49c42883b7695a6472b8744c15e9",
"util/gles_loader_autogen.h":

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

@ -1,6 +1,6 @@
{
"scripts/egl_angle_ext.xml":
"4aea648b79c2c17ad4641903a52b942c",
"a325465cb2fd6e5bad81ab508e51885a",
"scripts/entry_point_packed_egl_enums.json":
"a72ae855c6b403912103b519139951a1",
"scripts/entry_point_packed_gl_enums.json":
@ -14,9 +14,9 @@
"scripts/registry_xml.py":
"179f63c3ceb5081e649a7ed3700dfa25",
"src/common/entry_points_enum_autogen.cpp":
"45209cbb838b78e3bf0badd0579941bb",
"86a935e3c784ce3155869ba3c922e4e8",
"src/common/entry_points_enum_autogen.h":
"f5831493ade2434b4b10a76a7195e23a",
"0e5738ed2a44c5c1e12048a8268f8d13",
"src/libANGLE/Context_gl_1_autogen.h":
"115d224fd28b0bc2b2800354bb57fcf3",
"src/libANGLE/Context_gl_2_autogen.h":
@ -86,7 +86,7 @@
"src/libANGLE/validationCL_autogen.h":
"0022d0cdb6a9e2ef4a59b71164f62333",
"src/libANGLE/validationEGL_autogen.h":
"e980833db949005de05ebfda3b65a18b",
"f2d2dacaa4d71f47002422663fc7ce67",
"src/libANGLE/validationES1_autogen.h":
"99af5e328690ae78d7724a80e94cfac5",
"src/libANGLE/validationES2_autogen.h":
@ -108,13 +108,13 @@
"src/libANGLE/validationGL4_autogen.h":
"cd7ad03880470cae2fe26fc9b7902ce9",
"src/libEGL/libEGL_autogen.cpp":
"d2a4716a1e32416b64aa11da7294a2d1",
"b5f1fb5f2b6c7726180ed1f5346a4b6f",
"src/libEGL/libEGL_autogen.def":
"773be535c00e01e343b52561fca73a6b",
"aee187cf3515a96c9114dab81b636ce7",
"src/libGLESv2/cl_stubs_autogen.h":
"6d880c6b65284192b5842f0e42ad2741",
"src/libGLESv2/egl_ext_stubs_autogen.h":
"35eac83d909581f12e28c98539b4f302",
"897ab98ae6d032876d73e42708bd95e5",
"src/libGLESv2/egl_get_labeled_object_data.json":
"2f4148b2ddf34e62670e32c5e6da4937",
"src/libGLESv2/egl_stubs_autogen.h":
@ -128,9 +128,9 @@
"src/libGLESv2/entry_points_egl_autogen.h":
"3bc7a8df9deadd7cfd615d0cfad0c6a8",
"src/libGLESv2/entry_points_egl_ext_autogen.cpp":
"9acd4e2c7d4ae61adc2cc01029f1dd08",
"104244d8913340f73808065850ba36e3",
"src/libGLESv2/entry_points_egl_ext_autogen.h":
"5ce03067f75c6179d47fe85186dff646",
"132314c90c7f1a104d41f911316c169d",
"src/libGLESv2/entry_points_gl_1_autogen.cpp":
"d4a2563f39dce48c37c4f932d199195e",
"src/libGLESv2/entry_points_gl_1_autogen.h":
@ -174,11 +174,11 @@
"src/libGLESv2/libGLESv2_autogen.cpp":
"e3d4791f3c9df1b6e7bbbbfb4075b2ce",
"src/libGLESv2/libGLESv2_autogen.def":
"ebfcc9d31afd905ed6b4d634bbe645bd",
"e150d390b5d42841c266e656a464230f",
"src/libGLESv2/libGLESv2_no_capture_autogen.def":
"1d593f099c8c59130e7827d7760463b2",
"874fd3a36dab15e6c6b5e4ef3de42245",
"src/libGLESv2/libGLESv2_with_capture_autogen.def":
"582ff7c2764077b83b137b1ff7d26ba5",
"ecce87aa987821f782010b15aeb26255",
"src/libOpenCL/libOpenCL_autogen.cpp":
"10849978c910dc1af5dd4f0c815d1581",
"third_party/EGL-Registry/src/api/egl.xml":

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

@ -1,6 +1,6 @@
{
"scripts/egl_angle_ext.xml":
"4aea648b79c2c17ad4641903a52b942c",
"a325465cb2fd6e5bad81ab508e51885a",
"scripts/gen_proc_table.py":
"073351265b085943f816498cecaa281c",
"scripts/gl.xml":
@ -12,7 +12,7 @@
"src/libGLESv2/proc_table_cl_autogen.cpp":
"ed003b0f041aaaa35b67d3fe07e61f91",
"src/libGLESv2/proc_table_egl_autogen.cpp":
"650697e18c5af4dfa53030a636901f06",
"0b632bfb29377f7ae1e2233980fe96a9",
"src/libGLESv2/proc_table_glx_autogen.cpp":
"429ff88a90eb303d1aaa58440e509d5e",
"src/libGLESv2/proc_table_wgl_autogen.cpp":

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

@ -131,6 +131,11 @@
<param><ptype>void *</ptype> <name>vk_image</name></param>
<param><ptype>void *</ptype> <name>vk_image_create_info</name></param>
</command>
<command>
<proto><ptype>void *</ptype> <name>eglCopyMetalSharedEventANGLE</name></proto>
<param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
<param><ptype>EGLSyncKHR</ptype> <name>sync</name></param>
</command>
</commands>
<!-- SECTION: ANGLE extension interface definitions -->
<extensions>
@ -452,6 +457,7 @@
</extension>
<extension name="EGL_ANGLE_metal_shared_event_sync" supported="egl">
<require>
<command name="eglCopyMetalSharedEventANGLE"/>
<enum name="EGL_SYNC_METAL_SHARED_EVENT_ANGLE"/>
<enum name="EGL_SYNC_METAL_SHARED_EVENT_OBJECT_ANGLE"/>
<enum name="EGL_SYNC_METAL_SHARED_EVENT_SIGNAL_VALUE_LO_ANGLE"/>

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

@ -260,6 +260,8 @@ const char *GetEntryPointName(EntryPoint ep)
return "eglClientWaitSyncKHR";
case EntryPoint::EGLCopyBuffers:
return "eglCopyBuffers";
case EntryPoint::EGLCopyMetalSharedEventANGLE:
return "eglCopyMetalSharedEventANGLE";
case EntryPoint::EGLCreateContext:
return "eglCreateContext";
case EntryPoint::EGLCreateDeviceANGLE:

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

@ -136,6 +136,7 @@ enum class EntryPoint
EGLClientWaitSync,
EGLClientWaitSyncKHR,
EGLCopyBuffers,
EGLCopyMetalSharedEventANGLE,
EGLCreateContext,
EGLCreateDeviceANGLE,
EGLCreateImage,

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

@ -101,6 +101,11 @@ Error Sync::getStatus(const Display *display, EGLint *outStatus) const
return mFence->getStatus(display, outStatus);
}
Error Sync::copyMetalSharedEventANGLE(const Display *display, void **result) const
{
return mFence->copyMetalSharedEventANGLE(display, result);
}
Error Sync::dupNativeFenceFD(const Display *display, EGLint *result) const
{
return mFence->dupNativeFenceFD(display, result);

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

@ -50,6 +50,7 @@ class Sync final : public angle::RefCountObject<Display, angle::Result>, public
Error signal(const Display *display, const gl::Context *context, EGLint mode);
Error getStatus(const Display *display, EGLint *outStatus) const;
Error copyMetalSharedEventANGLE(const Display *display, void **result) const;
Error dupNativeFenceFD(const Display *display, EGLint *result) const;
EGLenum getType() const { return mType; }

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

@ -21,6 +21,13 @@ egl::Error EGLSyncImpl::signal(const egl::Display *display, const gl::Context *c
return egl::EglBadMatch();
}
egl::Error EGLSyncImpl::copyMetalSharedEventANGLE(const egl::Display *display,
void **eventOut) const
{
UNREACHABLE();
return egl::EglBadMatch();
}
egl::Error EGLSyncImpl::dupNativeFenceFD(const egl::Display *display, EGLint *fdOut) const
{
UNREACHABLE();

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

@ -48,6 +48,8 @@ class EGLSyncImpl : angle::NonCopyable
EGLint flags) = 0;
virtual egl::Error signal(const egl::Display *display, const gl::Context *context, EGLint mode);
virtual egl::Error getStatus(const egl::Display *display, EGLint *outStatus) = 0;
virtual egl::Error copyMetalSharedEventANGLE(const egl::Display *display,
void **outEvent) const;
virtual egl::Error dupNativeFenceFD(const egl::Display *display, EGLint *fdOut) const;
};
} // namespace rx

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

@ -60,6 +60,8 @@ class Sync
void serverWait(ContextMtl *contextMtl);
angle::Result getStatus(bool *signaled);
void *copySharedEvent() const;
private:
SharedEventRef mMetalSharedEvent;
uint64_t mSignalValue = 0;
@ -97,6 +99,12 @@ class Sync
UNREACHABLE();
return angle::Result::Stop;
}
void *copySharedEvent() const
{
UNREACHABLE();
return nullptr;
}
};
#endif // #if defined(__IPHONE_12_0) || defined(__MAC_10_14)
} // namespace mtl
@ -158,6 +166,7 @@ class EGLSyncMtl final : public EGLSyncImpl
EGLint flags) override;
egl::Error getStatus(const egl::Display *display, EGLint *outStatus) override;
egl::Error copyMetalSharedEventANGLE(const egl::Display *display, void **result) const override;
egl::Error dupNativeFenceFD(const egl::Display *display, EGLint *result) const override;
private:

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

@ -138,6 +138,12 @@ angle::Result Sync::getStatus(bool *signaled)
*signaled = mMetalSharedEvent.get().signaledValue >= mSignalValue;
return angle::Result::Continue;
}
void *Sync::copySharedEvent() const
{
mtl::SharedEventRef copySharedEvent = mMetalSharedEvent;
return reinterpret_cast<void *>(copySharedEvent.leakObject());
}
#endif // #if defined(__IPHONE_12_0) || defined(__MAC_10_14)
} // namespace mtl
@ -272,9 +278,6 @@ egl::Error EGLSyncMtl::initialize(const egl::Display *display,
ASSERT(!mSignalValue.valid());
break;
case EGL_SYNC_METAL_SHARED_EVENT_ANGLE:
if (!mSharedEvent)
return egl::Error(EGL_BAD_ATTRIBUTE,
"EGL_SYNC_METAL_SHARED_EVENT_ANGLE can't be NULL");
break;
default:
UNREACHABLE();
@ -353,6 +356,19 @@ egl::Error EGLSyncMtl::getStatus(const egl::Display *display, EGLint *outStatus)
return egl::NoError();
}
egl::Error EGLSyncMtl::copyMetalSharedEventANGLE(const egl::Display *display, void **result) const
{
switch (mType)
{
case EGL_SYNC_METAL_SHARED_EVENT_ANGLE:
*result = mSync.copySharedEvent();
return egl::NoError();
default:
return egl::EglBadDisplay();
}
}
egl::Error EGLSyncMtl::dupNativeFenceFD(const egl::Display *display, EGLint *result) const
{
UNREACHABLE();

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

@ -249,6 +249,7 @@ class WrappedObject
bool valid() const { return (mMetalObject != nil); }
T get() const { return mMetalObject; }
T leakObject() { return std::exchange(mMetalObject, nullptr); }
inline void reset() { release(); }
operator T() const { return get(); }

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

@ -6110,6 +6110,23 @@ bool ValidateCreateNativeClientBufferANDROID(const ValidationContext *val,
return true;
}
bool ValidateCopyMetalSharedEventANGLE(const ValidationContext *val,
const Display *display,
const Sync *sync)
{
ANGLE_VALIDATION_TRY(ValidateDisplay(val, display));
if (!display->getExtensions().mtlSyncSharedEventANGLE)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANGLE_metal_shared_event_sync is not available.");
return false;
}
ANGLE_VALIDATION_TRY(ValidateSync(val, display, sync));
return true;
}
bool ValidateDupNativeFenceFDANDROID(const ValidationContext *val,
const Display *display,
const Sync *sync)

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

@ -242,6 +242,11 @@ bool ValidateQueryDisplayAttribANGLE(const ValidationContext *val,
EGLint attribute,
const EGLAttrib *value);
// EGL_ANGLE_metal_shared_event_sync
bool ValidateCopyMetalSharedEventANGLE(const ValidationContext *val,
const egl::Display *dpyPacked,
const Sync *syncPacked);
// EGL_ANGLE_power_preference
bool ValidateReleaseHighPowerGPUANGLE(const ValidationContext *val,
const egl::Display *dpyPacked,

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

@ -68,6 +68,7 @@ PFNEGLCREATEDEVICEANGLEPROC l_EGL_CreateDeviceANGLE;
PFNEGLRELEASEDEVICEANGLEPROC l_EGL_ReleaseDeviceANGLE;
PFNEGLQUERYDISPLAYATTRIBANGLEPROC l_EGL_QueryDisplayAttribANGLE;
PFNEGLQUERYSTRINGIANGLEPROC l_EGL_QueryStringiANGLE;
PFNEGLCOPYMETALSHAREDEVENTANGLEPROC l_EGL_CopyMetalSharedEventANGLE;
PFNEGLFORCEGPUSWITCHANGLEPROC l_EGL_ForceGPUSwitchANGLE;
PFNEGLHANDLEGPUSWITCHANGLEPROC l_EGL_HandleGPUSwitchANGLE;
PFNEGLREACQUIREHIGHPOWERGPUANGLEPROC l_EGL_ReacquireHighPowerGPUANGLE;
@ -214,6 +215,8 @@ void LoadEGL_EGL(LoadProc loadProc)
loadProc("EGL_QueryDisplayAttribANGLE"));
l_EGL_QueryStringiANGLE =
reinterpret_cast<PFNEGLQUERYSTRINGIANGLEPROC>(loadProc("EGL_QueryStringiANGLE"));
l_EGL_CopyMetalSharedEventANGLE = reinterpret_cast<PFNEGLCOPYMETALSHAREDEVENTANGLEPROC>(
loadProc("EGL_CopyMetalSharedEventANGLE"));
l_EGL_ForceGPUSwitchANGLE =
reinterpret_cast<PFNEGLFORCEGPUSWITCHANGLEPROC>(loadProc("EGL_ForceGPUSwitchANGLE"));
l_EGL_HandleGPUSwitchANGLE =

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

@ -73,6 +73,7 @@
#define EGL_ReleaseDeviceANGLE l_EGL_ReleaseDeviceANGLE
#define EGL_QueryDisplayAttribANGLE l_EGL_QueryDisplayAttribANGLE
#define EGL_QueryStringiANGLE l_EGL_QueryStringiANGLE
#define EGL_CopyMetalSharedEventANGLE l_EGL_CopyMetalSharedEventANGLE
#define EGL_ForceGPUSwitchANGLE l_EGL_ForceGPUSwitchANGLE
#define EGL_HandleGPUSwitchANGLE l_EGL_HandleGPUSwitchANGLE
#define EGL_ReacquireHighPowerGPUANGLE l_EGL_ReacquireHighPowerGPUANGLE
@ -184,6 +185,7 @@ ANGLE_NO_EXPORT extern PFNEGLCREATEDEVICEANGLEPROC l_EGL_CreateDeviceANGLE;
ANGLE_NO_EXPORT extern PFNEGLRELEASEDEVICEANGLEPROC l_EGL_ReleaseDeviceANGLE;
ANGLE_NO_EXPORT extern PFNEGLQUERYDISPLAYATTRIBANGLEPROC l_EGL_QueryDisplayAttribANGLE;
ANGLE_NO_EXPORT extern PFNEGLQUERYSTRINGIANGLEPROC l_EGL_QueryStringiANGLE;
ANGLE_NO_EXPORT extern PFNEGLCOPYMETALSHAREDEVENTANGLEPROC l_EGL_CopyMetalSharedEventANGLE;
ANGLE_NO_EXPORT extern PFNEGLFORCEGPUSWITCHANGLEPROC l_EGL_ForceGPUSwitchANGLE;
ANGLE_NO_EXPORT extern PFNEGLHANDLEGPUSWITCHANGLEPROC l_EGL_HandleGPUSwitchANGLE;
ANGLE_NO_EXPORT extern PFNEGLREACQUIREHIGHPOWERGPUANGLEPROC l_EGL_ReacquireHighPowerGPUANGLE;

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

@ -495,6 +495,13 @@ EGLBoolean EGLAPIENTRY eglQueryDisplayAttribANGLE(EGLDisplay dpy,
return EGL_QueryDisplayAttribANGLE(dpy, attribute, value);
}
// EGL_ANGLE_metal_shared_event_sync
void *EGLAPIENTRY eglCopyMetalSharedEventANGLE(EGLDisplay dpy, EGLSyncKHR sync)
{
EnsureEGLLoaded();
return EGL_CopyMetalSharedEventANGLE(dpy, sync);
}
// EGL_ANGLE_power_preference
void EGLAPIENTRY eglReleaseHighPowerGPUANGLE(EGLDisplay dpy, EGLContext ctx)
{

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

@ -91,6 +91,9 @@ EXPORTS
eglQueryDisplayAttribANGLE
eglQueryStringiANGLE
; EGL_ANGLE_metal_shared_event_sync
eglCopyMetalSharedEventANGLE
; EGL_ANGLE_power_preference
eglForceGPUSwitchANGLE
eglHandleGPUSwitchANGLE

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

@ -958,4 +958,17 @@ EGLBoolean QueryDmaBufModifiersEXT(Thread *thread,
return EGL_TRUE;
}
void *CopyMetalSharedEventANGLE(Thread *thread, Display *display, Sync *syncObject)
{
ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglCopyMetalSharedEventANGLE",
GetDisplayIfValid(display), nullptr);
void *result = nullptr;
ANGLE_EGL_TRY_RETURN(thread, syncObject->copyMetalSharedEventANGLE(display, &result),
"eglCopyMetalSharedEventANGLE", GetSyncIfValid(display, syncObject),
nullptr);
thread->setSuccess();
return result;
}
} // namespace egl

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

@ -259,5 +259,6 @@ EGLBoolean ExportVkImageANGLE(Thread *thread,
Image *imagePacked,
void *vk_image,
void *vk_image_create_info);
void *CopyMetalSharedEventANGLE(Thread *thread, egl::Display *dpyPacked, Sync *syncPacked);
} // namespace egl
#endif // LIBGLESV2_EGL_EXT_STUBS_AUTOGEN_H_

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

@ -312,6 +312,25 @@ EGLBoolean EGLAPIENTRY EGL_QueryDisplayAttribANGLE(EGLDisplay dpy,
return QueryDisplayAttribANGLE(thread, dpyPacked, attribute, value);
}
// EGL_ANGLE_metal_shared_event_sync
void *EGLAPIENTRY EGL_CopyMetalSharedEventANGLE(EGLDisplay dpy, EGLSyncKHR sync)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EGL_EVENT(CopyMetalSharedEventANGLE, "dpy = 0x%016" PRIxPTR ", sync = 0x%016" PRIxPTR "",
(uintptr_t)dpy, (uintptr_t)sync);
Thread *thread = egl::GetCurrentThread();
egl::Display *dpyPacked = PackParam<egl::Display *>(dpy);
Sync *syncPacked = PackParam<Sync *>(sync);
ANGLE_EGL_VALIDATE(thread, CopyMetalSharedEventANGLE, GetDisplayIfValid(dpyPacked), void *,
dpyPacked, syncPacked);
return CopyMetalSharedEventANGLE(thread, dpyPacked, syncPacked);
}
// EGL_ANGLE_power_preference
void EGLAPIENTRY EGL_ReleaseHighPowerGPUANGLE(EGLDisplay dpy, EGLContext ctx)
{

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

@ -74,6 +74,9 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY EGL_QueryDisplayAttribANGLE(EGLDisplay dpy,
EGLint attribute,
EGLAttrib *value);
// EGL_ANGLE_metal_shared_event_sync
ANGLE_EXPORT void *EGLAPIENTRY EGL_CopyMetalSharedEventANGLE(EGLDisplay dpy, EGLSyncKHR sync);
// EGL_ANGLE_power_preference
ANGLE_EXPORT void EGLAPIENTRY EGL_ReleaseHighPowerGPUANGLE(EGLDisplay dpy, EGLContext ctx);
ANGLE_EXPORT void EGLAPIENTRY EGL_ReacquireHighPowerGPUANGLE(EGLDisplay dpy, EGLContext ctx);

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

@ -1260,6 +1260,9 @@ EXPORTS
EGL_QueryDisplayAttribANGLE
EGL_QueryStringiANGLE
; EGL_ANGLE_metal_shared_event_sync
EGL_CopyMetalSharedEventANGLE
; EGL_ANGLE_power_preference
EGL_ForceGPUSwitchANGLE
EGL_HandleGPUSwitchANGLE

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

@ -1260,6 +1260,9 @@ EXPORTS
EGL_QueryDisplayAttribANGLE
EGL_QueryStringiANGLE
; EGL_ANGLE_metal_shared_event_sync
EGL_CopyMetalSharedEventANGLE
; EGL_ANGLE_power_preference
EGL_ForceGPUSwitchANGLE
EGL_HandleGPUSwitchANGLE

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

@ -1260,6 +1260,9 @@ EXPORTS
EGL_QueryDisplayAttribANGLE
EGL_QueryStringiANGLE
; EGL_ANGLE_metal_shared_event_sync
EGL_CopyMetalSharedEventANGLE
; EGL_ANGLE_power_preference
EGL_ForceGPUSwitchANGLE
EGL_HandleGPUSwitchANGLE

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

@ -51,6 +51,7 @@ const ProcEntry g_procTable[] = {
{"eglClientWaitSync", P(EGL_ClientWaitSync)},
{"eglClientWaitSyncKHR", P(EGL_ClientWaitSyncKHR)},
{"eglCopyBuffers", P(EGL_CopyBuffers)},
{"eglCopyMetalSharedEventANGLE", P(EGL_CopyMetalSharedEventANGLE)},
{"eglCreateContext", P(EGL_CreateContext)},
{"eglCreateDeviceANGLE", P(EGL_CreateDeviceANGLE)},
{"eglCreateImage", P(EGL_CreateImage)},

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

@ -64,6 +64,11 @@ class EGLSyncTestMetalSharedEvent : public ANGLETest<>
{
return reinterpret_cast<EGLAttrib>(sharedEvent);
}
id<MTLSharedEvent> sharedEventFromVoidPtr(void *ptr) const
{
return (__bridge id<MTLSharedEvent>)ptr;
}
};
// Test existing fence is created unsignaled
@ -154,23 +159,6 @@ TEST_P(EGLSyncTestMetalSharedEvent, GetSyncAttrib)
sharedEvent = nil;
}
// Verify CreateSync fails with out a valid EGL_SYNC_METAL_SHARED_OBJECT_ANGLE
TEST_P(EGLSyncTestMetalSharedEvent, CreateError)
{
ANGLE_SKIP_TEST_IF(!hasSyncMetalSharedEventExtension());
EGLDisplay display = getEGLWindow()->getDisplay();
EXPECT_EQ(EGL_NO_SYNC_KHR, eglCreateSync(display, EGL_SYNC_METAL_SHARED_EVENT_ANGLE, nullptr));
EXPECT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
EGLAttrib syncAttribs[] = {EGL_SYNC_METAL_SHARED_EVENT_OBJECT_ANGLE, NULL, EGL_NONE};
EXPECT_EQ(EGL_NO_SYNC_KHR,
eglCreateSync(display, EGL_SYNC_METAL_SHARED_EVENT_ANGLE, syncAttribs));
EXPECT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
}
// Verify CreateSync and ClientWait for EGL_ANGLE_metal_shared_event_sync
TEST_P(EGLSyncTestMetalSharedEvent, AngleMetalSharedEventSync_ClientWait)
{
@ -252,6 +240,31 @@ TEST_P(EGLSyncTestMetalSharedEvent, AngleMetalSharedEventSync_ClientWait_WithSig
sharedEvent = nil;
}
// Verify eglCopyMetalSharedEventANGLE for EGL_ANGLE_metal_shared_event_sync
TEST_P(EGLSyncTestMetalSharedEvent, AngleMetalSharedEventSync_CopyMetalSharedEventANGLE)
{
ANGLE_SKIP_TEST_IF(!hasSyncMetalSharedEventExtension());
EGLDisplay display = getEGLWindow()->getDisplay();
// We can ClientWait on this
EGLSync syncWithGeneratedEvent =
eglCreateSyncKHR(display, EGL_SYNC_METAL_SHARED_EVENT_ANGLE, nullptr);
EXPECT_NE(syncWithGeneratedEvent, EGL_NO_SYNC_KHR);
id<MTLSharedEvent> sharedEvent =
sharedEventFromVoidPtr(eglCopyMetalSharedEventANGLE(display, syncWithGeneratedEvent));
EXPECT_EGL_SUCCESS();
EXPECT_EQ([sharedEvent retainCount], 3ul);
glFinish();
EXPECT_EGL_TRUE(eglDestroySync(display, syncWithGeneratedEvent));
// Clean up created objects.
EXPECT_EQ([sharedEvent retainCount], 1ul);
[sharedEvent release];
}
// Verify WaitSync with EGL_ANGLE_metal_shared_event_sync
// Simulate passing shared events across processes by passing across Contexts.
TEST_P(EGLSyncTestMetalSharedEvent, AngleMetalSharedEventSync_WaitSync)

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

@ -72,6 +72,7 @@ ANGLE_TRACE_LOADER_EXPORT PFNEGLCREATEDEVICEANGLEPROC t_eglCreateDeviceANGLE;
ANGLE_TRACE_LOADER_EXPORT PFNEGLRELEASEDEVICEANGLEPROC t_eglReleaseDeviceANGLE;
ANGLE_TRACE_LOADER_EXPORT PFNEGLQUERYDISPLAYATTRIBANGLEPROC t_eglQueryDisplayAttribANGLE;
ANGLE_TRACE_LOADER_EXPORT PFNEGLQUERYSTRINGIANGLEPROC t_eglQueryStringiANGLE;
ANGLE_TRACE_LOADER_EXPORT PFNEGLCOPYMETALSHAREDEVENTANGLEPROC t_eglCopyMetalSharedEventANGLE;
ANGLE_TRACE_LOADER_EXPORT PFNEGLFORCEGPUSWITCHANGLEPROC t_eglForceGPUSwitchANGLE;
ANGLE_TRACE_LOADER_EXPORT PFNEGLHANDLEGPUSWITCHANGLEPROC t_eglHandleGPUSwitchANGLE;
ANGLE_TRACE_LOADER_EXPORT PFNEGLREACQUIREHIGHPOWERGPUANGLEPROC t_eglReacquireHighPowerGPUANGLE;
@ -220,6 +221,8 @@ void LoadEGL(LoadProc loadProc)
reinterpret_cast<PFNEGLQUERYDISPLAYATTRIBANGLEPROC>(loadProc("eglQueryDisplayAttribANGLE"));
t_eglQueryStringiANGLE =
reinterpret_cast<PFNEGLQUERYSTRINGIANGLEPROC>(loadProc("eglQueryStringiANGLE"));
t_eglCopyMetalSharedEventANGLE = reinterpret_cast<PFNEGLCOPYMETALSHAREDEVENTANGLEPROC>(
loadProc("eglCopyMetalSharedEventANGLE"));
t_eglForceGPUSwitchANGLE =
reinterpret_cast<PFNEGLFORCEGPUSWITCHANGLEPROC>(loadProc("eglForceGPUSwitchANGLE"));
t_eglHandleGPUSwitchANGLE =

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

@ -74,6 +74,7 @@
#define eglReleaseDeviceANGLE t_eglReleaseDeviceANGLE
#define eglQueryDisplayAttribANGLE t_eglQueryDisplayAttribANGLE
#define eglQueryStringiANGLE t_eglQueryStringiANGLE
#define eglCopyMetalSharedEventANGLE t_eglCopyMetalSharedEventANGLE
#define eglForceGPUSwitchANGLE t_eglForceGPUSwitchANGLE
#define eglHandleGPUSwitchANGLE t_eglHandleGPUSwitchANGLE
#define eglReacquireHighPowerGPUANGLE t_eglReacquireHighPowerGPUANGLE
@ -190,6 +191,7 @@ ANGLE_TRACE_LOADER_EXPORT extern PFNEGLCREATEDEVICEANGLEPROC t_eglCreateDeviceAN
ANGLE_TRACE_LOADER_EXPORT extern PFNEGLRELEASEDEVICEANGLEPROC t_eglReleaseDeviceANGLE;
ANGLE_TRACE_LOADER_EXPORT extern PFNEGLQUERYDISPLAYATTRIBANGLEPROC t_eglQueryDisplayAttribANGLE;
ANGLE_TRACE_LOADER_EXPORT extern PFNEGLQUERYSTRINGIANGLEPROC t_eglQueryStringiANGLE;
ANGLE_TRACE_LOADER_EXPORT extern PFNEGLCOPYMETALSHAREDEVENTANGLEPROC t_eglCopyMetalSharedEventANGLE;
ANGLE_TRACE_LOADER_EXPORT extern PFNEGLFORCEGPUSWITCHANGLEPROC t_eglForceGPUSwitchANGLE;
ANGLE_TRACE_LOADER_EXPORT extern PFNEGLHANDLEGPUSWITCHANGLEPROC t_eglHandleGPUSwitchANGLE;
ANGLE_TRACE_LOADER_EXPORT extern PFNEGLREACQUIREHIGHPOWERGPUANGLEPROC

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

@ -70,6 +70,7 @@ ANGLE_UTIL_EXPORT PFNEGLCREATEDEVICEANGLEPROC l_eglCreateDeviceANGLE;
ANGLE_UTIL_EXPORT PFNEGLRELEASEDEVICEANGLEPROC l_eglReleaseDeviceANGLE;
ANGLE_UTIL_EXPORT PFNEGLQUERYDISPLAYATTRIBANGLEPROC l_eglQueryDisplayAttribANGLE;
ANGLE_UTIL_EXPORT PFNEGLQUERYSTRINGIANGLEPROC l_eglQueryStringiANGLE;
ANGLE_UTIL_EXPORT PFNEGLCOPYMETALSHAREDEVENTANGLEPROC l_eglCopyMetalSharedEventANGLE;
ANGLE_UTIL_EXPORT PFNEGLFORCEGPUSWITCHANGLEPROC l_eglForceGPUSwitchANGLE;
ANGLE_UTIL_EXPORT PFNEGLHANDLEGPUSWITCHANGLEPROC l_eglHandleGPUSwitchANGLE;
ANGLE_UTIL_EXPORT PFNEGLREACQUIREHIGHPOWERGPUANGLEPROC l_eglReacquireHighPowerGPUANGLE;
@ -215,6 +216,8 @@ void LoadEGL(LoadProc loadProc)
reinterpret_cast<PFNEGLQUERYDISPLAYATTRIBANGLEPROC>(loadProc("eglQueryDisplayAttribANGLE"));
l_eglQueryStringiANGLE =
reinterpret_cast<PFNEGLQUERYSTRINGIANGLEPROC>(loadProc("eglQueryStringiANGLE"));
l_eglCopyMetalSharedEventANGLE = reinterpret_cast<PFNEGLCOPYMETALSHAREDEVENTANGLEPROC>(
loadProc("eglCopyMetalSharedEventANGLE"));
l_eglForceGPUSwitchANGLE =
reinterpret_cast<PFNEGLFORCEGPUSWITCHANGLEPROC>(loadProc("eglForceGPUSwitchANGLE"));
l_eglHandleGPUSwitchANGLE =

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

@ -74,6 +74,7 @@
#define eglReleaseDeviceANGLE l_eglReleaseDeviceANGLE
#define eglQueryDisplayAttribANGLE l_eglQueryDisplayAttribANGLE
#define eglQueryStringiANGLE l_eglQueryStringiANGLE
#define eglCopyMetalSharedEventANGLE l_eglCopyMetalSharedEventANGLE
#define eglForceGPUSwitchANGLE l_eglForceGPUSwitchANGLE
#define eglHandleGPUSwitchANGLE l_eglHandleGPUSwitchANGLE
#define eglReacquireHighPowerGPUANGLE l_eglReacquireHighPowerGPUANGLE
@ -185,6 +186,7 @@ ANGLE_UTIL_EXPORT extern PFNEGLCREATEDEVICEANGLEPROC l_eglCreateDeviceANGLE;
ANGLE_UTIL_EXPORT extern PFNEGLRELEASEDEVICEANGLEPROC l_eglReleaseDeviceANGLE;
ANGLE_UTIL_EXPORT extern PFNEGLQUERYDISPLAYATTRIBANGLEPROC l_eglQueryDisplayAttribANGLE;
ANGLE_UTIL_EXPORT extern PFNEGLQUERYSTRINGIANGLEPROC l_eglQueryStringiANGLE;
ANGLE_UTIL_EXPORT extern PFNEGLCOPYMETALSHAREDEVENTANGLEPROC l_eglCopyMetalSharedEventANGLE;
ANGLE_UTIL_EXPORT extern PFNEGLFORCEGPUSWITCHANGLEPROC l_eglForceGPUSwitchANGLE;
ANGLE_UTIL_EXPORT extern PFNEGLHANDLEGPUSWITCHANGLEPROC l_eglHandleGPUSwitchANGLE;
ANGLE_UTIL_EXPORT extern PFNEGLREACQUIREHIGHPOWERGPUANGLEPROC l_eglReacquireHighPowerGPUANGLE;