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

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: rebase fix 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/render_thread_impl.h ('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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 for (size_t i = 0; i < pieces.size(); ++i) { 396 for (size_t i = 0; i < pieces.size(); ++i) {
397 unsigned number = 0; 397 unsigned number = 0;
398 bool succeed = base::StringToUint(pieces[i], &number); 398 bool succeed = base::StringToUint(pieces[i], &number);
399 DCHECK(succeed); 399 DCHECK(succeed);
400 vector->push_back(number); 400 vector->push_back(number);
401 } 401 }
402 } 402 }
403 403
404 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext( 404 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext(
405 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, 405 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
406 command_buffer_metrics::ContextType type) { 406 command_buffer_metrics::ContextType type,
407 int32_t stream_id,
408 gpu::GpuStreamPriority stream_priority) {
407 DCHECK(gpu_channel_host); 409 DCHECK(gpu_channel_host);
408 // This is used to create a few different offscreen contexts: 410 // This is used to create a few different offscreen contexts:
409 // - The shared main thread context (offscreen) used by blink for canvas. 411 // - The shared main thread context (offscreen) used by blink for canvas.
410 // - The worker context (offscreen) used for GPU raster and video decoding. 412 // - The worker context (offscreen) used for GPU raster and video decoding.
411 // This is for an offscreen context, so the default framebuffer doesn't need 413 // This is for an offscreen context, so the default framebuffer doesn't need
412 // alpha, depth, stencil, antialiasing. 414 // alpha, depth, stencil, antialiasing.
413 gpu::gles2::ContextCreationAttribHelper attributes; 415 gpu::gles2::ContextCreationAttribHelper attributes;
414 attributes.alpha_size = -1; 416 attributes.alpha_size = -1;
415 attributes.depth_size = 0; 417 attributes.depth_size = 0;
416 attributes.stencil_size = 0; 418 attributes.stencil_size = 0;
417 attributes.samples = 0; 419 attributes.samples = 0;
418 attributes.sample_buffers = 0; 420 attributes.sample_buffers = 0;
419 attributes.bind_generates_resource = false; 421 attributes.bind_generates_resource = false;
420 attributes.lose_context_when_out_of_memory = true; 422 attributes.lose_context_when_out_of_memory = true;
421 constexpr bool automatic_flushes = false; 423 const bool automatic_flushes = false;
422 return make_scoped_refptr(new ContextProviderCommandBuffer( 424 return make_scoped_refptr(new ContextProviderCommandBuffer(
423 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, 425 std::move(gpu_channel_host), stream_id, stream_priority,
426 gpu::kNullSurfaceHandle,
424 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), 427 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"),
425 gfx::PreferIntegratedGpu, automatic_flushes, gpu::SharedMemoryLimits(), 428 gfx::PreferIntegratedGpu, automatic_flushes, gpu::SharedMemoryLimits(),
426 attributes, nullptr, type)); 429 attributes, nullptr, type));
427 } 430 }
428 431
429 } // namespace 432 } // namespace
430 433
431 // 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.
432 class MemoryObserver : public base::MessageLoop::TaskObserver { 435 class MemoryObserver : public base::MessageLoop::TaskObserver {
433 public: 436 public:
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 is_lcd_text_enabled_ = false; 739 is_lcd_text_enabled_ = false;
737 #else 740 #else
738 is_lcd_text_enabled_ = true; 741 is_lcd_text_enabled_ = true;
739 #endif 742 #endif
740 } 743 }
741 744
742 is_gpu_rasterization_enabled_ = 745 is_gpu_rasterization_enabled_ =
743 command_line.HasSwitch(switches::kEnableGpuRasterization); 746 command_line.HasSwitch(switches::kEnableGpuRasterization);
744 is_gpu_rasterization_forced_ = 747 is_gpu_rasterization_forced_ =
745 command_line.HasSwitch(switches::kForceGpuRasterization); 748 command_line.HasSwitch(switches::kForceGpuRasterization);
749 is_async_worker_context_enabled_ =
750 command_line.HasSwitch(switches::kEnableGpuAsyncWorkerContext);
746 751
747 if (command_line.HasSwitch(switches::kGpuRasterizationMSAASampleCount)) { 752 if (command_line.HasSwitch(switches::kGpuRasterizationMSAASampleCount)) {
748 std::string string_value = command_line.GetSwitchValueASCII( 753 std::string string_value = command_line.GetSwitchValueASCII(
749 switches::kGpuRasterizationMSAASampleCount); 754 switches::kGpuRasterizationMSAASampleCount);
750 bool parsed_msaa_sample_count = 755 bool parsed_msaa_sample_count =
751 base::StringToInt(string_value, &gpu_rasterization_msaa_sample_count_); 756 base::StringToInt(string_value, &gpu_rasterization_msaa_sample_count_);
752 DCHECK(parsed_msaa_sample_count) << string_value; 757 DCHECK(parsed_msaa_sample_count) << string_value;
753 DCHECK_GE(gpu_rasterization_msaa_sample_count_, 0); 758 DCHECK_GE(gpu_rasterization_msaa_sample_count_, 0);
754 } else { 759 } else {
755 gpu_rasterization_msaa_sample_count_ = -1; 760 gpu_rasterization_msaa_sample_count_ = -1;
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 1445
1441 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( 1446 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync(
1442 CAUSE_FOR_GPU_LAUNCH_RENDERER_SHARED_MAIN_THREAD_CONTEXT)); 1447 CAUSE_FOR_GPU_LAUNCH_RENDERER_SHARED_MAIN_THREAD_CONTEXT));
1443 if (!gpu_channel_host) { 1448 if (!gpu_channel_host) {
1444 shared_main_thread_contexts_ = nullptr; 1449 shared_main_thread_contexts_ = nullptr;
1445 return nullptr; 1450 return nullptr;
1446 } 1451 }
1447 1452
1448 shared_main_thread_contexts_ = CreateOffscreenContext( 1453 shared_main_thread_contexts_ = CreateOffscreenContext(
1449 std::move(gpu_channel_host), 1454 std::move(gpu_channel_host),
1450 command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT); 1455 command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT,
1456 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL);
1451 if (!shared_main_thread_contexts_->BindToCurrentThread()) 1457 if (!shared_main_thread_contexts_->BindToCurrentThread())
1452 shared_main_thread_contexts_ = nullptr; 1458 shared_main_thread_contexts_ = nullptr;
1453 return shared_main_thread_contexts_; 1459 return shared_main_thread_contexts_;
1454 } 1460 }
1455 1461
1456 #if defined(OS_ANDROID) 1462 #if defined(OS_ANDROID)
1457 1463
1458 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { 1464 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() {
1459 DCHECK(IsMainThread()); 1465 DCHECK(IsMainThread());
1460 if (!stream_texture_factory_.get() || 1466 if (!stream_texture_factory_.get() ||
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 } 1526 }
1521 1527
1522 bool RenderThreadImpl::IsGpuRasterizationForced() { 1528 bool RenderThreadImpl::IsGpuRasterizationForced() {
1523 return is_gpu_rasterization_forced_; 1529 return is_gpu_rasterization_forced_;
1524 } 1530 }
1525 1531
1526 bool RenderThreadImpl::IsGpuRasterizationEnabled() { 1532 bool RenderThreadImpl::IsGpuRasterizationEnabled() {
1527 return is_gpu_rasterization_enabled_; 1533 return is_gpu_rasterization_enabled_;
1528 } 1534 }
1529 1535
1536 bool RenderThreadImpl::IsAsyncWorkerContextEnabled() {
1537 return is_async_worker_context_enabled_;
1538 }
1539
1530 int RenderThreadImpl::GetGpuRasterizationMSAASampleCount() { 1540 int RenderThreadImpl::GetGpuRasterizationMSAASampleCount() {
1531 return gpu_rasterization_msaa_sample_count_; 1541 return gpu_rasterization_msaa_sample_count_;
1532 } 1542 }
1533 1543
1534 bool RenderThreadImpl::IsLcdTextEnabled() { 1544 bool RenderThreadImpl::IsLcdTextEnabled() {
1535 return is_lcd_text_enabled_; 1545 return is_lcd_text_enabled_;
1536 } 1546 }
1537 1547
1538 bool RenderThreadImpl::IsDistanceFieldTextEnabled() { 1548 bool RenderThreadImpl::IsDistanceFieldTextEnabled() {
1539 return is_distance_field_text_enabled_; 1549 return is_distance_field_text_enabled_;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 return shared_worker_context_provider_; 1955 return shared_worker_context_provider_;
1946 } 1956 }
1947 1957
1948 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( 1958 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync(
1949 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT)); 1959 CAUSE_FOR_GPU_LAUNCH_SHARED_WORKER_THREAD_CONTEXT));
1950 if (!gpu_channel_host) { 1960 if (!gpu_channel_host) {
1951 shared_worker_context_provider_ = nullptr; 1961 shared_worker_context_provider_ = nullptr;
1952 return shared_worker_context_provider_; 1962 return shared_worker_context_provider_;
1953 } 1963 }
1954 1964
1965 int32_t stream_id = gpu::GPU_STREAM_DEFAULT;
1966 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL;
1967 if (is_async_worker_context_enabled_) {
1968 stream_id = gpu_channel_host->GenerateStreamID();
1969 stream_priority = gpu::GpuStreamPriority::LOW;
1970 }
1971
1955 shared_worker_context_provider_ = 1972 shared_worker_context_provider_ =
1956 CreateOffscreenContext(std::move(gpu_channel_host), 1973 CreateOffscreenContext(std::move(gpu_channel_host),
1957 command_buffer_metrics::RENDER_WORKER_CONTEXT); 1974 command_buffer_metrics::RENDER_WORKER_CONTEXT,
1975 stream_id, stream_priority);
1958 if (!shared_worker_context_provider_->BindToCurrentThread()) 1976 if (!shared_worker_context_provider_->BindToCurrentThread())
1959 shared_worker_context_provider_ = nullptr; 1977 shared_worker_context_provider_ = nullptr;
1960 if (shared_worker_context_provider_) 1978 if (shared_worker_context_provider_)
1961 shared_worker_context_provider_->SetupLock(); 1979 shared_worker_context_provider_->SetupLock();
1962 return shared_worker_context_provider_; 1980 return shared_worker_context_provider_;
1963 } 1981 }
1964 1982
1965 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { 1983 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) {
1966 blink_platform_impl_->sampleGamepads(*data); 1984 blink_platform_impl_->sampleGamepads(*data);
1967 } 1985 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 } 2064 }
2047 2065
2048 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 2066 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
2049 size_t erased = 2067 size_t erased =
2050 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 2068 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
2051 routing_id_); 2069 routing_id_);
2052 DCHECK_EQ(1u, erased); 2070 DCHECK_EQ(1u, erased);
2053 } 2071 }
2054 2072
2055 } // namespace content 2073 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698