Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: gpu/command_buffer/service/vertex_attrib_manager.cc

Issue 2148723004: WebGL 2: make sure VertexAttrib type match the corresponding attrib type in shader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the bug in Windows gpu bot Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 glDeleteVertexArraysOES(1, &service_id_); 120 glDeleteVertexArraysOES(1, &service_id_);
121 } 121 }
122 manager_->StopTracking(this); 122 manager_->StopTracking(this);
123 manager_ = NULL; 123 manager_ = NULL;
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 attrib_base_type_mask_ = 0u;
131 attrib_written_mask_ = 0u;
130 132
131 for (uint32_t vv = 0; vv < vertex_attribs_.size(); ++vv) { 133 for (uint32_t vv = 0; vv < vertex_attribs_.size(); ++vv) {
132 vertex_attribs_[vv].set_index(vv); 134 vertex_attribs_[vv].set_index(vv);
133 vertex_attribs_[vv].SetList(&disabled_vertex_attribs_); 135 vertex_attribs_[vv].SetList(&disabled_vertex_attribs_);
134 136
135 if (init_attribs) { 137 if (init_attribs) {
136 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f); 138 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f);
137 } 139 }
138 } 140 }
139 } 141 }
140 142
141 void VertexAttribManager::SetElementArrayBuffer(Buffer* buffer) { 143 void VertexAttribManager::SetElementArrayBuffer(Buffer* buffer) {
142 element_array_buffer_ = buffer; 144 element_array_buffer_ = buffer;
143 } 145 }
144 146
145 bool VertexAttribManager::Enable(GLuint index, bool enable) { 147 bool VertexAttribManager::Enable(GLuint index, bool enable) {
146 if (index >= vertex_attribs_.size()) { 148 if (index >= vertex_attribs_.size()) {
147 return false; 149 return false;
148 } 150 }
151
152 if (!enable) {
153 attrib_written_mask_ &= ~(0x3 << (index * 2));
154 }
155
149 VertexAttrib& info = vertex_attribs_[index]; 156 VertexAttrib& info = vertex_attribs_[index];
150 if (info.enabled() != enable) { 157 if (info.enabled() != enable) {
151 info.set_enabled(enable); 158 info.set_enabled(enable);
152 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_); 159 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_);
153 } 160 }
154 return true; 161 return true;
155 } 162 }
156 163
157 void VertexAttribManager::Unbind(Buffer* buffer) { 164 void VertexAttribManager::Unbind(Buffer* buffer) {
158 if (element_array_buffer_.get() == buffer) { 165 if (element_array_buffer_.get() == buffer) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 if (current_buffer_id != kInitialBufferId) { 282 if (current_buffer_id != kInitialBufferId) {
276 // Restore the buffer binding. 283 // Restore the buffer binding.
277 decoder->RestoreBufferBindings(); 284 decoder->RestoreBufferBindings();
278 } 285 }
279 286
280 return true; 287 return true;
281 } 288 }
282 289
283 } // namespace gles2 290 } // namespace gles2
284 } // namespace gpu 291 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698