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