diff options
author | Brian Osman <brianosman@google.com> | 2017-11-16 14:02:11 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-16 14:02:23 +0000 |
commit | 24f9c19172e149602551cd6716b3cc264c1d40ef (patch) | |
tree | 48f622c34b80fa9d6595f1050b313033ec8e4104 /include | |
parent | 554c1f0508a95b5411036a95d1bb62c0d5fdeae8 (diff) |
Revert "Fix precision caps and rrect/ellipse effect precisions"
This reverts commit e42180022720f2fcfd3c634cad855506a7940591.
Reason for revert: Also may be responsible for layout test failures? Playing it safe.
Original change's description:
> Fix precision caps and rrect/ellipse effect precisions
>
> Replaces all the complex precision caps with a single flag that says
> whether "float" == fp32. Updates the ellipse and rrect effects to
> use float coords, and use the scale workaround when float != fp32.
>
> Bug: skia:7190
> Change-Id: Ieccff9f38acd05e5cec78fe90d01a5da901a9307
> Reviewed-on: https://skia-review.googlesource.com/70961
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com,ethannicholas@google.com
Change-Id: Idca2f0390e7a0eb85010255183f2f27332b8d26d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7190
Reviewed-on: https://skia-review.googlesource.com/72540
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrShaderCaps.h | 71 | ||||
-rw-r--r-- | include/private/GrTypesPriv.h | 27 |
2 files changed, 65 insertions, 33 deletions
diff --git a/include/gpu/GrShaderCaps.h b/include/gpu/GrShaderCaps.h index 4c847ac8b0..5ecd58ca59 100644 --- a/include/gpu/GrShaderCaps.h +++ b/include/gpu/GrShaderCaps.h @@ -20,6 +20,40 @@ class SkJSONWriter; class GrShaderCaps : public SkRefCnt { public: + /** 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 + in a given GrShaderType. The info here is hoisted from the OpenGL spec. */ + struct PrecisionInfo { + PrecisionInfo() { + fLogRangeLow = 0; + fLogRangeHigh = 0; + fBits = 0; + } + + /** Is this precision level allowed in the shader stage? */ + bool supported() const { return 0 != fBits; } + + bool operator==(const PrecisionInfo& that) const { + return fLogRangeLow == that.fLogRangeLow && fLogRangeHigh == that.fLogRangeHigh && + fBits == that.fBits; + } + bool operator!=(const PrecisionInfo& that) const { return !(*this == that); } + + /** floor(log2(|min_value|)) */ + int fLogRangeLow; + /** floor(log2(|max_value|)) */ + int fLogRangeHigh; + /** 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. + """ + */ + int fBits; + }; + /** * Indicates how GLSL must interact with advanced blend equations. The KHR extension requires * special layout qualifiers in the fragment shader. @@ -48,6 +82,24 @@ public: int imageLoadStoreSupport() const { return fImageLoadStoreSupport; } /** + * Get the precision info for a variable of type kFloat_GrSLType, kFloat2_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; } + + /** * Some helper functions for encapsulating various extensions to read FB Buffer on openglES * * TODO(joshualitt) On desktop opengl 4.2+ we can achieve something similar to this effect @@ -84,10 +136,6 @@ public: bool vertexIDSupport() const { return fVertexIDSupport; } - bool floatIs32Bits() const { return fFloatIs32Bits; } - - bool halfIs32Bits() const { return fHalfIs32Bits; } - AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; } bool mustEnableAdvBlendEqs() const { @@ -212,9 +260,17 @@ public: return fConfigOutputSwizzle[config]; } + /** Precision qualifier that should be used with a sampler, given its config and visibility. */ + GrSLPrecision samplerPrecision(GrPixelConfig config, GrShaderFlags visibility) const { + return static_cast<GrSLPrecision>(fSamplerPrecisions[visibility][config]); + } + GrGLSLGeneration generation() const { return fGLSLGeneration; } private: + /** GrCaps subclasses must call this after filling in the shader precision table. */ + void initSamplerPrecisionTable(); + void applyOptionsOverrides(const GrContextOptions& options); GrGLSLGeneration fGLSLGeneration; @@ -228,6 +284,7 @@ private: bool fIntegerSupport : 1; bool fTexelBufferSupport : 1; bool fImageLoadStoreSupport : 1; + bool fShaderPrecisionVaries : 1; bool fDropsTileOnZeroDivide : 1; bool fFBFetchSupport : 1; bool fFBFetchNeedsCustomOutput : 1; @@ -243,8 +300,6 @@ private: bool fExternalTextureSupport : 1; bool fTexelFetchSupport : 1; bool fVertexIDSupport : 1; - bool fFloatIs32Bits : 1; - bool fHalfIs32Bits : 1; bool fDisableImageMultitexturing : 1; // Used for specific driver bug work arounds @@ -256,6 +311,8 @@ private: bool fMustObfuscateUniformColor : 1; bool fMustGuardDivisionEvenAfterExplicitZeroCheck : 1; + PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount]; + const char* fVersionDeclString; const char* fShaderDerivativeExtensionString; @@ -282,6 +339,8 @@ private: GrSwizzle fConfigTextureSwizzle[kGrPixelConfigCnt]; GrSwizzle fConfigOutputSwizzle[kGrPixelConfigCnt]; + uint8_t fSamplerPrecisions[(1 << kGrShaderTypeCount)][kGrPixelConfigCnt]; + friend class GrGLCaps; // For initialization. friend class GrMockCaps; friend class GrMtlCaps; diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h index cd1c0d4483..a90944064f 100644 --- a/include/private/GrTypesPriv.h +++ b/include/private/GrTypesPriv.h @@ -909,33 +909,6 @@ static inline bool GrPixelConfigIsUnorm(GrPixelConfig config) { return false; } -/** - * Precision qualifier that should be used with a sampler. - */ -static inline GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) { - switch (config) { - case kUnknown_GrPixelConfig: - case kAlpha_8_GrPixelConfig: - case kGray_8_GrPixelConfig: - case kRGB_565_GrPixelConfig: - case kRGBA_4444_GrPixelConfig: - case kRGBA_8888_GrPixelConfig: - case kBGRA_8888_GrPixelConfig: - case kSRGBA_8888_GrPixelConfig: - case kSBGRA_8888_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: - return kLow_GrSLPrecision; - case kRGBA_float_GrPixelConfig: - case kRG_float_GrPixelConfig: - return kHigh_GrSLPrecision; - case kAlpha_half_GrPixelConfig: - case kRGBA_half_GrPixelConfig: - return kMedium_GrSLPrecision; - } - SK_ABORT("Unexpected type"); - return kHigh_GrSLPrecision; -} - static inline GrPixelConfigIsClamped GrGetPixelConfigIsClamped(GrPixelConfig config) { return GrPixelConfigIsFloatingPoint(config) ? GrPixelConfigIsClamped::kNo : GrPixelConfigIsClamped::kYes; |