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

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

Issue 1186393004: gpu: Remove async texture uploads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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 | « cc/test/test_gles2_interface.cc ('k') | cc/trees/layer_tree_host_pixeltest_blending.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 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 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "cc/output/software_renderer.h" 51 #include "cc/output/software_renderer.h"
52 #include "cc/output/texture_mailbox_deleter.h" 52 #include "cc/output/texture_mailbox_deleter.h"
53 #include "cc/quads/render_pass_draw_quad.h" 53 #include "cc/quads/render_pass_draw_quad.h"
54 #include "cc/quads/shared_quad_state.h" 54 #include "cc/quads/shared_quad_state.h"
55 #include "cc/quads/solid_color_draw_quad.h" 55 #include "cc/quads/solid_color_draw_quad.h"
56 #include "cc/quads/texture_draw_quad.h" 56 #include "cc/quads/texture_draw_quad.h"
57 #include "cc/raster/bitmap_tile_task_worker_pool.h" 57 #include "cc/raster/bitmap_tile_task_worker_pool.h"
58 #include "cc/raster/gpu_rasterizer.h" 58 #include "cc/raster/gpu_rasterizer.h"
59 #include "cc/raster/gpu_tile_task_worker_pool.h" 59 #include "cc/raster/gpu_tile_task_worker_pool.h"
60 #include "cc/raster/one_copy_tile_task_worker_pool.h" 60 #include "cc/raster/one_copy_tile_task_worker_pool.h"
61 #include "cc/raster/pixel_buffer_tile_task_worker_pool.h"
62 #include "cc/raster/tile_task_worker_pool.h" 61 #include "cc/raster/tile_task_worker_pool.h"
63 #include "cc/raster/zero_copy_tile_task_worker_pool.h" 62 #include "cc/raster/zero_copy_tile_task_worker_pool.h"
64 #include "cc/resources/memory_history.h" 63 #include "cc/resources/memory_history.h"
65 #include "cc/resources/resource_pool.h" 64 #include "cc/resources/resource_pool.h"
66 #include "cc/resources/ui_resource_bitmap.h" 65 #include "cc/resources/ui_resource_bitmap.h"
67 #include "cc/scheduler/delay_based_time_source.h" 66 #include "cc/scheduler/delay_based_time_source.h"
68 #include "cc/tiles/eviction_tile_priority_queue.h" 67 #include "cc/tiles/eviction_tile_priority_queue.h"
69 #include "cc/tiles/picture_layer_tiling.h" 68 #include "cc/tiles/picture_layer_tiling.h"
70 #include "cc/tiles/raster_tile_priority_queue.h" 69 #include "cc/tiles/raster_tile_priority_queue.h"
71 #include "cc/trees/damage_tracker.h" 70 #include "cc/trees/damage_tracker.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) { 122 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) {
124 if (visible) { 123 if (visible) {
125 TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id, 124 TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id,
126 "LayerTreeHostImpl", id); 125 "LayerTreeHostImpl", id);
127 return; 126 return;
128 } 127 }
129 128
130 TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id); 129 TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id);
131 } 130 }
132 131
133 size_t GetMaxTransferBufferUsageBytes(
134 const ContextProvider::Capabilities& context_capabilities,
135 double refresh_rate) {
136 // We want to make sure the default transfer buffer size is equal to the
137 // amount of data that can be uploaded by the compositor to avoid stalling
138 // the pipeline.
139 // For reference Chromebook Pixel can upload 1MB in about 0.5ms.
140 const size_t kMaxBytesUploadedPerMs = 1024 * 1024 * 2;
141
142 // We need to upload at least enough work to keep the GPU process busy until
143 // the next time it can handle a request to start more uploads from the
144 // compositor. We assume that it will pick up any sent upload requests within
145 // the time of a vsync, since the browser will want to swap a frame within
146 // that time interval, and then uploads should have a chance to be processed.
147 size_t ms_per_frame = std::floor(1000.0 / refresh_rate);
148 size_t max_transfer_buffer_usage_bytes =
149 ms_per_frame * kMaxBytesUploadedPerMs;
150
151 // The context may request a lower limit based on the device capabilities.
152 return std::min(context_capabilities.max_transfer_buffer_usage_bytes,
153 max_transfer_buffer_usage_bytes);
154 }
155
156 size_t GetDefaultMemoryAllocationLimit() { 132 size_t GetDefaultMemoryAllocationLimit() {
157 // TODO(ccameron): (http://crbug.com/137094) This 64MB default is a straggler 133 // TODO(ccameron): (http://crbug.com/137094) This 64MB default is a straggler
158 // from the old texture manager and is just to give us a default memory 134 // from the old texture manager and is just to give us a default memory
159 // allocation before we get a callback from the GPU memory manager. We 135 // allocation before we get a callback from the GPU memory manager. We
160 // should probaby either: 136 // should probaby either:
161 // - wait for the callback before rendering anything instead 137 // - wait for the callback before rendering anything instead
162 // - push this into the GPU memory manager somehow. 138 // - push this into the GPU memory manager somehow.
163 return 64 * 1024 * 1024; 139 return 64 * 1024 * 1024;
164 } 140 }
165 141
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 animation_host_->SetSupportsScrollAnimations( 228 animation_host_->SetSupportsScrollAnimations(
253 proxy_->SupportsImplScrolling()); 229 proxy_->SupportsImplScrolling());
254 } 230 }
255 } else { 231 } else {
256 animation_registrar_ = AnimationRegistrar::Create(); 232 animation_registrar_ = AnimationRegistrar::Create();
257 animation_registrar_->set_supports_scroll_animations( 233 animation_registrar_->set_supports_scroll_animations(
258 proxy_->SupportsImplScrolling()); 234 proxy_->SupportsImplScrolling());
259 } 235 }
260 236
261 DCHECK(proxy_->IsImplThread()); 237 DCHECK(proxy_->IsImplThread());
262 DCHECK_IMPLIES(settings.use_one_copy, !settings.use_zero_copy);
263 DCHECK_IMPLIES(settings.use_zero_copy, !settings.use_one_copy);
264 DidVisibilityChange(this, visible_); 238 DidVisibilityChange(this, visible_);
265 239
266 SetDebugState(settings.initial_debug_state); 240 SetDebugState(settings.initial_debug_state);
267 241
268 // LTHI always has an active tree. 242 // LTHI always has an active tree.
269 active_tree_ = 243 active_tree_ =
270 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), 244 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(),
271 new SyncedTopControls, new SyncedElasticOverscroll); 245 new SyncedTopControls, new SyncedElasticOverscroll);
272 246
273 viewport_ = Viewport::Create(this); 247 viewport_ = Viewport::Create(this);
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 2101
2128 if (use_zero_copy) { 2102 if (use_zero_copy) {
2129 *resource_pool = 2103 *resource_pool =
2130 ResourcePool::Create(resource_provider_.get(), GetTaskRunner()); 2104 ResourcePool::Create(resource_provider_.get(), GetTaskRunner());
2131 2105
2132 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( 2106 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create(
2133 GetTaskRunner(), task_graph_runner, resource_provider_.get()); 2107 GetTaskRunner(), task_graph_runner, resource_provider_.get());
2134 return; 2108 return;
2135 } 2109 }
2136 2110
2137 if (settings_.use_one_copy) {
2138 *resource_pool = ResourcePool::Create(resource_provider_.get(),
2139 GetTaskRunner(), GL_TEXTURE_2D);
2140
2141 int max_copy_texture_chromium_size =
2142 context_provider->ContextCapabilities()
2143 .gpu.max_copy_texture_chromium_size;
2144
2145 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create(
2146 GetTaskRunner(), task_graph_runner, context_provider,
2147 resource_provider_.get(), max_copy_texture_chromium_size,
2148 settings_.use_persistent_map_for_gpu_memory_buffers,
2149 settings_.max_staging_buffers);
2150 return;
2151 }
2152
2153 // Synchronous single-threaded mode depends on tiles being ready to
2154 // draw when raster is complete. Therefore, it must use one of zero
2155 // copy, software raster, or GPU raster (in the branches above).
2156 DCHECK(!is_synchronous_single_threaded_);
2157
2158 *resource_pool = ResourcePool::Create(resource_provider_.get(), 2111 *resource_pool = ResourcePool::Create(resource_provider_.get(),
2159 GetTaskRunner(), GL_TEXTURE_2D); 2112 GetTaskRunner(), GL_TEXTURE_2D);
2160 2113
2161 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( 2114 int max_copy_texture_chromium_size = context_provider->ContextCapabilities()
2162 GetTaskRunner(), task_graph_runner_, context_provider, 2115 .gpu.max_copy_texture_chromium_size;
2163 resource_provider_.get(), 2116
2164 GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(), 2117 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create(
2165 settings_.renderer_settings.refresh_rate)); 2118 GetTaskRunner(), task_graph_runner, context_provider,
2119 resource_provider_.get(), max_copy_texture_chromium_size,
2120 settings_.use_persistent_map_for_gpu_memory_buffers,
2121 settings_.max_staging_buffers);
2166 } 2122 }
2167 2123
2168 void LayerTreeHostImpl::RecordMainFrameTiming( 2124 void LayerTreeHostImpl::RecordMainFrameTiming(
2169 const BeginFrameArgs& start_of_main_frame_args, 2125 const BeginFrameArgs& start_of_main_frame_args,
2170 const BeginFrameArgs& expected_next_main_frame_args) { 2126 const BeginFrameArgs& expected_next_main_frame_args) {
2171 std::vector<int64_t> request_ids; 2127 std::vector<int64_t> request_ids;
2172 active_tree_->GatherFrameTimingRequestIds(&request_ids); 2128 active_tree_->GatherFrameTimingRequestIds(&request_ids);
2173 if (request_ids.empty()) 2129 if (request_ids.empty())
2174 return; 2130 return;
2175 2131
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 if (active_tree()) { 3598 if (active_tree()) {
3643 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); 3599 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id);
3644 if (layer) 3600 if (layer)
3645 return layer->ScrollOffsetForAnimation(); 3601 return layer->ScrollOffsetForAnimation();
3646 } 3602 }
3647 3603
3648 return gfx::ScrollOffset(); 3604 return gfx::ScrollOffset();
3649 } 3605 }
3650 3606
3651 } // namespace cc 3607 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_gles2_interface.cc ('k') | cc/trees/layer_tree_host_pixeltest_blending.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698