summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/utils/SkBlitterTrace.h
blob: e350c0f8c015ec7a8099e85f2b9f79bf48796e1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * Copyright 2022 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * This is an experimental (and probably temporary) solution that allows
 * to compare performance SkVM blitters vs RasterPipeline blitters.
 * In addition to measuring performance (which is questionable) it also produces
 * other counts (pixels, scanlines) and more detailed traces that
 * can explain the current results (SkVM is slower) and help improve it.
 * The entire code is hidden under build flag skia_compare_vm_vs_rp=true
 * and will not appear at all without it.
 *
 * In order to collect the tracing information SkVM Blitters should run with SKVM_BLITTER_TRACE_ON
 * and RasterPipeline Blitters with RASTER_PIPELINE_BLITTER_TRACE_ON.
 */

#ifndef SkBlitterTrace_DEFINED
#define SkBlitterTrace_DEFINED

#include <inttypes.h>
#include <unordered_map>
#include "src/utils/SkBlitterTraceCommon.h"

#ifdef SKIA_COMPARE_VM_VS_RP

#if !defined(SK_BLITTER_TRACE_IS_SKVM) && !defined(SK_BLITTER_TRACE_IS_RASTER_PIPELINE)
#error "One blitter trace type should be defined if we have flag skia_compare_vm_vs_rp flag = true."
#endif

#if defined(SK_BLITTER_TRACE_IS_SKVM) && defined(SK_BLITTER_TRACE_IS_RASTER_PIPELINE)
#error "Only one blitter trace type should be defined."
#endif

#ifdef SK_BLITTER_TRACE_IS_SKVM
SkBlitterTrace gSkVMBlitterTrace("VM", false);
#define SK_BLITTER_TRACE_STEP(name, trace, scanlines, pixels) \
    SkBlitterTrace::Step name(trace ? &gSkVMBlitterTrace : nullptr, \
                              #name,     \
                              scanlines, \
                              pixels)
#endif

#ifdef SK_BLITTER_TRACE_IS_RASTER_PIPELINE
SkBlitterTrace gSkRPBlitterTrace("RP", false);
#define SK_BLITTER_TRACE_STEP(name, trace, scanlines, pixels) \
    SkBlitterTrace::Step name(trace ? &gSkRPBlitterTrace : nullptr, \
                              #name,     \
                              scanlines, \
                              pixels)
#endif

#define SK_BLITTER_TRACE_STEP_ACCUMULATE(step, pixels) \
        step.add(/*scanlines=*/0, /*pixels=*/run)
#else
#define INITIATE_BLITTER_TRACE(type) SK_BLITTER_TRACE_NO_CODE
#define SK_BLITTER_TRACE_STEP(name, trace, scanlines, pixels) SK_BLITTER_TRACE_NO_CODE
#define SK_BLITTER_TRACE_STEP_ACCUMULATE(step, pixels) SK_BLITTER_TRACE_NO_CODE
#endif

#endif // SkBlitterTrace_DEFINED