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

Side by Side Diff: content/renderer/gpu/renderer_gl_context.cc

Issue 7301010: Fixed improper destruction of transfer buffers that are still in use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gpu/command_buffer/common/constants.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/renderer/gpu/renderer_gl_context.h" 5 #include "content/renderer/gpu/renderer_gl_context.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 20 matching lines...) Expand all
31 #endif // ENABLE_GPU 31 #endif // ENABLE_GPU
32 32
33 namespace { 33 namespace {
34 34
35 const int32 kCommandBufferSize = 1024 * 1024; 35 const int32 kCommandBufferSize = 1024 * 1024;
36 // TODO(kbr): make the transfer buffer size configurable via context 36 // TODO(kbr): make the transfer buffer size configurable via context
37 // creation attributes. 37 // creation attributes.
38 const int32 kTransferBufferSize = 1024 * 1024; 38 const int32 kTransferBufferSize = 1024 * 1024;
39 39
40 const uint32 kMaxLatchesPerRenderer = 2048; 40 const uint32 kMaxLatchesPerRenderer = 2048;
41 const uint32 kInvalidLatchId = 0xffffffffu;
42 41
43 // Singleton used to initialize and terminate the gles2 library. 42 // Singleton used to initialize and terminate the gles2 library.
44 class GLES2Initializer { 43 class GLES2Initializer {
45 public: 44 public:
46 GLES2Initializer() { 45 GLES2Initializer() {
47 gles2::Initialize(); 46 gles2::Initialize();
48 } 47 }
49 48
50 ~GLES2Initializer() { 49 ~GLES2Initializer() {
51 gles2::Terminate(); 50 gles2::Terminate();
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 373 }
375 374
376 gpu::gles2::GLES2Implementation* RendererGLContext::GetImplementation() { 375 gpu::gles2::GLES2Implementation* RendererGLContext::GetImplementation() {
377 return gles2_implementation_; 376 return gles2_implementation_;
378 } 377 }
379 378
380 RendererGLContext::RendererGLContext(GpuChannelHost* channel) 379 RendererGLContext::RendererGLContext(GpuChannelHost* channel)
381 : channel_(channel), 380 : channel_(channel),
382 parent_(base::WeakPtr<RendererGLContext>()), 381 parent_(base::WeakPtr<RendererGLContext>()),
383 parent_texture_id_(0), 382 parent_texture_id_(0),
384 child_to_parent_latch_(kInvalidLatchId), 383 child_to_parent_latch_(gpu::kInvalidLatchId),
385 parent_to_child_latch_(kInvalidLatchId), 384 parent_to_child_latch_(gpu::kInvalidLatchId),
386 latch_transfer_buffer_id_(-1), 385 latch_transfer_buffer_id_(-1),
387 command_buffer_(NULL), 386 command_buffer_(NULL),
388 gles2_helper_(NULL), 387 gles2_helper_(NULL),
389 transfer_buffer_id_(-1), 388 transfer_buffer_id_(-1),
390 gles2_implementation_(NULL), 389 gles2_implementation_(NULL),
391 last_error_(SUCCESS), 390 last_error_(SUCCESS),
392 frame_number_(0) { 391 frame_number_(0) {
393 DCHECK(channel); 392 DCHECK(channel);
394 } 393 }
395 394
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 return true; 531 return true;
533 } 532 }
534 533
535 void RendererGLContext::Destroy() { 534 void RendererGLContext::Destroy() {
536 TRACE_EVENT0("gpu", "RendererGLContext::Destroy"); 535 TRACE_EVENT0("gpu", "RendererGLContext::Destroy");
537 SetParent(NULL); 536 SetParent(NULL);
538 537
539 delete gles2_implementation_; 538 delete gles2_implementation_;
540 gles2_implementation_ = NULL; 539 gles2_implementation_ = NULL;
541 540
542 if (child_to_parent_latch_ != kInvalidLatchId) { 541 // Do not destroy these transfer buffers here, because commands are still
543 DestroyLatch(child_to_parent_latch_); 542 // in flight on the GPU process that may access them. When the command buffer
544 child_to_parent_latch_ = kInvalidLatchId; 543 // is destroyed, the associated shared memory will be cleaned up.
545 } 544 latch_transfer_buffer_id_ = -1;
546 if (parent_to_child_latch_ != kInvalidLatchId) { 545 transfer_buffer_id_ = -1;
547 DestroyLatch(parent_to_child_latch_);
548 parent_to_child_latch_ = kInvalidLatchId;
549 }
550 if (command_buffer_ && latch_transfer_buffer_id_ != -1) {
551 command_buffer_->DestroyTransferBuffer(latch_transfer_buffer_id_);
552 latch_transfer_buffer_id_ = -1;
553 }
554
555 if (command_buffer_ && transfer_buffer_id_ != -1) {
556 command_buffer_->DestroyTransferBuffer(transfer_buffer_id_);
557 transfer_buffer_id_ = -1;
558 }
559 546
560 delete gles2_helper_; 547 delete gles2_helper_;
561 gles2_helper_ = NULL; 548 gles2_helper_ = NULL;
562 549
563 if (channel_ && command_buffer_) { 550 if (channel_ && command_buffer_) {
564 channel_->DestroyCommandBuffer(command_buffer_); 551 channel_->DestroyCommandBuffer(command_buffer_);
565 command_buffer_ = NULL; 552 command_buffer_ = NULL;
566 } 553 }
567 554
568 channel_ = NULL; 555 channel_ = NULL;
556
557 // Destroy latches here, after the command buffer is destroyed so that no
558 // commands are still in flight that may access the latch memory.
559 if (child_to_parent_latch_ != gpu::kInvalidLatchId) {
560 DestroyLatch(child_to_parent_latch_);
561 child_to_parent_latch_ = gpu::kInvalidLatchId;
562 }
563 if (parent_to_child_latch_ != gpu::kInvalidLatchId) {
564 DestroyLatch(parent_to_child_latch_);
565 parent_to_child_latch_ = gpu::kInvalidLatchId;
566 }
569 } 567 }
570 568
571 void RendererGLContext::OnSwapBuffers() { 569 void RendererGLContext::OnSwapBuffers() {
572 if (swap_buffers_callback_.get()) 570 if (swap_buffers_callback_.get())
573 swap_buffers_callback_->Run(); 571 swap_buffers_callback_->Run();
574 } 572 }
575 573
576 void RendererGLContext::OnContextLost() { 574 void RendererGLContext::OnContextLost() {
577 if (context_lost_callback_.get()) 575 if (context_lost_callback_.get())
578 context_lost_callback_->Run(); 576 context_lost_callback_->Run();
579 } 577 }
580 578
581 bool RendererGLContext::CreateLatch(uint32* ret_latch) { 579 bool RendererGLContext::CreateLatch(uint32* ret_latch) {
582 return LatchAllocator::GetInstance()->AllocateLatch(ret_latch); 580 return LatchAllocator::GetInstance()->AllocateLatch(ret_latch);
583 } 581 }
584 582
585 bool RendererGLContext::DestroyLatch(uint32 latch) { 583 bool RendererGLContext::DestroyLatch(uint32 latch) {
586 return LatchAllocator::GetInstance()->FreeLatch(latch); 584 return LatchAllocator::GetInstance()->FreeLatch(latch);
587 } 585 }
588 586
589 bool RendererGLContext::GetParentToChildLatch(uint32* parent_to_child_latch) { 587 bool RendererGLContext::GetParentToChildLatch(uint32* parent_to_child_latch) {
590 *parent_to_child_latch = parent_to_child_latch_; 588 *parent_to_child_latch = parent_to_child_latch_;
591 return true; 589 return true;
592 } 590 }
593 591
594 bool RendererGLContext::GetChildToParentLatch(uint32* child_to_parent_latch) { 592 bool RendererGLContext::GetChildToParentLatch(uint32* child_to_parent_latch) {
595 *child_to_parent_latch = child_to_parent_latch_; 593 *child_to_parent_latch = child_to_parent_latch_;
596 return true; 594 return true;
597 } 595 }
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/common/constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698