aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-03-11 13:34:32 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-11 13:34:32 -0800
commit5f2d8e28c4f8ec0ead92eb613254063ace4e90b4 (patch)
tree8cadf1d160eacc82079a10f7ca42c34faaf8ce51
parentfde05114e6c4107b36e1aa571c64d31def40f613 (diff)
Add sampler precision to GrTextureAccess
-rw-r--r--include/gpu/GrTextureAccess.h14
-rw-r--r--include/gpu/GrTypesPriv.h4
-rw-r--r--src/gpu/GrTextureAccess.cpp13
-rw-r--r--src/gpu/gl/GrGLUniformHandler.cpp2
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp2
-rw-r--r--src/gpu/glsl/GrGLSLShaderVar.h12
6 files changed, 31 insertions, 16 deletions
diff --git a/include/gpu/GrTextureAccess.h b/include/gpu/GrTextureAccess.h
index 1b5de0ce99..237485a9e2 100644
--- a/include/gpu/GrTextureAccess.h
+++ b/include/gpu/GrTextureAccess.h
@@ -30,25 +30,30 @@ public:
explicit GrTextureAccess(GrTexture*,
GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode,
- GrShaderFlags visibility = kFragment_GrShaderFlag);
+ GrShaderFlags visibility = kFragment_GrShaderFlag,
+ GrSLPrecision = kDefault_GrSLPrecision);
void reset(GrTexture*, const GrTextureParams&,
- GrShaderFlags visibility = kFragment_GrShaderFlag);
+ GrShaderFlags visibility = kFragment_GrShaderFlag,
+ GrSLPrecision = kDefault_GrSLPrecision);
void reset(GrTexture*,
GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode,
- GrShaderFlags visibility = kFragment_GrShaderFlag);
+ GrShaderFlags visibility = kFragment_GrShaderFlag,
+ GrSLPrecision = kDefault_GrSLPrecision);
bool operator==(const GrTextureAccess& that) const {
return this->getTexture() == that.getTexture() &&
fParams == that.fParams &&
- fVisibility == that.fVisibility;
+ fVisibility == that.fVisibility &&
+ fPrecision == that.fPrecision;
}
bool operator!=(const GrTextureAccess& other) const { return !(*this == other); }
GrTexture* getTexture() const { return fTexture.get(); }
GrShaderFlags getVisibility() const { return fVisibility; }
+ GrSLPrecision getPrecision() const { return fPrecision; }
/**
* For internal use by GrProcessor.
@@ -64,6 +69,7 @@ private:
ProgramTexture fTexture;
GrTextureParams fParams;
GrShaderFlags fVisibility;
+ GrSLPrecision fPrecision;
typedef SkNoncopyable INHERITED;
};
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index a045153772..a2facfa6cf 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -204,6 +204,10 @@ static inline bool GrSLTypeIsSamplerType(GrSLType type) {
GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
}
+static inline bool GrSLTypeAcceptsPrecision(GrSLType type) {
+ return GrSLTypeIsNumeric(type) || GrSLTypeIsSamplerType(type);
+}
+
//////////////////////////////////////////////////////////////////////////////
/**
diff --git a/src/gpu/GrTextureAccess.cpp b/src/gpu/GrTextureAccess.cpp
index 675bc20777..a62a4ddce0 100644
--- a/src/gpu/GrTextureAccess.cpp
+++ b/src/gpu/GrTextureAccess.cpp
@@ -18,25 +18,30 @@ GrTextureAccess::GrTextureAccess(GrTexture* texture, const GrTextureParams& para
GrTextureAccess::GrTextureAccess(GrTexture* texture,
GrTextureParams::FilterMode filterMode,
SkShader::TileMode tileXAndY,
- GrShaderFlags visibility) {
- this->reset(texture, filterMode, tileXAndY, visibility);
+ GrShaderFlags visibility,
+ GrSLPrecision precision) {
+ this->reset(texture, filterMode, tileXAndY, visibility, precision);
}
void GrTextureAccess::reset(GrTexture* texture,
const GrTextureParams& params,
- GrShaderFlags visibility) {
+ GrShaderFlags visibility,
+ GrSLPrecision precision) {
SkASSERT(texture);
fTexture.set(SkRef(texture), kRead_GrIOType);
fParams = params;
fVisibility = visibility;
+ fPrecision = precision;
}
void GrTextureAccess::reset(GrTexture* texture,
GrTextureParams::FilterMode filterMode,
SkShader::TileMode tileXAndY,
- GrShaderFlags visibility) {
+ GrShaderFlags visibility,
+ GrSLPrecision precision) {
SkASSERT(texture);
fTexture.set(SkRef(texture), kRead_GrIOType);
fParams.reset(tileXAndY, filterMode);
fVisibility = visibility;
+ fPrecision = precision;
}
diff --git a/src/gpu/gl/GrGLUniformHandler.cpp b/src/gpu/gl/GrGLUniformHandler.cpp
index 856afb4b9a..7f6f106964 100644
--- a/src/gpu/gl/GrGLUniformHandler.cpp
+++ b/src/gpu/gl/GrGLUniformHandler.cpp
@@ -26,7 +26,7 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
SkDEBUGCODE(static const uint32_t kVisMask = kVertex_GrShaderFlag | kFragment_GrShaderFlag);
SkASSERT(0 == (~kVisMask & visibility));
SkASSERT(0 != visibility);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
UniformInfo& uni = fUniforms.push_back();
uni.fVariable.setType(type);
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index bc0208321c..7116d193f4 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -240,7 +240,7 @@ void GrGLSLProgramBuilder::emitSamplers(const GrProcessor& processor,
name.printf("Sampler%d", t);
localSamplerUniforms[t] = this->uniformHandler()->addUniform(access.getVisibility(),
samplerType,
- kDefault_GrSLPrecision,
+ access.getPrecision(),
name.c_str());
outSamplers->emplace_back(localSamplerUniforms[t], access);
}
diff --git a/src/gpu/glsl/GrGLSLShaderVar.h b/src/gpu/glsl/GrGLSLShaderVar.h
index bdd36f3763..a7d7479d39 100644
--- a/src/gpu/glsl/GrGLSLShaderVar.h
+++ b/src/gpu/glsl/GrGLSLShaderVar.h
@@ -76,7 +76,7 @@ public:
const char* extraModifiers = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
INHERITED::set(type, name, typeModifier, precision);
fLayoutQualifier = layoutQualifier;
if (extraModifiers) {
@@ -96,7 +96,7 @@ public:
const char* extraModifiers = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
INHERITED::set(type, name, typeModifier, precision);
fLayoutQualifier = layoutQualifier;
if (extraModifiers) {
@@ -117,7 +117,7 @@ public:
const char* extraModifiers = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
INHERITED::set(type, name, typeModifier, precision, count);
fLayoutQualifier = layoutQualifier;
if (extraModifiers) {
@@ -138,7 +138,7 @@ public:
const char* extraModifiers = nullptr,
bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
SkASSERT(kVoid_GrSLType != type);
- SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type));
+ SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeAcceptsPrecision(type));
INHERITED::set(type, name, typeModifier, precision, count);
fLayoutQualifier = layoutQualifier;
if (extraModifiers) {
@@ -164,7 +164,7 @@ public:
* Write a declaration of this variable to out.
*/
void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
- SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsNumeric(fType));
+ SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeAcceptsPrecision(fType));
if (!fLayoutQualifier.isEmpty()) {
out->appendf("layout(%s) ", fLayoutQualifier.c_str());
}
@@ -174,7 +174,7 @@ public:
out->append(" ");
}
GrSLType effectiveType = this->getType();
- if (effectiveType != kBool_GrSLType) {
+ if (GrSLTypeAcceptsPrecision(effectiveType)) {
out->append(PrecisionString(glslCaps, fPrecision));
}
if (this->isArray()) {