aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrDistanceFieldGeoProc.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-08-16 16:41:30 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-16 23:05:15 +0000
commit88d99c63878c2d3d340120f0321676f72afcb4f0 (patch)
tree5b957dbf2f78ef7a15aa3810f8922c915508683f /src/gpu/effects/GrDistanceFieldGeoProc.cpp
parenta26d219a929f4e70f8597dfd57a53348c4bba905 (diff)
Switched highp float to highfloat and mediump float to half.
The ultimate goal is to end up with "float" and "half", but this intermediate step uses "highfloat" so that it is clear if I missed a "float" somewhere. Once this lands, a subsequent CL will switch all "highfloats" back to "floats". Bug: skia: Change-Id: Ia13225c7a0a0a2901e07665891c473d2500ddcca Reviewed-on: https://skia-review.googlesource.com/31000 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/effects/GrDistanceFieldGeoProc.cpp')
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.cpp156
1 files changed, 76 insertions, 80 deletions
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 8dd2fa617a..d1d14c9292 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -45,8 +45,7 @@ public:
// adjust based on gamma
const char* distanceAdjustUniName = nullptr;
// width, height, 1/(3*width)
- fDistanceAdjustUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kFloat_GrSLType, kDefault_GrSLPrecision,
+ fDistanceAdjustUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
"DistanceAdjust", &distanceAdjustUniName);
#endif
@@ -70,8 +69,8 @@ public:
args.fFPCoordTransformHandler);
// add varyings
- GrGLSLVertToFrag recipScale(kFloat_GrSLType);
- GrGLSLVertToFrag uv(kVec2f_GrSLType);
+ GrGLSLVertToFrag recipScale(kHalf2_GrSLType);
+ GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) ==
kUniformScale_DistanceFieldEffectMask;
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
@@ -79,7 +78,7 @@ public:
SkToBool(dfTexEffect.getFlags() & kGammaCorrect_DistanceFieldEffectFlag);
bool isAliased =
SkToBool(dfTexEffect.getFlags() & kAliased_DistanceFieldEffectFlag);
- varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
+ varyingHandler->addVarying("TextureCoords", &uv);
vertBuilder->codeAppendf("%s = %s;", uv.vsOut(), dfTexEffect.inTextureCoords()->fName);
// compute numbers to be hardcoded to convert texture coordinates from float to int
@@ -87,28 +86,28 @@ public:
GrTexture* atlas = dfTexEffect.textureSampler(0).peekTexture();
SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()));
- GrGLSLVertToFrag st(kVec2f_GrSLType);
- varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = float2(%d, %d) * %s;", st.vsOut(),
+ GrGLSLVertToFrag st(kHighFloat2_GrSLType);
+ varyingHandler->addVarying("IntTextureCoords", &st);
+ vertBuilder->codeAppendf("%s = highfloat2(%d, %d) * %s;", st.vsOut(),
atlas->width(), atlas->height(),
dfTexEffect.inTextureCoords()->fName);
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highp float2 uv = %s;\n", uv.fsIn());
+ fragBuilder->codeAppendf("highfloat2 uv = %s;\n", uv.fsIn());
- fragBuilder->codeAppend("\tfloat texColor = ");
+ fragBuilder->codeAppend("\thalf texColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0],
"uv",
- kVec2f_GrSLType);
+ kHighFloat2_GrSLType);
fragBuilder->codeAppend(".r;\n");
- fragBuilder->codeAppend("\tfloat distance = "
+ fragBuilder->codeAppend("\thalf distance = "
SK_DistanceFieldMultiplier "*(texColor - " SK_DistanceFieldThreshold ");");
#ifdef SK_GAMMA_APPLY_TO_A8
// adjust width based on gamma
fragBuilder->codeAppendf("distance -= %s;", distanceAdjustUniName);
#endif
- fragBuilder->codeAppend("float afwidth;");
+ fragBuilder->codeAppend("half afwidth;");
if (isUniformScale) {
// For uniform scale, we adjust for the effect of the transformation on the distance
// by using the length of the gradient of the t coordinate in the y direction.
@@ -131,29 +130,29 @@ public:
// this gives us a smooth step across approximately one fragment
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("float st_grad_len = length(dFdx(%s));", st.fsIn());
+ fragBuilder->codeAppendf("half st_grad_len = length(dFdx(%s));", st.fsIn());
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppendf("float st_grad_len = length(dFdy(%s));", st.fsIn());
+ fragBuilder->codeAppendf("half st_grad_len = length(dFdy(%s));", st.fsIn());
#endif
fragBuilder->codeAppend("afwidth = abs(" SK_DistanceFieldAAFactor "*st_grad_len);");
} else {
// For general transforms, to determine the amount of correction we multiply a unit
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
- fragBuilder->codeAppend("float2 dist_grad = float2(dFdx(distance), dFdy(distance));");
+ fragBuilder->codeAppend("half2 dist_grad = half2(dFdx(distance), dFdy(distance));");
// the length of the gradient may be 0, so we need to check for this
// this also compensates for the Adreno, which likes to drop tiles on division by 0
- fragBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
+ fragBuilder->codeAppend("half dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = half2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppendf("float2 Jdx = dFdx(%s);", st.fsIn());
- fragBuilder->codeAppendf("float2 Jdy = dFdy(%s);", st.fsIn());
- fragBuilder->codeAppend("float2 grad = float2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ fragBuilder->codeAppendf("half2 Jdx = dFdx(%s);", st.fsIn());
+ fragBuilder->codeAppendf("half2 Jdy = dFdy(%s);", st.fsIn());
+ fragBuilder->codeAppend("half2 grad = half2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
// this gives us a smooth step across approximately one fragment
@@ -161,18 +160,18 @@ public:
}
if (isAliased) {
- fragBuilder->codeAppend("float val = distance > 0 ? 1.0 : 0.0;");
+ fragBuilder->codeAppend("half val = distance > 0 ? 1.0 : 0.0;");
} else if (isGammaCorrect) {
// The smoothstep falloff compensates for the non-linear sRGB response curve. If we are
// doing gamma-correct rendering (to an sRGB or F16 buffer), then we actually want
// distance mapped linearly to coverage, so use a linear step:
fragBuilder->codeAppend(
- "float val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
+ "half val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
} else {
- fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
+ fragBuilder->codeAppend("half val = smoothstep(-afwidth, afwidth, distance);");
}
- fragBuilder->codeAppendf("%s = float4(val);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = half4(val);", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
@@ -323,7 +322,7 @@ public:
// emit attributes
varyingHandler->emitAttributes(dfTexEffect);
- GrGLSLVertToFrag v(kVec2f_GrSLType);
+ GrGLSLVertToFrag v(kHighFloat2_GrSLType);
varyingHandler->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
// setup pass through color
@@ -347,23 +346,22 @@ public:
args.fFPCoordTransformHandler);
const char* textureSizeUniName = nullptr;
- fTextureSizeUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kVec2f_GrSLType, kDefault_GrSLPrecision,
+ fTextureSizeUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf2_GrSLType,
"TextureSize", &textureSizeUniName);
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highp float2 uv = %s;", v.fsIn());
+ fragBuilder->codeAppendf("highfloat2 uv = %s;", v.fsIn());
- fragBuilder->codeAppend("float texColor = ");
+ fragBuilder->codeAppend("half texColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0],
"uv",
- kVec2f_GrSLType);
+ kHighFloat2_GrSLType);
fragBuilder->codeAppend(".r;");
- fragBuilder->codeAppend("float distance = "
+ fragBuilder->codeAppend("half distance = "
SK_DistanceFieldMultiplier "*(texColor - " SK_DistanceFieldThreshold ");");
- fragBuilder->codeAppendf("highp float2 st = uv*%s;", textureSizeUniName);
- fragBuilder->codeAppend("float afwidth;");
+ fragBuilder->codeAppendf("highfloat2 st = uv*%s;", textureSizeUniName);
+ fragBuilder->codeAppend("half afwidth;");
bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) ==
kUniformScale_DistanceFieldEffectMask;
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
@@ -388,29 +386,29 @@ public:
// this gives us a smooth step across approximately one fragment
#ifdef SK_VULKAN
- fragBuilder->codeAppend("float st_grad_len = length(dFdx(st));");
+ fragBuilder->codeAppend("half st_grad_len = length(dFdx(st));");
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppend("float st_grad_len = length(dFdy(st));");
+ fragBuilder->codeAppend("half st_grad_len = length(dFdy(st));");
#endif
fragBuilder->codeAppend("afwidth = abs(" SK_DistanceFieldAAFactor "*st_grad_len);");
} else {
// For general transforms, to determine the amount of correction we multiply a unit
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
- fragBuilder->codeAppend("float2 dist_grad = float2(dFdx(distance), dFdy(distance));");
+ fragBuilder->codeAppend("half2 dist_grad = half2(dFdx(distance), dFdy(distance));");
// the length of the gradient may be 0, so we need to check for this
// this also compensates for the Adreno, which likes to drop tiles on division by 0
- fragBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
+ fragBuilder->codeAppend("half dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = half2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppend("float2 Jdx = dFdx(st);");
- fragBuilder->codeAppend("float2 Jdy = dFdy(st);");
- fragBuilder->codeAppend("float2 grad = float2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ fragBuilder->codeAppend("half2 Jdx = dFdx(st);");
+ fragBuilder->codeAppend("half2 Jdy = dFdy(st);");
+ fragBuilder->codeAppend("half2 grad = half2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
// this gives us a smooth step across approximately one fragment
@@ -421,12 +419,12 @@ public:
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppend(
- "float val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
+ "half val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
} else {
- fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
+ fragBuilder->codeAppend("half val = smoothstep(-afwidth, afwidth, distance);");
}
- fragBuilder->codeAppendf("%s = float4(val);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = half4(val);", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
@@ -589,8 +587,7 @@ public:
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
bool isGammaCorrect =
SkToBool(dfTexEffect.getFlags() & kGammaCorrect_DistanceFieldEffectFlag);
- GrGLSLVertToFrag recipScale(kFloat_GrSLType);
- GrGLSLVertToFrag uv(kVec2f_GrSLType);
+ GrGLSLVertToFrag uv(kHighFloat2_GrSLType);
varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", uv.vsOut(), dfTexEffect.inTextureCoords()->fName);
@@ -599,9 +596,9 @@ public:
GrTexture* atlas = dfTexEffect.textureSampler(0).peekTexture();
SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()));
- GrGLSLVertToFrag st(kVec2f_GrSLType);
+ GrGLSLVertToFrag st(kHighFloat2_GrSLType);
varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = float2(%d, %d) * %s;", st.vsOut(),
+ vertBuilder->codeAppendf("%s = highfloat2(%d, %d) * %s;", st.vsOut(),
atlas->width(), atlas->height(),
dfTexEffect.inTextureCoords()->fName);
@@ -609,69 +606,68 @@ public:
// create LCD offset adjusted by inverse of transform
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highp float2 uv = %s;\n", uv.fsIn());
+ fragBuilder->codeAppendf("highfloat2 uv = %s;\n", uv.fsIn());
SkScalar lcdDelta = 1.0f / (3.0f * atlas->width());
if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
- fragBuilder->codeAppendf("highp float delta = -%.*f;\n", SK_FLT_DECIMAL_DIG, lcdDelta);
+ fragBuilder->codeAppendf("highfloat delta = -%.*f;\n", SK_FLT_DECIMAL_DIG, lcdDelta);
} else {
- fragBuilder->codeAppendf("highp float delta = %.*f;\n", SK_FLT_DECIMAL_DIG, lcdDelta);
+ fragBuilder->codeAppendf("highfloat delta = %.*f;\n", SK_FLT_DECIMAL_DIG, lcdDelta);
}
if (isUniformScale) {
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("float st_grad_len = abs(dFdx(%s.x));", st.fsIn());
+ fragBuilder->codeAppendf("half st_grad_len = abs(dFdx(%s.x));", st.fsIn());
#else
// We use the y gradient because there is a bug in the Mali 400 in the x direction.
- fragBuilder->codeAppendf("float st_grad_len = abs(dFdy(%s.y));", st.fsIn());
+ fragBuilder->codeAppendf("half st_grad_len = abs(dFdy(%s.y));", st.fsIn());
#endif
- fragBuilder->codeAppend("float2 offset = float2(st_grad_len*delta, 0.0);");
+ fragBuilder->codeAppend("half2 offset = half2(st_grad_len*delta, 0.0);");
} else if (isSimilarity) {
// For a similarity matrix with rotation, the gradient will not be aligned
// with the texel coordinate axes, so we need to calculate it.
#ifdef SK_VULKAN
- fragBuilder->codeAppendf("float2 st_grad = dFdx(%s);", st.fsIn());
- fragBuilder->codeAppend("float2 offset = delta*st_grad;");
+ fragBuilder->codeAppendf("half2 st_grad = dFdx(%s);", st.fsIn());
+ fragBuilder->codeAppend("half2 offset = delta*st_grad;");
#else
// We use dFdy because of a Mali 400 bug, and rotate -90 degrees to
// get the gradient in the x direction.
- fragBuilder->codeAppendf("float2 st_grad = dFdy(%s);", st.fsIn());
- fragBuilder->codeAppend("float2 offset = delta*float2(st_grad.y, -st_grad.x);");
+ fragBuilder->codeAppendf("half2 st_grad = dFdy(%s);", st.fsIn());
+ fragBuilder->codeAppend("half2 offset = delta*half2(st_grad.y, -st_grad.x);");
#endif
- fragBuilder->codeAppend("float st_grad_len = length(st_grad);");
+ fragBuilder->codeAppend("half st_grad_len = length(st_grad);");
} else {
- fragBuilder->codeAppendf("float2 st = %s;\n", st.fsIn());
+ fragBuilder->codeAppendf("half2 st = %s;\n", st.fsIn());
- fragBuilder->codeAppend("float2 Jdx = dFdx(st);");
- fragBuilder->codeAppend("float2 Jdy = dFdy(st);");
- fragBuilder->codeAppend("float2 offset = delta*Jdx;");
+ fragBuilder->codeAppend("half2 Jdx = dFdx(st);");
+ fragBuilder->codeAppend("half2 Jdy = dFdy(st);");
+ fragBuilder->codeAppend("half2 offset = delta*Jdx;");
}
// green is distance to uv center
- fragBuilder->codeAppend("\tfloat4 texColor = ");
- fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv", kVec2f_GrSLType);
+ fragBuilder->codeAppend("\thalf4 texColor = ");
+ fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv", kHighFloat2_GrSLType);
fragBuilder->codeAppend(";\n");
- fragBuilder->codeAppend("\tfloat3 distance;\n");
+ fragBuilder->codeAppend("\thalf3 distance;\n");
fragBuilder->codeAppend("\tdistance.y = texColor.r;\n");
// red is distance to left offset
- fragBuilder->codeAppend("\tfloat2 uv_adjusted = uv - offset;\n");
+ fragBuilder->codeAppend("\thighfloat2 uv_adjusted = uv - offset;\n");
fragBuilder->codeAppend("\ttexColor = ");
- fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv_adjusted", kVec2f_GrSLType);
+ fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv_adjusted", kHighFloat2_GrSLType);
fragBuilder->codeAppend(";\n");
fragBuilder->codeAppend("\tdistance.x = texColor.r;\n");
// blue is distance to right offset
fragBuilder->codeAppend("\tuv_adjusted = uv + offset;\n");
fragBuilder->codeAppend("\ttexColor = ");
- fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv_adjusted", kVec2f_GrSLType);
+ fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv_adjusted", kHighFloat2_GrSLType);
fragBuilder->codeAppend(";\n");
fragBuilder->codeAppend("\tdistance.z = texColor.r;\n");
fragBuilder->codeAppend("\tdistance = "
- "float3(" SK_DistanceFieldMultiplier ")*(distance - float3(" SK_DistanceFieldThreshold"));");
+ "half3(" SK_DistanceFieldMultiplier ")*(distance - half3(" SK_DistanceFieldThreshold"));");
// adjust width based on gamma
const char* distanceAdjustUniName = nullptr;
- fDistanceAdjustUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
- kVec3f_GrSLType, kDefault_GrSLPrecision,
+ fDistanceAdjustUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kHalf3_GrSLType,
"DistanceAdjust", &distanceAdjustUniName);
fragBuilder->codeAppendf("distance -= %s;", distanceAdjustUniName);
@@ -679,7 +675,7 @@ public:
// for each color component. However, this is only important when using perspective
// transformations, and even then using a single factor seems like a reasonable
// trade-off between quality and speed.
- fragBuilder->codeAppend("float afwidth;");
+ fragBuilder->codeAppend("half afwidth;");
if (isSimilarity) {
// For similarity transform (uniform scale-only is a subset of this), we adjust for the
// effect of the transformation on the distance by using the length of the gradient of
@@ -692,16 +688,16 @@ public:
// For general transforms, to determine the amount of correction we multiply a unit
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
- fragBuilder->codeAppend("float2 dist_grad = float2(dFdx(distance.r), dFdy(distance.r));");
+ fragBuilder->codeAppend("half2 dist_grad = half2(dFdx(distance.r), dFdy(distance.r));");
// the length of the gradient may be 0, so we need to check for this
// this also compensates for the Adreno, which likes to drop tiles on division by 0
- fragBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
+ fragBuilder->codeAppend("half dg_len2 = dot(dist_grad, dist_grad);");
fragBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = half2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppend("float2 grad = float2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ fragBuilder->codeAppend("half2 grad = half2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fragBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
// this gives us a smooth step across approximately one fragment
@@ -713,11 +709,11 @@ public:
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppendf("%s = "
- "float4(clamp((distance + float3(afwidth)) / float3(2.0 * afwidth), 0.0, 1.0), 1.0);",
+ "half4(clamp((distance + half3(afwidth)) / half3(2.0 * afwidth), 0.0, 1.0), 1.0);",
args.fOutputCoverage);
} else {
fragBuilder->codeAppendf(
- "%s = float4(smoothstep(float3(-afwidth), float3(afwidth), distance), 1.0);",
+ "%s = half4(smoothstep(half3(-afwidth), half3(afwidth), distance), 1.0);",
args.fOutputCoverage);
}
}