Skip to content

Commit

Permalink
Revert 209673 "gpu: Propagate lost context signal to all contexts"
Browse files Browse the repository at this point in the history
Speculative revert to try to fix 256903

BUG=256903

> gpu: Propagate lost context signal to all contexts
> 
> When any individual command buffer context encounters a context lost
> event, propagate the context lost status to all other contexts if
> gfx::GLContext::LosesAllContextsOnContextLost() is true. This allows
> all command buffer clients to get notified of GPU resets. This is
> useful with virtual contexts because the reset is generally picked
> up by a random virtual context.
> 
> Also, if virtual contexts are being used, all contexts should avoid
> doing GL object cleanup during teardown because the real context has
> already been lost at that point.
> 
> BUG=232449
> TEST=https://www.khronos.org/registry/webgl/conformance-suites/1.0.1/extra/lots-of-polys-example.html
> 
> Review URL: https://chromiumcodereview.appspot.com/17550012

TBR=skyostil@chromium.org

Review URL: https://codereview.chromium.org/18647004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210011 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
crogers@google.com committed Jul 3, 2013
1 parent b249906 commit 37b80b5
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 62 deletions.
7 changes: 0 additions & 7 deletions content/common/gpu/gpu_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -702,13 +702,6 @@ void GpuChannel::LoseAllContexts() {
gpu_channel_manager_->LoseAllContexts();
}

void GpuChannel::MarkAllContextsLost() {
for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
!it.IsAtEnd(); it.Advance()) {
it.GetCurrentValue()->MarkContextLost();
}
}

void GpuChannel::DestroySoon() {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&GpuChannel::OnDestroy, this));
Expand Down
1 change: 0 additions & 1 deletion content/common/gpu/gpu_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class GpuChannel : public IPC::Listener,
GpuCommandBufferStub* LookupCommandBuffer(int32 route_id);

void LoseAllContexts();
void MarkAllContextsLost();

// Destroy channel and all contained contexts.
void DestroySoon();
Expand Down
4 changes: 0 additions & 4 deletions content/common/gpu/gpu_channel_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@ uint64 GpuChannelManager::MessagesProcessed() {
}

void GpuChannelManager::LoseAllContexts() {
for (GpuChannelMap::iterator iter = gpu_channels_.begin();
iter != gpu_channels_.end(); ++iter) {
iter->second->MarkAllContextsLost();
}
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&GpuChannelManager::OnLoseAllContexts,
Expand Down
49 changes: 17 additions & 32 deletions content/common/gpu/gpu_command_buffer_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ bool GpuCommandBufferStub::MakeCurrent() {
DLOG(ERROR) << "Context lost because MakeCurrent failed.";
command_buffer_->SetContextLostReason(decoder_->GetContextLostReason());
command_buffer_->SetParseError(gpu::error::kLostContext);
CheckContextLost();
if (gfx::GLContext::LosesAllContextsOnContextLost())
channel_->LoseAllContexts();
return false;
}

Expand All @@ -360,9 +361,8 @@ void GpuCommandBufferStub::Destroy() {
// destroy it before those.
scheduler_.reset();

gpu::CommandBuffer::State state = command_buffer_->GetState();
bool have_context = false;
if (decoder_ && state.error != gpu::error::kLostContext)
if (decoder_)
have_context = decoder_->MakeCurrent();
FOR_EACH_OBSERVER(DestructionObserver,
destruction_observers_,
Expand Down Expand Up @@ -589,7 +589,10 @@ void GpuCommandBufferStub::OnGetState(IPC::Message* reply_message) {
TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnGetState");
if (command_buffer_) {
gpu::CommandBuffer::State state = command_buffer_->GetState();
CheckContextLost();
if (state.error == gpu::error::kLostContext &&
gfx::GLContext::LosesAllContextsOnContextLost())
channel_->LoseAllContexts();

GpuCommandBufferMsg_GetState::WriteReplyParams(reply_message, state);
} else {
DLOG(ERROR) << "no command_buffer.";
Expand All @@ -613,15 +616,16 @@ void GpuCommandBufferStub::OnParseError() {
GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext(
handle_.is_null(), state.context_lost_reason, active_url_));

CheckContextLost();
}

void GpuCommandBufferStub::OnGetStateFast(IPC::Message* reply_message) {
TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnGetStateFast");
DCHECK(command_buffer_.get());
CheckContextLost();
gpu::CommandBuffer::State state = command_buffer_->GetState();
if (state.error == gpu::error::kLostContext &&
gfx::GLContext::LosesAllContextsOnContextLost())
channel_->LoseAllContexts();

GpuCommandBufferMsg_GetStateFast::WriteReplyParams(reply_message, state);
Send(reply_message);
}
Expand Down Expand Up @@ -708,8 +712,13 @@ void GpuCommandBufferStub::OnCommandProcessed() {
}

void GpuCommandBufferStub::ReportState() {
if (!CheckContextLost())
gpu::CommandBuffer::State state = command_buffer_->GetState();
if (state.error == gpu::error::kLostContext &&
gfx::GLContext::LosesAllContextsOnContextLost()) {
channel_->LoseAllContexts();
} else {
command_buffer_->UpdateState();
}
}

void GpuCommandBufferStub::PutChanged() {
Expand Down Expand Up @@ -925,28 +934,4 @@ void GpuCommandBufferStub::SetMemoryAllocation(
last_memory_allocation_ = allocation;
}

bool GpuCommandBufferStub::CheckContextLost() {
DCHECK(command_buffer_);
gpu::CommandBuffer::State state = command_buffer_->GetState();
bool was_lost = state.error == gpu::error::kLostContext;
// Lose all other contexts if the reset was triggered by the robustness
// extension instead of being synthetic.
if (was_lost && decoder_ && decoder_->WasContextLostByRobustnessExtension() &&
(gfx::GLContext::LosesAllContextsOnContextLost() ||
use_virtualized_gl_context_))
channel_->LoseAllContexts();
return was_lost;
}

void GpuCommandBufferStub::MarkContextLost() {
if (!command_buffer_ ||
command_buffer_->GetState().error == gpu::error::kLostContext)
return;

command_buffer_->SetContextLostReason(gpu::error::kUnknown);
if (decoder_)
decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
command_buffer_->SetParseError(gpu::error::kLostContext);
}

} // namespace content
4 changes: 0 additions & 4 deletions content/common/gpu/gpu_command_buffer_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ class GpuCommandBufferStub

void SetLatencyInfoCallback(const LatencyInfoCallback& callback);

void MarkContextLost();

private:
GpuMemoryManager* GetMemoryManager();
bool MakeCurrent();
Expand Down Expand Up @@ -199,8 +197,6 @@ class GpuCommandBufferStub

void ScheduleDelayedWork(int64 delay);

bool CheckContextLost();

// The lifetime of objects of this class is managed by a GpuChannel. The
// GpuChannels destroy all the GpuCommandBufferStubs that they own when they
// are destroyed. So a raw pointer is safe.
Expand Down
8 changes: 0 additions & 8 deletions gpu/command_buffer/service/gles2_cmd_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,6 @@ class GLES2DecoderImpl : public GLES2Decoder {
size_t GetBackbufferMemoryTotal();

virtual bool WasContextLost() OVERRIDE;
virtual bool WasContextLostByRobustnessExtension() OVERRIDE;
virtual void LoseContext(uint32 reset_status) OVERRIDE;

#if defined(OS_MACOSX)
Expand Down Expand Up @@ -1693,7 +1692,6 @@ class GLES2DecoderImpl : public GLES2Decoder {

bool has_robustness_extension_;
GLenum reset_status_;
bool reset_by_robustness_extension_;

// These flags are used to override the state of the shared feature_info_
// member. Because the same FeatureInfo instance may be shared among many
Expand Down Expand Up @@ -2152,7 +2150,6 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
frame_number_(0),
has_robustness_extension_(false),
reset_status_(GL_NO_ERROR),
reset_by_robustness_extension_(false),
force_webgl_glsl_validation_(false),
derivatives_explicitly_enabled_(false),
frag_depth_explicitly_enabled_(false),
Expand Down Expand Up @@ -9002,7 +8999,6 @@ bool GLES2DecoderImpl::WasContextLost() {
if (status != GL_NO_ERROR) {
// The graphics card was reset. Signal a lost context to the application.
reset_status_ = status;
reset_by_robustness_extension_ = true;
LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen")
<< " context lost via ARB/EXT_robustness. Reset status = "
<< GLES2Util::GetStringEnum(status);
Expand All @@ -9012,10 +9008,6 @@ bool GLES2DecoderImpl::WasContextLost() {
return false;
}

bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() {
return WasContextLost() && reset_by_robustness_extension_;
}

void GLES2DecoderImpl::LoseContext(uint32 reset_status) {
// Only loses the context once.
if (reset_status_ != GL_NO_ERROR) {
Expand Down
6 changes: 1 addition & 5 deletions gpu/command_buffer/service/gles2_cmd_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,9 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>,
virtual base::TimeDelta GetTotalProcessingCommandsTime() = 0;
virtual void AddProcessingCommandsTime(base::TimeDelta) = 0;

// Returns true if the context was lost either by GL_ARB_robustness, forced
// context loss or command buffer parse error.
// Returns true if the context was just lost due to e.g. GL_ARB_robustness.
virtual bool WasContextLost() = 0;

// Returns true if the context was lost specifically by GL_ARB_robustness.
virtual bool WasContextLostByRobustnessExtension() = 0;

// Lose this context.
virtual void LoseContext(uint32 reset_status) = 0;

Expand Down
1 change: 0 additions & 1 deletion gpu/command_buffer/service/gles2_cmd_decoder_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class MockGLES2Decoder : public GLES2Decoder {
MOCK_METHOD0(GetTotalProcessingCommandsTime, base::TimeDelta());
MOCK_METHOD1(AddProcessingCommandsTime, void(base::TimeDelta));
MOCK_METHOD0(WasContextLost, bool());
MOCK_METHOD0(WasContextLostByRobustnessExtension, bool());
MOCK_METHOD1(LoseContext, void(uint32 reset_status));

DISALLOW_COPY_AND_ASSIGN(MockGLES2Decoder);
Expand Down

0 comments on commit 37b80b5

Please sign in to comment.