/src/skia/include/gpu/graphite/ContextOptions.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2022 Google LLC |
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 | | |
8 | | #ifndef skgpu_graphite_ContextOptions_DEFINED |
9 | | #define skgpu_graphite_ContextOptions_DEFINED |
10 | | |
11 | | #include "include/private/base/SkAPI.h" |
12 | | #include "include/private/base/SkMath.h" |
13 | | |
14 | | namespace skgpu { class ShaderErrorHandler; } |
15 | | |
16 | | namespace skgpu::graphite { |
17 | | |
18 | | struct ContextOptionsPriv; |
19 | | |
20 | | struct SK_API ContextOptions { |
21 | 24 | ContextOptions() {} |
22 | | |
23 | | /** |
24 | | * Disables correctness workarounds that are enabled for particular GPUs, OSes, or drivers. |
25 | | * This does not affect code path choices that are made for perfomance reasons nor does it |
26 | | * override other ContextOption settings. |
27 | | */ |
28 | | bool fDisableDriverCorrectnessWorkarounds = false; |
29 | | |
30 | | /** |
31 | | * If present, use this object to report shader compilation failures. If not, report failures |
32 | | * via SkDebugf and assert. |
33 | | */ |
34 | | skgpu::ShaderErrorHandler* fShaderErrorHandler = nullptr; |
35 | | |
36 | | /** |
37 | | * Specifies the number of samples Graphite should use when performing internal draws with MSAA |
38 | | * (hardware capabilities permitting). |
39 | | * |
40 | | * If <= 1, Graphite will disable internal code paths that use multisampling. |
41 | | */ |
42 | | int fInternalMultisampleCount = 4; |
43 | | |
44 | | /** |
45 | | * Will the client make sure to only ever be executing one thread that uses the Context and all |
46 | | * derived classes (e.g. Recorders, Recordings, etc.) at a time. If so we can possibly make some |
47 | | * objects (e.g. VulkanMemoryAllocator) not thread safe to improve single thread performance. |
48 | | */ |
49 | | bool fClientWillExternallySynchronizeAllThreads = false; |
50 | | |
51 | | /** |
52 | | * The maximum size of cache textures used for Skia's Glyph cache. |
53 | | */ |
54 | | size_t fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4; |
55 | | |
56 | | /** |
57 | | * Below this threshold size in device space distance field fonts won't be used. Distance field |
58 | | * fonts don't support hinting which is more important at smaller sizes. |
59 | | */ |
60 | | float fMinDistanceFieldFontSize = 18; |
61 | | |
62 | | /** |
63 | | * Above this threshold size in device space glyphs are drawn as individual paths. |
64 | | */ |
65 | | #if defined(SK_BUILD_FOR_ANDROID) |
66 | | float fGlyphsAsPathsFontSize = 384; |
67 | | #elif defined(SK_BUILD_FOR_MAC) |
68 | | float fGlyphsAsPathsFontSize = 256; |
69 | | #else |
70 | | float fGlyphsAsPathsFontSize = 324; |
71 | | #endif |
72 | | |
73 | | /** |
74 | | * The maximum size of textures used for Skia's PathAtlas caches. |
75 | | */ |
76 | | int fMaxPathAtlasTextureSize = 8192; // oversized, PathAtlas will likely be smaller |
77 | | |
78 | | /** |
79 | | * Can the glyph and path atlases use multiple textures. If allowed, each texture's size is |
80 | | * bound by fGlyphCacheTextureMaximumBytes and fMaxPathAtlasTextureSize, respectively. |
81 | | */ |
82 | | bool fAllowMultipleAtlasTextures = true; |
83 | | bool fSupportBilerpFromGlyphAtlas = false; |
84 | | |
85 | | /** |
86 | | * Disable caching of glyph uploads at the start of each Recording. These can add additional |
87 | | * overhead and are only necessary if Recordings are replayed or played out of order. |
88 | | * |
89 | | * Deprecated, now only used to set requireOrderedRecordings Caps. |
90 | | */ |
91 | | bool fDisableCachedGlyphUploads = false; |
92 | | |
93 | | static constexpr size_t kDefaultContextBudget = 256 * (1 << 20); |
94 | | /** |
95 | | * What is the budget for GPU resources allocated and held by the Context. |
96 | | */ |
97 | | size_t fGpuBudgetInBytes = kDefaultContextBudget; |
98 | | |
99 | | /** |
100 | | * Whether labels will be set on backend resources. |
101 | | */ |
102 | | #if defined(SK_DEBUG) |
103 | | bool fSetBackendLabels = true; |
104 | | #else |
105 | | bool fSetBackendLabels = false; |
106 | | #endif |
107 | | |
108 | | /** |
109 | | * Private options that are only meant for testing within Skia's tools. |
110 | | */ |
111 | | ContextOptionsPriv* fOptionsPriv = nullptr; |
112 | | }; |
113 | | |
114 | | } // namespace skgpu::graphite |
115 | | |
116 | | #endif // skgpu_graphite_ContextOptions |