• 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, egl::Display *display);
35 
36     void onDestroy(const Context *context) override;
37 
38     ShCompilerInstance getInstance(ShaderType shaderType);
39     void putInstance(ShCompilerInstance &&instance);
getShaderOutputType()40     ShShaderOutput getShaderOutputType() const { return mOutputType; }
41 
42     static ShShaderSpec SelectShaderSpec(const State &state);
43 
44   private:
45     ~Compiler() override;
46     std::unique_ptr<rx::CompilerImpl> mImplementation;
47     ShShaderSpec mSpec;
48     ShShaderOutput mOutputType;
49     ShBuiltInResources mResources;
50     ShaderMap<std::vector<ShCompilerInstance>> mPools;
51 };
52 
53 class ShCompilerInstance final : public angle::NonCopyable
54 {
55   public:
56     ShCompilerInstance();
57     ShCompilerInstance(ShHandle handle, ShShaderOutput outputType, ShaderType shaderType);
58     ~ShCompilerInstance();
59     void destroy();
60 
61     ShCompilerInstance(ShCompilerInstance &&other);
62     ShCompilerInstance &operator=(ShCompilerInstance &&other);
63 
64     ShHandle getHandle();
65     ShaderType getShaderType() const;
66     ShBuiltInResources getBuiltInResources() const;
67     ShShaderOutput getShaderOutputType() const;
68 
69   private:
70     ShHandle mHandle;
71     ShShaderOutput mOutputType;
72     ShaderType mShaderType;
73 };
74 
75 }  // namespace gl
76 
77 #endif  // LIBANGLE_COMPILER_H_
78