| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 < max_vertex_attribs_); | 204 DCHECK(loc < max_vertex_attribs_); |
| 205 int shift_bits = (loc % 16) * 2; | 205 int shift_bits = (loc % 16) * 2; |
| 206 attrib_type_written_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 // Return 16 attributes' base types, in which the attribute | 211 // Return 16 attributes' base types, in which the attribute |
| 212 // specified by argument 'loc' located. | 212 // specified by argument 'loc' located. |
| 213 uint32_t attrib_base_type_mask(GLuint loc) const { | 213 uint32_t attrib_base_type_mask(GLuint loc) const { |
| 214 DCHECK(loc < max_vertex_attribs_); | 214 DCHECK(loc < max_vertex_attribs_); |
| 215 return attrib_base_type_mask_[loc / 16]; | 215 return attrib_base_type_mask_[loc / 16]; |
| 216 } | 216 } |
| 217 | 217 |
| 218 // Return 16 attributes' type written masks, in which the | 218 // Return 16 attributes' type written masks, in which the |
| 219 // attribute specified by argument 'loc' located. | 219 // attribute specified by argument 'loc' located. |
| 220 uint32_t attrib_type_written_mask(GLuint loc) const { | 220 uint32_t attrib_enabled_mask(GLuint loc) const { |
| 221 DCHECK(loc < max_vertex_attribs_); | 221 DCHECK(loc < max_vertex_attribs_); |
| 222 return attrib_type_written_mask_[loc / 16]; | 222 return attrib_enabled_mask_[loc / 16]; |
| 223 } | 223 } |
| 224 | 224 |
| 225 void SetAttribInfo( | 225 void SetAttribInfo( |
| 226 GLuint index, | 226 GLuint index, |
| 227 Buffer* buffer, | 227 Buffer* buffer, |
| 228 GLint size, | 228 GLint size, |
| 229 GLenum type, | 229 GLenum type, |
| 230 GLboolean normalized, | 230 GLboolean normalized, |
| 231 GLsizei gl_stride, | 231 GLsizei gl_stride, |
| 232 GLsizei real_stride, | 232 GLsizei real_stride, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 304 |
| 305 // 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 |
| 306 // if it is safe to draw. | 306 // if it is safe to draw. |
| 307 std::vector<VertexAttrib> vertex_attribs_; | 307 std::vector<VertexAttrib> vertex_attribs_; |
| 308 | 308 |
| 309 uint32_t max_vertex_attribs_; | 309 uint32_t max_vertex_attribs_; |
| 310 // Vertex attrib base types: FLOAT, INT, or UINT. | 310 // Vertex attrib base types: FLOAT, INT, or UINT. |
| 311 // 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, |
| 312 // the highest 2 bits for location (max_vertex_attribs_ - 1). | 312 // the highest 2 bits for location (max_vertex_attribs_ - 1). |
| 313 std::vector<uint32_t> attrib_base_type_mask_; | 313 std::vector<uint32_t> attrib_base_type_mask_; |
| 314 // Same layout as above, 2 bits per location, 0x03 if a location is set | 314 // Same layout as above, 2 bits per location, 0x03 if a location for an |
| 315 // by vertexAttrib API, 0x00 if not. | 315 // vertex attrib is enabled by enabbleVertexAttribArray, 0x00 if it is |
| 316 std::vector<uint32_t> attrib_type_written_mask_; | 316 // disabled by disableVertexAttribArray. Every location is 0x00 by default. |
| 317 std::vector<uint32_t> attrib_enabled_mask_; |
| 317 | 318 |
| 318 // 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 |
| 319 // to call glDrawElements. | 320 // to call glDrawElements. |
| 320 scoped_refptr<Buffer> element_array_buffer_; | 321 scoped_refptr<Buffer> element_array_buffer_; |
| 321 | 322 |
| 322 // Lists for which vertex attribs are enabled, disabled. | 323 // Lists for which vertex attribs are enabled, disabled. |
| 323 VertexAttribList enabled_vertex_attribs_; | 324 VertexAttribList enabled_vertex_attribs_; |
| 324 VertexAttribList disabled_vertex_attribs_; | 325 VertexAttribList disabled_vertex_attribs_; |
| 325 | 326 |
| 326 // The VertexArrayManager that owns this VertexAttribManager | 327 // The VertexArrayManager that owns this VertexAttribManager |
| 327 VertexArrayManager* manager_; | 328 VertexArrayManager* manager_; |
| 328 | 329 |
| 329 // True if deleted. | 330 // True if deleted. |
| 330 bool deleted_; | 331 bool deleted_; |
| 331 | 332 |
| 332 // Service side vertex array object id. | 333 // Service side vertex array object id. |
| 333 GLuint service_id_; | 334 GLuint service_id_; |
| 334 }; | 335 }; |
| 335 | 336 |
| 336 } // namespace gles2 | 337 } // namespace gles2 |
| 337 } // namespace gpu | 338 } // namespace gpu |
| 338 | 339 |
| 339 #endif // GPU_COMMAND_BUFFER_SERVICE_VERTEX_ATTRIB_MANAGER_H_ | 340 #endif // GPU_COMMAND_BUFFER_SERVICE_VERTEX_ATTRIB_MANAGER_H_ |
| 340 | 341 |
| OLD | NEW |