tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Compiler.h (2039B)


      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);
     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    const std::string &getBuiltinResourcesString() const;
     68    ShShaderOutput getShaderOutputType() const;
     69 
     70  private:
     71    ShHandle mHandle;
     72    ShShaderOutput mOutputType;
     73    ShaderType mShaderType;
     74 };
     75 
     76 }  // namespace gl
     77 
     78 #endif  // LIBANGLE_COMPILER_H_