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 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()) { |
no sievers
2015/04/24 21:00:26
There is actually a bug here (even before my patch
| |
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 return false; | |
3351 } | |
3352 | |
3338 ProcessFinishedAsyncTransfers(); | 3353 ProcessFinishedAsyncTransfers(); |
3339 | 3354 |
3340 // Rebind the FBO if it was unbound by the context. | 3355 // Rebind the FBO if it was unbound by the context. |
3341 if (workarounds().unbind_fbo_on_context_switch) | 3356 if (workarounds().unbind_fbo_on_context_switch) |
3342 RestoreFramebufferBindings(); | 3357 RestoreFramebufferBindings(); |
3343 | 3358 |
3344 framebuffer_state_.clear_state_dirty = true; | 3359 framebuffer_state_.clear_state_dirty = true; |
3345 | 3360 |
3346 return true; | 3361 return true; |
3347 } | 3362 } |
(...skipping 6950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10298 offscreen_saved_color_texture_->AllocateStorage( | 10313 offscreen_saved_color_texture_->AllocateStorage( |
10299 offscreen_size_, offscreen_saved_color_format_, false); | 10314 offscreen_size_, offscreen_saved_color_format_, false); |
10300 | 10315 |
10301 offscreen_saved_frame_buffer_->AttachRenderTexture( | 10316 offscreen_saved_frame_buffer_->AttachRenderTexture( |
10302 offscreen_saved_color_texture_.get()); | 10317 offscreen_saved_color_texture_.get()); |
10303 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { | 10318 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { |
10304 if (offscreen_saved_frame_buffer_->CheckStatus() != | 10319 if (offscreen_saved_frame_buffer_->CheckStatus() != |
10305 GL_FRAMEBUFFER_COMPLETE) { | 10320 GL_FRAMEBUFFER_COMPLETE) { |
10306 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 10321 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
10307 << "because offscreen saved FBO was incomplete."; | 10322 << "because offscreen saved FBO was incomplete."; |
10308 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10323 MarkContextLost(error::kUnknown); |
10324 group_->LoseContexts(error::kUnknown); | |
10309 return; | 10325 return; |
10310 } | 10326 } |
10311 | 10327 |
10312 // Clear the offscreen color texture. | 10328 // Clear the offscreen color texture. |
10313 // TODO(piman): Is this still necessary? | 10329 // TODO(piman): Is this still necessary? |
10314 { | 10330 { |
10315 ScopedFrameBufferBinder binder(this, | 10331 ScopedFrameBufferBinder binder(this, |
10316 offscreen_saved_frame_buffer_->id()); | 10332 offscreen_saved_frame_buffer_->id()); |
10317 glClearColor(0, 0, 0, 0); | 10333 glClearColor(0, 0, 0, 0); |
10318 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 10334 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10355 | 10371 |
10356 // Ensure the side effects of the copy are visible to the parent | 10372 // 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 | 10373 // context. There is no need to do this for ANGLE because it uses a |
10358 // single D3D device for all contexts. | 10374 // single D3D device for all contexts. |
10359 if (!feature_info_->gl_version_info().is_angle) | 10375 if (!feature_info_->gl_version_info().is_angle) |
10360 glFlush(); | 10376 glFlush(); |
10361 } | 10377 } |
10362 } else { | 10378 } else { |
10363 if (!surface_->SwapBuffers()) { | 10379 if (!surface_->SwapBuffers()) { |
10364 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 10380 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
10365 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10381 if (!CheckResetStatus()) { |
10382 MarkContextLost(error::kUnknown); | |
10383 group_->LoseContexts(error::kUnknown); | |
10384 } | |
10366 } | 10385 } |
10367 } | 10386 } |
10368 | 10387 |
10369 // This may be a slow command. Exit command processing to allow for | 10388 // This may be a slow command. Exit command processing to allow for |
10370 // context preemption and GPU watchdog checks. | 10389 // context preemption and GPU watchdog checks. |
10371 ExitCommandProcessingEarly(); | 10390 ExitCommandProcessingEarly(); |
10372 } | 10391 } |
10373 | 10392 |
10374 void GLES2DecoderImpl::DoSwapInterval(int interval) { | 10393 void GLES2DecoderImpl::DoSwapInterval(int interval) { |
10375 context_->SetSwapInterval(interval); | 10394 context_->SetSwapInterval(interval); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10615 Program* program = NULL; | 10634 Program* program = NULL; |
10616 program = GetProgram(program_id); | 10635 program = GetProgram(program_id); |
10617 if (!program || !program->IsValid()) { | 10636 if (!program || !program->IsValid()) { |
10618 return error::kNoError; | 10637 return error::kNoError; |
10619 } | 10638 } |
10620 program->GetTransformFeedbackVaryings(bucket); | 10639 program->GetTransformFeedbackVaryings(bucket); |
10621 return error::kNoError; | 10640 return error::kNoError; |
10622 } | 10641 } |
10623 | 10642 |
10624 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { | 10643 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { |
10625 switch (reset_status_) { | 10644 return context_lost_reason_; |
10645 } | |
10646 | |
10647 error::ContextLostReason GLES2DecoderImpl::GetContextLostReasonFromResetStatus( | |
10648 GLenum reset_status) const { | |
10649 switch (reset_status) { | |
10626 case GL_NO_ERROR: | 10650 case GL_NO_ERROR: |
10627 // TODO(kbr): improve the precision of the error code in this case. | 10651 // TODO(kbr): improve the precision of the error code in this case. |
10628 // Consider delegating to context for error code if MakeCurrent fails. | 10652 // Consider delegating to context for error code if MakeCurrent fails. |
10629 return error::kUnknown; | 10653 return error::kUnknown; |
10630 case GL_GUILTY_CONTEXT_RESET_ARB: | 10654 case GL_GUILTY_CONTEXT_RESET_ARB: |
10631 return error::kGuilty; | 10655 return error::kGuilty; |
10632 case GL_INNOCENT_CONTEXT_RESET_ARB: | 10656 case GL_INNOCENT_CONTEXT_RESET_ARB: |
10633 return error::kInnocent; | 10657 return error::kInnocent; |
10634 case GL_UNKNOWN_CONTEXT_RESET_ARB: | 10658 case GL_UNKNOWN_CONTEXT_RESET_ARB: |
10635 return error::kUnknown; | 10659 return error::kUnknown; |
10636 } | 10660 } |
10637 | 10661 |
10638 NOTREACHED(); | 10662 NOTREACHED(); |
10639 return error::kUnknown; | 10663 return error::kUnknown; |
10640 } | 10664 } |
10641 | 10665 |
10642 void GLES2DecoderImpl::MaybeExitOnContextLost() { | 10666 bool GLES2DecoderImpl::WasContextLost() const { |
10667 return context_was_lost_; | |
10668 } | |
10669 | |
10670 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() const { | |
10671 return WasContextLost() && reset_by_robustness_extension_; | |
10672 } | |
10673 | |
10674 void GLES2DecoderImpl::MarkContextLost(error::ContextLostReason reason) { | |
10675 // Only lose the context once. | |
10676 if (WasContextLost()) | |
10677 return; | |
10678 | |
10679 // Don't make GL calls in here, the context might not be current. | |
10680 context_lost_reason_ = reason; | |
10681 current_decoder_error_ = error::kLostContext; | |
10682 context_was_lost_ = true; | |
10683 | |
10643 // Some D3D drivers cannot recover from device lost in the GPU process | 10684 // Some D3D drivers cannot recover from device lost in the GPU process |
10644 // sandbox. Allow a new GPU process to launch. | 10685 // sandbox. Allow a new GPU process to launch. |
10645 if (workarounds().exit_on_context_lost) { | 10686 if (workarounds().exit_on_context_lost) { |
10646 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" | 10687 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" |
10647 << " a D3D device in the Chrome GPU process sandbox."; | 10688 << " a D3D device in the Chrome GPU process sandbox."; |
10648 #if defined(OS_WIN) | 10689 #if defined(OS_WIN) |
10649 base::win::SetShouldCrashOnProcessDetach(false); | 10690 base::win::SetShouldCrashOnProcessDetach(false); |
10650 #endif | 10691 #endif |
10651 exit(0); | 10692 exit(0); |
10652 } | 10693 } |
10653 } | 10694 } |
10654 | 10695 |
10655 bool GLES2DecoderImpl::WasContextLost() { | 10696 bool GLES2DecoderImpl::CheckResetStatus() { |
10656 if (reset_status_ != GL_NO_ERROR) { | 10697 DCHECK(!WasContextLost()); |
10657 MaybeExitOnContextLost(); | 10698 DCHECK(context_->IsCurrent(NULL)); |
10699 | |
10700 if (IsRobustnessSupported()) { | |
10701 // If the reason for the call was a GL error, we can try to determine the | |
10702 // reset status more accurately. | |
10703 GLenum driver_status = glGetGraphicsResetStatusARB(); | |
10704 if (driver_status == GL_NO_ERROR) | |
10705 return false; | |
10706 | |
10707 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") | |
10708 << " context lost via ARB/EXT_robustness. Reset status = " | |
10709 << GLES2Util::GetStringEnum(driver_status); | |
10710 | |
10711 // Don't pretend we know which client was responsible. | |
10712 if (workarounds().use_virtualized_gl_contexts) | |
10713 driver_status = GL_UNKNOWN_CONTEXT_RESET_ARB; | |
10714 | |
10715 switch (driver_status) { | |
10716 case GL_GUILTY_CONTEXT_RESET_ARB: | |
10717 MarkContextLost(error::kGuilty); | |
10718 break; | |
10719 case GL_INNOCENT_CONTEXT_RESET_ARB: | |
10720 MarkContextLost(error::kInnocent); | |
10721 break; | |
10722 case GL_UNKNOWN_CONTEXT_RESET_ARB: | |
10723 MarkContextLost(error::kUnknown); | |
10724 break; | |
10725 default: | |
10726 NOTREACHED(); | |
10727 return false; | |
10728 } | |
10729 reset_by_robustness_extension_ = true; | |
10658 return true; | 10730 return true; |
10659 } | 10731 } |
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; | 10732 return false; |
10674 } | 10733 } |
10675 | 10734 |
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( | 10735 error::Error GLES2DecoderImpl::HandleInsertSyncPointCHROMIUM( |
10709 uint32 immediate_data_size, | 10736 uint32 immediate_data_size, |
10710 const void* cmd_data) { | 10737 const void* cmd_data) { |
10711 return error::kUnknownCommand; | 10738 return error::kUnknownCommand; |
10712 } | 10739 } |
10713 | 10740 |
10714 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM( | 10741 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM( |
10715 uint32 immediate_data_size, | 10742 uint32 immediate_data_size, |
10716 const void* cmd_data) { | 10743 const void* cmd_data) { |
10717 const gles2::cmds::WaitSyncPointCHROMIUM& c = | 10744 const gles2::cmds::WaitSyncPointCHROMIUM& c = |
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12071 if (GetBackbufferServiceId() != 0 && // emulated backbuffer | 12098 if (GetBackbufferServiceId() != 0 && // emulated backbuffer |
12072 bufs[0] == GL_BACK) { | 12099 bufs[0] == GL_BACK) { |
12073 mapped_buf = GL_COLOR_ATTACHMENT0; | 12100 mapped_buf = GL_COLOR_ATTACHMENT0; |
12074 } | 12101 } |
12075 glDrawBuffersARB(count, &mapped_buf); | 12102 glDrawBuffersARB(count, &mapped_buf); |
12076 group_->set_draw_buffer(bufs[0]); | 12103 group_->set_draw_buffer(bufs[0]); |
12077 } | 12104 } |
12078 } | 12105 } |
12079 | 12106 |
12080 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { | 12107 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { |
12081 group_->LoseContexts(other); | 12108 MarkContextLost(GetContextLostReasonFromResetStatus(current)); |
12082 reset_status_ = current; | 12109 group_->LoseContexts(GetContextLostReasonFromResetStatus(other)); |
12083 current_decoder_error_ = error::kLostContext; | 12110 reset_by_robustness_extension_ = true; |
12084 } | 12111 } |
12085 | 12112 |
12086 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, | 12113 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, |
12087 const GLfloat* matrix) { | 12114 const GLfloat* matrix) { |
12088 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || | 12115 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || |
12089 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); | 12116 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); |
12090 if (!features().chromium_path_rendering) { | 12117 if (!features().chromium_path_rendering) { |
12091 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 12118 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
12092 "glMatrixLoadfCHROMIUM", | 12119 "glMatrixLoadfCHROMIUM", |
12093 "function not available"); | 12120 "function not available"); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12591 } | 12618 } |
12592 buffer->RemoveMappedRange(); | 12619 buffer->RemoveMappedRange(); |
12593 GLboolean rt = glUnmapBuffer(target); | 12620 GLboolean rt = glUnmapBuffer(target); |
12594 if (rt == GL_FALSE) { | 12621 if (rt == GL_FALSE) { |
12595 // At this point, we have already done the necessary validation, so | 12622 // At this point, we have already done the necessary validation, so |
12596 // GL_FALSE indicates data corruption. | 12623 // GL_FALSE indicates data corruption. |
12597 // TODO(zmo): We could redo the map / copy data / unmap to recover, but | 12624 // 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 | 12625 // the second unmap could still return GL_FALSE. For now, we simply lose |
12599 // the contexts in the share group. | 12626 // the contexts in the share group. |
12600 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; | 12627 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; |
12601 group_->LoseContexts(GL_INNOCENT_CONTEXT_RESET_ARB); | 12628 // Need to lose current context before broadcasting! |
12602 reset_status_ = GL_GUILTY_CONTEXT_RESET_ARB; | 12629 MarkContextLost(error::kGuilty); |
12630 group_->LoseContexts(error::kInnocent); | |
12603 return error::kLostContext; | 12631 return error::kLostContext; |
12604 } | 12632 } |
12605 return error::kNoError; | 12633 return error::kNoError; |
12606 } | 12634 } |
12607 | 12635 |
12608 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( | 12636 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( |
12609 TextureRef* texture_ref) { | 12637 TextureRef* texture_ref) { |
12610 Texture* texture = texture_ref->texture(); | 12638 Texture* texture = texture_ref->texture(); |
12611 DoDidUseTexImageIfNeeded(texture, texture->target()); | 12639 DoDidUseTexImageIfNeeded(texture, texture->target()); |
12612 } | 12640 } |
12613 | 12641 |
12642 // Note that GL_LOST_CONTEXT is specific to GLES. | |
12643 // For desktop GL we have to query the reset status proactively. | |
12614 void GLES2DecoderImpl::OnContextLostError() { | 12644 void GLES2DecoderImpl::OnContextLostError() { |
12615 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12645 if (!WasContextLost()) { |
12646 // Need to lose current context before broadcasting! | |
12647 CheckResetStatus(); | |
12648 group_->LoseContexts(error::kUnknown); | |
12649 reset_by_robustness_extension_ = true; | |
12650 } | |
12616 } | 12651 } |
12617 | 12652 |
12618 void GLES2DecoderImpl::OnOutOfMemoryError() { | 12653 void GLES2DecoderImpl::OnOutOfMemoryError() { |
12619 if (lose_context_when_out_of_memory_) { | 12654 if (lose_context_when_out_of_memory_ && !WasContextLost()) { |
12620 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12655 error::ContextLostReason other = error::kOutOfMemory; |
12656 if (CheckResetStatus()) { | |
12657 other = error::kUnknown; | |
12658 } else { | |
12659 // Need to lose current context before broadcasting! | |
12660 MarkContextLost(error::kOutOfMemory); | |
12661 } | |
12662 group_->LoseContexts(other); | |
12621 } | 12663 } |
12622 } | 12664 } |
12623 | 12665 |
12624 // Include the auto-generated part of this file. We split this because it means | 12666 // 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 | 12667 // 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. | 12668 // instead of having to edit some template or the code generator. |
12627 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12669 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12628 | 12670 |
12629 } // namespace gles2 | 12671 } // namespace gles2 |
12630 } // namespace gpu | 12672 } // namespace gpu |
OLD | NEW |