1 2 // 3 // Copyright 2019 The ANGLE Project Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style license that can be 5 // found in the LICENSE file. 6 // 7 // ProgramMtl.h: 8 // Defines the class interface for ProgramMtl, implementing ProgramImpl. 9 // 10 11 #ifndef LIBANGLE_RENDERER_METAL_PROGRAMMTL_H_ 12 #define LIBANGLE_RENDERER_METAL_PROGRAMMTL_H_ 13 14 #import <Metal/Metal.h> 15 16 #include <array> 17 18 #include "common/Optional.h" 19 #include "common/utilities.h" 20 #include "libANGLE/renderer/ProgramImpl.h" 21 #include "libANGLE/renderer/metal/ProgramExecutableMtl.h" 22 #include "libANGLE/renderer/metal/ShaderMtl.h" 23 #include "libANGLE/renderer/metal/mtl_context_device.h" 24 25 namespace rx 26 { 27 #define SHADER_ENTRY_NAME @"main0" 28 class ContextMtl; 29 30 class ProgramMtl : public ProgramImpl 31 { 32 public: 33 ProgramMtl(const gl::ProgramState &state); 34 ~ProgramMtl() override; 35 36 void destroy(const gl::Context *context) override; 37 38 angle::Result load(const gl::Context *context, 39 gl::BinaryInputStream *stream, 40 std::shared_ptr<LinkTask> *loadTaskOut, 41 egl::CacheGetResult *resultOut) override; 42 void save(const gl::Context *context, gl::BinaryOutputStream *stream) override; 43 void setBinaryRetrievableHint(bool retrievable) override; 44 void setSeparable(bool separable) override; 45 46 void prepareForLink(const gl::ShaderMap<ShaderImpl *> &shaders) override; 47 angle::Result link(const gl::Context *context, std::shared_ptr<LinkTask> *linkTaskOut) override; 48 GLboolean validate(const gl::Caps &caps) override; 49 getExecutable()50 const ProgramExecutableMtl *getExecutable() const 51 { 52 return mtl::GetImpl(&mState.getExecutable()); 53 } getExecutable()54 ProgramExecutableMtl *getExecutable() { return mtl::GetImpl(&mState.getExecutable()); } 55 56 private: 57 class LinkTaskMtl; 58 class LoadTaskMtl; 59 60 friend class LinkTaskMtl; 61 62 angle::Result linkJobImpl(mtl::Context *context, 63 const gl::ProgramLinkedResources &resources, 64 std::vector<std::shared_ptr<LinkSubTask>> *subTasksOut); 65 66 void linkResources(const gl::ProgramLinkedResources &resources); 67 angle::Result compileMslShaderLibs(mtl::Context *context, 68 std::vector<std::shared_ptr<LinkSubTask>> *subTasksOut); 69 70 gl::ShaderMap<SharedCompiledShaderStateMtl> mAttachedShaders; 71 }; 72 73 } // namespace rx 74 75 #endif /* LIBANGLE_RENDERER_METAL_PROGRAMMTL_H_ */ 76