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