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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 522023002: cc: Decrease transfer buffer memory limit to a single frame of uploads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: memlimit: commentfix Created 6 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 "LayerTreeHostImpl::SetVisible", 82 "LayerTreeHostImpl::SetVisible",
83 id, 83 id,
84 "LayerTreeHostImpl", 84 "LayerTreeHostImpl",
85 id); 85 id);
86 return; 86 return;
87 } 87 }
88 88
89 TRACE_EVENT_ASYNC_END0("webkit", "LayerTreeHostImpl::SetVisible", id); 89 TRACE_EVENT_ASYNC_END0("webkit", "LayerTreeHostImpl::SetVisible", id);
90 } 90 }
91 91
92 size_t GetMaxTransferBufferUsageBytes(cc::ContextProvider* context_provider) { 92 size_t GetMaxTransferBufferUsageBytes(cc::ContextProvider* context_provider,
93 double refresh_rate) {
93 // Software compositing should not use this value in production. Just use a 94 // Software compositing should not use this value in production. Just use a
94 // default value when testing uploads with the software compositor. 95 // default value when testing uploads with the software compositor.
95 if (!context_provider) 96 if (!context_provider)
96 return std::numeric_limits<size_t>::max(); 97 return std::numeric_limits<size_t>::max();
97 98
98 // We want to make sure the default transfer buffer size is equal to the 99 // We want to make sure the default transfer buffer size is equal to the
99 // amount of data that can be uploaded by the compositor to avoid stalling 100 // amount of data that can be uploaded by the compositor to avoid stalling
100 // the pipeline. 101 // the pipeline.
101 // For reference Chromebook Pixel can upload 1MB in about 0.5ms. 102 // For reference Chromebook Pixel can upload 1MB in about 0.5ms.
102 const size_t kMaxBytesUploadedPerMs = 1024 * 1024 * 2; 103 const size_t kMaxBytesUploadedPerMs = 1024 * 1024 * 2;
103 // Assuming a two frame deep pipeline between CPU and GPU and we are 104
104 // drawing 60 frames per second which would require us to draw one 105 // We need to upload at least enough work to keep the GPU process busy until
105 // frame in 16 milliseconds. 106 // the next time it can handle a request to start more uploads from the
106 const size_t kMaxTransferBufferUsageBytes = 16 * 2 * kMaxBytesUploadedPerMs; 107 // compositor. We assume that it will pick up any sent upload requests within
108 // the time of a vsync, since the browser will want to swap a frame within
109 // that time interval, and then uploads should have a chance to be processed.
110 size_t ms_per_frame = std::floor(1000.0 / refresh_rate);
111 size_t max_transfer_buffer_usage_bytes =
112 ms_per_frame * kMaxBytesUploadedPerMs;
113
114 // The context may request a lower limit based on the device capabilities.
107 return std::min( 115 return std::min(
108 context_provider->ContextCapabilities().max_transfer_buffer_usage_bytes, 116 context_provider->ContextCapabilities().max_transfer_buffer_usage_bytes,
109 kMaxTransferBufferUsageBytes); 117 max_transfer_buffer_usage_bytes);
110 } 118 }
111 119
112 unsigned GetMapImageTextureTarget(cc::ContextProvider* context_provider) { 120 unsigned GetMapImageTextureTarget(cc::ContextProvider* context_provider) {
113 if (!context_provider) 121 if (!context_provider)
114 return GL_TEXTURE_2D; 122 return GL_TEXTURE_2D;
115 123
116 if (context_provider->ContextCapabilities().gpu.egl_image_external) 124 if (context_provider->ContextCapabilities().gpu.egl_image_external)
117 return GL_TEXTURE_EXTERNAL_OES; 125 return GL_TEXTURE_EXTERNAL_OES;
118 if (context_provider->ContextCapabilities().gpu.texture_rectangle) 126 if (context_provider->ContextCapabilities().gpu.texture_rectangle)
119 return GL_TEXTURE_RECTANGLE_ARB; 127 return GL_TEXTURE_RECTANGLE_ARB;
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 1940
1933 void LayerTreeHostImpl::CreateAndSetTileManager() { 1941 void LayerTreeHostImpl::CreateAndSetTileManager() {
1934 DCHECK(!tile_manager_); 1942 DCHECK(!tile_manager_);
1935 DCHECK(settings_.impl_side_painting); 1943 DCHECK(settings_.impl_side_painting);
1936 DCHECK(output_surface_); 1944 DCHECK(output_surface_);
1937 DCHECK(resource_provider_); 1945 DCHECK(resource_provider_);
1938 DCHECK(proxy_->ImplThreadTaskRunner()); 1946 DCHECK(proxy_->ImplThreadTaskRunner());
1939 1947
1940 ContextProvider* context_provider = output_surface_->context_provider(); 1948 ContextProvider* context_provider = output_surface_->context_provider();
1941 transfer_buffer_memory_limit_ = 1949 transfer_buffer_memory_limit_ =
1942 GetMaxTransferBufferUsageBytes(context_provider); 1950 GetMaxTransferBufferUsageBytes(context_provider, settings_.refresh_rate);
1943 1951
1944 if (use_gpu_rasterization_ && context_provider) { 1952 if (use_gpu_rasterization_ && context_provider) {
1945 resource_pool_ = 1953 resource_pool_ =
1946 ResourcePool::Create(resource_provider_.get(), 1954 ResourcePool::Create(resource_provider_.get(),
1947 GL_TEXTURE_2D, 1955 GL_TEXTURE_2D,
1948 resource_provider_->best_texture_format()); 1956 resource_provider_->best_texture_format());
1949 1957
1950 raster_worker_pool_ = 1958 raster_worker_pool_ =
1951 GpuRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), 1959 GpuRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(),
1952 context_provider, 1960 context_provider,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 settings_.highp_threshold_min, 2067 settings_.highp_threshold_min,
2060 settings_.use_rgba_4444_textures, 2068 settings_.use_rgba_4444_textures,
2061 settings_.texture_id_allocation_chunk_size, 2069 settings_.texture_id_allocation_chunk_size,
2062 settings_.use_distance_field_text); 2070 settings_.use_distance_field_text);
2063 2071
2064 if (output_surface_->capabilities().deferred_gl_initialization) 2072 if (output_surface_->capabilities().deferred_gl_initialization)
2065 EnforceZeroBudget(true); 2073 EnforceZeroBudget(true);
2066 2074
2067 CreateAndSetRenderer(); 2075 CreateAndSetRenderer();
2068 2076
2069 transfer_buffer_memory_limit_ =
2070 GetMaxTransferBufferUsageBytes(output_surface_->context_provider());
2071
2072 if (settings_.impl_side_painting) 2077 if (settings_.impl_side_painting)
2073 CreateAndSetTileManager(); 2078 CreateAndSetTileManager();
2074 2079
2075 // Initialize vsync parameters to sane values. 2080 // Initialize vsync parameters to sane values.
2076 const base::TimeDelta display_refresh_interval = 2081 const base::TimeDelta display_refresh_interval =
2077 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / 2082 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond /
2078 settings_.refresh_rate); 2083 settings_.refresh_rate);
2079 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); 2084 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval);
2080 2085
2081 // TODO(brianderson): Don't use a hard-coded parent draw time. 2086 // TODO(brianderson): Don't use a hard-coded parent draw time.
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 } 3357 }
3353 3358
3354 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3359 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3355 std::vector<PictureLayerImpl*>::iterator it = 3360 std::vector<PictureLayerImpl*>::iterator it =
3356 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3361 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3357 DCHECK(it != picture_layers_.end()); 3362 DCHECK(it != picture_layers_.end());
3358 picture_layers_.erase(it); 3363 picture_layers_.erase(it);
3359 } 3364 }
3360 3365
3361 } // namespace cc 3366 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698