Move shader precision modifier check onto GLSLCaps
BUG=skia: Review URL: https://codereview.chromium.org/1414373002
This commit is contained in:
parent
02141734f2
commit
f529439fea
@ -11,6 +11,7 @@
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GLBench.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLGLSL.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
@ -114,11 +115,11 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
|
||||
GrGLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aPosition.appendDecl(*ctx, &vshaderTxt);
|
||||
aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
aColor.appendDecl(*ctx, &vshaderTxt);
|
||||
aColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
oColor.appendDecl(*ctx, &vshaderTxt);
|
||||
oColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
|
||||
vshaderTxt.append(
|
||||
@ -136,12 +137,12 @@ GrGLuint GLCpuPosInstancedArraysBench::setupShader(const GrGLContext* ctx) {
|
||||
GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->fStandard,
|
||||
&fshaderTxt);
|
||||
oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
|
||||
oColor.appendDecl(*ctx, &fshaderTxt);
|
||||
oColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";\n");
|
||||
|
||||
const char* fsOutName;
|
||||
if (ctx->caps()->glslCaps()->mustDeclareFragmentShaderOutput()) {
|
||||
oFragColor.appendDecl(*ctx, &fshaderTxt);
|
||||
oFragColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";\n");
|
||||
fsOutName = oFragColor.c_str();
|
||||
} else {
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GLBench.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLGLSL.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
@ -105,13 +106,13 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
|
||||
GrGLShaderVar oColor("o_color", kVec3f_GrSLType, GrShaderVar::kVaryingOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aPosition.appendDecl(*ctx, &vshaderTxt);
|
||||
aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
aColor.appendDecl(*ctx, &vshaderTxt);
|
||||
aColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
oPosition.appendDecl(*ctx, &vshaderTxt);
|
||||
oPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
oColor.appendDecl(*ctx, &vshaderTxt);
|
||||
oColor.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
|
||||
vshaderTxt.append(
|
||||
@ -134,15 +135,15 @@ GrGLuint GLVec4ScalarBench::setupShader(const GrGLContext* ctx) {
|
||||
GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, gl->fStandard,
|
||||
&fshaderTxt);
|
||||
oPosition.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
|
||||
oPosition.appendDecl(*ctx, &fshaderTxt);
|
||||
oPosition.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";\n");
|
||||
oColor.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
|
||||
oColor.appendDecl(*ctx, &fshaderTxt);
|
||||
oColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";\n");
|
||||
|
||||
const char* fsOutName;
|
||||
if (ctx->caps()->glslCaps()->mustDeclareFragmentShaderOutput()) {
|
||||
oFragColor.appendDecl(*ctx, &fshaderTxt);
|
||||
oFragColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";\n");
|
||||
fsOutName = oFragColor.c_str();
|
||||
} else {
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GLBench.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLGLSL.h"
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
@ -72,16 +73,16 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
SkTArray<GrGLShaderVar> oVars;
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aPosition.appendDecl(*ctx, &vshaderTxt);
|
||||
aPosition.appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
|
||||
for (uint32_t i = 0; i < attribs; i++) {
|
||||
SkString aname;
|
||||
aname.appendf("a_color_%d", i);
|
||||
aVars.push_back(GrGLShaderVar(aname.c_str(),
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kAttribute_TypeModifier));
|
||||
aVars.back().appendDecl(*ctx, &vshaderTxt);
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kAttribute_TypeModifier));
|
||||
aVars.back().appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
|
||||
}
|
||||
@ -90,9 +91,9 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
SkString oname;
|
||||
oname.appendf("o_color_%d", i);
|
||||
oVars.push_back(GrGLShaderVar(oname.c_str(),
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kVaryingOut_TypeModifier));
|
||||
oVars.back().appendDecl(*ctx, &vshaderTxt);
|
||||
kVec4f_GrSLType,
|
||||
GrShaderVar::kVaryingOut_TypeModifier));
|
||||
oVars.back().appendDecl(ctx->caps()->glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";\n");
|
||||
}
|
||||
|
||||
@ -122,7 +123,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
|
||||
const char* fsOutName;
|
||||
if (ctx->caps()->glslCaps()->mustDeclareFragmentShaderOutput()) {
|
||||
oFragColor.appendDecl(*ctx, &fshaderTxt);
|
||||
oFragColor.appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";\n");
|
||||
fsOutName = oFragColor.c_str();
|
||||
} else {
|
||||
@ -131,7 +132,7 @@ GrGLuint GLVertexAttributesBench::setupShader(const GrGLContext* ctx, uint32_t a
|
||||
|
||||
for (uint32_t i = 0; i < maxAttribs; i++) {
|
||||
oVars[i].setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
|
||||
oVars[i].appendDecl(*ctx, &fshaderTxt);
|
||||
oVars[i].appendDecl(ctx->caps()->glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";\n");
|
||||
}
|
||||
|
||||
|
@ -721,8 +721,8 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
|
||||
const char *rectName;
|
||||
const char *profileSizeName;
|
||||
|
||||
const char* precisionString = GrGLShaderVar::PrecisionString(
|
||||
fPrecision, args.fBuilder->ctxInfo().standard());
|
||||
const char* precisionString = GrGLShaderVar::PrecisionString(args.fBuilder->glslCaps(),
|
||||
fPrecision);
|
||||
fProxyRectUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
fPrecision,
|
||||
|
@ -908,6 +908,7 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
|
||||
#include "effects/GrTextureStripAtlas.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "SkGr.h"
|
||||
|
||||
|
@ -167,6 +167,7 @@ void SkSweepGradient::SweepGradientContext::shadeSpan16(int x, int y, uint16_t*
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "SkGr.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
class GrGLSweepGradient : public GrGLGradientEffect {
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
/*
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "SkTLazy.h"
|
||||
#include "batches/GrVertexBatch.h"
|
||||
#include "effects/GrRRectEffect.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "gl/GrGLProcessor.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "gl/GrGLFragmentProcessor.h"
|
||||
#include "gl/GrGLGeometryProcessor.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
class GrGLConicEffect : public GrGLGeometryProcessor {
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
// Using highp for GLES here in order to avoid some precision issues on specific GPUs.
|
||||
GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision);
|
||||
SkString tmpDecl;
|
||||
tmpVar.appendDecl(args.fBuilder->ctxInfo(), &tmpDecl);
|
||||
tmpVar.appendDecl(args.fBuilder->glslCaps(), &tmpDecl);
|
||||
|
||||
GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "GrConvexPolyEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "SkPathPriv.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLFragmentProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
|
@ -33,11 +33,11 @@ public:
|
||||
const GrDistanceFieldA8TextGeoProc& dfTexEffect =
|
||||
args.fGP.cast<GrDistanceFieldA8TextGeoProc>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
|
||||
SkAssertResult(fsBuilder->enableFeature(
|
||||
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
|
||||
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
|
||||
|
||||
// emit attributes
|
||||
vsBuilder->emitAttributes(dfTexEffect);
|
||||
@ -46,7 +46,7 @@ public:
|
||||
// adjust based on gamma
|
||||
const char* distanceAdjustUniName = nullptr;
|
||||
// width, height, 1/(3*width)
|
||||
fDistanceAdjustUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
fDistanceAdjustUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"DistanceAdjust", &distanceAdjustUniName);
|
||||
#endif
|
||||
@ -65,14 +65,14 @@ public:
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
|
||||
this->emitTransforms(pb, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
|
||||
args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
// add varyings
|
||||
GrGLVertToFrag recipScale(kFloat_GrSLType);
|
||||
GrGLVertToFrag st(kVec2f_GrSLType);
|
||||
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
|
||||
args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
|
||||
pb->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
|
||||
vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName);
|
||||
|
||||
// compute numbers to be hardcoded to convert texture coordinates from int to float
|
||||
@ -83,15 +83,14 @@ public:
|
||||
SkScalar recipHeight = 1.0f / atlas->height();
|
||||
|
||||
GrGLVertToFrag uv(kVec2f_GrSLType);
|
||||
args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
|
||||
pb->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
|
||||
vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(),
|
||||
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
|
||||
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
|
||||
dfTexEffect.inTextureCoords()->fName);
|
||||
|
||||
// Use highp to work around aliasing issues
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
|
||||
pb->ctxInfo().standard()));
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn());
|
||||
|
||||
fsBuilder->codeAppend("\tfloat texColor = ");
|
||||
@ -284,17 +283,17 @@ public:
|
||||
const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistanceFieldPathGeoProc>();
|
||||
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
|
||||
SkAssertResult(fsBuilder->enableFeature(
|
||||
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
|
||||
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
|
||||
|
||||
// emit attributes
|
||||
vsBuilder->emitAttributes(dfTexEffect);
|
||||
|
||||
GrGLVertToFrag v(kVec2f_GrSLType);
|
||||
args.fPB->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
|
||||
pb->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
|
||||
|
||||
// setup pass through color
|
||||
if (!dfTexEffect.colorIgnored()) {
|
||||
@ -311,17 +310,16 @@ public:
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
|
||||
this->emitTransforms(pb, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
|
||||
args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
const char* textureSizeUniName = nullptr;
|
||||
fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"TextureSize", &textureSizeUniName);
|
||||
fTextureSizeUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"TextureSize", &textureSizeUniName);
|
||||
|
||||
// Use highp to work around aliasing issues
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
|
||||
pb->ctxInfo().standard()));
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppendf("vec2 uv = %s;", v.fsIn());
|
||||
|
||||
fsBuilder->codeAppend("float texColor = ");
|
||||
@ -332,8 +330,7 @@ public:
|
||||
fsBuilder->codeAppend("float distance = "
|
||||
SK_DistanceFieldMultiplier "*(texColor - " SK_DistanceFieldThreshold ");");
|
||||
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
|
||||
pb->ctxInfo().standard()));
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppendf("vec2 st = uv*%s;", textureSizeUniName);
|
||||
fsBuilder->codeAppend("float afwidth;");
|
||||
if (dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag) {
|
||||
@ -500,7 +497,7 @@ public:
|
||||
args.fGP.cast<GrDistanceFieldLCDTextGeoProc>();
|
||||
GrGLGPBuilder* pb = args.fPB;
|
||||
|
||||
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
|
||||
GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
|
||||
|
||||
// emit attributes
|
||||
vsBuilder->emitAttributes(dfTexEffect);
|
||||
@ -515,14 +512,14 @@ public:
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
|
||||
this->emitTransforms(pb, gpArgs->fPositionVar, dfTexEffect.inPosition()->fName,
|
||||
args.fTransformsIn, args.fTransformsOut);
|
||||
|
||||
// set up varyings
|
||||
bool isUniformScale = SkToBool(dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask);
|
||||
GrGLVertToFrag recipScale(kFloat_GrSLType);
|
||||
GrGLVertToFrag st(kVec2f_GrSLType);
|
||||
args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
|
||||
pb->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
|
||||
vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoords()->fName);
|
||||
|
||||
// compute numbers to be hardcoded to convert texture coordinates from int to float
|
||||
@ -533,25 +530,23 @@ public:
|
||||
SkScalar recipHeight = 1.0f / atlas->height();
|
||||
|
||||
GrGLVertToFrag uv(kVec2f_GrSLType);
|
||||
args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
|
||||
pb->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
|
||||
vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", uv.vsOut(),
|
||||
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
|
||||
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
|
||||
dfTexEffect.inTextureCoords()->fName);
|
||||
|
||||
// add frag shader code
|
||||
GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
|
||||
GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
|
||||
|
||||
SkAssertResult(fsBuilder->enableFeature(
|
||||
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
|
||||
|
||||
// create LCD offset adjusted by inverse of transform
|
||||
// Use highp to work around aliasing issues
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
|
||||
pb->ctxInfo().standard()));
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
fsBuilder->codeAppendf("vec2 uv = %s;\n", uv.fsIn());
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
|
||||
pb->ctxInfo().standard()));
|
||||
fsBuilder->codeAppend(GrGLShaderVar::PrecisionString(pb->glslCaps(), kHigh_GrSLPrecision));
|
||||
|
||||
SkScalar lcdDelta = 1.0f / (3.0f * atlas->width());
|
||||
if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
|
||||
@ -594,7 +589,7 @@ public:
|
||||
|
||||
// adjust width based on gamma
|
||||
const char* distanceAdjustUniName = nullptr;
|
||||
fDistanceAdjustUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
fDistanceAdjustUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"DistanceAdjust", &distanceAdjustUniName);
|
||||
fsBuilder->codeAppendf("distance -= %s;", distanceAdjustUniName);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrSimpleTextureEffect.h"
|
||||
#include "SkFloatingPoint.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLFragmentProcessor.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
@ -99,11 +100,11 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder,
|
||||
inCoords.c_str());
|
||||
builder->codeAppend(";");
|
||||
|
||||
builder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
|
||||
program->ctxInfo().standard()));
|
||||
builder->codeAppend(GrGLShaderVar::PrecisionString(program->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
builder->codeAppendf("float x = (%s).x;", inCoords.c_str());
|
||||
builder->codeAppend(GrGLShaderVar::PrecisionString(kHigh_GrSLPrecision,
|
||||
program->ctxInfo().standard()));
|
||||
builder->codeAppend(GrGLShaderVar::PrecisionString(program->glslCaps(),
|
||||
kHigh_GrSLPrecision));
|
||||
builder->codeAppendf("float y = (%s).y;", inCoords.c_str());
|
||||
|
||||
builder->codeAppendf("x = abs(2.0*(x - %s.x)/(%s.z - %s.x) - 1.0);",
|
||||
|
@ -92,6 +92,7 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
|
||||
glslCaps->fFBFetchColorName = "gl_LastFragColorARM";
|
||||
glslCaps->fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch";
|
||||
}
|
||||
glslCaps->fUsesPrecisionModifiers = true;
|
||||
}
|
||||
|
||||
glslCaps->fBindlessTextureSupport = ctxInfo.hasExtension("GL_NV_bindless_texture");
|
||||
|
@ -266,7 +266,7 @@ public:
|
||||
bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
|
||||
bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
|
||||
|
||||
GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
|
||||
const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
|
||||
|
||||
private:
|
||||
void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
|
||||
|
@ -6,7 +6,9 @@
|
||||
*/
|
||||
|
||||
#include "GrGLGLSL.h"
|
||||
#include "GrGLContext.h"
|
||||
#include "GrGLShaderVar.h"
|
||||
#include "GrGLUtil.h"
|
||||
#include "SkString.h"
|
||||
|
||||
bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
|
||||
|
@ -2820,13 +2820,13 @@ void GrGLGpu::createCopyProgram() {
|
||||
GrGLShaderVar oFragColor("o_FragColor", kVec4f_GrSLType, GrShaderVar::kOut_TypeModifier);
|
||||
|
||||
SkString vshaderTxt(version);
|
||||
aVertex.appendDecl(this->ctxInfo(), &vshaderTxt);
|
||||
aVertex.appendDecl(this->glCaps().glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";");
|
||||
uTexCoordXform.appendDecl(this->ctxInfo(), &vshaderTxt);
|
||||
uTexCoordXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";");
|
||||
uPosXform.appendDecl(this->ctxInfo(), &vshaderTxt);
|
||||
uPosXform.appendDecl(this->glCaps().glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";");
|
||||
vTexCoord.appendDecl(this->ctxInfo(), &vshaderTxt);
|
||||
vTexCoord.appendDecl(this->glCaps().glslCaps(), &vshaderTxt);
|
||||
vshaderTxt.append(";");
|
||||
|
||||
vshaderTxt.append(
|
||||
@ -2842,13 +2842,13 @@ void GrGLGpu::createCopyProgram() {
|
||||
GrGLAppendGLSLDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision, this->glStandard(),
|
||||
&fshaderTxt);
|
||||
vTexCoord.setTypeModifier(GrShaderVar::kVaryingIn_TypeModifier);
|
||||
vTexCoord.appendDecl(this->ctxInfo(), &fshaderTxt);
|
||||
vTexCoord.appendDecl(this->glCaps().glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";");
|
||||
uTexture.appendDecl(this->ctxInfo(), &fshaderTxt);
|
||||
uTexture.appendDecl(this->glCaps().glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";");
|
||||
const char* fsOutName;
|
||||
if (this->glCaps().glslCaps()->mustDeclareFragmentShaderOutput()) {
|
||||
oFragColor.appendDecl(this->ctxInfo(), &fshaderTxt);
|
||||
oFragColor.appendDecl(this->glCaps().glslCaps(), &fshaderTxt);
|
||||
fshaderTxt.append(";");
|
||||
fsOutName = oFragColor.c_str();
|
||||
} else {
|
||||
|
@ -8,8 +8,9 @@
|
||||
#ifndef GrGLProgramDataManager_DEFINED
|
||||
#define GrGLProgramDataManager_DEFINED
|
||||
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
#include "GrAllocator.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
#include "gl/GrGLTypes.h"
|
||||
|
||||
#include "SkTArray.h"
|
||||
|
||||
|
@ -8,8 +8,9 @@
|
||||
#ifndef GrGLShaderVar_DEFINED
|
||||
#define GrGLShaderVar_DEFINED
|
||||
|
||||
#include "GrGLContext.h"
|
||||
#include "GrShaderVar.h"
|
||||
#include "../glsl/GrGLSL.h"
|
||||
#include "../glsl/GrGLSLCaps.h"
|
||||
|
||||
#define USE_UNIFORM_FLOAT_ARRAYS true
|
||||
|
||||
@ -155,7 +156,7 @@ public:
|
||||
/**
|
||||
* Write a declaration of this variable to out.
|
||||
*/
|
||||
void appendDecl(const GrGLContextInfo& ctxInfo, SkString* out) const {
|
||||
void appendDecl(const GrGLSLCaps* glslCaps, SkString* out) const {
|
||||
SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeIsFloatType(fType));
|
||||
if (kUpperLeft_Origin == fOrigin) {
|
||||
// this is the only place where we specify a layout modifier. If we use other layout
|
||||
@ -163,10 +164,10 @@ public:
|
||||
out->append("layout(origin_upper_left) ");
|
||||
}
|
||||
if (this->getTypeModifier() != kNone_TypeModifier) {
|
||||
out->append(TypeModifierString(this->getTypeModifier(), ctxInfo.glslGeneration()));
|
||||
out->append(TypeModifierString(glslCaps, this->getTypeModifier()));
|
||||
out->append(" ");
|
||||
}
|
||||
out->append(PrecisionString(fPrecision, ctxInfo.standard()));
|
||||
out->append(PrecisionString(glslCaps, fPrecision));
|
||||
GrSLType effectiveType = this->getType();
|
||||
if (this->isArray()) {
|
||||
if (this->isUnsizedArray()) {
|
||||
@ -201,9 +202,9 @@ public:
|
||||
fUseUniformFloatArrays ? "" : ".x");
|
||||
}
|
||||
|
||||
static const char* PrecisionString(GrSLPrecision p, GrGLStandard standard) {
|
||||
static const char* PrecisionString(const GrGLSLCaps* glslCaps, GrSLPrecision p) {
|
||||
// Desktop GLSL has added precision qualifiers but they don't do anything.
|
||||
if (kGLES_GrGLStandard == standard) {
|
||||
if (glslCaps->usesPrecisionModifiers()) {
|
||||
switch (p) {
|
||||
case kLow_GrSLPrecision:
|
||||
return "lowp ";
|
||||
@ -219,7 +220,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static const char* TypeModifierString(TypeModifier t, GrGLSLGeneration gen) {
|
||||
static const char* TypeModifierString(const GrGLSLCaps* glslCaps, TypeModifier t) {
|
||||
GrGLSLGeneration gen = glslCaps->generation();
|
||||
switch (t) {
|
||||
case kNone_TypeModifier:
|
||||
return "";
|
||||
|
@ -159,7 +159,7 @@ void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility,
|
||||
SkString* out) const {
|
||||
for (int i = 0; i < fUniforms.count(); ++i) {
|
||||
if (fUniforms[i].fVisibility & visibility) {
|
||||
fUniforms[i].fVariable.appendDecl(this->ctxInfo(), out);
|
||||
fUniforms[i].fVariable.appendDecl(this->glslCaps(), out);
|
||||
out->append(";\n");
|
||||
}
|
||||
}
|
||||
@ -169,6 +169,10 @@ const GrGLContextInfo& GrGLProgramBuilder::ctxInfo() const {
|
||||
return fGpu->ctxInfo();
|
||||
}
|
||||
|
||||
const GrGLSLCaps* GrGLProgramBuilder::glslCaps() const {
|
||||
return this->ctxInfo().caps()->glslCaps();
|
||||
}
|
||||
|
||||
bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage) {
|
||||
// First we loop over all of the installed processors and collect coord transforms. These will
|
||||
// be sent to the GrGLPrimitiveProcessor in its emitCode function
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "../../GrPipeline.h"
|
||||
|
||||
class GrFragmentProcessor;
|
||||
class GrGLSLCaps;
|
||||
|
||||
// Enough precision to represent 1 / 2048 accurately in printf
|
||||
#define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11
|
||||
@ -75,6 +76,8 @@ public:
|
||||
|
||||
virtual const GrGLContextInfo& ctxInfo() const = 0;
|
||||
|
||||
virtual const GrGLSLCaps* glslCaps() const = 0;
|
||||
|
||||
virtual GrGLGpu* gpu() const = 0;
|
||||
|
||||
/*
|
||||
@ -250,6 +253,8 @@ public:
|
||||
|
||||
const GrGLContextInfo& ctxInfo() const override;
|
||||
|
||||
const GrGLSLCaps* glslCaps() const override;
|
||||
|
||||
GrGLGpu* gpu() const override { return fGpu; }
|
||||
|
||||
GrGLXPFragmentBuilder* getFragmentShaderBuilder() override { return &fFS; }
|
||||
|
@ -8,8 +8,10 @@
|
||||
#include "GrGLShaderBuilder.h"
|
||||
#include "GrGLProgramBuilder.h"
|
||||
#include "GrGLShaderStringBuilder.h"
|
||||
#include "../GrGLGpu.h"
|
||||
#include "../GrGLShaderVar.h"
|
||||
#include "gl/GrGLCaps.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "gl/GrGLShaderVar.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
|
||||
namespace {
|
||||
@ -67,7 +69,7 @@ GrGLShaderBuilder::GrGLShaderBuilder(GrGLProgramBuilder* program)
|
||||
|
||||
void GrGLShaderBuilder::declAppend(const GrGLShaderVar& var) {
|
||||
SkString tempDecl;
|
||||
var.appendDecl(fProgramBuilder->ctxInfo(), &tempDecl);
|
||||
var.appendDecl(fProgramBuilder->glslCaps(), &tempDecl);
|
||||
this->codeAppendf("%s;", tempDecl.c_str());
|
||||
}
|
||||
|
||||
@ -81,9 +83,8 @@ void GrGLShaderBuilder::emitFunction(GrSLType returnType,
|
||||
fProgramBuilder->nameVariable(outName, '\0', name);
|
||||
this->functions().appendf(" %s", outName->c_str());
|
||||
this->functions().append("(");
|
||||
const GrGLContextInfo& ctxInfo = fProgramBuilder->gpu()->ctxInfo();
|
||||
for (int i = 0; i < argCnt; ++i) {
|
||||
args[i].appendDecl(ctxInfo, &this->functions());
|
||||
args[i].appendDecl(fProgramBuilder->glslCaps(), &this->functions());
|
||||
if (i < argCnt - 1) {
|
||||
this->functions().append(", ");
|
||||
}
|
||||
@ -147,7 +148,7 @@ void GrGLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionNam
|
||||
|
||||
void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
|
||||
for (int i = 0; i < vars.count(); ++i) {
|
||||
vars[i].appendDecl(fProgramBuilder->ctxInfo(), out);
|
||||
vars[i].appendDecl(fProgramBuilder->glslCaps(), out);
|
||||
out->append(";\n");
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,11 @@
|
||||
#include "gl/GrGLFragmentProcessor.h"
|
||||
#include "gl/GrGLProgramDesc.h"
|
||||
#include "gl/GrGLProgramDataManager.h"
|
||||
#include "gl/GrGLTypes.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
class GrGLCaps;
|
||||
class GrGLContextInfo;
|
||||
class GrGLProgramBuilder;
|
||||
|
||||
|
@ -17,6 +17,7 @@ GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options) {
|
||||
fFBFetchSupport = false;
|
||||
fFBFetchNeedsCustomOutput = false;
|
||||
fBindlessTextureSupport = false;
|
||||
fUsesPrecisionModifiers = false;
|
||||
fFBFetchColorName = nullptr;
|
||||
fFBFetchExtensionString = nullptr;
|
||||
fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction;
|
||||
@ -42,6 +43,7 @@ SkString GrGLSLCaps::dump() const {
|
||||
r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
|
||||
r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
|
||||
r.appendf("Bindless texture support: %s\n", (fBindlessTextureSupport ? "YES" : "NO"));
|
||||
r.appendf("Uses precision modifiers: %s\n", (fUsesPrecisionModifiers ? "YES" : "NO"));
|
||||
r.appendf("Advanced blend equation interaction: %s\n",
|
||||
kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]);
|
||||
return r;
|
||||
|
@ -65,6 +65,8 @@ public:
|
||||
return fGLSLGeneration > k110_GrGLSLGeneration;
|
||||
}
|
||||
|
||||
bool usesPrecisionModifiers() const { return fUsesPrecisionModifiers; }
|
||||
|
||||
GrGLSLGeneration generation() const { return fGLSLGeneration; }
|
||||
|
||||
/**
|
||||
@ -79,6 +81,8 @@ private:
|
||||
bool fFBFetchSupport : 1;
|
||||
bool fFBFetchNeedsCustomOutput : 1;
|
||||
bool fBindlessTextureSupport : 1;
|
||||
bool fUsesPrecisionModifiers : 1;
|
||||
|
||||
|
||||
const char* fFBFetchColorName;
|
||||
const char* fFBFetchExtensionString;
|
||||
|
Loading…
Reference in New Issue
Block a user