Chromium Code Reviews| Index: gpu/command_buffer/service/context_state.h |
| diff --git a/gpu/command_buffer/service/context_state.h b/gpu/command_buffer/service/context_state.h |
| index d026df9a06fd38c22f76e0d508d994063614921c..a8f573accc663f33cc1c6c56dc3a3712f3177297 100644 |
| --- a/gpu/command_buffer/service/context_state.h |
| +++ b/gpu/command_buffer/service/context_state.h |
| @@ -243,6 +243,31 @@ struct GPU_EXPORT ContextState { |
| void SetBoundBuffer(GLenum target, Buffer* buffer); |
| void RemoveBoundBuffer(Buffer* buffer); |
| + void InitGenericAttribBaseType(GLuint max_vertex_attribs) { |
| + max_vertex_attribs_ = max_vertex_attribs; |
| + |
| + uint32_t packed_size = max_vertex_attribs_ / 16; |
|
Zhenyao Mo
2016/07/22 14:36:47
nit: this can be ceil(), but your code is also cor
|
| + packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1; |
| + generic_attrib_base_type_mask_.resize(packed_size); |
| + for (uint32_t i = 0; i < packed_size; ++i) { |
| + generic_attrib_base_type_mask_[i] = 0xFFFFFFFF; |
|
Zhenyao Mo
2016/07/22 14:36:47
set this to be 0x55555555 * SHADER_VARIABLE_FLOAT
|
| + } |
| + } |
| + |
| + void SetGenericVertexAttribBaseType(GLuint index, GLenum base_type) { |
| + DCHECK(index < max_vertex_attribs_); |
| + int shift_bits = (index % 16) * 2; |
| + generic_attrib_base_type_mask_[index / 16] &= ~(0x3 << shift_bits); |
| + generic_attrib_base_type_mask_[index / 16] |= (base_type << shift_bits); |
| + } |
| + |
| + // Return 16 attributes' base types, in which the generic attribute |
| + // specified by argument 'index' located. |
| + uint32_t GetGenericVertexAttribBaseTypeMask(GLuint index) { |
| + DCHECK(index < max_vertex_attribs_); |
| + return generic_attrib_base_type_mask_[index / 16]; |
| + } |
| + |
| void UnbindTexture(TextureRef* texture); |
| void UnbindSampler(Sampler* sampler); |
| @@ -320,6 +345,12 @@ struct GPU_EXPORT ContextState { |
| bool framebuffer_srgb_; |
| + uint32_t max_vertex_attribs_; |
| + // Generic 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> generic_attrib_base_type_mask_; |
| + |
| FeatureInfo* feature_info_; |
| std::unique_ptr<ErrorState> error_state_; |
| }; |