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 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "gpu/command_buffer/service/gl_utils.h" | 14 #include "gpu/command_buffer/service/gl_utils.h" |
15 #include "gpu/command_buffer/service/shader_translator.h" | 15 #include "gpu/command_buffer/service/shader_translator.h" |
16 #include "gpu/gpu_export.h" | 16 #include "gpu/gpu_export.h" |
17 | 17 |
18 namespace gpu { | 18 namespace gpu { |
19 namespace gles2 { | 19 namespace gles2 { |
20 | 20 |
| 21 class ProgressReporter; |
| 22 |
21 enum ShaderVariableBaseType { | 23 enum ShaderVariableBaseType { |
22 SHADER_VARIABLE_INT = 0x01, | 24 SHADER_VARIABLE_INT = 0x01, |
23 SHADER_VARIABLE_UINT = 0x02, | 25 SHADER_VARIABLE_UINT = 0x02, |
24 SHADER_VARIABLE_FLOAT = 0x03, | 26 SHADER_VARIABLE_FLOAT = 0x03, |
25 SHADER_VARIABLE_UNDEFINED_TYPE = 0x00 | 27 SHADER_VARIABLE_UNDEFINED_TYPE = 0x00 |
26 }; | 28 }; |
27 | 29 |
28 // This is used to keep the source code for a shader. This is because in order | 30 // This is used to keep the source code for a shader. This is because in order |
29 // to emluate GLES2 the shaders will have to be re-written before passed to | 31 // to emluate GLES2 the shaders will have to be re-written before passed to |
30 // the underlying OpenGL. But, when the user calls glGetShaderSource they | 32 // the underlying OpenGL. But, when the user calls glGetShaderSource they |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // The name hashing info when the shader was last compiled. | 263 // The name hashing info when the shader was last compiled. |
262 NameMap name_map_; | 264 NameMap name_map_; |
263 }; | 265 }; |
264 | 266 |
265 // Tracks the Shaders. | 267 // Tracks the Shaders. |
266 // | 268 // |
267 // NOTE: To support shared resources an instance of this class will | 269 // NOTE: To support shared resources an instance of this class will |
268 // need to be shared by multiple GLES2Decoders. | 270 // need to be shared by multiple GLES2Decoders. |
269 class GPU_EXPORT ShaderManager { | 271 class GPU_EXPORT ShaderManager { |
270 public: | 272 public: |
271 ShaderManager(); | 273 ShaderManager(ProgressReporter* progress_reporter); |
272 ~ShaderManager(); | 274 ~ShaderManager(); |
273 | 275 |
274 // Must call before destruction. | 276 // Must call before destruction. |
275 void Destroy(bool have_context); | 277 void Destroy(bool have_context); |
276 | 278 |
277 // Creates a shader for the given shader ID. | 279 // Creates a shader for the given shader ID. |
278 Shader* CreateShader( | 280 Shader* CreateShader( |
279 GLuint client_id, | 281 GLuint client_id, |
280 GLuint service_id, | 282 GLuint service_id, |
281 GLenum shader_type); | 283 GLenum shader_type); |
(...skipping 19 matching lines...) Expand all Loading... |
301 | 303 |
302 private: | 304 private: |
303 friend class Shader; | 305 friend class Shader; |
304 | 306 |
305 // Info for each shader by service side shader Id. | 307 // Info for each shader by service side shader Id. |
306 typedef base::hash_map<GLuint, scoped_refptr<Shader> > ShaderMap; | 308 typedef base::hash_map<GLuint, scoped_refptr<Shader> > ShaderMap; |
307 ShaderMap shaders_; | 309 ShaderMap shaders_; |
308 | 310 |
309 void RemoveShader(Shader* shader); | 311 void RemoveShader(Shader* shader); |
310 | 312 |
| 313 // Used to notify the watchdog thread of progress during destruction, |
| 314 // preventing time-outs when destruction takes a long time. May be null when |
| 315 // using in-process command buffer. |
| 316 ProgressReporter* progress_reporter_; |
| 317 |
311 DISALLOW_COPY_AND_ASSIGN(ShaderManager); | 318 DISALLOW_COPY_AND_ASSIGN(ShaderManager); |
312 }; | 319 }; |
313 | 320 |
314 } // namespace gles2 | 321 } // namespace gles2 |
315 } // namespace gpu | 322 } // namespace gpu |
316 | 323 |
317 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ | 324 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ |
318 | 325 |
OLD | NEW |