2 * Copyright 2022 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
7 * This is an experimental (and probably temporary) solution that allows
8 * to compare performance SkVM blitters vs RasterPipeline blitters.
9 * In addition to measuring performance (which is questionable) it also produces
10 * other counts (pixels, scanlines) and more detailed traces that
11 * can explain the current results (SkVM is slower) and help improve it.
12 * The entire code is hidden under build flag skia_compare_vm_vs_rp=true
13 * and will not appear at all without it.
15 * In order to collect the tracing information SkVM Blitters should run with SKVM_BLITTER_TRACE_ON
16 * and RasterPipeline Blitters with RASTER_PIPELINE_BLITTER_TRACE_ON.
19 #ifndef SkBlitterTrace_DEFINED
20 #define SkBlitterTrace_DEFINED
23 #include <unordered_map>
24 #include "src/utils/SkBlitterTraceCommon.h"
26 #ifdef SKIA_COMPARE_VM_VS_RP
28 #if !defined(SK_BLITTER_TRACE_IS_SKVM) && !defined(SK_BLITTER_TRACE_IS_RASTER_PIPELINE)
29 #error "One blitter trace type should be defined if we have flag skia_compare_vm_vs_rp flag = true."
32 #if defined(SK_BLITTER_TRACE_IS_SKVM) && defined(SK_BLITTER_TRACE_IS_RASTER_PIPELINE)
33 #error "Only one blitter trace type should be defined."
36 #ifdef SK_BLITTER_TRACE_IS_SKVM
37 SkBlitterTrace gSkVMBlitterTrace("VM", false);
38 #define SK_BLITTER_TRACE_STEP(name, trace, scanlines, pixels) \
39 SkBlitterTrace::Step name(trace ? &gSkVMBlitterTrace : nullptr, \
45 #ifdef SK_BLITTER_TRACE_IS_RASTER_PIPELINE
46 SkBlitterTrace gSkRPBlitterTrace("RP", false);
47 #define SK_BLITTER_TRACE_STEP(name, trace, scanlines, pixels) \
48 SkBlitterTrace::Step name(trace ? &gSkRPBlitterTrace : nullptr, \
54 #define SK_BLITTER_TRACE_STEP_ACCUMULATE(step, pixels) \
55 step.add(/*scanlines=*/0, /*pixels=*/run)
57 #define INITIATE_BLITTER_TRACE(type) SK_BLITTER_TRACE_NO_CODE
58 #define SK_BLITTER_TRACE_STEP(name, trace, scanlines, pixels) SK_BLITTER_TRACE_NO_CODE
59 #define SK_BLITTER_TRACE_STEP_ACCUMULATE(step, pixels) SK_BLITTER_TRACE_NO_CODE
62 #endif // SkBlitterTrace_DEFINED