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

Side by Side Diff: gpu/ipc/service/gpu_command_buffer_stub.cc

Issue 2693333003: Don't use a global share group for the passthrough command buffer contexts. (Closed)
Patch Set: Created 3 years, 10 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
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/service/gpu_command_buffer_stub.h" 5 #include "gpu/ipc/service/gpu_command_buffer_stub.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 523
524 bool have_context = false; 524 bool have_context = false;
525 if (decoder_ && decoder_->GetGLContext()) { 525 if (decoder_ && decoder_->GetGLContext()) {
526 // Try to make the context current regardless of whether it was lost, so we 526 // Try to make the context current regardless of whether it was lost, so we
527 // don't leak resources. 527 // don't leak resources.
528 have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); 528 have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get());
529 } 529 }
530 for (auto& observer : destruction_observers_) 530 for (auto& observer : destruction_observers_)
531 observer.OnWillDestroyStub(); 531 observer.OnWillDestroyStub();
532 532
533 share_group_ = nullptr;
534
533 // Remove this after crbug.com/248395 is sorted out. 535 // Remove this after crbug.com/248395 is sorted out.
534 // Destroy the surface before the context, some surface destructors make GL 536 // Destroy the surface before the context, some surface destructors make GL
535 // calls. 537 // calls.
536 surface_ = nullptr; 538 surface_ = nullptr;
537 539
538 if (decoder_) { 540 if (decoder_) {
539 decoder_->Destroy(have_context); 541 decoder_->Destroy(have_context);
540 decoder_.reset(); 542 decoder_.reset();
541 } 543 }
542 544
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } else { 632 } else {
631 surface_ = ImageTransportSurface::CreateNativeSurface( 633 surface_ = ImageTransportSurface::CreateNativeSurface(
632 AsWeakPtr(), surface_handle_, surface_format); 634 AsWeakPtr(), surface_handle_, surface_format);
633 if (!surface_ || !surface_->Initialize(surface_format)) { 635 if (!surface_ || !surface_->Initialize(surface_format)) {
634 surface_ = nullptr; 636 surface_ = nullptr;
635 DLOG(ERROR) << "Failed to create surface."; 637 DLOG(ERROR) << "Failed to create surface.";
636 return false; 638 return false;
637 } 639 }
638 } 640 }
639 641
642 if (context_group_->gpu_preferences().use_passthrough_cmd_decoder) {
643 // When using the passthrough command decoder, only share with other
644 // contexts in the explicitly requested share group
645 if (share_command_buffer_stub) {
646 share_group_ = share_command_buffer_stub->share_group_;
647 } else {
648 share_group_ = new gl::GLShareGroup();
649 }
650 } else {
651 // When using the validating command decoder, always use the global share
652 // group
653 share_group_ = channel_->share_group();
654 }
655
640 scoped_refptr<gl::GLContext> context; 656 scoped_refptr<gl::GLContext> context;
641 gl::GLShareGroup* gl_share_group = channel_->share_group(); 657 if (use_virtualized_gl_context_ && share_group_) {
642 if (use_virtualized_gl_context_ && gl_share_group) { 658 context = share_group_->GetSharedContext(surface_.get());
643 context = gl_share_group->GetSharedContext(surface_.get());
644 if (!context.get()) { 659 if (!context.get()) {
645 context = gl::init::CreateGLContext( 660 context = gl::init::CreateGLContext(
646 gl_share_group, surface_.get(), 661 share_group_.get(), surface_.get(),
647 GenerateGLContextAttribs(init_params.attribs, 662 GenerateGLContextAttribs(init_params.attribs,
648 context_group_->gpu_preferences())); 663 context_group_->gpu_preferences()));
649 if (!context.get()) { 664 if (!context.get()) {
650 DLOG(ERROR) << "Failed to create shared context for virtualization."; 665 DLOG(ERROR) << "Failed to create shared context for virtualization.";
651 return false; 666 return false;
652 } 667 }
653 // Ensure that context creation did not lose track of the intended 668 // Ensure that context creation did not lose track of the intended share
654 // gl_share_group. 669 // group.
655 DCHECK(context->share_group() == gl_share_group); 670 DCHECK(context->share_group() == share_group_.get());
656 gl_share_group->SetSharedContext(surface_.get(), context.get()); 671 share_group_->SetSharedContext(surface_.get(), context.get());
657 } 672 }
658 // This should be either: 673 // This should be either:
659 // (1) a non-virtual GL context, or 674 // (1) a non-virtual GL context, or
660 // (2) a mock/stub context. 675 // (2) a mock/stub context.
661 DCHECK(context->GetHandle() || 676 DCHECK(context->GetHandle() ||
662 gl::GetGLImplementation() == gl::kGLImplementationMockGL || 677 gl::GetGLImplementation() == gl::kGLImplementationMockGL ||
663 gl::GetGLImplementation() == gl::kGLImplementationStubGL); 678 gl::GetGLImplementation() == gl::kGLImplementationStubGL);
664 context = new GLContextVirtual( 679 context = new GLContextVirtual(share_group_.get(), context.get(),
665 gl_share_group, context.get(), decoder_->AsWeakPtr()); 680 decoder_->AsWeakPtr());
666 if (!context->Initialize( 681 if (!context->Initialize(
667 surface_.get(), 682 surface_.get(),
668 GenerateGLContextAttribs(init_params.attribs, 683 GenerateGLContextAttribs(init_params.attribs,
669 context_group_->gpu_preferences()))) { 684 context_group_->gpu_preferences()))) {
670 // The real context created above for the default offscreen surface 685 // The real context created above for the default offscreen surface
671 // might not be compatible with this surface. 686 // might not be compatible with this surface.
672 context = NULL; 687 context = NULL;
673 DLOG(ERROR) << "Failed to initialize virtual GL context."; 688 DLOG(ERROR) << "Failed to initialize virtual GL context.";
674 return false; 689 return false;
675 } 690 }
676 } 691 }
677 if (!context.get()) { 692 if (!context.get()) {
678 context = gl::init::CreateGLContext( 693 context = gl::init::CreateGLContext(
679 gl_share_group, surface_.get(), 694 share_group_.get(), surface_.get(),
680 GenerateGLContextAttribs(init_params.attribs, 695 GenerateGLContextAttribs(init_params.attribs,
681 context_group_->gpu_preferences())); 696 context_group_->gpu_preferences()));
682 } 697 }
683 if (!context.get()) { 698 if (!context.get()) {
684 DLOG(ERROR) << "Failed to create context."; 699 DLOG(ERROR) << "Failed to create context.";
685 return false; 700 return false;
686 } 701 }
687 702
688 if (!context->MakeCurrent(surface_.get())) { 703 if (!context->MakeCurrent(surface_.get())) {
689 LOG(ERROR) << "Failed to make context current."; 704 LOG(ERROR) << "Failed to make context current.";
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 command_buffer_->GetLastState().error == error::kLostContext) 1221 command_buffer_->GetLastState().error == error::kLostContext)
1207 return; 1222 return;
1208 1223
1209 command_buffer_->SetContextLostReason(error::kUnknown); 1224 command_buffer_->SetContextLostReason(error::kUnknown);
1210 if (decoder_) 1225 if (decoder_)
1211 decoder_->MarkContextLost(error::kUnknown); 1226 decoder_->MarkContextLost(error::kUnknown);
1212 command_buffer_->SetParseError(error::kLostContext); 1227 command_buffer_->SetParseError(error::kLostContext);
1213 } 1228 }
1214 1229
1215 } // namespace gpu 1230 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698