Commit cddee2c7 authored by yunchao.he's avatar yunchao.he Committed by Commit bot

WebGL 2: Fix nits when check vertexAttrib type with variable type in vertex shader.

See the CL: https://codereview.chromium.org/2148723004

BUG=628459
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2175673003
Cr-Commit-Position: refs/heads/master@{#407303}
parent 5c1cf329
...@@ -222,12 +222,9 @@ ContextState::ContextState(FeatureInfo* feature_info, ...@@ -222,12 +222,9 @@ ContextState::ContextState(FeatureInfo* feature_info,
ignore_cached_state(false), ignore_cached_state(false),
fbo_binding_for_scissor_workaround_dirty(false), fbo_binding_for_scissor_workaround_dirty(false),
framebuffer_srgb_(false), framebuffer_srgb_(false),
max_vertex_attribs_(0),
feature_info_(feature_info), feature_info_(feature_info),
error_state_(ErrorState::Create(error_state_client, logger)) { error_state_(ErrorState::Create(error_state_client, logger)) {
max_vertex_attribs_ = 0;
generic_attrib_base_type_mask_.resize(1);
generic_attrib_base_type_mask_[0] = 0xFFFFFFFF;
Initialize(); Initialize();
} }
......
...@@ -250,7 +250,8 @@ struct GPU_EXPORT ContextState { ...@@ -250,7 +250,8 @@ struct GPU_EXPORT ContextState {
packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1; packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1;
generic_attrib_base_type_mask_.resize(packed_size); generic_attrib_base_type_mask_.resize(packed_size);
for (uint32_t i = 0; i < packed_size; ++i) { for (uint32_t i = 0; i < packed_size; ++i) {
generic_attrib_base_type_mask_[i] = 0xFFFFFFFF; // All generic attribs are float type by default.
generic_attrib_base_type_mask_[i] = 0x55555555u * SHADER_VARIABLE_FLOAT;
} }
} }
......
...@@ -1433,10 +1433,10 @@ bool FeatureInfo::IsWebGL2OrES3Context() const { ...@@ -1433,10 +1433,10 @@ bool FeatureInfo::IsWebGL2OrES3Context() const {
case CONTEXT_TYPE_WEBGL1: case CONTEXT_TYPE_WEBGL1:
case CONTEXT_TYPE_OPENGLES2: case CONTEXT_TYPE_OPENGLES2:
return false; return false;
default:
NOTREACHED();
return false;
} }
NOTREACHED();
return false;
} }
void FeatureInfo::AddExtensionString(const char* s) { void FeatureInfo::AddExtensionString(const char* s) {
......
...@@ -9142,14 +9142,14 @@ bool GLES2DecoderImpl::AttribsTypeMatch() { ...@@ -9142,14 +9142,14 @@ bool GLES2DecoderImpl::AttribsTypeMatch() {
for (uint32_t index = 0; index < group_->max_vertex_attribs(); index += 16) { for (uint32_t index = 0; index < group_->max_vertex_attribs(); index += 16) {
uint32_t shader_attrib_written_mask = uint32_t shader_attrib_written_mask =
state_.current_program->vertex_input_type_written_mask(index); state_.current_program->vertex_input_type_written_mask(index);
uint32_t vao_attrib_written_mask = uint32_t vao_attrib_enabled_mask =
state_.vertex_attrib_manager->attrib_type_written_mask(index); state_.vertex_attrib_manager->attrib_enabled_mask(index);
uint32_t vertex_attrib_base_type_mask = uint32_t vertex_attrib_base_type_mask =
(~vao_attrib_written_mask & (~vao_attrib_enabled_mask &
state_.GetGenericVertexAttribBaseTypeMask(index)) | state_.GetGenericVertexAttribBaseTypeMask(index)) |
(vao_attrib_written_mask & (vao_attrib_enabled_mask &
state_.vertex_attrib_manager->attrib_base_type_mask(index)); state_.vertex_attrib_manager->attrib_base_type_mask(index));
if ((state_.current_program->vertex_input_base_type_mask(index) if ((state_.current_program->vertex_input_base_type_mask(index)
& shader_attrib_written_mask) != & shader_attrib_written_mask) !=
......
...@@ -131,10 +131,10 @@ void VertexAttribManager::Initialize(uint32_t max_vertex_attribs, ...@@ -131,10 +131,10 @@ void VertexAttribManager::Initialize(uint32_t max_vertex_attribs,
uint32_t packed_size = max_vertex_attribs_ / 16; uint32_t packed_size = max_vertex_attribs_ / 16;
packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1; packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1;
attrib_base_type_mask_.resize(packed_size); attrib_base_type_mask_.resize(packed_size);
attrib_type_written_mask_.resize(packed_size); attrib_enabled_mask_.resize(packed_size);
for (uint32_t ii = 0; ii < packed_size; ++ii) { for (uint32_t ii = 0; ii < packed_size; ++ii) {
attrib_type_written_mask_[ii] = 0u; attrib_enabled_mask_[ii] = 0u;
attrib_base_type_mask_[ii] = 0u; attrib_base_type_mask_[ii] = 0u;
} }
...@@ -160,9 +160,9 @@ bool VertexAttribManager::Enable(GLuint index, bool enable) { ...@@ -160,9 +160,9 @@ bool VertexAttribManager::Enable(GLuint index, bool enable) {
DCHECK(index < max_vertex_attribs_); DCHECK(index < max_vertex_attribs_);
GLuint shift_bits = (index % 16) * 2; GLuint shift_bits = (index % 16) * 2;
if (enable) { if (enable) {
attrib_type_written_mask_[index / 16] |= (0x3 << shift_bits); attrib_enabled_mask_[index / 16] |= (0x3 << shift_bits);
} else { } else {
attrib_type_written_mask_[index / 16] &= ~(0x3 << shift_bits); attrib_enabled_mask_[index / 16] &= ~(0x3 << shift_bits);
} }
VertexAttrib& info = vertex_attribs_[index]; VertexAttrib& info = vertex_attribs_[index];
......
...@@ -203,7 +203,7 @@ class GPU_EXPORT VertexAttribManager : ...@@ -203,7 +203,7 @@ class GPU_EXPORT VertexAttribManager :
void UpdateAttribBaseTypeAndMask(GLuint loc, GLenum base_type) { void UpdateAttribBaseTypeAndMask(GLuint loc, GLenum base_type) {
DCHECK(loc < max_vertex_attribs_); DCHECK(loc < max_vertex_attribs_);
int shift_bits = (loc % 16) * 2; int shift_bits = (loc % 16) * 2;
attrib_type_written_mask_[loc / 16] |= (0x3 << shift_bits); attrib_enabled_mask_[loc / 16] |= (0x3 << shift_bits);
attrib_base_type_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; attrib_base_type_mask_[loc / 16] |= base_type << shift_bits;
} }
...@@ -217,9 +217,9 @@ class GPU_EXPORT VertexAttribManager : ...@@ -217,9 +217,9 @@ class GPU_EXPORT VertexAttribManager :
// Return 16 attributes' type written masks, in which the // Return 16 attributes' type written masks, in which the
// attribute specified by argument 'loc' located. // attribute specified by argument 'loc' located.
uint32_t attrib_type_written_mask(GLuint loc) const { uint32_t attrib_enabled_mask(GLuint loc) const {
DCHECK(loc < max_vertex_attribs_); DCHECK(loc < max_vertex_attribs_);
return attrib_type_written_mask_[loc / 16]; return attrib_enabled_mask_[loc / 16];
} }
void SetAttribInfo( void SetAttribInfo(
...@@ -311,9 +311,10 @@ class GPU_EXPORT VertexAttribManager : ...@@ -311,9 +311,10 @@ class GPU_EXPORT VertexAttribManager :
// Each base type is encoded into 2 bits, the lowest 2 bits for location 0, // 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). // the highest 2 bits for location (max_vertex_attribs_ - 1).
std::vector<uint32_t> attrib_base_type_mask_; std::vector<uint32_t> attrib_base_type_mask_;
// Same layout as above, 2 bits per location, 0x03 if a location is set // Same layout as above, 2 bits per location, 0x03 if a location for an
// by vertexAttrib API, 0x00 if not. // vertex attrib is enabled by enabbleVertexAttribArray, 0x00 if it is
std::vector<uint32_t> attrib_type_written_mask_; // disabled by disableVertexAttribArray. Every location is 0x00 by default.
std::vector<uint32_t> attrib_enabled_mask_;
// The currently bound element array buffer. If this is 0 it is illegal // The currently bound element array buffer. If this is 0 it is illegal
// to call glDrawElements. // to call glDrawElements.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment