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 <cmath> | 10 #include <cmath> |
(...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 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 GLint fake_location, | 1653 GLint fake_location, |
1651 uint32 shm_id, | 1654 uint32 shm_id, |
1652 uint32 shm_offset, | 1655 uint32 shm_offset, |
1653 error::Error* error, | 1656 error::Error* error, |
1654 GLint* real_location, | 1657 GLint* real_location, |
1655 GLuint* service_id, | 1658 GLuint* service_id, |
1656 void** result, | 1659 void** result, |
1657 GLenum* result_type, | 1660 GLenum* result_type, |
1658 GLsizei* result_size); | 1661 GLsizei* result_size); |
1659 | 1662 |
1660 void MaybeExitOnContextLost(); | 1663 bool WasContextLost() const override; |
1661 bool WasContextLost() override; | 1664 bool WasContextLostByRobustnessExtension() const override; |
1662 bool WasContextLostByRobustnessExtension() override; | 1665 void MarkContextLost(error::ContextLostReason reason) override; |
1663 void LoseContext(uint32 reset_status) override; | 1666 bool CheckResetStatus(); |
1664 | 1667 |
1665 #if defined(OS_MACOSX) | 1668 #if defined(OS_MACOSX) |
1666 void ReleaseIOSurfaceForTexture(GLuint texture_id); | 1669 void ReleaseIOSurfaceForTexture(GLuint texture_id); |
1667 #endif | 1670 #endif |
1668 | 1671 |
1669 bool ValidateCompressedTexDimensions( | 1672 bool ValidateCompressedTexDimensions( |
1670 const char* function_name, | 1673 const char* function_name, |
1671 GLint level, GLsizei width, GLsizei height, GLenum format); | 1674 GLint level, GLsizei width, GLsizei height, GLenum format); |
1672 bool ValidateCompressedTexFuncData( | 1675 bool ValidateCompressedTexFuncData( |
1673 const char* function_name, | 1676 const char* function_name, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1856 // Cached from ContextGroup | 1859 // Cached from ContextGroup |
1857 const Validators* validators_; | 1860 const Validators* validators_; |
1858 scoped_refptr<FeatureInfo> feature_info_; | 1861 scoped_refptr<FeatureInfo> feature_info_; |
1859 | 1862 |
1860 int frame_number_; | 1863 int frame_number_; |
1861 | 1864 |
1862 // Number of commands remaining to be processed in DoCommands(). | 1865 // Number of commands remaining to be processed in DoCommands(). |
1863 int commands_to_process_; | 1866 int commands_to_process_; |
1864 | 1867 |
1865 bool has_robustness_extension_; | 1868 bool has_robustness_extension_; |
1866 GLenum reset_status_; | 1869 error::ContextLostReason context_lost_reason_; |
| 1870 bool context_was_lost_; |
1867 bool reset_by_robustness_extension_; | 1871 bool reset_by_robustness_extension_; |
1868 bool supports_post_sub_buffer_; | 1872 bool supports_post_sub_buffer_; |
1869 | 1873 |
1870 // These flags are used to override the state of the shared feature_info_ | 1874 // These flags are used to override the state of the shared feature_info_ |
1871 // member. Because the same FeatureInfo instance may be shared among many | 1875 // member. Because the same FeatureInfo instance may be shared among many |
1872 // contexts, the assumptions on the availablity of extensions in WebGL | 1876 // contexts, the assumptions on the availablity of extensions in WebGL |
1873 // contexts may be broken. These flags override the shared state to preserve | 1877 // contexts may be broken. These flags override the shared state to preserve |
1874 // WebGL semantics. | 1878 // WebGL semantics. |
1875 bool force_webgl_glsl_validation_; | 1879 bool force_webgl_glsl_validation_; |
1876 bool derivatives_explicitly_enabled_; | 1880 bool derivatives_explicitly_enabled_; |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2398 back_buffer_has_depth_(false), | 2402 back_buffer_has_depth_(false), |
2399 back_buffer_has_stencil_(false), | 2403 back_buffer_has_stencil_(false), |
2400 surfaceless_(false), | 2404 surfaceless_(false), |
2401 backbuffer_needs_clear_bits_(0), | 2405 backbuffer_needs_clear_bits_(0), |
2402 current_decoder_error_(error::kNoError), | 2406 current_decoder_error_(error::kNoError), |
2403 use_shader_translator_(true), | 2407 use_shader_translator_(true), |
2404 validators_(group_->feature_info()->validators()), | 2408 validators_(group_->feature_info()->validators()), |
2405 feature_info_(group_->feature_info()), | 2409 feature_info_(group_->feature_info()), |
2406 frame_number_(0), | 2410 frame_number_(0), |
2407 has_robustness_extension_(false), | 2411 has_robustness_extension_(false), |
2408 reset_status_(GL_NO_ERROR), | 2412 context_lost_reason_(error::kUnknown), |
| 2413 context_was_lost_(false), |
2409 reset_by_robustness_extension_(false), | 2414 reset_by_robustness_extension_(false), |
2410 supports_post_sub_buffer_(false), | 2415 supports_post_sub_buffer_(false), |
2411 force_webgl_glsl_validation_(false), | 2416 force_webgl_glsl_validation_(false), |
2412 derivatives_explicitly_enabled_(false), | 2417 derivatives_explicitly_enabled_(false), |
2413 frag_depth_explicitly_enabled_(false), | 2418 frag_depth_explicitly_enabled_(false), |
2414 draw_buffers_explicitly_enabled_(false), | 2419 draw_buffers_explicitly_enabled_(false), |
2415 shader_texture_lod_explicitly_enabled_(false), | 2420 shader_texture_lod_explicitly_enabled_(false), |
2416 compile_shader_always_succeeds_(false), | 2421 compile_shader_always_succeeds_(false), |
2417 lose_context_when_out_of_memory_(false), | 2422 lose_context_when_out_of_memory_(false), |
2418 service_logging_(base::CommandLine::ForCurrentProcess()->HasSwitch( | 2423 service_logging_(base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3320 } | 3325 } |
3321 } | 3326 } |
3322 } | 3327 } |
3323 | 3328 |
3324 // } // anonymous namespace | 3329 // } // anonymous namespace |
3325 | 3330 |
3326 bool GLES2DecoderImpl::MakeCurrent() { | 3331 bool GLES2DecoderImpl::MakeCurrent() { |
3327 if (!context_.get()) | 3332 if (!context_.get()) |
3328 return false; | 3333 return false; |
3329 | 3334 |
3330 if (!context_->MakeCurrent(surface_.get()) || WasContextLost()) { | 3335 if (WasContextLost()) { |
3331 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | 3336 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
3332 | |
3333 MaybeExitOnContextLost(); | |
3334 | |
3335 return false; | 3337 return false; |
3336 } | 3338 } |
3337 | 3339 |
| 3340 if (!context_->MakeCurrent(surface_.get())) { |
| 3341 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; |
| 3342 MarkContextLost(error::kMakeCurrentFailed); |
| 3343 group_->LoseContexts(error::kUnknown); |
| 3344 return false; |
| 3345 } |
| 3346 |
| 3347 if (CheckResetStatus()) { |
| 3348 LOG(ERROR) |
| 3349 << " GLES2DecoderImpl: Context reset detected after MakeCurrent."; |
| 3350 group_->LoseContexts(error::kUnknown); |
| 3351 return false; |
| 3352 } |
| 3353 |
3338 ProcessFinishedAsyncTransfers(); | 3354 ProcessFinishedAsyncTransfers(); |
3339 | 3355 |
3340 // Rebind the FBO if it was unbound by the context. | 3356 // Rebind the FBO if it was unbound by the context. |
3341 if (workarounds().unbind_fbo_on_context_switch) | 3357 if (workarounds().unbind_fbo_on_context_switch) |
3342 RestoreFramebufferBindings(); | 3358 RestoreFramebufferBindings(); |
3343 | 3359 |
3344 framebuffer_state_.clear_state_dirty = true; | 3360 framebuffer_state_.clear_state_dirty = true; |
3345 | 3361 |
3346 return true; | 3362 return true; |
3347 } | 3363 } |
(...skipping 6950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10298 offscreen_saved_color_texture_->AllocateStorage( | 10314 offscreen_saved_color_texture_->AllocateStorage( |
10299 offscreen_size_, offscreen_saved_color_format_, false); | 10315 offscreen_size_, offscreen_saved_color_format_, false); |
10300 | 10316 |
10301 offscreen_saved_frame_buffer_->AttachRenderTexture( | 10317 offscreen_saved_frame_buffer_->AttachRenderTexture( |
10302 offscreen_saved_color_texture_.get()); | 10318 offscreen_saved_color_texture_.get()); |
10303 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { | 10319 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { |
10304 if (offscreen_saved_frame_buffer_->CheckStatus() != | 10320 if (offscreen_saved_frame_buffer_->CheckStatus() != |
10305 GL_FRAMEBUFFER_COMPLETE) { | 10321 GL_FRAMEBUFFER_COMPLETE) { |
10306 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 10322 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
10307 << "because offscreen saved FBO was incomplete."; | 10323 << "because offscreen saved FBO was incomplete."; |
10308 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10324 MarkContextLost(error::kUnknown); |
| 10325 group_->LoseContexts(error::kUnknown); |
10309 return; | 10326 return; |
10310 } | 10327 } |
10311 | 10328 |
10312 // Clear the offscreen color texture. | 10329 // Clear the offscreen color texture. |
10313 // TODO(piman): Is this still necessary? | 10330 // TODO(piman): Is this still necessary? |
10314 { | 10331 { |
10315 ScopedFrameBufferBinder binder(this, | 10332 ScopedFrameBufferBinder binder(this, |
10316 offscreen_saved_frame_buffer_->id()); | 10333 offscreen_saved_frame_buffer_->id()); |
10317 glClearColor(0, 0, 0, 0); | 10334 glClearColor(0, 0, 0, 0); |
10318 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 10335 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10355 | 10372 |
10356 // Ensure the side effects of the copy are visible to the parent | 10373 // Ensure the side effects of the copy are visible to the parent |
10357 // context. There is no need to do this for ANGLE because it uses a | 10374 // context. There is no need to do this for ANGLE because it uses a |
10358 // single D3D device for all contexts. | 10375 // single D3D device for all contexts. |
10359 if (!feature_info_->gl_version_info().is_angle) | 10376 if (!feature_info_->gl_version_info().is_angle) |
10360 glFlush(); | 10377 glFlush(); |
10361 } | 10378 } |
10362 } else { | 10379 } else { |
10363 if (!surface_->SwapBuffers()) { | 10380 if (!surface_->SwapBuffers()) { |
10364 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 10381 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
10365 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10382 if (!CheckResetStatus()) { |
| 10383 MarkContextLost(error::kUnknown); |
| 10384 group_->LoseContexts(error::kUnknown); |
| 10385 } |
10366 } | 10386 } |
10367 } | 10387 } |
10368 | 10388 |
10369 // This may be a slow command. Exit command processing to allow for | 10389 // This may be a slow command. Exit command processing to allow for |
10370 // context preemption and GPU watchdog checks. | 10390 // context preemption and GPU watchdog checks. |
10371 ExitCommandProcessingEarly(); | 10391 ExitCommandProcessingEarly(); |
10372 } | 10392 } |
10373 | 10393 |
10374 void GLES2DecoderImpl::DoSwapInterval(int interval) { | 10394 void GLES2DecoderImpl::DoSwapInterval(int interval) { |
10375 context_->SetSwapInterval(interval); | 10395 context_->SetSwapInterval(interval); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10615 Program* program = NULL; | 10635 Program* program = NULL; |
10616 program = GetProgram(program_id); | 10636 program = GetProgram(program_id); |
10617 if (!program || !program->IsValid()) { | 10637 if (!program || !program->IsValid()) { |
10618 return error::kNoError; | 10638 return error::kNoError; |
10619 } | 10639 } |
10620 program->GetTransformFeedbackVaryings(bucket); | 10640 program->GetTransformFeedbackVaryings(bucket); |
10621 return error::kNoError; | 10641 return error::kNoError; |
10622 } | 10642 } |
10623 | 10643 |
10624 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { | 10644 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { |
10625 switch (reset_status_) { | 10645 return context_lost_reason_; |
| 10646 } |
| 10647 |
| 10648 error::ContextLostReason GLES2DecoderImpl::GetContextLostReasonFromResetStatus( |
| 10649 GLenum reset_status) const { |
| 10650 switch (reset_status) { |
10626 case GL_NO_ERROR: | 10651 case GL_NO_ERROR: |
10627 // TODO(kbr): improve the precision of the error code in this case. | 10652 // TODO(kbr): improve the precision of the error code in this case. |
10628 // Consider delegating to context for error code if MakeCurrent fails. | 10653 // Consider delegating to context for error code if MakeCurrent fails. |
10629 return error::kUnknown; | 10654 return error::kUnknown; |
10630 case GL_GUILTY_CONTEXT_RESET_ARB: | 10655 case GL_GUILTY_CONTEXT_RESET_ARB: |
10631 return error::kGuilty; | 10656 return error::kGuilty; |
10632 case GL_INNOCENT_CONTEXT_RESET_ARB: | 10657 case GL_INNOCENT_CONTEXT_RESET_ARB: |
10633 return error::kInnocent; | 10658 return error::kInnocent; |
10634 case GL_UNKNOWN_CONTEXT_RESET_ARB: | 10659 case GL_UNKNOWN_CONTEXT_RESET_ARB: |
10635 return error::kUnknown; | 10660 return error::kUnknown; |
10636 } | 10661 } |
10637 | 10662 |
10638 NOTREACHED(); | 10663 NOTREACHED(); |
10639 return error::kUnknown; | 10664 return error::kUnknown; |
10640 } | 10665 } |
10641 | 10666 |
10642 void GLES2DecoderImpl::MaybeExitOnContextLost() { | 10667 bool GLES2DecoderImpl::WasContextLost() const { |
| 10668 return context_was_lost_; |
| 10669 } |
| 10670 |
| 10671 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() const { |
| 10672 return WasContextLost() && reset_by_robustness_extension_; |
| 10673 } |
| 10674 |
| 10675 void GLES2DecoderImpl::MarkContextLost(error::ContextLostReason reason) { |
| 10676 // Only lose the context once. |
| 10677 if (WasContextLost()) |
| 10678 return; |
| 10679 |
| 10680 // Don't make GL calls in here, the context might not be current. |
| 10681 context_lost_reason_ = reason; |
| 10682 current_decoder_error_ = error::kLostContext; |
| 10683 context_was_lost_ = true; |
| 10684 |
10643 // Some D3D drivers cannot recover from device lost in the GPU process | 10685 // Some D3D drivers cannot recover from device lost in the GPU process |
10644 // sandbox. Allow a new GPU process to launch. | 10686 // sandbox. Allow a new GPU process to launch. |
10645 if (workarounds().exit_on_context_lost) { | 10687 if (workarounds().exit_on_context_lost) { |
10646 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" | 10688 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" |
10647 << " a D3D device in the Chrome GPU process sandbox."; | 10689 << " a D3D device in the Chrome GPU process sandbox."; |
10648 #if defined(OS_WIN) | 10690 #if defined(OS_WIN) |
10649 base::win::SetShouldCrashOnProcessDetach(false); | 10691 base::win::SetShouldCrashOnProcessDetach(false); |
10650 #endif | 10692 #endif |
10651 exit(0); | 10693 exit(0); |
10652 } | 10694 } |
10653 } | 10695 } |
10654 | 10696 |
10655 bool GLES2DecoderImpl::WasContextLost() { | 10697 bool GLES2DecoderImpl::CheckResetStatus() { |
10656 if (reset_status_ != GL_NO_ERROR) { | 10698 DCHECK(!WasContextLost()); |
10657 MaybeExitOnContextLost(); | 10699 DCHECK(context_->IsCurrent(NULL)); |
| 10700 |
| 10701 if (IsRobustnessSupported()) { |
| 10702 // If the reason for the call was a GL error, we can try to determine the |
| 10703 // reset status more accurately. |
| 10704 GLenum driver_status = glGetGraphicsResetStatusARB(); |
| 10705 if (driver_status == GL_NO_ERROR) |
| 10706 return false; |
| 10707 |
| 10708 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") |
| 10709 << " context lost via ARB/EXT_robustness. Reset status = " |
| 10710 << GLES2Util::GetStringEnum(driver_status); |
| 10711 |
| 10712 // Don't pretend we know which client was responsible. |
| 10713 if (workarounds().use_virtualized_gl_contexts) |
| 10714 driver_status = GL_UNKNOWN_CONTEXT_RESET_ARB; |
| 10715 |
| 10716 switch (driver_status) { |
| 10717 case GL_GUILTY_CONTEXT_RESET_ARB: |
| 10718 MarkContextLost(error::kGuilty); |
| 10719 break; |
| 10720 case GL_INNOCENT_CONTEXT_RESET_ARB: |
| 10721 MarkContextLost(error::kInnocent); |
| 10722 break; |
| 10723 case GL_UNKNOWN_CONTEXT_RESET_ARB: |
| 10724 MarkContextLost(error::kUnknown); |
| 10725 break; |
| 10726 default: |
| 10727 NOTREACHED(); |
| 10728 return false; |
| 10729 } |
| 10730 reset_by_robustness_extension_ = true; |
10658 return true; | 10731 return true; |
10659 } | 10732 } |
10660 if (IsRobustnessSupported()) { | |
10661 GLenum status = glGetGraphicsResetStatusARB(); | |
10662 if (status != GL_NO_ERROR) { | |
10663 // The graphics card was reset. Signal a lost context to the application. | |
10664 reset_status_ = status; | |
10665 reset_by_robustness_extension_ = true; | |
10666 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") | |
10667 << " context lost via ARB/EXT_robustness. Reset status = " | |
10668 << GLES2Util::GetStringEnum(status); | |
10669 MaybeExitOnContextLost(); | |
10670 return true; | |
10671 } | |
10672 } | |
10673 return false; | 10733 return false; |
10674 } | 10734 } |
10675 | 10735 |
10676 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() { | |
10677 return WasContextLost() && reset_by_robustness_extension_; | |
10678 } | |
10679 | |
10680 void GLES2DecoderImpl::LoseContext(uint32 reset_status) { | |
10681 // Only loses the context once. | |
10682 if (reset_status_ != GL_NO_ERROR) { | |
10683 return; | |
10684 } | |
10685 | |
10686 if (workarounds().use_virtualized_gl_contexts) { | |
10687 // If the context is virtual, the real context being guilty does not ensure | |
10688 // that the virtual context is guilty. | |
10689 if (reset_status == GL_GUILTY_CONTEXT_RESET_ARB) { | |
10690 reset_status = GL_UNKNOWN_CONTEXT_RESET_ARB; | |
10691 } | |
10692 } else if (reset_status == GL_UNKNOWN_CONTEXT_RESET_ARB && | |
10693 IsRobustnessSupported()) { | |
10694 // If the reason for the call was a GL error, we can try to determine the | |
10695 // reset status more accurately. | |
10696 GLenum driver_status = glGetGraphicsResetStatusARB(); | |
10697 if (driver_status == GL_GUILTY_CONTEXT_RESET_ARB || | |
10698 driver_status == GL_INNOCENT_CONTEXT_RESET_ARB) { | |
10699 reset_status = driver_status; | |
10700 } | |
10701 } | |
10702 | |
10703 // Marks this context as lost. | |
10704 reset_status_ = reset_status; | |
10705 current_decoder_error_ = error::kLostContext; | |
10706 } | |
10707 | |
10708 error::Error GLES2DecoderImpl::HandleInsertSyncPointCHROMIUM( | 10736 error::Error GLES2DecoderImpl::HandleInsertSyncPointCHROMIUM( |
10709 uint32 immediate_data_size, | 10737 uint32 immediate_data_size, |
10710 const void* cmd_data) { | 10738 const void* cmd_data) { |
10711 return error::kUnknownCommand; | 10739 return error::kUnknownCommand; |
10712 } | 10740 } |
10713 | 10741 |
10714 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM( | 10742 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM( |
10715 uint32 immediate_data_size, | 10743 uint32 immediate_data_size, |
10716 const void* cmd_data) { | 10744 const void* cmd_data) { |
10717 const gles2::cmds::WaitSyncPointCHROMIUM& c = | 10745 const gles2::cmds::WaitSyncPointCHROMIUM& c = |
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12071 if (GetBackbufferServiceId() != 0 && // emulated backbuffer | 12099 if (GetBackbufferServiceId() != 0 && // emulated backbuffer |
12072 bufs[0] == GL_BACK) { | 12100 bufs[0] == GL_BACK) { |
12073 mapped_buf = GL_COLOR_ATTACHMENT0; | 12101 mapped_buf = GL_COLOR_ATTACHMENT0; |
12074 } | 12102 } |
12075 glDrawBuffersARB(count, &mapped_buf); | 12103 glDrawBuffersARB(count, &mapped_buf); |
12076 group_->set_draw_buffer(bufs[0]); | 12104 group_->set_draw_buffer(bufs[0]); |
12077 } | 12105 } |
12078 } | 12106 } |
12079 | 12107 |
12080 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { | 12108 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { |
12081 group_->LoseContexts(other); | 12109 MarkContextLost(GetContextLostReasonFromResetStatus(current)); |
12082 reset_status_ = current; | 12110 group_->LoseContexts(GetContextLostReasonFromResetStatus(other)); |
12083 current_decoder_error_ = error::kLostContext; | 12111 reset_by_robustness_extension_ = true; |
12084 } | 12112 } |
12085 | 12113 |
12086 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, | 12114 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, |
12087 const GLfloat* matrix) { | 12115 const GLfloat* matrix) { |
12088 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || | 12116 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || |
12089 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); | 12117 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); |
12090 if (!features().chromium_path_rendering) { | 12118 if (!features().chromium_path_rendering) { |
12091 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 12119 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
12092 "glMatrixLoadfCHROMIUM", | 12120 "glMatrixLoadfCHROMIUM", |
12093 "function not available"); | 12121 "function not available"); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12591 } | 12619 } |
12592 buffer->RemoveMappedRange(); | 12620 buffer->RemoveMappedRange(); |
12593 GLboolean rt = glUnmapBuffer(target); | 12621 GLboolean rt = glUnmapBuffer(target); |
12594 if (rt == GL_FALSE) { | 12622 if (rt == GL_FALSE) { |
12595 // At this point, we have already done the necessary validation, so | 12623 // At this point, we have already done the necessary validation, so |
12596 // GL_FALSE indicates data corruption. | 12624 // GL_FALSE indicates data corruption. |
12597 // TODO(zmo): We could redo the map / copy data / unmap to recover, but | 12625 // TODO(zmo): We could redo the map / copy data / unmap to recover, but |
12598 // the second unmap could still return GL_FALSE. For now, we simply lose | 12626 // the second unmap could still return GL_FALSE. For now, we simply lose |
12599 // the contexts in the share group. | 12627 // the contexts in the share group. |
12600 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; | 12628 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; |
12601 group_->LoseContexts(GL_INNOCENT_CONTEXT_RESET_ARB); | 12629 // Need to lose current context before broadcasting! |
12602 reset_status_ = GL_GUILTY_CONTEXT_RESET_ARB; | 12630 MarkContextLost(error::kGuilty); |
| 12631 group_->LoseContexts(error::kInnocent); |
12603 return error::kLostContext; | 12632 return error::kLostContext; |
12604 } | 12633 } |
12605 return error::kNoError; | 12634 return error::kNoError; |
12606 } | 12635 } |
12607 | 12636 |
12608 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( | 12637 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( |
12609 TextureRef* texture_ref) { | 12638 TextureRef* texture_ref) { |
12610 Texture* texture = texture_ref->texture(); | 12639 Texture* texture = texture_ref->texture(); |
12611 DoDidUseTexImageIfNeeded(texture, texture->target()); | 12640 DoDidUseTexImageIfNeeded(texture, texture->target()); |
12612 } | 12641 } |
12613 | 12642 |
| 12643 // Note that GL_LOST_CONTEXT is specific to GLES. |
| 12644 // For desktop GL we have to query the reset status proactively. |
12614 void GLES2DecoderImpl::OnContextLostError() { | 12645 void GLES2DecoderImpl::OnContextLostError() { |
12615 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12646 if (!WasContextLost()) { |
| 12647 // Need to lose current context before broadcasting! |
| 12648 CheckResetStatus(); |
| 12649 group_->LoseContexts(error::kUnknown); |
| 12650 reset_by_robustness_extension_ = true; |
| 12651 } |
12616 } | 12652 } |
12617 | 12653 |
12618 void GLES2DecoderImpl::OnOutOfMemoryError() { | 12654 void GLES2DecoderImpl::OnOutOfMemoryError() { |
12619 if (lose_context_when_out_of_memory_) { | 12655 if (lose_context_when_out_of_memory_ && !WasContextLost()) { |
12620 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12656 error::ContextLostReason other = error::kOutOfMemory; |
| 12657 if (CheckResetStatus()) { |
| 12658 other = error::kUnknown; |
| 12659 } else { |
| 12660 // Need to lose current context before broadcasting! |
| 12661 MarkContextLost(error::kOutOfMemory); |
| 12662 } |
| 12663 group_->LoseContexts(other); |
12621 } | 12664 } |
12622 } | 12665 } |
12623 | 12666 |
12624 // Include the auto-generated part of this file. We split this because it means | 12667 // Include the auto-generated part of this file. We split this because it means |
12625 // we can easily edit the non-auto generated parts right here in this file | 12668 // we can easily edit the non-auto generated parts right here in this file |
12626 // instead of having to edit some template or the code generator. | 12669 // instead of having to edit some template or the code generator. |
12627 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12670 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12628 | 12671 |
12629 } // namespace gles2 | 12672 } // namespace gles2 |
12630 } // namespace gpu | 12673 } // namespace gpu |
OLD | NEW |