| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "cc/debug/lap_timer.h" | 12 #include "cc/debug/lap_timer.h" |
| 13 #include "cc/output/context_provider.h" | 13 #include "cc/output/context_provider.h" |
| 14 #include "cc/raster/bitmap_tile_task_worker_pool.h" | 14 #include "cc/raster/bitmap_tile_task_worker_pool.h" |
| 15 #include "cc/raster/gpu_rasterizer.h" | 15 #include "cc/raster/gpu_rasterizer.h" |
| 16 #include "cc/raster/gpu_tile_task_worker_pool.h" | 16 #include "cc/raster/gpu_tile_task_worker_pool.h" |
| 17 #include "cc/raster/one_copy_tile_task_worker_pool.h" | 17 #include "cc/raster/one_copy_tile_task_worker_pool.h" |
| 18 #include "cc/raster/synchronous_task_graph_runner.h" | 18 #include "cc/raster/synchronous_task_graph_runner.h" |
| 19 #include "cc/raster/tile_task_runner.h" | |
| 20 #include "cc/raster/tile_task_worker_pool.h" | 19 #include "cc/raster/tile_task_worker_pool.h" |
| 21 #include "cc/raster/zero_copy_tile_task_worker_pool.h" | 20 #include "cc/raster/zero_copy_tile_task_worker_pool.h" |
| 22 #include "cc/resources/resource_pool.h" | 21 #include "cc/resources/resource_pool.h" |
| 23 #include "cc/resources/resource_provider.h" | 22 #include "cc/resources/resource_provider.h" |
| 24 #include "cc/resources/scoped_resource.h" | 23 #include "cc/resources/scoped_resource.h" |
| 25 #include "cc/test/fake_output_surface.h" | 24 #include "cc/test/fake_output_surface.h" |
| 26 #include "cc/test/fake_output_surface_client.h" | 25 #include "cc/test/fake_output_surface_client.h" |
| 27 #include "cc/test/fake_resource_provider.h" | 26 #include "cc/test/fake_resource_provider.h" |
| 28 #include "cc/test/test_context_support.h" | 27 #include "cc/test/test_context_support.h" |
| 29 #include "cc/test/test_gpu_memory_buffer_manager.h" | 28 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 CreateSoftwareOutputSurfaceAndResourceProvider(); | 280 CreateSoftwareOutputSurfaceAndResourceProvider(); |
| 282 tile_task_worker_pool_ = BitmapTileTaskWorkerPool::Create( | 281 tile_task_worker_pool_ = BitmapTileTaskWorkerPool::Create( |
| 283 task_runner_.get(), task_graph_runner_.get(), | 282 task_runner_.get(), task_graph_runner_.get(), |
| 284 resource_provider_.get()); | 283 resource_provider_.get()); |
| 285 break; | 284 break; |
| 286 } | 285 } |
| 287 | 286 |
| 288 DCHECK(tile_task_worker_pool_); | 287 DCHECK(tile_task_worker_pool_); |
| 289 } | 288 } |
| 290 void TearDown() override { | 289 void TearDown() override { |
| 291 tile_task_worker_pool_->AsTileTaskRunner()->Shutdown(); | 290 tile_task_worker_pool_->Shutdown(); |
| 292 tile_task_worker_pool_->AsTileTaskRunner()->CheckForCompletedTasks(); | 291 tile_task_worker_pool_->CheckForCompletedTasks(); |
| 293 } | 292 } |
| 294 | 293 |
| 295 void RunMessageLoopUntilAllTasksHaveCompleted() { | 294 void RunMessageLoopUntilAllTasksHaveCompleted() { |
| 296 task_graph_runner_->RunUntilIdle(); | 295 task_graph_runner_->RunUntilIdle(); |
| 297 task_runner_->RunUntilIdle(); | 296 task_runner_->RunUntilIdle(); |
| 298 } | 297 } |
| 299 | 298 |
| 300 void RunScheduleTasksTest(const std::string& test_name, | 299 void RunScheduleTasksTest(const std::string& test_name, |
| 301 unsigned num_raster_tasks, | 300 unsigned num_raster_tasks, |
| 302 unsigned num_image_decode_tasks) { | 301 unsigned num_image_decode_tasks) { |
| 303 TileTask::Vector image_decode_tasks; | 302 TileTask::Vector image_decode_tasks; |
| 304 RasterTaskVector raster_tasks; | 303 RasterTaskVector raster_tasks; |
| 305 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks); | 304 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks); |
| 306 CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks); | 305 CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks); |
| 307 | 306 |
| 308 // Avoid unnecessary heap allocations by reusing the same graph. | 307 // Avoid unnecessary heap allocations by reusing the same graph. |
| 309 TaskGraph graph; | 308 TaskGraph graph; |
| 310 | 309 |
| 311 timer_.Reset(); | 310 timer_.Reset(); |
| 312 do { | 311 do { |
| 313 graph.Reset(); | 312 graph.Reset(); |
| 314 BuildTileTaskGraph(&graph, raster_tasks); | 313 BuildTileTaskGraph(&graph, raster_tasks); |
| 315 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&graph); | 314 tile_task_worker_pool_->ScheduleTasks(&graph); |
| 316 tile_task_worker_pool_->AsTileTaskRunner()->CheckForCompletedTasks(); | 315 tile_task_worker_pool_->CheckForCompletedTasks(); |
| 317 timer_.NextLap(); | 316 timer_.NextLap(); |
| 318 } while (!timer_.HasTimeLimitExpired()); | 317 } while (!timer_.HasTimeLimitExpired()); |
| 319 | 318 |
| 320 TaskGraph empty; | 319 TaskGraph empty; |
| 321 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&empty); | 320 tile_task_worker_pool_->ScheduleTasks(&empty); |
| 322 RunMessageLoopUntilAllTasksHaveCompleted(); | 321 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 323 | 322 |
| 324 perf_test::PrintResult("schedule_tasks", TestModifierString(), test_name, | 323 perf_test::PrintResult("schedule_tasks", TestModifierString(), test_name, |
| 325 timer_.LapsPerSecond(), "runs/s", true); | 324 timer_.LapsPerSecond(), "runs/s", true); |
| 326 } | 325 } |
| 327 | 326 |
| 328 void RunScheduleAlternateTasksTest(const std::string& test_name, | 327 void RunScheduleAlternateTasksTest(const std::string& test_name, |
| 329 unsigned num_raster_tasks, | 328 unsigned num_raster_tasks, |
| 330 unsigned num_image_decode_tasks) { | 329 unsigned num_image_decode_tasks) { |
| 331 const size_t kNumVersions = 2; | 330 const size_t kNumVersions = 2; |
| 332 TileTask::Vector image_decode_tasks[kNumVersions]; | 331 TileTask::Vector image_decode_tasks[kNumVersions]; |
| 333 RasterTaskVector raster_tasks[kNumVersions]; | 332 RasterTaskVector raster_tasks[kNumVersions]; |
| 334 for (size_t i = 0; i < kNumVersions; ++i) { | 333 for (size_t i = 0; i < kNumVersions; ++i) { |
| 335 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks[i]); | 334 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks[i]); |
| 336 CreateRasterTasks(num_raster_tasks, image_decode_tasks[i], | 335 CreateRasterTasks(num_raster_tasks, image_decode_tasks[i], |
| 337 &raster_tasks[i]); | 336 &raster_tasks[i]); |
| 338 } | 337 } |
| 339 | 338 |
| 340 // Avoid unnecessary heap allocations by reusing the same graph. | 339 // Avoid unnecessary heap allocations by reusing the same graph. |
| 341 TaskGraph graph; | 340 TaskGraph graph; |
| 342 | 341 |
| 343 size_t count = 0; | 342 size_t count = 0; |
| 344 timer_.Reset(); | 343 timer_.Reset(); |
| 345 do { | 344 do { |
| 346 graph.Reset(); | 345 graph.Reset(); |
| 347 BuildTileTaskGraph(&graph, raster_tasks[count % kNumVersions]); | 346 BuildTileTaskGraph(&graph, raster_tasks[count % kNumVersions]); |
| 348 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&graph); | 347 tile_task_worker_pool_->ScheduleTasks(&graph); |
| 349 tile_task_worker_pool_->AsTileTaskRunner()->CheckForCompletedTasks(); | 348 tile_task_worker_pool_->CheckForCompletedTasks(); |
| 350 ++count; | 349 ++count; |
| 351 timer_.NextLap(); | 350 timer_.NextLap(); |
| 352 } while (!timer_.HasTimeLimitExpired()); | 351 } while (!timer_.HasTimeLimitExpired()); |
| 353 | 352 |
| 354 TaskGraph empty; | 353 TaskGraph empty; |
| 355 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&empty); | 354 tile_task_worker_pool_->ScheduleTasks(&empty); |
| 356 RunMessageLoopUntilAllTasksHaveCompleted(); | 355 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 357 | 356 |
| 358 perf_test::PrintResult("schedule_alternate_tasks", TestModifierString(), | 357 perf_test::PrintResult("schedule_alternate_tasks", TestModifierString(), |
| 359 test_name, timer_.LapsPerSecond(), "runs/s", true); | 358 test_name, timer_.LapsPerSecond(), "runs/s", true); |
| 360 } | 359 } |
| 361 | 360 |
| 362 void RunScheduleAndExecuteTasksTest(const std::string& test_name, | 361 void RunScheduleAndExecuteTasksTest(const std::string& test_name, |
| 363 unsigned num_raster_tasks, | 362 unsigned num_raster_tasks, |
| 364 unsigned num_image_decode_tasks) { | 363 unsigned num_image_decode_tasks) { |
| 365 TileTask::Vector image_decode_tasks; | 364 TileTask::Vector image_decode_tasks; |
| 366 RasterTaskVector raster_tasks; | 365 RasterTaskVector raster_tasks; |
| 367 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks); | 366 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks); |
| 368 CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks); | 367 CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks); |
| 369 | 368 |
| 370 // Avoid unnecessary heap allocations by reusing the same graph. | 369 // Avoid unnecessary heap allocations by reusing the same graph. |
| 371 TaskGraph graph; | 370 TaskGraph graph; |
| 372 | 371 |
| 373 timer_.Reset(); | 372 timer_.Reset(); |
| 374 do { | 373 do { |
| 375 graph.Reset(); | 374 graph.Reset(); |
| 376 BuildTileTaskGraph(&graph, raster_tasks); | 375 BuildTileTaskGraph(&graph, raster_tasks); |
| 377 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&graph); | 376 tile_task_worker_pool_->ScheduleTasks(&graph); |
| 378 RunMessageLoopUntilAllTasksHaveCompleted(); | 377 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 379 timer_.NextLap(); | 378 timer_.NextLap(); |
| 380 } while (!timer_.HasTimeLimitExpired()); | 379 } while (!timer_.HasTimeLimitExpired()); |
| 381 | 380 |
| 382 TaskGraph empty; | 381 TaskGraph empty; |
| 383 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&empty); | 382 tile_task_worker_pool_->ScheduleTasks(&empty); |
| 384 RunMessageLoopUntilAllTasksHaveCompleted(); | 383 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 385 | 384 |
| 386 perf_test::PrintResult("schedule_and_execute_tasks", TestModifierString(), | 385 perf_test::PrintResult("schedule_and_execute_tasks", TestModifierString(), |
| 387 test_name, timer_.LapsPerSecond(), "runs/s", true); | 386 test_name, timer_.LapsPerSecond(), "runs/s", true); |
| 388 } | 387 } |
| 389 | 388 |
| 390 private: | 389 private: |
| 391 void Create3dOutputSurfaceAndResourceProvider() { | 390 void Create3dOutputSurfaceAndResourceProvider() { |
| 392 output_surface_ = FakeOutputSurface::Create3d(context_provider_); | 391 output_surface_ = FakeOutputSurface::Create3d(context_provider_); |
| 393 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 392 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 RunBuildTileTaskGraphTest("1_0", 1, 0); | 494 RunBuildTileTaskGraphTest("1_0", 1, 0); |
| 496 RunBuildTileTaskGraphTest("32_0", 32, 0); | 495 RunBuildTileTaskGraphTest("32_0", 32, 0); |
| 497 RunBuildTileTaskGraphTest("1_1", 1, 1); | 496 RunBuildTileTaskGraphTest("1_1", 1, 1); |
| 498 RunBuildTileTaskGraphTest("32_1", 32, 1); | 497 RunBuildTileTaskGraphTest("32_1", 32, 1); |
| 499 RunBuildTileTaskGraphTest("1_4", 1, 4); | 498 RunBuildTileTaskGraphTest("1_4", 1, 4); |
| 500 RunBuildTileTaskGraphTest("32_4", 32, 4); | 499 RunBuildTileTaskGraphTest("32_4", 32, 4); |
| 501 } | 500 } |
| 502 | 501 |
| 503 } // namespace | 502 } // namespace |
| 504 } // namespace cc | 503 } // namespace cc |
| OLD | NEW |