bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2013 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 8 | #ifndef GrCaps_DEFINED |
| 9 | #define GrCaps_DEFINED |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 10 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 11 | #include "GrTypes.h" |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 12 | #include "GrTypesPriv.h" |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 13 | #include "GrBlend.h" |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 14 | #include "GrShaderVar.h" |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 15 | #include "SkRefCnt.h" |
| 16 | #include "SkString.h" |
| 17 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 18 | struct GrContextOptions; |
| 19 | |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 20 | class GrShaderCaps : public SkRefCnt { |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 21 | public: |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 22 | /** Info about shader variable precision within a given shader stage. That is, this info |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 23 | is relevant to a float (or vecNf) variable declared with a GrSLPrecision |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 24 | in a given GrShaderType. The info here is hoisted from the OpenGL spec. */ |
| 25 | struct PrecisionInfo { |
| 26 | PrecisionInfo() { |
| 27 | fLogRangeLow = 0; |
| 28 | fLogRangeHigh = 0; |
| 29 | fBits = 0; |
| 30 | } |
| 31 | |
| 32 | /** Is this precision level allowed in the shader stage? */ |
| 33 | bool supported() const { return 0 != fBits; } |
| 34 | |
| 35 | bool operator==(const PrecisionInfo& that) const { |
| 36 | return fLogRangeLow == that.fLogRangeLow && fLogRangeHigh == that.fLogRangeHigh && |
| 37 | fBits == that.fBits; |
| 38 | } |
| 39 | bool operator!=(const PrecisionInfo& that) const { return !(*this == that); } |
| 40 | |
| 41 | /** floor(log2(|min_value|)) */ |
| 42 | int fLogRangeLow; |
| 43 | /** floor(log2(|max_value|)) */ |
| 44 | int fLogRangeHigh; |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 45 | /** Number of bits of precision. As defined in OpenGL (with names modified to reflect this |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 46 | struct) : |
| 47 | """ |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 48 | If the smallest representable value greater than 1 is 1 + e, then fBits will |
| 49 | contain floor(log2(e)), and every value in the range [2^fLogRangeLow, |
| 50 | 2^fLogRangeHigh] can be represented to at least one part in 2^fBits. |
| 51 | """ |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 52 | */ |
| 53 | int fBits; |
| 54 | }; |
| 55 | |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 56 | GrShaderCaps(); |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 57 | |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 58 | virtual SkString dump() const; |
| 59 | |
| 60 | bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; } |
| 61 | bool geometryShaderSupport() const { return fGeometryShaderSupport; } |
| 62 | bool pathRenderingSupport() const { return fPathRenderingSupport; } |
| 63 | bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; } |
| 64 | bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; } |
cdalton | 793dc26 | 2016-02-08 10:11:47 -0800 | [diff] [blame] | 65 | bool integerSupport() const { return fIntegerSupport; } |
cdalton | f8a6ce8 | 2016-04-11 13:02:05 -0700 | [diff] [blame] | 66 | bool texelBufferSupport() const { return fTexelBufferSupport; } |
Brian Salomon | f26f7a0 | 2016-11-15 14:05:01 -0500 | [diff] [blame] | 67 | int imageLoadStoreSupport() const { return fImageLoadStoreSupport; } |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a |
| 71 | * given shader type. If the shader type is not supported or the precision level is not |
| 72 | * supported in that shader type then the returned struct will report false when supported() is |
| 73 | * called. |
| 74 | */ |
| 75 | const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType, |
robertphillips | 2eb1009 | 2015-12-11 04:59:36 -0800 | [diff] [blame] | 76 | GrSLPrecision precision) const { |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 77 | return fFloatPrecisions[shaderType][precision]; |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 78 | } |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 79 | |
| 80 | /** |
| 81 | * Is there any difference between the float shader variable precision types? If this is true |
| 82 | * then unless the shader type is not supported, any call to getFloatShaderPrecisionInfo() would |
| 83 | * report the same info for all precisions in all shader types. |
| 84 | */ |
| 85 | bool floatPrecisionVaries() const { return fShaderPrecisionVaries; } |
| 86 | |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 87 | /** |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 88 | * PLS storage size in bytes (0 when not supported). The PLS spec defines a minimum size of 16 |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 89 | * bytes whenever PLS is supported. |
| 90 | */ |
| 91 | int pixelLocalStorageSize() const { return fPixelLocalStorageSize; } |
| 92 | |
| 93 | /** |
| 94 | * True if this context supports the necessary extensions and features to enable the PLS path |
| 95 | * renderer. |
| 96 | */ |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 97 | bool plsPathRenderingSupport() const { |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 98 | #if GR_ENABLE_PLS_PATH_RENDERING |
| 99 | return fPLSPathRenderingSupport; |
| 100 | #else |
| 101 | return false; |
| 102 | #endif |
| 103 | } |
| 104 | |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 105 | protected: |
cdalton | 4cd6713 | 2015-06-10 19:23:46 -0700 | [diff] [blame] | 106 | /** Subclasses must call this after initialization in order to apply caps overrides requested by |
| 107 | the client. Note that overrides will only reduce the caps never expand them. */ |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 108 | void applyOptionsOverrides(const GrContextOptions& options); |
| 109 | |
Brian Salomon | f26f7a0 | 2016-11-15 14:05:01 -0500 | [diff] [blame] | 110 | bool fShaderDerivativeSupport : 1; |
| 111 | bool fGeometryShaderSupport : 1; |
| 112 | bool fPathRenderingSupport : 1; |
| 113 | bool fDstReadInShaderSupport : 1; |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 114 | bool fDualSourceBlendingSupport : 1; |
Brian Salomon | f26f7a0 | 2016-11-15 14:05:01 -0500 | [diff] [blame] | 115 | bool fIntegerSupport : 1; |
| 116 | bool fTexelBufferSupport : 1; |
| 117 | bool fImageLoadStoreSupport : 1; |
| 118 | bool fPLSPathRenderingSupport : 1; |
| 119 | bool fShaderPrecisionVaries : 1; |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 120 | PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount]; |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 121 | int fPixelLocalStorageSize; |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 122 | |
| 123 | private: |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 124 | virtual void onApplyOptionsOverrides(const GrContextOptions&) {} |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 125 | typedef SkRefCnt INHERITED; |
| 126 | }; |
| 127 | |
| 128 | /** |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 129 | * Represents the capabilities of a GrContext. |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 130 | */ |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 131 | class GrCaps : public SkRefCnt { |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 132 | public: |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 133 | GrCaps(const GrContextOptions&); |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 134 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 135 | virtual SkString dump() const; |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 136 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 137 | GrShaderCaps* shaderCaps() const { return fShaderCaps.get(); } |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 138 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 139 | bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; } |
commit-bot@chromium.org | 4744231 | 2013-12-19 16:18:01 +0000 | [diff] [blame] | 140 | /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g. |
| 141 | only for POT textures) */ |
| 142 | bool mipMapSupport() const { return fMipMapSupport; } |
brianosman | 64d094d | 2016-03-25 06:01:59 -0700 | [diff] [blame] | 143 | |
| 144 | /** |
| 145 | * Skia convention is that a device only has sRGB support if it supports sRGB formats for both |
| 146 | * textures and framebuffers. In addition: |
| 147 | * Decoding to linear of an sRGB texture can be disabled. |
brianosman | 64d094d | 2016-03-25 06:01:59 -0700 | [diff] [blame] | 148 | */ |
brianosman | a635936 | 2016-03-21 06:55:37 -0700 | [diff] [blame] | 149 | bool srgbSupport() const { return fSRGBSupport; } |
brianosman | 35b784d | 2016-05-05 11:52:53 -0700 | [diff] [blame] | 150 | /** |
| 151 | * Is there support for enabling/disabling sRGB writes for sRGB-capable color buffers? |
| 152 | */ |
| 153 | bool srgbWriteControl() const { return fSRGBWriteControl; } |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 154 | bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; } |
| 155 | bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; } |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 156 | bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; } |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 157 | bool gpuTracingSupport() const { return fGpuTracingSupport; } |
krajcevski | 78697816 | 2014-07-30 11:25:44 -0700 | [diff] [blame] | 158 | bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; } |
bsalomon | d08ea5f | 2015-02-20 06:58:13 -0800 | [diff] [blame] | 159 | bool oversizedStencilSupport() const { return fOversizedStencilSupport; } |
cdalton | fd4167d | 2015-04-21 11:45:56 -0700 | [diff] [blame] | 160 | bool textureBarrierSupport() const { return fTextureBarrierSupport; } |
cdalton | eb79eea | 2016-02-26 10:39:34 -0800 | [diff] [blame] | 161 | bool sampleLocationsSupport() const { return fSampleLocationsSupport; } |
csmartdalton | 2b5f2cb | 2016-06-10 14:06:32 -0700 | [diff] [blame] | 162 | bool multisampleDisableSupport() const { return fMultisampleDisableSupport; } |
egdaniel | eed519e | 2016-01-15 11:36:18 -0800 | [diff] [blame] | 163 | bool usesMixedSamples() const { return fUsesMixedSamples; } |
csmartdalton | 485a120 | 2016-07-13 10:16:32 -0700 | [diff] [blame] | 164 | bool preferClientSideDynamicBuffers() const { return fPreferClientSideDynamicBuffers; } |
robertphillips@google.com | 2d2e5c4 | 2013-10-30 21:30:43 +0000 | [diff] [blame] | 165 | |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 166 | bool useDrawInsteadOfClear() const { return fUseDrawInsteadOfClear; } |
joshualitt | 83bc229 | 2015-06-18 14:18:02 -0700 | [diff] [blame] | 167 | bool useDrawInsteadOfPartialRenderTargetWrite() const { |
| 168 | return fUseDrawInsteadOfPartialRenderTargetWrite; |
| 169 | } |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 170 | |
bsalomon | babafcc | 2016-02-16 11:36:47 -0800 | [diff] [blame] | 171 | bool useDrawInsteadOfAllRenderTargetWrites() const { |
| 172 | return fUseDrawInsteadOfAllRenderTargetWrites; |
| 173 | } |
| 174 | |
robertphillips | 6392668 | 2015-08-20 09:39:02 -0700 | [diff] [blame] | 175 | bool preferVRAMUseOverFlushes() const { return fPreferVRAMUseOverFlushes; } |
| 176 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 177 | /** |
csmartdalton | e0d3629 | 2016-07-29 08:14:20 -0700 | [diff] [blame] | 178 | * Indicates the level of support for gr_instanced::* functionality. A higher level includes |
| 179 | * all functionality from the levels below it. |
| 180 | */ |
| 181 | enum class InstancedSupport { |
| 182 | kNone, |
| 183 | kBasic, |
| 184 | kMultisampled, |
| 185 | kMixedSampled |
| 186 | }; |
| 187 | |
| 188 | InstancedSupport instancedSupport() const { return fInstancedSupport; } |
| 189 | |
| 190 | bool avoidInstancedDrawsToFPTargets() const { return fAvoidInstancedDrawsToFPTargets; } |
| 191 | |
| 192 | /** |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 193 | * Indicates the capabilities of the fixed function blend unit. |
| 194 | */ |
| 195 | enum BlendEquationSupport { |
| 196 | kBasic_BlendEquationSupport, //<! Support to select the operator that |
| 197 | // combines src and dst terms. |
| 198 | kAdvanced_BlendEquationSupport, //<! Additional fixed function support for specific |
| 199 | // SVG/PDF blend modes. Requires blend barriers. |
| 200 | kAdvancedCoherent_BlendEquationSupport, //<! Advanced blend equation support that does not |
| 201 | // require blend barriers, and permits overlap. |
| 202 | |
| 203 | kLast_BlendEquationSupport = kAdvancedCoherent_BlendEquationSupport |
| 204 | }; |
| 205 | |
| 206 | BlendEquationSupport blendEquationSupport() const { return fBlendEquationSupport; } |
| 207 | |
| 208 | bool advancedBlendEquationSupport() const { |
| 209 | return fBlendEquationSupport >= kAdvanced_BlendEquationSupport; |
| 210 | } |
| 211 | |
| 212 | bool advancedCoherentBlendEquationSupport() const { |
| 213 | return kAdvancedCoherent_BlendEquationSupport == fBlendEquationSupport; |
| 214 | } |
| 215 | |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 216 | bool canUseAdvancedBlendEquation(GrBlendEquation equation) const { |
| 217 | SkASSERT(GrBlendEquationIsAdvanced(equation)); |
| 218 | return SkToBool(fAdvBlendEqBlacklist & (1 << equation)); |
| 219 | } |
| 220 | |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 221 | /** |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 222 | * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and |
| 223 | * textures allows partial mappings or full mappings. |
| 224 | */ |
| 225 | enum MapFlags { |
| 226 | kNone_MapFlags = 0x0, //<! Cannot map the resource. |
| 227 | |
| 228 | kCanMap_MapFlag = 0x1, //<! The resource can be mapped. Must be set for any of |
| 229 | // the other flags to have meaning.k |
| 230 | kSubset_MapFlag = 0x2, //<! The resource can be partially mapped. |
| 231 | }; |
| 232 | |
| 233 | uint32_t mapBufferFlags() const { return fMapBufferFlags; } |
| 234 | |
robertphillips@google.com | 2d2e5c4 | 2013-10-30 21:30:43 +0000 | [diff] [blame] | 235 | // Scratch textures not being reused means that those scratch textures |
skia.committer@gmail.com | 7ed98df | 2013-10-31 07:01:53 +0000 | [diff] [blame] | 236 | // that we upload to (i.e., don't have a render target) will not be |
robertphillips@google.com | 2d2e5c4 | 2013-10-30 21:30:43 +0000 | [diff] [blame] | 237 | // recycled in the texture cache. This is to prevent ghosting by drivers |
| 238 | // (in particular for deferred architectures). |
commit-bot@chromium.org | b835652 | 2013-07-18 22:26:39 +0000 | [diff] [blame] | 239 | bool reuseScratchTextures() const { return fReuseScratchTextures; } |
robertphillips | 1b8e1b5 | 2015-06-24 06:54:10 -0700 | [diff] [blame] | 240 | bool reuseScratchBuffers() const { return fReuseScratchBuffers; } |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 241 | |
bsalomon | 7dbd45d | 2016-03-23 10:40:53 -0700 | [diff] [blame] | 242 | /// maximum number of attribute values per vertex |
| 243 | int maxVertexAttributes() const { return fMaxVertexAttributes; } |
| 244 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 245 | int maxRenderTargetSize() const { return fMaxRenderTargetSize; } |
| 246 | int maxTextureSize() const { return fMaxTextureSize; } |
bsalomon | 8c07b7a | 2015-11-02 11:36:52 -0800 | [diff] [blame] | 247 | /** This is the maximum tile size to use by GPU devices for rendering sw-backed images/bitmaps. |
| 248 | It is usually the max texture size, unless we're overriding it for testing. */ |
| 249 | int maxTileSize() const { SkASSERT(fMaxTileSize <= fMaxTextureSize); return fMaxTileSize; } |
bsalomon | c59a1df | 2015-06-01 07:13:42 -0700 | [diff] [blame] | 250 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 251 | // Will be 0 if MSAA is not supported |
egdaniel | eed519e | 2016-01-15 11:36:18 -0800 | [diff] [blame] | 252 | int maxColorSampleCount() const { return fMaxColorSampleCount; } |
| 253 | // Will be 0 if MSAA is not supported |
| 254 | int maxStencilSampleCount() const { return fMaxStencilSampleCount; } |
cdalton | af8bc7d | 2016-02-05 09:35:20 -0800 | [diff] [blame] | 255 | // Will be 0 if raster multisample is not supported. Raster multisample is a special HW mode |
| 256 | // where the rasterizer runs with more samples than are in the target framebuffer. |
| 257 | int maxRasterSamples() const { return fMaxRasterSamples; } |
egdaniel | eed519e | 2016-01-15 11:36:18 -0800 | [diff] [blame] | 258 | // We require the sample count to be less than maxColorSampleCount and maxStencilSampleCount. |
| 259 | // If we are using mixed samples, we only care about stencil. |
| 260 | int maxSampleCount() const { |
| 261 | if (this->usesMixedSamples()) { |
| 262 | return this->maxStencilSampleCount(); |
| 263 | } else { |
| 264 | return SkTMin(this->maxColorSampleCount(), this->maxStencilSampleCount()); |
| 265 | } |
| 266 | } |
| 267 | |
csmartdalton | 9bc1187 | 2016-08-09 12:42:47 -0700 | [diff] [blame] | 268 | int maxWindowRectangles() const { return fMaxWindowRectangles; } |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 269 | |
bsalomon | 41e4384e | 2016-01-08 09:12:44 -0800 | [diff] [blame] | 270 | virtual bool isConfigTexturable(GrPixelConfig config) const = 0; |
| 271 | virtual bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const = 0; |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 272 | virtual bool canConfigBeImageStorage(GrPixelConfig config) const = 0; |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 273 | |
robertphillips | caef345 | 2015-11-11 13:18:11 -0800 | [diff] [blame] | 274 | bool suppressPrints() const { return fSuppressPrints; } |
| 275 | |
| 276 | bool immediateFlush() const { return fImmediateFlush; } |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 277 | |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 278 | size_t bufferMapThreshold() const { |
| 279 | SkASSERT(fBufferMapThreshold >= 0); |
| 280 | return fBufferMapThreshold; |
joshualitt | 7224c86 | 2015-05-29 06:46:47 -0700 | [diff] [blame] | 281 | } |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 282 | |
egdaniel | 51c8d40 | 2015-08-06 10:54:13 -0700 | [diff] [blame] | 283 | bool fullClearIsFree() const { return fFullClearIsFree; } |
| 284 | |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 285 | /** True in environments that will issue errors if memory uploaded to buffers |
bsalomon | 7dea7b7 | 2015-08-19 08:26:51 -0700 | [diff] [blame] | 286 | is not initialized (even if not read by draw calls). */ |
| 287 | bool mustClearUploadedBufferData() const { return fMustClearUploadedBufferData; } |
| 288 | |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 289 | bool sampleShadingSupport() const { return fSampleShadingSupport; } |
| 290 | |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 291 | bool fenceSyncSupport() const { return fFenceSyncSupport; } |
| 292 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 293 | protected: |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 294 | /** Subclasses must call this at the end of their constructors in order to apply caps |
| 295 | overrides requested by the client. Note that overrides will only reduce the caps never |
| 296 | expand them. */ |
| 297 | void applyOptionsOverrides(const GrContextOptions& options); |
| 298 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 299 | sk_sp<GrShaderCaps> fShaderCaps; |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 300 | |
joshualitt | 83bc229 | 2015-06-18 14:18:02 -0700 | [diff] [blame] | 301 | bool fNPOTTextureTileSupport : 1; |
| 302 | bool fMipMapSupport : 1; |
brianosman | a635936 | 2016-03-21 06:55:37 -0700 | [diff] [blame] | 303 | bool fSRGBSupport : 1; |
brianosman | 35b784d | 2016-05-05 11:52:53 -0700 | [diff] [blame] | 304 | bool fSRGBWriteControl : 1; |
joshualitt | 83bc229 | 2015-06-18 14:18:02 -0700 | [diff] [blame] | 305 | bool fTwoSidedStencilSupport : 1; |
| 306 | bool fStencilWrapOpsSupport : 1; |
| 307 | bool fDiscardRenderTargetSupport : 1; |
| 308 | bool fReuseScratchTextures : 1; |
robertphillips | 1b8e1b5 | 2015-06-24 06:54:10 -0700 | [diff] [blame] | 309 | bool fReuseScratchBuffers : 1; |
joshualitt | 83bc229 | 2015-06-18 14:18:02 -0700 | [diff] [blame] | 310 | bool fGpuTracingSupport : 1; |
| 311 | bool fCompressedTexSubImageSupport : 1; |
| 312 | bool fOversizedStencilSupport : 1; |
| 313 | bool fTextureBarrierSupport : 1; |
cdalton | eb79eea | 2016-02-26 10:39:34 -0800 | [diff] [blame] | 314 | bool fSampleLocationsSupport : 1; |
csmartdalton | 2b5f2cb | 2016-06-10 14:06:32 -0700 | [diff] [blame] | 315 | bool fMultisampleDisableSupport : 1; |
egdaniel | eed519e | 2016-01-15 11:36:18 -0800 | [diff] [blame] | 316 | bool fUsesMixedSamples : 1; |
csmartdalton | 485a120 | 2016-07-13 10:16:32 -0700 | [diff] [blame] | 317 | bool fPreferClientSideDynamicBuffers : 1; |
egdaniel | 51c8d40 | 2015-08-06 10:54:13 -0700 | [diff] [blame] | 318 | bool fFullClearIsFree : 1; |
bsalomon | 7dea7b7 | 2015-08-19 08:26:51 -0700 | [diff] [blame] | 319 | bool fMustClearUploadedBufferData : 1; |
robertphillips | 1b8e1b5 | 2015-06-24 06:54:10 -0700 | [diff] [blame] | 320 | |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 321 | // Driver workaround |
joshualitt | 83bc229 | 2015-06-18 14:18:02 -0700 | [diff] [blame] | 322 | bool fUseDrawInsteadOfClear : 1; |
| 323 | bool fUseDrawInsteadOfPartialRenderTargetWrite : 1; |
bsalomon | babafcc | 2016-02-16 11:36:47 -0800 | [diff] [blame] | 324 | bool fUseDrawInsteadOfAllRenderTargetWrites : 1; |
csmartdalton | e0d3629 | 2016-07-29 08:14:20 -0700 | [diff] [blame] | 325 | bool fAvoidInstancedDrawsToFPTargets : 1; |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 326 | |
robertphillips | 6392668 | 2015-08-20 09:39:02 -0700 | [diff] [blame] | 327 | // ANGLE workaround |
| 328 | bool fPreferVRAMUseOverFlushes : 1; |
| 329 | |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 330 | bool fSampleShadingSupport : 1; |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 331 | // TODO: this may need to be an enum to support different fence types |
| 332 | bool fFenceSyncSupport : 1; |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 333 | |
csmartdalton | e0d3629 | 2016-07-29 08:14:20 -0700 | [diff] [blame] | 334 | InstancedSupport fInstancedSupport; |
| 335 | |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 336 | BlendEquationSupport fBlendEquationSupport; |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 337 | uint32_t fAdvBlendEqBlacklist; |
| 338 | GR_STATIC_ASSERT(kLast_GrBlendEquation < 32); |
| 339 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 340 | uint32_t fMapBufferFlags; |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 341 | int fBufferMapThreshold; |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 342 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 343 | int fMaxRenderTargetSize; |
bsalomon | 7dbd45d | 2016-03-23 10:40:53 -0700 | [diff] [blame] | 344 | int fMaxVertexAttributes; |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 345 | int fMaxTextureSize; |
bsalomon | 8c07b7a | 2015-11-02 11:36:52 -0800 | [diff] [blame] | 346 | int fMaxTileSize; |
egdaniel | eed519e | 2016-01-15 11:36:18 -0800 | [diff] [blame] | 347 | int fMaxColorSampleCount; |
| 348 | int fMaxStencilSampleCount; |
cdalton | af8bc7d | 2016-02-05 09:35:20 -0800 | [diff] [blame] | 349 | int fMaxRasterSamples; |
csmartdalton | 9bc1187 | 2016-08-09 12:42:47 -0700 | [diff] [blame] | 350 | int fMaxWindowRectangles; |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 351 | |
egdaniel | bc127a3 | 2014-09-19 12:07:43 -0700 | [diff] [blame] | 352 | private: |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 353 | virtual void onApplyOptionsOverrides(const GrContextOptions&) {} |
egdaniel | b7e7d57 | 2015-11-04 04:23:53 -0800 | [diff] [blame] | 354 | |
robertphillips | caef345 | 2015-11-11 13:18:11 -0800 | [diff] [blame] | 355 | bool fSuppressPrints : 1; |
| 356 | bool fImmediateFlush: 1; |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 357 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 358 | typedef SkRefCnt INHERITED; |
| 359 | }; |
| 360 | |
| 361 | #endif |