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_CLIENT_PROGRAM_INFO_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_ |
7 | 7 |
8 #include <GLES3/gl3.h> | 8 #include <GLES3/gl3.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 GLES2Implementation* gl, GLuint program, GLuint index, GLuint binding); | 67 GLES2Implementation* gl, GLuint program, GLuint index, GLuint binding); |
68 | 68 |
69 bool GetTransformFeedbackVarying( | 69 bool GetTransformFeedbackVarying( |
70 GLES2Implementation* gl, GLuint program, GLuint index, GLsizei bufsize, | 70 GLES2Implementation* gl, GLuint program, GLuint index, GLsizei bufsize, |
71 GLsizei* length, GLsizei* size, GLenum* type, char* name); | 71 GLsizei* length, GLsizei* size, GLenum* type, char* name); |
72 | 72 |
73 bool GetUniformIndices( | 73 bool GetUniformIndices( |
74 GLES2Implementation* gl, GLuint program, GLsizei count, | 74 GLES2Implementation* gl, GLuint program, GLsizei count, |
75 const char* const* names, GLuint* indices); | 75 const char* const* names, GLuint* indices); |
76 | 76 |
| 77 bool GetActiveUniformsiv( |
| 78 GLES2Implementation* gl, GLuint program, GLsizei count, |
| 79 const GLuint* indices, GLenum pname, GLint* params); |
| 80 |
77 private: | 81 private: |
78 friend class ProgramInfoManagerTest; | 82 friend class ProgramInfoManagerTest; |
79 | 83 |
80 FRIEND_TEST_ALL_PREFIXES(ProgramInfoManagerTest, UpdateES2); | 84 FRIEND_TEST_ALL_PREFIXES(ProgramInfoManagerTest, UpdateES2); |
81 FRIEND_TEST_ALL_PREFIXES(ProgramInfoManagerTest, UpdateES3UniformBlocks); | 85 FRIEND_TEST_ALL_PREFIXES(ProgramInfoManagerTest, UpdateES3UniformBlocks); |
82 FRIEND_TEST_ALL_PREFIXES(ProgramInfoManagerTest, | 86 FRIEND_TEST_ALL_PREFIXES(ProgramInfoManagerTest, |
83 UpdateES3TransformFeedbackVaryings); | 87 UpdateES3TransformFeedbackVaryings); |
| 88 FRIEND_TEST_ALL_PREFIXES(ProgramInfoManagerTest, |
| 89 GetActiveUniformsivCached); |
84 | 90 |
85 enum ProgramInfoType { | 91 enum ProgramInfoType { |
86 kES2, | 92 kES2, |
87 kES3UniformBlocks, | 93 kES3UniformBlocks, |
88 kES3TransformFeedbackVaryings, | 94 kES3TransformFeedbackVaryings, |
| 95 kES3Uniformsiv, |
89 kNone, | 96 kNone, |
90 }; | 97 }; |
91 | 98 |
92 // Need GLES2_IMPL_EXPORT for tests. | 99 // Need GLES2_IMPL_EXPORT for tests. |
93 class GLES2_IMPL_EXPORT Program { | 100 class GLES2_IMPL_EXPORT Program { |
94 public: | 101 public: |
95 struct UniformInfo { | 102 struct UniformInfo { |
96 UniformInfo(GLsizei _size, GLenum _type, const std::string& _name); | 103 UniformInfo(GLsizei _size, GLenum _type, const std::string& _name); |
97 ~UniformInfo(); | 104 ~UniformInfo(); |
98 | 105 |
99 GLsizei size; | 106 GLsizei size; |
100 GLenum type; | 107 GLenum type; |
101 bool is_array; | 108 bool is_array; |
102 std::string name; | 109 std::string name; |
103 std::vector<GLint> element_locations; | 110 std::vector<GLint> element_locations; |
104 }; | 111 }; |
| 112 struct UniformES3 { |
| 113 UniformES3(); |
| 114 ~UniformES3(); |
| 115 |
| 116 GLint block_index; |
| 117 GLint offset; |
| 118 GLint array_stride; |
| 119 GLint matrix_stride; |
| 120 GLint is_row_major; |
| 121 }; |
105 struct VertexAttrib { | 122 struct VertexAttrib { |
106 VertexAttrib(GLsizei _size, GLenum _type, const std::string& _name, | 123 VertexAttrib(GLsizei _size, GLenum _type, const std::string& _name, |
107 GLint _location); | 124 GLint _location); |
108 ~VertexAttrib(); | 125 ~VertexAttrib(); |
109 | 126 |
110 GLsizei size; | 127 GLsizei size; |
111 GLenum type; | 128 GLenum type; |
112 GLint location; | 129 GLint location; |
113 std::string name; | 130 std::string name; |
114 }; | 131 }; |
(...skipping 24 matching lines...) Expand all Loading... |
139 | 156 |
140 GLint GetAttribLocation(const std::string& name) const; | 157 GLint GetAttribLocation(const std::string& name) const; |
141 | 158 |
142 const UniformInfo* GetUniformInfo(GLint index) const; | 159 const UniformInfo* GetUniformInfo(GLint index) const; |
143 | 160 |
144 // Gets the location of a uniform by name. | 161 // Gets the location of a uniform by name. |
145 GLint GetUniformLocation(const std::string& name) const; | 162 GLint GetUniformLocation(const std::string& name) const; |
146 // Gets the index of a uniform by name. Return INVALID_INDEX in failure. | 163 // Gets the index of a uniform by name. Return INVALID_INDEX in failure. |
147 GLuint GetUniformIndex(const std::string& name) const; | 164 GLuint GetUniformIndex(const std::string& name) const; |
148 | 165 |
| 166 bool GetUniformsiv( |
| 167 GLsizei count, const GLuint* indices, GLenum pname, GLint* params); |
| 168 |
149 GLint GetFragDataLocation(const std::string& name) const; | 169 GLint GetFragDataLocation(const std::string& name) const; |
150 void CacheFragDataLocation(const std::string& name, GLint loc); | 170 void CacheFragDataLocation(const std::string& name, GLint loc); |
151 | 171 |
152 bool GetProgramiv(GLenum pname, GLint* params); | 172 bool GetProgramiv(GLenum pname, GLint* params); |
153 | 173 |
154 // Gets the index of a uniform block by name. | 174 // Gets the index of a uniform block by name. |
155 GLuint GetUniformBlockIndex(const std::string& name) const; | 175 GLuint GetUniformBlockIndex(const std::string& name) const; |
156 const UniformBlock* GetUniformBlock(GLuint index) const; | 176 const UniformBlock* GetUniformBlock(GLuint index) const; |
157 // Update the binding if the |index| uniform block is in the cache. | 177 // Update the binding if the |index| uniform block is in the cache. |
158 void UniformBlockBinding(GLuint index, GLuint binding); | 178 void UniformBlockBinding(GLuint index, GLuint binding); |
159 | 179 |
160 const TransformFeedbackVarying* GetTransformFeedbackVarying( | 180 const TransformFeedbackVarying* GetTransformFeedbackVarying( |
161 GLuint index) const; | 181 GLuint index) const; |
162 | 182 |
163 // Updates the ES2 only program info after a successful link. | 183 // Updates the ES2 only program info after a successful link. |
164 void UpdateES2(const std::vector<int8>& result); | 184 void UpdateES2(const std::vector<int8>& result); |
165 | 185 |
166 // Updates the ES3 UniformBlock info after a successful link. | 186 // Updates the ES3 UniformBlock info after a successful link. |
167 void UpdateES3UniformBlocks(const std::vector<int8>& result); | 187 void UpdateES3UniformBlocks(const std::vector<int8>& result); |
168 | 188 |
| 189 // Updates the ES3 Uniformsiv info after a successful link. |
| 190 void UpdateES3Uniformsiv(const std::vector<int8>& result); |
| 191 |
169 // Updates the ES3 TransformFeedbackVaryings info after a successful link. | 192 // Updates the ES3 TransformFeedbackVaryings info after a successful link. |
170 void UpdateES3TransformFeedbackVaryings(const std::vector<int8>& result); | 193 void UpdateES3TransformFeedbackVaryings(const std::vector<int8>& result); |
171 | 194 |
172 bool IsCached(ProgramInfoType type) const; | 195 bool IsCached(ProgramInfoType type) const; |
173 | 196 |
174 private: | 197 private: |
175 bool cached_es2_; | 198 bool cached_es2_; |
176 | 199 |
177 GLsizei max_attrib_name_length_; | 200 GLsizei max_attrib_name_length_; |
178 | 201 |
(...skipping 17 matching lines...) Expand all Loading... |
196 // Uniform blocks by index. | 219 // Uniform blocks by index. |
197 std::vector<UniformBlock> uniform_blocks_; | 220 std::vector<UniformBlock> uniform_blocks_; |
198 | 221 |
199 bool cached_es3_transform_feedback_varyings_; | 222 bool cached_es3_transform_feedback_varyings_; |
200 | 223 |
201 uint32_t transform_feedback_varying_max_length_; | 224 uint32_t transform_feedback_varying_max_length_; |
202 | 225 |
203 // TransformFeedback varyings by index. | 226 // TransformFeedback varyings by index. |
204 std::vector<TransformFeedbackVarying> transform_feedback_varyings_; | 227 std::vector<TransformFeedbackVarying> transform_feedback_varyings_; |
205 | 228 |
| 229 bool cached_es3_uniformsiv_; |
| 230 |
| 231 std::vector<UniformES3> uniforms_es3_; |
| 232 |
206 base::hash_map<std::string, GLint> frag_data_locations_; | 233 base::hash_map<std::string, GLint> frag_data_locations_; |
207 }; | 234 }; |
208 | 235 |
209 Program* GetProgramInfo( | 236 Program* GetProgramInfo( |
210 GLES2Implementation* gl, GLuint program, ProgramInfoType type); | 237 GLES2Implementation* gl, GLuint program, ProgramInfoType type); |
211 | 238 |
212 typedef base::hash_map<GLuint, Program> ProgramInfoMap; | 239 typedef base::hash_map<GLuint, Program> ProgramInfoMap; |
213 | 240 |
214 ProgramInfoMap program_infos_; | 241 ProgramInfoMap program_infos_; |
215 | 242 |
216 mutable base::Lock lock_; | 243 mutable base::Lock lock_; |
217 }; | 244 }; |
218 | 245 |
219 } // namespace gles2 | 246 } // namespace gles2 |
220 } // namespace gpu | 247 } // namespace gpu |
221 | 248 |
222 #endif // GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_ | 249 #endif // GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_ |
OLD | NEW |