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

Unified Diff: cc/resources/tile_manager.cc

Issue 733773005: cc: GPU rasterize tiles synchronously in PrepareToDraw (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_manager_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/tile_manager.cc
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index d83b8243682e717fd3cf33b585742eff0c9d5472..d4fe7f3657e06f5be2bcd5e86f22fd4cc623d916 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -209,14 +209,12 @@ scoped_ptr<TileManager> TileManager::Create(
base::SequencedTaskRunner* task_runner,
ResourcePool* resource_pool,
Rasterizer* rasterizer,
+ GpuRasterizer* gpu_rasterizer,
RenderingStatsInstrumentation* rendering_stats_instrumentation,
size_t scheduled_raster_task_limit) {
- return make_scoped_ptr(new TileManager(client,
- task_runner,
- resource_pool,
- rasterizer,
- rendering_stats_instrumentation,
- scheduled_raster_task_limit));
+ return make_scoped_ptr(new TileManager(
+ client, task_runner, resource_pool, rasterizer, gpu_rasterizer,
+ rendering_stats_instrumentation, scheduled_raster_task_limit));
}
TileManager::TileManager(
@@ -224,12 +222,14 @@ TileManager::TileManager(
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
ResourcePool* resource_pool,
Rasterizer* rasterizer,
+ GpuRasterizer* gpu_rasterizer,
RenderingStatsInstrumentation* rendering_stats_instrumentation,
size_t scheduled_raster_task_limit)
: client_(client),
task_runner_(task_runner),
resource_pool_(resource_pool),
rasterizer_(rasterizer),
+ gpu_rasterizer_(gpu_rasterizer),
scheduled_raster_task_limit_(scheduled_raster_task_limit),
all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
rendering_stats_instrumentation_(rendering_stats_instrumentation),
@@ -329,8 +329,12 @@ void TileManager::DidFinishRunningTasks(TaskSet task_set) {
rasterizer_->CheckForCompletedTasks();
did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
+ client_->BuildRasterQueue(&raster_priority_queue_,
+ global_state_.tree_priority);
TileVector tiles_that_need_to_be_rasterized;
- AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized);
+ AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized,
+ scheduled_raster_task_limit_);
+ raster_priority_queue_.Reset();
// |tiles_that_need_to_be_rasterized| will be empty when we reach a
// steady memory state. Keep scheduling tasks until we reach this state.
@@ -354,12 +358,11 @@ void TileManager::DidFinishRunningTasks(TaskSet task_set) {
global_state_.memory_limit_policy != ALLOW_NOTHING;
// Use on-demand raster for any required-for-activation tiles that have
- // not
- // been been assigned memory after reaching a steady memory state. This
- // ensures that we activate even when OOM. Note that we have to rebuilt
- // the
- // queue in case the last AssignGpuMemoryToTiles evicted some tiles that
- // would otherwise not be picked up by the old raster queue.
+ // not been been assigned memory after reaching a steady memory
+ // state. This ensures that we activate even when OOM. Note that we have
+ // to rebuilt the queue in case the last AssignGpuMemoryToTiles evicted
+ // some tiles that would otherwise not be picked up by the old raster
+ // queue.
client_->BuildRasterQueue(&raster_priority_queue_,
global_state_.tree_priority);
bool ready_to_activate = true;
@@ -398,6 +401,55 @@ void TileManager::DidFinishRunningTasks(TaskSet task_set) {
NOTREACHED();
}
+void TileManager::RasterizeTiles(
+ const GlobalStateThatImpactsTilePriority& state) {
+ DCHECK(gpu_rasterizer_);
+ TRACE_EVENT0("cc", "TileManager::RasterizeTiles");
+
+ global_state_ = state;
+
+ FreeResourcesForReleasedTiles();
+ CleanUpReleasedTiles();
+
+ client_->BuildRasterQueue(&raster_priority_queue_,
+ global_state_.tree_priority);
+ TileVector tiles_that_need_to_be_rasterized;
+ AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized,
+ std::numeric_limits<size_t>::max());
+
+ // We must reduce the amount of unused resoruces before calling
+ // RunTasks to prevent usage from rising above limits.
+ resource_pool_->ReduceResourceUsage();
+
+ // Run and complete all raster task synchronously.
+ gpu_rasterizer_->RasterizeTiles(tiles_that_need_to_be_rasterized,
+ resource_pool_, this);
+
+ // Use on-demand raster for any tiles that have not been been assigned
+ // memory. This ensures that we draw even when OOM.
+ while (!raster_priority_queue_.IsEmpty()) {
+ Tile* tile = raster_priority_queue_.Top();
+ ManagedTileState& mts = tile->managed_state();
+
+ if (!mts.draw_info.IsReadyToDraw()) {
+ mts.draw_info.set_rasterize_on_demand();
+ client_->NotifyTileStateChanged(tile);
+ }
+ raster_priority_queue_.Pop();
+ }
+ raster_priority_queue_.Reset();
+
+ if (IsReadyToDraw())
+ client_->NotifyReadyToDraw();
+
+ TRACE_EVENT_INSTANT1("cc", "DidRasterize", TRACE_EVENT_SCOPE_THREAD, "state",
+ BasicStateAsValue());
+
+ TRACE_COUNTER_ID1("cc", "unused_memory_bytes", this,
+ resource_pool_->total_memory_usage_bytes() -
+ resource_pool_->acquired_memory_usage_bytes());
+}
+
void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) {
TRACE_EVENT0("cc", "TileManager::ManageTiles");
@@ -413,8 +465,12 @@ void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) {
FreeResourcesForReleasedTiles();
CleanUpReleasedTiles();
+ client_->BuildRasterQueue(&raster_priority_queue_,
+ global_state_.tree_priority);
TileVector tiles_that_need_to_be_rasterized;
- AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized);
+ AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized,
+ scheduled_raster_task_limit_);
+ raster_priority_queue_.Reset();
// Finally, schedule rasterizer tasks.
ScheduleTasks(tiles_that_need_to_be_rasterized);
@@ -531,7 +587,8 @@ bool TileManager::TilePriorityViolatesMemoryPolicy(
}
void TileManager::AssignGpuMemoryToTiles(
- TileVector* tiles_that_need_to_be_rasterized) {
+ TileVector* tiles_that_need_to_be_rasterized,
+ size_t scheduled_raster_task_limit) {
TRACE_EVENT_BEGIN0("cc", "TileManager::AssignGpuMemoryToTiles");
// Maintain the list of released resources that can potentially be re-used
@@ -555,8 +612,6 @@ void TileManager::AssignGpuMemoryToTiles(
resource_pool_->acquired_resource_count());
eviction_priority_queue_is_up_to_date_ = false;
- client_->BuildRasterQueue(&raster_priority_queue_,
- global_state_.tree_priority);
while (!raster_priority_queue_.IsEmpty()) {
Tile* tile = raster_priority_queue_.Top();
@@ -572,7 +627,7 @@ void TileManager::AssignGpuMemoryToTiles(
// We won't be able to schedule this tile, so break out early.
if (tiles_that_need_to_be_rasterized->size() >=
- scheduled_raster_task_limit_) {
+ scheduled_raster_task_limit) {
all_tiles_that_need_to_be_rasterized_are_scheduled_ = false;
break;
}
@@ -637,8 +692,6 @@ void TileManager::AssignGpuMemoryToTiles(
memory_stats_from_last_assign_.had_enough_memory =
had_enough_memory_to_schedule_tiles_needed_now;
- raster_priority_queue_.Reset();
-
TRACE_EVENT_END2("cc",
"TileManager::AssignGpuMemoryToTiles",
"all_tiles_that_need_to_be_rasterized_are_scheduled",
@@ -794,6 +847,13 @@ void TileManager::OnImageDecodeTaskCompleted(int layer_id,
pixel_ref_tasks.erase(task_it);
}
+void TileManager::CompleteRasterTask(
+ Tile::Id tile_id,
+ scoped_ptr<ScopedResource> resource,
+ const RasterSource::SolidColorAnalysis& analysis) {
+ OnRasterTaskCompleted(tile_id, resource.Pass(), analysis, false);
+}
+
void TileManager::OnRasterTaskCompleted(
Tile::Id tile_id,
scoped_ptr<ScopedResource> resource,
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698