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

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

Issue 2106103005: Revert of Pass initial size and GPU preference via context attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 manager->shader_translator_cache(), 469 manager->shader_translator_cache(),
470 manager->framebuffer_completeness_cache(), feature_info, 470 manager->framebuffer_completeness_cache(), feature_info,
471 init_params.attribs.bind_generates_resource, 471 init_params.attribs.bind_generates_resource,
472 gmb_factory ? gmb_factory->AsImageFactory() : nullptr); 472 gmb_factory ? gmb_factory->AsImageFactory() : nullptr);
473 } 473 }
474 474
475 #if defined(OS_MACOSX) 475 #if defined(OS_MACOSX)
476 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent 476 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent
477 // performance regressions when enabling FCM. 477 // performance regressions when enabling FCM.
478 // http://crbug.com/180463 478 // http://crbug.com/180463
479 if (init_params.attribs.gpu_preference == gl::PreferIntegratedGpu) 479 if (init_params.gpu_preference == gl::PreferIntegratedGpu)
480 use_virtualized_gl_context_ = true; 480 use_virtualized_gl_context_ = true;
481 #endif 481 #endif
482 482
483 use_virtualized_gl_context_ |= 483 use_virtualized_gl_context_ |=
484 context_group_->feature_info()->workarounds().use_virtualized_gl_contexts; 484 context_group_->feature_info()->workarounds().use_virtualized_gl_contexts;
485 485
486 // MailboxManagerSync synchronization correctness currently depends on having 486 // MailboxManagerSync synchronization correctness currently depends on having
487 // only a single context. See crbug.com/510243 for details. 487 // only a single context. See crbug.com/510243 for details.
488 use_virtualized_gl_context_ |= channel_->mailbox_manager()->UsesSync(); 488 use_virtualized_gl_context_ |= channel_->mailbox_manager()->UsesSync();
489 489
490 gl::GLSurface::Format surface_format = gl::GLSurface::SURFACE_DEFAULT; 490 gl::GLSurface::Format surface_format = gl::GLSurface::SURFACE_DEFAULT;
491 bool offscreen = (surface_handle_ == kNullSurfaceHandle); 491 bool offscreen = (surface_handle_ == kNullSurfaceHandle);
492 gl::GLSurface* default_surface = manager->GetDefaultOffscreenSurface(); 492 gl::GLSurface* default_surface = manager->GetDefaultOffscreenSurface();
493 if (!default_surface) { 493 if (!default_surface) {
494 DLOG(ERROR) << "Failed to create default offscreen surface."; 494 DLOG(ERROR) << "Failed to create default offscreen surface.";
495 return false; 495 return false;
496 } 496 }
497 #if defined(OS_ANDROID) 497 #if defined(OS_ANDROID)
498 if (init_params.attribs.red_size <= 5 && 498 if (init_params.attribs.red_size <= 5 &&
499 init_params.attribs.green_size <= 6 && 499 init_params.attribs.green_size <= 6 &&
500 init_params.attribs.blue_size <= 5 && 500 init_params.attribs.blue_size <= 5 &&
501 init_params.attribs.alpha_size == 0) 501 init_params.attribs.alpha_size == 0)
502 surface_format = gl::GLSurface::SURFACE_RGB565; 502 surface_format = gl::GLSurface::SURFACE_RGB565;
503 // We can only use virtualized contexts for onscreen command buffers if their 503 // We can only use virtualized contexts for onscreen command buffers if their
504 // config is compatible with the offscreen ones - otherwise MakeCurrent fails. 504 // config is compatible with the offscreen ones - otherwise MakeCurrent fails.
505 if (surface_format != default_surface->GetFormat() && !offscreen) 505 if (surface_format != default_surface->GetFormat() && !offscreen)
506 use_virtualized_gl_context_ = false; 506 use_virtualized_gl_context_ = false;
507 #endif 507 #endif
508 508
509 gfx::Size initial_size = init_params.size;
510 if (offscreen && initial_size.IsEmpty()) {
511 // If we're an offscreen surface with zero width and/or height, set to a
512 // non-zero size so that we have a complete framebuffer for operations like
513 // glClear.
514 initial_size = gfx::Size(1, 1);
515 }
516
509 command_buffer_.reset(new CommandBufferService( 517 command_buffer_.reset(new CommandBufferService(
510 context_group_->transfer_buffer_manager())); 518 context_group_->transfer_buffer_manager()));
511 519
512 decoder_.reset(gles2::GLES2Decoder::Create(context_group_.get())); 520 decoder_.reset(gles2::GLES2Decoder::Create(context_group_.get()));
513 executor_.reset(new CommandExecutor(command_buffer_.get(), decoder_.get(), 521 executor_.reset(new CommandExecutor(command_buffer_.get(), decoder_.get(),
514 decoder_.get())); 522 decoder_.get()));
515 sync_point_client_ = channel_->sync_point_manager()->CreateSyncPointClient( 523 sync_point_client_ = channel_->sync_point_manager()->CreateSyncPointClient(
516 channel_->GetSyncPointOrderData(stream_id_), 524 channel_->GetSyncPointOrderData(stream_id_),
517 CommandBufferNamespace::GPU_IO, command_buffer_id_); 525 CommandBufferNamespace::GPU_IO, command_buffer_id_);
518 526
(...skipping 12 matching lines...) Expand all
531 return false; 539 return false;
532 } 540 }
533 } 541 }
534 542
535 scoped_refptr<gl::GLContext> context; 543 scoped_refptr<gl::GLContext> context;
536 gl::GLShareGroup* gl_share_group = channel_->share_group(); 544 gl::GLShareGroup* gl_share_group = channel_->share_group();
537 if (use_virtualized_gl_context_ && gl_share_group) { 545 if (use_virtualized_gl_context_ && gl_share_group) {
538 context = gl_share_group->GetSharedContext(); 546 context = gl_share_group->GetSharedContext();
539 if (!context.get()) { 547 if (!context.get()) {
540 context = gl::init::CreateGLContext(gl_share_group, default_surface, 548 context = gl::init::CreateGLContext(gl_share_group, default_surface,
541 init_params.attribs.gpu_preference); 549 init_params.gpu_preference);
542 if (!context.get()) { 550 if (!context.get()) {
543 DLOG(ERROR) << "Failed to create shared context for virtualization."; 551 DLOG(ERROR) << "Failed to create shared context for virtualization.";
544 return false; 552 return false;
545 } 553 }
546 // Ensure that context creation did not lose track of the intended 554 // Ensure that context creation did not lose track of the intended
547 // gl_share_group. 555 // gl_share_group.
548 DCHECK(context->share_group() == gl_share_group); 556 DCHECK(context->share_group() == gl_share_group);
549 gl_share_group->SetSharedContext(context.get()); 557 gl_share_group->SetSharedContext(context.get());
550 } 558 }
551 // This should be either: 559 // This should be either:
552 // (1) a non-virtual GL context, or 560 // (1) a non-virtual GL context, or
553 // (2) a mock context. 561 // (2) a mock context.
554 DCHECK(context->GetHandle() || 562 DCHECK(context->GetHandle() ||
555 gl::GetGLImplementation() == gl::kGLImplementationMockGL); 563 gl::GetGLImplementation() == gl::kGLImplementationMockGL);
556 context = new GLContextVirtual( 564 context = new GLContextVirtual(
557 gl_share_group, context.get(), decoder_->AsWeakPtr()); 565 gl_share_group, context.get(), decoder_->AsWeakPtr());
558 if (!context->Initialize(surface_.get(), 566 if (!context->Initialize(surface_.get(), init_params.gpu_preference)) {
559 init_params.attribs.gpu_preference)) {
560 // The real context created above for the default offscreen surface 567 // The real context created above for the default offscreen surface
561 // might not be compatible with this surface. 568 // might not be compatible with this surface.
562 context = NULL; 569 context = NULL;
563 DLOG(ERROR) << "Failed to initialize virtual GL context."; 570 DLOG(ERROR) << "Failed to initialize virtual GL context.";
564 return false; 571 return false;
565 } 572 }
566 } 573 }
567 if (!context.get()) { 574 if (!context.get()) {
568 context = gl::init::CreateGLContext(gl_share_group, surface_.get(), 575 context = gl::init::CreateGLContext(gl_share_group, surface_.get(),
569 init_params.attribs.gpu_preference); 576 init_params.gpu_preference);
570 } 577 }
571 if (!context.get()) { 578 if (!context.get()) {
572 DLOG(ERROR) << "Failed to create context."; 579 DLOG(ERROR) << "Failed to create context.";
573 return false; 580 return false;
574 } 581 }
575 582
576 if (!context->MakeCurrent(surface_.get())) { 583 if (!context->MakeCurrent(surface_.get())) {
577 LOG(ERROR) << "Failed to make context current."; 584 LOG(ERROR) << "Failed to make context current.";
578 return false; 585 return false;
579 } 586 }
580 587
581 if (!context->GetGLStateRestorer()) { 588 if (!context->GetGLStateRestorer()) {
582 context->SetGLStateRestorer( 589 context->SetGLStateRestorer(
583 new GLStateRestorerImpl(decoder_->AsWeakPtr())); 590 new GLStateRestorerImpl(decoder_->AsWeakPtr()));
584 } 591 }
585 592
586 if (!context_group_->has_program_cache() && 593 if (!context_group_->has_program_cache() &&
587 !context_group_->feature_info()->workarounds().disable_program_cache) { 594 !context_group_->feature_info()->workarounds().disable_program_cache) {
588 context_group_->set_program_cache(manager->program_cache()); 595 context_group_->set_program_cache(manager->program_cache());
589 } 596 }
590 597
591 // Initialize the decoder with either the view or pbuffer GLContext. 598 // Initialize the decoder with either the view or pbuffer GLContext.
592 if (!decoder_->Initialize(surface_, context, offscreen, 599 if (!decoder_->Initialize(surface_, context, offscreen, initial_size,
593 gpu::gles2::DisallowedFeatures(), 600 gpu::gles2::DisallowedFeatures(),
594 init_params.attribs)) { 601 init_params.attribs)) {
595 DLOG(ERROR) << "Failed to initialize decoder."; 602 DLOG(ERROR) << "Failed to initialize decoder.";
596 return false; 603 return false;
597 } 604 }
598 605
599 if (manager->gpu_preferences().enable_gpu_service_logging) { 606 if (manager->gpu_preferences().enable_gpu_service_logging) {
600 decoder_->set_log_commands(true); 607 decoder_->set_log_commands(true);
601 } 608 }
602 609
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); 1120 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params));
1114 } 1121 }
1115 1122
1116 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1123 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1117 base::TimeDelta interval) { 1124 base::TimeDelta interval) {
1118 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1125 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1119 interval)); 1126 interval));
1120 } 1127 }
1121 1128
1122 } // namespace gpu 1129 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/gpu_channel_unittest.cc ('k') | ui/compositor/test/in_process_context_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698