• 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 // ShaderImpl.h: Defines the abstract rx::ShaderImpl class.
8 
9 #ifndef LIBANGLE_RENDERER_SHADERIMPL_H_
10 #define LIBANGLE_RENDERER_SHADERIMPL_H_
11 
12 #include <functional>
13 
14 #include "common/angleutils.h"
15 #include "libANGLE/Shader.h"
16 #include "libANGLE/WorkerThread.h"
17 
18 namespace gl
19 {
20 class ShCompilerInstance;
21 }  // namespace gl
22 
23 namespace rx
24 {
25 
26 using UpdateShaderStateFunctor = std::function<void(bool compiled, ShHandle handle)>;
27 class WaitableCompileEvent : public angle::WaitableEvent
28 {
29   public:
30     WaitableCompileEvent(std::shared_ptr<angle::WaitableEvent> waitableEvent);
31     ~WaitableCompileEvent() override;
32 
33     void wait() override;
34 
35     bool isReady() override;
36 
37     virtual bool getResult() = 0;
38 
39     virtual bool postTranslate(std::string *infoLog) = 0;
40 
41     const std::string &getInfoLog();
42 
43   protected:
44     std::shared_ptr<angle::WaitableEvent> mWaitableEvent;
45     std::string mInfoLog;
46 };
47 
48 class ShaderImpl : angle::NonCopyable
49 {
50   public:
ShaderImpl(const gl::ShaderState & data)51     ShaderImpl(const gl::ShaderState &data) : mData(data) {}
~ShaderImpl()52     virtual ~ShaderImpl() {}
53 
destroy()54     virtual void destroy() {}
55 
56     virtual std::shared_ptr<WaitableCompileEvent> compile(const gl::Context *context,
57                                                           gl::ShCompilerInstance *compilerInstance,
58                                                           ShCompileOptions options) = 0;
59 
60     virtual std::string getDebugInfo() const = 0;
61 
getData()62     const gl::ShaderState &getData() const { return mData; }
63 
64   protected:
65     std::shared_ptr<WaitableCompileEvent> compileImpl(const gl::Context *context,
66                                                       gl::ShCompilerInstance *compilerInstance,
67                                                       const std::string &source,
68                                                       ShCompileOptions compileOptions);
69 
70     const gl::ShaderState &mData;
71 };
72 
73 }  // namespace rx
74 
75 #endif  // LIBANGLE_RENDERER_SHADERIMPL_H_
76