diff options
author | 2015-04-29 11:18:05 -0700 | |
---|---|---|
committer | 2015-04-29 11:18:05 -0700 | |
commit | e9c0fc616d2a1632c285885b9b656b68ca8d4f24 (patch) | |
tree | 70325926996eb9e0cd63db76ea5aaec288091a84 /src/gpu/GrDrawTargetCaps.h | |
parent | 23c5f5137106221f9a00ac1e12740ee33e09767f (diff) |
Pull out shader-specific caps into GrShaderCaps and GrGLSLCaps
BUG=skia:
Review URL: https://codereview.chromium.org/1116713002
Diffstat (limited to 'src/gpu/GrDrawTargetCaps.h')
-rw-r--r-- | src/gpu/GrDrawTargetCaps.h | 109 |
1 files changed, 68 insertions, 41 deletions
diff --git a/src/gpu/GrDrawTargetCaps.h b/src/gpu/GrDrawTargetCaps.h index e1fd1cf403..310703caca 100644 --- a/src/gpu/GrDrawTargetCaps.h +++ b/src/gpu/GrDrawTargetCaps.h @@ -14,12 +14,9 @@ #include "SkRefCnt.h" #include "SkString.h" -/** - * Represents the draw target capabilities. - */ -class GrDrawTargetCaps : public SkRefCnt { +class GrShaderCaps : public SkRefCnt { public: - SK_DECLARE_INST_COUNT(GrDrawTargetCaps) + SK_DECLARE_INST_COUNT(GrShaderCaps) /** Info about shader variable precision within a given shader stage. That is, this info is relevant to a float (or vecNf) variable declared with a GrSLPrecision @@ -44,19 +41,76 @@ public: int fLogRangeLow; /** floor(log2(|max_value|)) */ int fLogRangeHigh; - /** Number of bits of precision. As defined in OpenGL (with names modified to reflect this + /** Number of bits of precision. As defined in OpenGL (with names modified to reflect this struct) : """ - If the smallest representable value greater than 1 is 1 + e, then fBits will - contain floor(log2(e)), and every value in the range [2^fLogRangeLow, - 2^fLogRangeHigh] can be represented to at least one part in 2^fBits. - """ + If the smallest representable value greater than 1 is 1 + e, then fBits will + contain floor(log2(e)), and every value in the range [2^fLogRangeLow, + 2^fLogRangeHigh] can be represented to at least one part in 2^fBits. + """ */ int fBits; }; + GrShaderCaps() { + this->reset(); + } + virtual ~GrShaderCaps() {} + GrShaderCaps(const GrShaderCaps& other) : INHERITED() { + *this = other; + } + GrShaderCaps& operator= (const GrShaderCaps&); + + virtual void reset(); + virtual SkString dump() const; + + bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; } + bool geometryShaderSupport() const { return fGeometryShaderSupport; } + bool pathRenderingSupport() const { return fPathRenderingSupport; } + bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; } + bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; } + + /** + * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a + * given shader type. If the shader type is not supported or the precision level is not + * supported in that shader type then the returned struct will report false when supported() is + * called. + */ + const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType, + GrSLPrecision precision) const { + return fFloatPrecisions[shaderType][precision]; + }; + + /** + * Is there any difference between the float shader variable precision types? If this is true + * then unless the shader type is not supported, any call to getFloatShaderPrecisionInfo() would + * report the same info for all precisions in all shader types. + */ + bool floatPrecisionVaries() const { return fShaderPrecisionVaries; } + +protected: + bool fShaderDerivativeSupport : 1; + bool fGeometryShaderSupport : 1; + bool fPathRenderingSupport : 1; + bool fDstReadInShaderSupport : 1; + bool fDualSourceBlendingSupport : 1; + + bool fShaderPrecisionVaries; + PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount]; + +private: + typedef SkRefCnt INHERITED; +}; + +/** + * Represents the draw target capabilities. + */ +class GrDrawTargetCaps : public SkRefCnt { +public: + SK_DECLARE_INST_COUNT(GrDrawTargetCaps) GrDrawTargetCaps() { + fShaderCaps.reset(NULL); this->reset(); } GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED() { @@ -67,17 +121,14 @@ public: virtual void reset(); virtual SkString dump() const; + GrShaderCaps* shaderCaps() const { return fShaderCaps; } + bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; } /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g. only for POT textures) */ bool mipMapSupport() const { return fMipMapSupport; } bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; } bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; } - bool shaderDerivativeSupport() const { return fShaderDerivativeSupport; } - bool geometryShaderSupport() const { return fGeometryShaderSupport; } - bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; } - bool pathRenderingSupport() const { return fPathRenderingSupport; } - bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; } bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; } #if GR_FORCE_GPU_TRACE_DEBUGGING bool gpuTracingSupport() const { return true; } @@ -125,34 +176,13 @@ public: return fConfigTextureSupport[config]; } - /** - * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a - * given shader type. If the shader type is not supported or the precision level is not - * supported in that shader type then the returned struct will report false when supported() is - * called. - */ - const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType, - GrSLPrecision precision) const { - return fFloatPrecisions[shaderType][precision]; - }; - - /** - * Is there any difference between the float shader variable precision types? If this is true - * then unless the shader type is not supported, any call to getFloatShaderPrecisionInfo() would - * report the same info for all precisions in all shader types. - */ - bool floatPrecisionVaries() const { return fShaderPrecisionVaries; } - protected: + SkAutoTUnref<GrShaderCaps> fShaderCaps; + bool fNPOTTextureTileSupport : 1; bool fMipMapSupport : 1; bool fTwoSidedStencilSupport : 1; bool fStencilWrapOpsSupport : 1; - bool fShaderDerivativeSupport : 1; - bool fGeometryShaderSupport : 1; - bool fDualSourceBlendingSupport : 1; - bool fPathRenderingSupport : 1; - bool fDstReadInShaderSupport : 1; bool fDiscardRenderTargetSupport : 1; bool fReuseScratchTextures : 1; bool fGpuTracingSupport : 1; @@ -172,9 +202,6 @@ protected: bool fConfigRenderSupport[kGrPixelConfigCnt][2]; bool fConfigTextureSupport[kGrPixelConfigCnt]; - bool fShaderPrecisionVaries; - PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount]; - private: typedef SkRefCnt INHERITED; }; |