aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-11-15 18:27:09 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-16 03:31:45 +0000
commite42180022720f2fcfd3c634cad855506a7940591 (patch)
tree76fb7187cd7dd509da717a221b3c309f9b703d3b /include
parentae9d6189ec03c4a188e67b42d755c42024397f44 (diff)
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>
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrShaderCaps.h71
-rw-r--r--include/private/GrTypesPriv.h27
2 files changed, 33 insertions, 65 deletions
diff --git a/include/gpu/GrShaderCaps.h b/include/gpu/GrShaderCaps.h
index 5ecd58ca59..4c847ac8b0 100644
--- a/include/gpu/GrShaderCaps.h
+++ b/include/gpu/GrShaderCaps.h
@@ -20,40 +20,6 @@ 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.
@@ -82,24 +48,6 @@ 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
@@ -136,6 +84,10 @@ public:
bool vertexIDSupport() const { return fVertexIDSupport; }
+ bool floatIs32Bits() const { return fFloatIs32Bits; }
+
+ bool halfIs32Bits() const { return fHalfIs32Bits; }
+
AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; }
bool mustEnableAdvBlendEqs() const {
@@ -260,17 +212,9 @@ 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;
@@ -284,7 +228,6 @@ private:
bool fIntegerSupport : 1;
bool fTexelBufferSupport : 1;
bool fImageLoadStoreSupport : 1;
- bool fShaderPrecisionVaries : 1;
bool fDropsTileOnZeroDivide : 1;
bool fFBFetchSupport : 1;
bool fFBFetchNeedsCustomOutput : 1;
@@ -300,6 +243,8 @@ 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
@@ -311,8 +256,6 @@ private:
bool fMustObfuscateUniformColor : 1;
bool fMustGuardDivisionEvenAfterExplicitZeroCheck : 1;
- PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
-
const char* fVersionDeclString;
const char* fShaderDerivativeExtensionString;
@@ -339,8 +282,6 @@ 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 a90944064f..cd1c0d4483 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -909,6 +909,33 @@ 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;