1 // 2 // Copyright 2019 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 // mtl_msl_utils.h: Utilities to manipulate MSL. 7 // 8 9 #ifndef mtl_msl_utils_h 10 #define mtl_msl_utils_h 11 #include "libANGLE/Context.h" 12 #include "libANGLE/renderer/ProgramImpl.h" 13 #include "libANGLE/renderer/metal/mtl_common.h" 14 15 namespace rx 16 { 17 namespace mtl 18 { 19 struct SamplerBinding 20 { 21 uint32_t textureBinding = 0; 22 uint32_t samplerBinding = 0; 23 }; 24 25 struct TranslatedShaderInfo 26 { 27 void reset(); 28 // Translated Metal source code 29 std::shared_ptr<const std::string> metalShaderSource; 30 // Metal library compiled from source code above. Used by ProgramMtl. 31 AutoObjCPtr<id<MTLLibrary>> metalLibrary; 32 std::array<SamplerBinding, kMaxGLSamplerBindings> actualSamplerBindings; 33 std::array<int, kMaxShaderImages> actualImageBindings; 34 std::array<uint32_t, kMaxGLUBOBindings> actualUBOBindings; 35 std::array<uint32_t, kMaxShaderXFBs> actualXFBBindings; 36 bool hasUBOArgumentBuffer; 37 bool hasInvariantOrAtan; 38 }; 39 void MSLGetShaderSource(const gl::Context *context, 40 const gl::ProgramState &programState, 41 const gl::ProgramLinkedResources &resources, 42 gl::ShaderMap<std::string> *shaderSourcesOut); 43 44 angle::Result MTLGetMSL(const gl::Context *glContext, 45 const gl::ProgramState &programState, 46 const gl::Caps &glCaps, 47 const gl::ShaderMap<std::string> &shaderSources, 48 gl::ShaderMap<TranslatedShaderInfo> *mslShaderInfoOut, 49 size_t xfbBufferCount); 50 51 // Get equivalent shadow compare mode that is used in translated msl shader. 52 uint MslGetShaderShadowCompareMode(GLenum mode, GLenum func); 53 } // namespace mtl 54 } // namespace rx 55 56 #endif /* mtl_msl_utils_h */ 57