Index: gpu/command_buffer/client/program_info_manager.h |
diff --git a/gpu/command_buffer/client/program_info_manager.h b/gpu/command_buffer/client/program_info_manager.h |
index 81be345f7b8db7145ecfb8ef3a6863c295465c10..570976862c32f32fd49cea20ebd9a1d2b7caaf4a 100644 |
--- a/gpu/command_buffer/client/program_info_manager.h |
+++ b/gpu/command_buffer/client/program_info_manager.h |
@@ -6,48 +6,143 @@ |
#define GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_ |
#include <GLES2/gl2.h> |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/containers/hash_tables.h" |
+#include "base/synchronization/lock.h" |
#include "gles2_impl_export.h" |
+#include "gpu/command_buffer/client/gles2_implementation.h" |
namespace gpu { |
namespace gles2 { |
-class GLES2Implementation; |
- |
// Manages info about OpenGL ES Programs. |
class GLES2_IMPL_EXPORT ProgramInfoManager { |
public: |
- virtual ~ProgramInfoManager(); |
+ ProgramInfoManager(); |
+ ~ProgramInfoManager(); |
- static ProgramInfoManager* Create(bool shared_resources_across_processes); |
+ void CreateInfo(GLuint program); |
- virtual void CreateInfo(GLuint program) = 0; |
+ void DeleteInfo(GLuint program); |
- virtual void DeleteInfo(GLuint program) = 0; |
+ bool GetProgramiv( |
+ GLES2Implementation* gl, GLuint program, GLenum pname, GLint* params); |
- virtual bool GetProgramiv( |
- GLES2Implementation* gl, GLuint program, GLenum pname, GLint* params) = 0; |
+ GLint GetAttribLocation( |
+ GLES2Implementation* gl, GLuint program, const char* name); |
- virtual GLint GetAttribLocation( |
- GLES2Implementation* gl, GLuint program, const char* name) = 0; |
+ GLint GetUniformLocation( |
+ GLES2Implementation* gl, GLuint program, const char* name); |
- virtual GLint GetUniformLocation( |
- GLES2Implementation* gl, GLuint program, const char* name) = 0; |
+ GLint GetFragDataLocation( |
+ GLES2Implementation* gl, GLuint program, const char* name); |
- virtual GLint GetFragDataLocation( |
- GLES2Implementation* gl, GLuint program, const char* name) = 0; |
+ bool GetActiveAttrib( |
+ GLES2Implementation* gl, GLuint program, GLuint index, GLsizei bufsize, |
+ GLsizei* length, GLint* size, GLenum* type, char* name); |
- virtual bool GetActiveAttrib( |
- GLES2Implementation* gl, |
- GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, |
- GLint* size, GLenum* type, char* name) = 0; |
+ bool GetActiveUniform( |
+ GLES2Implementation* gl, GLuint program, GLuint index, GLsizei bufsize, |
+ GLsizei* length, GLint* size, GLenum* type, char* name); |
- virtual bool GetActiveUniform( |
- GLES2Implementation* gl, |
- GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, |
- GLint* size, GLenum* type, char* name) = 0; |
+ private: |
+ class Program { |
+ public: |
+ struct UniformInfo { |
+ UniformInfo(GLsizei _size, GLenum _type, const std::string& _name); |
+ ~UniformInfo() { |
bajones
2015/01/30 21:40:22
Pretty sure just moving the closing curly brace on
piman
2015/01/30 21:55:39
It actually needs to be out-of-line because of non
Zhenyao Mo
2015/01/30 22:11:38
Thank you both for the tips. However, why my loca
piman
2015/01/30 22:15:45
It's a clang plugin.
|
+ } |
- protected: |
- ProgramInfoManager(); |
+ GLsizei size; |
+ GLenum type; |
+ bool is_array; |
+ std::string name; |
+ std::vector<GLint> element_locations; |
+ }; |
+ struct VertexAttrib { |
+ VertexAttrib(GLsizei _size, GLenum _type, const std::string& _name, |
+ GLint _location) |
+ : size(_size), |
+ type(_type), |
+ location(_location), |
+ name(_name) { |
+ } |
+ ~VertexAttrib() { |
bajones
2015/01/30 21:40:22
Ditto
|
+ } |
+ |
+ GLsizei size; |
+ GLenum type; |
+ GLint location; |
+ std::string name; |
+ }; |
+ |
+ typedef std::vector<UniformInfo> UniformInfoVector; |
+ typedef std::vector<VertexAttrib> AttribInfoVector; |
+ |
+ Program(); |
+ ~Program() { |
bajones
2015/01/30 21:40:22
Ditto
|
+ } |
+ |
+ const AttribInfoVector& GetAttribInfos() const { |
+ return attrib_infos_; |
+ } |
+ |
+ const VertexAttrib* GetAttribInfo(GLint index) const { |
+ return (static_cast<size_t>(index) < attrib_infos_.size()) ? |
+ &attrib_infos_[index] : NULL; |
+ } |
+ |
+ GLint GetAttribLocation(const std::string& name) const; |
+ |
+ const UniformInfo* GetUniformInfo(GLint index) const { |
+ return (static_cast<size_t>(index) < uniform_infos_.size()) ? |
+ &uniform_infos_[index] : NULL; |
+ } |
+ |
+ // Gets the location of a uniform by name. |
+ GLint GetUniformLocation(const std::string& name) const; |
+ |
+ GLint GetFragDataLocation(const std::string& name) const; |
+ void CacheFragDataLocation(const std::string& name, GLint loc); |
+ |
+ bool GetProgramiv(GLenum pname, GLint* params); |
+ |
+ // Updates the program info after a successful link. |
+ void Update(GLES2Implementation* gl, |
+ GLuint program, |
+ const std::vector<int8>& result); |
+ |
+ bool cached() const { return cached_; } |
+ |
+ private: |
+ bool cached_; |
+ |
+ GLsizei max_attrib_name_length_; |
+ |
+ // Attrib by index. |
+ AttribInfoVector attrib_infos_; |
+ |
+ GLsizei max_uniform_name_length_; |
+ |
+ // Uniform info by index. |
+ UniformInfoVector uniform_infos_; |
+ |
+ base::hash_map<std::string, GLint> frag_data_locations_; |
+ |
+ // This is true if glLinkProgram was successful last time it was called. |
+ bool link_status_; |
+ }; |
+ |
+ Program* GetProgramInfo(GLES2Implementation* gl, GLuint program); |
+ |
+ typedef base::hash_map<GLuint, Program> ProgramInfoMap; |
+ |
+ ProgramInfoMap program_infos_; |
+ |
+ mutable base::Lock lock_; |
}; |
} // namespace gles2 |