1*8975f5c5SAndroid Build Coastguard Worker // 2*8975f5c5SAndroid Build Coastguard Worker // Copyright (c) 2020 The ANGLE Project Authors. All rights reserved. 3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file. 5*8975f5c5SAndroid Build Coastguard Worker // 6*8975f5c5SAndroid Build Coastguard Worker // SyncMtl: 7*8975f5c5SAndroid Build Coastguard Worker // Defines the class interface for SyncMtl, implementing SyncImpl. 8*8975f5c5SAndroid Build Coastguard Worker // 9*8975f5c5SAndroid Build Coastguard Worker 10*8975f5c5SAndroid Build Coastguard Worker #ifndef LIBANGLE_RENDERER_METAL_SYNCMTL_H_ 11*8975f5c5SAndroid Build Coastguard Worker #define LIBANGLE_RENDERER_METAL_SYNCMTL_H_ 12*8975f5c5SAndroid Build Coastguard Worker 13*8975f5c5SAndroid Build Coastguard Worker #include <optional> 14*8975f5c5SAndroid Build Coastguard Worker 15*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/EGLSyncImpl.h" 16*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/FenceNVImpl.h" 17*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/SyncImpl.h" 18*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/metal/mtl_common.h" 19*8975f5c5SAndroid Build Coastguard Worker 20*8975f5c5SAndroid Build Coastguard Worker namespace egl 21*8975f5c5SAndroid Build Coastguard Worker { 22*8975f5c5SAndroid Build Coastguard Worker class AttributeMap; 23*8975f5c5SAndroid Build Coastguard Worker } 24*8975f5c5SAndroid Build Coastguard Worker 25*8975f5c5SAndroid Build Coastguard Worker namespace rx 26*8975f5c5SAndroid Build Coastguard Worker { 27*8975f5c5SAndroid Build Coastguard Worker 28*8975f5c5SAndroid Build Coastguard Worker class ContextMtl; 29*8975f5c5SAndroid Build Coastguard Worker 30*8975f5c5SAndroid Build Coastguard Worker namespace mtl 31*8975f5c5SAndroid Build Coastguard Worker { 32*8975f5c5SAndroid Build Coastguard Worker class SyncImpl; 33*8975f5c5SAndroid Build Coastguard Worker } // namespace mtl 34*8975f5c5SAndroid Build Coastguard Worker 35*8975f5c5SAndroid Build Coastguard Worker class FenceNVMtl : public FenceNVImpl 36*8975f5c5SAndroid Build Coastguard Worker { 37*8975f5c5SAndroid Build Coastguard Worker public: 38*8975f5c5SAndroid Build Coastguard Worker FenceNVMtl(); 39*8975f5c5SAndroid Build Coastguard Worker ~FenceNVMtl() override; 40*8975f5c5SAndroid Build Coastguard Worker void onDestroy(const gl::Context *context) override; 41*8975f5c5SAndroid Build Coastguard Worker angle::Result set(const gl::Context *context, GLenum condition) override; 42*8975f5c5SAndroid Build Coastguard Worker angle::Result test(const gl::Context *context, GLboolean *outFinished) override; 43*8975f5c5SAndroid Build Coastguard Worker angle::Result finish(const gl::Context *context) override; 44*8975f5c5SAndroid Build Coastguard Worker 45*8975f5c5SAndroid Build Coastguard Worker private: 46*8975f5c5SAndroid Build Coastguard Worker std::unique_ptr<mtl::SyncImpl> mSync; 47*8975f5c5SAndroid Build Coastguard Worker }; 48*8975f5c5SAndroid Build Coastguard Worker 49*8975f5c5SAndroid Build Coastguard Worker class SyncMtl : public SyncImpl 50*8975f5c5SAndroid Build Coastguard Worker { 51*8975f5c5SAndroid Build Coastguard Worker public: 52*8975f5c5SAndroid Build Coastguard Worker SyncMtl(); 53*8975f5c5SAndroid Build Coastguard Worker ~SyncMtl() override; 54*8975f5c5SAndroid Build Coastguard Worker 55*8975f5c5SAndroid Build Coastguard Worker void onDestroy(const gl::Context *context) override; 56*8975f5c5SAndroid Build Coastguard Worker 57*8975f5c5SAndroid Build Coastguard Worker angle::Result set(const gl::Context *context, GLenum condition, GLbitfield flags) override; 58*8975f5c5SAndroid Build Coastguard Worker angle::Result clientWait(const gl::Context *context, 59*8975f5c5SAndroid Build Coastguard Worker GLbitfield flags, 60*8975f5c5SAndroid Build Coastguard Worker GLuint64 timeout, 61*8975f5c5SAndroid Build Coastguard Worker GLenum *outResult) override; 62*8975f5c5SAndroid Build Coastguard Worker angle::Result serverWait(const gl::Context *context, 63*8975f5c5SAndroid Build Coastguard Worker GLbitfield flags, 64*8975f5c5SAndroid Build Coastguard Worker GLuint64 timeout) override; 65*8975f5c5SAndroid Build Coastguard Worker angle::Result getStatus(const gl::Context *context, GLint *outResult) override; 66*8975f5c5SAndroid Build Coastguard Worker 67*8975f5c5SAndroid Build Coastguard Worker private: 68*8975f5c5SAndroid Build Coastguard Worker std::unique_ptr<mtl::SyncImpl> mSync; 69*8975f5c5SAndroid Build Coastguard Worker }; 70*8975f5c5SAndroid Build Coastguard Worker 71*8975f5c5SAndroid Build Coastguard Worker class EGLSyncMtl final : public EGLSyncImpl 72*8975f5c5SAndroid Build Coastguard Worker { 73*8975f5c5SAndroid Build Coastguard Worker public: 74*8975f5c5SAndroid Build Coastguard Worker EGLSyncMtl(); 75*8975f5c5SAndroid Build Coastguard Worker ~EGLSyncMtl() override; 76*8975f5c5SAndroid Build Coastguard Worker 77*8975f5c5SAndroid Build Coastguard Worker void onDestroy(const egl::Display *display) override; 78*8975f5c5SAndroid Build Coastguard Worker 79*8975f5c5SAndroid Build Coastguard Worker egl::Error initialize(const egl::Display *display, 80*8975f5c5SAndroid Build Coastguard Worker const gl::Context *context, 81*8975f5c5SAndroid Build Coastguard Worker EGLenum type, 82*8975f5c5SAndroid Build Coastguard Worker const egl::AttributeMap &attribs) override; 83*8975f5c5SAndroid Build Coastguard Worker egl::Error clientWait(const egl::Display *display, 84*8975f5c5SAndroid Build Coastguard Worker const gl::Context *context, 85*8975f5c5SAndroid Build Coastguard Worker EGLint flags, 86*8975f5c5SAndroid Build Coastguard Worker EGLTime timeout, 87*8975f5c5SAndroid Build Coastguard Worker EGLint *outResult) override; 88*8975f5c5SAndroid Build Coastguard Worker egl::Error serverWait(const egl::Display *display, 89*8975f5c5SAndroid Build Coastguard Worker const gl::Context *context, 90*8975f5c5SAndroid Build Coastguard Worker EGLint flags) override; 91*8975f5c5SAndroid Build Coastguard Worker egl::Error getStatus(const egl::Display *display, EGLint *outStatus) override; 92*8975f5c5SAndroid Build Coastguard Worker 93*8975f5c5SAndroid Build Coastguard Worker egl::Error copyMetalSharedEventANGLE(const egl::Display *display, void **result) const override; 94*8975f5c5SAndroid Build Coastguard Worker egl::Error dupNativeFenceFD(const egl::Display *display, EGLint *result) const override; 95*8975f5c5SAndroid Build Coastguard Worker 96*8975f5c5SAndroid Build Coastguard Worker private: 97*8975f5c5SAndroid Build Coastguard Worker mtl::AutoObjCPtr<id<MTLSharedEvent>> mSharedEvent; 98*8975f5c5SAndroid Build Coastguard Worker 99*8975f5c5SAndroid Build Coastguard Worker std::unique_ptr<mtl::SyncImpl> mSync; 100*8975f5c5SAndroid Build Coastguard Worker }; 101*8975f5c5SAndroid Build Coastguard Worker 102*8975f5c5SAndroid Build Coastguard Worker } // namespace rx 103*8975f5c5SAndroid Build Coastguard Worker 104*8975f5c5SAndroid Build Coastguard Worker #endif 105