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

Unified Diff: gpu/command_buffer/service/vertex_attrib_manager.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: code clean 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/vertex_attrib_manager.h
diff --git a/gpu/command_buffer/service/vertex_attrib_manager.h b/gpu/command_buffer/service/vertex_attrib_manager.h
index f3fae6d2d8f2e98ab144da10dad5f1ba210cfe1a..7491a56113a7a9732abb6c61cff5ca359d6d8e5e 100644
--- a/gpu/command_buffer/service/vertex_attrib_manager.h
+++ b/gpu/command_buffer/service/vertex_attrib_manager.h
@@ -200,6 +200,28 @@ class GPU_EXPORT VertexAttribManager :
return NULL;
}
+ void UpdateAttribBaseTypeAndMask(GLuint loc, GLenum base_type) {
+ DCHECK(loc < max_vertex_attribs_);
+ int shift_bits = (loc % 16) * 2;
+ attrib_type_written_mask_[loc / 16] |= (0x3 << shift_bits);
+ attrib_base_type_mask_[loc / 16] &= ~(0x3 << shift_bits);
+ attrib_base_type_mask_[loc / 16] |= base_type << shift_bits;
+ }
+
+ // Return 16 attributes' base types, in which the attribute
+ // specified by argument 'loc' located.
+ uint32_t attrib_base_type_mask(GLuint loc) const {
+ DCHECK(loc < max_vertex_attribs_);
+ return attrib_base_type_mask_[loc / 16];
+ }
+
+ // Return 16 attributes' type written masks, in which the
+ // attribute specified by argument 'loc' located.
+ uint32_t attrib_type_written_mask(GLuint loc) const {
+ DCHECK(loc < max_vertex_attribs_);
+ return attrib_type_written_mask_[loc / 16];
+ }
+
void SetAttribInfo(
GLuint index,
Buffer* buffer,
@@ -284,6 +306,15 @@ class GPU_EXPORT VertexAttribManager :
// if it is safe to draw.
std::vector<VertexAttrib> vertex_attribs_;
+ uint32_t max_vertex_attribs_;
+ // Vertex attrib base types: FLOAT, INT, or UINT.
+ // Each base type is encoded into 2 bits, the lowest 2 bits for location 0,
+ // the highest 2 bits for location (max_vertex_attribs_ - 1).
+ std::vector<uint32_t> attrib_base_type_mask_;
+ // Same layout as above, 2 bits per location, 0x03 if a location is set
+ // by vertexAttrib API, 0x00 if not.
+ std::vector<uint32_t> attrib_type_written_mask_;
Zhenyao Mo 2016/07/22 14:36:47 You don't need this written mask. If it's not wri
+
// The currently bound element array buffer. If this is 0 it is illegal
// to call glDrawElements.
scoped_refptr<Buffer> element_array_buffer_;

Powered by Google App Engine
This is Rietveld 408576698