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

Side by Side Diff: cc/raster/raster_buffer_provider_perftest.cc

Issue 1951193002: cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: ericrk's review Created 4 years, 6 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
OLDNEW
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_raster_buffer_provider.h" 14 #include "cc/raster/bitmap_raster_buffer_provider.h"
15 #include "cc/raster/gpu_raster_buffer_provider.h" 15 #include "cc/raster/gpu_raster_buffer_provider.h"
16 #include "cc/raster/gpu_rasterizer.h"
17 #include "cc/raster/one_copy_raster_buffer_provider.h" 16 #include "cc/raster/one_copy_raster_buffer_provider.h"
18 #include "cc/raster/raster_buffer_provider.h" 17 #include "cc/raster/raster_buffer_provider.h"
19 #include "cc/raster/synchronous_task_graph_runner.h" 18 #include "cc/raster/synchronous_task_graph_runner.h"
20 #include "cc/raster/zero_copy_raster_buffer_provider.h" 19 #include "cc/raster/zero_copy_raster_buffer_provider.h"
20 #include "cc/resources/platform_color.h"
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 "cc/tiles/tile_task_manager.h"
32 #include "gpu/command_buffer/common/sync_token.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 #include "testing/perf/perf_test.h" 34 #include "testing/perf/perf_test.h"
34 #include "third_party/khronos/GLES2/gl2.h" 35 #include "third_party/khronos/GLES2/gl2.h"
35 #include "third_party/skia/include/gpu/GrContext.h" 36 #include "third_party/skia/include/gpu/GrContext.h"
36 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" 37 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
37 38
38 namespace cc { 39 namespace cc {
39 namespace { 40 namespace {
40 41
41 class PerfGLES2Interface : public gpu::gles2::GLES2InterfaceStub { 42 class PerfGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
(...skipping 19 matching lines...) Expand all
61 void GenQueriesEXT(GLsizei n, GLuint* queries) override { 62 void GenQueriesEXT(GLsizei n, GLuint* queries) override {
62 for (GLsizei i = 0; i < n; ++i) 63 for (GLsizei i = 0; i < n; ++i)
63 queries[i] = 1u; 64 queries[i] = 1u;
64 } 65 }
65 void GetQueryObjectuivEXT(GLuint query, 66 void GetQueryObjectuivEXT(GLuint query,
66 GLenum pname, 67 GLenum pname,
67 GLuint* params) override { 68 GLuint* params) override {
68 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT) 69 if (pname == GL_QUERY_RESULT_AVAILABLE_EXT)
69 *params = 1; 70 *params = 1;
70 } 71 }
72 void GenUnverifiedSyncTokenCHROMIUM(GLuint64 fence_sync,
73 GLbyte* sync_token) override {
74 // Copy the data over after setting the data to ensure alignment.
75 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0,
76 gpu::CommandBufferId(), fence_sync);
77 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data));
78 }
71 }; 79 };
72 80
73 class PerfContextProvider : public ContextProvider { 81 class PerfContextProvider : public ContextProvider {
74 public: 82 public:
75 PerfContextProvider() : context_gl_(new PerfGLES2Interface) {} 83 PerfContextProvider() : context_gl_(new PerfGLES2Interface) {}
76 84
77 bool BindToCurrentThread() override { return true; } 85 bool BindToCurrentThread() override { return true; }
78 gpu::Capabilities ContextCapabilities() override { 86 gpu::Capabilities ContextCapabilities() override {
79 gpu::Capabilities capabilities; 87 gpu::Capabilities capabilities;
80 capabilities.image = true; 88 capabilities.image = true;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 LapTimer timer_; 312 LapTimer timer_;
305 }; 313 };
306 314
307 class RasterBufferProviderPerfTest 315 class RasterBufferProviderPerfTest
308 : public RasterBufferProviderPerfTestBase, 316 : public RasterBufferProviderPerfTestBase,
309 public PerfRasterBufferProviderHelper, 317 public PerfRasterBufferProviderHelper,
310 public testing::TestWithParam<RasterBufferProviderType> { 318 public testing::TestWithParam<RasterBufferProviderType> {
311 public: 319 public:
312 // Overridden from testing::Test: 320 // Overridden from testing::Test:
313 void SetUp() override { 321 void SetUp() override {
314 std::unique_ptr<RasterBufferProvider> raster_buffer_provider;
315 switch (GetParam()) { 322 switch (GetParam()) {
316 case RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY: 323 case RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY:
317 Create3dOutputSurfaceAndResourceProvider(); 324 Create3dOutputSurfaceAndResourceProvider();
318 raster_buffer_provider = ZeroCopyRasterBufferProvider::Create( 325 raster_buffer_provider_ = ZeroCopyRasterBufferProvider::Create(
319 resource_provider_.get(), PlatformColor::BestTextureFormat()); 326 resource_provider_.get(), PlatformColor::BestTextureFormat());
320 break; 327 break;
321 case RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY: 328 case RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY:
322 Create3dOutputSurfaceAndResourceProvider(); 329 Create3dOutputSurfaceAndResourceProvider();
323 raster_buffer_provider = base::MakeUnique<OneCopyRasterBufferProvider>( 330 raster_buffer_provider_ = base::MakeUnique<OneCopyRasterBufferProvider>(
324 task_runner_.get(), compositor_context_provider_.get(), 331 task_runner_.get(), compositor_context_provider_.get(),
325 worker_context_provider_.get(), resource_provider_.get(), 332 worker_context_provider_.get(), resource_provider_.get(),
326 std::numeric_limits<int>::max(), false, 333 std::numeric_limits<int>::max(), false,
327 std::numeric_limits<int>::max(), 334 std::numeric_limits<int>::max(), PlatformColor::BestTextureFormat(),
328 PlatformColor::BestTextureFormat()); 335 false);
329 break; 336 break;
330 case RASTER_BUFFER_PROVIDER_TYPE_GPU: 337 case RASTER_BUFFER_PROVIDER_TYPE_GPU:
331 Create3dOutputSurfaceAndResourceProvider(); 338 Create3dOutputSurfaceAndResourceProvider();
332 raster_buffer_provider = base::MakeUnique<GpuRasterBufferProvider>( 339 raster_buffer_provider_ = base::MakeUnique<GpuRasterBufferProvider>(
333 compositor_context_provider_.get(), worker_context_provider_.get(), 340 compositor_context_provider_.get(), worker_context_provider_.get(),
334 resource_provider_.get(), false, 0); 341 resource_provider_.get(), false, 0, false);
335 break; 342 break;
336 case RASTER_BUFFER_PROVIDER_TYPE_BITMAP: 343 case RASTER_BUFFER_PROVIDER_TYPE_BITMAP:
337 CreateSoftwareOutputSurfaceAndResourceProvider(); 344 CreateSoftwareOutputSurfaceAndResourceProvider();
338 raster_buffer_provider = 345 raster_buffer_provider_ =
339 BitmapRasterBufferProvider::Create(resource_provider_.get()); 346 BitmapRasterBufferProvider::Create(resource_provider_.get());
340 break; 347 break;
341 } 348 }
342 349
343 DCHECK(raster_buffer_provider); 350 DCHECK(raster_buffer_provider_);
344 351
345 tile_task_manager_ = TileTaskManagerImpl::Create( 352 tile_task_manager_ = TileTaskManagerImpl::Create(task_graph_runner_.get());
346 std::move(raster_buffer_provider), task_graph_runner_.get());
347 } 353 }
348 void TearDown() override { 354 void TearDown() override {
349 tile_task_manager_->Shutdown(); 355 tile_task_manager_->Shutdown();
350 tile_task_manager_->CheckForCompletedTasks(); 356 tile_task_manager_->CheckForCompletedTasks();
357
358 raster_buffer_provider_->Shutdown();
351 } 359 }
352 360
353 // Overridden from PerfRasterBufferProviderHelper: 361 // Overridden from PerfRasterBufferProviderHelper:
354 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( 362 std::unique_ptr<RasterBuffer> AcquireBufferForRaster(
355 const Resource* resource, 363 const Resource* resource,
356 uint64_t resource_content_id, 364 uint64_t resource_content_id,
357 uint64_t previous_content_id) override { 365 uint64_t previous_content_id) override {
358 return tile_task_manager_->GetRasterBufferProvider() 366 return raster_buffer_provider_->AcquireBufferForRaster(
359 ->AcquireBufferForRaster(resource, resource_content_id, 367 resource, resource_content_id, previous_content_id);
360 previous_content_id);
361 } 368 }
362 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override { 369 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override {
363 tile_task_manager_->GetRasterBufferProvider()->ReleaseBufferForRaster( 370 raster_buffer_provider_->ReleaseBufferForRaster(std::move(buffer));
364 std::move(buffer));
365 } 371 }
366 372
367 void RunMessageLoopUntilAllTasksHaveCompleted() { 373 void RunMessageLoopUntilAllTasksHaveCompleted() {
368 task_graph_runner_->RunUntilIdle(); 374 task_graph_runner_->RunUntilIdle();
369 task_runner_->RunUntilIdle(); 375 task_runner_->RunUntilIdle();
370 } 376 }
371 377
372 void RunScheduleTasksTest(const std::string& test_name, 378 void RunScheduleTasksTest(const std::string& test_name,
373 unsigned num_raster_tasks, 379 unsigned num_raster_tasks,
374 unsigned num_image_decode_tasks) { 380 unsigned num_image_decode_tasks) {
375 TileTask::Vector image_decode_tasks; 381 TileTask::Vector image_decode_tasks;
376 RasterTaskVector raster_tasks; 382 RasterTaskVector raster_tasks;
377 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks); 383 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks);
378 CreateRasterTasks(this, num_raster_tasks, image_decode_tasks, 384 CreateRasterTasks(this, num_raster_tasks, image_decode_tasks,
379 &raster_tasks); 385 &raster_tasks);
380 386
381 // Avoid unnecessary heap allocations by reusing the same graph. 387 // Avoid unnecessary heap allocations by reusing the same graph.
382 TaskGraph graph; 388 TaskGraph graph;
383 389
384 timer_.Reset(); 390 timer_.Reset();
385 do { 391 do {
386 graph.Reset(); 392 graph.Reset();
387 ResetRasterTasks(raster_tasks); 393 ResetRasterTasks(raster_tasks);
388 BuildTileTaskGraph(&graph, raster_tasks); 394 BuildTileTaskGraph(&graph, raster_tasks);
395 raster_buffer_provider_->OrderingBarrier();
389 tile_task_manager_->ScheduleTasks(&graph); 396 tile_task_manager_->ScheduleTasks(&graph);
390 tile_task_manager_->CheckForCompletedTasks(); 397 tile_task_manager_->CheckForCompletedTasks();
391 timer_.NextLap(); 398 timer_.NextLap();
392 } while (!timer_.HasTimeLimitExpired()); 399 } while (!timer_.HasTimeLimitExpired());
393 400
394 TaskGraph empty; 401 TaskGraph empty;
402 raster_buffer_provider_->OrderingBarrier();
395 tile_task_manager_->ScheduleTasks(&empty); 403 tile_task_manager_->ScheduleTasks(&empty);
396 RunMessageLoopUntilAllTasksHaveCompleted(); 404 RunMessageLoopUntilAllTasksHaveCompleted();
397 tile_task_manager_->CheckForCompletedTasks(); 405 tile_task_manager_->CheckForCompletedTasks();
398 406
399 perf_test::PrintResult("schedule_tasks", TestModifierString(), test_name, 407 perf_test::PrintResult("schedule_tasks", TestModifierString(), test_name,
400 timer_.LapsPerSecond(), "runs/s", true); 408 timer_.LapsPerSecond(), "runs/s", true);
401 } 409 }
402 410
403 void RunScheduleAlternateTasksTest(const std::string& test_name, 411 void RunScheduleAlternateTasksTest(const std::string& test_name,
404 unsigned num_raster_tasks, 412 unsigned num_raster_tasks,
(...skipping 10 matching lines...) Expand all
415 // Avoid unnecessary heap allocations by reusing the same graph. 423 // Avoid unnecessary heap allocations by reusing the same graph.
416 TaskGraph graph; 424 TaskGraph graph;
417 425
418 size_t count = 0; 426 size_t count = 0;
419 timer_.Reset(); 427 timer_.Reset();
420 do { 428 do {
421 graph.Reset(); 429 graph.Reset();
422 // Reset the tasks as for scheduling new state tasks are needed. 430 // Reset the tasks as for scheduling new state tasks are needed.
423 ResetRasterTasks(raster_tasks[count % kNumVersions]); 431 ResetRasterTasks(raster_tasks[count % kNumVersions]);
424 BuildTileTaskGraph(&graph, raster_tasks[count % kNumVersions]); 432 BuildTileTaskGraph(&graph, raster_tasks[count % kNumVersions]);
433 raster_buffer_provider_->OrderingBarrier();
425 tile_task_manager_->ScheduleTasks(&graph); 434 tile_task_manager_->ScheduleTasks(&graph);
426 tile_task_manager_->CheckForCompletedTasks(); 435 tile_task_manager_->CheckForCompletedTasks();
427 ++count; 436 ++count;
428 timer_.NextLap(); 437 timer_.NextLap();
429 } while (!timer_.HasTimeLimitExpired()); 438 } while (!timer_.HasTimeLimitExpired());
430 439
431 TaskGraph empty; 440 TaskGraph empty;
441 raster_buffer_provider_->OrderingBarrier();
432 tile_task_manager_->ScheduleTasks(&empty); 442 tile_task_manager_->ScheduleTasks(&empty);
433 RunMessageLoopUntilAllTasksHaveCompleted(); 443 RunMessageLoopUntilAllTasksHaveCompleted();
434 tile_task_manager_->CheckForCompletedTasks(); 444 tile_task_manager_->CheckForCompletedTasks();
435 445
436 perf_test::PrintResult("schedule_alternate_tasks", TestModifierString(), 446 perf_test::PrintResult("schedule_alternate_tasks", TestModifierString(),
437 test_name, timer_.LapsPerSecond(), "runs/s", true); 447 test_name, timer_.LapsPerSecond(), "runs/s", true);
438 } 448 }
439 449
440 void RunScheduleAndExecuteTasksTest(const std::string& test_name, 450 void RunScheduleAndExecuteTasksTest(const std::string& test_name,
441 unsigned num_raster_tasks, 451 unsigned num_raster_tasks,
442 unsigned num_image_decode_tasks) { 452 unsigned num_image_decode_tasks) {
443 TileTask::Vector image_decode_tasks; 453 TileTask::Vector image_decode_tasks;
444 RasterTaskVector raster_tasks; 454 RasterTaskVector raster_tasks;
445 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks); 455 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks);
446 CreateRasterTasks(this, num_raster_tasks, image_decode_tasks, 456 CreateRasterTasks(this, num_raster_tasks, image_decode_tasks,
447 &raster_tasks); 457 &raster_tasks);
448 458
449 // Avoid unnecessary heap allocations by reusing the same graph. 459 // Avoid unnecessary heap allocations by reusing the same graph.
450 TaskGraph graph; 460 TaskGraph graph;
451 461
452 timer_.Reset(); 462 timer_.Reset();
453 do { 463 do {
454 graph.Reset(); 464 graph.Reset();
455 BuildTileTaskGraph(&graph, raster_tasks); 465 BuildTileTaskGraph(&graph, raster_tasks);
466 raster_buffer_provider_->OrderingBarrier();
456 tile_task_manager_->ScheduleTasks(&graph); 467 tile_task_manager_->ScheduleTasks(&graph);
457 RunMessageLoopUntilAllTasksHaveCompleted(); 468 RunMessageLoopUntilAllTasksHaveCompleted();
458 timer_.NextLap(); 469 timer_.NextLap();
459 } while (!timer_.HasTimeLimitExpired()); 470 } while (!timer_.HasTimeLimitExpired());
460 471
461 TaskGraph empty; 472 TaskGraph empty;
473 raster_buffer_provider_->OrderingBarrier();
462 tile_task_manager_->ScheduleTasks(&empty); 474 tile_task_manager_->ScheduleTasks(&empty);
463 RunMessageLoopUntilAllTasksHaveCompleted(); 475 RunMessageLoopUntilAllTasksHaveCompleted();
464 476
465 perf_test::PrintResult("schedule_and_execute_tasks", TestModifierString(), 477 perf_test::PrintResult("schedule_and_execute_tasks", TestModifierString(),
466 test_name, timer_.LapsPerSecond(), "runs/s", true); 478 test_name, timer_.LapsPerSecond(), "runs/s", true);
467 } 479 }
468 480
469 private: 481 private:
470 void Create3dOutputSurfaceAndResourceProvider() { 482 void Create3dOutputSurfaceAndResourceProvider() {
471 output_surface_ = FakeOutputSurface::Create3d(compositor_context_provider_, 483 output_surface_ = FakeOutputSurface::Create3d(compositor_context_provider_,
(...skipping 20 matching lines...) Expand all
492 case RASTER_BUFFER_PROVIDER_TYPE_GPU: 504 case RASTER_BUFFER_PROVIDER_TYPE_GPU:
493 return std::string("_gpu_raster_buffer_provider"); 505 return std::string("_gpu_raster_buffer_provider");
494 case RASTER_BUFFER_PROVIDER_TYPE_BITMAP: 506 case RASTER_BUFFER_PROVIDER_TYPE_BITMAP:
495 return std::string("_bitmap_raster_buffer_provider"); 507 return std::string("_bitmap_raster_buffer_provider");
496 } 508 }
497 NOTREACHED(); 509 NOTREACHED();
498 return std::string(); 510 return std::string();
499 } 511 }
500 512
501 std::unique_ptr<TileTaskManager> tile_task_manager_; 513 std::unique_ptr<TileTaskManager> tile_task_manager_;
514 std::unique_ptr<RasterBufferProvider> raster_buffer_provider_;
502 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; 515 TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
503 TestSharedBitmapManager shared_bitmap_manager_; 516 TestSharedBitmapManager shared_bitmap_manager_;
504 }; 517 };
505 518
506 TEST_P(RasterBufferProviderPerfTest, ScheduleTasks) { 519 TEST_P(RasterBufferProviderPerfTest, ScheduleTasks) {
507 RunScheduleTasksTest("1_0", 1, 0); 520 RunScheduleTasksTest("1_0", 1, 0);
508 RunScheduleTasksTest("32_0", 32, 0); 521 RunScheduleTasksTest("32_0", 32, 0);
509 RunScheduleTasksTest("1_1", 1, 1); 522 RunScheduleTasksTest("1_1", 1, 1);
510 RunScheduleTasksTest("32_1", 32, 1); 523 RunScheduleTasksTest("32_1", 32, 1);
511 RunScheduleTasksTest("1_4", 1, 4); 524 RunScheduleTasksTest("1_4", 1, 4);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 RunBuildTileTaskGraphTest("1_0", 1, 0); 593 RunBuildTileTaskGraphTest("1_0", 1, 0);
581 RunBuildTileTaskGraphTest("32_0", 32, 0); 594 RunBuildTileTaskGraphTest("32_0", 32, 0);
582 RunBuildTileTaskGraphTest("1_1", 1, 1); 595 RunBuildTileTaskGraphTest("1_1", 1, 1);
583 RunBuildTileTaskGraphTest("32_1", 32, 1); 596 RunBuildTileTaskGraphTest("32_1", 32, 1);
584 RunBuildTileTaskGraphTest("1_4", 1, 4); 597 RunBuildTileTaskGraphTest("1_4", 1, 4);
585 RunBuildTileTaskGraphTest("32_4", 32, 4); 598 RunBuildTileTaskGraphTest("32_4", 32, 4);
586 } 599 }
587 600
588 } // namespace 601 } // namespace
589 } // namespace cc 602 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698