Index: gpu/command_buffer/service/vertex_attrib_manager.cc |
diff --git a/gpu/command_buffer/service/vertex_attrib_manager.cc b/gpu/command_buffer/service/vertex_attrib_manager.cc |
index 76883dc0f3fe2e956e9017ea82970d0b407e3fb1..fc3affe2cdcb5140dd3879f6e42f7e5c1c5023ef 100644 |
--- a/gpu/command_buffer/service/vertex_attrib_manager.cc |
+++ b/gpu/command_buffer/service/vertex_attrib_manager.cc |
@@ -127,6 +127,16 @@ VertexAttribManager::~VertexAttribManager() { |
void VertexAttribManager::Initialize(uint32_t max_vertex_attribs, |
bool init_attribs) { |
vertex_attribs_.resize(max_vertex_attribs); |
+ max_vertex_attribs_ = max_vertex_attribs; |
+ uint32_t packed_size = max_vertex_attribs_ / 16; |
+ packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1; |
+ attrib_base_type_mask_.resize(packed_size); |
+ attrib_type_written_mask_.resize(packed_size); |
+ |
+ for (uint32_t ii = 0; ii < packed_size; ++ii) { |
+ attrib_type_written_mask_[ii] = 0u; |
+ attrib_base_type_mask_[ii] = 0u; |
+ } |
for (uint32_t vv = 0; vv < vertex_attribs_.size(); ++vv) { |
vertex_attribs_[vv].set_index(vv); |
@@ -146,6 +156,15 @@ bool VertexAttribManager::Enable(GLuint index, bool enable) { |
if (index >= vertex_attribs_.size()) { |
return false; |
} |
+ |
+ DCHECK(index < max_vertex_attribs_); |
+ GLuint shift_bits = (index % 16) * 2; |
+ if (enable) { |
+ attrib_type_written_mask_[index / 16] |= (0x3 << shift_bits); |
+ } else { |
+ attrib_type_written_mask_[index / 16] &= ~(0x3 << shift_bits); |
+ } |
+ |
VertexAttrib& info = vertex_attribs_[index]; |
if (info.enabled() != enable) { |
info.set_enabled(enable); |