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_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 kANGLE, | 28 kANGLE, |
29 kGL, // GL or GLES | 29 kGL, // GL or GLES |
30 }; | 30 }; |
31 | 31 |
32 enum ShaderState { | 32 enum ShaderState { |
33 kShaderStateWaiting, | 33 kShaderStateWaiting, |
34 kShaderStateCompileRequested, | 34 kShaderStateCompileRequested, |
35 kShaderStateCompiled, // Signifies compile happened, not valid compile. | 35 kShaderStateCompiled, // Signifies compile happened, not valid compile. |
36 }; | 36 }; |
37 | 37 |
38 void RequestCompile(); | 38 void RequestCompile(scoped_refptr<ShaderTranslatorInterface> translator, |
| 39 TranslatedShaderSourceType type); |
39 | 40 |
40 void DoCompile(ShaderTranslatorInterface* translator, | 41 void DoCompile(); |
41 TranslatedShaderSourceType type); | |
42 | 42 |
43 ShaderState shader_state() const { | 43 ShaderState shader_state() const { |
44 return shader_state_; | 44 return shader_state_; |
45 } | 45 } |
46 | 46 |
47 GLuint service_id() const { | 47 GLuint service_id() const { |
48 return service_id_; | 48 return service_id_; |
49 } | 49 } |
50 | 50 |
51 GLenum shader_type() const { | 51 GLenum shader_type() const { |
52 return shader_type_; | 52 return shader_type_; |
53 } | 53 } |
54 | 54 |
55 const std::string& source() const { | 55 const std::string& source() const { |
56 return source_; | 56 return source_; |
57 } | 57 } |
58 | 58 |
59 void set_source(const std::string& source) { | 59 void set_source(const std::string& source) { |
60 source_ = source; | 60 source_ = source; |
61 } | 61 } |
62 | 62 |
63 const std::string& translated_source() const { | 63 const std::string& translated_source() const { |
64 return translated_source_; | 64 return translated_source_; |
65 } | 65 } |
66 | 66 |
67 const std::string& last_compiled_source() const { | 67 std::string last_compiled_source() const { |
68 return last_compiled_source_; | 68 return last_compiled_source_; |
69 } | 69 } |
70 | 70 |
| 71 std::string last_compiled_signature() const { |
| 72 if (translator_.get()) { |
| 73 return last_compiled_source_ + |
| 74 translator_->GetStringForOptionsThatWouldAffectCompilation(); |
| 75 } |
| 76 return last_compiled_source_; |
| 77 } |
| 78 |
71 const sh::Attribute* GetAttribInfo(const std::string& name) const; | 79 const sh::Attribute* GetAttribInfo(const std::string& name) const; |
72 const sh::Uniform* GetUniformInfo(const std::string& name) const; | 80 const sh::Uniform* GetUniformInfo(const std::string& name) const; |
73 const sh::Varying* GetVaryingInfo(const std::string& name) const; | 81 const sh::Varying* GetVaryingInfo(const std::string& name) const; |
74 | 82 |
75 // If the original_name is not found, return NULL. | 83 // If the original_name is not found, return NULL. |
76 const std::string* GetAttribMappedName( | 84 const std::string* GetAttribMappedName( |
77 const std::string& original_name) const; | 85 const std::string& original_name) const; |
78 | 86 |
79 // If the hashed_name is not found, return NULL. | 87 // If the hashed_name is not found, return NULL. |
80 const std::string* GetOriginalNameFromHashedName( | 88 const std::string* GetOriginalNameFromHashedName( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 153 |
146 // The current state of the shader. | 154 // The current state of the shader. |
147 ShaderState shader_state_; | 155 ShaderState shader_state_; |
148 | 156 |
149 // The shader this Shader is tracking. | 157 // The shader this Shader is tracking. |
150 GLuint service_id_; | 158 GLuint service_id_; |
151 | 159 |
152 // Type of shader - GL_VERTEX_SHADER or GL_FRAGMENT_SHADER. | 160 // Type of shader - GL_VERTEX_SHADER or GL_FRAGMENT_SHADER. |
153 GLenum shader_type_; | 161 GLenum shader_type_; |
154 | 162 |
| 163 // Translated source type when shader was last requested to be compiled. |
| 164 TranslatedShaderSourceType source_type_; |
| 165 |
| 166 // Translator to use, set when shader was last requested to be compiled. |
| 167 scoped_refptr<ShaderTranslatorInterface> translator_; |
| 168 |
155 // True if compilation succeeded. | 169 // True if compilation succeeded. |
156 bool valid_; | 170 bool valid_; |
157 | 171 |
158 // The shader source as passed to glShaderSource. | 172 // The shader source as passed to glShaderSource. |
159 std::string source_; | 173 std::string source_; |
160 | 174 |
161 // The source the last compile used. | 175 // The source the last compile used. |
162 std::string last_compiled_source_; | 176 std::string last_compiled_source_; |
163 | 177 |
164 // The translated shader source. | 178 // The translated shader source. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 void RemoveShader(Shader* shader); | 237 void RemoveShader(Shader* shader); |
224 | 238 |
225 DISALLOW_COPY_AND_ASSIGN(ShaderManager); | 239 DISALLOW_COPY_AND_ASSIGN(ShaderManager); |
226 }; | 240 }; |
227 | 241 |
228 } // namespace gles2 | 242 } // namespace gles2 |
229 } // namespace gpu | 243 } // namespace gpu |
230 | 244 |
231 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ | 245 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ |
232 | 246 |
OLD | NEW |