summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-31 22:04:28 +0000
committerkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-31 22:04:28 +0000
commit20322ca10771c6b24d961bfeedcc67f919bbb694 (patch)
tree619bfba477f77bd0641fc658eef54c4f6eab19cb /content
parent6ab47081940ab41e44b6d172306a98688a54fea3 (diff)
downloadchromium_src-20322ca10771c6b24d961bfeedcc67f919bbb694.zip
chromium_src-20322ca10771c6b24d961bfeedcc67f919bbb694.tar.gz
chromium_src-20322ca10771c6b24d961bfeedcc67f919bbb694.tar.bz2
Upon receiving OnError callback against a context, only clear the set of created contexts if the receiving context is live. Otherwise, it will break sharing among more recently created contexts.
BUG=121780,125246,125416,126044 TEST=test cases from above bugs on MacBook Pro with AMD GPU running 10.7.3; more self-contained tests will be created under other bug IDs Review URL: https://chromiumcodereview.appspot.com/10446093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc28
1 files changed, 27 insertions, 1 deletions
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
index bcce813..e59a87e 100644
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
@@ -45,6 +45,26 @@ void ClearSharedContexts() {
g_all_shared_contexts.Pointer()->clear();
}
+void ClearSharedContextsIfInShareSet(
+ WebGraphicsContext3DCommandBufferImpl* context) {
+ // If the given context isn't in the share set, that means that it
+ // or another context it was previously sharing with already
+ // provoked a lost context. Other contexts might have since been
+ // successfully created and added to the share set, so do not clear
+ // out the share set unless we know that all the contexts in there
+ // are supposed to be lost simultaneously.
+ base::AutoLock lock(g_all_shared_contexts_lock.Get());
+ std::set<WebGraphicsContext3DCommandBufferImpl*>* share_set =
+ g_all_shared_contexts.Pointer();
+ for (std::set<WebGraphicsContext3DCommandBufferImpl*>::iterator iter =
+ share_set->begin(); iter != share_set->end(); ++iter) {
+ if (context == *iter) {
+ share_set->clear();
+ return;
+ }
+ }
+}
+
const int32 kCommandBufferSize = 1024 * 1024;
// TODO(kbr): make the transfer buffer size configurable via context
// creation attributes.
@@ -140,6 +160,9 @@ WebGraphicsContext3DCommandBufferImpl::
if (host_) {
if (host_->WillGpuSwitchOccur(false, gpu_preference_)) {
host_->ForciblyCloseChannel();
+ TRACE_EVENT0(
+ "gpu",
+ "WebGfxCtx3DCmdBfrImpl::~WebGfxCtx3DCmdBfrImpl closed channel");
ClearSharedContexts();
}
}
@@ -192,6 +215,9 @@ bool WebGraphicsContext3DCommandBufferImpl::Initialize(
// channel and recreate it.
if (host_->WillGpuSwitchOccur(true, gpu_preference_)) {
host_->ForciblyCloseChannel();
+ TRACE_EVENT0(
+ "gpu",
+ "WebGfxCtx3DCmdBfrImpl::Initialize closed channel");
ClearSharedContexts();
retry = true;
}
@@ -1515,7 +1541,7 @@ void WebGraphicsContext3DCommandBufferImpl::OnContextLost() {
context_lost_callback_->onContextLost();
}
if (attributes_.shareResources)
- ClearSharedContexts();
+ ClearSharedContextsIfInShareSet(this);
if (ShouldUseSwapClient())
swap_client_->OnViewContextSwapBuffersAborted();
}