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

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: 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 // This is the number of bytes the compositor would be able to upload before
105 // frame in 16 milliseconds. 106 // the next frame deadline.
reveman 2014/08/30 00:38:39 maybe worth mentioning that this assumes no more t
danakj 2014/08/30 00:51:38 I added something, let me know if you think it's a
106 const size_t kMaxTransferBufferUsageBytes = 16 * 2 * kMaxBytesUploadedPerMs; 107 const size_t ms_per_frame = std::floor(1000.0 / refresh_rate);
108 const size_t max_transfer_buffer_usage_bytes =
109 ms_per_frame * kMaxBytesUploadedPerMs;
reveman 2014/08/30 00:38:39 nit: up to you but I'd get rid of the 'const' modi
danakj 2014/08/30 00:42:32 Done.
110
111 // The context may request a higher limit based on the device capabilities.
reveman 2014/08/30 00:38:39 nit: lower limit based on the device capabilities.
danakj 2014/08/30 00:42:32 I would have to change std::min to std::max then.
danakj 2014/08/30 00:44:28 Oh, no I agree with you. Fridays~
107 return std::min( 112 return std::min(
108 context_provider->ContextCapabilities().max_transfer_buffer_usage_bytes, 113 context_provider->ContextCapabilities().max_transfer_buffer_usage_bytes,
109 kMaxTransferBufferUsageBytes); 114 max_transfer_buffer_usage_bytes);
110 } 115 }
111 116
112 unsigned GetMapImageTextureTarget(cc::ContextProvider* context_provider) { 117 unsigned GetMapImageTextureTarget(cc::ContextProvider* context_provider) {
113 if (!context_provider) 118 if (!context_provider)
114 return GL_TEXTURE_2D; 119 return GL_TEXTURE_2D;
115 120
116 if (context_provider->ContextCapabilities().gpu.egl_image_external) 121 if (context_provider->ContextCapabilities().gpu.egl_image_external)
117 return GL_TEXTURE_EXTERNAL_OES; 122 return GL_TEXTURE_EXTERNAL_OES;
118 if (context_provider->ContextCapabilities().gpu.texture_rectangle) 123 if (context_provider->ContextCapabilities().gpu.texture_rectangle)
119 return GL_TEXTURE_RECTANGLE_ARB; 124 return GL_TEXTURE_RECTANGLE_ARB;
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 1937
1933 void LayerTreeHostImpl::CreateAndSetTileManager() { 1938 void LayerTreeHostImpl::CreateAndSetTileManager() {
1934 DCHECK(!tile_manager_); 1939 DCHECK(!tile_manager_);
1935 DCHECK(settings_.impl_side_painting); 1940 DCHECK(settings_.impl_side_painting);
1936 DCHECK(output_surface_); 1941 DCHECK(output_surface_);
1937 DCHECK(resource_provider_); 1942 DCHECK(resource_provider_);
1938 DCHECK(proxy_->ImplThreadTaskRunner()); 1943 DCHECK(proxy_->ImplThreadTaskRunner());
1939 1944
1940 ContextProvider* context_provider = output_surface_->context_provider(); 1945 ContextProvider* context_provider = output_surface_->context_provider();
1941 transfer_buffer_memory_limit_ = 1946 transfer_buffer_memory_limit_ =
1942 GetMaxTransferBufferUsageBytes(context_provider); 1947 GetMaxTransferBufferUsageBytes(context_provider, settings_.refresh_rate);
1943 1948
1944 if (use_gpu_rasterization_ && context_provider) { 1949 if (use_gpu_rasterization_ && context_provider) {
1945 resource_pool_ = 1950 resource_pool_ =
1946 ResourcePool::Create(resource_provider_.get(), 1951 ResourcePool::Create(resource_provider_.get(),
1947 GL_TEXTURE_2D, 1952 GL_TEXTURE_2D,
1948 resource_provider_->best_texture_format()); 1953 resource_provider_->best_texture_format());
1949 1954
1950 raster_worker_pool_ = 1955 raster_worker_pool_ =
1951 GpuRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), 1956 GpuRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(),
1952 context_provider, 1957 context_provider,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 settings_.highp_threshold_min, 2064 settings_.highp_threshold_min,
2060 settings_.use_rgba_4444_textures, 2065 settings_.use_rgba_4444_textures,
2061 settings_.texture_id_allocation_chunk_size, 2066 settings_.texture_id_allocation_chunk_size,
2062 settings_.use_distance_field_text); 2067 settings_.use_distance_field_text);
2063 2068
2064 if (output_surface_->capabilities().deferred_gl_initialization) 2069 if (output_surface_->capabilities().deferred_gl_initialization)
2065 EnforceZeroBudget(true); 2070 EnforceZeroBudget(true);
2066 2071
2067 CreateAndSetRenderer(); 2072 CreateAndSetRenderer();
2068 2073
2069 transfer_buffer_memory_limit_ =
danakj 2014/08/30 00:29:00 this is also set in CreateAndSetTileManager() whic
2070 GetMaxTransferBufferUsageBytes(output_surface_->context_provider());
2071
2072 if (settings_.impl_side_painting) 2074 if (settings_.impl_side_painting)
2073 CreateAndSetTileManager(); 2075 CreateAndSetTileManager();
2074 2076
2075 // Initialize vsync parameters to sane values. 2077 // Initialize vsync parameters to sane values.
2076 const base::TimeDelta display_refresh_interval = 2078 const base::TimeDelta display_refresh_interval =
2077 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / 2079 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond /
2078 settings_.refresh_rate); 2080 settings_.refresh_rate);
2079 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); 2081 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval);
2080 2082
2081 // TODO(brianderson): Don't use a hard-coded parent draw time. 2083 // TODO(brianderson): Don't use a hard-coded parent draw time.
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 } 3354 }
3353 3355
3354 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3356 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3355 std::vector<PictureLayerImpl*>::iterator it = 3357 std::vector<PictureLayerImpl*>::iterator it =
3356 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3358 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3357 DCHECK(it != picture_layers_.end()); 3359 DCHECK(it != picture_layers_.end());
3358 picture_layers_.erase(it); 3360 picture_layers_.erase(it);
3359 } 3361 }
3360 3362
3361 } // namespace cc 3363 } // 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