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

Side by Side Diff: cc/ipc/cc_serialization_perftest.cc

Issue 2770753002: cc: Add complex compositor frame to serialization perf tests (Closed)
Patch Set: clean up for review Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 5 #include <utility>
6 6
7 #include "base/test/launcher/unit_test_launcher.h" 7 #include "base/test/launcher/unit_test_launcher.h"
8 #include "base/test/test_suite.h" 8 #include "base/test/test_suite.h"
9 #include "cc/ipc/begin_frame_args_struct_traits.h" 9 #include "cc/ipc/begin_frame_args_struct_traits.h"
10 #include "cc/ipc/cc_param_traits.h" 10 #include "cc/ipc/cc_param_traits.h"
11 #include "cc/ipc/compositor_frame.mojom.h" 11 #include "cc/ipc/compositor_frame.mojom.h"
12 #include "cc/ipc/compositor_frame_metadata_struct_traits.h" 12 #include "cc/ipc/compositor_frame_metadata_struct_traits.h"
13 #include "cc/ipc/compositor_frame_struct_traits.h" 13 #include "cc/ipc/compositor_frame_struct_traits.h"
14 #include "cc/ipc/render_pass_struct_traits.h" 14 #include "cc/ipc/render_pass_struct_traits.h"
15 #include "cc/ipc/selection_struct_traits.h" 15 #include "cc/ipc/selection_struct_traits.h"
16 #include "cc/ipc/shared_quad_state_struct_traits.h" 16 #include "cc/ipc/shared_quad_state_struct_traits.h"
17 #include "cc/ipc/surface_id_struct_traits.h" 17 #include "cc/ipc/surface_id_struct_traits.h"
18 #include "cc/ipc/transferable_resource_struct_traits.h" 18 #include "cc/ipc/transferable_resource_struct_traits.h"
19 #include "cc/output/compositor_frame.h" 19 #include "cc/output/compositor_frame.h"
20 #include "cc/quads/picture_draw_quad.h" 20 #include "cc/quads/picture_draw_quad.h"
21 #include "gpu/ipc/common/mailbox_holder_struct_traits.h" 21 #include "gpu/ipc/common/mailbox_holder_struct_traits.h"
22 #include "gpu/ipc/common/mailbox_struct_traits.h" 22 #include "gpu/ipc/common/mailbox_struct_traits.h"
23 #include "gpu/ipc/common/sync_token_struct_traits.h" 23 #include "gpu/ipc/common/sync_token_struct_traits.h"
24 #include "ipc/ipc_message.h" 24 #include "ipc/ipc_message.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "testing/perf/perf_test.h" 26 #include "testing/perf/perf_test.h"
27 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
27 #include "ui/events/mojo/latency_info_struct_traits.h" 28 #include "ui/events/mojo/latency_info_struct_traits.h"
28 #include "ui/gfx/geometry/mojo/geometry.mojom.h" 29 #include "ui/gfx/geometry/mojo/geometry.mojom.h"
29 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" 30 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
30 #include "ui/gfx/mojo/selection_bound_struct_traits.h" 31 #include "ui/gfx/mojo/selection_bound_struct_traits.h"
31 32
32 namespace cc { 33 namespace cc {
33 namespace { 34 namespace {
34 35
35 static const int kTimeLimitMillis = 2000; 36 static const int kTimeLimitMillis = 5000;
36 static const int kNumWarmupRuns = 20; 37 static const int kNumWarmupRuns = 20;
37 static const int kTimeCheckInterval = 10; 38 static const int kTimeCheckInterval = 10;
38 39
39 enum class UseSingleSharedQuadState { YES, NO }; 40 enum class UseSingleSharedQuadState { YES, NO };
40 41
41 class CCSerializationPerfTest : public testing::Test { 42 class CCSerializationPerfTest : public testing::Test {
42 protected: 43 protected:
43 static bool ReadMessage(const IPC::Message* msg, CompositorFrame* frame) { 44 static bool ReadMessage(const IPC::Message* msg, CompositorFrame* frame) {
44 base::PickleIterator iter(*msg); 45 base::PickleIterator iter(*msg);
45 return IPC::ParamTraits<CompositorFrame>::Read(msg, &iter, frame); 46 return IPC::ParamTraits<CompositorFrame>::Read(msg, &iter, frame);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 : "_per_quad_shared_quad_state", 220 : "_per_quad_shared_quad_state",
220 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us", 221 test_name, min_time.InMillisecondsF() / kTimeCheckInterval * 1000, "us",
221 true); 222 true);
222 perf_test::PrintResult("StructTraits serialization: num runs in 2 seconds", 223 perf_test::PrintResult("StructTraits serialization: num runs in 2 seconds",
223 single_sqs == UseSingleSharedQuadState::YES 224 single_sqs == UseSingleSharedQuadState::YES
224 ? "_per_render_pass_shared_quad_state" 225 ? "_per_render_pass_shared_quad_state"
225 : "_per_quad_shared_quad_state", 226 : "_per_quad_shared_quad_state",
226 test_name, count, "", true); 227 test_name, count, "", true);
227 } 228 }
228 229
230 static void RunComplexCompositorFrameTest(const std::string& test_name) {
231 CompositorFrame frame;
232 // 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,
233
234 TransferableResourceArray& resource_list = frame.resource_list;
235 for (uint32_t i = 0; i < 40; ++i) {
236 gpu::SyncToken arbitrary_token1(
237 gpu::CommandBufferNamespace::GPU_IO, 0,
238 gpu::CommandBufferId::FromUnsafeValue(0x123), 71234838);
239 arbitrary_token1.SetVerifyFlush();
240 gpu::SyncToken arbitrary_token2(
241 gpu::CommandBufferNamespace::GPU_IO, 0,
242 gpu::CommandBufferId::FromUnsafeValue(0x123), 53589793);
243 arbitrary_token2.SetVerifyFlush();
244
245 GLbyte arbitrary_mailbox1[GL_MAILBOX_SIZE_CHROMIUM] = {
246 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6};
247
248 GLbyte arbitrary_mailbox2[GL_MAILBOX_SIZE_CHROMIUM] = {
249 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2};
250
251 TransferableResource arbitrary_resource1;
252 arbitrary_resource1.id = 2178312;
253 arbitrary_resource1.format = RGBA_8888;
254 arbitrary_resource1.filter = 53;
255 arbitrary_resource1.size = gfx::Size(37189, 123123);
256 arbitrary_resource1.mailbox_holder.mailbox.SetName(arbitrary_mailbox1);
257 arbitrary_resource1.mailbox_holder.texture_target = GL_TEXTURE_2D;
258 arbitrary_resource1.mailbox_holder.sync_token = arbitrary_token1;
259 arbitrary_resource1.is_overlay_candidate = true;
260 #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
261 arbitrary_resource1.is_backed_by_surface_texture = true;
262 arbitrary_resource1.wants_promotion_hint = true;
263 #endif
264
265 TransferableResource arbitrary_resource2;
266 arbitrary_resource2.id = 789132;
267 arbitrary_resource2.format = RGBA_4444;
268 arbitrary_resource2.filter = 47;
269 arbitrary_resource2.size = gfx::Size(89123, 23789);
270 arbitrary_resource2.mailbox_holder.mailbox.SetName(arbitrary_mailbox2);
271 arbitrary_resource2.mailbox_holder.texture_target =
272 GL_TEXTURE_EXTERNAL_OES;
273 arbitrary_resource2.mailbox_holder.sync_token = arbitrary_token2;
274 arbitrary_resource2.is_overlay_candidate = false;
275 #if defined(OS_ANDROID)
276 arbitrary_resource2.is_backed_by_surface_texture = false;
277 arbitrary_resource2.wants_promotion_hint = false;
278 #endif
279
280 resource_list.push_back(arbitrary_resource1);
281 resource_list.push_back(arbitrary_resource2);
282 }
283
284 RenderPassList& render_pass_list = frame.render_pass_list;
285
286 gfx::Transform arbitrary_matrix1;
287 arbitrary_matrix1.Scale(3, 3);
288 arbitrary_matrix1.Translate(-5, 20);
289 arbitrary_matrix1.Rotate(15);
290 gfx::Transform arbitrary_matrix2;
291 arbitrary_matrix2.Scale(10, -1);
292 arbitrary_matrix2.Translate(20, 3);
293 arbitrary_matrix2.Rotate(24);
294 gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
295 gfx::Rect arbitrary_rect1_inside_rect1(-4, 12, 2, 8);
296 gfx::Rect arbitrary_rect2_inside_rect1(-5, 11, 1, 2);
297 gfx::Rect arbitrary_rect2(40, 23, 11, 7);
298 gfx::Rect arbitrary_rect1_inside_rect2(44, 23, 4, 2);
299 gfx::Rect arbitrary_rect2_inside_rect2(41, 25, 3, 5);
300 gfx::Rect arbitrary_rect3(7, -53, 22, 19);
301 gfx::Rect arbitrary_rect1_inside_rect3(10, -40, 6, 3);
302 gfx::Rect arbitrary_rect2_inside_rect3(12, -51, 5, 12);
303 gfx::Size arbitrary_size1(15, 19);
304 gfx::Size arbitrary_size2(3, 99);
305 gfx::Size arbitrary_size3(75, 1281);
306 gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f);
307 gfx::RectF arbitrary_rectf2(2.1f, -411.05f, 7.8f, 14.75f);
308 gfx::SizeF arbitrary_sizef1(15.2f, 104.6f);
309 gfx::PointF arbitrary_pointf1(31.4f, 15.9f);
310 gfx::PointF arbitrary_pointf2(26.5f, -35.8f);
311 gfx::Vector2dF arbitrary_vector2df1(16.2f, -85.1f);
312 gfx::Vector2dF arbitrary_vector2df2(-8.3f, 0.47f);
313 float arbitrary_float1 = 0.7f;
314 float arbitrary_float2 = 0.3f;
315 float arbitrary_float3 = 0.9f;
316 float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f};
317 bool arbitrary_bool1 = true;
318 bool arbitrary_bool2 = false;
319 bool arbitrary_bool3 = true;
320 bool arbitrary_bool4 = true;
321 bool arbitrary_bool5 = false;
322 bool arbitrary_bool6 = true;
323 int arbitrary_context_id1 = 12;
324 int arbitrary_context_id2 = 57;
325 int arbitrary_context_id3 = -503;
326 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58);
327 SkBlendMode arbitrary_blend_mode1 = SkBlendMode::kScreen;
328 SkBlendMode arbitrary_blend_mode2 = SkBlendMode::kLighten;
329 SkBlendMode arbitrary_blend_mode3 = SkBlendMode::kOverlay;
330 ResourceId arbitrary_resourceid1 = 55;
331 ResourceId arbitrary_resourceid2 = 47;
332 ResourceId arbitrary_resourceid3 = 23;
333 ResourceId arbitrary_resourceid4 = 16;
334 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f);
335 gfx::ColorSpace arbitrary_color_space = gfx::ColorSpace::CreateXYZD50();
336 int root_id = 14;
337
338 FilterOperations arbitrary_filters1;
339 arbitrary_filters1.Append(
340 FilterOperation::CreateGrayscaleFilter(arbitrary_float1));
341 arbitrary_filters1.Append(FilterOperation::CreateReferenceFilter(
342 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr)));
343
344 FilterOperations arbitrary_filters2;
345 arbitrary_filters2.Append(
346 FilterOperation::CreateBrightnessFilter(arbitrary_float2));
347
348 std::unique_ptr<RenderPass> pass_in = RenderPass::Create();
349 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2,
350 arbitrary_matrix1, arbitrary_filters2, arbitrary_filters1,
351 arbitrary_color_space, arbitrary_bool1);
352
353 // Texture quads
354 for (uint32_t i = 0; i < 10; ++i) {
355 SharedQuadState* shared_state1_in =
356 pass_in->CreateAndAppendSharedQuadState();
357 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1,
358 arbitrary_rect1, arbitrary_rect2,
359 arbitrary_bool1, arbitrary_float1,
360 arbitrary_blend_mode1, arbitrary_context_id1);
361
362 TextureDrawQuad* texture_in =
363 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
364 texture_in->SetAll(
365 shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
366 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid1,
367 arbitrary_size1, arbitrary_bool1, arbitrary_pointf1,
368 arbitrary_pointf2, arbitrary_color, arbitrary_float_array,
369 arbitrary_bool4, arbitrary_bool5, arbitrary_bool6);
370
371 TextureDrawQuad* texture_in2 =
372 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
373 texture_in2->SetAll(
374 shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
375 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid2,
376 arbitrary_size1, arbitrary_bool3, arbitrary_pointf1,
377 arbitrary_pointf2, arbitrary_color, arbitrary_float_array,
378 arbitrary_bool4, arbitrary_bool5, arbitrary_bool6);
379
380 TextureDrawQuad* texture_in3 =
381 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
382 texture_in3->SetAll(
383 shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
384 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid3,
385 arbitrary_size1, arbitrary_bool2, arbitrary_pointf1,
386 arbitrary_pointf2, arbitrary_color, arbitrary_float_array,
387 arbitrary_bool4, arbitrary_bool6, arbitrary_bool6);
388
389 TextureDrawQuad* texture_in4 =
390 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
391 texture_in4->SetAll(
392 shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
393 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid4,
394 arbitrary_size2, arbitrary_bool4, arbitrary_pointf1,
395 arbitrary_pointf2, arbitrary_color, arbitrary_float_array,
396 arbitrary_bool4, arbitrary_bool5, arbitrary_bool6);
397 }
398
399 // Tiled quads
400 for (uint32_t i = 0; i < 10; ++i) {
401 SharedQuadState* shared_state2_in =
402 pass_in->CreateAndAppendSharedQuadState();
403 shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2,
404 arbitrary_rect2, arbitrary_rect3,
405 arbitrary_bool1, arbitrary_float2,
406 arbitrary_blend_mode2, arbitrary_context_id2);
407 for (uint32_t j = 0; j < 6; ++j) {
408 TileDrawQuad* tile_in =
409 pass_in->CreateAndAppendDrawQuad<TileDrawQuad>();
410 tile_in->SetAll(shared_state2_in, arbitrary_rect2,
411 arbitrary_rect2_inside_rect2,
412 arbitrary_rect1_inside_rect2, arbitrary_bool1,
413 arbitrary_resourceid3, arbitrary_rectf1,
414 arbitrary_size1, arbitrary_bool2, arbitrary_bool3);
415 }
416 }
417
418 // Solid color quads
419 for (uint32_t i = 0; i < 5; ++i) {
420 SharedQuadState* shared_state3_in =
421 pass_in->CreateAndAppendSharedQuadState();
422 shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3,
423 arbitrary_rect3, arbitrary_rect1,
424 arbitrary_bool1, arbitrary_float3,
425 arbitrary_blend_mode3, arbitrary_context_id3);
426 for (uint32_t j = 0; j < 5; ++j) {
427 SolidColorDrawQuad* solidcolor_in =
428 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
429 solidcolor_in->SetAll(shared_state3_in, arbitrary_rect3,
430 arbitrary_rect1_inside_rect3,
431 arbitrary_rect2_inside_rect3, arbitrary_bool1,
432 arbitrary_color, arbitrary_bool2);
433 }
434 }
435
436 render_pass_list.push_back(std::move(pass_in));
437 RunTest(test_name, std::move(frame), UseSingleSharedQuadState::NO);
438 }
439
229 static void RunCompositorFrameTest(const std::string& test_name, 440 static void RunCompositorFrameTest(const std::string& test_name,
230 uint32_t num_quads, 441 uint32_t num_quads,
231 uint32_t num_passes, 442 uint32_t num_passes,
232 UseSingleSharedQuadState single_sqs) { 443 UseSingleSharedQuadState single_sqs) {
233 CompositorFrame frame; 444 CompositorFrame frame;
234 445
235 for (uint32_t i = 0; i < num_passes; ++i) { 446 for (uint32_t i = 0; i < num_passes; ++i) {
236 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 447 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
237 render_pass->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform()); 448 render_pass->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform());
238 for (uint32_t j = 0; j < num_quads; ++j) { 449 for (uint32_t j = 0; j < num_quads; ++j) {
(...skipping 14 matching lines...) Expand all
253 static void RunTest(const std::string& test_name, 464 static void RunTest(const std::string& test_name,
254 CompositorFrame frame, 465 CompositorFrame frame,
255 UseSingleSharedQuadState single_sqs) { 466 UseSingleSharedQuadState single_sqs) {
256 RunSerializationTestStructTraits(test_name, frame, single_sqs); 467 RunSerializationTestStructTraits(test_name, frame, single_sqs);
257 RunDeserializationTestStructTraits(test_name, frame, single_sqs); 468 RunDeserializationTestStructTraits(test_name, frame, single_sqs);
258 RunSerializationTestParamTraits(test_name, frame, single_sqs); 469 RunSerializationTestParamTraits(test_name, frame, single_sqs);
259 RunDeserializationTestParamTraits(test_name, frame, single_sqs); 470 RunDeserializationTestParamTraits(test_name, frame, single_sqs);
260 } 471 }
261 }; 472 };
262 473
474 // Test for compositor frames with one render pass, 80 resources in resource
475 // list, 10 shared quad states with 4 texture quads each, 10 shared quad states
476 // with 6 tiled quads each, and 5 shared quad states with 5 solid color quads
477 // each.
478 TEST_F(CCSerializationPerfTest, DelegatedFrame_Complex) {
479 RunComplexCompositorFrameTest("DelegatedFrame_Complex");
480 }
481
263 // Test for compositor frames with one render pass and 4000 quads. 482 // Test for compositor frames with one render pass and 4000 quads.
264 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) { 483 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) {
265 // Case 1: One shared quad state for all quads in one render pass. 484 // Case 1: One shared quad state for all quads in one render pass.
266 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_4000", 4000, 1, 485 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_4000", 4000, 1,
267 UseSingleSharedQuadState::YES); 486 UseSingleSharedQuadState::YES);
268 // Case 2: One shared quad state for each quad. 487 // Case 2: One shared quad state for each quad.
269 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_4000", 4000, 1, 488 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_4000", 4000, 1,
270 UseSingleSharedQuadState::NO); 489 UseSingleSharedQuadState::NO);
271 } 490 }
272 491
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Case 1: One shared quad state for all quads in one render pass. 546 // Case 1: One shared quad state for all quads in one render pass.
328 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_1000_100", 100, 1000, 547 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_1000_100", 100, 1000,
329 UseSingleSharedQuadState::YES); 548 UseSingleSharedQuadState::YES);
330 // Case 2: One shared quad state for each quad. 549 // Case 2: One shared quad state for each quad.
331 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_1000_100", 100, 1000, 550 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_1000_100", 100, 1000,
332 UseSingleSharedQuadState::NO); 551 UseSingleSharedQuadState::NO);
333 } 552 }
334 553
335 } // namespace 554 } // namespace
336 } // namespace cc 555 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698