Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1153)

Unified Diff: src/gpu/GrDrawTargetCaps.h

Issue 778783002: Use texture size to determine precision of texture coord varyings (Closed) Base URL: https://skia.googlesource.com/skia.git@defaultp
Patch Set: more Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrDrawTargetCaps.h
diff --git a/src/gpu/GrDrawTargetCaps.h b/src/gpu/GrDrawTargetCaps.h
index f13aa53c806dfe8173174ddfa901108b58bc00d9..d3c8c110884ca5f30e07b85ee553c99fda92ebd2 100644
--- a/src/gpu/GrDrawTargetCaps.h
+++ b/src/gpu/GrDrawTargetCaps.h
@@ -9,6 +9,8 @@
#define GrDrawTargetCaps_DEFINED
#include "GrTypes.h"
+#include "GrTypesPriv.h"
+#include "GrShaderVar.h"
#include "SkRefCnt.h"
#include "SkString.h"
@@ -19,6 +21,41 @@ class GrDrawTargetCaps : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(GrDrawTargetCaps)
+ /** 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 GrShaderVar::Precision
+ 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.
+ """
+ */
joshualitt 2014/12/08 19:38:32 wraps
bsalomon 2014/12/08 19:49:18 Done.
+ int fBits;
+ };
+
+
GrDrawTargetCaps() : fUniqueID(CreateUniqueID()) {
this->reset();
}
@@ -84,6 +121,24 @@ public:
}
/**
+ * 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,
+ GrShaderVar::Precision 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; }
+
+ /**
* Gets an id that is unique for this GrDrawTargetCaps object. It is static in that it does
* not change when the content of the GrDrawTargetCaps object changes. This will never return
* 0.
@@ -119,6 +174,9 @@ protected:
bool fConfigRenderSupport[kGrPixelConfigCnt][2];
bool fConfigTextureSupport[kGrPixelConfigCnt];
+ bool fShaderPrecisionVaries;
+ PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][GrShaderVar::kPrecisionCount];
+
private:
static uint32_t CreateUniqueID();
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | src/gpu/SkGpuDevice.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698