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 7ecd8d5f47bf07b2f1410eb945e5d1295423c7b6..4275de555250a399115b6ed041cf329ee81b3640 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -6236,12 +6236,24 @@ void GLES2DecoderImpl::DoFramebufferRenderbuffer( |
| void GLES2DecoderImpl::DoDisable(GLenum cap) { |
| if (SetCapabilityState(cap, false)) { |
| + if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && |
| + feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { |
| + // Enable and Disable PRIMITIVE_RESTART only before and after |
| + // DrawElements* for old desktop GL. |
| + return; |
| + } |
| glDisable(cap); |
| } |
| } |
| void GLES2DecoderImpl::DoEnable(GLenum cap) { |
| if (SetCapabilityState(cap, true)) { |
| + if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && |
| + feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { |
| + // Enable and Disable PRIMITIVE_RESTART only before and after |
| + // DrawElements* for old desktop GL. |
| + return; |
| + } |
| glEnable(cap); |
| } |
| } |
| @@ -8265,9 +8277,6 @@ error::Error GLES2DecoderImpl::DoDrawArrays( |
| error::Error GLES2DecoderImpl::HandleDrawArrays(uint32_t immediate_data_size, |
| const void* cmd_data) { |
| - // TODO(zmo): crbug.com/481184 |
| - // On Desktop GL with versions lower than 4.3, we need to emulate |
| - // GL_PRIMITIVE_RESTART_FIXED_INDEX using glPrimitiveRestartIndex(). |
| const cmds::DrawArrays& c = *static_cast<const cmds::DrawArrays*>(cmd_data); |
| return DoDrawArrays("glDrawArrays", |
| false, |
| @@ -8343,7 +8352,9 @@ error::Error GLES2DecoderImpl::DoDrawElements(const char* function_name, |
| state_.vertex_attrib_manager->element_array_buffer(); |
| if (!element_array_buffer->GetMaxValueForRange( |
| - offset, count, type, &max_vertex_accessed)) { |
| + offset, count, type, |
| + state_.enable_flags.primitive_restart_fixed_index, |
| + &max_vertex_accessed)) { |
| LOCAL_SET_GL_ERROR( |
| GL_INVALID_OPERATION, function_name, "range out of bounds for buffer"); |
| return error::kNoError; |
| @@ -8375,12 +8386,23 @@ error::Error GLES2DecoderImpl::DoDrawElements(const char* function_name, |
| indices = element_array_buffer->GetRange(offset, 0); |
| } |
| + if (state_.enable_flags.primitive_restart_fixed_index && |
| + feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { |
|
Zhenyao Mo
2016/03/25 17:24:29
nit: this is beyond 80 characters.
yunchao
2016/03/30 08:25:22
Done.
|
| + glEnable(GL_PRIMITIVE_RESTART); |
| + buffer_manager()->SetPrimitiveRestartFixedIndexIfNecessary(type); |
| + } |
| + |
| if (!instanced) { |
| glDrawElements(mode, count, type, indices); |
| } else { |
| glDrawElementsInstancedANGLE(mode, count, type, indices, primcount); |
| } |
| + if (state_.enable_flags.primitive_restart_fixed_index && |
| + feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { |
|
Zhenyao Mo
2016/03/25 17:24:29
nit: this is beyond 80 characters.
yunchao
2016/03/30 08:25:22
Done.
|
| + glDisable(GL_PRIMITIVE_RESTART); |
| + } |
| + |
| if (used_client_side_array) { |
| glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, |
| element_array_buffer->service_id()); |
| @@ -8406,9 +8428,6 @@ error::Error GLES2DecoderImpl::DoDrawElements(const char* function_name, |
| error::Error GLES2DecoderImpl::HandleDrawElements(uint32_t immediate_data_size, |
| const void* cmd_data) { |
| - // TODO(zmo): crbug.com/481184 |
| - // On Desktop GL with versions lower than 4.3, we need to emulate |
| - // GL_PRIMITIVE_RESTART_FIXED_INDEX using glPrimitiveRestartIndex(). |
| const gles2::cmds::DrawElements& c = |
| *static_cast<const gles2::cmds::DrawElements*>(cmd_data); |
| return DoDrawElements("glDrawElements", false, static_cast<GLenum>(c.mode), |
| @@ -8440,8 +8459,18 @@ GLuint GLES2DecoderImpl::DoGetMaxValueInBufferCHROMIUM( |
| LOCAL_SET_GL_ERROR( |
| GL_INVALID_VALUE, "GetMaxValueInBufferCHROMIUM", "unknown buffer"); |
| } else { |
| + // The max value is used here to emulate client-side vertex |
| + // arrays, by uploading enough vertices into buffer objects to |
| + // cover the DrawElements call. Baking the primitive restart bit |
| + // into this result isn't strictly correct in all cases; the |
| + // client side code should pass down the bit and decide how to use |
| + // the result. However, the only caller makes the draw call |
| + // immediately afterward, so the state won't change between this |
| + // query and the draw call. |
| if (!buffer->GetMaxValueForRange( |
| - offset, count, type, &max_vertex_accessed)) { |
| + offset, count, type, |
| + state_.enable_flags.primitive_restart_fixed_index, |
| + &max_vertex_accessed)) { |
| // TODO(gman): Should this be a GL error or a command buffer error? |
| LOCAL_SET_GL_ERROR( |
| GL_INVALID_OPERATION, |