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_VERTEX_ATTRIB_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_VERTEX_ATTRIB_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_VERTEX_ATTRIB_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_VERTEX_ATTRIB_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 194 } |
195 | 195 |
196 VertexAttrib* GetVertexAttrib(GLuint index) { | 196 VertexAttrib* GetVertexAttrib(GLuint index) { |
197 if (index < vertex_attribs_.size()) { | 197 if (index < vertex_attribs_.size()) { |
198 return &vertex_attribs_[index]; | 198 return &vertex_attribs_[index]; |
199 } | 199 } |
200 return NULL; | 200 return NULL; |
201 } | 201 } |
202 | 202 |
203 void UpdateAttribBaseTypeAndMask(GLuint loc, GLenum base_type) { | 203 void UpdateAttribBaseTypeAndMask(GLuint loc, GLenum base_type) { |
204 DCHECK(loc < vertex_attribs_.size()); | 204 DCHECK(loc < max_vertex_attribs_); |
205 int shift_bits = (loc % 16) * 2; | 205 int shift_bits = (loc % 16) * 2; |
206 attrib_enabled_mask_[loc / 16] |= (0x3 << shift_bits); | 206 attrib_enabled_mask_[loc / 16] |= (0x3 << shift_bits); |
207 attrib_base_type_mask_[loc / 16] &= ~(0x3 << shift_bits); | 207 attrib_base_type_mask_[loc / 16] &= ~(0x3 << shift_bits); |
208 attrib_base_type_mask_[loc / 16] |= base_type << shift_bits; | 208 attrib_base_type_mask_[loc / 16] |= base_type << shift_bits; |
209 } | 209 } |
210 | 210 |
211 const std::vector<uint32_t>& attrib_base_type_mask() const { | 211 // Return 16 attributes' base types, in which the attribute |
212 return attrib_base_type_mask_; | 212 // specified by argument 'loc' located. |
| 213 uint32_t attrib_base_type_mask(GLuint loc) const { |
| 214 DCHECK(loc < max_vertex_attribs_); |
| 215 return attrib_base_type_mask_[loc / 16]; |
213 } | 216 } |
214 const std::vector<uint32_t>& attrib_enabled_mask() const { | 217 |
215 return attrib_enabled_mask_; | 218 // Return 16 attributes' type written masks, in which the |
| 219 // attribute specified by argument 'loc' located. |
| 220 uint32_t attrib_enabled_mask(GLuint loc) const { |
| 221 DCHECK(loc < max_vertex_attribs_); |
| 222 return attrib_enabled_mask_[loc / 16]; |
216 } | 223 } |
217 | 224 |
218 void SetAttribInfo( | 225 void SetAttribInfo( |
219 GLuint index, | 226 GLuint index, |
220 Buffer* buffer, | 227 Buffer* buffer, |
221 GLint size, | 228 GLint size, |
222 GLenum type, | 229 GLenum type, |
223 GLboolean normalized, | 230 GLboolean normalized, |
224 GLsizei gl_stride, | 231 GLsizei gl_stride, |
225 GLsizei real_stride, | 232 GLsizei real_stride, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 deleted_ = true; | 299 deleted_ = true; |
293 } | 300 } |
294 | 301 |
295 // number of attribs using type GL_FIXED. | 302 // number of attribs using type GL_FIXED. |
296 int num_fixed_attribs_; | 303 int num_fixed_attribs_; |
297 | 304 |
298 // Info for each vertex attribute saved so we can check at glDrawXXX time | 305 // Info for each vertex attribute saved so we can check at glDrawXXX time |
299 // if it is safe to draw. | 306 // if it is safe to draw. |
300 std::vector<VertexAttrib> vertex_attribs_; | 307 std::vector<VertexAttrib> vertex_attribs_; |
301 | 308 |
| 309 uint32_t max_vertex_attribs_; |
302 // Vertex attrib base types: FLOAT, INT, or UINT. | 310 // Vertex attrib base types: FLOAT, INT, or UINT. |
303 // Each base type is encoded into 2 bits, the lowest 2 bits for location 0, | 311 // Each base type is encoded into 2 bits, the lowest 2 bits for location 0, |
304 // the highest 2 bits for location (max_vertex_attribs - 1). | 312 // the highest 2 bits for location (max_vertex_attribs_ - 1). |
305 std::vector<uint32_t> attrib_base_type_mask_; | 313 std::vector<uint32_t> attrib_base_type_mask_; |
306 // Same layout as above, 2 bits per location, 0x03 if a location for an | 314 // Same layout as above, 2 bits per location, 0x03 if a location for an |
307 // vertex attrib is enabled by enabbleVertexAttribArray, 0x00 if it is | 315 // vertex attrib is enabled by enabbleVertexAttribArray, 0x00 if it is |
308 // disabled by disableVertexAttribArray. Every location is 0x00 by default. | 316 // disabled by disableVertexAttribArray. Every location is 0x00 by default. |
309 std::vector<uint32_t> attrib_enabled_mask_; | 317 std::vector<uint32_t> attrib_enabled_mask_; |
310 | 318 |
311 // The currently bound element array buffer. If this is 0 it is illegal | 319 // The currently bound element array buffer. If this is 0 it is illegal |
312 // to call glDrawElements. | 320 // to call glDrawElements. |
313 scoped_refptr<Buffer> element_array_buffer_; | 321 scoped_refptr<Buffer> element_array_buffer_; |
314 | 322 |
315 // Lists for which vertex attribs are enabled, disabled. | 323 // Lists for which vertex attribs are enabled, disabled. |
316 VertexAttribList enabled_vertex_attribs_; | 324 VertexAttribList enabled_vertex_attribs_; |
317 VertexAttribList disabled_vertex_attribs_; | 325 VertexAttribList disabled_vertex_attribs_; |
318 | 326 |
319 // The VertexArrayManager that owns this VertexAttribManager | 327 // The VertexArrayManager that owns this VertexAttribManager |
320 VertexArrayManager* manager_; | 328 VertexArrayManager* manager_; |
321 | 329 |
322 // True if deleted. | 330 // True if deleted. |
323 bool deleted_; | 331 bool deleted_; |
324 | 332 |
325 // Service side vertex array object id. | 333 // Service side vertex array object id. |
326 GLuint service_id_; | 334 GLuint service_id_; |
327 }; | 335 }; |
328 | 336 |
329 } // namespace gles2 | 337 } // namespace gles2 |
330 } // namespace gpu | 338 } // namespace gpu |
331 | 339 |
332 #endif // GPU_COMMAND_BUFFER_SERVICE_VERTEX_ATTRIB_MANAGER_H_ | 340 #endif // GPU_COMMAND_BUFFER_SERVICE_VERTEX_ATTRIB_MANAGER_H_ |
333 | 341 |
OLD | NEW |