1 // 2 // Copyright 2020 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 7 #ifndef COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_PROGRAMPRELUDE_H_ 8 #define COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_PROGRAMPRELUDE_H_ 9 10 #include <unordered_set> 11 12 #include "common/angleutils.h" 13 14 namespace sh 15 { 16 17 class TInfoSinkBase; 18 class TIntermBlock; 19 20 enum class MetalShaderType 21 { 22 None, 23 Vertex, 24 Fragment, 25 Compute, // Unused currently 26 Count, 27 }; 28 29 struct ProgramPreludeConfig 30 { 31 public: ProgramPreludeConfigProgramPreludeConfig32 ProgramPreludeConfig() {} ProgramPreludeConfigProgramPreludeConfig33 explicit ProgramPreludeConfig(MetalShaderType shaderType) : shaderType(shaderType) {} 34 bool hasStructEq = false; 35 MetalShaderType shaderType = MetalShaderType::None; 36 }; 37 38 // This emits fixed helper Metal code directly without adding code to the AST. This walks the AST to 39 // figure out the required what prelude MSL code is needed for various things in the AST. You can 40 // think of this as effectively inlining various portions of a helper library into the emitted 41 // Metal program. 42 ANGLE_NO_DISCARD bool EmitProgramPrelude(TIntermBlock &root, 43 TInfoSinkBase &out, 44 const ProgramPreludeConfig &ppc); 45 46 } // namespace sh 47 48 #endif // COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_PROGRAMPRELUDE_H_ 49