• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 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 // Compiler.h: Defines the gl::Compiler class, abstracting the ESSL compiler
8 // that a GL context holds.
9 
10 #ifndef LIBANGLE_COMPILER_H_
11 #define LIBANGLE_COMPILER_H_
12 
13 #include <vector>
14 
15 #include "GLSLANG/ShaderLang.h"
16 #include "common/PackedEnums.h"
17 #include "libANGLE/Error.h"
18 #include "libANGLE/RefCountObject.h"
19 
20 namespace rx
21 {
22 class CompilerImpl;
23 class GLImplFactory;
24 }  // namespace rx
25 
26 namespace gl
27 {
28 class ShCompilerInstance;
29 class State;
30 
31 class Compiler final : public RefCountObjectNoID
32 {
33   public:
34     Compiler(rx::GLImplFactory *implFactory, const State &data);
35 
36     ShCompilerInstance getInstance(ShaderType shaderType);
37     void putInstance(ShCompilerInstance &&instance);
getShaderOutputType()38     ShShaderOutput getShaderOutputType() const { return mOutputType; }
39 
40   private:
41     ~Compiler() override;
42     std::unique_ptr<rx::CompilerImpl> mImplementation;
43     ShShaderSpec mSpec;
44     ShShaderOutput mOutputType;
45     ShBuiltInResources mResources;
46     ShaderMap<std::vector<ShCompilerInstance>> mPools;
47 };
48 
49 class ShCompilerInstance final : public angle::NonCopyable
50 {
51   public:
52     ShCompilerInstance();
53     ShCompilerInstance(ShHandle handle, ShShaderOutput outputType, ShaderType shaderType);
54     ~ShCompilerInstance();
55     void destroy();
56 
57     ShCompilerInstance(ShCompilerInstance &&other);
58     ShCompilerInstance &operator=(ShCompilerInstance &&other);
59 
60     ShHandle getHandle();
61     ShaderType getShaderType() const;
62     const std::string &getBuiltinResourcesString();
63     ShShaderOutput getShaderOutputType() const;
64 
65   private:
66     ShHandle mHandle;
67     ShShaderOutput mOutputType;
68     ShaderType mShaderType;
69 };
70 
71 }  // namespace gl
72 
73 #endif  // LIBANGLE_COMPILER_H_
74