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

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

Issue 1282183002: Revert of Re-land: cc: Use worker context for one-copy tile initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_pixeltest_tiles.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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // that time interval, and then uploads should have a chance to be processed. 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); 147 size_t ms_per_frame = std::floor(1000.0 / refresh_rate);
148 size_t max_transfer_buffer_usage_bytes = 148 size_t max_transfer_buffer_usage_bytes =
149 ms_per_frame * kMaxBytesUploadedPerMs; 149 ms_per_frame * kMaxBytesUploadedPerMs;
150 150
151 // The context may request a lower limit based on the device capabilities. 151 // The context may request a lower limit based on the device capabilities.
152 return std::min(context_capabilities.max_transfer_buffer_usage_bytes, 152 return std::min(context_capabilities.max_transfer_buffer_usage_bytes,
153 max_transfer_buffer_usage_bytes); 153 max_transfer_buffer_usage_bytes);
154 } 154 }
155 155
156 size_t GetMaxStagingResourceCount() {
157 // Upper bound for number of staging resource to allow.
158 return 32;
159 }
160
156 size_t GetDefaultMemoryAllocationLimit() { 161 size_t GetDefaultMemoryAllocationLimit() {
157 // TODO(ccameron): (http://crbug.com/137094) This 64MB default is a straggler 162 // 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 163 // 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 164 // allocation before we get a callback from the GPU memory manager. We
160 // should probaby either: 165 // should probaby either:
161 // - wait for the callback before rendering anything instead 166 // - wait for the callback before rendering anything instead
162 // - push this into the GPU memory manager somehow. 167 // - push this into the GPU memory manager somehow.
163 return 64 * 1024 * 1024; 168 return 64 * 1024 * 1024;
164 } 169 }
165 170
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 // TODO(reveman): We should avoid keeping around unused resources if 1228 // TODO(reveman): We should avoid keeping around unused resources if
1224 // possible. crbug.com/224475 1229 // possible. crbug.com/224475
1225 // Unused limit is calculated from soft-limit, as hard-limit may 1230 // Unused limit is calculated from soft-limit, as hard-limit may
1226 // be very high and shouldn't typically be exceeded. 1231 // be very high and shouldn't typically be exceeded.
1227 size_t unused_memory_limit_in_bytes = static_cast<size_t>( 1232 size_t unused_memory_limit_in_bytes = static_cast<size_t>(
1228 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) * 1233 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) *
1229 settings_.max_unused_resource_memory_percentage) / 1234 settings_.max_unused_resource_memory_percentage) /
1230 100); 1235 100);
1231 1236
1232 DCHECK(resource_pool_); 1237 DCHECK(resource_pool_);
1233 resource_pool_->CheckBusyResources(); 1238 resource_pool_->CheckBusyResources(false);
1234 // Soft limit is used for resource pool such that memory returns to soft 1239 // Soft limit is used for resource pool such that memory returns to soft
1235 // limit after going over. 1240 // limit after going over.
1236 resource_pool_->SetResourceUsageLimits( 1241 resource_pool_->SetResourceUsageLimits(
1237 global_tile_state_.soft_memory_limit_in_bytes, 1242 global_tile_state_.soft_memory_limit_in_bytes,
1238 unused_memory_limit_in_bytes, 1243 unused_memory_limit_in_bytes,
1239 global_tile_state_.num_resources_limit); 1244 global_tile_state_.num_resources_limit);
1240 1245
1246 // Release all staging resources when invisible.
1247 if (staging_resource_pool_) {
1248 staging_resource_pool_->CheckBusyResources(false);
1249 staging_resource_pool_->SetResourceUsageLimits(
1250 std::numeric_limits<size_t>::max(),
1251 std::numeric_limits<size_t>::max(),
1252 visible_ ? GetMaxStagingResourceCount() : 0);
1253 }
1254
1241 DidModifyTilePriorities(); 1255 DidModifyTilePriorities();
1242 } 1256 }
1243 1257
1244 void LayerTreeHostImpl::DidModifyTilePriorities() { 1258 void LayerTreeHostImpl::DidModifyTilePriorities() {
1245 // Mark priorities as dirty and schedule a PrepareTiles(). 1259 // Mark priorities as dirty and schedule a PrepareTiles().
1246 tile_priorities_dirty_ = true; 1260 tile_priorities_dirty_ = true;
1247 client_->SetNeedsPrepareTilesOnImplThread(); 1261 client_->SetNeedsPrepareTilesOnImplThread();
1248 } 1262 }
1249 1263
1250 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( 1264 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue(
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 1458
1445 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) { 1459 void LayerTreeHostImpl::ReclaimResources(const CompositorFrameAck* ack) {
1446 // TODO(piman): We may need to do some validation on this ack before 1460 // TODO(piman): We may need to do some validation on this ack before
1447 // processing it. 1461 // processing it.
1448 if (renderer_) 1462 if (renderer_)
1449 renderer_->ReceiveSwapBuffersAck(*ack); 1463 renderer_->ReceiveSwapBuffersAck(*ack);
1450 1464
1451 // In OOM, we now might be able to release more resources that were held 1465 // In OOM, we now might be able to release more resources that were held
1452 // because they were exported. 1466 // because they were exported.
1453 if (resource_pool_) { 1467 if (resource_pool_) {
1454 resource_pool_->CheckBusyResources(); 1468 resource_pool_->CheckBusyResources(false);
1455 resource_pool_->ReduceResourceUsage(); 1469 resource_pool_->ReduceResourceUsage();
1456 } 1470 }
1457 // If we're not visible, we likely released resources, so we want to 1471 // If we're not visible, we likely released resources, so we want to
1458 // aggressively flush here to make sure those DeleteTextures make it to the 1472 // aggressively flush here to make sure those DeleteTextures make it to the
1459 // GPU process to free up the memory. 1473 // GPU process to free up the memory.
1460 if (output_surface_->context_provider() && !visible_) { 1474 if (output_surface_->context_provider() && !visible_) {
1461 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM(); 1475 output_surface_->context_provider()->ContextGL()->ShallowFlushCHROMIUM();
1462 } 1476 }
1463 } 1477 }
1464 1478
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be 2054 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be
2041 // initialized to get max texture size. Also, after releasing resources, 2055 // initialized to get max texture size. Also, after releasing resources,
2042 // trees need another update to generate new ones. 2056 // trees need another update to generate new ones.
2043 active_tree_->set_needs_update_draw_properties(); 2057 active_tree_->set_needs_update_draw_properties();
2044 if (pending_tree_) 2058 if (pending_tree_)
2045 pending_tree_->set_needs_update_draw_properties(); 2059 pending_tree_->set_needs_update_draw_properties();
2046 client_->UpdateRendererCapabilitiesOnImplThread(); 2060 client_->UpdateRendererCapabilitiesOnImplThread();
2047 } 2061 }
2048 2062
2049 void LayerTreeHostImpl::CreateTileManagerResources() { 2063 void LayerTreeHostImpl::CreateTileManagerResources() {
2050 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_); 2064 CreateResourceAndTileTaskWorkerPool(&tile_task_worker_pool_, &resource_pool_,
2065 &staging_resource_pool_);
2051 // TODO(vmpstr): Initialize tile task limit at ctor time. 2066 // TODO(vmpstr): Initialize tile task limit at ctor time.
2052 tile_manager_->SetResources( 2067 tile_manager_->SetResources(
2053 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(), 2068 resource_pool_.get(), tile_task_worker_pool_->AsTileTaskRunner(),
2054 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max() 2069 is_synchronous_single_threaded_ ? std::numeric_limits<size_t>::max()
2055 : settings_.scheduled_raster_task_limit); 2070 : settings_.scheduled_raster_task_limit);
2056 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); 2071 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy());
2057 } 2072 }
2058 2073
2059 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( 2074 void LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
2060 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, 2075 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
2061 scoped_ptr<ResourcePool>* resource_pool) { 2076 scoped_ptr<ResourcePool>* resource_pool,
2077 scoped_ptr<ResourcePool>* staging_resource_pool) {
2062 DCHECK(GetTaskRunner()); 2078 DCHECK(GetTaskRunner());
2063 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is 2079 // TODO(vmpstr): Make this a DCHECK (or remove) when crbug.com/419086 is
2064 // resolved. 2080 // resolved.
2065 CHECK(resource_provider_); 2081 CHECK(resource_provider_);
2066 2082
2067 // Pass the single-threaded synchronous task graph runner to the worker pool 2083 // Pass the single-threaded synchronous task graph runner to the worker pool
2068 // if we're in synchronous single-threaded mode. 2084 // if we're in synchronous single-threaded mode.
2069 TaskGraphRunner* task_graph_runner = task_graph_runner_; 2085 TaskGraphRunner* task_graph_runner = task_graph_runner_;
2070 if (is_synchronous_single_threaded_) { 2086 if (is_synchronous_single_threaded_) {
2071 DCHECK(!single_thread_synchronous_task_graph_runner_); 2087 DCHECK(!single_thread_synchronous_task_graph_runner_);
(...skipping 29 matching lines...) Expand all
2101 2117
2102 if (settings_.use_zero_copy) { 2118 if (settings_.use_zero_copy) {
2103 *resource_pool = ResourcePool::Create(resource_provider_.get()); 2119 *resource_pool = ResourcePool::Create(resource_provider_.get());
2104 2120
2105 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( 2121 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create(
2106 GetTaskRunner(), task_graph_runner, resource_provider_.get()); 2122 GetTaskRunner(), task_graph_runner, resource_provider_.get());
2107 return; 2123 return;
2108 } 2124 }
2109 2125
2110 if (settings_.use_one_copy) { 2126 if (settings_.use_one_copy) {
2127 // Synchronous single-threaded mode depends on tiles being ready to
2128 // draw when raster is complete. Therefore, it must use one of zero
2129 // copy, software raster, or GPU raster.
2130 DCHECK(!is_synchronous_single_threaded_);
2131
2132 // We need to create a staging resource pool when using copy rasterizer.
2133 *staging_resource_pool = ResourcePool::Create(resource_provider_.get());
2111 *resource_pool = 2134 *resource_pool =
2112 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); 2135 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D);
2113 2136
2114 int max_copy_texture_chromium_size = 2137 int max_copy_texture_chromium_size =
2115 context_provider->ContextCapabilities() 2138 context_provider->ContextCapabilities()
2116 .gpu.max_copy_texture_chromium_size; 2139 .gpu.max_copy_texture_chromium_size;
2117 2140
2118 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( 2141 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create(
2119 GetTaskRunner(), task_graph_runner, context_provider, 2142 GetTaskRunner(), task_graph_runner, context_provider,
2120 resource_provider_.get(), max_copy_texture_chromium_size, 2143 resource_provider_.get(), staging_resource_pool_.get(),
2121 settings_.use_persistent_map_for_gpu_memory_buffers, 2144 max_copy_texture_chromium_size,
2122 settings_.max_staging_buffers); 2145 settings_.use_persistent_map_for_gpu_memory_buffers);
2123 return; 2146 return;
2124 } 2147 }
2125 2148
2126 // Synchronous single-threaded mode depends on tiles being ready to 2149 // Synchronous single-threaded mode depends on tiles being ready to
2127 // draw when raster is complete. Therefore, it must use one of zero 2150 // draw when raster is complete. Therefore, it must use one of zero
2128 // copy, software raster, or GPU raster (in the branches above). 2151 // copy, software raster, or GPU raster (in the branches above).
2129 DCHECK(!is_synchronous_single_threaded_); 2152 DCHECK(!is_synchronous_single_threaded_);
2130 2153
2131 *resource_pool = ResourcePool::Create( 2154 *resource_pool = ResourcePool::Create(
2132 resource_provider_.get(), GL_TEXTURE_2D); 2155 resource_provider_.get(), GL_TEXTURE_2D);
(...skipping 22 matching lines...) Expand all
2155 void LayerTreeHostImpl::PostFrameTimingEvents( 2178 void LayerTreeHostImpl::PostFrameTimingEvents(
2156 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 2179 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
2157 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 2180 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
2158 client_->PostFrameTimingEventsOnImplThread(composite_events.Pass(), 2181 client_->PostFrameTimingEventsOnImplThread(composite_events.Pass(),
2159 main_frame_events.Pass()); 2182 main_frame_events.Pass());
2160 } 2183 }
2161 2184
2162 void LayerTreeHostImpl::CleanUpTileManager() { 2185 void LayerTreeHostImpl::CleanUpTileManager() {
2163 tile_manager_->FinishTasksAndCleanUp(); 2186 tile_manager_->FinishTasksAndCleanUp();
2164 resource_pool_ = nullptr; 2187 resource_pool_ = nullptr;
2188 staging_resource_pool_ = nullptr;
2165 tile_task_worker_pool_ = nullptr; 2189 tile_task_worker_pool_ = nullptr;
2166 single_thread_synchronous_task_graph_runner_ = nullptr; 2190 single_thread_synchronous_task_graph_runner_ = nullptr;
2167 } 2191 }
2168 2192
2169 bool LayerTreeHostImpl::InitializeRenderer( 2193 bool LayerTreeHostImpl::InitializeRenderer(
2170 scoped_ptr<OutputSurface> output_surface) { 2194 scoped_ptr<OutputSurface> output_surface) {
2171 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); 2195 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer");
2172 2196
2173 // Since we will create a new resource provider, we cannot continue to use 2197 // Since we will create a new resource provider, we cannot continue to use
2174 // the old resources (i.e. render_surfaces and texture IDs). Clear them 2198 // the old resources (i.e. render_surfaces and texture IDs). Clear them
(...skipping 13 matching lines...) Expand all
2188 return false; 2212 return false;
2189 } 2213 }
2190 2214
2191 output_surface_ = output_surface.Pass(); 2215 output_surface_ = output_surface.Pass();
2192 resource_provider_ = ResourceProvider::Create( 2216 resource_provider_ = ResourceProvider::Create(
2193 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_, 2217 output_surface_.get(), shared_bitmap_manager_, gpu_memory_buffer_manager_,
2194 proxy_->blocking_main_thread_task_runner(), 2218 proxy_->blocking_main_thread_task_runner(),
2195 settings_.renderer_settings.highp_threshold_min, 2219 settings_.renderer_settings.highp_threshold_min,
2196 settings_.renderer_settings.use_rgba_4444_textures, 2220 settings_.renderer_settings.use_rgba_4444_textures,
2197 settings_.renderer_settings.texture_id_allocation_chunk_size, 2221 settings_.renderer_settings.texture_id_allocation_chunk_size,
2222 settings_.use_persistent_map_for_gpu_memory_buffers,
2198 settings_.use_image_texture_targets); 2223 settings_.use_image_texture_targets);
2199 2224
2200 CreateAndSetRenderer(); 2225 CreateAndSetRenderer();
2201 2226
2202 // Since the new renderer may be capable of MSAA, update status here. 2227 // Since the new renderer may be capable of MSAA, update status here.
2203 UpdateGpuRasterizationStatus(); 2228 UpdateGpuRasterizationStatus();
2204 2229
2205 CreateTileManagerResources(); 2230 CreateTileManagerResources();
2206 RecreateTreeResources(); 2231 RecreateTreeResources();
2207 2232
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
3603 if (active_tree()) { 3628 if (active_tree()) {
3604 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); 3629 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id);
3605 if (layer) 3630 if (layer)
3606 return layer->ScrollOffsetForAnimation(); 3631 return layer->ScrollOffsetForAnimation();
3607 } 3632 }
3608 3633
3609 return gfx::ScrollOffset(); 3634 return gfx::ScrollOffset();
3610 } 3635 }
3611 3636
3612 } // namespace cc 3637 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_pixeltest_tiles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698