| OLD | NEW |
| (Empty) |
| 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 */ | |
| 8 #ifndef GrCaps_DEFINED | |
| 9 #define GrCaps_DEFINED | |
| 10 | |
| 11 #include "GrTypes.h" | |
| 12 #include "GrTypesPriv.h" | |
| 13 #include "GrShaderVar.h" | |
| 14 #include "SkRefCnt.h" | |
| 15 #include "SkString.h" | |
| 16 | |
| 17 class GrShaderCaps : public SkRefCnt { | |
| 18 public: | |
| 19 SK_DECLARE_INST_COUNT(GrShaderCaps) | |
| 20 | |
| 21 /** Info about shader variable precision within a given shader stage. That i
s, this info | |
| 22 is relevant to a float (or vecNf) variable declared with a GrSLPrecision | |
| 23 in a given GrShaderType. The info here is hoisted from the OpenGL spec.
*/ | |
| 24 struct PrecisionInfo { | |
| 25 PrecisionInfo() { | |
| 26 fLogRangeLow = 0; | |
| 27 fLogRangeHigh = 0; | |
| 28 fBits = 0; | |
| 29 } | |
| 30 | |
| 31 /** Is this precision level allowed in the shader stage? */ | |
| 32 bool supported() const { return 0 != fBits; } | |
| 33 | |
| 34 bool operator==(const PrecisionInfo& that) const { | |
| 35 return fLogRangeLow == that.fLogRangeLow && fLogRangeHigh == that.fL
ogRangeHigh && | |
| 36 fBits == that.fBits; | |
| 37 } | |
| 38 bool operator!=(const PrecisionInfo& that) const { return !(*this == tha
t); } | |
| 39 | |
| 40 /** floor(log2(|min_value|)) */ | |
| 41 int fLogRangeLow; | |
| 42 /** floor(log2(|max_value|)) */ | |
| 43 int fLogRangeHigh; | |
| 44 /** Number of bits of precision. As defined in OpenGL (with names modifi
ed to reflect this | |
| 45 struct) : | |
| 46 """ | |
| 47 If the smallest representable value greater than 1 is 1 + e, then fB
its will | |
| 48 contain floor(log2(e)), and every value in the range [2^fLogRangeLow
, | |
| 49 2^fLogRangeHigh] can be represented to at least one part in 2^fBits. | |
| 50 """ | |
| 51 */ | |
| 52 int fBits; | |
| 53 }; | |
| 54 | |
| 55 GrShaderCaps() { | |
| 56 this->reset(); | |
| 57 } | |
| 58 virtual ~GrShaderCaps() {} | |
| 59 GrShaderCaps(const GrShaderCaps& other) : INHERITED() { | |
| 60 *this = other; | |
| 61 } | |
| 62 GrShaderCaps& operator= (const GrShaderCaps&); | |
| 63 | |
| 64 virtual void reset(); | |
| 65 virtual SkString dump() const; | |
| 66 | |
| 67 bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; } | |
| 68 bool geometryShaderSupport() const { return fGeometryShaderSupport; } | |
| 69 bool pathRenderingSupport() const { return fPathRenderingSupport; } | |
| 70 bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; } | |
| 71 bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport;
} | |
| 72 bool mixedSamplesSupport() const { return fMixedSamplesSupport; } | |
| 73 | |
| 74 /** | |
| 75 * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSL
Type, etc in a | |
| 76 * given shader type. If the shader type is not supported or the precision le
vel is not | |
| 77 * supported in that shader type then the returned struct will report false w
hen supported() is | |
| 78 * called. | |
| 79 */ | |
| 80 const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType, | |
| 81 GrSLPrecision precision) const { | |
| 82 return fFloatPrecisions[shaderType][precision]; | |
| 83 }; | |
| 84 | |
| 85 /** | |
| 86 * Is there any difference between the float shader variable precision types?
If this is true | |
| 87 * then unless the shader type is not supported, any call to getFloatShaderPr
ecisionInfo() would | |
| 88 * report the same info for all precisions in all shader types. | |
| 89 */ | |
| 90 bool floatPrecisionVaries() const { return fShaderPrecisionVaries; } | |
| 91 | |
| 92 protected: | |
| 93 bool fShaderDerivativeSupport : 1; | |
| 94 bool fGeometryShaderSupport : 1; | |
| 95 bool fPathRenderingSupport : 1; | |
| 96 bool fDstReadInShaderSupport : 1; | |
| 97 bool fDualSourceBlendingSupport : 1; | |
| 98 bool fMixedSamplesSupport : 1; | |
| 99 | |
| 100 bool fShaderPrecisionVaries; | |
| 101 PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount]; | |
| 102 | |
| 103 private: | |
| 104 typedef SkRefCnt INHERITED; | |
| 105 }; | |
| 106 | |
| 107 /** | |
| 108 * Represents the capabilities of a GrContext. | |
| 109 */ | |
| 110 class GrCaps : public SkRefCnt { | |
| 111 public: | |
| 112 SK_DECLARE_INST_COUNT(GrCaps) | |
| 113 | |
| 114 GrCaps() { | |
| 115 fShaderCaps.reset(NULL); | |
| 116 this->reset(); | |
| 117 } | |
| 118 GrCaps(const GrCaps& other) : INHERITED() { | |
| 119 *this = other; | |
| 120 } | |
| 121 virtual ~GrCaps() {} | |
| 122 GrCaps& operator= (const GrCaps&); | |
| 123 | |
| 124 virtual void reset(); | |
| 125 virtual SkString dump() const; | |
| 126 | |
| 127 GrShaderCaps* shaderCaps() const { return fShaderCaps; } | |
| 128 | |
| 129 bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; } | |
| 130 /** To avoid as-yet-unnecessary complexity we don't allow any partial suppor
t of MIP Maps (e.g. | |
| 131 only for POT textures) */ | |
| 132 bool mipMapSupport() const { return fMipMapSupport; } | |
| 133 bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; } | |
| 134 bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; } | |
| 135 bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport
; } | |
| 136 #if GR_FORCE_GPU_TRACE_DEBUGGING | |
| 137 bool gpuTracingSupport() const { return true; } | |
| 138 #else | |
| 139 bool gpuTracingSupport() const { return fGpuTracingSupport; } | |
| 140 #endif | |
| 141 bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSup
port; } | |
| 142 bool oversizedStencilSupport() const { return fOversizedStencilSupport; } | |
| 143 bool textureBarrierSupport() const { return fTextureBarrierSupport; } | |
| 144 | |
| 145 bool useDrawInsteadOfClear() const { return fUseDrawInsteadOfClear; } | |
| 146 | |
| 147 /** | |
| 148 * Indicates the capabilities of the fixed function blend unit. | |
| 149 */ | |
| 150 enum BlendEquationSupport { | |
| 151 kBasic_BlendEquationSupport, //<! Support to select the oper
ator that | |
| 152 // combines src and dst terms
. | |
| 153 kAdvanced_BlendEquationSupport, //<! Additional fixed function
support for specific | |
| 154 // SVG/PDF blend modes. Requi
res blend barriers. | |
| 155 kAdvancedCoherent_BlendEquationSupport, //<! Advanced blend equation su
pport that does not | |
| 156 // require blend barriers, an
d permits overlap. | |
| 157 | |
| 158 kLast_BlendEquationSupport = kAdvancedCoherent_BlendEquationSupport | |
| 159 }; | |
| 160 | |
| 161 BlendEquationSupport blendEquationSupport() const { return fBlendEquationSup
port; } | |
| 162 | |
| 163 bool advancedBlendEquationSupport() const { | |
| 164 return fBlendEquationSupport >= kAdvanced_BlendEquationSupport; | |
| 165 } | |
| 166 | |
| 167 bool advancedCoherentBlendEquationSupport() const { | |
| 168 return kAdvancedCoherent_BlendEquationSupport == fBlendEquationSupport; | |
| 169 } | |
| 170 | |
| 171 /** | |
| 172 * Indicates whether GPU->CPU memory mapping for GPU resources such as verte
x buffers and | |
| 173 * textures allows partial mappings or full mappings. | |
| 174 */ | |
| 175 enum MapFlags { | |
| 176 kNone_MapFlags = 0x0, //<! Cannot map the resource. | |
| 177 | |
| 178 kCanMap_MapFlag = 0x1, //<! The resource can be mapped. Must be s
et for any of | |
| 179 // the other flags to have meaning.k | |
| 180 kSubset_MapFlag = 0x2, //<! The resource can be partially mapped. | |
| 181 }; | |
| 182 | |
| 183 uint32_t mapBufferFlags() const { return fMapBufferFlags; } | |
| 184 | |
| 185 // Scratch textures not being reused means that those scratch textures | |
| 186 // that we upload to (i.e., don't have a render target) will not be | |
| 187 // recycled in the texture cache. This is to prevent ghosting by drivers | |
| 188 // (in particular for deferred architectures). | |
| 189 bool reuseScratchTextures() const { return fReuseScratchTextures; } | |
| 190 | |
| 191 int maxRenderTargetSize() const { return fMaxRenderTargetSize; } | |
| 192 int maxTextureSize() const { return fMaxTextureSize; } | |
| 193 // Will be 0 if MSAA is not supported | |
| 194 int maxSampleCount() const { return fMaxSampleCount; } | |
| 195 | |
| 196 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const { | |
| 197 SkASSERT(kGrPixelConfigCnt > config); | |
| 198 return fConfigRenderSupport[config][withMSAA]; | |
| 199 } | |
| 200 | |
| 201 bool isConfigTexturable(GrPixelConfig config) const { | |
| 202 SkASSERT(kGrPixelConfigCnt > config); | |
| 203 return fConfigTextureSupport[config]; | |
| 204 } | |
| 205 | |
| 206 protected: | |
| 207 SkAutoTUnref<GrShaderCaps> fShaderCaps; | |
| 208 | |
| 209 bool fNPOTTextureTileSupport : 1; | |
| 210 bool fMipMapSupport : 1; | |
| 211 bool fTwoSidedStencilSupport : 1; | |
| 212 bool fStencilWrapOpsSupport : 1; | |
| 213 bool fDiscardRenderTargetSupport : 1; | |
| 214 bool fReuseScratchTextures : 1; | |
| 215 bool fGpuTracingSupport : 1; | |
| 216 bool fCompressedTexSubImageSupport : 1; | |
| 217 bool fOversizedStencilSupport : 1; | |
| 218 bool fTextureBarrierSupport : 1; | |
| 219 // Driver workaround | |
| 220 bool fUseDrawInsteadOfClear : 1; | |
| 221 | |
| 222 BlendEquationSupport fBlendEquationSupport; | |
| 223 uint32_t fMapBufferFlags; | |
| 224 | |
| 225 int fMaxRenderTargetSize; | |
| 226 int fMaxTextureSize; | |
| 227 int fMaxSampleCount; | |
| 228 | |
| 229 // The first entry for each config is without msaa and the second is with. | |
| 230 bool fConfigRenderSupport[kGrPixelConfigCnt][2]; | |
| 231 bool fConfigTextureSupport[kGrPixelConfigCnt]; | |
| 232 | |
| 233 private: | |
| 234 typedef SkRefCnt INHERITED; | |
| 235 }; | |
| 236 | |
| 237 #endif | |
| OLD | NEW |