Always make atlas texture index varying a float
This improves perf on ANGLE D3D11 ES3. Will make conditional if any other config regresses. Also makes the varyings passed to append_index_uv_varyings be purely output params. Change-Id: I332940d9d55be854d3bba72286ca89840ab43d50 Bug: skia:10644 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316226 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
b6b7fffc35
commit
de3d44109a
@ -56,16 +56,21 @@ static void append_index_uv_varyings(GrGLSLPrimitiveProcessor::EmitArgs& args,
|
||||
}
|
||||
|
||||
// Multiply by 1/atlasDimensions to get normalized texture coordinates
|
||||
uv->reset(kFloat2_GrSLType);
|
||||
args.fVaryingHandler->addVarying("TextureCoords", uv);
|
||||
args.fVertBuilder->codeAppendf(
|
||||
"%s = unormTexCoords * %s;", uv->vsOut(), atlasDimensionsInvName);
|
||||
|
||||
args.fVaryingHandler->addVarying("TexIndex", texIdx, args.fShaderCaps->integerSupport()
|
||||
? Interpolation::kMustBeFlat
|
||||
: Interpolation::kCanBeFlat);
|
||||
args.fVertBuilder->codeAppendf("%s = texIdx;", texIdx->vsOut());
|
||||
// On ANGLE there is a significant cost to using an int varying. We don't know of any case where
|
||||
// it is worse to use a float so for now we always do.
|
||||
texIdx->reset(kFloat_GrSLType);
|
||||
// If we computed the local var "texIdx" as an int we will need to cast it to float
|
||||
const char* cast = args.fShaderCaps->integerSupport() ? "float" : "";
|
||||
args.fVaryingHandler->addVarying("TexIndex", texIdx, Interpolation::kCanBeFlat);
|
||||
args.fVertBuilder->codeAppendf("%s = %s(texIdx);", texIdx->vsOut(), cast);
|
||||
|
||||
if (st) {
|
||||
st->reset(kFloat2_GrSLType);
|
||||
args.fVaryingHandler->addVarying("IntTextureCoords", st);
|
||||
args.fVertBuilder->codeAppendf("%s = unormTexCoords;", st->vsOut());
|
||||
}
|
||||
|
@ -39,9 +39,7 @@ public:
|
||||
fAtlasDimensionsInvUniform = uniformHandler->addUniform(nullptr, kVertex_GrShaderFlag,
|
||||
kFloat2_GrSLType, "AtlasSizeInv", &atlasDimensionsInvName);
|
||||
|
||||
GrGLSLVarying uv(kFloat2_GrSLType);
|
||||
GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType;
|
||||
GrGLSLVarying texIdx(texIdxType);
|
||||
GrGLSLVarying uv, texIdx;
|
||||
append_index_uv_varyings(args, btgp.numTextureSamplers(), btgp.inTextureCoords().name(),
|
||||
atlasDimensionsInvName, &uv, &texIdx, nullptr);
|
||||
|
||||
|
@ -61,10 +61,7 @@ public:
|
||||
dfTexEffect.localMatrix(), &fLocalMatrixUniform);
|
||||
|
||||
// add varyings
|
||||
GrGLSLVarying uv(kFloat2_GrSLType);
|
||||
GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType;
|
||||
GrGLSLVarying texIdx(texIdxType);
|
||||
GrGLSLVarying st(kFloat2_GrSLType);
|
||||
GrGLSLVarying uv, texIdx, st;
|
||||
append_index_uv_varyings(args, dfTexEffect.numTextureSamplers(),
|
||||
dfTexEffect.inTextureCoords().name(), atlasDimensionsInvName, &uv,
|
||||
&texIdx, &st);
|
||||
@ -339,10 +336,7 @@ public:
|
||||
"AtlasDimensionsInv",
|
||||
&atlasDimensionsInvName);
|
||||
|
||||
GrGLSLVarying uv(kFloat2_GrSLType);
|
||||
GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType;
|
||||
GrGLSLVarying texIdx(texIdxType);
|
||||
GrGLSLVarying st(kFloat2_GrSLType);
|
||||
GrGLSLVarying uv, texIdx, st;
|
||||
append_index_uv_varyings(args, dfPathEffect.numTextureSamplers(),
|
||||
dfPathEffect.inTextureCoords().name(), atlasDimensionsInvName, &uv,
|
||||
&texIdx, &st);
|
||||
@ -619,10 +613,7 @@ public:
|
||||
&fLocalMatrixUniform);
|
||||
|
||||
// set up varyings
|
||||
GrGLSLVarying uv(kFloat2_GrSLType);
|
||||
GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType;
|
||||
GrGLSLVarying texIdx(texIdxType);
|
||||
GrGLSLVarying st(kFloat2_GrSLType);
|
||||
GrGLSLVarying uv, texIdx, st;
|
||||
append_index_uv_varyings(args, dfTexEffect.numTextureSamplers(),
|
||||
dfTexEffect.inTextureCoords().name(), atlasDimensionsInvName, &uv,
|
||||
&texIdx, &st);
|
||||
|
Loading…
Reference in New Issue
Block a user