summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-07 20:44:33 +0000
committerjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-07 20:44:33 +0000
commit16adff66ea7224ddd91d01160a7bcc54f5d8b5a6 (patch)
tree89f6964ede070dc3809db976e6528f0f11d993a1
parentf3d5a44568be26375eac9daa7c1a69e36ea6f1bf (diff)
downloadchromium_src-16adff66ea7224ddd91d01160a7bcc54f5d8b5a6.zip
chromium_src-16adff66ea7224ddd91d01160a7bcc54f5d8b5a6.tar.gz
chromium_src-16adff66ea7224ddd91d01160a7bcc54f5d8b5a6.tar.bz2
We were synchronously destroying the RendererGlContext transfer buffers while commands may still be pending in the command buffer that use them. This generated spurious kOutOfBounds errors. kOutOfBounds errors cause us to kill the associated GpuChannel. That leads to lots of bad behavior, such as failing to reload certain WebGL demos.
This change simply lets the command buffer destroy the shared memory in its destructor instead of destroying them explicitly. The GPU-side resources are cleaned up when the command buffer is destroyed. BUG=88115 TEST=Open NVIDIA Command Buffer Object WebGL demo; Refresh; Verify successful refresh. Review URL: http://codereview.chromium.org/7301010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91747 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/gpu/renderer_gl_context.cc38
-rw-r--r--gpu/command_buffer/common/constants.h2
2 files changed, 19 insertions, 21 deletions
diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc
index b245716..5b61c8a 100644
--- a/content/renderer/gpu/renderer_gl_context.cc
+++ b/content/renderer/gpu/renderer_gl_context.cc
@@ -38,7 +38,6 @@ const int32 kCommandBufferSize = 1024 * 1024;
const int32 kTransferBufferSize = 1024 * 1024;
const uint32 kMaxLatchesPerRenderer = 2048;
-const uint32 kInvalidLatchId = 0xffffffffu;
// Singleton used to initialize and terminate the gles2 library.
class GLES2Initializer {
@@ -381,8 +380,8 @@ RendererGLContext::RendererGLContext(GpuChannelHost* channel)
: channel_(channel),
parent_(base::WeakPtr<RendererGLContext>()),
parent_texture_id_(0),
- child_to_parent_latch_(kInvalidLatchId),
- parent_to_child_latch_(kInvalidLatchId),
+ child_to_parent_latch_(gpu::kInvalidLatchId),
+ parent_to_child_latch_(gpu::kInvalidLatchId),
latch_transfer_buffer_id_(-1),
command_buffer_(NULL),
gles2_helper_(NULL),
@@ -539,23 +538,11 @@ void RendererGLContext::Destroy() {
delete gles2_implementation_;
gles2_implementation_ = NULL;
- if (child_to_parent_latch_ != kInvalidLatchId) {
- DestroyLatch(child_to_parent_latch_);
- child_to_parent_latch_ = kInvalidLatchId;
- }
- if (parent_to_child_latch_ != kInvalidLatchId) {
- DestroyLatch(parent_to_child_latch_);
- parent_to_child_latch_ = kInvalidLatchId;
- }
- if (command_buffer_ && latch_transfer_buffer_id_ != -1) {
- command_buffer_->DestroyTransferBuffer(latch_transfer_buffer_id_);
- latch_transfer_buffer_id_ = -1;
- }
-
- if (command_buffer_ && transfer_buffer_id_ != -1) {
- command_buffer_->DestroyTransferBuffer(transfer_buffer_id_);
- transfer_buffer_id_ = -1;
- }
+ // Do not destroy these transfer buffers here, because commands are still
+ // in flight on the GPU process that may access them. When the command buffer
+ // is destroyed, the associated shared memory will be cleaned up.
+ latch_transfer_buffer_id_ = -1;
+ transfer_buffer_id_ = -1;
delete gles2_helper_;
gles2_helper_ = NULL;
@@ -566,6 +553,17 @@ void RendererGLContext::Destroy() {
}
channel_ = NULL;
+
+ // Destroy latches here, after the command buffer is destroyed so that no
+ // commands are still in flight that may access the latch memory.
+ if (child_to_parent_latch_ != gpu::kInvalidLatchId) {
+ DestroyLatch(child_to_parent_latch_);
+ child_to_parent_latch_ = gpu::kInvalidLatchId;
+ }
+ if (parent_to_child_latch_ != gpu::kInvalidLatchId) {
+ DestroyLatch(parent_to_child_latch_);
+ parent_to_child_latch_ = gpu::kInvalidLatchId;
+ }
}
void RendererGLContext::OnSwapBuffers() {
diff --git a/gpu/command_buffer/common/constants.h b/gpu/command_buffer/common/constants.h
index 3b06cad..873dfa0 100644
--- a/gpu/command_buffer/common/constants.h
+++ b/gpu/command_buffer/common/constants.h
@@ -57,7 +57,7 @@ const int32 kCommandBufferSharedMemoryId = 4;
const int32 kLatchSharedMemoryId = 5;
// Invalid latch ID.
-const int32 kInvalidLatchId = 0xffffffffu;
+const uint32 kInvalidLatchId = 0xffffffffu;
} // namespace gpu