diff options
author | piman <piman@chromium.org> | 2016-01-12 07:35:31 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-12 15:36:26 +0000 |
commit | 990d8ea8ff1f46b1f0dde0f85677e1c27cfa5482 (patch) | |
tree | 5239cc6aa446538b201e14e7dc7f8f9d7395d2a0 | |
parent | 1fb58f101f2f9f79ca965eb423a7913d64c5e01e (diff) | |
download | chromium_src-990d8ea8ff1f46b1f0dde0f85677e1c27cfa5482.zip chromium_src-990d8ea8ff1f46b1f0dde0f85677e1c27cfa5482.tar.gz chromium_src-990d8ea8ff1f46b1f0dde0f85677e1c27cfa5482.tar.bz2 |
Allow GPU channels to be created when using SwiftShader
When using SwiftShader, we still need a GPU channel for webgl, but we need to
make sure the renderer compositor falls back to software.
BUG=576500
Review URL: https://codereview.chromium.org/1575293002
Cr-Commit-Position: refs/heads/master@{#368882}
-rw-r--r-- | content/browser/gpu/gpu_process_host.cc | 4 | ||||
-rw-r--r-- | content/browser/gpu/gpu_process_host.h | 4 | ||||
-rw-r--r-- | content/browser/renderer_host/gpu_message_filter.cc | 6 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 55 | ||||
-rw-r--r-- | content/renderer/render_widget.h | 2 |
5 files changed, 33 insertions, 38 deletions
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index 45eaf1a..ad9cafe 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -807,6 +807,7 @@ void GpuProcessHost::CreateArcVideoAcceleratorChannel( void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", result); initialized_ = result; + gpu_info_ = gpu_info; if (!initialized_) GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); @@ -842,8 +843,7 @@ void GpuProcessHost::OnChannelEstablished( return; } - callback.Run(channel_handle, - GpuDataManagerImpl::GetInstance()->GetGPUInfo()); + callback.Run(channel_handle, gpu_info_); } void GpuProcessHost::OnCommandBufferCreated(CreateCommandBufferResult result) { diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h index ec94b98..3fb0c00 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h @@ -275,6 +275,10 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, bool swiftshader_rendering_; GpuProcessKind kind_; + // The GPUInfo for the connected process. Only valid after initialized_ is + // true. + gpu::GPUInfo gpu_info_; + scoped_ptr<base::Thread> in_process_gpu_thread_; // Whether we actually launched a GPU process. diff --git a/content/browser/renderer_host/gpu_message_filter.cc b/content/browser/renderer_host/gpu_message_filter.cc index c381a15..73f4077 100644 --- a/content/browser/renderer_host/gpu_message_filter.cc +++ b/content/browser/renderer_host/gpu_message_filter.cc @@ -44,12 +44,6 @@ void GpuMessageFilter::OnEstablishGpuChannel( IPC::Message* reply_ptr) { DCHECK_CURRENTLY_ON(BrowserThread::IO); scoped_ptr<IPC::Message> reply(reply_ptr); - if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { - reply->set_reply_error(); - Send(reply.release()); - return; - } - GpuProcessHost* host = GpuProcessHost::FromID(gpu_process_id_); if (!host) { host = GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index a541369..56612ca 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -958,6 +958,7 @@ GURL RenderWidget::GetURLForGraphicsContext3D() { } scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { + DCHECK(webwidget_); // For widgets that are never visible, we don't start the compositor, so we // never get a request for a cc::OutputSurface. DCHECK(!compositor_never_visible_); @@ -976,15 +977,29 @@ scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { } #endif - scoped_refptr<ContextProviderCommandBuffer> context_provider; - scoped_refptr<ContextProviderCommandBuffer> worker_context_provider; + scoped_refptr<GpuChannelHost> gpu_channel_host; if (!use_software) { - context_provider = ContextProviderCommandBuffer::Create( - CreateGraphicsContext3D(true), RENDER_COMPOSITOR_CONTEXT); - if (!context_provider.get()) { + CauseForGpuLaunch cause = + CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; + gpu_channel_host = + RenderThreadImpl::current()->EstablishGpuChannelSync(cause); + if (!gpu_channel_host.get()) { // Cause the compositor to wait and try again. return nullptr; } + // We may get a valid channel, but with a software renderer. In that case, + // disable GPU compositing. + if (gpu_channel_host->gpu_info().software_rendering) + use_software = true; + } + + scoped_refptr<ContextProviderCommandBuffer> context_provider; + scoped_refptr<ContextProviderCommandBuffer> worker_context_provider; + if (!use_software) { + context_provider = ContextProviderCommandBuffer::Create( + CreateGraphicsContext3D(gpu_channel_host.get()), + RENDER_COMPOSITOR_CONTEXT); + DCHECK(context_provider); worker_context_provider = RenderThreadImpl::current()->SharedWorkerContextProvider(); if (!worker_context_provider) { @@ -2097,21 +2112,7 @@ void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { } scoped_ptr<WebGraphicsContext3DCommandBufferImpl> -RenderWidget::CreateGraphicsContext3D(bool compositor) { - if (!webwidget_) - return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableGpuCompositing)) - return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); - if (!RenderThreadImpl::current()) - return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); - CauseForGpuLaunch cause = - CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; - scoped_refptr<GpuChannelHost> gpu_channel_host( - RenderThreadImpl::current()->EstablishGpuChannelSync(cause)); - if (!gpu_channel_host.get()) - return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); - +RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { // Explicitly disable antialiasing for the compositor. As of the time of // this writing, the only platform that supported antialiasing for the // compositor was Mac OS X, because the on-screen OpenGL context creation @@ -2159,17 +2160,13 @@ RenderWidget::CreateGraphicsContext3D(bool compositor) { limits.mapped_memory_reclaim_limit = max_transfer_buffer_usage_mb * kBytesPerMegabyte; #endif - if (compositor) { - limits.command_buffer_size = 64 * 1024; - limits.start_transfer_buffer_size = 64 * 1024; - limits.min_transfer_buffer_size = 64 * 1024; - } + limits.command_buffer_size = 64 * 1024; + limits.start_transfer_buffer_size = 64 * 1024; + limits.min_transfer_buffer_size = 64 * 1024; - scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( - new WebGraphicsContext3DCommandBufferImpl( - 0, GetURLForGraphicsContext3D(), gpu_channel_host.get(), attributes, + return make_scoped_ptr(new WebGraphicsContext3DCommandBufferImpl( + 0, GetURLForGraphicsContext3D(), gpu_channel_host, attributes, lose_context_when_out_of_memory, limits, NULL)); - return context; } void RenderWidget::RegisterRenderFrameProxy(RenderFrameProxy* proxy) { diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index c654047..20d98e8 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -550,7 +550,7 @@ class CONTENT_EXPORT RenderWidget // Creates a 3D context associated with this view. scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D( - bool compositor); + GpuChannelHost* gpu_channel_host); // Routing ID that allows us to communicate to the parent browser process // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. |