Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| index f8f29f1b42c6f43a085fb405a4c76e58d3354341..603ee8bb80e572c5c76053e258825798981a8675 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -8699,22 +8699,27 @@ bool GLES2DecoderImpl::ValidateAndAdjustDrawBuffers(const char* func_name) { |
| } |
| bool GLES2DecoderImpl::ValidateUniformBlockBackings(const char* func_name) { |
| - if (feature_info_->IsWebGL1OrES2Context()) { |
| - // Uniform blocks do not exist in ES2 contexts. |
| - return true; |
| - } |
| + DCHECK(feature_info_->IsWebGL1OrES2Context()); |
|
piman
2016/11/01 22:26:39
Did you mean DCHECK(feature_info_->IsWebGL2OrES3Co
Zhenyao Mo
2016/11/01 22:33:40
Right. Thanks for catching this.
Let's see if any
|
| DCHECK(state_.current_program.get()); |
| + int32_t max_index = -1; |
| for (auto info : state_.current_program->uniform_block_size_info()) { |
| - uint32_t buffer_size = static_cast<uint32_t>( |
| - state_.indexed_uniform_buffer_bindings->GetEffectiveBufferSize( |
| - info.binding)); |
| - if (info.data_size > buffer_size) { |
| - LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| - "uniform blocks are not backed by a buffer with sufficient data"); |
| - return false; |
| - } |
| + int32_t index = static_cast<int32_t>(info.binding); |
| + if (index > max_index) |
| + max_index = index; |
| } |
| - return true; |
| + if (max_index < 0) |
| + return true; |
| + std::vector<GLsizeiptr> uniform_block_sizes(max_index + 1); |
| + for (int32_t ii = 0; ii <= max_index; ++ii) |
| + uniform_block_sizes[ii] = 0; |
| + for (auto info : state_.current_program->uniform_block_size_info()) { |
| + uint32_t index = info.binding; |
| + uniform_block_sizes[index] = |
| + state_.indexed_uniform_buffer_bindings->GetEffectiveBufferSize(index); |
| + } |
| + return buffer_manager()->RequestBuffersAccess( |
| + state_.GetErrorState(), state_.indexed_uniform_buffer_bindings.get(), |
| + uniform_block_sizes, 1, func_name, "uniform buffers"); |
| } |
| bool GLES2DecoderImpl::CheckUniformForApiType( |
| @@ -9825,6 +9830,10 @@ error::Error GLES2DecoderImpl::DoDrawArrays( |
| return error::kNoError; |
| } |
| } |
| + |
| + if (!ValidateUniformBlockBackings(function_name)) { |
| + return error::kNoError; |
| + } |
| } |
| if (count == 0 || primcount == 0) { |
| @@ -9861,9 +9870,6 @@ error::Error GLES2DecoderImpl::DoDrawArrays( |
| if (!ValidateAndAdjustDrawBuffers(function_name)) { |
| return error::kNoError; |
| } |
| - if (!ValidateUniformBlockBackings(function_name)) { |
| - return error::kNoError; |
| - } |
| if (!instanced) { |
| glDrawArrays(mode, first, count); |
| } else { |
| @@ -9965,16 +9971,19 @@ error::Error GLES2DecoderImpl::DoDrawElements(const char* function_name, |
| return error::kNoError; |
| } |
| - if (count == 0 || primcount == 0) { |
| - return error::kNoError; |
| - } |
| - |
| if (feature_info_->IsWebGL2OrES3Context()) { |
| if (!AttribsTypeMatch()) { |
| LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| "vertexAttrib function must match shader attrib type"); |
| return error::kNoError; |
| } |
| + if (!ValidateUniformBlockBackings(function_name)) { |
| + return error::kNoError; |
| + } |
| + } |
| + |
| + if (count == 0 || primcount == 0) { |
| + return error::kNoError; |
| } |
| GLuint max_vertex_accessed; |
| @@ -10015,9 +10024,6 @@ error::Error GLES2DecoderImpl::DoDrawElements(const char* function_name, |
| if (!ValidateAndAdjustDrawBuffers(function_name)) { |
| return error::kNoError; |
| } |
| - if (!ValidateUniformBlockBackings(function_name)) { |
| - return error::kNoError; |
| - } |
| if (state_.enable_flags.primitive_restart_fixed_index && |
| feature_info_->feature_flags(). |
| emulate_primitive_restart_fixed_index) { |