• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_glslang_mtl_utils.h: Wrapper for Khronos's glslang compiler for MSL.
7 //
8 
9 #ifndef mtl_glslang_mtl_utils_h
10 #define mtl_glslang_mtl_utils_h
11 #include "libANGLE/Context.h"
12 #include "libANGLE/renderer/ProgramImpl.h"
13 #include "libANGLE/renderer/glslang_wrapper_utils.h"
14 #include "libANGLE/renderer/metal/mtl_common.h"
15 
16 namespace rx
17 {
18 namespace mtl
19 {
20 struct SamplerBinding
21 {
22     uint32_t textureBinding = 0;
23     uint32_t samplerBinding = 0;
24 };
25 
26 struct TranslatedShaderInfo
27 {
28     void reset();
29     // Translated Metal source code
30     std::string metalShaderSource;
31     // Metal library compiled from source code above. Used by ProgramMtl.
32     AutoObjCPtr<id<MTLLibrary>> metalLibrary;
33     std::array<SamplerBinding, kMaxGLSamplerBindings> actualSamplerBindings;
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::ProgramState &programState,
40                         const gl::ProgramLinkedResources &resources,
41                         gl::ShaderMap<std::string> *shaderSourcesOut,
42                         ShaderInterfaceVariableInfoMap *variableInfoMapOut);
43 
44 angle::Result GlslangGetMSL(const gl::Context *glContext,
45                             const gl::ProgramState &programState,
46                             const gl::Caps &glCaps,
47                             const gl::ShaderMap<std::string> &shaderSources,
48                             const ShaderInterfaceVariableInfoMap &variableInfoMap,
49                             gl::ShaderMap<TranslatedShaderInfo> *mslShaderInfoOut,
50                             gl::ShaderMap<std::string> *mslCodeOut,
51                             size_t xfbBufferCount);
52 
53 // Get equivalent shadow compare mode that is used in translated msl shader.
54 uint MslGetShaderShadowCompareMode(GLenum mode, GLenum func);
55 
56 }  // namespace mtl
57 }  // namespace rx
58 
59 #endif /* mtl_glslang_mtl_utils_h */
60