diff options
author | Jim Van Verth <jvanverth@google.com> | 2018-11-15 16:26:50 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-11-16 16:35:04 +0000 |
commit | 3a8f345cf5689c6e1f22e852acfde4b8b1e5ba42 (patch) | |
tree | 983c5190ef681b064face6c43a3bf5cd65ef3983 /src | |
parent | 68f40d3b0ee0d45b771ea07336d0c733363296fa (diff) | |
download | platform_external_skqp-3a8f345cf5689c6e1f22e852acfde4b8b1e5ba42.tar.gz platform_external_skqp-3a8f345cf5689c6e1f22e852acfde4b8b1e5ba42.tar.bz2 platform_external_skqp-3a8f345cf5689c6e1f22e852acfde4b8b1e5ba42.zip |
Remove use of integers for atlas indexing
Bug: skia:
Change-Id: I7c29e90de6531a35c415f0338e23c176a7293040
Reviewed-on: https://skia-review.googlesource.com/c/171233
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/effects/GrAtlasedShaderHelpers.h | 24 | ||||
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.cpp | 6 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 18 |
3 files changed, 14 insertions, 34 deletions
diff --git a/src/gpu/effects/GrAtlasedShaderHelpers.h b/src/gpu/effects/GrAtlasedShaderHelpers.h index a7d445ac86..e4ebaab35b 100644 --- a/src/gpu/effects/GrAtlasedShaderHelpers.h +++ b/src/gpu/effects/GrAtlasedShaderHelpers.h @@ -20,31 +20,19 @@ static void append_index_uv_varyings(GrGLSLPrimitiveProcessor::EmitArgs& args, GrGLSLVarying *uv, GrGLSLVarying *texIdx, GrGLSLVarying *st) { - using Interpolation = GrGLSLVaryingHandler::Interpolation; - - // This extracts the texture index and texel coordinates from the same variable // Packing structure: texel coordinates are multiplied by 2 (or shifted left 1) // texture index is stored as lower bits of both x and y - if (args.fShaderCaps->integerSupport()) { - args.fVertBuilder->codeAppendf("int2 signedCoords = int2(%s.x, %s.y);", - inTexCoordsName, inTexCoordsName); - args.fVertBuilder->codeAppend("int texIdx = 2*(signedCoords.x & 0x1) + (signedCoords.y & 0x1);"); - args.fVertBuilder->codeAppend("float2 unormTexCoords = float2(signedCoords.x/2, signedCoords.y/2);"); - } else { - args.fVertBuilder->codeAppendf("float2 indexTexCoords = float2(%s.x, %s.y);", - inTexCoordsName, inTexCoordsName); - args.fVertBuilder->codeAppend("float2 unormTexCoords = floor(0.5*indexTexCoords);"); - args.fVertBuilder->codeAppend("float2 diff = indexTexCoords - 2.0*unormTexCoords;"); - args.fVertBuilder->codeAppend("float texIdx = 2.0*diff.x + diff.y;"); - } + args.fVertBuilder->codeAppendf("float2 indexTexCoords = float2(%s.x, %s.y);", + inTexCoordsName, inTexCoordsName); + args.fVertBuilder->codeAppend("float2 unormTexCoords = floor(0.5*indexTexCoords);"); + args.fVertBuilder->codeAppend("float2 diff = indexTexCoords - 2.0*unormTexCoords;"); + args.fVertBuilder->codeAppend("float texIdx = 2.0*diff.x + diff.y;"); // Multiply by 1/atlasSize to get normalized texture coordinates args.fVaryingHandler->addVarying("TextureCoords", uv); args.fVertBuilder->codeAppendf("%s = unormTexCoords * %s;", uv->vsOut(), atlasSizeInvName); - args.fVaryingHandler->addVarying("TexIndex", texIdx, args.fShaderCaps->integerSupport() - ? Interpolation::kMustBeFlat - : Interpolation::kCanBeFlat); + args.fVaryingHandler->addVarying("TexIndex", texIdx); args.fVertBuilder->codeAppendf("%s = texIdx;", texIdx->vsOut()); if (st) { diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index c59ae4aa60..2656fb8859 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -40,8 +40,7 @@ public: &atlasSizeInvName); GrGLSLVarying uv(kFloat2_GrSLType); - GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType; - GrGLSLVarying texIdx(texIdxType); + GrGLSLVarying texIdx(kFloat_GrSLType); append_index_uv_varyings(args, btgp.inTextureCoords().name(), atlasSizeInvName, &uv, &texIdx, nullptr); @@ -144,8 +143,7 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(const GrShaderCaps& caps, fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType}; } - fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType, - caps.integerSupport() ? kUShort2_GrSLType : kFloat2_GrSLType}; + fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType, kFloat2_GrSLType}; this->setVertexAttributes(&fInPosition, 3); if (numActiveProxies) { diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index d6a5e84f8e..a0941edab6 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -68,8 +68,7 @@ public: // add varyings GrGLSLVarying uv(kFloat2_GrSLType); - GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType; - GrGLSLVarying texIdx(texIdxType); + GrGLSLVarying texIdx(kFloat_GrSLType); GrGLSLVarying st(kFloat2_GrSLType); append_index_uv_varyings(args, dfTexEffect.inTextureCoords().name(), atlasSizeInvName, &uv, &texIdx, &st); @@ -231,8 +230,7 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const GrShaderCaps& c fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; } fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType }; - fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType, - caps.integerSupport() ? kUShort2_GrSLType : kFloat2_GrSLType}; + fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType, kFloat2_GrSLType}; this->setVertexAttributes(&fInPosition, 3); if (numProxies) { @@ -345,8 +343,7 @@ public: &atlasSizeInvName); GrGLSLVarying uv(kFloat2_GrSLType); - GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType; - GrGLSLVarying texIdx(texIdxType); + GrGLSLVarying texIdx(kFloat_GrSLType); GrGLSLVarying st(kFloat2_GrSLType); append_index_uv_varyings(args, dfPathEffect.inTextureCoords().name(), atlasSizeInvName, &uv, &texIdx, &st); @@ -523,8 +520,7 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const GrShaderCaps& caps, fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType}; - fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType, - caps.integerSupport() ? kUShort2_GrSLType : kFloat2_GrSLType}; + fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType, kFloat2_GrSLType}; this->setVertexAttributes(&fInPosition, 3); if (numProxies) { @@ -648,8 +644,7 @@ public: // set up varyings GrGLSLVarying uv(kFloat2_GrSLType); - GrSLType texIdxType = args.fShaderCaps->integerSupport() ? kInt_GrSLType : kFloat_GrSLType; - GrGLSLVarying texIdx(texIdxType); + GrGLSLVarying texIdx(kFloat_GrSLType); GrGLSLVarying st(kFloat2_GrSLType); append_index_uv_varyings(args, dfTexEffect.inTextureCoords().name(), atlasSizeInvName, &uv, &texIdx, &st); @@ -843,8 +838,7 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const GrShaderCaps& fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType}; } fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType}; - fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType, - caps.integerSupport() ? kUShort2_GrSLType : kFloat2_GrSLType}; + fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType, kFloat2_GrSLType}; this->setVertexAttributes(&fInPosition, 3); if (numProxies) { |