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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 1949023005: gpu: Add flag for enabling asynchronous worker context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « content/renderer/pepper/ppb_graphics_3d_impl.cc ('k') | content/renderer/render_widget.cc » ('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) 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 "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 for (size_t i = 0; i < pieces.size(); ++i) { 395 for (size_t i = 0; i < pieces.size(); ++i) {
396 unsigned number = 0; 396 unsigned number = 0;
397 bool succeed = base::StringToUint(pieces[i], &number); 397 bool succeed = base::StringToUint(pieces[i], &number);
398 DCHECK(succeed); 398 DCHECK(succeed);
399 vector->push_back(number); 399 vector->push_back(number);
400 } 400 }
401 } 401 }
402 402
403 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext( 403 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext(
404 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, 404 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
405 command_buffer_metrics::ContextType type) { 405 command_buffer_metrics::ContextType type,
406 int32_t stream_id,
407 gpu::GpuStreamPriority stream_priority) {
406 DCHECK(gpu_channel_host); 408 DCHECK(gpu_channel_host);
407 // This is used to create a few different offscreen contexts: 409 // This is used to create a few different offscreen contexts:
408 // - The shared main thread context (offscreen) used by blink for canvas. 410 // - The shared main thread context (offscreen) used by blink for canvas.
409 // - The worker context (offscreen) used for GPU raster and video decoding. 411 // - The worker context (offscreen) used for GPU raster and video decoding.
410 // This is for an offscreen context, so the default framebuffer doesn't need 412 // This is for an offscreen context, so the default framebuffer doesn't need
411 // alpha, depth, stencil, antialiasing. 413 // alpha, depth, stencil, antialiasing.
412 gpu::gles2::ContextCreationAttribHelper attributes; 414 gpu::gles2::ContextCreationAttribHelper attributes;
413 attributes.alpha_size = -1; 415 attributes.alpha_size = -1;
414 attributes.depth_size = 0; 416 attributes.depth_size = 0;
415 attributes.stencil_size = 0; 417 attributes.stencil_size = 0;
416 attributes.samples = 0; 418 attributes.samples = 0;
417 attributes.sample_buffers = 0; 419 attributes.sample_buffers = 0;
418 attributes.bind_generates_resource = false; 420 attributes.bind_generates_resource = false;
419 attributes.lose_context_when_out_of_memory = true; 421 attributes.lose_context_when_out_of_memory = true;
420 constexpr bool automatic_flushes = false; 422 const bool automatic_flushes = false;
421 return make_scoped_refptr(new ContextProviderCommandBuffer( 423 return make_scoped_refptr(new ContextProviderCommandBuffer(
422 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( 424 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl(
423 gpu::kNullSurfaceHandle, 425 gpu::kNullSurfaceHandle,
424 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), 426 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"),
425 std::move(gpu_channel_host), gfx::PreferIntegratedGpu, 427 std::move(gpu_channel_host), gfx::PreferIntegratedGpu,
426 automatic_flushes)), 428 automatic_flushes, stream_id, stream_priority)),
427 gpu::SharedMemoryLimits(), attributes, nullptr, type)); 429 gpu::SharedMemoryLimits(), attributes, nullptr, type));
428 } 430 }
429 431
430 } // namespace 432 } // namespace
431 433
432 // For measuring memory usage after each task. Behind a command line flag. 434 // For measuring memory usage after each task. Behind a command line flag.
433 class MemoryObserver : public base::MessageLoop::TaskObserver { 435 class MemoryObserver : public base::MessageLoop::TaskObserver {
434 public: 436 public:
435 MemoryObserver() {} 437 MemoryObserver() {}
436 ~MemoryObserver() override {} 438 ~MemoryObserver() override {}
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1443
1442 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( 1444 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync(
1443 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); 1445 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
1444 if (!gpu_channel_host) { 1446 if (!gpu_channel_host) {
1445 shared_main_thread_contexts_ = nullptr; 1447 shared_main_thread_contexts_ = nullptr;
1446 return nullptr; 1448 return nullptr;
1447 } 1449 }
1448 1450
1449 shared_main_thread_contexts_ = CreateOffscreenContext( 1451 shared_main_thread_contexts_ = CreateOffscreenContext(
1450 std::move(gpu_channel_host), 1452 std::move(gpu_channel_host),
1451 command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT); 1453 command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT,
1454 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL);
1452 if (!shared_main_thread_contexts_->BindToCurrentThread()) 1455 if (!shared_main_thread_contexts_->BindToCurrentThread())
1453 shared_main_thread_contexts_ = nullptr; 1456 shared_main_thread_contexts_ = nullptr;
1454 return shared_main_thread_contexts_; 1457 return shared_main_thread_contexts_;
1455 } 1458 }
1456 1459
1457 #if defined(OS_ANDROID) 1460 #if defined(OS_ANDROID)
1458 1461
1459 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { 1462 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() {
1460 DCHECK(IsMainThread()); 1463 DCHECK(IsMainThread());
1461 if (!stream_texture_factory_.get() || 1464 if (!stream_texture_factory_.get() ||
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 return shared_worker_context_provider_; 1941 return shared_worker_context_provider_;
1939 } 1942 }
1940 1943
1941 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( 1944 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync(
1942 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); 1945 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
1943 if (!gpu_channel_host) { 1946 if (!gpu_channel_host) {
1944 shared_worker_context_provider_ = nullptr; 1947 shared_worker_context_provider_ = nullptr;
1945 return shared_worker_context_provider_; 1948 return shared_worker_context_provider_;
1946 } 1949 }
1947 1950
1951 int32_t stream_id = gpu::GPU_STREAM_DEFAULT;
1952 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL;
1953 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1954 switches::kEnableGpuAsyncWorkerContext)) {
piman 2016/05/04 21:45:06 For this to work, you need to propagate the flag t
1955 stream_id = gpu_channel_host->GenerateStreamID();
1956 stream_priority = gpu::GpuStreamPriority::LOW;
1957 }
1958
1948 shared_worker_context_provider_ = 1959 shared_worker_context_provider_ =
1949 CreateOffscreenContext(std::move(gpu_channel_host), 1960 CreateOffscreenContext(std::move(gpu_channel_host),
1950 command_buffer_metrics::RENDER_WORKER_CONTEXT); 1961 command_buffer_metrics::RENDER_WORKER_CONTEXT,
1962 stream_id, stream_priority);
1951 if (!shared_worker_context_provider_->BindToCurrentThread()) 1963 if (!shared_worker_context_provider_->BindToCurrentThread())
1952 shared_worker_context_provider_ = nullptr; 1964 shared_worker_context_provider_ = nullptr;
1953 if (shared_worker_context_provider_) 1965 if (shared_worker_context_provider_)
1954 shared_worker_context_provider_->SetupLock(); 1966 shared_worker_context_provider_->SetupLock();
1955 return shared_worker_context_provider_; 1967 return shared_worker_context_provider_;
1956 } 1968 }
1957 1969
1958 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { 1970 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) {
1959 blink_platform_impl_->sampleGamepads(*data); 1971 blink_platform_impl_->sampleGamepads(*data);
1960 } 1972 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 } 2051 }
2040 2052
2041 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 2053 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
2042 size_t erased = 2054 size_t erased =
2043 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 2055 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
2044 routing_id_); 2056 routing_id_);
2045 DCHECK_EQ(1u, erased); 2057 DCHECK_EQ(1u, erased);
2046 } 2058 }
2047 2059
2048 } // namespace content 2060 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/ppb_graphics_3d_impl.cc ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698