Chromium Code Reviews| Index: cc/ipc/cc_serialization_perftest.cc |
| diff --git a/cc/ipc/cc_serialization_perftest.cc b/cc/ipc/cc_serialization_perftest.cc |
| index 6bf7180d1c9cb9ac68ec974f3aa4ff624b35de11..9a781766482326e7edffd518829b12c3b9801b10 100644 |
| --- a/cc/ipc/cc_serialization_perftest.cc |
| +++ b/cc/ipc/cc_serialization_perftest.cc |
| @@ -24,6 +24,7 @@ |
| #include "ipc/ipc_message.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "testing/perf/perf_test.h" |
| +#include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| #include "ui/events/mojo/latency_info_struct_traits.h" |
| #include "ui/gfx/geometry/mojo/geometry.mojom.h" |
| #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" |
| @@ -32,7 +33,7 @@ |
| namespace cc { |
| namespace { |
| -static const int kTimeLimitMillis = 2000; |
| +static const int kTimeLimitMillis = 5000; |
| static const int kNumWarmupRuns = 20; |
| static const int kTimeCheckInterval = 10; |
| @@ -226,6 +227,216 @@ class CCSerializationPerfTest : public testing::Test { |
| test_name, count, "", true); |
| } |
| + static void RunComplexCompositorFrameTest(const std::string& test_name) { |
| + CompositorFrame frame; |
| + // The default metadata should occupy same space. |
|
danakj
2017/03/24 15:29:58
I'm not sure what this means?
weiliangc
2017/03/27 15:57:07
Sorry, probably left over from my setting this up,
|
| + |
| + TransferableResourceArray& resource_list = frame.resource_list; |
| + for (uint32_t i = 0; i < 40; ++i) { |
| + gpu::SyncToken arbitrary_token1( |
| + gpu::CommandBufferNamespace::GPU_IO, 0, |
| + gpu::CommandBufferId::FromUnsafeValue(0x123), 71234838); |
| + arbitrary_token1.SetVerifyFlush(); |
| + gpu::SyncToken arbitrary_token2( |
| + gpu::CommandBufferNamespace::GPU_IO, 0, |
| + gpu::CommandBufferId::FromUnsafeValue(0x123), 53589793); |
| + arbitrary_token2.SetVerifyFlush(); |
| + |
| + GLbyte arbitrary_mailbox1[GL_MAILBOX_SIZE_CHROMIUM] = { |
| + 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6}; |
| + |
| + GLbyte arbitrary_mailbox2[GL_MAILBOX_SIZE_CHROMIUM] = { |
| + 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2}; |
| + |
| + TransferableResource arbitrary_resource1; |
| + arbitrary_resource1.id = 2178312; |
| + arbitrary_resource1.format = RGBA_8888; |
| + arbitrary_resource1.filter = 53; |
| + arbitrary_resource1.size = gfx::Size(37189, 123123); |
| + arbitrary_resource1.mailbox_holder.mailbox.SetName(arbitrary_mailbox1); |
| + arbitrary_resource1.mailbox_holder.texture_target = GL_TEXTURE_2D; |
| + arbitrary_resource1.mailbox_holder.sync_token = arbitrary_token1; |
| + arbitrary_resource1.is_overlay_candidate = true; |
| +#if defined(OS_ANDROID) |
|
danakj
2017/03/24 15:29:58
Why is the test different on android?
weiliangc
2017/03/27 15:57:07
Android's trasnferable resource is different. It's
danakj
2017/03/28 18:01:56
Unit tests are checking for correctness, do the va
|
| + arbitrary_resource1.is_backed_by_surface_texture = true; |
| + arbitrary_resource1.wants_promotion_hint = true; |
| +#endif |
| + |
| + TransferableResource arbitrary_resource2; |
| + arbitrary_resource2.id = 789132; |
| + arbitrary_resource2.format = RGBA_4444; |
| + arbitrary_resource2.filter = 47; |
| + arbitrary_resource2.size = gfx::Size(89123, 23789); |
| + arbitrary_resource2.mailbox_holder.mailbox.SetName(arbitrary_mailbox2); |
| + arbitrary_resource2.mailbox_holder.texture_target = |
| + GL_TEXTURE_EXTERNAL_OES; |
| + arbitrary_resource2.mailbox_holder.sync_token = arbitrary_token2; |
| + arbitrary_resource2.is_overlay_candidate = false; |
| +#if defined(OS_ANDROID) |
| + arbitrary_resource2.is_backed_by_surface_texture = false; |
| + arbitrary_resource2.wants_promotion_hint = false; |
| +#endif |
| + |
| + resource_list.push_back(arbitrary_resource1); |
| + resource_list.push_back(arbitrary_resource2); |
| + } |
| + |
| + RenderPassList& render_pass_list = frame.render_pass_list; |
| + |
| + gfx::Transform arbitrary_matrix1; |
| + arbitrary_matrix1.Scale(3, 3); |
| + arbitrary_matrix1.Translate(-5, 20); |
| + arbitrary_matrix1.Rotate(15); |
| + gfx::Transform arbitrary_matrix2; |
| + arbitrary_matrix2.Scale(10, -1); |
| + arbitrary_matrix2.Translate(20, 3); |
| + arbitrary_matrix2.Rotate(24); |
| + gfx::Rect arbitrary_rect1(-5, 9, 3, 15); |
| + gfx::Rect arbitrary_rect1_inside_rect1(-4, 12, 2, 8); |
| + gfx::Rect arbitrary_rect2_inside_rect1(-5, 11, 1, 2); |
| + gfx::Rect arbitrary_rect2(40, 23, 11, 7); |
| + gfx::Rect arbitrary_rect1_inside_rect2(44, 23, 4, 2); |
| + gfx::Rect arbitrary_rect2_inside_rect2(41, 25, 3, 5); |
| + gfx::Rect arbitrary_rect3(7, -53, 22, 19); |
| + gfx::Rect arbitrary_rect1_inside_rect3(10, -40, 6, 3); |
| + gfx::Rect arbitrary_rect2_inside_rect3(12, -51, 5, 12); |
| + gfx::Size arbitrary_size1(15, 19); |
| + gfx::Size arbitrary_size2(3, 99); |
| + gfx::Size arbitrary_size3(75, 1281); |
| + gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f); |
| + gfx::RectF arbitrary_rectf2(2.1f, -411.05f, 7.8f, 14.75f); |
| + gfx::SizeF arbitrary_sizef1(15.2f, 104.6f); |
| + gfx::PointF arbitrary_pointf1(31.4f, 15.9f); |
| + gfx::PointF arbitrary_pointf2(26.5f, -35.8f); |
| + gfx::Vector2dF arbitrary_vector2df1(16.2f, -85.1f); |
| + gfx::Vector2dF arbitrary_vector2df2(-8.3f, 0.47f); |
| + float arbitrary_float1 = 0.7f; |
| + float arbitrary_float2 = 0.3f; |
| + float arbitrary_float3 = 0.9f; |
| + float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f}; |
| + bool arbitrary_bool1 = true; |
| + bool arbitrary_bool2 = false; |
| + bool arbitrary_bool3 = true; |
| + bool arbitrary_bool4 = true; |
| + bool arbitrary_bool5 = false; |
| + bool arbitrary_bool6 = true; |
| + int arbitrary_context_id1 = 12; |
| + int arbitrary_context_id2 = 57; |
| + int arbitrary_context_id3 = -503; |
| + SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58); |
| + SkBlendMode arbitrary_blend_mode1 = SkBlendMode::kScreen; |
| + SkBlendMode arbitrary_blend_mode2 = SkBlendMode::kLighten; |
| + SkBlendMode arbitrary_blend_mode3 = SkBlendMode::kOverlay; |
| + ResourceId arbitrary_resourceid1 = 55; |
| + ResourceId arbitrary_resourceid2 = 47; |
| + ResourceId arbitrary_resourceid3 = 23; |
| + ResourceId arbitrary_resourceid4 = 16; |
| + SkScalar arbitrary_sigma = SkFloatToScalar(2.0f); |
| + gfx::ColorSpace arbitrary_color_space = gfx::ColorSpace::CreateXYZD50(); |
| + int root_id = 14; |
| + |
| + FilterOperations arbitrary_filters1; |
| + arbitrary_filters1.Append( |
| + FilterOperation::CreateGrayscaleFilter(arbitrary_float1)); |
| + arbitrary_filters1.Append(FilterOperation::CreateReferenceFilter( |
| + SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); |
| + |
| + FilterOperations arbitrary_filters2; |
| + arbitrary_filters2.Append( |
| + FilterOperation::CreateBrightnessFilter(arbitrary_float2)); |
| + |
| + std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); |
| + pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, |
| + arbitrary_matrix1, arbitrary_filters2, arbitrary_filters1, |
| + arbitrary_color_space, arbitrary_bool1); |
| + |
| + // Texture quads |
| + for (uint32_t i = 0; i < 10; ++i) { |
| + SharedQuadState* shared_state1_in = |
| + pass_in->CreateAndAppendSharedQuadState(); |
| + shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, |
| + arbitrary_rect1, arbitrary_rect2, |
| + arbitrary_bool1, arbitrary_float1, |
| + arbitrary_blend_mode1, arbitrary_context_id1); |
| + |
| + TextureDrawQuad* texture_in = |
| + pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| + texture_in->SetAll( |
| + shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2, |
| + arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid1, |
| + arbitrary_size1, arbitrary_bool1, arbitrary_pointf1, |
| + arbitrary_pointf2, arbitrary_color, arbitrary_float_array, |
| + arbitrary_bool4, arbitrary_bool5, arbitrary_bool6); |
| + |
| + TextureDrawQuad* texture_in2 = |
| + pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| + texture_in2->SetAll( |
| + shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2, |
| + arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid2, |
| + arbitrary_size1, arbitrary_bool3, arbitrary_pointf1, |
| + arbitrary_pointf2, arbitrary_color, arbitrary_float_array, |
| + arbitrary_bool4, arbitrary_bool5, arbitrary_bool6); |
| + |
| + TextureDrawQuad* texture_in3 = |
| + pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| + texture_in3->SetAll( |
| + shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2, |
| + arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid3, |
| + arbitrary_size1, arbitrary_bool2, arbitrary_pointf1, |
| + arbitrary_pointf2, arbitrary_color, arbitrary_float_array, |
| + arbitrary_bool4, arbitrary_bool6, arbitrary_bool6); |
| + |
| + TextureDrawQuad* texture_in4 = |
| + pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| + texture_in4->SetAll( |
| + shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2, |
| + arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid4, |
| + arbitrary_size2, arbitrary_bool4, arbitrary_pointf1, |
| + arbitrary_pointf2, arbitrary_color, arbitrary_float_array, |
| + arbitrary_bool4, arbitrary_bool5, arbitrary_bool6); |
| + } |
| + |
| + // Tiled quads |
| + for (uint32_t i = 0; i < 10; ++i) { |
| + SharedQuadState* shared_state2_in = |
| + pass_in->CreateAndAppendSharedQuadState(); |
| + shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2, |
| + arbitrary_rect2, arbitrary_rect3, |
| + arbitrary_bool1, arbitrary_float2, |
| + arbitrary_blend_mode2, arbitrary_context_id2); |
| + for (uint32_t j = 0; j < 6; ++j) { |
| + TileDrawQuad* tile_in = |
| + pass_in->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| + tile_in->SetAll(shared_state2_in, arbitrary_rect2, |
| + arbitrary_rect2_inside_rect2, |
| + arbitrary_rect1_inside_rect2, arbitrary_bool1, |
| + arbitrary_resourceid3, arbitrary_rectf1, |
| + arbitrary_size1, arbitrary_bool2, arbitrary_bool3); |
| + } |
| + } |
| + |
| + // Solid color quads |
| + for (uint32_t i = 0; i < 5; ++i) { |
| + SharedQuadState* shared_state3_in = |
| + pass_in->CreateAndAppendSharedQuadState(); |
| + shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3, |
| + arbitrary_rect3, arbitrary_rect1, |
| + arbitrary_bool1, arbitrary_float3, |
| + arbitrary_blend_mode3, arbitrary_context_id3); |
| + for (uint32_t j = 0; j < 5; ++j) { |
| + SolidColorDrawQuad* solidcolor_in = |
| + pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| + solidcolor_in->SetAll(shared_state3_in, arbitrary_rect3, |
| + arbitrary_rect1_inside_rect3, |
| + arbitrary_rect2_inside_rect3, arbitrary_bool1, |
| + arbitrary_color, arbitrary_bool2); |
| + } |
| + } |
| + |
| + render_pass_list.push_back(std::move(pass_in)); |
| + RunTest(test_name, std::move(frame), UseSingleSharedQuadState::NO); |
| + } |
| + |
| static void RunCompositorFrameTest(const std::string& test_name, |
| uint32_t num_quads, |
| uint32_t num_passes, |
| @@ -260,6 +471,14 @@ class CCSerializationPerfTest : public testing::Test { |
| } |
| }; |
| +// Test for compositor frames with one render pass, 80 resources in resource |
| +// list, 10 shared quad states with 4 texture quads each, 10 shared quad states |
| +// with 6 tiled quads each, and 5 shared quad states with 5 solid color quads |
| +// each. |
| +TEST_F(CCSerializationPerfTest, DelegatedFrame_Complex) { |
| + RunComplexCompositorFrameTest("DelegatedFrame_Complex"); |
| +} |
| + |
| // Test for compositor frames with one render pass and 4000 quads. |
| TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) { |
| // Case 1: One shared quad state for all quads in one render pass. |