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 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 5 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 void VertexAttribManager::Initialize(uint32_t max_vertex_attribs, | 127 void VertexAttribManager::Initialize(uint32_t max_vertex_attribs, |
128 bool init_attribs) { | 128 bool init_attribs) { |
129 vertex_attribs_.resize(max_vertex_attribs); | 129 vertex_attribs_.resize(max_vertex_attribs); |
130 max_vertex_attribs_ = max_vertex_attribs; | 130 max_vertex_attribs_ = max_vertex_attribs; |
131 uint32_t packed_size = max_vertex_attribs_ / 16; | 131 uint32_t packed_size = max_vertex_attribs_ / 16; |
132 packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1; | 132 packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1; |
133 attrib_base_type_mask_.resize(packed_size); | 133 attrib_base_type_mask_.resize(packed_size); |
134 attrib_type_written_mask_.resize(packed_size); | 134 attrib_enabled_mask_.resize(packed_size); |
135 | 135 |
136 for (uint32_t ii = 0; ii < packed_size; ++ii) { | 136 for (uint32_t ii = 0; ii < packed_size; ++ii) { |
137 attrib_type_written_mask_[ii] = 0u; | 137 attrib_enabled_mask_[ii] = 0u; |
138 attrib_base_type_mask_[ii] = 0u; | 138 attrib_base_type_mask_[ii] = 0u; |
139 } | 139 } |
140 | 140 |
141 for (uint32_t vv = 0; vv < vertex_attribs_.size(); ++vv) { | 141 for (uint32_t vv = 0; vv < vertex_attribs_.size(); ++vv) { |
142 vertex_attribs_[vv].set_index(vv); | 142 vertex_attribs_[vv].set_index(vv); |
143 vertex_attribs_[vv].SetList(&disabled_vertex_attribs_); | 143 vertex_attribs_[vv].SetList(&disabled_vertex_attribs_); |
144 | 144 |
145 if (init_attribs) { | 145 if (init_attribs) { |
146 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f); | 146 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f); |
147 } | 147 } |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 void VertexAttribManager::SetElementArrayBuffer(Buffer* buffer) { | 151 void VertexAttribManager::SetElementArrayBuffer(Buffer* buffer) { |
152 element_array_buffer_ = buffer; | 152 element_array_buffer_ = buffer; |
153 } | 153 } |
154 | 154 |
155 bool VertexAttribManager::Enable(GLuint index, bool enable) { | 155 bool VertexAttribManager::Enable(GLuint index, bool enable) { |
156 if (index >= vertex_attribs_.size()) { | 156 if (index >= vertex_attribs_.size()) { |
157 return false; | 157 return false; |
158 } | 158 } |
159 | 159 |
160 DCHECK(index < max_vertex_attribs_); | 160 DCHECK(index < max_vertex_attribs_); |
161 GLuint shift_bits = (index % 16) * 2; | 161 GLuint shift_bits = (index % 16) * 2; |
162 if (enable) { | 162 if (enable) { |
163 attrib_type_written_mask_[index / 16] |= (0x3 << shift_bits); | 163 attrib_enabled_mask_[index / 16] |= (0x3 << shift_bits); |
164 } else { | 164 } else { |
165 attrib_type_written_mask_[index / 16] &= ~(0x3 << shift_bits); | 165 attrib_enabled_mask_[index / 16] &= ~(0x3 << shift_bits); |
166 } | 166 } |
167 | 167 |
168 VertexAttrib& info = vertex_attribs_[index]; | 168 VertexAttrib& info = vertex_attribs_[index]; |
169 if (info.enabled() != enable) { | 169 if (info.enabled() != enable) { |
170 info.set_enabled(enable); | 170 info.set_enabled(enable); |
171 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_); | 171 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_); |
172 } | 172 } |
173 return true; | 173 return true; |
174 } | 174 } |
175 | 175 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 if (current_buffer_id != kInitialBufferId) { | 294 if (current_buffer_id != kInitialBufferId) { |
295 // Restore the buffer binding. | 295 // Restore the buffer binding. |
296 decoder->RestoreBufferBindings(); | 296 decoder->RestoreBufferBindings(); |
297 } | 297 } |
298 | 298 |
299 return true; | 299 return true; |
300 } | 300 } |
301 | 301 |
302 } // namespace gles2 | 302 } // namespace gles2 |
303 } // namespace gpu | 303 } // namespace gpu |
OLD | NEW |