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

Side by Side Diff: gpu/command_buffer/service/context_state.h

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: update vertex attrib base type for vertexAttrib{I}Pointer only if the vertex attrib array is enabled 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 // This file contains the ContextState class. 5 // This file contains the ContextState class.
6 6
7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_
8 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ 8 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_
9 9
10 #include <memory> 10 #include <memory>
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return; 236 return;
237 } 237 }
238 glStencilMaskSeparate(op, mask); 238 glStencilMaskSeparate(op, mask);
239 } 239 }
240 240
241 ErrorState* GetErrorState(); 241 ErrorState* GetErrorState();
242 242
243 void SetBoundBuffer(GLenum target, Buffer* buffer); 243 void SetBoundBuffer(GLenum target, Buffer* buffer);
244 void RemoveBoundBuffer(Buffer* buffer); 244 void RemoveBoundBuffer(Buffer* buffer);
245 245
246 void SetGenericVertexAttribBaseType(GLuint index, GLenum base_type) {
247 DCHECK(index >=0 && index < 16);
248 int shift_bits = index * 2;
249 generic_attrib_type_written_mask_ |= ~(0x3 << shift_bits);
Zhenyao Mo 2016/07/20 17:54:56 You don't need this written mask. Every vertex at
yunchao 2016/07/22 13:43:53 Done.
250 generic_attrib_base_type_ &= ~(0x3 << shift_bits);
251 generic_attrib_base_type_ |= base_type << shift_bits;
252 }
253
254 uint32_t GetGenericVertexAttribBaseType() {
255 return generic_attrib_base_type_;
256 }
257
258 uint32_t GetGenericVertexAttribTypeMask() {
259 return generic_attrib_type_written_mask_;
260 }
261
246 void UnbindTexture(TextureRef* texture); 262 void UnbindTexture(TextureRef* texture);
247 void UnbindSampler(Sampler* sampler); 263 void UnbindSampler(Sampler* sampler);
248 264
249 PixelStoreParams GetPackParams(); 265 PixelStoreParams GetPackParams();
250 PixelStoreParams GetUnpackParams(Dimension dimension); 266 PixelStoreParams GetUnpackParams(Dimension dimension);
251 267
252 void EnableDisableFramebufferSRGB(bool enable); 268 void EnableDisableFramebufferSRGB(bool enable);
253 269
254 #include "gpu/command_buffer/service/context_state_autogen.h" 270 #include "gpu/command_buffer/service/context_state_autogen.h"
255 271
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // user values; otherwise, set them to 0. 329 // user values; otherwise, set them to 0.
314 void UpdatePackParameters() const; 330 void UpdatePackParameters() const;
315 // If a buffer object is bound to PIXEL_UNPACK_BUFFER, set all unpack 331 // If a buffer object is bound to PIXEL_UNPACK_BUFFER, set all unpack
316 // parameters user values; otherwise, set them to 0. 332 // parameters user values; otherwise, set them to 0.
317 void UpdateUnpackParameters() const; 333 void UpdateUnpackParameters() const;
318 334
319 void InitStateManual(const ContextState* prev_state) const; 335 void InitStateManual(const ContextState* prev_state) const;
320 336
321 bool framebuffer_srgb_; 337 bool framebuffer_srgb_;
322 338
339 // Generic vertex attrib base types: FLOAT, INT, or UINT.
340 // We have up to 16 attribs, each is encoded into 2 bits, total 32 bits
Zhenyao Mo 2016/07/20 17:54:56 You can't really limit it to 16. Instead, it shou
yunchao 2016/07/22 13:43:53 Done.
341 // the lowest 2 bits for location 0, the highest 2 bits for location 15.
342 uint32_t generic_attrib_base_type_;
Zhenyao Mo 2016/07/20 17:54:56 I really think we should keep the type_mask_ inste
yunchao 2016/07/22 13:43:53 Acknowledged.
343 // Same layout as above, 2 bits per location, 0x03 if a location is set
344 // by vertexAttrib API, 0x00 if not.
345 uint32_t generic_attrib_type_written_mask_;
346
323 FeatureInfo* feature_info_; 347 FeatureInfo* feature_info_;
324 std::unique_ptr<ErrorState> error_state_; 348 std::unique_ptr<ErrorState> error_state_;
325 }; 349 };
326 350
327 } // namespace gles2 351 } // namespace gles2
328 } // namespace gpu 352 } // namespace gpu
329 353
330 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ 354 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_
331 355
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/context_state.cc » ('j') | gpu/command_buffer/service/feature_info.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698