Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, | 753 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, |
| 754 uint32 sync_data_shm_id, | 754 uint32 sync_data_shm_id, |
| 755 uint32 sync_data_shm_offset); | 755 uint32 sync_data_shm_offset); |
| 756 | 756 |
| 757 | 757 |
| 758 | 758 |
| 759 // Workarounds | 759 // Workarounds |
| 760 void OnFboChanged() const; | 760 void OnFboChanged() const; |
| 761 void OnUseFramebuffer() const; | 761 void OnUseFramebuffer() const; |
| 762 | 762 |
| 763 error::ContextLostReason GetContextLostReasonFromResetStatus( | |
| 764 GLenum reset_status) const; | |
| 765 | |
| 763 // TODO(gman): Cache these pointers? | 766 // TODO(gman): Cache these pointers? |
| 764 BufferManager* buffer_manager() { | 767 BufferManager* buffer_manager() { |
| 765 return group_->buffer_manager(); | 768 return group_->buffer_manager(); |
| 766 } | 769 } |
| 767 | 770 |
| 768 RenderbufferManager* renderbuffer_manager() { | 771 RenderbufferManager* renderbuffer_manager() { |
| 769 return group_->renderbuffer_manager(); | 772 return group_->renderbuffer_manager(); |
| 770 } | 773 } |
| 771 | 774 |
| 772 FramebufferManager* framebuffer_manager() { | 775 FramebufferManager* framebuffer_manager() { |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1648 uint32 shm_id, | 1651 uint32 shm_id, |
| 1649 uint32 shm_offset, | 1652 uint32 shm_offset, |
| 1650 error::Error* error, | 1653 error::Error* error, |
| 1651 GLint* real_location, | 1654 GLint* real_location, |
| 1652 GLuint* service_id, | 1655 GLuint* service_id, |
| 1653 void** result, | 1656 void** result, |
| 1654 GLenum* result_type, | 1657 GLenum* result_type, |
| 1655 GLsizei* result_size); | 1658 GLsizei* result_size); |
| 1656 | 1659 |
| 1657 void MaybeExitOnContextLost(); | 1660 void MaybeExitOnContextLost(); |
| 1658 bool WasContextLost() override; | 1661 bool WasContextLost() const override; |
| 1659 bool WasContextLostByRobustnessExtension() override; | 1662 bool WasContextLostByRobustnessExtension() const override; |
| 1660 void LoseContext(uint32 reset_status) override; | 1663 void MarkContextLost(error::ContextLostReason reason) override; |
| 1664 bool CheckResetStatus(); | |
| 1661 | 1665 |
| 1662 #if defined(OS_MACOSX) | 1666 #if defined(OS_MACOSX) |
| 1663 void ReleaseIOSurfaceForTexture(GLuint texture_id); | 1667 void ReleaseIOSurfaceForTexture(GLuint texture_id); |
| 1664 #endif | 1668 #endif |
| 1665 | 1669 |
| 1666 bool ValidateCompressedTexDimensions( | 1670 bool ValidateCompressedTexDimensions( |
| 1667 const char* function_name, | 1671 const char* function_name, |
| 1668 GLint level, GLsizei width, GLsizei height, GLenum format); | 1672 GLint level, GLsizei width, GLsizei height, GLenum format); |
| 1669 bool ValidateCompressedTexFuncData( | 1673 bool ValidateCompressedTexFuncData( |
| 1670 const char* function_name, | 1674 const char* function_name, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1853 // Cached from ContextGroup | 1857 // Cached from ContextGroup |
| 1854 const Validators* validators_; | 1858 const Validators* validators_; |
| 1855 scoped_refptr<FeatureInfo> feature_info_; | 1859 scoped_refptr<FeatureInfo> feature_info_; |
| 1856 | 1860 |
| 1857 int frame_number_; | 1861 int frame_number_; |
| 1858 | 1862 |
| 1859 // Number of commands remaining to be processed in DoCommands(). | 1863 // Number of commands remaining to be processed in DoCommands(). |
| 1860 int commands_to_process_; | 1864 int commands_to_process_; |
| 1861 | 1865 |
| 1862 bool has_robustness_extension_; | 1866 bool has_robustness_extension_; |
| 1863 GLenum reset_status_; | 1867 error::ContextLostReason context_lost_reason_; |
| 1868 bool context_was_lost_; | |
| 1864 bool reset_by_robustness_extension_; | 1869 bool reset_by_robustness_extension_; |
| 1865 bool supports_post_sub_buffer_; | 1870 bool supports_post_sub_buffer_; |
| 1866 | 1871 |
| 1867 // These flags are used to override the state of the shared feature_info_ | 1872 // These flags are used to override the state of the shared feature_info_ |
| 1868 // member. Because the same FeatureInfo instance may be shared among many | 1873 // member. Because the same FeatureInfo instance may be shared among many |
| 1869 // contexts, the assumptions on the availablity of extensions in WebGL | 1874 // contexts, the assumptions on the availablity of extensions in WebGL |
| 1870 // contexts may be broken. These flags override the shared state to preserve | 1875 // contexts may be broken. These flags override the shared state to preserve |
| 1871 // WebGL semantics. | 1876 // WebGL semantics. |
| 1872 bool force_webgl_glsl_validation_; | 1877 bool force_webgl_glsl_validation_; |
| 1873 bool derivatives_explicitly_enabled_; | 1878 bool derivatives_explicitly_enabled_; |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2395 back_buffer_has_depth_(false), | 2400 back_buffer_has_depth_(false), |
| 2396 back_buffer_has_stencil_(false), | 2401 back_buffer_has_stencil_(false), |
| 2397 surfaceless_(false), | 2402 surfaceless_(false), |
| 2398 backbuffer_needs_clear_bits_(0), | 2403 backbuffer_needs_clear_bits_(0), |
| 2399 current_decoder_error_(error::kNoError), | 2404 current_decoder_error_(error::kNoError), |
| 2400 use_shader_translator_(true), | 2405 use_shader_translator_(true), |
| 2401 validators_(group_->feature_info()->validators()), | 2406 validators_(group_->feature_info()->validators()), |
| 2402 feature_info_(group_->feature_info()), | 2407 feature_info_(group_->feature_info()), |
| 2403 frame_number_(0), | 2408 frame_number_(0), |
| 2404 has_robustness_extension_(false), | 2409 has_robustness_extension_(false), |
| 2405 reset_status_(GL_NO_ERROR), | 2410 context_lost_reason_(error::kUnknown), |
| 2411 context_was_lost_(false), | |
| 2406 reset_by_robustness_extension_(false), | 2412 reset_by_robustness_extension_(false), |
| 2407 supports_post_sub_buffer_(false), | 2413 supports_post_sub_buffer_(false), |
| 2408 force_webgl_glsl_validation_(false), | 2414 force_webgl_glsl_validation_(false), |
| 2409 derivatives_explicitly_enabled_(false), | 2415 derivatives_explicitly_enabled_(false), |
| 2410 frag_depth_explicitly_enabled_(false), | 2416 frag_depth_explicitly_enabled_(false), |
| 2411 draw_buffers_explicitly_enabled_(false), | 2417 draw_buffers_explicitly_enabled_(false), |
| 2412 shader_texture_lod_explicitly_enabled_(false), | 2418 shader_texture_lod_explicitly_enabled_(false), |
| 2413 compile_shader_always_succeeds_(false), | 2419 compile_shader_always_succeeds_(false), |
| 2414 lose_context_when_out_of_memory_(false), | 2420 lose_context_when_out_of_memory_(false), |
| 2415 service_logging_(base::CommandLine::ForCurrentProcess()->HasSwitch( | 2421 service_logging_(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3317 } | 3323 } |
| 3318 } | 3324 } |
| 3319 } | 3325 } |
| 3320 | 3326 |
| 3321 // } // anonymous namespace | 3327 // } // anonymous namespace |
| 3322 | 3328 |
| 3323 bool GLES2DecoderImpl::MakeCurrent() { | 3329 bool GLES2DecoderImpl::MakeCurrent() { |
| 3324 if (!context_.get()) | 3330 if (!context_.get()) |
| 3325 return false; | 3331 return false; |
| 3326 | 3332 |
| 3327 if (!context_->MakeCurrent(surface_.get()) || WasContextLost()) { | 3333 if (WasContextLost()) { |
| 3328 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | 3334 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
| 3329 | |
| 3330 MaybeExitOnContextLost(); | |
| 3331 | |
| 3332 return false; | 3335 return false; |
| 3333 } | 3336 } |
| 3334 | 3337 |
| 3338 if (!context_->MakeCurrent(surface_.get())) { | |
| 3339 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | |
| 3340 MarkContextLost(error::kMakeCurrentFailed); | |
| 3341 MaybeExitOnContextLost(); | |
| 3342 return false; | |
| 3343 } | |
| 3344 | |
| 3345 if (CheckResetStatus()) { | |
|
piman
2015/04/18 01:03:18
Do we really want to check this on every MakeCurre
Ken Russell (switch to Gerrit)
2015/04/24 02:39:41
Actually, I think it was already being done in Was
no sievers
2015/04/24 18:52:47
We might also want to check it proactively here fo
| |
| 3346 LOG(ERROR) | |
| 3347 << " GLES2DecoderImpl: Context reset detected after MakeCurrent."; | |
| 3348 return false; | |
| 3349 } | |
| 3350 | |
| 3335 ProcessFinishedAsyncTransfers(); | 3351 ProcessFinishedAsyncTransfers(); |
| 3336 | 3352 |
| 3337 // Rebind the FBO if it was unbound by the context. | 3353 // Rebind the FBO if it was unbound by the context. |
| 3338 if (workarounds().unbind_fbo_on_context_switch) | 3354 if (workarounds().unbind_fbo_on_context_switch) |
| 3339 RestoreFramebufferBindings(); | 3355 RestoreFramebufferBindings(); |
| 3340 | 3356 |
| 3341 framebuffer_state_.clear_state_dirty = true; | 3357 framebuffer_state_.clear_state_dirty = true; |
| 3342 | 3358 |
| 3343 return true; | 3359 return true; |
| 3344 } | 3360 } |
| (...skipping 6944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10289 offscreen_saved_color_texture_->AllocateStorage( | 10305 offscreen_saved_color_texture_->AllocateStorage( |
| 10290 offscreen_size_, offscreen_saved_color_format_, false); | 10306 offscreen_size_, offscreen_saved_color_format_, false); |
| 10291 | 10307 |
| 10292 offscreen_saved_frame_buffer_->AttachRenderTexture( | 10308 offscreen_saved_frame_buffer_->AttachRenderTexture( |
| 10293 offscreen_saved_color_texture_.get()); | 10309 offscreen_saved_color_texture_.get()); |
| 10294 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { | 10310 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { |
| 10295 if (offscreen_saved_frame_buffer_->CheckStatus() != | 10311 if (offscreen_saved_frame_buffer_->CheckStatus() != |
| 10296 GL_FRAMEBUFFER_COMPLETE) { | 10312 GL_FRAMEBUFFER_COMPLETE) { |
| 10297 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 10313 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
| 10298 << "because offscreen saved FBO was incomplete."; | 10314 << "because offscreen saved FBO was incomplete."; |
| 10299 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10315 MarkContextLost(error::kUnknown); |
|
piman
2015/04/18 01:03:18
Here, and other places we call MarkContextLost, we
| |
| 10300 return; | 10316 return; |
| 10301 } | 10317 } |
| 10302 | 10318 |
| 10303 // Clear the offscreen color texture. | 10319 // Clear the offscreen color texture. |
| 10304 // TODO(piman): Is this still necessary? | 10320 // TODO(piman): Is this still necessary? |
| 10305 { | 10321 { |
| 10306 ScopedFrameBufferBinder binder(this, | 10322 ScopedFrameBufferBinder binder(this, |
| 10307 offscreen_saved_frame_buffer_->id()); | 10323 offscreen_saved_frame_buffer_->id()); |
| 10308 glClearColor(0, 0, 0, 0); | 10324 glClearColor(0, 0, 0, 0); |
| 10309 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 10325 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10346 | 10362 |
| 10347 // Ensure the side effects of the copy are visible to the parent | 10363 // Ensure the side effects of the copy are visible to the parent |
| 10348 // context. There is no need to do this for ANGLE because it uses a | 10364 // context. There is no need to do this for ANGLE because it uses a |
| 10349 // single D3D device for all contexts. | 10365 // single D3D device for all contexts. |
| 10350 if (!feature_info_->gl_version_info().is_angle) | 10366 if (!feature_info_->gl_version_info().is_angle) |
| 10351 glFlush(); | 10367 glFlush(); |
| 10352 } | 10368 } |
| 10353 } else { | 10369 } else { |
| 10354 if (!surface_->SwapBuffers()) { | 10370 if (!surface_->SwapBuffers()) { |
| 10355 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 10371 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
| 10356 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10372 if (!CheckResetStatus()) |
| 10373 MarkContextLost(error::kUnknown); | |
| 10357 } | 10374 } |
| 10358 } | 10375 } |
| 10359 | 10376 |
| 10360 // This may be a slow command. Exit command processing to allow for | 10377 // This may be a slow command. Exit command processing to allow for |
| 10361 // context preemption and GPU watchdog checks. | 10378 // context preemption and GPU watchdog checks. |
| 10362 ExitCommandProcessingEarly(); | 10379 ExitCommandProcessingEarly(); |
| 10363 } | 10380 } |
| 10364 | 10381 |
| 10365 void GLES2DecoderImpl::DoSwapInterval(int interval) { | 10382 void GLES2DecoderImpl::DoSwapInterval(int interval) { |
| 10366 context_->SetSwapInterval(interval); | 10383 context_->SetSwapInterval(interval); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10606 Program* program = NULL; | 10623 Program* program = NULL; |
| 10607 program = GetProgram(program_id); | 10624 program = GetProgram(program_id); |
| 10608 if (!program || !program->IsValid()) { | 10625 if (!program || !program->IsValid()) { |
| 10609 return error::kNoError; | 10626 return error::kNoError; |
| 10610 } | 10627 } |
| 10611 program->GetTransformFeedbackVaryings(bucket); | 10628 program->GetTransformFeedbackVaryings(bucket); |
| 10612 return error::kNoError; | 10629 return error::kNoError; |
| 10613 } | 10630 } |
| 10614 | 10631 |
| 10615 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { | 10632 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { |
| 10616 switch (reset_status_) { | 10633 return context_lost_reason_; |
| 10634 } | |
| 10635 | |
| 10636 error::ContextLostReason GLES2DecoderImpl::GetContextLostReasonFromResetStatus( | |
| 10637 GLenum reset_status) const { | |
| 10638 switch (reset_status) { | |
| 10617 case GL_NO_ERROR: | 10639 case GL_NO_ERROR: |
| 10618 // TODO(kbr): improve the precision of the error code in this case. | 10640 // TODO(kbr): improve the precision of the error code in this case. |
| 10619 // Consider delegating to context for error code if MakeCurrent fails. | 10641 // Consider delegating to context for error code if MakeCurrent fails. |
| 10620 return error::kUnknown; | 10642 return error::kUnknown; |
| 10621 case GL_GUILTY_CONTEXT_RESET_ARB: | 10643 case GL_GUILTY_CONTEXT_RESET_ARB: |
| 10622 return error::kGuilty; | 10644 return error::kGuilty; |
| 10623 case GL_INNOCENT_CONTEXT_RESET_ARB: | 10645 case GL_INNOCENT_CONTEXT_RESET_ARB: |
| 10624 return error::kInnocent; | 10646 return error::kInnocent; |
| 10625 case GL_UNKNOWN_CONTEXT_RESET_ARB: | 10647 case GL_UNKNOWN_CONTEXT_RESET_ARB: |
| 10626 return error::kUnknown; | 10648 return error::kUnknown; |
| 10627 } | 10649 } |
| 10628 | 10650 |
| 10629 NOTREACHED(); | 10651 NOTREACHED(); |
| 10630 return error::kUnknown; | 10652 return error::kUnknown; |
| 10631 } | 10653 } |
| 10632 | 10654 |
| 10633 void GLES2DecoderImpl::MaybeExitOnContextLost() { | 10655 void GLES2DecoderImpl::MaybeExitOnContextLost() { |
| 10634 // Some D3D drivers cannot recover from device lost in the GPU process | 10656 // Some D3D drivers cannot recover from device lost in the GPU process |
| 10635 // sandbox. Allow a new GPU process to launch. | 10657 // sandbox. Allow a new GPU process to launch. |
| 10636 if (workarounds().exit_on_context_lost) { | 10658 if (workarounds().exit_on_context_lost) { |
| 10637 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" | 10659 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" |
| 10638 << " a D3D device in the Chrome GPU process sandbox."; | 10660 << " a D3D device in the Chrome GPU process sandbox."; |
| 10639 #if defined(OS_WIN) | 10661 #if defined(OS_WIN) |
| 10640 base::win::SetShouldCrashOnProcessDetach(false); | 10662 base::win::SetShouldCrashOnProcessDetach(false); |
| 10641 #endif | 10663 #endif |
| 10642 exit(0); | 10664 exit(0); |
| 10643 } | 10665 } |
| 10644 } | 10666 } |
| 10645 | 10667 |
| 10646 bool GLES2DecoderImpl::WasContextLost() { | 10668 bool GLES2DecoderImpl::WasContextLost() const { |
| 10647 if (reset_status_ != GL_NO_ERROR) { | 10669 return context_was_lost_; |
| 10648 MaybeExitOnContextLost(); | 10670 } |
| 10671 | |
| 10672 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() const { | |
| 10673 return WasContextLost() && reset_by_robustness_extension_; | |
| 10674 } | |
| 10675 | |
| 10676 void GLES2DecoderImpl::MarkContextLost(error::ContextLostReason reason) { | |
| 10677 // Only lose the context once. | |
| 10678 if (WasContextLost()) | |
| 10679 return; | |
| 10680 | |
| 10681 // Don't make GL calls in here, the context might not be current. | |
| 10682 context_lost_reason_ = reason; | |
| 10683 current_decoder_error_ = error::kLostContext; | |
| 10684 context_was_lost_ = true; | |
| 10685 MaybeExitOnContextLost(); | |
| 10686 } | |
| 10687 | |
| 10688 bool GLES2DecoderImpl::CheckResetStatus() { | |
| 10689 DCHECK(!WasContextLost()); | |
| 10690 DCHECK(context_->IsCurrent(NULL)); | |
| 10691 | |
| 10692 if (IsRobustnessSupported()) { | |
| 10693 // If the reason for the call was a GL error, we can try to determine the | |
| 10694 // reset status more accurately. | |
| 10695 GLenum driver_status = glGetGraphicsResetStatusARB(); | |
| 10696 if (driver_status == GL_NO_ERROR) | |
| 10697 return false; | |
| 10698 | |
| 10699 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") | |
| 10700 << " context lost via ARB/EXT_robustness. Reset status = " | |
| 10701 << GLES2Util::GetStringEnum(driver_status); | |
| 10702 | |
| 10703 // Don't pretend we know which client was responsible. | |
| 10704 if (workarounds().use_virtualized_gl_contexts) | |
| 10705 driver_status = GL_UNKNOWN_CONTEXT_RESET_ARB; | |
| 10706 | |
| 10707 switch (driver_status) { | |
| 10708 case GL_GUILTY_CONTEXT_RESET_ARB: | |
| 10709 MarkContextLost(error::kGuilty); | |
| 10710 break; | |
| 10711 case GL_INNOCENT_CONTEXT_RESET_ARB: | |
| 10712 MarkContextLost(error::kInnocent); | |
| 10713 break; | |
| 10714 case GL_UNKNOWN_CONTEXT_RESET_ARB: | |
| 10715 MarkContextLost(error::kUnknown); | |
| 10716 break; | |
| 10717 default: | |
| 10718 NOTREACHED(); | |
| 10719 return false; | |
| 10720 } | |
| 10721 reset_by_robustness_extension_ = true; | |
| 10649 return true; | 10722 return true; |
| 10650 } | 10723 } |
| 10651 if (IsRobustnessSupported()) { | |
| 10652 GLenum status = glGetGraphicsResetStatusARB(); | |
| 10653 if (status != GL_NO_ERROR) { | |
| 10654 // The graphics card was reset. Signal a lost context to the application. | |
| 10655 reset_status_ = status; | |
| 10656 reset_by_robustness_extension_ = true; | |
| 10657 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") | |
| 10658 << " context lost via ARB/EXT_robustness. Reset status = " | |
| 10659 << GLES2Util::GetStringEnum(status); | |
| 10660 MaybeExitOnContextLost(); | |
| 10661 return true; | |
| 10662 } | |
| 10663 } | |
| 10664 return false; | 10724 return false; |
| 10665 } | 10725 } |
| 10666 | 10726 |
| 10667 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() { | |
| 10668 return WasContextLost() && reset_by_robustness_extension_; | |
| 10669 } | |
| 10670 | |
| 10671 void GLES2DecoderImpl::LoseContext(uint32 reset_status) { | |
| 10672 // Only loses the context once. | |
| 10673 if (reset_status_ != GL_NO_ERROR) { | |
| 10674 return; | |
| 10675 } | |
| 10676 | |
| 10677 if (workarounds().use_virtualized_gl_contexts) { | |
| 10678 // If the context is virtual, the real context being guilty does not ensure | |
| 10679 // that the virtual context is guilty. | |
| 10680 if (reset_status == GL_GUILTY_CONTEXT_RESET_ARB) { | |
| 10681 reset_status = GL_UNKNOWN_CONTEXT_RESET_ARB; | |
| 10682 } | |
| 10683 } else if (reset_status == GL_UNKNOWN_CONTEXT_RESET_ARB && | |
| 10684 IsRobustnessSupported()) { | |
| 10685 // If the reason for the call was a GL error, we can try to determine the | |
| 10686 // reset status more accurately. | |
| 10687 GLenum driver_status = glGetGraphicsResetStatusARB(); | |
| 10688 if (driver_status == GL_GUILTY_CONTEXT_RESET_ARB || | |
| 10689 driver_status == GL_INNOCENT_CONTEXT_RESET_ARB) { | |
| 10690 reset_status = driver_status; | |
| 10691 } | |
| 10692 } | |
| 10693 | |
| 10694 // Marks this context as lost. | |
| 10695 reset_status_ = reset_status; | |
| 10696 current_decoder_error_ = error::kLostContext; | |
| 10697 } | |
| 10698 | |
| 10699 error::Error GLES2DecoderImpl::HandleInsertSyncPointCHROMIUM( | 10727 error::Error GLES2DecoderImpl::HandleInsertSyncPointCHROMIUM( |
| 10700 uint32 immediate_data_size, | 10728 uint32 immediate_data_size, |
| 10701 const void* cmd_data) { | 10729 const void* cmd_data) { |
| 10702 return error::kUnknownCommand; | 10730 return error::kUnknownCommand; |
| 10703 } | 10731 } |
| 10704 | 10732 |
| 10705 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM( | 10733 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM( |
| 10706 uint32 immediate_data_size, | 10734 uint32 immediate_data_size, |
| 10707 const void* cmd_data) { | 10735 const void* cmd_data) { |
| 10708 const gles2::cmds::WaitSyncPointCHROMIUM& c = | 10736 const gles2::cmds::WaitSyncPointCHROMIUM& c = |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12062 if (GetBackbufferServiceId() != 0 && // emulated backbuffer | 12090 if (GetBackbufferServiceId() != 0 && // emulated backbuffer |
| 12063 bufs[0] == GL_BACK) { | 12091 bufs[0] == GL_BACK) { |
| 12064 mapped_buf = GL_COLOR_ATTACHMENT0; | 12092 mapped_buf = GL_COLOR_ATTACHMENT0; |
| 12065 } | 12093 } |
| 12066 glDrawBuffersARB(count, &mapped_buf); | 12094 glDrawBuffersARB(count, &mapped_buf); |
| 12067 group_->set_draw_buffer(bufs[0]); | 12095 group_->set_draw_buffer(bufs[0]); |
| 12068 } | 12096 } |
| 12069 } | 12097 } |
| 12070 | 12098 |
| 12071 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { | 12099 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { |
| 12072 group_->LoseContexts(other); | 12100 MarkContextLost(GetContextLostReasonFromResetStatus(current)); |
| 12073 reset_status_ = current; | 12101 group_->LoseContexts(GetContextLostReasonFromResetStatus(other)); |
| 12074 current_decoder_error_ = error::kLostContext; | 12102 reset_by_robustness_extension_ = true; |
| 12075 } | 12103 } |
| 12076 | 12104 |
| 12077 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, | 12105 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, |
| 12078 const GLfloat* matrix) { | 12106 const GLfloat* matrix) { |
| 12079 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || | 12107 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || |
| 12080 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); | 12108 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); |
| 12081 if (!features().chromium_path_rendering) { | 12109 if (!features().chromium_path_rendering) { |
| 12082 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 12110 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
| 12083 "glMatrixLoadfCHROMIUM", | 12111 "glMatrixLoadfCHROMIUM", |
| 12084 "function not available"); | 12112 "function not available"); |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12582 } | 12610 } |
| 12583 buffer->RemoveMappedRange(); | 12611 buffer->RemoveMappedRange(); |
| 12584 GLboolean rt = glUnmapBuffer(target); | 12612 GLboolean rt = glUnmapBuffer(target); |
| 12585 if (rt == GL_FALSE) { | 12613 if (rt == GL_FALSE) { |
| 12586 // At this point, we have already done the necessary validation, so | 12614 // At this point, we have already done the necessary validation, so |
| 12587 // GL_FALSE indicates data corruption. | 12615 // GL_FALSE indicates data corruption. |
| 12588 // TODO(zmo): We could redo the map / copy data / unmap to recover, but | 12616 // TODO(zmo): We could redo the map / copy data / unmap to recover, but |
| 12589 // the second unmap could still return GL_FALSE. For now, we simply lose | 12617 // the second unmap could still return GL_FALSE. For now, we simply lose |
| 12590 // the contexts in the share group. | 12618 // the contexts in the share group. |
| 12591 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; | 12619 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; |
| 12592 group_->LoseContexts(GL_INNOCENT_CONTEXT_RESET_ARB); | 12620 // Need to lose current context before broadcasting! |
| 12593 reset_status_ = GL_GUILTY_CONTEXT_RESET_ARB; | 12621 MarkContextLost(error::kGuilty); |
| 12622 group_->LoseContexts(error::kInnocent); | |
| 12594 return error::kLostContext; | 12623 return error::kLostContext; |
| 12595 } | 12624 } |
| 12596 return error::kNoError; | 12625 return error::kNoError; |
| 12597 } | 12626 } |
| 12598 | 12627 |
| 12599 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( | 12628 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( |
| 12600 TextureRef* texture_ref) { | 12629 TextureRef* texture_ref) { |
| 12601 Texture* texture = texture_ref->texture(); | 12630 Texture* texture = texture_ref->texture(); |
| 12602 DoDidUseTexImageIfNeeded(texture, texture->target()); | 12631 DoDidUseTexImageIfNeeded(texture, texture->target()); |
| 12603 } | 12632 } |
| 12604 | 12633 |
| 12605 void GLES2DecoderImpl::OnContextLostError() { | 12634 void GLES2DecoderImpl::OnContextLostError() { |
| 12606 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12635 if (!WasContextLost()) { |
| 12636 // Need to lose current context before broadcasting! | |
| 12637 CheckResetStatus(); | |
| 12638 group_->LoseContexts(error::kUnknown); | |
| 12639 reset_by_robustness_extension_ = true; | |
| 12640 } | |
| 12607 } | 12641 } |
| 12608 | 12642 |
| 12609 void GLES2DecoderImpl::OnOutOfMemoryError() { | 12643 void GLES2DecoderImpl::OnOutOfMemoryError() { |
| 12610 if (lose_context_when_out_of_memory_) { | 12644 if (lose_context_when_out_of_memory_ && !WasContextLost()) { |
| 12611 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12645 error::ContextLostReason other = error::kOutOfMemory; |
| 12646 if (CheckResetStatus()) { | |
| 12647 other = error::kUnknown; | |
| 12648 } else { | |
| 12649 // Need to lose current context before broadcasting! | |
| 12650 MarkContextLost(error::kOutOfMemory); | |
| 12651 } | |
| 12652 group_->LoseContexts(other); | |
| 12612 } | 12653 } |
| 12613 } | 12654 } |
| 12614 | 12655 |
| 12615 // Include the auto-generated part of this file. We split this because it means | 12656 // Include the auto-generated part of this file. We split this because it means |
| 12616 // we can easily edit the non-auto generated parts right here in this file | 12657 // we can easily edit the non-auto generated parts right here in this file |
| 12617 // instead of having to edit some template or the code generator. | 12658 // instead of having to edit some template or the code generator. |
| 12618 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12659 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 12619 | 12660 |
| 12620 } // namespace gles2 | 12661 } // namespace gles2 |
| 12621 } // namespace gpu | 12662 } // namespace gpu |
| OLD | NEW |