commit-bot@chromium.org | ff6ea26 | 2013-03-12 12:26:08 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | |
| 8 | #ifndef GrTypesPriv_DEFINED |
| 9 | #define GrTypesPriv_DEFINED |
| 10 | |
Brian Salomon | 5e15085 | 2017-03-22 14:53:13 -0400 | [diff] [blame] | 11 | #include <chrono> |
jvanverth@google.com | 054ae99 | 2013-04-01 20:06:51 +0000 | [diff] [blame] | 12 | #include "GrTypes.h" |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 13 | #include "SkRefCnt.h" |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 14 | |
Brian Salomon | e225b56 | 2017-06-14 13:00:03 -0400 | [diff] [blame] | 15 | class GrCaps; |
| 16 | |
Brian Salomon | 5e15085 | 2017-03-22 14:53:13 -0400 | [diff] [blame] | 17 | // The old libstdc++ uses the draft name "monotonic_clock" rather than "steady_clock". This might |
| 18 | // not actually be monotonic, depending on how libstdc++ was built. However, this is only currently |
| 19 | // used for idle resource purging so it shouldn't cause a correctness problem. |
| 20 | #if defined(__GLIBCXX__) && (__GLIBCXX__ < 20130000) |
| 21 | using GrStdSteadyClock = std::chrono::monotonic_clock; |
| 22 | #else |
| 23 | using GrStdSteadyClock = std::chrono::steady_clock; |
| 24 | #endif |
| 25 | |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 26 | /** This enum indicates the type of antialiasing to be performed. */ |
Brian Salomon | af9847e | 2017-03-01 11:28:27 -0500 | [diff] [blame] | 27 | enum class GrAAType : unsigned { |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 28 | /** No antialiasing */ |
| 29 | kNone, |
| 30 | /** Use fragment shader code to compute a fractional pixel coverage. */ |
| 31 | kCoverage, |
| 32 | /** Use normal MSAA. */ |
| 33 | kMSAA, |
| 34 | /** |
| 35 | * Use "mixed samples" MSAA such that the stencil buffer is multisampled but the color buffer is |
| 36 | * not. |
| 37 | */ |
| 38 | kMixedSamples |
| 39 | }; |
| 40 | |
Brian Salomon | 0abc8b4 | 2016-12-13 10:22:54 -0500 | [diff] [blame] | 41 | static inline bool GrAATypeIsHW(GrAAType type) { |
| 42 | switch (type) { |
| 43 | case GrAAType::kNone: |
| 44 | return false; |
| 45 | case GrAAType::kCoverage: |
| 46 | return false; |
| 47 | case GrAAType::kMSAA: |
| 48 | return true; |
| 49 | case GrAAType::kMixedSamples: |
| 50 | return true; |
| 51 | } |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 52 | SK_ABORT("Unknown AA Type"); |
Brian Salomon | 0abc8b4 | 2016-12-13 10:22:54 -0500 | [diff] [blame] | 53 | return false; |
| 54 | } |
| 55 | |
Brian Salomon | 7c8460e | 2017-05-12 11:36:10 -0400 | [diff] [blame] | 56 | /** The type of full scene antialiasing supported by a render target. */ |
| 57 | enum class GrFSAAType { |
| 58 | /** No FSAA */ |
| 59 | kNone, |
| 60 | /** Regular MSAA where each attachment has the same sample count. */ |
| 61 | kUnifiedMSAA, |
| 62 | /** One color sample, N stencil samples. */ |
| 63 | kMixedSamples, |
| 64 | }; |
| 65 | |
| 66 | /** |
| 67 | * Not all drawing code paths support using mixed samples when available and instead use |
| 68 | * coverage-based aa. |
| 69 | */ |
| 70 | enum class GrAllowMixedSamples { kNo, kYes }; |
| 71 | |
Brian Salomon | e225b56 | 2017-06-14 13:00:03 -0400 | [diff] [blame] | 72 | GrAAType GrChooseAAType(GrAA, GrFSAAType, GrAllowMixedSamples, const GrCaps&); |
Brian Salomon | 7c8460e | 2017-05-12 11:36:10 -0400 | [diff] [blame] | 73 | |
Brian Salomon | 0abc8b4 | 2016-12-13 10:22:54 -0500 | [diff] [blame] | 74 | /** |
| 75 | * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars, |
| 76 | * but should be applicable to other shader languages.) |
| 77 | */ |
commit-bot@chromium.org | ff6ea26 | 2013-03-12 12:26:08 +0000 | [diff] [blame] | 78 | enum GrSLType { |
| 79 | kVoid_GrSLType, |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 80 | kBool_GrSLType, |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 81 | kUint_GrSLType, |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 82 | kShort_GrSLType, |
| 83 | kUShort_GrSLType, |
| 84 | kHighFloat_GrSLType, |
| 85 | kHighFloat2_GrSLType, |
| 86 | kHighFloat3_GrSLType, |
| 87 | kHighFloat4_GrSLType, |
| 88 | kHighFloat2x2_GrSLType, |
| 89 | kHighFloat3x3_GrSLType, |
| 90 | kHighFloat4x4_GrSLType, |
| 91 | kHalf_GrSLType, |
| 92 | kHalf2_GrSLType, |
| 93 | kHalf3_GrSLType, |
| 94 | kHalf4_GrSLType, |
| 95 | kHalf2x2_GrSLType, |
| 96 | kHalf3x3_GrSLType, |
| 97 | kHalf4x4_GrSLType, |
| 98 | kInt_GrSLType, |
| 99 | kInt2_GrSLType, |
| 100 | kInt3_GrSLType, |
| 101 | kInt4_GrSLType, |
egdaniel | 990dbc8 | 2016-07-13 14:09:30 -0700 | [diff] [blame] | 102 | kTexture2DSampler_GrSLType, |
Brian Salomon | a8f0002 | 2016-11-16 12:55:57 -0500 | [diff] [blame] | 103 | kITexture2DSampler_GrSLType, |
egdaniel | 990dbc8 | 2016-07-13 14:09:30 -0700 | [diff] [blame] | 104 | kTextureExternalSampler_GrSLType, |
| 105 | kTexture2DRectSampler_GrSLType, |
csmartdalton | 2245803 | 2016-11-16 11:28:16 -0700 | [diff] [blame] | 106 | kBufferSampler_GrSLType, |
egdaniel | 990dbc8 | 2016-07-13 14:09:30 -0700 | [diff] [blame] | 107 | kTexture2D_GrSLType, |
| 108 | kSampler_GrSLType, |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 109 | kImageStorage2D_GrSLType, |
| 110 | kIImageStorage2D_GrSLType, |
commit-bot@chromium.org | ff6ea26 | 2013-03-12 12:26:08 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 113 | enum GrShaderType { |
| 114 | kVertex_GrShaderType, |
| 115 | kGeometry_GrShaderType, |
| 116 | kFragment_GrShaderType, |
| 117 | |
| 118 | kLastkFragment_GrShaderType = kFragment_GrShaderType |
| 119 | }; |
| 120 | static const int kGrShaderTypeCount = kLastkFragment_GrShaderType + 1; |
| 121 | |
cdalton | 5e58cee | 2016-02-11 12:49:47 -0800 | [diff] [blame] | 122 | enum GrShaderFlags { |
| 123 | kNone_GrShaderFlags = 0, |
| 124 | kVertex_GrShaderFlag = 1 << kVertex_GrShaderType, |
| 125 | kGeometry_GrShaderFlag = 1 << kGeometry_GrShaderType, |
| 126 | kFragment_GrShaderFlag = 1 << kFragment_GrShaderType |
| 127 | }; |
| 128 | GR_MAKE_BITFIELD_OPS(GrShaderFlags); |
| 129 | |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 130 | /** |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 131 | * Precisions of shader language variables. Not all shading languages support precisions or actually |
bsalomon | 422f56f | 2014-12-09 10:18:12 -0800 | [diff] [blame] | 132 | * vary the internal precision based on the qualifiers. These currently only apply to float types ( |
| 133 | * including float vectors and matrices). |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 134 | */ |
| 135 | enum GrSLPrecision { |
| 136 | kLow_GrSLPrecision, |
| 137 | kMedium_GrSLPrecision, |
| 138 | kHigh_GrSLPrecision, |
| 139 | |
Brian Osman | 33aa2c7 | 2017-04-05 09:26:15 -0400 | [diff] [blame] | 140 | // Default precision is a special tag that means "whatever the default for the program/type |
| 141 | // combination is". In other words, it maps to the empty string in shader code. There are some |
| 142 | // scenarios where kDefault is not allowed (as the default precision for a program, or for |
| 143 | // varyings, for example). |
| 144 | kDefault_GrSLPrecision, |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 145 | |
Brian Osman | 33aa2c7 | 2017-04-05 09:26:15 -0400 | [diff] [blame] | 146 | // We only consider the "real" precisions here |
| 147 | kLast_GrSLPrecision = kHigh_GrSLPrecision, |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1; |
| 151 | |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 152 | /** Is the shading language type float (including vectors/matrices)? */ |
bsalomon | 422f56f | 2014-12-09 10:18:12 -0800 | [diff] [blame] | 153 | static inline bool GrSLTypeIsFloatType(GrSLType type) { |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 154 | switch (type) { |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 155 | case kHighFloat_GrSLType: |
| 156 | case kHighFloat2_GrSLType: |
| 157 | case kHighFloat3_GrSLType: |
| 158 | case kHighFloat4_GrSLType: |
| 159 | case kHighFloat2x2_GrSLType: |
| 160 | case kHighFloat3x3_GrSLType: |
| 161 | case kHighFloat4x4_GrSLType: |
| 162 | case kHalf_GrSLType: |
| 163 | case kHalf2_GrSLType: |
| 164 | case kHalf3_GrSLType: |
| 165 | case kHalf4_GrSLType: |
| 166 | case kHalf2x2_GrSLType: |
| 167 | case kHalf3x3_GrSLType: |
| 168 | case kHalf4x4_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 169 | return true; |
bsalomon | 422f56f | 2014-12-09 10:18:12 -0800 | [diff] [blame] | 170 | |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 171 | case kVoid_GrSLType: |
| 172 | case kTexture2DSampler_GrSLType: |
Brian Salomon | a8f0002 | 2016-11-16 12:55:57 -0500 | [diff] [blame] | 173 | case kITexture2DSampler_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 174 | case kTextureExternalSampler_GrSLType: |
| 175 | case kTexture2DRectSampler_GrSLType: |
csmartdalton | 2245803 | 2016-11-16 11:28:16 -0700 | [diff] [blame] | 176 | case kBufferSampler_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 177 | case kBool_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 178 | case kUint_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 179 | case kShort_GrSLType: |
| 180 | case kUShort_GrSLType: |
| 181 | case kInt_GrSLType: |
| 182 | case kInt2_GrSLType: |
| 183 | case kInt3_GrSLType: |
| 184 | case kInt4_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 185 | case kTexture2D_GrSLType: |
| 186 | case kSampler_GrSLType: |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 187 | case kImageStorage2D_GrSLType: |
| 188 | case kIImageStorage2D_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 189 | return false; |
| 190 | } |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 191 | SK_ABORT("Unexpected type"); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 192 | return false; |
bsalomon | e5286e0 | 2016-01-14 09:24:09 -0800 | [diff] [blame] | 193 | } |
| 194 | |
egdaniel | 990dbc8 | 2016-07-13 14:09:30 -0700 | [diff] [blame] | 195 | static inline bool GrSLTypeIs2DCombinedSamplerType(GrSLType type) { |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 196 | switch (type) { |
| 197 | case kTexture2DSampler_GrSLType: |
Brian Salomon | a8f0002 | 2016-11-16 12:55:57 -0500 | [diff] [blame] | 198 | case kITexture2DSampler_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 199 | case kTextureExternalSampler_GrSLType: |
| 200 | case kTexture2DRectSampler_GrSLType: |
| 201 | return true; |
bsalomon | e5286e0 | 2016-01-14 09:24:09 -0800 | [diff] [blame] | 202 | |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 203 | case kVoid_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 204 | case kHighFloat_GrSLType: |
| 205 | case kHighFloat2_GrSLType: |
| 206 | case kHighFloat3_GrSLType: |
| 207 | case kHighFloat4_GrSLType: |
| 208 | case kHighFloat2x2_GrSLType: |
| 209 | case kHighFloat3x3_GrSLType: |
| 210 | case kHighFloat4x4_GrSLType: |
| 211 | case kHalf_GrSLType: |
| 212 | case kHalf2_GrSLType: |
| 213 | case kHalf3_GrSLType: |
| 214 | case kHalf4_GrSLType: |
| 215 | case kHalf2x2_GrSLType: |
| 216 | case kHalf3x3_GrSLType: |
| 217 | case kHalf4x4_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 218 | case kInt_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 219 | case kInt2_GrSLType: |
| 220 | case kInt3_GrSLType: |
| 221 | case kInt4_GrSLType: |
| 222 | case kBufferSampler_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 223 | case kUint_GrSLType: |
| 224 | case kBool_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 225 | case kShort_GrSLType: |
| 226 | case kUShort_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 227 | case kTexture2D_GrSLType: |
| 228 | case kSampler_GrSLType: |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 229 | case kImageStorage2D_GrSLType: |
| 230 | case kIImageStorage2D_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 231 | return false; |
| 232 | } |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 233 | SK_ABORT("Unexpected type"); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 234 | return false; |
egdaniel | fa89632 | 2016-01-13 12:19:30 -0800 | [diff] [blame] | 235 | } |
| 236 | |
egdaniel | 990dbc8 | 2016-07-13 14:09:30 -0700 | [diff] [blame] | 237 | static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) { |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 238 | switch (type) { |
| 239 | case kTexture2DSampler_GrSLType: |
Brian Salomon | a8f0002 | 2016-11-16 12:55:57 -0500 | [diff] [blame] | 240 | case kITexture2DSampler_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 241 | case kTextureExternalSampler_GrSLType: |
| 242 | case kTexture2DRectSampler_GrSLType: |
csmartdalton | 2245803 | 2016-11-16 11:28:16 -0700 | [diff] [blame] | 243 | case kBufferSampler_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 244 | return true; |
cdalton | 74b8d32 | 2016-04-11 14:47:28 -0700 | [diff] [blame] | 245 | |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 246 | case kVoid_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 247 | case kHighFloat_GrSLType: |
| 248 | case kHighFloat2_GrSLType: |
| 249 | case kHighFloat3_GrSLType: |
| 250 | case kHighFloat4_GrSLType: |
| 251 | case kHighFloat2x2_GrSLType: |
| 252 | case kHighFloat3x3_GrSLType: |
| 253 | case kHighFloat4x4_GrSLType: |
| 254 | case kHalf_GrSLType: |
| 255 | case kHalf2_GrSLType: |
| 256 | case kHalf3_GrSLType: |
| 257 | case kHalf4_GrSLType: |
| 258 | case kHalf2x2_GrSLType: |
| 259 | case kHalf3x3_GrSLType: |
| 260 | case kHalf4x4_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 261 | case kInt_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 262 | case kInt2_GrSLType: |
| 263 | case kInt3_GrSLType: |
| 264 | case kInt4_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 265 | case kUint_GrSLType: |
| 266 | case kBool_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 267 | case kShort_GrSLType: |
| 268 | case kUShort_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 269 | case kTexture2D_GrSLType: |
| 270 | case kSampler_GrSLType: |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 271 | case kImageStorage2D_GrSLType: |
| 272 | case kIImageStorage2D_GrSLType: |
| 273 | return false; |
| 274 | } |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 275 | SK_ABORT("Unexpected type"); |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 276 | return false; |
| 277 | } |
| 278 | |
| 279 | static inline bool GrSLTypeIsImageStorage(GrSLType type) { |
| 280 | switch (type) { |
| 281 | case kImageStorage2D_GrSLType: |
| 282 | case kIImageStorage2D_GrSLType: |
| 283 | return true; |
| 284 | |
| 285 | case kVoid_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 286 | case kHighFloat_GrSLType: |
| 287 | case kHighFloat2_GrSLType: |
| 288 | case kHighFloat3_GrSLType: |
| 289 | case kHighFloat4_GrSLType: |
| 290 | case kHighFloat2x2_GrSLType: |
| 291 | case kHighFloat3x3_GrSLType: |
| 292 | case kHighFloat4x4_GrSLType: |
| 293 | case kHalf_GrSLType: |
| 294 | case kHalf2_GrSLType: |
| 295 | case kHalf3_GrSLType: |
| 296 | case kHalf4_GrSLType: |
| 297 | case kHalf2x2_GrSLType: |
| 298 | case kHalf3x3_GrSLType: |
| 299 | case kHalf4x4_GrSLType: |
| 300 | case kInt2_GrSLType: |
| 301 | case kInt3_GrSLType: |
| 302 | case kInt4_GrSLType: |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 303 | case kInt_GrSLType: |
| 304 | case kUint_GrSLType: |
| 305 | case kBool_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 306 | case kShort_GrSLType: |
| 307 | case kUShort_GrSLType: |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 308 | case kTexture2D_GrSLType: |
| 309 | case kSampler_GrSLType: |
| 310 | case kTexture2DSampler_GrSLType: |
| 311 | case kITexture2DSampler_GrSLType: |
| 312 | case kTextureExternalSampler_GrSLType: |
| 313 | case kTexture2DRectSampler_GrSLType: |
| 314 | case kBufferSampler_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 315 | return false; |
| 316 | } |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 317 | SK_ABORT("Unexpected type"); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 318 | return false; |
cdalton | 74b8d32 | 2016-04-11 14:47:28 -0700 | [diff] [blame] | 319 | } |
| 320 | |
cdalton | 5f2d8e2 | 2016-03-11 13:34:32 -0800 | [diff] [blame] | 321 | static inline bool GrSLTypeAcceptsPrecision(GrSLType type) { |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 322 | switch (type) { |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 323 | case kTexture2DSampler_GrSLType: |
| 324 | case kITexture2DSampler_GrSLType: |
| 325 | case kTextureExternalSampler_GrSLType: |
| 326 | case kTexture2DRectSampler_GrSLType: |
| 327 | case kBufferSampler_GrSLType: |
| 328 | case kTexture2D_GrSLType: |
| 329 | case kSampler_GrSLType: |
| 330 | case kImageStorage2D_GrSLType: |
| 331 | case kIImageStorage2D_GrSLType: |
| 332 | return true; |
| 333 | |
| 334 | case kVoid_GrSLType: |
| 335 | case kBool_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 336 | case kUint_GrSLType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 337 | case kShort_GrSLType: |
| 338 | case kUShort_GrSLType: |
| 339 | case kHighFloat_GrSLType: |
| 340 | case kHighFloat2_GrSLType: |
| 341 | case kHighFloat3_GrSLType: |
| 342 | case kHighFloat4_GrSLType: |
| 343 | case kHighFloat2x2_GrSLType: |
| 344 | case kHighFloat3x3_GrSLType: |
| 345 | case kHighFloat4x4_GrSLType: |
| 346 | case kHalf_GrSLType: |
| 347 | case kHalf2_GrSLType: |
| 348 | case kHalf3_GrSLType: |
| 349 | case kHalf4_GrSLType: |
| 350 | case kHalf2x2_GrSLType: |
| 351 | case kHalf3x3_GrSLType: |
| 352 | case kHalf4x4_GrSLType: |
| 353 | case kInt_GrSLType: |
| 354 | case kInt2_GrSLType: |
| 355 | case kInt3_GrSLType: |
| 356 | case kInt4_GrSLType: |
| 357 | return false; |
| 358 | } |
Ben Wagner | 824e730 | 2017-08-17 09:15:28 -0400 | [diff] [blame] | 359 | SK_ABORT("Unexpected type"); |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 360 | return false; |
| 361 | } |
| 362 | |
| 363 | // temporarily accepting (but ignoring) precision modifiers on the new types; this will be killed |
| 364 | // in a future CL |
| 365 | static inline bool GrSLTypeTemporarilyAcceptsPrecision(GrSLType type) { |
| 366 | switch (type) { |
| 367 | case kUint_GrSLType: |
| 368 | case kShort_GrSLType: |
| 369 | case kUShort_GrSLType: |
| 370 | case kHighFloat_GrSLType: |
| 371 | case kHighFloat2_GrSLType: |
| 372 | case kHighFloat3_GrSLType: |
| 373 | case kHighFloat4_GrSLType: |
| 374 | case kHighFloat2x2_GrSLType: |
| 375 | case kHighFloat3x3_GrSLType: |
| 376 | case kHighFloat4x4_GrSLType: |
| 377 | case kHalf_GrSLType: |
| 378 | case kHalf2_GrSLType: |
| 379 | case kHalf3_GrSLType: |
| 380 | case kHalf4_GrSLType: |
| 381 | case kHalf2x2_GrSLType: |
| 382 | case kHalf3x3_GrSLType: |
| 383 | case kHalf4x4_GrSLType: |
| 384 | case kInt_GrSLType: |
| 385 | case kInt2_GrSLType: |
| 386 | case kInt3_GrSLType: |
| 387 | case kInt4_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 388 | case kTexture2DSampler_GrSLType: |
Brian Salomon | a8f0002 | 2016-11-16 12:55:57 -0500 | [diff] [blame] | 389 | case kITexture2DSampler_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 390 | case kTextureExternalSampler_GrSLType: |
| 391 | case kTexture2DRectSampler_GrSLType: |
csmartdalton | 2245803 | 2016-11-16 11:28:16 -0700 | [diff] [blame] | 392 | case kBufferSampler_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 393 | case kTexture2D_GrSLType: |
| 394 | case kSampler_GrSLType: |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 395 | case kImageStorage2D_GrSLType: |
| 396 | case kIImageStorage2D_GrSLType: |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 397 | return true; |
| 398 | |
| 399 | case kVoid_GrSLType: |
| 400 | case kBool_GrSLType: |
| 401 | return false; |
| 402 | } |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 403 | SK_ABORT("Unexpected type"); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 404 | return false; |
cdalton | 5f2d8e2 | 2016-03-11 13:34:32 -0800 | [diff] [blame] | 405 | } |
| 406 | |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 407 | ////////////////////////////////////////////////////////////////////////////// |
| 408 | |
jvanverth@google.com | 054ae99 | 2013-04-01 20:06:51 +0000 | [diff] [blame] | 409 | /** |
| 410 | * Types used to describe format of vertices in arrays. |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 411 | */ |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 412 | enum GrVertexAttribType { |
| 413 | kFloat_GrVertexAttribType = 0, |
| 414 | kVec2f_GrVertexAttribType, |
| 415 | kVec3f_GrVertexAttribType, |
| 416 | kVec4f_GrVertexAttribType, |
egdaniel | 37b4d86 | 2014-11-03 10:07:07 -0800 | [diff] [blame] | 417 | |
csmartdalton | b37cb23 | 2017-02-08 14:56:27 -0500 | [diff] [blame] | 418 | kVec2i_GrVertexAttribType, // vector of 2 32-bit ints |
| 419 | kVec3i_GrVertexAttribType, // vector of 3 32-bit ints |
| 420 | kVec4i_GrVertexAttribType, // vector of 4 32-bit ints |
| 421 | |
egdaniel | 37b4d86 | 2014-11-03 10:07:07 -0800 | [diff] [blame] | 422 | kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage |
jvanverth | 5a105ff | 2015-02-18 11:36:35 -0800 | [diff] [blame] | 423 | kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 424 | |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 425 | kVec2us_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 426 | |
| 427 | kInt_GrVertexAttribType, |
cdalton | 793dc26 | 2016-02-08 10:11:47 -0800 | [diff] [blame] | 428 | kUint_GrVertexAttribType, |
egdaniel | 990dbc8 | 2016-07-13 14:09:30 -0700 | [diff] [blame] | 429 | |
cdalton | 793dc26 | 2016-02-08 10:11:47 -0800 | [diff] [blame] | 430 | kLast_GrVertexAttribType = kUint_GrVertexAttribType |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 431 | }; |
| 432 | static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; |
| 433 | |
jvanverth@google.com | 054ae99 | 2013-04-01 20:06:51 +0000 | [diff] [blame] | 434 | /** |
| 435 | * Returns the size of the attrib type in bytes. |
| 436 | */ |
| 437 | static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 438 | switch (type) { |
| 439 | case kFloat_GrVertexAttribType: |
| 440 | return sizeof(float); |
| 441 | case kVec2f_GrVertexAttribType: |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 442 | return 2 * sizeof(float); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 443 | case kVec3f_GrVertexAttribType: |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 444 | return 3 * sizeof(float); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 445 | case kVec4f_GrVertexAttribType: |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 446 | return 4 * sizeof(float); |
csmartdalton | b37cb23 | 2017-02-08 14:56:27 -0500 | [diff] [blame] | 447 | case kVec2i_GrVertexAttribType: |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 448 | return 2 * sizeof(int32_t); |
csmartdalton | b37cb23 | 2017-02-08 14:56:27 -0500 | [diff] [blame] | 449 | case kVec3i_GrVertexAttribType: |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 450 | return 3 * sizeof(int32_t); |
csmartdalton | b37cb23 | 2017-02-08 14:56:27 -0500 | [diff] [blame] | 451 | case kVec4i_GrVertexAttribType: |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 452 | return 4 * sizeof(int32_t); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 453 | case kUByte_GrVertexAttribType: |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 454 | return 1 * sizeof(char); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 455 | case kVec4ub_GrVertexAttribType: |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 456 | return 4 * sizeof(char); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 457 | case kVec2us_GrVertexAttribType: |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 458 | return 2 * sizeof(int16_t); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 459 | case kInt_GrVertexAttribType: |
| 460 | return sizeof(int32_t); |
| 461 | case kUint_GrVertexAttribType: |
| 462 | return sizeof(uint32_t); |
| 463 | } |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 464 | SK_ABORT("Unexpected attribute type"); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 465 | return 0; |
jvanverth@google.com | 054ae99 | 2013-04-01 20:06:51 +0000 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | /** |
cdalton | 793dc26 | 2016-02-08 10:11:47 -0800 | [diff] [blame] | 469 | * Is the attrib type integral? |
| 470 | */ |
| 471 | static inline bool GrVertexAttribTypeIsIntType(GrVertexAttribType type) { |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 472 | switch (type) { |
| 473 | case kFloat_GrVertexAttribType: |
| 474 | return false; |
| 475 | case kVec2f_GrVertexAttribType: |
| 476 | return false; |
| 477 | case kVec3f_GrVertexAttribType: |
| 478 | return false; |
| 479 | case kVec4f_GrVertexAttribType: |
| 480 | return false; |
csmartdalton | b37cb23 | 2017-02-08 14:56:27 -0500 | [diff] [blame] | 481 | case kVec2i_GrVertexAttribType: |
| 482 | return true; |
| 483 | case kVec3i_GrVertexAttribType: |
| 484 | return true; |
| 485 | case kVec4i_GrVertexAttribType: |
| 486 | return true; |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 487 | case kUByte_GrVertexAttribType: |
| 488 | return false; |
| 489 | case kVec4ub_GrVertexAttribType: |
| 490 | return false; |
| 491 | case kVec2us_GrVertexAttribType: |
| 492 | return false; |
| 493 | case kInt_GrVertexAttribType: |
| 494 | return true; |
| 495 | case kUint_GrVertexAttribType: |
| 496 | return true; |
| 497 | } |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 498 | SK_ABORT("Unexpected attribute type"); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 499 | return false; |
cdalton | 793dc26 | 2016-02-08 10:11:47 -0800 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | /** |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 503 | * converts a GrVertexAttribType to a GrSLType |
jvanverth@google.com | 054ae99 | 2013-04-01 20:06:51 +0000 | [diff] [blame] | 504 | */ |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 505 | static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { |
| 506 | switch (type) { |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 507 | case kUByte_GrVertexAttribType: |
| 508 | case kFloat_GrVertexAttribType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 509 | return kHighFloat_GrSLType; |
jvanverth | 7023a00 | 2016-02-22 11:25:32 -0800 | [diff] [blame] | 510 | case kVec2us_GrVertexAttribType: |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 511 | case kVec2f_GrVertexAttribType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 512 | return kHighFloat2_GrSLType; |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 513 | case kVec3f_GrVertexAttribType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 514 | return kHighFloat3_GrSLType; |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 515 | case kVec4ub_GrVertexAttribType: |
| 516 | case kVec4f_GrVertexAttribType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 517 | return kHighFloat4_GrSLType; |
csmartdalton | b37cb23 | 2017-02-08 14:56:27 -0500 | [diff] [blame] | 518 | case kVec2i_GrVertexAttribType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 519 | return kInt2_GrSLType; |
csmartdalton | b37cb23 | 2017-02-08 14:56:27 -0500 | [diff] [blame] | 520 | case kVec3i_GrVertexAttribType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 521 | return kInt3_GrSLType; |
csmartdalton | b37cb23 | 2017-02-08 14:56:27 -0500 | [diff] [blame] | 522 | case kVec4i_GrVertexAttribType: |
Ethan Nicholas | 88d99c6 | 2017-08-16 16:41:30 -0400 | [diff] [blame] | 523 | return kInt4_GrSLType; |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 524 | case kInt_GrVertexAttribType: |
| 525 | return kInt_GrSLType; |
cdalton | 793dc26 | 2016-02-08 10:11:47 -0800 | [diff] [blame] | 526 | case kUint_GrVertexAttribType: |
| 527 | return kUint_GrSLType; |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 528 | } |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 529 | SK_ABORT("Unsupported type conversion"); |
Brian Salomon | fa26e66 | 2016-11-14 11:27:00 -0500 | [diff] [blame] | 530 | return kVoid_GrSLType; |
joshualitt | 2dd1ae0 | 2014-12-03 06:24:10 -0800 | [diff] [blame] | 531 | } |
bsalomon@google.com | 31ec798 | 2013-03-27 18:14:57 +0000 | [diff] [blame] | 532 | |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 533 | ////////////////////////////////////////////////////////////////////////////// |
| 534 | |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 535 | enum class GrImageStorageFormat { |
| 536 | kRGBA8, |
| 537 | kRGBA8i, |
| 538 | kRGBA16f, |
| 539 | kRGBA32f, |
| 540 | }; |
| 541 | |
| 542 | /** |
| 543 | * Describes types of caching and compiler optimizations allowed for certain variable types |
| 544 | * (currently only image storages). |
| 545 | **/ |
| 546 | enum class GrSLMemoryModel { |
| 547 | /** No special restrctions on memory accesses or compiler optimizations */ |
| 548 | kNone, |
| 549 | /** Cache coherent across shader invocations */ |
| 550 | kCoherent, |
| 551 | /** |
| 552 | * Disallows compiler from eliding loads or stores that appear redundant in a single |
| 553 | * invocation. Implies coherent. |
| 554 | */ |
| 555 | kVolatile |
| 556 | }; |
| 557 | |
| 558 | /** |
| 559 | * If kYes then the memory backing the varialble is only accessed via the variable. This is |
| 560 | * currently only used with image storages. |
| 561 | */ |
| 562 | enum class GrSLRestrict { |
| 563 | kYes, |
| 564 | kNo, |
| 565 | }; |
| 566 | |
| 567 | ////////////////////////////////////////////////////////////////////////////// |
| 568 | |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 569 | /** |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 570 | * We have coverage effects that clip rendering to the edge of some geometric primitive. |
| 571 | * This enum specifies how that clipping is performed. Not all factories that take a |
| 572 | * GrProcessorEdgeType will succeed with all values and it is up to the caller to check for |
| 573 | * a NULL return. |
| 574 | */ |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 575 | enum GrPrimitiveEdgeType { |
| 576 | kFillBW_GrProcessorEdgeType, |
| 577 | kFillAA_GrProcessorEdgeType, |
| 578 | kInverseFillBW_GrProcessorEdgeType, |
| 579 | kInverseFillAA_GrProcessorEdgeType, |
| 580 | kHairlineAA_GrProcessorEdgeType, |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 581 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 582 | kLast_GrProcessorEdgeType = kHairlineAA_GrProcessorEdgeType |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 583 | }; |
| 584 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 585 | static const int kGrProcessorEdgeTypeCnt = kLast_GrProcessorEdgeType + 1; |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 586 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 587 | static inline bool GrProcessorEdgeTypeIsFill(const GrPrimitiveEdgeType edgeType) { |
| 588 | return (kFillAA_GrProcessorEdgeType == edgeType || kFillBW_GrProcessorEdgeType == edgeType); |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 589 | } |
| 590 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 591 | static inline bool GrProcessorEdgeTypeIsInverseFill(const GrPrimitiveEdgeType edgeType) { |
| 592 | return (kInverseFillAA_GrProcessorEdgeType == edgeType || |
| 593 | kInverseFillBW_GrProcessorEdgeType == edgeType); |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 594 | } |
| 595 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 596 | static inline bool GrProcessorEdgeTypeIsAA(const GrPrimitiveEdgeType edgeType) { |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 597 | return (kFillBW_GrProcessorEdgeType != edgeType && |
| 598 | kInverseFillBW_GrProcessorEdgeType != edgeType); |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 599 | } |
| 600 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 601 | static inline GrPrimitiveEdgeType GrInvertProcessorEdgeType(const GrPrimitiveEdgeType edgeType) { |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 602 | switch (edgeType) { |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 603 | case kFillBW_GrProcessorEdgeType: |
| 604 | return kInverseFillBW_GrProcessorEdgeType; |
| 605 | case kFillAA_GrProcessorEdgeType: |
| 606 | return kInverseFillAA_GrProcessorEdgeType; |
| 607 | case kInverseFillBW_GrProcessorEdgeType: |
| 608 | return kFillBW_GrProcessorEdgeType; |
| 609 | case kInverseFillAA_GrProcessorEdgeType: |
| 610 | return kFillAA_GrProcessorEdgeType; |
| 611 | case kHairlineAA_GrProcessorEdgeType: |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 612 | SK_ABORT("Hairline fill isn't invertible."); |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 613 | } |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 614 | return kFillAA_GrProcessorEdgeType; // suppress warning. |
commit-bot@chromium.org | cabf4b2 | 2014-03-05 18:27:43 +0000 | [diff] [blame] | 615 | } |
| 616 | |
bsalomon | bcf0a52 | 2014-10-08 08:40:09 -0700 | [diff] [blame] | 617 | /** |
| 618 | * Indicates the type of pending IO operations that can be recorded for gpu resources. |
| 619 | */ |
| 620 | enum GrIOType { |
| 621 | kRead_GrIOType, |
| 622 | kWrite_GrIOType, |
| 623 | kRW_GrIOType |
| 624 | }; |
| 625 | |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 626 | /** |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 627 | * Indicates the type of data that a GPU buffer will be used for. |
| 628 | */ |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 629 | enum GrBufferType { |
| 630 | kVertex_GrBufferType, |
| 631 | kIndex_GrBufferType, |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 632 | kTexel_GrBufferType, |
| 633 | kDrawIndirect_GrBufferType, |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 634 | kXferCpuToGpu_GrBufferType, |
| 635 | kXferGpuToCpu_GrBufferType, |
| 636 | |
| 637 | kLast_GrBufferType = kXferGpuToCpu_GrBufferType |
| 638 | }; |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 639 | static const int kGrBufferTypeCount = kLast_GrBufferType + 1; |
| 640 | |
| 641 | static inline bool GrBufferTypeIsVertexOrIndex(GrBufferType type) { |
| 642 | SkASSERT(type >= 0 && type < kGrBufferTypeCount); |
| 643 | return type <= kIndex_GrBufferType; |
| 644 | |
| 645 | GR_STATIC_ASSERT(0 == kVertex_GrBufferType); |
| 646 | GR_STATIC_ASSERT(1 == kIndex_GrBufferType); |
| 647 | } |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 648 | |
| 649 | /** |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 650 | * Provides a performance hint regarding the frequency at which a data store will be accessed. |
| 651 | */ |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 652 | enum GrAccessPattern { |
| 653 | /** Data store will be respecified repeatedly and used many times. */ |
| 654 | kDynamic_GrAccessPattern, |
| 655 | /** Data store will be specified once and used many times. (Thus disqualified from caching.) */ |
| 656 | kStatic_GrAccessPattern, |
| 657 | /** Data store will be specified once and used at most a few times. (Also can't be cached.) */ |
| 658 | kStream_GrAccessPattern, |
| 659 | |
| 660 | kLast_GrAccessPattern = kStream_GrAccessPattern |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 661 | }; |
| 662 | |
Robert Phillips | c4f0a82 | 2017-06-13 08:11:36 -0400 | [diff] [blame] | 663 | // Flags shared between GrRenderTarget and GrRenderTargetProxy |
| 664 | enum class GrRenderTargetFlags { |
| 665 | kNone = 0, |
| 666 | |
| 667 | // For internal resources: |
| 668 | // this is enabled whenever MSAA is enabled and GrCaps reports mixed samples are supported |
| 669 | // For wrapped resources: |
| 670 | // this is disabled for FBO0 |
| 671 | // but, otherwise, is enabled whenever MSAA is enabled and GrCaps reports mixed samples |
| 672 | // are supported |
| 673 | kMixedSampled = 1 << 0, |
| 674 | |
| 675 | // For internal resources: |
| 676 | // this is enabled whenever GrCaps reports window rect support |
| 677 | // For wrapped resources1 |
| 678 | // this is disabled for FBO0 |
| 679 | // but, otherwise, is enabled whenever GrCaps reports window rect support |
| 680 | kWindowRectsSupport = 1 << 1 |
| 681 | }; |
| 682 | GR_MAKE_BITFIELD_CLASS_OPS(GrRenderTargetFlags) |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 683 | |
joshualitt | 7d022d6 | 2015-05-12 12:03:50 -0700 | [diff] [blame] | 684 | #ifdef SK_DEBUG |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 685 | // Takes a pointer to a GrCaps, and will suppress prints if required |
Brian Salomon | c588603 | 2017-07-19 11:48:05 -0400 | [diff] [blame] | 686 | #define GrCapsDebugf(caps, ...) \ |
| 687 | if (!(caps)->suppressPrints()) { \ |
| 688 | SkDebugf(__VA_ARGS__); \ |
joshualitt | 7d022d6 | 2015-05-12 12:03:50 -0700 | [diff] [blame] | 689 | } |
| 690 | #else |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 691 | #define GrCapsDebugf(caps, ...) |
joshualitt | 7d022d6 | 2015-05-12 12:03:50 -0700 | [diff] [blame] | 692 | #endif |
| 693 | |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 694 | /** |
| 695 | * Specifies if the holder owns the backend, OpenGL or Vulkan, object. |
| 696 | */ |
| 697 | enum class GrBackendObjectOwnership : bool { |
| 698 | /** Holder does not destroy the backend object. */ |
| 699 | kBorrowed = false, |
| 700 | /** Holder destroys the backend object. */ |
| 701 | kOwned = true |
| 702 | }; |
| 703 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 704 | template <typename T> |
| 705 | T* const* unique_ptr_address_as_pointer_address(std::unique_ptr<T> const* up) { |
| 706 | static_assert(sizeof(T*) == sizeof(std::unique_ptr<T>), "unique_ptr not expected size."); |
| 707 | return reinterpret_cast<T* const*>(up); |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 708 | } |
| 709 | |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 710 | /* |
| 711 | * Object for CPU-GPU synchronization |
| 712 | */ |
Greg Daniel | 6be3523 | 2017-03-01 17:01:09 -0500 | [diff] [blame] | 713 | typedef uint64_t GrFence; |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 714 | |
commit-bot@chromium.org | ff6ea26 | 2013-03-12 12:26:08 +0000 | [diff] [blame] | 715 | #endif |