| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "cc/resources/resource_pool.h" | 21 #include "cc/resources/resource_pool.h" |
| 22 #include "cc/resources/resource_provider.h" | 22 #include "cc/resources/resource_provider.h" |
| 23 #include "cc/resources/scoped_resource.h" | 23 #include "cc/resources/scoped_resource.h" |
| 24 #include "cc/test/fake_output_surface.h" | 24 #include "cc/test/fake_output_surface.h" |
| 25 #include "cc/test/fake_output_surface_client.h" | 25 #include "cc/test/fake_output_surface_client.h" |
| 26 #include "cc/test/fake_resource_provider.h" | 26 #include "cc/test/fake_resource_provider.h" |
| 27 #include "cc/test/test_context_support.h" | 27 #include "cc/test/test_context_support.h" |
| 28 #include "cc/test/test_gpu_memory_buffer_manager.h" | 28 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 29 #include "cc/test/test_shared_bitmap_manager.h" | 29 #include "cc/test/test_shared_bitmap_manager.h" |
| 30 #include "cc/test/test_web_graphics_context_3d.h" | 30 #include "cc/test/test_web_graphics_context_3d.h" |
| 31 #include "cc/tiles/tile_task_manager.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 32 #include "testing/perf/perf_test.h" | 33 #include "testing/perf/perf_test.h" |
| 33 #include "third_party/khronos/GLES2/gl2.h" | 34 #include "third_party/khronos/GLES2/gl2.h" |
| 34 #include "third_party/skia/include/gpu/GrContext.h" | 35 #include "third_party/skia/include/gpu/GrContext.h" |
| 35 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 36 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 36 | 37 |
| 37 namespace cc { | 38 namespace cc { |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 class PerfGLES2Interface : public gpu::gles2::GLES2InterfaceStub { | 41 class PerfGLES2Interface : public gpu::gles2::GLES2InterfaceStub { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 std::unique_ptr<SynchronousTaskGraphRunner> task_graph_runner_; | 249 std::unique_ptr<SynchronousTaskGraphRunner> task_graph_runner_; |
| 249 LapTimer timer_; | 250 LapTimer timer_; |
| 250 }; | 251 }; |
| 251 | 252 |
| 252 class TileTaskWorkerPoolPerfTest | 253 class TileTaskWorkerPoolPerfTest |
| 253 : public TileTaskWorkerPoolPerfTestBase, | 254 : public TileTaskWorkerPoolPerfTestBase, |
| 254 public testing::TestWithParam<TileTaskWorkerPoolType> { | 255 public testing::TestWithParam<TileTaskWorkerPoolType> { |
| 255 public: | 256 public: |
| 256 // Overridden from testing::Test: | 257 // Overridden from testing::Test: |
| 257 void SetUp() override { | 258 void SetUp() override { |
| 259 std::unique_ptr<TileTaskWorkerPool> tile_task_worker_pool; |
| 258 switch (GetParam()) { | 260 switch (GetParam()) { |
| 259 case TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY: | 261 case TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY: |
| 260 Create3dOutputSurfaceAndResourceProvider(); | 262 Create3dOutputSurfaceAndResourceProvider(); |
| 261 tile_task_worker_pool_ = ZeroCopyTileTaskWorkerPool::Create( | 263 tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( |
| 262 task_runner_.get(), task_graph_runner_.get(), | |
| 263 resource_provider_.get(), PlatformColor::BestTextureFormat()); | 264 resource_provider_.get(), PlatformColor::BestTextureFormat()); |
| 264 break; | 265 break; |
| 265 case TILE_TASK_WORKER_POOL_TYPE_ONE_COPY: | 266 case TILE_TASK_WORKER_POOL_TYPE_ONE_COPY: |
| 266 Create3dOutputSurfaceAndResourceProvider(); | 267 Create3dOutputSurfaceAndResourceProvider(); |
| 267 tile_task_worker_pool_ = OneCopyTileTaskWorkerPool::Create( | 268 tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( |
| 268 task_runner_.get(), task_graph_runner_.get(), | 269 task_runner_.get(), context_provider_.get(), |
| 269 context_provider_.get(), resource_provider_.get(), | 270 resource_provider_.get(), std::numeric_limits<int>::max(), false, |
| 270 std::numeric_limits<int>::max(), false, | |
| 271 std::numeric_limits<int>::max(), | 271 std::numeric_limits<int>::max(), |
| 272 PlatformColor::BestTextureFormat()); | 272 PlatformColor::BestTextureFormat()); |
| 273 break; | 273 break; |
| 274 case TILE_TASK_WORKER_POOL_TYPE_GPU: | 274 case TILE_TASK_WORKER_POOL_TYPE_GPU: |
| 275 Create3dOutputSurfaceAndResourceProvider(); | 275 Create3dOutputSurfaceAndResourceProvider(); |
| 276 tile_task_worker_pool_ = GpuTileTaskWorkerPool::Create( | 276 tile_task_worker_pool = GpuTileTaskWorkerPool::Create( |
| 277 task_runner_.get(), task_graph_runner_.get(), | |
| 278 context_provider_.get(), resource_provider_.get(), false, 0); | 277 context_provider_.get(), resource_provider_.get(), false, 0); |
| 279 break; | 278 break; |
| 280 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: | 279 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: |
| 281 CreateSoftwareOutputSurfaceAndResourceProvider(); | 280 CreateSoftwareOutputSurfaceAndResourceProvider(); |
| 282 tile_task_worker_pool_ = BitmapTileTaskWorkerPool::Create( | 281 tile_task_worker_pool = |
| 283 task_runner_.get(), task_graph_runner_.get(), | 282 BitmapTileTaskWorkerPool::Create(resource_provider_.get()); |
| 284 resource_provider_.get()); | |
| 285 break; | 283 break; |
| 286 } | 284 } |
| 287 | 285 |
| 288 DCHECK(tile_task_worker_pool_); | 286 DCHECK(tile_task_worker_pool); |
| 287 |
| 288 tile_task_manager_ = TileTaskManager::Create( |
| 289 std::move(tile_task_worker_pool), task_graph_runner_.get()); |
| 289 } | 290 } |
| 290 void TearDown() override { | 291 void TearDown() override { |
| 291 tile_task_worker_pool_->Shutdown(); | 292 tile_task_manager_->Shutdown(); |
| 292 tile_task_worker_pool_->CheckForCompletedTasks(); | 293 tile_task_manager_->CheckForCompletedTasks(); |
| 293 } | 294 } |
| 294 | 295 |
| 295 void RunMessageLoopUntilAllTasksHaveCompleted() { | 296 void RunMessageLoopUntilAllTasksHaveCompleted() { |
| 296 task_graph_runner_->RunUntilIdle(); | 297 task_graph_runner_->RunUntilIdle(); |
| 297 task_runner_->RunUntilIdle(); | 298 task_runner_->RunUntilIdle(); |
| 298 } | 299 } |
| 299 | 300 |
| 300 void RunScheduleTasksTest(const std::string& test_name, | 301 void RunScheduleTasksTest(const std::string& test_name, |
| 301 unsigned num_raster_tasks, | 302 unsigned num_raster_tasks, |
| 302 unsigned num_image_decode_tasks) { | 303 unsigned num_image_decode_tasks) { |
| 303 RasterTaskVector raster_tasks; | 304 RasterTaskVector raster_tasks; |
| 304 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, &raster_tasks); | 305 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, &raster_tasks); |
| 305 | 306 |
| 306 // Avoid unnecessary heap allocations by reusing the same graph. | 307 // Avoid unnecessary heap allocations by reusing the same graph. |
| 307 TaskGraph graph; | 308 TaskGraph graph; |
| 308 | 309 |
| 309 timer_.Reset(); | 310 timer_.Reset(); |
| 310 do { | 311 do { |
| 311 graph.Reset(); | 312 graph.Reset(); |
| 312 BuildTileTaskGraph(&graph, raster_tasks); | 313 BuildTileTaskGraph(&graph, raster_tasks); |
| 313 tile_task_worker_pool_->ScheduleTasks(&graph); | 314 tile_task_manager_->ScheduleTasks(&graph); |
| 314 tile_task_worker_pool_->CheckForCompletedTasks(); | 315 tile_task_manager_->CheckForCompletedTasks(); |
| 315 timer_.NextLap(); | 316 timer_.NextLap(); |
| 316 } while (!timer_.HasTimeLimitExpired()); | 317 } while (!timer_.HasTimeLimitExpired()); |
| 317 | 318 |
| 318 TaskGraph empty; | 319 TaskGraph empty; |
| 319 tile_task_worker_pool_->ScheduleTasks(&empty); | 320 tile_task_manager_->ScheduleTasks(&empty); |
| 320 RunMessageLoopUntilAllTasksHaveCompleted(); | 321 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 321 | 322 |
| 322 perf_test::PrintResult("schedule_tasks", TestModifierString(), test_name, | 323 perf_test::PrintResult("schedule_tasks", TestModifierString(), test_name, |
| 323 timer_.LapsPerSecond(), "runs/s", true); | 324 timer_.LapsPerSecond(), "runs/s", true); |
| 324 } | 325 } |
| 325 | 326 |
| 326 void RunScheduleAlternateTasksTest(const std::string& test_name, | 327 void RunScheduleAlternateTasksTest(const std::string& test_name, |
| 327 unsigned num_raster_tasks, | 328 unsigned num_raster_tasks, |
| 328 unsigned num_image_decode_tasks) { | 329 unsigned num_image_decode_tasks) { |
| 329 const size_t kNumVersions = 2; | 330 const size_t kNumVersions = 2; |
| 330 RasterTaskVector raster_tasks[kNumVersions]; | 331 RasterTaskVector raster_tasks[kNumVersions]; |
| 331 for (size_t i = 0; i < kNumVersions; ++i) { | 332 for (size_t i = 0; i < kNumVersions; ++i) { |
| 332 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, | 333 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, |
| 333 &raster_tasks[i]); | 334 &raster_tasks[i]); |
| 334 } | 335 } |
| 335 | 336 |
| 336 // Avoid unnecessary heap allocations by reusing the same graph. | 337 // Avoid unnecessary heap allocations by reusing the same graph. |
| 337 TaskGraph graph; | 338 TaskGraph graph; |
| 338 | 339 |
| 339 size_t count = 0; | 340 size_t count = 0; |
| 340 timer_.Reset(); | 341 timer_.Reset(); |
| 341 do { | 342 do { |
| 342 graph.Reset(); | 343 graph.Reset(); |
| 343 BuildTileTaskGraph(&graph, raster_tasks[count % kNumVersions]); | 344 BuildTileTaskGraph(&graph, raster_tasks[count % kNumVersions]); |
| 344 tile_task_worker_pool_->ScheduleTasks(&graph); | 345 tile_task_manager_->ScheduleTasks(&graph); |
| 345 tile_task_worker_pool_->CheckForCompletedTasks(); | 346 tile_task_manager_->CheckForCompletedTasks(); |
| 346 ++count; | 347 ++count; |
| 347 timer_.NextLap(); | 348 timer_.NextLap(); |
| 348 } while (!timer_.HasTimeLimitExpired()); | 349 } while (!timer_.HasTimeLimitExpired()); |
| 349 | 350 |
| 350 TaskGraph empty; | 351 TaskGraph empty; |
| 351 tile_task_worker_pool_->ScheduleTasks(&empty); | 352 tile_task_manager_->ScheduleTasks(&empty); |
| 352 RunMessageLoopUntilAllTasksHaveCompleted(); | 353 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 353 | 354 |
| 354 perf_test::PrintResult("schedule_alternate_tasks", TestModifierString(), | 355 perf_test::PrintResult("schedule_alternate_tasks", TestModifierString(), |
| 355 test_name, timer_.LapsPerSecond(), "runs/s", true); | 356 test_name, timer_.LapsPerSecond(), "runs/s", true); |
| 356 } | 357 } |
| 357 | 358 |
| 358 void RunScheduleAndExecuteTasksTest(const std::string& test_name, | 359 void RunScheduleAndExecuteTasksTest(const std::string& test_name, |
| 359 unsigned num_raster_tasks, | 360 unsigned num_raster_tasks, |
| 360 unsigned num_image_decode_tasks) { | 361 unsigned num_image_decode_tasks) { |
| 361 RasterTaskVector raster_tasks; | 362 RasterTaskVector raster_tasks; |
| 362 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, &raster_tasks); | 363 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, &raster_tasks); |
| 363 | 364 |
| 364 // Avoid unnecessary heap allocations by reusing the same graph. | 365 // Avoid unnecessary heap allocations by reusing the same graph. |
| 365 TaskGraph graph; | 366 TaskGraph graph; |
| 366 | 367 |
| 367 timer_.Reset(); | 368 timer_.Reset(); |
| 368 do { | 369 do { |
| 369 graph.Reset(); | 370 graph.Reset(); |
| 370 BuildTileTaskGraph(&graph, raster_tasks); | 371 BuildTileTaskGraph(&graph, raster_tasks); |
| 371 tile_task_worker_pool_->ScheduleTasks(&graph); | 372 tile_task_manager_->ScheduleTasks(&graph); |
| 372 RunMessageLoopUntilAllTasksHaveCompleted(); | 373 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 373 timer_.NextLap(); | 374 timer_.NextLap(); |
| 374 } while (!timer_.HasTimeLimitExpired()); | 375 } while (!timer_.HasTimeLimitExpired()); |
| 375 | 376 |
| 376 TaskGraph empty; | 377 TaskGraph empty; |
| 377 tile_task_worker_pool_->ScheduleTasks(&empty); | 378 tile_task_manager_->ScheduleTasks(&empty); |
| 378 RunMessageLoopUntilAllTasksHaveCompleted(); | 379 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 379 | 380 |
| 380 perf_test::PrintResult("schedule_and_execute_tasks", TestModifierString(), | 381 perf_test::PrintResult("schedule_and_execute_tasks", TestModifierString(), |
| 381 test_name, timer_.LapsPerSecond(), "runs/s", true); | 382 test_name, timer_.LapsPerSecond(), "runs/s", true); |
| 382 } | 383 } |
| 383 | 384 |
| 384 private: | 385 private: |
| 385 void Create3dOutputSurfaceAndResourceProvider() { | 386 void Create3dOutputSurfaceAndResourceProvider() { |
| 386 output_surface_ = FakeOutputSurface::Create3d(context_provider_); | 387 output_surface_ = FakeOutputSurface::Create3d(context_provider_); |
| 387 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 388 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 405 return std::string("_one_copy_tile_task_worker_pool"); | 406 return std::string("_one_copy_tile_task_worker_pool"); |
| 406 case TILE_TASK_WORKER_POOL_TYPE_GPU: | 407 case TILE_TASK_WORKER_POOL_TYPE_GPU: |
| 407 return std::string("_gpu_tile_task_worker_pool"); | 408 return std::string("_gpu_tile_task_worker_pool"); |
| 408 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: | 409 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: |
| 409 return std::string("_bitmap_tile_task_worker_pool"); | 410 return std::string("_bitmap_tile_task_worker_pool"); |
| 410 } | 411 } |
| 411 NOTREACHED(); | 412 NOTREACHED(); |
| 412 return std::string(); | 413 return std::string(); |
| 413 } | 414 } |
| 414 | 415 |
| 415 std::unique_ptr<TileTaskWorkerPool> tile_task_worker_pool_; | 416 std::unique_ptr<TileTaskManager> tile_task_manager_; |
| 416 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; | 417 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
| 417 TestSharedBitmapManager shared_bitmap_manager_; | 418 TestSharedBitmapManager shared_bitmap_manager_; |
| 418 }; | 419 }; |
| 419 | 420 |
| 420 TEST_P(TileTaskWorkerPoolPerfTest, ScheduleTasks) { | 421 TEST_P(TileTaskWorkerPoolPerfTest, ScheduleTasks) { |
| 421 RunScheduleTasksTest("1_0", 1, 0); | 422 RunScheduleTasksTest("1_0", 1, 0); |
| 422 RunScheduleTasksTest("32_0", 32, 0); | 423 RunScheduleTasksTest("32_0", 32, 0); |
| 423 RunScheduleTasksTest("1_1", 1, 1); | 424 RunScheduleTasksTest("1_1", 1, 1); |
| 424 RunScheduleTasksTest("32_1", 32, 1); | 425 RunScheduleTasksTest("32_1", 32, 1); |
| 425 RunScheduleTasksTest("1_4", 1, 4); | 426 RunScheduleTasksTest("1_4", 1, 4); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 RunBuildTileTaskGraphTest("1_0", 1, 0); | 488 RunBuildTileTaskGraphTest("1_0", 1, 0); |
| 488 RunBuildTileTaskGraphTest("32_0", 32, 0); | 489 RunBuildTileTaskGraphTest("32_0", 32, 0); |
| 489 RunBuildTileTaskGraphTest("1_1", 1, 1); | 490 RunBuildTileTaskGraphTest("1_1", 1, 1); |
| 490 RunBuildTileTaskGraphTest("32_1", 32, 1); | 491 RunBuildTileTaskGraphTest("32_1", 32, 1); |
| 491 RunBuildTileTaskGraphTest("1_4", 1, 4); | 492 RunBuildTileTaskGraphTest("1_4", 1, 4); |
| 492 RunBuildTileTaskGraphTest("32_4", 32, 4); | 493 RunBuildTileTaskGraphTest("32_4", 32, 4); |
| 493 } | 494 } |
| 494 | 495 |
| 495 } // namespace | 496 } // namespace |
| 496 } // namespace cc | 497 } // namespace cc |
| OLD | NEW |