Debian Codegraph @

src/core/SkOpts.cpp

raw
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #include "src/core/SkOpts.h"
8
9 #include "include/private/base/SkFeatures.h"
10 #include "src/core/SkCpu.h"
11 #include "src/core/SkOptsTargets.h"
12
13 #define SK_OPTS_TARGET SK_OPTS_TARGET_DEFAULT
14 #include "src/opts/SkOpts_SetTarget.h"
15
16 #include "src/opts/SkRasterPipeline_opts.h" // IWYU pragma: keep
17
18 #include "src/opts/SkOpts_RestoreTarget.h"
19
20 namespace SkOpts {
21 // Define default function pointer values here...
22 // If our global compile options are set high enough, these defaults might even be
23 // CPU-specialized, e.g. a typical x86-64 machine might start with SSE2 defaults.
24 // They'll still get a chance to be replaced with even better ones, e.g. using SSE4.1.
25 size_t raster_pipeline_lowp_stride = SK_OPTS_NS::raster_pipeline_lowp_stride();
26 size_t raster_pipeline_highp_stride = SK_OPTS_NS::raster_pipeline_highp_stride();
27
28 #define M(st) (StageFn)SK_OPTS_NS::st,
29 StageFn ops_highp[] = { SK_RASTER_PIPELINE_OPS_ALL(M) };
30 StageFn just_return_highp = (StageFn)SK_OPTS_NS::just_return;
31 void (*start_pipeline_highp)(size_t, size_t, size_t, size_t, SkRasterPipelineStage*,
32 SkSpan<SkRasterPipelineContexts::MemoryCtxPatch>,
33 uint8_t*) =
34 SK_OPTS_NS::start_pipeline;
35 #undef M
36
37 #define M(st) (StageFn)SK_OPTS_NS::lowp::st,
38 StageFn ops_lowp[] = { SK_RASTER_PIPELINE_OPS_LOWP(M) };
39 StageFn just_return_lowp = (StageFn)SK_OPTS_NS::lowp::just_return;
40 void (*start_pipeline_lowp)(size_t, size_t, size_t, size_t, SkRasterPipelineStage*,
41 SkSpan<SkRasterPipelineContexts::MemoryCtxPatch>,
42 uint8_t*) =
43 SK_OPTS_NS::lowp::start_pipeline;
44 #undef M
45
46 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp.
47 void Init_hsw();
48 void Init_skx();
49 void Init_lasx();
50
51 static bool init() {
52 #if defined(SK_ENABLE_OPTIMIZE_SIZE)
53 // All Init_foo functions are omitted when optimizing for size
54 #elif defined(SK_CPU_X86)
55 #if SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_AVX2
56 if (SkCpu::Supports(SkCpu::HSW)) { Init_hsw(); }
57 #endif
58
59 #if (SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_SKX) && defined(SK_ENABLE_AVX512_OPTS)
60 if (SkCpu::Supports(SkCpu::SKX)) { Init_skx(); }
61 #endif
62
63 #elif defined(SK_CPU_LOONGARCH)
64 #if SK_CPU_LSX_LEVEL < SK_CPU_LSX_LEVEL_LASX
65 if (SkCpu::Supports(SkCpu::LOONGARCH_ASX)) { Init_lasx(); }
66 #endif
67 #endif
68 return true;
69 }
70
71 void Init() {
72 [[maybe_unused]] static bool gInitialized = init();
73 }
74 } // namespace SkOpts