Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: gpu/ipc/client/command_buffer_proxy_impl.cc

Issue 1919203003: Revert of Report lost context from GLES2Implementation based on share group state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/ipc/client/command_buffer_proxy_impl.h ('k') | mojo/gles2/command_buffer_client_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ipc/client/command_buffer_proxy_impl.h" 5 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "base/optional.h"
14 #include "base/stl_util.h" 13 #include "base/stl_util.h"
15 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
16 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
17 #include "gpu/command_buffer/client/gpu_control_client.h" 16 #include "gpu/command_buffer/client/gpu_control_client.h"
18 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 17 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
19 #include "gpu/command_buffer/common/cmd_buffer_common.h" 18 #include "gpu/command_buffer/common/cmd_buffer_common.h"
20 #include "gpu/command_buffer/common/command_buffer_id.h" 19 #include "gpu/command_buffer/common/command_buffer_id.h"
21 #include "gpu/command_buffer/common/command_buffer_shared.h" 20 #include "gpu/command_buffer/common/command_buffer_shared.h"
22 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 21 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
23 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" 22 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 98
100 gpu::error::ContextLostReason context_lost_reason = 99 gpu::error::ContextLostReason context_lost_reason =
101 gpu::error::kGpuChannelLost; 100 gpu::error::kGpuChannelLost;
102 if (shared_state_shm_ && shared_state_shm_->memory()) { 101 if (shared_state_shm_ && shared_state_shm_->memory()) {
103 TryUpdateState(); 102 TryUpdateState();
104 // The GPU process might have intentionally been crashed 103 // The GPU process might have intentionally been crashed
105 // (exit_on_context_lost), so try to find out the original reason. 104 // (exit_on_context_lost), so try to find out the original reason.
106 if (last_state_.error == gpu::error::kLostContext) 105 if (last_state_.error == gpu::error::kLostContext)
107 context_lost_reason = last_state_.context_lost_reason; 106 context_lost_reason = last_state_.context_lost_reason;
108 } 107 }
109 OnLostContextNoReentrancy(context_lost_reason, gpu::error::kLostContext); 108 OnDestroyed(context_lost_reason, gpu::error::kLostContext);
110 } 109 }
111 110
112 void CommandBufferProxyImpl::OnDestroyed(gpu::error::ContextLostReason reason, 111 void CommandBufferProxyImpl::OnDestroyed(gpu::error::ContextLostReason reason,
113 gpu::error::Error error) { 112 gpu::error::Error error) {
114 OnLostContextNoReentrancy(reason, error); 113 CheckLock();
114
115 // When the client sees that the context is lost, they should delete this
116 // CommandBufferProxyImpl and create a new one.
117 last_state_.error = error;
118 last_state_.context_lost_reason = reason;
119
120 // Prevent any further messages from being sent, and ensure we only call
121 // the client for lost context a single time.
122 if (channel_) {
123 channel_->DestroyCommandBuffer(this);
124 channel_ = nullptr;
125 if (gpu_control_client_)
126 gpu_control_client_->OnGpuControlLostContext();
127 }
115 } 128 }
116 129
117 void CommandBufferProxyImpl::OnConsoleMessage( 130 void CommandBufferProxyImpl::OnConsoleMessage(
118 const GPUCommandBufferConsoleMessage& message) { 131 const GPUCommandBufferConsoleMessage& message) {
119 if (gpu_control_client_) 132 if (gpu_control_client_)
120 gpu_control_client_->OnGpuControlErrorMessage(message.message.c_str(), 133 gpu_control_client_->OnGpuControlErrorMessage(message.message.c_str(),
121 message.id); 134 message.id);
122 } 135 }
123 136
124 void CommandBufferProxyImpl::AddDeletionObserver(DeletionObserver* observer) { 137 void CommandBufferProxyImpl::AddDeletionObserver(DeletionObserver* observer) {
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 DLOG(ERROR) << "GpuCommandBufferMsg_CreateStreamTexture returned failure"; 499 DLOG(ERROR) << "GpuCommandBufferMsg_CreateStreamTexture returned failure";
487 return 0; 500 return 0;
488 } 501 }
489 return stream_id; 502 return stream_id;
490 } 503 }
491 504
492 void CommandBufferProxyImpl::SetLock(base::Lock* lock) { 505 void CommandBufferProxyImpl::SetLock(base::Lock* lock) {
493 lock_ = lock; 506 lock_ = lock;
494 } 507 }
495 508
509 bool CommandBufferProxyImpl::IsGpuChannelLost() {
510 return !channel_ || channel_->IsLost();
511 }
512
496 void CommandBufferProxyImpl::EnsureWorkVisible() { 513 void CommandBufferProxyImpl::EnsureWorkVisible() {
497 if (channel_) 514 if (channel_)
498 channel_->ValidateFlushIDReachedServer(stream_id_, true); 515 channel_->ValidateFlushIDReachedServer(stream_id_, true);
499 } 516 }
500 517
501 gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const { 518 gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const {
502 return gpu::CommandBufferNamespace::GPU_IO; 519 return gpu::CommandBufferNamespace::GPU_IO;
503 } 520 }
504 521
505 gpu::CommandBufferId CommandBufferProxyImpl::GetCommandBufferID() const { 522 gpu::CommandBufferId CommandBufferProxyImpl::GetCommandBufferID() const {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 697 }
681 698
682 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, 699 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase,
683 base::TimeDelta interval) { 700 base::TimeDelta interval) {
684 if (!update_vsync_parameters_completion_callback_.is_null()) 701 if (!update_vsync_parameters_completion_callback_.is_null())
685 update_vsync_parameters_completion_callback_.Run(timebase, interval); 702 update_vsync_parameters_completion_callback_.Run(timebase, interval);
686 } 703 }
687 704
688 void CommandBufferProxyImpl::InvalidGpuMessage() { 705 void CommandBufferProxyImpl::InvalidGpuMessage() {
689 LOG(ERROR) << "Received invalid message from the GPU process."; 706 LOG(ERROR) << "Received invalid message from the GPU process.";
690 OnLostContextNoReentrancy(gpu::error::kInvalidGpuMessage, 707 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext);
691 gpu::error::kLostContext);
692 } 708 }
693 709
694 void CommandBufferProxyImpl::InvalidGpuReply() { 710 void CommandBufferProxyImpl::InvalidGpuReply() {
711 CheckLock();
695 LOG(ERROR) << "Received invalid reply from the GPU process."; 712 LOG(ERROR) << "Received invalid reply from the GPU process.";
696 // This method may be inside a callstack from the GpuControlClient (we got a 713 last_state_.error = gpu::error::kLostContext;
697 // bad reply to something we are sending to the GPU process). So avoid 714 last_state_.context_lost_reason = gpu::error::kInvalidGpuMessage;
698 // re-entering the GpuControlClient here.
699 OnLostContextAvoidReentrancy(gpu::error::kInvalidGpuMessage,
700 gpu::error::kLostContext);
701 }
702
703 void CommandBufferProxyImpl::OnLostContextAvoidReentrancy(
704 gpu::error::ContextLostReason reason,
705 gpu::error::Error error) {
706 CheckLock();
707 // Set the error and reason immediately, in case clients want to query them
708 // as we unwind the stack.
709 last_state_.error = error;
710 last_state_.context_lost_reason = reason;
711 // Create a fresh call stack to call back to the GpuControlClient. For
712 // cases where we're inside a method that the GpuControlClient called
713 // on us and we don't want to re-enter it.
714 callback_thread_->PostTask( 715 callback_thread_->PostTask(
715 FROM_HERE, 716 FROM_HERE,
716 base::Bind(&CommandBufferProxyImpl::OnLostContextImplFromAvoidReentrancy, 717 base::Bind(&CommandBufferProxyImpl::InvalidGpuReplyOnClientThread,
717 weak_this_)); 718 weak_this_));
718 } 719 }
719 720
720 void CommandBufferProxyImpl::OnLostContextNoReentrancy( 721 void CommandBufferProxyImpl::InvalidGpuReplyOnClientThread() {
721 gpu::error::ContextLostReason reason, 722 std::unique_ptr<base::AutoLock> lock;
722 gpu::error::Error error) {
723 last_state_.error = error;
724 last_state_.context_lost_reason = reason;
725 OnLostContextImpl();
726 }
727
728 void CommandBufferProxyImpl::OnLostContextImplFromAvoidReentrancy() {
729 // This is a fresh call stack so we need to grab the lock.
730 base::Optional<base::AutoLock> hold;
731 if (lock_) 723 if (lock_)
732 hold.emplace(*lock_); 724 lock.reset(new base::AutoLock(*lock_));
733 OnLostContextImpl(); 725 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext);
734 }
735
736 void CommandBufferProxyImpl::OnLostContextImpl() {
737 CheckLock();
738 // Prevent any further messages from being sent, and ensure we only call
739 // the client for lost context a single time.
740 if (!channel_)
741 return;
742 channel_->DestroyCommandBuffer(this);
743 channel_ = nullptr;
744 if (gpu_control_client_)
745 gpu_control_client_->OnGpuControlLostContext();
746 } 726 }
747 727
748 } // namespace gpu 728 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/client/command_buffer_proxy_impl.h ('k') | mojo/gles2/command_buffer_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698