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

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

Issue 2770753002: cc: Add complex compositor frame to serialization perf tests (Closed)
Patch Set: remove values for transferable resources Created 3 years, 8 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 = 2000;
36 static const int kNumWarmupRuns = 20; 37 static const int kNumWarmupRuns = 20;
(...skipping 182 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
233 TransferableResourceArray& resource_list = frame.resource_list;
234 for (uint32_t i = 0; i < 80; ++i) {
235 TransferableResource arbitrary_resource;
236 resource_list.push_back(arbitrary_resource);
237 }
238
239 RenderPassList& render_pass_list = frame.render_pass_list;
240
241 gfx::Transform arbitrary_matrix1;
242 arbitrary_matrix1.Scale(3, 3);
243 arbitrary_matrix1.Translate(-5, 20);
244 arbitrary_matrix1.Rotate(15);
245 gfx::Transform arbitrary_matrix2;
246 arbitrary_matrix2.Scale(10, -1);
247 arbitrary_matrix2.Translate(20, 3);
248 arbitrary_matrix2.Rotate(24);
249 gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
250 gfx::Rect arbitrary_rect1_inside_rect1(-4, 12, 2, 8);
251 gfx::Rect arbitrary_rect2_inside_rect1(-5, 11, 1, 2);
252 gfx::Rect arbitrary_rect2(40, 23, 11, 7);
253 gfx::Rect arbitrary_rect1_inside_rect2(44, 23, 4, 2);
254 gfx::Rect arbitrary_rect2_inside_rect2(41, 25, 3, 5);
255 gfx::Rect arbitrary_rect3(7, -53, 22, 19);
256 gfx::Rect arbitrary_rect1_inside_rect3(10, -40, 6, 3);
257 gfx::Rect arbitrary_rect2_inside_rect3(12, -51, 5, 12);
258 gfx::Size arbitrary_size1(15, 19);
259 gfx::Size arbitrary_size2(3, 99);
260 gfx::Size arbitrary_size3(75, 1281);
261 gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f);
262 gfx::RectF arbitrary_rectf2(2.1f, -411.05f, 7.8f, 14.75f);
263 gfx::SizeF arbitrary_sizef1(15.2f, 104.6f);
264 gfx::PointF arbitrary_pointf1(31.4f, 15.9f);
265 gfx::PointF arbitrary_pointf2(26.5f, -35.8f);
266 gfx::Vector2dF arbitrary_vector2df1(16.2f, -85.1f);
267 gfx::Vector2dF arbitrary_vector2df2(-8.3f, 0.47f);
268 float arbitrary_float1 = 0.7f;
269 float arbitrary_float2 = 0.3f;
270 float arbitrary_float3 = 0.9f;
271 float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f};
272 bool arbitrary_bool1 = true;
273 bool arbitrary_bool2 = false;
274 bool arbitrary_bool3 = true;
275 bool arbitrary_bool4 = true;
276 bool arbitrary_bool5 = false;
277 bool arbitrary_bool6 = true;
278 int arbitrary_context_id1 = 12;
279 int arbitrary_context_id2 = 57;
280 int arbitrary_context_id3 = -503;
281 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58);
282 SkBlendMode arbitrary_blend_mode1 = SkBlendMode::kScreen;
283 SkBlendMode arbitrary_blend_mode2 = SkBlendMode::kLighten;
284 SkBlendMode arbitrary_blend_mode3 = SkBlendMode::kOverlay;
285 ResourceId arbitrary_resourceid1 = 55;
286 ResourceId arbitrary_resourceid2 = 47;
287 ResourceId arbitrary_resourceid3 = 23;
288 ResourceId arbitrary_resourceid4 = 16;
289 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f);
290 gfx::ColorSpace arbitrary_color_space = gfx::ColorSpace::CreateXYZD50();
291 int root_id = 14;
292
293 FilterOperations arbitrary_filters1;
294 arbitrary_filters1.Append(
295 FilterOperation::CreateGrayscaleFilter(arbitrary_float1));
296 arbitrary_filters1.Append(FilterOperation::CreateReferenceFilter(
297 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr)));
298
299 FilterOperations arbitrary_filters2;
300 arbitrary_filters2.Append(
301 FilterOperation::CreateBrightnessFilter(arbitrary_float2));
302
303 std::unique_ptr<RenderPass> pass_in = RenderPass::Create();
304 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2,
305 arbitrary_matrix1, arbitrary_filters2, arbitrary_filters1,
306 arbitrary_color_space, arbitrary_bool1);
307
308 // Texture quads
309 for (uint32_t i = 0; i < 10; ++i) {
310 SharedQuadState* shared_state1_in =
311 pass_in->CreateAndAppendSharedQuadState();
312 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1,
313 arbitrary_rect1, arbitrary_rect2,
314 arbitrary_bool1, arbitrary_float1,
315 arbitrary_blend_mode1, arbitrary_context_id1);
316
317 TextureDrawQuad* texture_in =
318 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
319 texture_in->SetAll(
320 shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
321 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid1,
322 arbitrary_size1, arbitrary_bool1, arbitrary_pointf1,
323 arbitrary_pointf2, arbitrary_color, arbitrary_float_array,
324 arbitrary_bool4, arbitrary_bool5, arbitrary_bool6);
325
326 TextureDrawQuad* texture_in2 =
327 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
328 texture_in2->SetAll(
329 shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
330 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid2,
331 arbitrary_size1, arbitrary_bool3, arbitrary_pointf1,
332 arbitrary_pointf2, arbitrary_color, arbitrary_float_array,
333 arbitrary_bool4, arbitrary_bool5, arbitrary_bool6);
334
335 TextureDrawQuad* texture_in3 =
336 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
337 texture_in3->SetAll(
338 shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
339 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid3,
340 arbitrary_size1, arbitrary_bool2, arbitrary_pointf1,
341 arbitrary_pointf2, arbitrary_color, arbitrary_float_array,
342 arbitrary_bool4, arbitrary_bool6, arbitrary_bool6);
343
344 TextureDrawQuad* texture_in4 =
345 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
346 texture_in4->SetAll(
347 shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
348 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid4,
349 arbitrary_size2, arbitrary_bool4, arbitrary_pointf1,
350 arbitrary_pointf2, arbitrary_color, arbitrary_float_array,
351 arbitrary_bool4, arbitrary_bool5, arbitrary_bool6);
352 }
353
354 // Tiled quads
355 for (uint32_t i = 0; i < 10; ++i) {
356 SharedQuadState* shared_state2_in =
357 pass_in->CreateAndAppendSharedQuadState();
358 shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2,
359 arbitrary_rect2, arbitrary_rect3,
360 arbitrary_bool1, arbitrary_float2,
361 arbitrary_blend_mode2, arbitrary_context_id2);
362 for (uint32_t j = 0; j < 6; ++j) {
363 TileDrawQuad* tile_in =
364 pass_in->CreateAndAppendDrawQuad<TileDrawQuad>();
365 tile_in->SetAll(shared_state2_in, arbitrary_rect2,
366 arbitrary_rect2_inside_rect2,
367 arbitrary_rect1_inside_rect2, arbitrary_bool1,
368 arbitrary_resourceid3, arbitrary_rectf1,
369 arbitrary_size1, arbitrary_bool2, arbitrary_bool3);
370 }
371 }
372
373 // Solid color quads
374 for (uint32_t i = 0; i < 5; ++i) {
375 SharedQuadState* shared_state3_in =
376 pass_in->CreateAndAppendSharedQuadState();
377 shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3,
378 arbitrary_rect3, arbitrary_rect1,
379 arbitrary_bool1, arbitrary_float3,
380 arbitrary_blend_mode3, arbitrary_context_id3);
381 for (uint32_t j = 0; j < 5; ++j) {
382 SolidColorDrawQuad* solidcolor_in =
383 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
384 solidcolor_in->SetAll(shared_state3_in, arbitrary_rect3,
385 arbitrary_rect1_inside_rect3,
386 arbitrary_rect2_inside_rect3, arbitrary_bool1,
387 arbitrary_color, arbitrary_bool2);
388 }
389 }
390
391 render_pass_list.push_back(std::move(pass_in));
392 RunTest(test_name, std::move(frame), UseSingleSharedQuadState::NO);
393 }
394
229 static void RunCompositorFrameTest(const std::string& test_name, 395 static void RunCompositorFrameTest(const std::string& test_name,
230 uint32_t num_quads, 396 uint32_t num_quads,
231 uint32_t num_passes, 397 uint32_t num_passes,
232 UseSingleSharedQuadState single_sqs) { 398 UseSingleSharedQuadState single_sqs) {
233 CompositorFrame frame; 399 CompositorFrame frame;
234 400
235 for (uint32_t i = 0; i < num_passes; ++i) { 401 for (uint32_t i = 0; i < num_passes; ++i) {
236 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 402 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
237 render_pass->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform()); 403 render_pass->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform());
238 for (uint32_t j = 0; j < num_quads; ++j) { 404 for (uint32_t j = 0; j < num_quads; ++j) {
(...skipping 14 matching lines...) Expand all
253 static void RunTest(const std::string& test_name, 419 static void RunTest(const std::string& test_name,
254 CompositorFrame frame, 420 CompositorFrame frame,
255 UseSingleSharedQuadState single_sqs) { 421 UseSingleSharedQuadState single_sqs) {
256 RunSerializationTestStructTraits(test_name, frame, single_sqs); 422 RunSerializationTestStructTraits(test_name, frame, single_sqs);
257 RunDeserializationTestStructTraits(test_name, frame, single_sqs); 423 RunDeserializationTestStructTraits(test_name, frame, single_sqs);
258 RunSerializationTestParamTraits(test_name, frame, single_sqs); 424 RunSerializationTestParamTraits(test_name, frame, single_sqs);
259 RunDeserializationTestParamTraits(test_name, frame, single_sqs); 425 RunDeserializationTestParamTraits(test_name, frame, single_sqs);
260 } 426 }
261 }; 427 };
262 428
429 // Test for compositor frames with one render pass, 80 resources in resource
430 // list, 10 shared quad states with 4 texture quads each, 10 shared quad states
431 // with 6 tiled quads each, and 5 shared quad states with 5 solid color quads
432 // each.
433 TEST_F(CCSerializationPerfTest, DelegatedFrame_Complex) {
434 RunComplexCompositorFrameTest("DelegatedFrame_Complex");
435 }
436
263 // Test for compositor frames with one render pass and 4000 quads. 437 // Test for compositor frames with one render pass and 4000 quads.
264 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) { 438 TEST_F(CCSerializationPerfTest, DelegatedFrame_ManyQuads_1_4000) {
265 // Case 1: One shared quad state for all quads in one render pass. 439 // Case 1: One shared quad state for all quads in one render pass.
266 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_4000", 4000, 1, 440 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_4000", 4000, 1,
267 UseSingleSharedQuadState::YES); 441 UseSingleSharedQuadState::YES);
268 // Case 2: One shared quad state for each quad. 442 // Case 2: One shared quad state for each quad.
269 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_4000", 4000, 1, 443 RunCompositorFrameTest("DelegatedFrame_ManyQuads_1_4000", 4000, 1,
270 UseSingleSharedQuadState::NO); 444 UseSingleSharedQuadState::NO);
271 } 445 }
272 446
(...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. 501 // Case 1: One shared quad state for all quads in one render pass.
328 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_1000_100", 100, 1000, 502 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_1000_100", 100, 1000,
329 UseSingleSharedQuadState::YES); 503 UseSingleSharedQuadState::YES);
330 // Case 2: One shared quad state for each quad. 504 // Case 2: One shared quad state for each quad.
331 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_1000_100", 100, 1000, 505 RunCompositorFrameTest("DelegatedFrame_ManyRenderPasses_1000_100", 100, 1000,
332 UseSingleSharedQuadState::NO); 506 UseSingleSharedQuadState::NO);
333 } 507 }
334 508
335 } // namespace 509 } // namespace
336 } // namespace cc 510 } // 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