Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: gpu/command_buffer/service/shader_translator.h

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "gpu/gpu_export.h" 15 #include "gpu/gpu_export.h"
16 #include "third_party/angle/include/GLSLANG/ShaderLang.h" 16 #include "third_party/angle/include/GLSLANG/ShaderLang.h"
17 17
18 namespace gpu { 18 namespace gpu {
19 namespace gles2 { 19 namespace gles2 {
20 20
21 // Mapping between variable name and info. 21 // Mapping between variable name and info.
22 typedef base::hash_map<std::string, sh::Attribute> AttributeMap; 22 typedef base::hash_map<std::string, sh::Attribute> AttributeMap;
23 typedef base::hash_map<std::string, sh::Uniform> UniformMap; 23 typedef base::hash_map<std::string, sh::Uniform> UniformMap;
24 typedef base::hash_map<std::string, sh::Varying> VaryingMap; 24 typedef base::hash_map<std::string, sh::Varying> VaryingMap;
25 // Mapping between hashed name and original name. 25 // Mapping between hashed name and original name.
26 typedef base::hash_map<std::string, std::string> NameMap; 26 typedef base::hash_map<std::string, std::string> NameMap;
27 27
28 // Translates a GLSL ES 2.0 shader to desktop GLSL shader, or just 28 // Translates a GLSL ES 2.0 shader to desktop GLSL shader, or just
29 // validates GLSL ES 2.0 shaders on a true GLSL ES implementation. 29 // validates GLSL ES 2.0 shaders on a true GLSL ES implementation.
30 class ShaderTranslatorInterface { 30 class ShaderTranslatorInterface
31 : public base::RefCounted<ShaderTranslatorInterface> {
31 public: 32 public:
33 ShaderTranslatorInterface() {}
32 enum GlslImplementationType { 34 enum GlslImplementationType {
33 kGlsl, 35 kGlsl,
34 kGlslES 36 kGlslES
35 }; 37 };
36 38
37 // Initializes the translator. 39 // Initializes the translator.
38 // Must be called once before using the translator object. 40 // Must be called once before using the translator object.
39 virtual bool Init( 41 virtual bool Init(
40 sh::GLenum shader_type, 42 sh::GLenum shader_type,
41 ShShaderSpec shader_spec, 43 ShShaderSpec shader_spec,
(...skipping 13 matching lines...) Expand all
55 UniformMap* uniform_map, 57 UniformMap* uniform_map,
56 VaryingMap* varying_map, 58 VaryingMap* varying_map,
57 NameMap* name_map) const = 0; 59 NameMap* name_map) const = 0;
58 60
59 // Return a string that is unique for a specfic set of options that would 61 // Return a string that is unique for a specfic set of options that would
60 // possibly affect compilation. 62 // possibly affect compilation.
61 virtual std::string GetStringForOptionsThatWouldAffectCompilation() const = 0; 63 virtual std::string GetStringForOptionsThatWouldAffectCompilation() const = 0;
62 64
63 protected: 65 protected:
64 virtual ~ShaderTranslatorInterface() {} 66 virtual ~ShaderTranslatorInterface() {}
67
68 private:
69 friend class base::RefCounted<ShaderTranslatorInterface>;
70 DISALLOW_COPY_AND_ASSIGN(ShaderTranslatorInterface);
65 }; 71 };
66 72
67 // Implementation of ShaderTranslatorInterface 73 // Implementation of ShaderTranslatorInterface
68 class GPU_EXPORT ShaderTranslator 74 class GPU_EXPORT ShaderTranslator
69 : public base::RefCounted<ShaderTranslator>, 75 : NON_EXPORTED_BASE(public ShaderTranslatorInterface) {
70 NON_EXPORTED_BASE(public ShaderTranslatorInterface) {
71 public: 76 public:
72 class DestructionObserver { 77 class DestructionObserver {
73 public: 78 public:
74 DestructionObserver(); 79 DestructionObserver();
75 virtual ~DestructionObserver(); 80 virtual ~DestructionObserver();
76 81
77 virtual void OnDestruct(ShaderTranslator* translator) = 0; 82 virtual void OnDestruct(ShaderTranslator* translator) = 0;
78 83
79 private: 84 private:
80 DISALLOW_COPY_AND_ASSIGN(DestructionObserver); 85 DISALLOW_COPY_AND_ASSIGN(DestructionObserver);
(...skipping 16 matching lines...) Expand all
97 UniformMap* uniform_map, 102 UniformMap* uniform_map,
98 VaryingMap* varying_map, 103 VaryingMap* varying_map,
99 NameMap* name_map) const override; 104 NameMap* name_map) const override;
100 105
101 std::string GetStringForOptionsThatWouldAffectCompilation() const override; 106 std::string GetStringForOptionsThatWouldAffectCompilation() const override;
102 107
103 void AddDestructionObserver(DestructionObserver* observer); 108 void AddDestructionObserver(DestructionObserver* observer);
104 void RemoveDestructionObserver(DestructionObserver* observer); 109 void RemoveDestructionObserver(DestructionObserver* observer);
105 110
106 private: 111 private:
107 friend class base::RefCounted<ShaderTranslator>; 112 ~ShaderTranslator() override;
108 113
109 ~ShaderTranslator() override;
110 int GetCompileOptions() const; 114 int GetCompileOptions() const;
111 115
112 ShHandle compiler_; 116 ShHandle compiler_;
113 bool implementation_is_glsl_es_; 117 bool implementation_is_glsl_es_;
114 ShCompileOptions driver_bug_workarounds_; 118 ShCompileOptions driver_bug_workarounds_;
115 ObserverList<DestructionObserver> destruction_observers_; 119 ObserverList<DestructionObserver> destruction_observers_;
116
117 DISALLOW_COPY_AND_ASSIGN(ShaderTranslator);
118 }; 120 };
119 121
120 } // namespace gles2 122 } // namespace gles2
121 } // namespace gpu 123 } // namespace gpu
122 124
123 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ 125 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_
124 126
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/shader_manager_unittest.cc ('k') | gpu/command_buffer/service/sync_point_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698