OLD | NEW |
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 gfx { | 18 namespace gfx { |
19 struct GLVersionInfo; | 19 struct GLVersionInfo; |
20 } | 20 } |
21 | 21 |
22 namespace gpu { | 22 namespace gpu { |
23 namespace gles2 { | 23 namespace gles2 { |
24 | 24 |
25 // Mapping between variable name and info. | 25 // Mapping between variable name and info. |
26 typedef base::hash_map<std::string, sh::Attribute> AttributeMap; | 26 typedef base::hash_map<std::string, sh::Attribute> AttributeMap; |
| 27 typedef std::vector<sh::OutputVariable> OutputVariableList; |
27 typedef base::hash_map<std::string, sh::Uniform> UniformMap; | 28 typedef base::hash_map<std::string, sh::Uniform> UniformMap; |
28 typedef base::hash_map<std::string, sh::Varying> VaryingMap; | 29 typedef base::hash_map<std::string, sh::Varying> VaryingMap; |
29 typedef base::hash_map<std::string, sh::InterfaceBlock> InterfaceBlockMap; | 30 typedef base::hash_map<std::string, sh::InterfaceBlock> InterfaceBlockMap; |
30 // Mapping between hashed name and original name. | 31 // Mapping between hashed name and original name. |
31 typedef base::hash_map<std::string, std::string> NameMap; | 32 typedef base::hash_map<std::string, std::string> NameMap; |
32 | 33 |
33 // Translates a GLSL ES 2.0 shader to desktop GLSL shader, or just | 34 // Translates a GLSL ES 2.0 shader to desktop GLSL shader, or just |
34 // validates GLSL ES 2.0 shaders on a true GLSL ES implementation. | 35 // validates GLSL ES 2.0 shaders on a true GLSL ES implementation. |
35 class ShaderTranslatorInterface | 36 class ShaderTranslatorInterface |
36 : public base::RefCounted<ShaderTranslatorInterface> { | 37 : public base::RefCounted<ShaderTranslatorInterface> { |
(...skipping 14 matching lines...) Expand all Loading... |
51 // Upon success, fill |translated_shader|, |attrib_map|, |uniform_map|, | 52 // Upon success, fill |translated_shader|, |attrib_map|, |uniform_map|, |
52 // |varying_map|, and |name_map| if they are non-null. | 53 // |varying_map|, and |name_map| if they are non-null. |
53 virtual bool Translate(const std::string& shader_source, | 54 virtual bool Translate(const std::string& shader_source, |
54 std::string* info_log, | 55 std::string* info_log, |
55 std::string* translated_shader, | 56 std::string* translated_shader, |
56 int* shader_version, | 57 int* shader_version, |
57 AttributeMap* attrib_map, | 58 AttributeMap* attrib_map, |
58 UniformMap* uniform_map, | 59 UniformMap* uniform_map, |
59 VaryingMap* varying_map, | 60 VaryingMap* varying_map, |
60 InterfaceBlockMap* interface_block_map, | 61 InterfaceBlockMap* interface_block_map, |
| 62 OutputVariableList* output_variable_list, |
61 NameMap* name_map) const = 0; | 63 NameMap* name_map) const = 0; |
62 | 64 |
63 // Return a string that is unique for a specfic set of options that would | 65 // Return a string that is unique for a specfic set of options that would |
64 // possibly affect compilation. | 66 // possibly affect compilation. |
65 virtual std::string GetStringForOptionsThatWouldAffectCompilation() const = 0; | 67 virtual std::string GetStringForOptionsThatWouldAffectCompilation() const = 0; |
66 | 68 |
67 protected: | 69 protected: |
68 virtual ~ShaderTranslatorInterface() {} | 70 virtual ~ShaderTranslatorInterface() {} |
69 | 71 |
70 private: | 72 private: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 104 |
103 // Overridden from ShaderTranslatorInterface. | 105 // Overridden from ShaderTranslatorInterface. |
104 bool Translate(const std::string& shader_source, | 106 bool Translate(const std::string& shader_source, |
105 std::string* info_log, | 107 std::string* info_log, |
106 std::string* translated_source, | 108 std::string* translated_source, |
107 int* shader_version, | 109 int* shader_version, |
108 AttributeMap* attrib_map, | 110 AttributeMap* attrib_map, |
109 UniformMap* uniform_map, | 111 UniformMap* uniform_map, |
110 VaryingMap* varying_map, | 112 VaryingMap* varying_map, |
111 InterfaceBlockMap* interface_block_map, | 113 InterfaceBlockMap* interface_block_map, |
| 114 OutputVariableList* output_variable_list, |
112 NameMap* name_map) const override; | 115 NameMap* name_map) const override; |
113 | 116 |
114 std::string GetStringForOptionsThatWouldAffectCompilation() const override; | 117 std::string GetStringForOptionsThatWouldAffectCompilation() const override; |
115 | 118 |
116 void AddDestructionObserver(DestructionObserver* observer); | 119 void AddDestructionObserver(DestructionObserver* observer); |
117 void RemoveDestructionObserver(DestructionObserver* observer); | 120 void RemoveDestructionObserver(DestructionObserver* observer); |
118 | 121 |
119 private: | 122 private: |
120 ~ShaderTranslator() override; | 123 ~ShaderTranslator() override; |
121 | 124 |
122 int GetCompileOptions() const; | 125 int GetCompileOptions() const; |
123 | 126 |
124 ShHandle compiler_; | 127 ShHandle compiler_; |
125 ShCompileOptions driver_bug_workarounds_; | 128 ShCompileOptions driver_bug_workarounds_; |
126 base::ObserverList<DestructionObserver> destruction_observers_; | 129 base::ObserverList<DestructionObserver> destruction_observers_; |
127 }; | 130 }; |
128 | 131 |
129 } // namespace gles2 | 132 } // namespace gles2 |
130 } // namespace gpu | 133 } // namespace gpu |
131 | 134 |
132 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ | 135 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ |
133 | 136 |
OLD | NEW |