aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-07-28 15:19:46 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-28 20:43:03 +0000
commit5af9ea399d5e0344cc4b7da4e97b5dc5b3c74f64 (patch)
treedf906a3af0b954b130340589f24d128ce655bb01 /src
parent0edfbb78244739cb6e695f240edb7f659a543160 (diff)
renamed SkSL types in preparation for killing precision modifiers
Bug: skia: Change-Id: Iff0289e25355a89cdc289a0892ed755dd1b1c900 Reviewed-on: https://skia-review.googlesource.com/27703 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkColorMatrixFilterRowMajor255.cpp5
-rw-r--r--src/core/SkNormalFlatSource.cpp2
-rw-r--r--src/core/SkNormalMapSource.cpp8
-rw-r--r--src/effects/GrAlphaThresholdFragmentProcessor.cpp14
-rw-r--r--src/effects/GrAlphaThresholdFragmentProcessor.fp4
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.cpp6
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.fp8
-rw-r--r--src/effects/SkArithmeticImageFilter.cpp6
-rw-r--r--src/effects/SkBlurMaskFilter.cpp22
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp8
-rw-r--r--src/effects/SkHighContrastFilter.cpp14
-rw-r--r--src/effects/SkLightingImageFilter.cpp24
-rw-r--r--src/effects/SkLumaColorFilter.cpp6
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp16
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp8
-rw-r--r--src/effects/SkOverdrawColorFilter.cpp14
-rw-r--r--src/effects/SkRRectsGaussianEdgeMaskFilter.cpp18
-rw-r--r--src/effects/SkTableColorFilter.cpp14
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.cpp12
-rw-r--r--src/gpu/GrFragmentProcessor.h2
-rw-r--r--src/gpu/GrPathProcessor.cpp2
-rw-r--r--src/gpu/GrTextureStripAtlas.h4
-rw-r--r--src/gpu/ccpr/GrCCPRCoverageProcessor.cpp76
-rw-r--r--src/gpu/ccpr/GrCCPRCoverageProcessor.h8
-rw-r--r--src/gpu/ccpr/GrCCPRCubicProcessor.cpp142
-rw-r--r--src/gpu/ccpr/GrCCPRPathProcessor.cpp22
-rw-r--r--src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp77
-rw-r--r--src/gpu/ccpr/GrCCPRTriangleProcessor.cpp68
-rw-r--r--src/gpu/effects/GrBezierEffect.cpp36
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp18
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp2
-rw-r--r--src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp5
-rw-r--r--src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp2
-rw-r--r--src/gpu/effects/GrCircleEffect.cpp12
-rw-r--r--src/gpu/effects/GrCircleEffect.fp6
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp6
-rw-r--r--src/gpu/effects/GrConvexPolyEffect.cpp2
-rw-r--r--src/gpu/effects/GrDisableColorXP.cpp2
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.cpp72
-rw-r--r--src/gpu/effects/GrDitherEffect.cpp10
-rw-r--r--src/gpu/effects/GrDitherEffect.fp4
-rw-r--r--src/gpu/effects/GrEllipseEffect.cpp31
-rw-r--r--src/gpu/effects/GrEllipseEffect.fp16
-rw-r--r--src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp6
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.cpp8
-rw-r--r--src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp10
-rw-r--r--src/gpu/effects/GrPorterDuffXferProcessor.cpp4
-rw-r--r--src/gpu/effects/GrRRectEffect.cpp42
-rw-r--r--src/gpu/effects/GrSRGBEffect.cpp10
-rw-r--r--src/gpu/effects/GrShadowGeoProc.cpp4
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.cpp8
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.fp2
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp10
-rw-r--r--src/gpu/effects/GrTextureDomain.h6
-rw-r--r--src/gpu/effects/GrXfermodeFragmentProcessor.cpp4
-rw-r--r--src/gpu/effects/GrYUVEffect.cpp8
-rw-r--r--src/gpu/gl/GrGLGpu.cpp22
-rw-r--r--src/gpu/gl/GrGLProgram.h4
-rw-r--r--src/gpu/glsl/GrGLSLBlend.cpp34
-rw-r--r--src/gpu/glsl/GrGLSLFragmentProcessor.cpp2
-rw-r--r--src/gpu/glsl/GrGLSLFragmentProcessor.h8
-rw-r--r--src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp8
-rw-r--r--src/gpu/glsl/GrGLSLGeometryProcessor.cpp12
-rw-r--r--src/gpu/glsl/GrGLSLGeometryProcessor.h2
-rw-r--r--src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp2
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp6
-rw-r--r--src/gpu/glsl/GrGLSLShaderBuilder.cpp2
-rw-r--r--src/gpu/glsl/GrGLSLShaderBuilder.h4
-rw-r--r--src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp14
-rw-r--r--src/gpu/glsl/GrGLSLXferProcessor.cpp12
-rw-r--r--src/gpu/instanced/InstanceProcessor.cpp210
-rw-r--r--src/gpu/ops/GrAAConvexPathRenderer.cpp8
-rw-r--r--src/gpu/ops/GrDashOp.cpp14
-rw-r--r--src/gpu/ops/GrMSAAPathRenderer.cpp2
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp28
-rw-r--r--src/gpu/vk/GrVkCopyManager.cpp16
-rw-r--r--src/gpu/vk/GrVkPipelineState.h4
-rw-r--r--src/gpu/vk/GrVkUniformHandler.cpp2
-rw-r--r--src/shaders/SkLightingShader.cpp8
-rw-r--r--src/shaders/SkPerlinNoiseShader.cpp92
-rw-r--r--src/shaders/gradients/SkGradientShader.cpp14
-rw-r--r--src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp16
-rw-r--r--src/sksl/README24
-rw-r--r--src/sksl/SkSLCPP.h4
-rw-r--r--src/sksl/SkSLCPPCodeGenerator.cpp54
-rw-r--r--src/sksl/SkSLCPPCodeGenerator.h2
-rw-r--r--src/sksl/SkSLCompiler.cpp105
-rw-r--r--src/sksl/SkSLContext.h200
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.cpp64
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.h2
-rw-r--r--src/sksl/SkSLHCodeGenerator.cpp8
-rw-r--r--src/sksl/SkSLIRGenerator.cpp24
-rw-r--r--src/sksl/SkSLSPIRVCodeGenerator.cpp22
-rw-r--r--src/sksl/ast/SkSLASTInterfaceBlock.h2
-rw-r--r--src/sksl/ir/SkSLConstructor.h2
-rw-r--r--src/sksl/ir/SkSLIndexExpression.h12
-rw-r--r--src/sksl/ir/SkSLInterfaceBlock.h2
-rw-r--r--src/sksl/ir/SkSLSwizzle.h38
-rw-r--r--src/sksl/ir/SkSLType.cpp66
-rw-r--r--src/sksl/ir/SkSLType.h4
-rw-r--r--src/sksl/sksl.include566
-rw-r--r--src/sksl/sksl_fp.include18
-rw-r--r--src/sksl/sksl_frag.include12
-rw-r--r--src/sksl/sksl_geom.include4
-rw-r--r--src/sksl/sksl_vert.include2
105 files changed, 1402 insertions, 1337 deletions
diff --git a/src/core/SkColorMatrixFilterRowMajor255.cpp b/src/core/SkColorMatrixFilterRowMajor255.cpp
index 94e3c7e030..9262e5bf5d 100644
--- a/src/core/SkColorMatrixFilterRowMajor255.cpp
+++ b/src/core/SkColorMatrixFilterRowMajor255.cpp
@@ -210,14 +210,15 @@ private:
if (nullptr == args.fInputColor) {
// could optimize this case, but we aren't for now.
- args.fInputColor = "vec4(1)";
+ args.fInputColor = "float4(1)";
}
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
// The max() is to guard against 0 / 0 during unpremul when the incoming color is
// transparent black.
fragBuilder->codeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n",
args.fInputColor);
- fragBuilder->codeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha) + %s;\n",
+ fragBuilder->codeAppendf("\t%s = %s * float4(%s.rgb / nonZeroAlpha, nonZeroAlpha) + "
+ "%s;\n",
args.fOutputColor,
uniformHandler->getUniformCStr(fMatrixHandle),
args.fInputColor,
diff --git a/src/core/SkNormalFlatSource.cpp b/src/core/SkNormalFlatSource.cpp
index 2879c8e4e0..1e97ca7224 100644
--- a/src/core/SkNormalFlatSource.cpp
+++ b/src/core/SkNormalFlatSource.cpp
@@ -35,7 +35,7 @@ private:
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- fragBuilder->codeAppendf("%s = vec4(0, 0, 1, 0);", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(0, 0, 1, 0);", args.fOutputColor);
}
private:
diff --git a/src/core/SkNormalMapSource.cpp b/src/core/SkNormalMapSource.cpp
index 326ce63086..d2ac97d258 100644
--- a/src/core/SkNormalMapSource.cpp
+++ b/src/core/SkNormalMapSource.cpp
@@ -58,12 +58,12 @@ private:
SkString dstNormalColorName("dstNormalColor");
this->emitChild(0, &dstNormalColorName, args);
- fragBuilder->codeAppendf("vec3 normal = normalize(%s.rgb - vec3(0.5));",
+ fragBuilder->codeAppendf("float3 normal = normalize(%s.rgb - float3(0.5));",
dstNormalColorName.c_str());
// If there's no x & y components, return (0, 0, +/- 1) instead to avoid division by 0
fragBuilder->codeAppend( "if (abs(normal.z) > 0.999) {");
- fragBuilder->codeAppendf(" %s = normalize(vec4(0.0, 0.0, normal.z, 0.0));",
+ fragBuilder->codeAppendf(" %s = normalize(float4(0.0, 0.0, normal.z, 0.0));",
args.fOutputColor);
// Else, Normalizing the transformed X and Y, while keeping constant both Z and the
// vector's angle in the XY plane. This maintains the "slope" for the surface while
@@ -71,13 +71,13 @@ private:
// Here, we call 'scaling factor' the number that must divide the transformed X and Y so
// that the normal's length remains equal to 1.
fragBuilder->codeAppend( "} else {");
- fragBuilder->codeAppendf(" vec2 transformed = %s * normal.xy;",
+ fragBuilder->codeAppendf(" float2 transformed = %s * normal.xy;",
xformUniName);
fragBuilder->codeAppend( " float scalingFactorSquared = "
"( (transformed.x * transformed.x) "
"+ (transformed.y * transformed.y) )"
"/(1.0 - (normal.z * normal.z));");
- fragBuilder->codeAppendf(" %s = vec4(transformed*inversesqrt(scalingFactorSquared),"
+ fragBuilder->codeAppendf(" %s = float4(transformed*inversesqrt(scalingFactorSquared),"
"normal.z, 0.0);",
args.fOutputColor);
fragBuilder->codeAppend( "}");
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
index 6de452bfa1..fab78cea9d 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -44,18 +44,18 @@ public:
SkSL::String sk_TransformedCoords2D_1 =
fragBuilder->ensureCoords2D(args.fTransformedCoords[1]);
fragBuilder->codeAppendf(
- "vec4 _tmpVar1;vec4 color = %stexture(%s, %s).%s%s;\nvec4 mask_color = texture(%s, "
- "%s).%s;\nif (mask_color.w < 0.5) {\n if (color.w > %s) {\n float scale "
- "= %s / color.w;\n color.xyz *= scale;\n color.w = %s;\n }\n} "
- "else if (color.w < %s) {\n float scale = %s / max(0.001, color.w);\n "
- "color.xyz *= scale;\n color.w = %s;\n}\n%s = color;\n",
+ "float4 _tmpVar1;float4 color = %stexture(%s, %s).%s%s;\nfloat4 mask_color = "
+ "texture(%s, %s).%s;\nif (mask_color.w < 0.5) {\n if (color.w > %s) {\n "
+ "float scale = %s / color.w;\n color.xyz *= scale;\n color.w = %s;\n "
+ " }\n} else if (color.w < %s) {\n float scale = %s / max(0.001, color.w);\n "
+ " color.xyz *= scale;\n color.w = %s;\n}\n%s = color;\n",
fColorSpaceHelper.isValid() ? "(_tmpVar1 = " : "",
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
sk_TransformedCoords2D_0.c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
fColorSpaceHelper.isValid()
- ? SkStringPrintf(", vec4(clamp((%s * vec4(_tmpVar1.rgb, 1.0)).rgb, 0.0, "
- "_tmpVar1.a), _tmpVar1.a))",
+ ? SkStringPrintf(", float4(clamp((%s * float4(_tmpVar1.rgb, 1.0)).rgb, "
+ "0.0, _tmpVar1.a), _tmpVar1.a))",
args.fUniformHandler->getUniformCStr(
fColorSpaceHelper.gamutXformUniform()))
.c_str()
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.fp b/src/effects/GrAlphaThresholdFragmentProcessor.fp
index 3c06dbe9d3..e930ed9a58 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.fp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.fp
@@ -53,8 +53,8 @@ in uniform float outerThreshold;
}
void main() {
- vec4 color = texture(image, sk_TransformedCoords2D[0], colorXform);
- vec4 mask_color = texture(mask, sk_TransformedCoords2D[1]);
+ float4 color = texture(image, sk_TransformedCoords2D[0], colorXform);
+ float4 mask_color = texture(mask, sk_TransformedCoords2D[1]);
if (mask_color.a < 0.5) {
if (color.a > outerThreshold) {
float scale = outerThreshold / color.a;
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index 2defcf26ca..1d281f045e 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -236,16 +236,16 @@ public:
fCircleDataVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType,
kDefault_GrSLPrecision, "circleData");
fragBuilder->codeAppendf(
- "vec2 vec = vec2((sk_FragCoord.x - %s.x) * %s.w, (sk_FragCoord.y - %s.y) * "
+ "float2 vec = float2((sk_FragCoord.x - %s.x) * %s.w, (sk_FragCoord.y - %s.y) * "
"%s.w);\nfloat dist = length(vec) + (0.5 - %s.z) * %s.w;\n%s = %s * texture(%s, "
- "vec2(dist, 0.5)).%s.w;\n",
+ "float2(dist, 0.5)).%s.w;\n",
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "vec4(1)",
+ args.fInputColor ? args.fInputColor : "float4(1)",
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
}
diff --git a/src/effects/GrCircleBlurFragmentProcessor.fp b/src/effects/GrCircleBlurFragmentProcessor.fp
index e87f365cd8..01e5426dc0 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.fp
+++ b/src/effects/GrCircleBlurFragmentProcessor.fp
@@ -1,4 +1,4 @@
-in vec4 circleRect;
+in float4 circleRect;
in float textureRadius;
in float solidRadius;
in uniform sampler2D blurProfileSampler;
@@ -7,7 +7,7 @@ in uniform sampler2D blurProfileSampler;
// x, y - the center of the circle
// z - inner radius that should map to 0th entry in the texture.
// w - the inverse of the distance over which the texture is stretched.
-uniform vec4 circleData;
+uniform float4 circleData;
@optimizationFlags {
kCompatibleWithCoverageAsAlpha_OptimizationFlag
@@ -278,10 +278,10 @@ uniform vec4 circleData;
void main() {
// We just want to compute "(length(vec) - circleData.z + 0.5) * circleData.w" but need to
// rearrange for precision.
- vec2 vec = vec2((sk_FragCoord.x - circleData.x) * circleData.w,
+ float2 vec = float2((sk_FragCoord.x - circleData.x) * circleData.w,
(sk_FragCoord.y - circleData.y) * circleData.w);
float dist = length(vec) + (0.5 - circleData.z) * circleData.w;
- sk_OutColor = sk_InColor * texture(blurProfileSampler, vec2(dist, 0.5)).a;
+ sk_OutColor = sk_InColor * texture(blurProfileSampler, float2(dist, 0.5)).a;
}
@test(testData) {
diff --git a/src/effects/SkArithmeticImageFilter.cpp b/src/effects/SkArithmeticImageFilter.cpp
index 2e61c45f76..6c6d6070c5 100644
--- a/src/effects/SkArithmeticImageFilter.cpp
+++ b/src/effects/SkArithmeticImageFilter.cpp
@@ -254,12 +254,12 @@ private:
// We don't try to optimize for this case at all
if (!args.fInputColor) {
- fragBuilder->codeAppend("const vec4 src = vec4(1);");
+ fragBuilder->codeAppend("const float4 src = float4(1);");
} else {
- fragBuilder->codeAppendf("vec4 src = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 src = %s;", args.fInputColor);
}
- fragBuilder->codeAppendf("vec4 dst = %s;", dstColor.c_str());
+ fragBuilder->codeAppendf("float4 dst = %s;", dstColor.c_str());
fragBuilder->codeAppendf("%s = %s.x * src * dst + %s.y * src + %s.z * dst + %s.w;",
args.fOutputColor, kUni, kUni, kUni, kUni);
fragBuilder->codeAppendf("%s = clamp(%s, 0.0, 1.0);\n", args.fOutputColor,
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 9ecedbd53e..f927cc7470 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -867,7 +867,7 @@ void OutputRectBlurProfileLookup(GrGLSLFPFragmentBuilder* fragBuilder,
fragBuilder->codeAppendf("float coord = ((abs(%s - 0.5 * %s) - 0.5 * %s)) / %s;",
loc, blurred_width, sharp_width, profileSize);
fragBuilder->codeAppendf("%s = ", output);
- fragBuilder->appendTextureLookup(sampler, "vec2(coord,0.5)");
+ fragBuilder->appendTextureLookup(sampler, "float2(coord,0.5)");
fragBuilder->codeAppend(".a;");
fragBuilder->codeAppendf("}");
}
@@ -907,23 +907,23 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
if (args.fInputColor) {
- fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 src=%s;", args.fInputColor);
} else {
- fragBuilder->codeAppendf("vec4 src=vec4(1);");
+ fragBuilder->codeAppendf("float4 src=float4(1);");
}
- fragBuilder->codeAppendf("%s vec2 translatedPos = sk_FragCoord.xy - %s.xy;",
+ fragBuilder->codeAppendf("%s float2 translatedPos = sk_FragCoord.xy - %s.xy;",
precisionString.c_str(), rectName);
fragBuilder->codeAppendf("%s float width = %s.z - %s.x;", precisionString.c_str(), rectName,
rectName);
fragBuilder->codeAppendf("%s float height = %s.w - %s.y;", precisionString.c_str(), rectName,
rectName);
- fragBuilder->codeAppendf("%s vec2 smallDims = vec2(width - %s, height - %s);",
+ fragBuilder->codeAppendf("%s float2 smallDims = float2(width - %s, height - %s);",
precisionString.c_str(), profileSizeName, profileSizeName);
fragBuilder->codeAppendf("%s float center = 2.0 * floor(%s/2.0 + .25) - 1.0;",
precisionString.c_str(), profileSizeName);
- fragBuilder->codeAppendf("%s vec2 wh = smallDims - vec2(center,center);",
+ fragBuilder->codeAppendf("%s float2 wh = smallDims - float2(center,center);",
precisionString.c_str());
OutputRectBlurProfileLookup(fragBuilder, args.fTexSamplers[0], "horiz_lookup", profileSizeName,
@@ -1296,10 +1296,10 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) {
// warp the fragment position to the appropriate part of the 9patch blur texture
- fragBuilder->codeAppendf("vec2 rectCenter = (%s.xy + %s.zw)/2.0;", rectName, rectName);
- fragBuilder->codeAppendf("vec2 translatedFragPos = sk_FragCoord.xy - %s.xy;", rectName);
+ fragBuilder->codeAppendf("float2 rectCenter = (%s.xy + %s.zw)/2.0;", rectName, rectName);
+ fragBuilder->codeAppendf("float2 translatedFragPos = sk_FragCoord.xy - %s.xy;", rectName);
fragBuilder->codeAppendf("float threshold = %s + 2.0*%s;", cornerRadiusName, blurRadiusName);
- fragBuilder->codeAppendf("vec2 middle = %s.zw - %s.xy - 2.0*threshold;", rectName, rectName);
+ fragBuilder->codeAppendf("float2 middle = %s.zw - %s.xy - 2.0*threshold;", rectName, rectName);
fragBuilder->codeAppendf(
"if (translatedFragPos.x >= threshold && translatedFragPos.x < (middle.x+threshold)) {");
@@ -1315,8 +1315,8 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("translatedFragPos.y -= middle.y - 1.0;");
fragBuilder->codeAppendf("}");
- fragBuilder->codeAppendf("vec2 proxyDims = vec2(2.0*threshold+1.0);");
- fragBuilder->codeAppendf("vec2 texCoord = translatedFragPos / proxyDims;");
+ fragBuilder->codeAppendf("float2 proxyDims = float2(2.0*threshold+1.0);");
+ fragBuilder->codeAppendf("float2 texCoord = translatedFragPos / proxyDims;");
fragBuilder->codeAppendf("%s = ", args.fOutputColor);
fragBuilder->appendTextureLookupAndModulate(args.fInputColor, args.fTexSamplers[0], "texCoord");
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 6a7378b6d4..626ff9f8b6 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -566,17 +566,17 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
fColorSpaceHelper.emitCode(args.fUniformHandler, displacementMap.colorSpaceXform());
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- fragBuilder->codeAppendf("\t\tvec4 %s = ", dColor);
+ fragBuilder->codeAppendf("\t\tfloat4 %s = ", dColor);
fragBuilder->appendTextureLookup(args.fTexSamplers[0], args.fTransformedCoords[0].c_str(),
args.fTransformedCoords[0].getType());
fragBuilder->codeAppend(";\n");
// Unpremultiply the displacement
fragBuilder->codeAppendf(
- "\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
+ "\t\t%s.rgb = (%s.a < %s) ? float3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
dColor, dColor, nearZero, dColor, dColor);
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[1]);
- fragBuilder->codeAppendf("\t\tvec2 %s = %s + %s*(%s.",
+ fragBuilder->codeAppendf("\t\tfloat2 %s = %s + %s*(%s.",
cCoords, coords2D.c_str(), scaleUni, dColor);
switch (displacementMap.xChannelSelector()) {
@@ -614,7 +614,7 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
default:
SkDEBUGFAIL("Unknown Y channel selector");
}
- fragBuilder->codeAppend("-vec2(0.5));\t\t");
+ fragBuilder->codeAppend("-float2(0.5));\t\t");
fGLDomain.sampleTexture(fragBuilder,
args.fUniformHandler,
diff --git a/src/effects/SkHighContrastFilter.cpp b/src/effects/SkHighContrastFilter.cpp
index 563cdefd73..6d9853e556 100644
--- a/src/effects/SkHighContrastFilter.cpp
+++ b/src/effects/SkHighContrastFilter.cpp
@@ -251,26 +251,26 @@ void GLHighContrastFilterEffect::emitCode(EmitArgs& args) {
"contrast", &contrast);
if (nullptr == args.fInputColor) {
- args.fInputColor = "vec4(1)";
+ args.fInputColor = "float4(1)";
}
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- fragBuilder->codeAppendf("vec4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = %s;", args.fInputColor);
// Unpremultiply. The max() is to guard against 0 / 0.
fragBuilder->codeAppendf("float nonZeroAlpha = max(color.a, 0.00001);");
- fragBuilder->codeAppendf("color = vec4(color.rgb / nonZeroAlpha, nonZeroAlpha);");
+ fragBuilder->codeAppendf("color = float4(color.rgb / nonZeroAlpha, nonZeroAlpha);");
// Grayscale.
if (fConfig.fGrayscale) {
- fragBuilder->codeAppendf("float luma = dot(color, vec4(%f, %f, %f, 0));",
+ fragBuilder->codeAppendf("float luma = dot(color, float4(%f, %f, %f, 0));",
SK_LUM_COEFF_R, SK_LUM_COEFF_G, SK_LUM_COEFF_B);
- fragBuilder->codeAppendf("color = vec4(luma, luma, luma, 0);");
+ fragBuilder->codeAppendf("color = float4(luma, luma, luma, 0);");
}
if (fConfig.fInvertStyle == InvertStyle::kInvertBrightness) {
- fragBuilder->codeAppendf("color = vec4(1, 1, 1, 1) - color;");
+ fragBuilder->codeAppendf("color = float4(1, 1, 1, 1) - color;");
}
if (fConfig.fInvertStyle == InvertStyle::kInvertLightness) {
@@ -325,7 +325,7 @@ void GLHighContrastFilterEffect::emitCode(EmitArgs& args) {
"return p;",
&hue2rgbFuncName);
fragBuilder->codeAppendf("if (s == 0) {");
- fragBuilder->codeAppendf(" color = vec4(l, l, l, 0);");
+ fragBuilder->codeAppendf(" color = float4(l, l, l, 0);");
fragBuilder->codeAppendf("} else {");
fragBuilder->codeAppendf(" float q = l < 0.5 ? l * (1 + s) : l + s - l * s;");
fragBuilder->codeAppendf(" float p = 2 * l - q;");
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index aee77ae5dd..817f96fd15 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -1863,7 +1863,7 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
"pointToNormal",
SK_ARRAY_COUNT(gPointToNormalArgs),
gPointToNormalArgs,
- "\treturn normalize(vec3(-x * scale, -y * scale, 1));\n",
+ "\treturn normalize(float3(-x * scale, -y * scale, 1));\n",
&pointToNormalName);
static const GrShaderVar gInteriorNormalArgs[] = {
@@ -1881,7 +1881,7 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
normalBody.c_str(),
&normalName);
- fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
+ fragBuilder->codeAppendf("\t\tfloat2 coord = %s;\n", coords2D.c_str());
fragBuilder->codeAppend("\t\tfloat m[9];\n");
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
@@ -1891,10 +1891,10 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
for (int dy = 1; dy >= -1; dy--) {
for (int dx = -1; dx <= 1; dx++) {
SkString texCoords;
- texCoords.appendf("coord + vec2(%d, %d) * %s", dx, dy, imgInc);
+ texCoords.appendf("coord + float2(%d, %d) * %s", dx, dy, imgInc);
SkString temp;
temp.appendf("temp%d", index);
- fragBuilder->codeAppendf("vec4 %s;", temp.c_str());
+ fragBuilder->codeAppendf("float4 %s;", temp.c_str());
fDomain.sampleTexture(fragBuilder,
args.fUniformHandler,
args.fShaderCaps,
@@ -1906,7 +1906,7 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
index++;
}
}
- fragBuilder->codeAppend("\t\tvec3 surfaceToLight = ");
+ fragBuilder->codeAppend("\t\tfloat3 surfaceToLight = ");
SkString arg;
arg.appendf("%s * m[4]", surfScale);
fLight->emitSurfaceToLight(uniformHandler, fragBuilder, arg.c_str());
@@ -1963,7 +1963,7 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHandl
};
SkString lightBody;
lightBody.appendf("\tfloat colorScale = %s * dot(normal, surfaceToLight);\n", kd);
- lightBody.appendf("\treturn vec4(lightColor * clamp(colorScale, 0.0, 1.0), 1.0);\n");
+ lightBody.appendf("\treturn float4(lightColor * clamp(colorScale, 0.0, 1.0), 1.0);\n");
fragBuilder->emitFunction(kVec4f_GrSLType,
"light",
SK_ARRAY_COUNT(gLightArgs),
@@ -2064,11 +2064,11 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHand
GrShaderVar("lightColor", kVec3f_GrSLType)
};
SkString lightBody;
- lightBody.appendf("\tvec3 halfDir = vec3(normalize(surfaceToLight + vec3(0, 0, 1)));\n");
+ lightBody.appendf("\tfloat3 halfDir = float3(normalize(surfaceToLight + float3(0, 0, 1)));\n");
lightBody.appendf("\thighp float colorScale = %s * pow(dot(normal, halfDir), %s);\n",
ks, shininess);
- lightBody.appendf("\tvec3 color = lightColor * clamp(colorScale, 0.0, 1.0);\n");
- lightBody.appendf("\treturn vec4(color, max(max(color.r, color.g), color.b));\n");
+ lightBody.appendf("\tfloat3 color = lightColor * clamp(colorScale, 0.0, 1.0);\n");
+ lightBody.appendf("\treturn float4(color, max(max(color.r, color.g), color.b));\n");
fragBuilder->emitFunction(kVec4f_GrSLType,
"light",
SK_ARRAY_COUNT(gLightArgs),
@@ -2141,7 +2141,7 @@ void GrGLPointLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
fLocationUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
kVec3f_GrSLType, kDefault_GrSLPrecision,
"LightLocation", &loc);
- fragBuilder->codeAppendf("normalize(%s - vec3(sk_FragCoord.xy, %s))",
+ fragBuilder->codeAppendf("normalize(%s - float3(sk_FragCoord.xy, %s))",
loc, z);
}
@@ -2168,7 +2168,7 @@ void GrGLSpotLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
kVec3f_GrSLType, kDefault_GrSLPrecision,
"LightLocation", &location);
- fragBuilder->codeAppendf("normalize(%s - vec3(sk_FragCoord.xy, %s))",
+ fragBuilder->codeAppendf("normalize(%s - float3(sk_FragCoord.xy, %s))",
location, z);
}
@@ -2204,7 +2204,7 @@ void GrGLSpotLight::emitLightColor(GrGLSLUniformHandler* uniformHandler,
SkString lightColorBody;
lightColorBody.appendf("\tfloat cosAngle = -dot(surfaceToLight, %s);\n", s);
lightColorBody.appendf("\tif (cosAngle < %s) {\n", cosOuter);
- lightColorBody.appendf("\t\treturn vec3(0);\n");
+ lightColorBody.appendf("\t\treturn float3(0);\n");
lightColorBody.appendf("\t}\n");
lightColorBody.appendf("\tfloat scale = pow(cosAngle, %s);\n", exponent);
lightColorBody.appendf("\tif (cosAngle < %s) {\n", cosInner);
diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp
index fd958c3a8b..2a065b3720 100644
--- a/src/effects/SkLumaColorFilter.cpp
+++ b/src/effects/SkLumaColorFilter.cpp
@@ -60,16 +60,16 @@ private:
void emitCode(EmitArgs& args) override {
if (nullptr == args.fInputColor) {
- args.fInputColor = "vec4(1)";
+ args.fInputColor = "float4(1)";
}
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- fragBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb);\n",
+ fragBuilder->codeAppendf("\tfloat luma = dot(float3(%f, %f, %f), %s.rgb);\n",
SK_ITU_BT709_LUM_COEFF_R,
SK_ITU_BT709_LUM_COEFF_G,
SK_ITU_BT709_LUM_COEFF_B,
args.fInputColor);
- fragBuilder->codeAppendf("\t%s = vec4(0, 0, 0, luma);\n",
+ fragBuilder->codeAppendf("\t%s = float4(0, 0, 0, luma);\n",
args.fOutputColor);
}
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index e640697610..7b03307264 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -199,30 +199,30 @@ void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
- fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
- fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n",
+ fragBuilder->codeAppendf("\t\tfloat2 coord = %s;\n", coords2D.c_str());
+ fragBuilder->codeAppendf("\t\tfloat2 zoom_coord = %s + %s * %s;\n",
uniformHandler->getUniformCStr(fOffsetVar),
coords2D.c_str(),
uniformHandler->getUniformCStr(fInvZoomVar));
const char* bounds = uniformHandler->getUniformCStr(fBoundsVar);
- fragBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", bounds, bounds);
- fragBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n");
+ fragBuilder->codeAppendf("\t\tfloat2 delta = (coord - %s.xy) * %s.zw;\n", bounds, bounds);
+ fragBuilder->codeAppendf("\t\tdelta = min(delta, float2(1.0, 1.0) - delta);\n");
fragBuilder->codeAppendf("\t\tdelta = delta * %s;\n",
uniformHandler->getUniformCStr(fInvInsetVar));
fragBuilder->codeAppend("\t\tfloat weight = 0.0;\n");
fragBuilder->codeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n");
- fragBuilder->codeAppend("\t\t\tdelta = vec2(2.0, 2.0) - delta;\n");
+ fragBuilder->codeAppend("\t\t\tdelta = float2(2.0, 2.0) - delta;\n");
fragBuilder->codeAppend("\t\t\tfloat dist = length(delta);\n");
fragBuilder->codeAppend("\t\t\tdist = max(2.0 - dist, 0.0);\n");
fragBuilder->codeAppend("\t\t\tweight = min(dist * dist, 1.0);\n");
fragBuilder->codeAppend("\t\t} else {\n");
- fragBuilder->codeAppend("\t\t\tvec2 delta_squared = delta * delta;\n");
+ fragBuilder->codeAppend("\t\t\tfloat2 delta_squared = delta * delta;\n");
fragBuilder->codeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squared.y), 1.0);\n");
fragBuilder->codeAppend("\t\t}\n");
- fragBuilder->codeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n");
- fragBuilder->codeAppend("\t\tvec4 output_color = ");
+ fragBuilder->codeAppend("\t\tfloat2 mix_coord = mix(coord, zoom_coord, weight);\n");
+ fragBuilder->codeAppend("\t\tfloat4 output_color = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0], "mix_coord", kVec2f_GrSLType,
&fColorSpaceHelper);
fragBuilder->codeAppend(";\n");
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 19481acb19..a29bca31e6 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -226,11 +226,11 @@ void GrGLMorphologyEffect::emitCode(EmitArgs& args) {
const char* func;
switch (me.type()) {
case GrMorphologyEffect::Type::kErode:
- fragBuilder->codeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", args.fOutputColor);
+ fragBuilder->codeAppendf("\t\t%s = float4(1, 1, 1, 1);\n", args.fOutputColor);
func = "min";
break;
case GrMorphologyEffect::Type::kDilate:
- fragBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", args.fOutputColor);
+ fragBuilder->codeAppendf("\t\t%s = float4(0, 0, 0, 0);\n", args.fOutputColor);
func = "max";
break;
default:
@@ -254,8 +254,8 @@ void GrGLMorphologyEffect::emitCode(EmitArgs& args) {
int width = me.width();
- // vec2 coord = coord2D;
- fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
+ // float2 coord = coord2D;
+ fragBuilder->codeAppendf("\t\tfloat2 coord = %s;\n", coords2D.c_str());
// coord.x -= radius * pixelSize;
fragBuilder->codeAppendf("\t\tcoord.%s -= %d.0 * %s; \n", dir, me.radius(), pixelSizeInc);
if (me.useRange()) {
diff --git a/src/effects/SkOverdrawColorFilter.cpp b/src/effects/SkOverdrawColorFilter.cpp
index b81fe6ca94..1fcd14fe27 100644
--- a/src/effects/SkOverdrawColorFilter.cpp
+++ b/src/effects/SkOverdrawColorFilter.cpp
@@ -150,7 +150,7 @@ GLOverdrawFragmentProcessor::GLOverdrawFragmentProcessor(const GrColor4f* colors
void GLOverdrawFragmentProcessor::emitCode(EmitArgs& args) {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
if (nullptr == args.fInputColor) {
- fragBuilder->codeAppendf("%s.rgba = vec4(%f, %f, %f, %f);", args.fOutputColor,
+ fragBuilder->codeAppendf("%s.rgba = float4(%f, %f, %f, %f);", args.fOutputColor,
fColors[5].fRGBA[0],
fColors[5].fRGBA[1],
fColors[5].fRGBA[2],
@@ -158,37 +158,37 @@ void GLOverdrawFragmentProcessor::emitCode(EmitArgs& args) {
} else {
fragBuilder->codeAppendf("float alpha = 255.0 * %s.a;", args.fInputColor);
fragBuilder->codeAppendf("if (alpha < 0.5) {");
- fragBuilder->codeAppendf(" %s.rgba = vec4(%f, %f, %f, %f);", args.fOutputColor,
+ fragBuilder->codeAppendf(" %s.rgba = float4(%f, %f, %f, %f);", args.fOutputColor,
fColors[0].fRGBA[0],
fColors[0].fRGBA[1],
fColors[0].fRGBA[2],
fColors[0].fRGBA[3]);
fragBuilder->codeAppendf("} else if (alpha < 1.5) {");
- fragBuilder->codeAppendf(" %s.rgba = vec4(%f, %f, %f, %f);", args.fOutputColor,
+ fragBuilder->codeAppendf(" %s.rgba = float4(%f, %f, %f, %f);", args.fOutputColor,
fColors[1].fRGBA[0],
fColors[1].fRGBA[1],
fColors[1].fRGBA[2],
fColors[1].fRGBA[3]);
fragBuilder->codeAppendf("} else if (alpha < 2.5) {");
- fragBuilder->codeAppendf(" %s.rgba = vec4(%f, %f, %f, %f);", args.fOutputColor,
+ fragBuilder->codeAppendf(" %s.rgba = float4(%f, %f, %f, %f);", args.fOutputColor,
fColors[2].fRGBA[0],
fColors[2].fRGBA[1],
fColors[2].fRGBA[2],
fColors[2].fRGBA[3]);
fragBuilder->codeAppendf("} else if (alpha < 3.5) {");
- fragBuilder->codeAppendf(" %s.rgba = vec4(%f, %f, %f, %f);", args.fOutputColor,
+ fragBuilder->codeAppendf(" %s.rgba = float4(%f, %f, %f, %f);", args.fOutputColor,
fColors[3].fRGBA[0],
fColors[3].fRGBA[1],
fColors[3].fRGBA[2],
fColors[3].fRGBA[3]);
fragBuilder->codeAppendf("} else if (alpha < 4.5) {");
- fragBuilder->codeAppendf(" %s.rgba = vec4(%f, %f, %f, %f);", args.fOutputColor,
+ fragBuilder->codeAppendf(" %s.rgba = float4(%f, %f, %f, %f);", args.fOutputColor,
fColors[4].fRGBA[0],
fColors[4].fRGBA[1],
fColors[4].fRGBA[2],
fColors[4].fRGBA[3]);
fragBuilder->codeAppendf("} else {");
- fragBuilder->codeAppendf(" %s.rgba = vec4(%f, %f, %f, %f);", args.fOutputColor,
+ fragBuilder->codeAppendf(" %s.rgba = float4(%f, %f, %f, %f);", args.fOutputColor,
fColors[5].fRGBA[0],
fColors[5].fRGBA[1],
fColors[5].fRGBA[2],
diff --git a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
index 98422902d6..8b1856a14a 100644
--- a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
+++ b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp
@@ -240,7 +240,7 @@ private:
// Positive distance is towards the center of the circle.
// Map all the cases to the lower right quadrant.
- fragBuilder->codeAppendf("vec2 delta = abs(sk_FragCoord.xy - %s.%s);",
+ fragBuilder->codeAppendf("float2 delta = abs(sk_FragCoord.xy - %s.%s);",
posName, indices);
switch (mode) {
@@ -254,7 +254,7 @@ private:
break;
case kRect_Mode:
fragBuilder->codeAppendf(
- "vec2 rectDist = vec2(1.0 - clamp((%s.%c - delta.x)/%s, 0.0, 1.0),"
+ "float2 rectDist = float2(1.0 - clamp((%s.%c - delta.x)/%s, 0.0, 1.0),"
"1.0 - clamp((%s.%c - delta.y)/%s, 0.0, 1.0));",
sizesName, indices[0], radName,
sizesName, indices[1], radName);
@@ -293,20 +293,20 @@ private:
// size of the RRect. In that case we don't want to go all the way to black.
fragBuilder->codeAppendf("float maxValue = insetDist/%s;", radName);
- fragBuilder->codeAppendf("vec2 coneBottom = vec2(%s.%c - insetDist,"
+ fragBuilder->codeAppendf("float2 coneBottom = float2(%s.%c - insetDist,"
"%s.%c - insetDist);",
sizesName, indices[0], sizesName, indices[1]);
- fragBuilder->codeAppendf("vec2 cornerTop = vec2(%s.%c - %s.%c, %s.%c) -"
+ fragBuilder->codeAppendf("float2 cornerTop = float2(%s.%c - %s.%c, %s.%c) -"
"coneBottom;",
sizesName, indices[0], radiiName, indices[0],
sizesName, indices[1]);
- fragBuilder->codeAppendf("vec2 cornerRight = vec2(%s.%c, %s.%c - %s.%c) -"
+ fragBuilder->codeAppendf("float2 cornerRight = float2(%s.%c, %s.%c - %s.%c) -"
"coneBottom;",
sizesName, indices[0],
sizesName, indices[1], radiiName, indices[1]);
- fragBuilder->codeAppend("vec2 ptInConeSpace = delta - coneBottom;");
+ fragBuilder->codeAppend("float2 ptInConeSpace = delta - coneBottom;");
fragBuilder->codeAppend("float distToPtInConeSpace = length(ptInConeSpace);");
fragBuilder->codeAppend("float cross1 = ptInConeSpace.x * cornerTop.y -"
@@ -317,11 +317,11 @@ private:
fragBuilder->codeAppend("float inCone = step(0.0, cross1) *"
"step(0.0, cross2);");
- fragBuilder->codeAppendf("vec2 cornerCenterInConeSpace = vec2(insetDist -"
+ fragBuilder->codeAppendf("float2 cornerCenterInConeSpace = float2(insetDist -"
"%s.%c);",
radiiName, indices[0]);
- fragBuilder->codeAppend("vec2 connectingVec = ptInConeSpace -"
+ fragBuilder->codeAppend("float2 connectingVec = ptInConeSpace -"
"cornerCenterInConeSpace;");
fragBuilder->codeAppend("ptInConeSpace = normalize(ptInConeSpace);");
@@ -389,7 +389,7 @@ private:
radUniName, "secondDist", "zw");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppend("vec2 distVec = vec2(1.0 - firstDist, 1.0 - secondDist);");
+ fragBuilder->codeAppend("float2 distVec = float2(1.0 - firstDist, 1.0 - secondDist);");
// Finally use the distance to apply the Gaussian edge
fragBuilder->codeAppend("float factor = clamp(length(distVec), 0.0, 1.0);");
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 6472ccbc8d..0fb91094f9 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -404,14 +404,14 @@ void GLColorTableEffect::emitCode(EmitArgs& args) {
if (nullptr == args.fInputColor) {
// the input color is solid white (all ones).
static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor;
- fragBuilder->codeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n",
+ fragBuilder->codeAppendf("\t\tfloat4 coord = float4(%f, %f, %f, %f);\n",
kMaxValue, kMaxValue, kMaxValue, kMaxValue);
} else {
fragBuilder->codeAppendf("\t\tfloat nonZeroAlpha = max(%s.a, .0001);\n", args.fInputColor);
- fragBuilder->codeAppendf("\t\tvec4 coord = vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha);\n",
+ fragBuilder->codeAppendf("\t\tfloat4 coord = float4(%s.rgb / nonZeroAlpha, nonZeroAlpha);\n",
args.fInputColor);
- fragBuilder->codeAppendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n",
+ fragBuilder->codeAppendf("\t\tcoord = coord * %f + float4(%f, %f, %f, %f);\n",
kColorScaleFactor,
kColorOffsetFactor, kColorOffsetFactor,
kColorOffsetFactor, kColorOffsetFactor);
@@ -420,22 +420,22 @@ void GLColorTableEffect::emitCode(EmitArgs& args) {
SkString coord;
fragBuilder->codeAppendf("\t\t%s.a = ", args.fOutputColor);
- coord.printf("vec2(coord.a, %s.a)", yoffsets);
+ coord.printf("float2(coord.a, %s.a)", yoffsets);
fragBuilder->appendTextureLookup(args.fTexSamplers[0], coord.c_str());
fragBuilder->codeAppend(".a;\n");
fragBuilder->codeAppendf("\t\t%s.r = ", args.fOutputColor);
- coord.printf("vec2(coord.r, %s.r)", yoffsets);
+ coord.printf("float2(coord.r, %s.r)", yoffsets);
fragBuilder->appendTextureLookup(args.fTexSamplers[0], coord.c_str());
fragBuilder->codeAppend(".a;\n");
fragBuilder->codeAppendf("\t\t%s.g = ", args.fOutputColor);
- coord.printf("vec2(coord.g, %s.g)", yoffsets);
+ coord.printf("float2(coord.g, %s.g)", yoffsets);
fragBuilder->appendTextureLookup(args.fTexSamplers[0], coord.c_str());
fragBuilder->codeAppend(".a;\n");
fragBuilder->codeAppendf("\t\t%s.b = ", args.fOutputColor);
- coord.printf("vec2(coord.b, %s.b)", yoffsets);
+ coord.printf("float2(coord.b, %s.b)", yoffsets);
fragBuilder->appendTextureLookup(args.fTexSamplers[0], coord.c_str());
fragBuilder->codeAppend(".a;\n");
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index ec79053788..c94c47aeb3 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -86,7 +86,7 @@ public:
varyingHandler->addVarying("color", &varying);
// There are several optional steps to process the color. Start with the attribute:
- vertBuilder->codeAppendf("vec4 color = %s;", gp.inColor()->fName);
+ vertBuilder->codeAppendf("float4 color = %s;", gp.inColor()->fName);
// Linearize
if (gp.linearizeColor()) {
@@ -101,7 +101,7 @@ public:
"return (x <= 0.04045) ? (x / 12.92) "
": pow((x + 0.055) / 1.055, 2.4);",
&srgbFuncName);
- vertBuilder->codeAppendf("color = vec4(%s(%s.r), %s(%s.g), %s(%s.b), %s.a);",
+ vertBuilder->codeAppendf("color = float4(%s(%s.r), %s(%s.g), %s(%s.b), %s.a);",
srgbFuncName.c_str(), gp.inColor()->fName,
srgbFuncName.c_str(), gp.inColor()->fName,
srgbFuncName.c_str(), gp.inColor()->fName,
@@ -110,7 +110,7 @@ public:
// For SkColor, do a red/blue swap and premul
if (gp.fFlags & kColorAttributeIsSkColor_GPFlag) {
- vertBuilder->codeAppend("color = vec4(color.a * color.bgr, color.a);");
+ vertBuilder->codeAppend("color = float4(color.a * color.bgr, color.a);");
}
// Do color-correction to destination gamut
@@ -163,9 +163,9 @@ public:
if (gp.hasVertexCoverage()) {
fragBuilder->codeAppendf("float alpha = 1.0;");
varyingHandler->addPassThroughAttribute(gp.inCoverage(), "alpha");
- fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(alpha);", args.fOutputCoverage);
} else if (gp.coverage() == 0xff) {
- fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
} else {
const char* fragCoverage;
fCoverageUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
@@ -173,7 +173,7 @@ public:
kDefault_GrSLPrecision,
"Coverage",
&fragCoverage);
- fragBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, fragCoverage);
+ fragBuilder->codeAppendf("%s = float4(%s);", args.fOutputCoverage, fragCoverage);
}
}
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 78319c7a7a..9c608086dd 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -18,7 +18,7 @@ class GrProcessorKeyBuilder;
class GrShaderCaps;
class GrSwizzle;
-/** Provides custom fragment shader code. Fragment processors receive an input color (vec4f) and
+/** Provides custom fragment shader code. Fragment processors receive an input color (float4) and
produce an output color. They may reference textures and uniforms. They may use
GrCoordTransforms to receive a transformation of the local coordinates that map from local space
to the fragment being processed.
diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp
index 39d418ba6b..42668bcf16 100644
--- a/src/gpu/GrPathProcessor.cpp
+++ b/src/gpu/GrPathProcessor.cpp
@@ -44,7 +44,7 @@ public:
fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, stagedLocalVarName);
// setup constant solid coverage
- fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
}
void emitTransforms(GrGLSLVaryingHandler* varyingHandler,
diff --git a/src/gpu/GrTextureStripAtlas.h b/src/gpu/GrTextureStripAtlas.h
index 8957aa305a..a67438bbe7 100644
--- a/src/gpu/GrTextureStripAtlas.h
+++ b/src/gpu/GrTextureStripAtlas.h
@@ -65,11 +65,11 @@ public:
*
* If a regular texture access without using the atlas looks like:
*
- * texture2D(sampler, vec2(x, y))
+ * texture2D(sampler, float2(x, y))
*
* Then when using the atlas we'd replace it with:
*
- * texture2D(sampler, vec2(x, yOffset + y * scaleFactor))
+ * texture2D(sampler, float2(x, yOffset + y * scaleFactor))
*
* Where yOffset, returned by getYOffset(), is the offset to the start of the row within the
* atlas and scaleFactor, returned by getNormalizedTexelHeight, is the normalized height of
diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
index 85b989b25f..332a64c664 100644
--- a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp
@@ -122,7 +122,8 @@ void PrimitiveProcessor::emitVertexShader(const GrCCPRCoverageProcessor& proc,
const TexelBufferHandle& pointsBuffer,
const char* rtAdjust, GrGPArgs* gpArgs) const {
v->codeAppendf("int packedoffset = %s.w;", proc.instanceAttrib());
- v->codeAppend ("highp vec2 atlasoffset = vec2((packedoffset<<16) >> 16, packedoffset >> 16);");
+ v->codeAppend ("highp float2 atlasoffset = float2((packedoffset<<16) >> 16, "
+ "packedoffset >> 16);");
this->onEmitVertexShader(proc, v, pointsBuffer, "atlasoffset", rtAdjust, gpArgs);
}
@@ -150,12 +151,12 @@ void PrimitiveProcessor::emitGeometryShader(const GrCCPRCoverageProcessor& proc,
fnBody.appendf("%s = %s * %s;",
fFragCoverageTimesWind.gsOut(), coverage, fGeomWind.c_str());
}
- fnBody.append ("gl_Position = vec4(position, 0, 1);");
+ fnBody.append ("gl_Position = float4(position, 0, 1);");
fnBody.append ("EmitVertex();");
return fnBody;
}().c_str(), &emitVertexFn);
- g->codeAppendf("highp vec2 bloat = %f * abs(%s.xz);", kAABloatRadius, rtAdjust);
+ g->codeAppendf("highp float2 bloat = %f * abs(%s.xz);", kAABloatRadius, rtAdjust);
#ifdef SK_DEBUG
if (proc.debugVisualizations()) {
@@ -172,7 +173,7 @@ int PrimitiveProcessor::emitHullGeometry(GrGLSLGeometryBuilder* g, const char* e
SkASSERT(numSides >= 3);
if (!insetPts) {
- g->codeAppendf("highp vec2 centroidpt = %s * vec%i(%f);",
+ g->codeAppendf("highp float2 centroidpt = %s * float%i(%f);",
polygonPts, numSides, 1.0 / numSides);
}
@@ -180,44 +181,44 @@ int PrimitiveProcessor::emitHullGeometry(GrGLSLGeometryBuilder* g, const char* e
"nextidx = (%s + 1) %% %i;",
wedgeIdx, numSides - 1, numSides, wedgeIdx, numSides);
- g->codeAppendf("highp vec2 self = %s[%s];"
+ g->codeAppendf("highp float2 self = %s[%s];"
"highp int leftidx = %s > 0 ? previdx : nextidx;"
"highp int rightidx = %s > 0 ? nextidx : previdx;",
polygonPts, wedgeIdx, fGeomWind.c_str(), fGeomWind.c_str());
// Which quadrant does the vector from self -> right fall into?
- g->codeAppendf("highp vec2 right = %s[rightidx];", polygonPts);
+ g->codeAppendf("highp float2 right = %s[rightidx];", polygonPts);
if (3 == numSides) {
// TODO: evaluate perf gains.
- g->codeAppend ("highp vec2 qsr = sign(right - self);");
+ g->codeAppend ("highp float2 qsr = sign(right - self);");
} else {
SkASSERT(4 == numSides);
- g->codeAppendf("highp vec2 diag = %s[(%s + 2) %% 4];", polygonPts, wedgeIdx);
- g->codeAppend ("highp vec2 qsr = sign((right != self ? right : diag) - self);");
+ g->codeAppendf("highp float2 diag = %s[(%s + 2) %% 4];", polygonPts, wedgeIdx);
+ g->codeAppend ("highp float2 qsr = sign((right != self ? right : diag) - self);");
}
// Which quadrant does the vector from left -> self fall into?
- g->codeAppendf("highp vec2 qls = sign(self - %s[leftidx]);", polygonPts);
+ g->codeAppendf("highp float2 qls = sign(self - %s[leftidx]);", polygonPts);
// d2 just helps us reduce triangle counts with orthogonal, axis-aligned lines.
// TODO: evaluate perf gains.
const char* dr2 = "dr";
if (3 == numSides) {
// TODO: evaluate perf gains.
- g->codeAppend ("highp vec2 dr = vec2(qsr.y != 0 ? +qsr.y : +qsr.x, "
+ g->codeAppend ("highp float2 dr = float2(qsr.y != 0 ? +qsr.y : +qsr.x, "
"qsr.x != 0 ? -qsr.x : +qsr.y);");
- g->codeAppend ("highp vec2 dr2 = vec2(qsr.y != 0 ? +qsr.y : -qsr.x, "
+ g->codeAppend ("highp float2 dr2 = float2(qsr.y != 0 ? +qsr.y : -qsr.x, "
"qsr.x != 0 ? -qsr.x : -qsr.y);");
- g->codeAppend ("highp vec2 dl = vec2(qls.y != 0 ? +qls.y : +qls.x, "
+ g->codeAppend ("highp float2 dl = float2(qls.y != 0 ? +qls.y : +qls.x, "
"qls.x != 0 ? -qls.x : +qls.y);");
dr2 = "dr2";
} else {
- g->codeAppend ("highp vec2 dr = vec2(qsr.y != 0 ? +qsr.y : 1, "
+ g->codeAppend ("highp float2 dr = float2(qsr.y != 0 ? +qsr.y : 1, "
"qsr.x != 0 ? -qsr.x : 1);");
- g->codeAppend ("highp vec2 dl = (qls == vec2(0)) ? dr : vec2(qls.y != 0 ? +qls.y : 1, "
- "qls.x != 0 ? -qls.x : 1);");
+ g->codeAppend ("highp float2 dl = (qls == float2(0)) ? dr : "
+ "float2(qls.y != 0 ? +qls.y : 1, qls.x != 0 ? -qls.x : 1);");
}
- g->codeAppendf("bvec2 dnotequal = notEqual(%s, dl);", dr2);
+ g->codeAppendf("bool2 dnotequal = notEqual(%s, dl);", dr2);
// Emit one third of what is the convex hull of pixel-size boxes centered on the vertices.
// Each invocation emits a different third.
@@ -235,7 +236,7 @@ int PrimitiveProcessor::emitHullGeometry(GrGLSLGeometryBuilder* g, const char* e
g->codeAppendf( "%s(self + bloat * dl, 1);", emitVertexFn);
g->codeAppend ("}");
g->codeAppend ("if (all(dnotequal)) {");
- g->codeAppendf( "%s(self + bloat * vec2(-dl.y, dl.x), 1);", emitVertexFn);
+ g->codeAppendf( "%s(self + bloat * float2(-dl.y, dl.x), 1);", emitVertexFn);
g->codeAppend ("}");
g->codeAppend ("EndPrimitive();");
@@ -246,18 +247,18 @@ int PrimitiveProcessor::emitEdgeGeometry(GrGLSLGeometryBuilder* g, const char* e
const char* leftPt, const char* rightPt,
const char* distanceEquation) const {
if (!distanceEquation) {
- this->emitEdgeDistanceEquation(g, leftPt, rightPt, "highp vec3 edge_distance_equation");
+ this->emitEdgeDistanceEquation(g, leftPt, rightPt, "highp float3 edge_distance_equation");
distanceEquation = "edge_distance_equation";
}
// qlr is defined in emitEdgeDistanceEquation.
- g->codeAppendf("highp mat2 endpts = mat2(%s - bloat * qlr, %s + bloat * qlr);",
+ g->codeAppendf("highp float2x2 endpts = float2x2(%s - bloat * qlr, %s + bloat * qlr);",
leftPt, rightPt);
- g->codeAppendf("mediump vec2 endpts_coverage = %s.xy * endpts + %s.z;",
+ g->codeAppendf("mediump float2 endpts_coverage = %s.xy * endpts + %s.z;",
distanceEquation, distanceEquation);
// d1 is defined in emitEdgeDistanceEquation.
- g->codeAppend ("highp vec2 d2 = d1;");
+ g->codeAppend ("highp float2 d2 = d1;");
g->codeAppend ("bool aligned = qlr.x == 0 || qlr.y == 0;");
g->codeAppend ("if (aligned) {");
g->codeAppend ( "d1 -= qlr;");
@@ -286,16 +287,17 @@ void PrimitiveProcessor::emitEdgeDistanceEquation(GrGLSLGeometryBuilder* g,
const char* leftPt, const char* rightPt,
const char* outputDistanceEquation) const {
// Which quadrant does the vector from left -> right fall into?
- g->codeAppendf("highp vec2 qlr = sign(%s - %s);", rightPt, leftPt);
- g->codeAppend ("highp vec2 d1 = vec2(qlr.y, -qlr.x);");
+ g->codeAppendf("highp float2 qlr = sign(%s - %s);", rightPt, leftPt);
+ g->codeAppend ("highp float2 d1 = float2(qlr.y, -qlr.x);");
- g->codeAppendf("highp vec2 n = vec2(%s.y - %s.y, %s.x - %s.x);",
+ g->codeAppendf("highp float2 n = float2(%s.y - %s.y, %s.x - %s.x);",
rightPt, leftPt, leftPt, rightPt);
- g->codeAppendf("highp vec2 kk = n * mat2(%s + bloat * d1, %s - bloat * d1);", leftPt, leftPt);
+ g->codeAppendf("highp float2 kk = n * float2x2(%s + bloat * d1, %s - bloat * d1);",
+ leftPt, leftPt);
// Clamp for when n=0. wind=0 when n=0 so as long as we don't get Inf or NaN we are fine.
g->codeAppendf("highp float scale = 1 / max(kk[0] - kk[1], 1e-30);");
- g->codeAppendf("%s = vec3(-n, kk[1]) * scale;", outputDistanceEquation);
+ g->codeAppendf("%s = float3(-n, kk[1]) * scale;", outputDistanceEquation);
}
void PrimitiveProcessor::emitCoverage(const GrCCPRCoverageProcessor& proc, GrGLSLFragmentBuilder* f,
@@ -314,11 +316,11 @@ void PrimitiveProcessor::emitCoverage(const GrCCPRCoverageProcessor& proc, GrGLS
break;
}
- f->codeAppendf("%s = vec4(1);", outputCoverage);
+ f->codeAppendf("%s = float4(1);", outputCoverage);
#ifdef SK_DEBUG
if (proc.debugVisualizations()) {
- f->codeAppendf("%s = vec4(-%s.a, %s.a, 0, 1);", outputColor, outputColor, outputColor);
+ f->codeAppendf("%s = float4(-%s.a, %s.a, 0, 1);", outputColor, outputColor, outputColor);
}
#endif
}
@@ -327,17 +329,17 @@ int PrimitiveProcessor::defineSoftSampleLocations(GrGLSLFragmentBuilder* f,
const char* samplesName) const {
// Standard DX11 sample locations.
#if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_IOS)
- f->defineConstant("highp vec2[8]", samplesName, "vec2[8]("
- "vec2(+1, -3)/16, vec2(-1, +3)/16, vec2(+5, +1)/16, vec2(-3, -5)/16, "
- "vec2(-5, +5)/16, vec2(-7, -1)/16, vec2(+3, +7)/16, vec2(+7, -7)/16."
+ f->defineConstant("highp float2[8]", samplesName, "float2[8]("
+ "float2(+1, -3)/16, float2(-1, +3)/16, float2(+5, +1)/16, float2(-3, -5)/16, "
+ "float2(-5, +5)/16, float2(-7, -1)/16, float2(+3, +7)/16, float2(+7, -7)/16."
")");
return 8;
#else
- f->defineConstant("highp vec2[16]", samplesName, "vec2[16]("
- "vec2(+1, +1)/16, vec2(-1, -3)/16, vec2(-3, +2)/16, vec2(+4, -1)/16, "
- "vec2(-5, -2)/16, vec2(+2, +5)/16, vec2(+5, +3)/16, vec2(+3, -5)/16, "
- "vec2(-2, +6)/16, vec2( 0, -7)/16, vec2(-4, -6)/16, vec2(-6, +4)/16, "
- "vec2(-8, 0)/16, vec2(+7, -4)/16, vec2(+6, +7)/16, vec2(-7, -8)/16."
+ f->defineConstant("highp float2[16]", samplesName, "float2[16]("
+ "float2(+1, +1)/16, float2(-1, -3)/16, float2(-3, +2)/16, float2(+4, -1)/16, "
+ "float2(-5, -2)/16, float2(+2, +5)/16, float2(+5, +3)/16, float2(+3, -5)/16, "
+ "float2(-2, +6)/16, float2( 0, -7)/16, float2(-4, -6)/16, float2(-6, +4)/16, "
+ "float2(-8, 0)/16, float2(+7, -4)/16, float2(+6, +7)/16, float2(-7, -8)/16."
")");
return 16;
#endif
diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.h b/src/gpu/ccpr/GrCCPRCoverageProcessor.h
index 574cf4a162..befa1a9c5a 100644
--- a/src/gpu/ccpr/GrCCPRCoverageProcessor.h
+++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.h
@@ -215,13 +215,13 @@ protected:
int emitEdgeGeometry(GrGLSLGeometryBuilder*, const char* emitVertexFn, const char* leftPt,
const char* rightPt, const char* distanceEquation = nullptr) const;
- // Defines an equation ("dot(vec3(pt, 1), distance_equation)") that is -1 on the outside border
- // of a conservative raster edge and 0 on the inside (see emitEdgeGeometry).
+ // Defines an equation ("dot(float3(pt, 1), distance_equation)") that is -1 on the outside
+ // border of a conservative raster edge and 0 on the inside (see emitEdgeGeometry).
void emitEdgeDistanceEquation(GrGLSLGeometryBuilder*, const char* leftPt, const char* rightPt,
const char* outputDistanceEquation) const;
- // Defines a global vec2 array that contains MSAA sample locations as offsets from pixel center.
- // Subclasses can use this for software multisampling.
+ // Defines a global float2 array that contains MSAA sample locations as offsets from pixel
+ // center. Subclasses can use this for software multisampling.
//
// Returns the number of samples.
int defineSoftSampleLocations(GrGLSLFragmentBuilder*, const char* samplesName) const;
diff --git a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
index 9dfa8e158f..5f6f759c6d 100644
--- a/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRCubicProcessor.cpp
@@ -24,10 +24,10 @@ void GrCCPRCubicProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor& pro
#endif
// Fetch all 4 cubic bezier points.
- v->codeAppendf("ivec4 indices = ivec4(%s.y, %s.x, %s.x + 1, %s.y + 1);",
+ v->codeAppendf("int4 indices = int4(%s.y, %s.x, %s.x + 1, %s.y + 1);",
proc.instanceAttrib(), proc.instanceAttrib(), proc.instanceAttrib(),
proc.instanceAttrib());
- v->codeAppend ("highp mat4x2 bezierpts = mat4x2(");
+ v->codeAppend ("highp float4x2 bezierpts = float4x2(");
v->appendTexelFetch(pointsBuffer, "indices[sk_VertexID]");
v->codeAppend (".xy, ");
v->appendTexelFetch(pointsBuffer, "indices[(sk_VertexID + 1) % 4]");
@@ -38,24 +38,24 @@ void GrCCPRCubicProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor& pro
v->codeAppend (".xy);");
// Find the corner of the inset geometry that corresponds to this bezier vertex (bezierpts[0]).
- v->codeAppend ("highp mat2 N = mat2(bezierpts[3].y - bezierpts[0].y, "
- "bezierpts[0].x - bezierpts[3].x, "
- "bezierpts[1].y - bezierpts[0].y, "
- "bezierpts[0].x - bezierpts[1].x);");
- v->codeAppend ("highp mat2 P = mat2(bezierpts[3], bezierpts[1]);");
+ v->codeAppend ("highp float2x2 N = float2x2(bezierpts[3].y - bezierpts[0].y, "
+ "bezierpts[0].x - bezierpts[3].x, "
+ "bezierpts[1].y - bezierpts[0].y, "
+ "bezierpts[0].x - bezierpts[1].x);");
+ v->codeAppend ("highp float2x2 P = float2x2(bezierpts[3], bezierpts[1]);");
v->codeAppend ("if (abs(determinant(N)) < 2) {"); // Area of [pts[3], pts[0], pts[1]] < 1px.
// The inset corner doesn't exist because we are effectively colinear with
// both neighbor vertices. Just duplicate a neighbor's inset corner.
v->codeAppend ( "int smallidx = (dot(N[0], N[0]) > dot(N[1], N[1])) ? 1 : 0;");
- v->codeAppend ( "N[smallidx] = vec2(bezierpts[2].y - bezierpts[3 - smallidx * 2].y, "
- "bezierpts[3 - smallidx * 2].x - bezierpts[2].x);");
+ v->codeAppend ( "N[smallidx] = float2(bezierpts[2].y - bezierpts[3 - smallidx * 2].y, "
+ "bezierpts[3 - smallidx * 2].x - bezierpts[2].x);");
v->codeAppend ( "P[smallidx] = bezierpts[2];");
v->codeAppend ("}");
v->codeAppend ("N[0] *= sign(dot(N[0], P[1] - P[0]));");
v->codeAppend ("N[1] *= sign(dot(N[1], P[0] - P[1]));");
- v->codeAppendf("highp vec2 K = vec2(dot(N[0], P[0] + %f * sign(N[0])), "
- "dot(N[1], P[1] + %f * sign(N[1])));", inset, inset);
+ v->codeAppendf("highp float2 K = float2(dot(N[0], P[0] + %f * sign(N[0])), "
+ "dot(N[1], P[1] + %f * sign(N[1])));", inset, inset);
v->codeAppendf("%s.xy = K * inverse(N) + %s;", fInset.vsOut(), atlasOffset);
v->codeAppendf("%s.xy = %s.xy * %s.xz + %s.yw;",
fInset.vsOut(), fInset.vsOut(), rtAdjust, rtAdjust);
@@ -71,14 +71,15 @@ void GrCCPRCubicProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor& pro
v->codeAppend ("[sk_VertexID % 2];");
// Emit the vertex position.
- v->codeAppendf("highp vec2 self = bezierpts[0] + %s;", atlasOffset);
+ v->codeAppendf("highp float2 self = bezierpts[0] + %s;", atlasOffset);
gpArgs->fPositionVar.set(kVec2f_GrSLType, "self");
}
void GrCCPRCubicProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdjust,
const char* outputWind) const {
// We will define bezierpts in onEmitGeometryShader.
- g->codeAppend ("highp float area_times_2 = determinant(mat3(1, bezierpts[0], "
+ g->codeAppend ("highp float area_times_2 = "
+ "determinant(float3x3(1, bezierpts[0], "
"1, bezierpts[2], "
"0, bezierpts[3] - bezierpts[1]));");
// Drop curves that are nearly flat. The KLM math becomes unstable in this case.
@@ -97,13 +98,13 @@ void GrCCPRCubicProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdju
void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const char* emitVertexFn,
const char* wind, const char* rtAdjust) const {
// Prepend bezierpts at the start of the shader.
- g->codePrependf("highp mat4x2 bezierpts = mat4x2(sk_in[0].gl_Position.xy, "
+ g->codePrependf("highp float4x2 bezierpts = float4x2(sk_in[0].gl_Position.xy, "
"sk_in[1].gl_Position.xy, "
"sk_in[2].gl_Position.xy, "
"sk_in[3].gl_Position.xy);");
// Evaluate the cubic at t=.5 for an approximate midpoint.
- g->codeAppendf("highp vec2 midpoint = bezierpts * vec4(.125, .375, .375, .125);");
+ g->codeAppendf("highp float2 midpoint = bezierpts * float4(.125, .375, .375, .125);");
// Finish finding the inset geometry we started in the vertex shader. The z component tells us
// how "sharp" an inset corner is. And the vertex shader already skips one corner if it is
@@ -111,9 +112,9 @@ void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const
// geometry is all empty (it should never be non-convex because the curve gets chopped into
// convex segments ahead of time).
g->codeAppendf("bool isempty = "
- "any(lessThan(vec4(%s[0].z, %s[1].z, %s[2].z, %s[3].z) * %s, vec4(2)));",
+ "any(lessThan(float4(%s[0].z, %s[1].z, %s[2].z, %s[3].z) * %s, float4(2)));",
fInset.gsIn(), fInset.gsIn(), fInset.gsIn(), fInset.gsIn(), wind);
- g->codeAppendf("highp vec2 inset[4];");
+ g->codeAppendf("highp float2 inset[4];");
g->codeAppend ("for (int i = 0; i < 4; ++i) {");
g->codeAppendf( "inset[i] = isempty ? midpoint : %s[i].xy;", fInset.gsIn());
g->codeAppend ("}");
@@ -127,8 +128,8 @@ void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const
g->codeAppend ("lowp int numbackwards = 0;");
g->codeAppend ("for (int i = 0; i < 4; ++i) {");
g->codeAppend ( "lowp int j = (i + 1) % 4;");
- g->codeAppendf( "highp vec2 inner = inset[j] - inset[i];");
- g->codeAppendf( "highp vec2 outer = sk_in[j].gl_Position.xy - sk_in[i].gl_Position.xy;");
+ g->codeAppendf( "highp float2 inner = inset[j] - inset[i];");
+ g->codeAppendf( "highp float2 outer = sk_in[j].gl_Position.xy - sk_in[i].gl_Position.xy;");
g->codeAppendf( "backwards[i] = sign(dot(outer, inner));");
g->codeAppendf( "numbackwards += backwards[i] < 0 ? 1 : 0;");
g->codeAppend ("}");
@@ -137,16 +138,16 @@ void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const
// dropped on the floor later.
g->codeAppend ("lowp int x = (backwards[0] != backwards[2]) ? 1 : 0;");
g->codeAppend ("lowp int x3 = (x + 3) % 4;");
- g->codeAppend ("highp mat2 X = mat2(inset[x].y - inset[x+1].y, "
- "inset[x+1].x - inset[x].x, "
- "inset[x+2].y - inset[x3].y, "
- "inset[x3].x - inset[x+2].x);");
- g->codeAppend ("highp vec2 KK = vec2(dot(X[0], inset[x]), dot(X[1], inset[x+2]));");
- g->codeAppend ("highp vec2 crossoverpoint = KK * inverse(X);");
+ g->codeAppend ("highp float2x2 X = float2x2(inset[x].y - inset[x+1].y, "
+ "inset[x+1].x - inset[x].x, "
+ "inset[x+2].y - inset[x3].y, "
+ "inset[x3].x - inset[x+2].x);");
+ g->codeAppend ("highp float2 KK = float2(dot(X[0], inset[x]), dot(X[1], inset[x+2]));");
+ g->codeAppend ("highp float2 crossoverpoint = KK * inverse(X);");
// Determine what point backwards edges should collapse into. If there is one backwards edge,
// it should collapse to the crossover point. If >1, they should all collapse to the midpoint.
- g->codeAppend ("highp vec2 collapsepoint = numbackwards == 1 ? crossoverpoint : midpoint;");
+ g->codeAppend ("highp float2 collapsepoint = numbackwards == 1 ? crossoverpoint : midpoint;");
// Collapse backwards egdes to the "collapse" point.
g->codeAppend ("for (int i = 0; i < 4; ++i) {");
@@ -157,46 +158,46 @@ void GrCCPRCubicProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g, const
// Calculate the KLM matrix.
g->declareGlobal(fKLMMatrix);
- g->codeAppend ("highp vec4 K, L, M;");
+ g->codeAppend ("highp float4 K, L, M;");
if (Type::kSerpentine == fType) {
- g->codeAppend ("highp vec2 l,m;");
- g->codeAppendf("l.ts = vec2(%s[0], %s[1]);", fTS.gsIn(), fTS.gsIn());
- g->codeAppendf("m.ts = vec2(%s[2], %s[3]);", fTS.gsIn(), fTS.gsIn());
- g->codeAppend ("K = vec4(0, l.s * m.s, -l.t * m.s - m.t * l.s, l.t * m.t);");
- g->codeAppend ("L = vec4(-1,3,-3,1) * l.ssst * l.sstt * l.sttt;");
- g->codeAppend ("M = vec4(-1,3,-3,1) * m.ssst * m.sstt * m.sttt;");
+ g->codeAppend ("highp float2 l,m;");
+ g->codeAppendf("l.ts = float2(%s[0], %s[1]);", fTS.gsIn(), fTS.gsIn());
+ g->codeAppendf("m.ts = float2(%s[2], %s[3]);", fTS.gsIn(), fTS.gsIn());
+ g->codeAppend ("K = float4(0, l.s * m.s, -l.t * m.s - m.t * l.s, l.t * m.t);");
+ g->codeAppend ("L = float4(-1,3,-3,1) * l.ssst * l.sstt * l.sttt;");
+ g->codeAppend ("M = float4(-1,3,-3,1) * m.ssst * m.sstt * m.sttt;");
} else {
- g->codeAppend ("highp vec2 d,e;");
- g->codeAppendf("d.ts = vec2(%s[0], %s[1]);", fTS.gsIn(), fTS.gsIn());
- g->codeAppendf("e.ts = vec2(%s[2], %s[3]);", fTS.gsIn(), fTS.gsIn());
- g->codeAppend ("highp vec4 dxe = vec4(d.s * e.s, d.s * e.t, d.t * e.s, d.t * e.t);");
- g->codeAppend ("K = vec4(0, dxe.x, -dxe.y - dxe.z, dxe.w);");
- g->codeAppend ("L = vec4(-1,1,-1,1) * d.sstt * (dxe.xyzw + vec4(0, 2*dxe.zy, 0));");
- g->codeAppend ("M = vec4(-1,1,-1,1) * e.sstt * (dxe.xzyw + vec4(0, 2*dxe.yz, 0));");
+ g->codeAppend ("highp float2 d,e;");
+ g->codeAppendf("d.ts = float2(%s[0], %s[1]);", fTS.gsIn(), fTS.gsIn());
+ g->codeAppendf("e.ts = float2(%s[2], %s[3]);", fTS.gsIn(), fTS.gsIn());
+ g->codeAppend ("highp float4 dxe = float4(d.s * e.s, d.s * e.t, d.t * e.s, d.t * e.t);");
+ g->codeAppend ("K = float4(0, dxe.x, -dxe.y - dxe.z, dxe.w);");
+ g->codeAppend ("L = float4(-1,1,-1,1) * d.sstt * (dxe.xyzw + float4(0, 2*dxe.zy, 0));");
+ g->codeAppend ("M = float4(-1,1,-1,1) * e.sstt * (dxe.xzyw + float4(0, 2*dxe.yz, 0));");
}
- g->codeAppend ("highp mat2x4 C = mat4(-1, 3, -3, 1, "
- " 3, -6, 3, 0, "
- "-3, 3, 0, 0, "
- " 1, 0, 0, 0) * transpose(bezierpts);");
+ g->codeAppend ("highp float2x4 C = float4x4(-1, 3, -3, 1, "
+ " 3, -6, 3, 0, "
+ "-3, 3, 0, 0, "
+ " 1, 0, 0, 0) * transpose(bezierpts);");
- g->codeAppend ("highp vec2 absdet = abs(C[0].xx * C[1].zy - C[1].xx * C[0].zy);");
+ g->codeAppend ("highp float2 absdet = abs(C[0].xx * C[1].zy - C[1].xx * C[0].zy);");
g->codeAppend ("lowp int middlerow = absdet[0] > absdet[1] ? 2 : 1;");
- g->codeAppend ("highp mat3 CI = inverse(mat3(C[0][0], C[0][middlerow], C[0][3], "
- "C[1][0], C[1][middlerow], C[1][3], "
- " 0, 0, 1));");
- g->codeAppendf("%s = CI * mat3(K[0], K[middlerow], K[3], "
- "L[0], L[middlerow], L[3], "
- "M[0], M[middlerow], M[3]);", fKLMMatrix.c_str());
+ g->codeAppend ("highp float3x3 CI = inverse(float3x3(C[0][0], C[0][middlerow], C[0][3], "
+ "C[1][0], C[1][middlerow], C[1][3], "
+ " 0, 0, 1));");
+ g->codeAppendf("%s = CI * float3x3(K[0], K[middlerow], K[3], "
+ "L[0], L[middlerow], L[3], "
+ "M[0], M[middlerow], M[3]);", fKLMMatrix.c_str());
// Orient the KLM matrix so we fill the correct side of the curve.
- g->codeAppendf("lowp vec2 orientation = sign(vec3(midpoint, 1) * mat2x3(%s[1], %s[2]));",
+ g->codeAppendf("lowp float2 orientation = sign(float3(midpoint, 1) * float2x3(%s[1], %s[2]));",
fKLMMatrix.c_str(), fKLMMatrix.c_str());
- g->codeAppendf("%s *= mat3(orientation[0] * orientation[1], 0, 0, "
- "0, orientation[0], 0, "
- "0, 0, orientation[1]);", fKLMMatrix.c_str());
+ g->codeAppendf("%s *= float3x3(orientation[0] * orientation[1], 0, 0, "
+ "0, orientation[0], 0, "
+ "0, 0, orientation[1]);", fKLMMatrix.c_str());
g->declareGlobal(fKLMDerivatives);
g->codeAppendf("%s[0] = %s[0].xy * %s.xz;",
@@ -227,7 +228,7 @@ void GrCCPRCubicInsetProcessor::emitCubicGeometry(GrGLSLGeometryBuilder* g,
void GrCCPRCubicInsetProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
const char* /*coverage*/,
const char* /*wind*/) const {
- fnBody->appendf("highp vec3 klm = vec3(%s, 1) * %s;", position, fKLMMatrix.c_str());
+ fnBody->appendf("highp float3 klm = float3(%s, 1) * %s;", position, fKLMMatrix.c_str());
fnBody->appendf("%s = klm;", fKLM.gsOut());
fnBody->appendf("%s[0] = 3 * klm[0] * %s[0];", fGradMatrix.gsOut(), fKLMDerivatives.c_str());
fnBody->appendf("%s[1] = -klm[1] * %s[2].xy - klm[2] * %s[1].xy;",
@@ -239,7 +240,7 @@ void GrCCPRCubicInsetProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
f->codeAppendf("highp float k = %s.x, l = %s.y, m = %s.z;",
fKLM.fsIn(), fKLM.fsIn(), fKLM.fsIn());
f->codeAppend ("highp float f = k*k*k - l*m;");
- f->codeAppendf("highp vec2 grad = %s * vec2(k, 1);", fGradMatrix.fsIn());
+ f->codeAppendf("highp float2 grad = %s * float2(k, 1);", fGradMatrix.fsIn());
f->codeAppend ("highp float d = f * inversesqrt(dot(grad, grad));");
f->codeAppendf("%s = clamp(0.5 - d, 0, 1);", outputCoverage);
}
@@ -250,8 +251,8 @@ void GrCCPRCubicBorderProcessor::emitCubicGeometry(GrGLSLGeometryBuilder* g,
// We defined bezierpts in onEmitGeometryShader.
g->declareGlobal(fEdgeDistanceEquation);
g->codeAppendf("int edgeidx0 = %s > 0 ? 3 : 0;", wind);
- g->codeAppendf("highp vec2 edgept0 = bezierpts[edgeidx0];");
- g->codeAppendf("highp vec2 edgept1 = bezierpts[3 - edgeidx0];");
+ g->codeAppendf("highp float2 edgept0 = bezierpts[edgeidx0];");
+ g->codeAppendf("highp float2 edgept1 = bezierpts[3 - edgeidx0];");
this->emitEdgeDistanceEquation(g, "edgept0", "edgept1", fEdgeDistanceEquation.c_str());
g->codeAppendf("%s.z += 0.5;", fEdgeDistanceEquation.c_str()); // outer = -.5, inner = .5
@@ -260,9 +261,9 @@ void GrCCPRCubicBorderProcessor::emitCubicGeometry(GrGLSLGeometryBuilder* g,
fEdgeDistanceDerivatives.c_str(), fEdgeDistanceEquation.c_str(), rtAdjust);
g->declareGlobal(fEdgeSpaceTransform);
- g->codeAppend ("highp vec4 edgebbox = vec4(min(bezierpts[0], bezierpts[3]) - bloat, "
+ g->codeAppend ("highp float4 edgebbox = float4(min(bezierpts[0], bezierpts[3]) - bloat, "
"max(bezierpts[0], bezierpts[3]) + bloat);");
- g->codeAppendf("%s.xy = 2 / vec2(edgebbox.zw - edgebbox.xy);", fEdgeSpaceTransform.c_str());
+ g->codeAppendf("%s.xy = 2 / float2(edgebbox.zw - edgebbox.xy);", fEdgeSpaceTransform.c_str());
g->codeAppendf("%s.zw = -1 - %s.xy * edgebbox.xy;",
fEdgeSpaceTransform.c_str(), fEdgeSpaceTransform.c_str());
@@ -277,14 +278,14 @@ void GrCCPRCubicBorderProcessor::emitCubicGeometry(GrGLSLGeometryBuilder* g,
void GrCCPRCubicBorderProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
const char* /*coverage*/,
const char* /*wind*/) const {
- fnBody->appendf("highp vec3 klm = vec3(%s, 1) * %s;", position, fKLMMatrix.c_str());
- fnBody->appendf("highp float d = dot(vec3(%s, 1), %s);",
+ fnBody->appendf("highp float3 klm = float3(%s, 1) * %s;", position, fKLMMatrix.c_str());
+ fnBody->appendf("highp float d = dot(float3(%s, 1), %s);",
position, fEdgeDistanceEquation.c_str());
- fnBody->appendf("%s = vec4(klm, d);", fKLMD.gsOut());
- fnBody->appendf("%s = vec4(%s[0].x, %s[1].x, %s[2].x, %s.x);",
+ fnBody->appendf("%s = float4(klm, d);", fKLMD.gsOut());
+ fnBody->appendf("%s = float4(%s[0].x, %s[1].x, %s[2].x, %s.x);",
fdKLMDdx.gsOut(), fKLMDerivatives.c_str(), fKLMDerivatives.c_str(),
fKLMDerivatives.c_str(), fEdgeDistanceDerivatives.c_str());
- fnBody->appendf("%s = vec4(%s[0].y, %s[1].y, %s[2].y, %s.y);",
+ fnBody->appendf("%s = float4(%s[0].y, %s[1].y, %s[2].y, %s.y);",
fdKLMDdy.gsOut(), fKLMDerivatives.c_str(), fKLMDerivatives.c_str(),
fKLMDerivatives.c_str(), fEdgeDistanceDerivatives.c_str());
fnBody->appendf("%s = position * %s.xy + %s.zw;", fEdgeSpaceCoord.gsOut(),
@@ -302,18 +303,19 @@ void GrCCPRCubicBorderProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
// Along the shared edge, we start with distance-to-edge coverage, then subtract out the
// remaining pixel coverage that is still inside the shared edge, but outside the curve.
// Outside the shared edege, we just use standard msaa to count samples inside the curve.
- f->codeAppendf("bool use_edge = all(lessThan(abs(%s), vec2(1)));", fEdgeSpaceCoord.fsIn());
+ f->codeAppendf("bool use_edge = all(lessThan(abs(%s), float2(1)));", fEdgeSpaceCoord.fsIn());
f->codeAppendf("%s = (use_edge ? clamp(%s.w + 0.5, 0, 1) : 0) * %i;",
outputCoverage, fKLMD.fsIn(), sampleCount);
- f->codeAppendf("highp mat2x4 grad_klmd = mat2x4(%s, %s);", fdKLMDdx.fsIn(), fdKLMDdy.fsIn());
+ f->codeAppendf("highp float2x4 grad_klmd = float2x4(%s, %s);", fdKLMDdx.fsIn(),
+ fdKLMDdy.fsIn());
f->codeAppendf("for (int i = 0; i < %i; ++i) {", sampleCount);
- f->codeAppendf( "highp vec4 klmd = grad_klmd * samples[i] + %s;", fKLMD.fsIn());
+ f->codeAppendf( "highp float4 klmd = grad_klmd * samples[i] + %s;", fKLMD.fsIn());
f->codeAppend ( "lowp float f = klmd.y * klmd.z - klmd.x * klmd.x * klmd.x;");
// A sample is inside our cubic sub-section if it is inside the implicit AND L & M are both
// positive. This works because the sections get chopped at the K/L and K/M intersections.
- f->codeAppend ( "bvec4 inside = greaterThan(vec4(f,klmd.yzw), vec4(0));");
+ f->codeAppend ( "bool4 inside = greaterThan(float4(f,klmd.yzw), float4(0));");
f->codeAppend ( "lowp float in_curve = all(inside.xyz) ? 1 : 0;");
f->codeAppend ( "lowp float in_edge = inside.w ? 1 : 0;");
f->codeAppendf( "%s += use_edge ? in_edge * (in_curve - 1) : in_curve;", outputCoverage);
diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.cpp b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
index 6efaecf9f9..1292553824 100644
--- a/src/gpu/ccpr/GrCCPRPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
@@ -136,41 +136,41 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// Find the intersections of (bloated) devBounds and devBounds45 in order to come up with an
// octagon that circumscribes the (bloated) path. A vertex is the intersection of two lines:
// one edge from the path's bounding box and one edge from its 45-degree bounding box.
- v->codeAppendf("highp mat2 N = mat2(%s);", proc.getEdgeNormsAttrib().fName);
+ v->codeAppendf("highp float2x2 N = float2x2(%s);", proc.getEdgeNormsAttrib().fName);
// N[0] is the normal for the edge we are intersecting from the regular bounding box, pointing
// out of the octagon.
- v->codeAppendf("highp vec2 refpt = (min(N[0].x, N[0].y) < 0) ? %s.xy : %s.zw;",
+ v->codeAppendf("highp float2 refpt = (min(N[0].x, N[0].y) < 0) ? %s.xy : %s.zw;",
proc.getInstanceAttrib(InstanceAttribs::kDevBounds).fName,
proc.getInstanceAttrib(InstanceAttribs::kDevBounds).fName);
v->codeAppendf("refpt += N[0] * %f;", kAABloatRadius); // bloat for AA.
// N[1] is the normal for the edge we are intersecting from the 45-degree bounding box, pointing
// out of the octagon.
- v->codeAppendf("highp vec2 refpt45 = (N[1].x < 0) ? %s.xy : %s.zw;",
+ v->codeAppendf("highp float2 refpt45 = (N[1].x < 0) ? %s.xy : %s.zw;",
proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName,
proc.getInstanceAttrib(InstanceAttribs::kDevBounds45).fName);
- v->codeAppendf("refpt45 *= mat2(.5,.5,-.5,.5);"); // transform back to device space.
+ v->codeAppendf("refpt45 *= float2x2(.5,.5,-.5,.5);"); // transform back to device space.
v->codeAppendf("refpt45 += N[1] * %f;", kAABloatRadius); // bloat for AA.
- v->codeAppend ("highp vec2 K = vec2(dot(N[0], refpt), dot(N[1], refpt45));");
- v->codeAppendf("highp vec2 octocoord = K * inverse(N);");
+ v->codeAppend ("highp float2 K = float2(dot(N[0], refpt), dot(N[1], refpt45));");
+ v->codeAppendf("highp float2 octocoord = K * inverse(N);");
gpArgs->fPositionVar.set(kVec2f_GrSLType, "octocoord");
// Convert to atlas coordinates in order to do our texture lookup.
- v->codeAppendf("highp vec2 atlascoord = octocoord + vec2(%s);",
+ v->codeAppendf("highp float2 atlascoord = octocoord + float2(%s);",
proc.getInstanceAttrib(InstanceAttribs::kAtlasOffset).fName);
if (kTopLeft_GrSurfaceOrigin == proc.atlasProxy()->origin()) {
v->codeAppendf("%s = atlascoord * %s;", texcoord.vsOut(), atlasAdjust);
} else {
SkASSERT(kBottomLeft_GrSurfaceOrigin == proc.atlasProxy()->origin());
- v->codeAppendf("%s = vec2(atlascoord.x * %s.x, 1 - atlascoord.y * %s.y);",
+ v->codeAppendf("%s = float2(atlascoord.x * %s.x, 1 - atlascoord.y * %s.y);",
texcoord.vsOut(), atlasAdjust, atlasAdjust);
}
// Convert to (local) path cordinates.
- v->codeAppendf("highp vec2 pathcoord = inverse(mat2(%s)) * (octocoord - %s);",
+ v->codeAppendf("highp float2 pathcoord = inverse(float2x2(%s)) * (octocoord - %s);",
proc.getInstanceAttrib(InstanceAttribs::kViewMatrix).fName,
proc.getInstanceAttrib(InstanceAttribs::kViewTranslate).fName);
@@ -185,11 +185,11 @@ void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
f->codeAppend (".a;");
if (SkPath::kWinding_FillType == proc.fillType()) {
- f->codeAppendf("%s = vec4(min(abs(coverage_count), 1));", args.fOutputCoverage);
+ f->codeAppendf("%s = float4(min(abs(coverage_count), 1));", args.fOutputCoverage);
} else {
SkASSERT(SkPath::kEvenOdd_FillType == proc.fillType());
f->codeAppend ("mediump float t = mod(abs(coverage_count), 2);");
- f->codeAppendf("%s = vec4(1 - abs(t - 1));", args.fOutputCoverage);
+ f->codeAppendf("%s = float4(1 - abs(t - 1));", args.fOutputCoverage);
}
}
diff --git a/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp b/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
index 8c58ea26a8..bc09fea1ae 100644
--- a/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRQuadraticProcessor.cpp
@@ -16,9 +16,9 @@ void GrCCPRQuadraticProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor&
const TexelBufferHandle& pointsBuffer,
const char* atlasOffset, const char* rtAdjust,
GrGPArgs* gpArgs) const {
- v->codeAppendf("ivec3 indices = ivec3(%s.y, %s.x, %s.y + 1);",
+ v->codeAppendf("int3 indices = int3(%s.y, %s.x, %s.y + 1);",
proc.instanceAttrib(), proc.instanceAttrib(), proc.instanceAttrib());
- v->codeAppend ("highp vec2 self = ");
+ v->codeAppend ("highp float2 self = ");
v->appendTexelFetch(pointsBuffer, "indices[sk_VertexID]");
v->codeAppendf(".xy + %s;", atlasOffset);
gpArgs->fPositionVar.set(kVec2f_GrSLType, "self");
@@ -27,8 +27,9 @@ void GrCCPRQuadraticProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor&
void GrCCPRQuadraticProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* rtAdjust,
const char* outputWind) const {
// We will define bezierpts in onEmitGeometryShader.
- g->codeAppend ("highp float area_times_2 = determinant(mat2(bezierpts[1] - bezierpts[0], "
- "bezierpts[2] - bezierpts[0]));");
+ g->codeAppend ("highp float area_times_2 = "
+ "determinant(float2x2(bezierpts[1] - bezierpts[0], "
+ "bezierpts[2] - bezierpts[0]));");
// Drop curves that are nearly flat, in favor of the higher quality triangle antialiasing.
g->codeAppendf("if (2 * abs(area_times_2) < length((bezierpts[2] - bezierpts[0]) * %s.zx)) {",
rtAdjust);
@@ -46,21 +47,21 @@ void GrCCPRQuadraticProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g,
const char* emitVertexFn, const char* wind,
const char* rtAdjust) const {
// Prepend bezierpts at the start of the shader.
- g->codePrependf("highp mat3x2 bezierpts = mat3x2(sk_in[0].gl_Position.xy, "
- "sk_in[1].gl_Position.xy, "
- "sk_in[2].gl_Position.xy);");
+ g->codePrependf("highp float3x2 bezierpts = float3x2(sk_in[0].gl_Position.xy, "
+ "sk_in[1].gl_Position.xy, "
+ "sk_in[2].gl_Position.xy);");
g->declareGlobal(fCanonicalMatrix);
- g->codeAppendf("%s = mat3(0.0, 0, 1, "
- "0.5, 0, 1, "
- "1.0, 1, 1) * "
- "inverse(mat3(bezierpts[0], 1, "
- "bezierpts[1], 1, "
- "bezierpts[2], 1));",
+ g->codeAppendf("%s = float3x3(0.0, 0, 1, "
+ "0.5, 0, 1, "
+ "1.0, 1, 1) * "
+ "inverse(float3x3(bezierpts[0], 1, "
+ "bezierpts[1], 1, "
+ "bezierpts[2], 1));",
fCanonicalMatrix.c_str());
g->declareGlobal(fCanonicalDerivatives);
- g->codeAppendf("%s = mat2(%s) * mat2(%s.x, 0, 0, %s.z);",
+ g->codeAppendf("%s = float2x2(%s) * float2x2(%s.x, 0, 0, %s.z);",
fCanonicalDerivatives.c_str(), fCanonicalMatrix.c_str(), rtAdjust, rtAdjust);
this->emitQuadraticGeometry(g, emitVertexFn, wind, rtAdjust);
@@ -69,10 +70,10 @@ void GrCCPRQuadraticProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g,
void GrCCPRQuadraticProcessor::emitPerVertexGeometryCode(SkString* fnBody, const char* position,
const char* /*coverage*/,
const char* /*wind*/) const {
- fnBody->appendf("%s.xy = (%s * vec3(%s, 1)).xy;",
+ fnBody->appendf("%s.xy = (%s * float3(%s, 1)).xy;",
fCanonicalCoord.gsOut(), fCanonicalMatrix.c_str(), position);
- fnBody->appendf("%s.zw = vec2(2 * %s.x * %s[0].x - %s[0].y, "
- "2 * %s.x * %s[1].x - %s[1].y);",
+ fnBody->appendf("%s.zw = float2(2 * %s.x * %s[0].x - %s[0].y, "
+ "2 * %s.x * %s[1].x - %s[1].y);",
fCanonicalCoord.gsOut(), fCanonicalCoord.gsOut(),
fCanonicalDerivatives.c_str(), fCanonicalDerivatives.c_str(),
fCanonicalCoord.gsOut(), fCanonicalDerivatives.c_str(),
@@ -93,26 +94,26 @@ void GrCCPRQuadraticHullProcessor::emitQuadraticGeometry(GrGLSLGeometryBuilder*
const char* rtAdjust) const {
// Find the point on the curve whose tangent is halfway between the tangents at the endpionts.
// We defined bezierpts in onEmitGeometryShader.
- g->codeAppend ("highp vec2 n = (normalize(bezierpts[0] - bezierpts[1]) + "
- "normalize(bezierpts[2] - bezierpts[1]));");
+ g->codeAppend ("highp float2 n = (normalize(bezierpts[0] - bezierpts[1]) + "
+ "normalize(bezierpts[2] - bezierpts[1]));");
g->codeAppend ("highp float t = dot(bezierpts[0] - bezierpts[1], n) / "
"dot(bezierpts[2] - 2 * bezierpts[1] + bezierpts[0], n);");
- g->codeAppend ("highp vec2 pt = (1 - t) * (1 - t) * bezierpts[0] + "
- "2 * t * (1 - t) * bezierpts[1] + "
- "t * t * bezierpts[2];");
+ g->codeAppend ("highp float2 pt = (1 - t) * (1 - t) * bezierpts[0] + "
+ "2 * t * (1 - t) * bezierpts[1] + "
+ "t * t * bezierpts[2];");
// Clip the triangle by the tangent line at this halfway point.
- g->codeAppend ("highp mat2 v = mat2(bezierpts[0] - bezierpts[1], "
- "bezierpts[2] - bezierpts[1]);");
- g->codeAppend ("highp vec2 nv = n * v;");
- g->codeAppend ("highp vec2 d = abs(nv[0]) > 0.1 * max(bloat.x, bloat.y) ? "
- "(dot(n, pt - bezierpts[1])) / nv : vec2(0);");
+ g->codeAppend ("highp float2x2 v = float2x2(bezierpts[0] - bezierpts[1], "
+ "bezierpts[2] - bezierpts[1]);");
+ g->codeAppend ("highp float2 nv = n * v;");
+ g->codeAppend ("highp float2 d = abs(nv[0]) > 0.1 * max(bloat.x, bloat.y) ? "
+ "(dot(n, pt - bezierpts[1])) / nv : float2(0);");
// Generate a 4-point hull of the curve from the clipped triangle.
- g->codeAppendf("highp mat4x2 quadratic_hull = mat4x2(bezierpts[0], "
- "bezierpts[1] + d[0] * v[0], "
- "bezierpts[1] + d[1] * v[1], "
- "bezierpts[2]);");
+ g->codeAppendf("highp float4x2 quadratic_hull = float4x2(bezierpts[0], "
+ "bezierpts[1] + d[0] * v[0], "
+ "bezierpts[1] + d[1] * v[1], "
+ "bezierpts[2]);");
int maxVerts = this->emitHullGeometry(g, emitVertexFn, "quadratic_hull", 4, "sk_InvocationID");
@@ -127,9 +128,9 @@ void GrCCPRQuadraticSharedEdgeProcessor::emitQuadraticGeometry(GrGLSLGeometryBui
const char* rtAdjust) const {
// We defined bezierpts in onEmitGeometryShader.
g->codeAppendf("int leftidx = %s > 0 ? 2 : 0;", wind);
- g->codeAppendf("highp vec2 left = bezierpts[leftidx];");
- g->codeAppendf("highp vec2 right = bezierpts[2 - leftidx];");
- this->emitEdgeDistanceEquation(g, "left", "right", "highp vec3 edge_distance_equation");
+ g->codeAppendf("highp float2 left = bezierpts[leftidx];");
+ g->codeAppendf("highp float2 right = bezierpts[2 - leftidx];");
+ this->emitEdgeDistanceEquation(g, "left", "right", "highp float3 edge_distance_equation");
g->declareGlobal(fEdgeDistanceDerivatives);
g->codeAppendf("%s = edge_distance_equation.xy * %s.xz;",
@@ -163,16 +164,16 @@ void GrCCPRQuadraticSharedEdgeProcessor::emitShaderCoverage(GrGLSLFragmentBuilde
// shared edge, but outside the curve.
int sampleCount = this->defineSoftSampleLocations(f, "samples");
- f->codeAppendf("highp mat2x3 grad_xyd = mat2x3(%s[0],%s.y, %s[1],%s.z);",
+ f->codeAppendf("highp float2x3 grad_xyd = float2x3(%s[0],%s.y, %s[1],%s.z);",
fFragCanonicalDerivatives.fsIn(), fEdgeDistance.fsIn(),
fFragCanonicalDerivatives.fsIn(), fEdgeDistance.fsIn());
- f->codeAppendf("highp vec3 center_xyd = vec3(%s.xy, %s.x);",
+ f->codeAppendf("highp float3 center_xyd = float3(%s.xy, %s.x);",
fCanonicalCoord.fsIn(), fEdgeDistance.fsIn());
f->codeAppendf("for (int i = 0; i < %i; ++i) {", sampleCount);
- f->codeAppend ( "highp vec3 xyd = grad_xyd * samples[i] + center_xyd;");
+ f->codeAppend ( "highp float3 xyd = grad_xyd * samples[i] + center_xyd;");
f->codeAppend ( "lowp float f = xyd.x * xyd.x - xyd.y;"); // f > 0 -> outside curve.
- f->codeAppend ( "bvec2 outside_curve_inside_edge = greaterThan(vec2(f, xyd.z), vec2(0));");
+ f->codeAppend ( "bool2 outside_curve_inside_edge = greaterThan(float2(f, xyd.z), float2(0));");
f->codeAppendf( "%s -= all(outside_curve_inside_edge) ? %f : 0;",
outputCoverage, 1.0 / sampleCount);
f->codeAppendf("}");
diff --git a/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp b/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
index 23f7b143b1..77da2cf0ad 100644
--- a/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRTriangleProcessor.cpp
@@ -16,7 +16,7 @@ void GrCCPRTriangleProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor&
const TexelBufferHandle& pointsBuffer,
const char* atlasOffset, const char* rtAdjust,
GrGPArgs* gpArgs) const {
- v->codeAppend ("highp vec2 self = ");
+ v->codeAppend ("highp float2 self = ");
v->appendTexelFetch(pointsBuffer,
SkStringPrintf("%s[sk_VertexID]", proc.instanceAttrib()).c_str());
v->codeAppendf(".xy + %s;", atlasOffset);
@@ -25,16 +25,17 @@ void GrCCPRTriangleProcessor::onEmitVertexShader(const GrCCPRCoverageProcessor&
void GrCCPRTriangleProcessor::defineInputVertices(GrGLSLGeometryBuilder* g) const {
// Prepend in_vertices at the start of the shader.
- g->codePrependf("highp mat3x2 in_vertices = mat3x2(sk_in[0].gl_Position.xy, "
- "sk_in[1].gl_Position.xy, "
- "sk_in[2].gl_Position.xy);");
+ g->codePrependf("highp float3x2 in_vertices = float3x2(sk_in[0].gl_Position.xy, "
+ "sk_in[1].gl_Position.xy, "
+ "sk_in[2].gl_Position.xy);");
}
void GrCCPRTriangleProcessor::emitWind(GrGLSLGeometryBuilder* g, const char* /*rtAdjust*/,
const char* outputWind) const {
// We will define in_vertices in defineInputVertices.
- g->codeAppendf("%s = sign(determinant(mat2(in_vertices[1] - in_vertices[0], "
- "in_vertices[2] - in_vertices[0])));", outputWind);
+ g->codeAppendf("%s = sign(determinant(float2x2(in_vertices[1] - in_vertices[0], "
+ "in_vertices[2] - in_vertices[0])));",
+ outputWind);
}
void GrCCPRTriangleHullAndEdgeProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder* g,
@@ -52,8 +53,8 @@ void GrCCPRTriangleHullAndEdgeProcessor::onEmitGeometryShader(GrGLSLGeometryBuil
if (GeometryType::kHulls != fGeometryType) {
g->codeAppend ("int edgeidx0 = sk_InvocationID, "
"edgeidx1 = (edgeidx0 + 1) % 3;");
- g->codeAppendf("highp vec2 edgept0 = in_vertices[%s > 0 ? edgeidx0 : edgeidx1];", wind);
- g->codeAppendf("highp vec2 edgept1 = in_vertices[%s > 0 ? edgeidx1 : edgeidx0];", wind);
+ g->codeAppendf("highp float2 edgept0 = in_vertices[%s > 0 ? edgeidx0 : edgeidx1];", wind);
+ g->codeAppendf("highp float2 edgept1 = in_vertices[%s > 0 ? edgeidx1 : edgeidx0];", wind);
maxOutputVertices += this->emitEdgeGeometry(g, emitVertexFn, "edgept0", "edgept1");
}
@@ -72,16 +73,17 @@ void GrCCPRTriangleCornerProcessor::onEmitVertexShader(const GrCCPRCoverageProce
this->INHERITED::onEmitVertexShader(proc, v, pointsBuffer, atlasOffset, rtAdjust, gpArgs);
// Fetch and transform the next point in the triangle.
- v->codeAppend ("highp vec2 next = ");
+ v->codeAppend ("highp float2 next = ");
v->appendTexelFetch(pointsBuffer,
SkStringPrintf("%s[(sk_VertexID+1) %% 3]", proc.instanceAttrib()).c_str());
v->codeAppendf(".xy + %s;", atlasOffset);
// Find the plane that gives distance from the [self -> next] edge, normalized to its AA
// bloat width.
- v->codeAppend ("highp vec2 n = vec2(next.y - self.y, self.x - next.x);");
- v->codeAppendf("highp vec2 d = n * mat2(self + %f * sign(n), "
- "self - %f * sign(n));", kAABloatRadius, kAABloatRadius);
+ v->codeAppend ("highp float2 n = float2(next.y - self.y, self.x - next.x);");
+ v->codeAppendf("highp float2 d = n * float2x2(self + %f * sign(n), "
+ "self - %f * sign(n));",
+ kAABloatRadius, kAABloatRadius);
// Clamp for when n=0. (wind=0 when n=0, so as long as we don't get Inf or NaN we are fine.)
v->codeAppendf("%s.xy = n / max(d[0] - d[1], 1e-30);", fEdgeDistance.vsOut());
@@ -96,11 +98,11 @@ void GrCCPRTriangleCornerProcessor::onEmitGeometryShader(GrGLSLGeometryBuilder*
const char* rtAdjust) const {
this->defineInputVertices(g);
- g->codeAppend ("highp vec2 self = in_vertices[sk_InvocationID];");
- g->codeAppendf("%s(self + vec2(-bloat.x, -bloat.y), 1);", emitVertexFn);
- g->codeAppendf("%s(self + vec2(-bloat.x, +bloat.y), 1);", emitVertexFn);
- g->codeAppendf("%s(self + vec2(+bloat.x, -bloat.y), 1);", emitVertexFn);
- g->codeAppendf("%s(self + vec2(+bloat.x, +bloat.y), 1);", emitVertexFn);
+ g->codeAppend ("highp float2 self = in_vertices[sk_InvocationID];");
+ g->codeAppendf("%s(self + float2(-bloat.x, -bloat.y), 1);", emitVertexFn);
+ g->codeAppendf("%s(self + float2(-bloat.x, +bloat.y), 1);", emitVertexFn);
+ g->codeAppendf("%s(self + float2(+bloat.x, -bloat.y), 1);", emitVertexFn);
+ g->codeAppendf("%s(self + float2(+bloat.x, +bloat.y), 1);", emitVertexFn);
g->codeAppend ("EndPrimitive();");
g->configure(GrGLSLGeometryBuilder::InputType::kTriangles,
@@ -116,13 +118,13 @@ void GrCCPRTriangleCornerProcessor::emitPerVertexGeometryCode(SkString* fnBody,
fNeighbors.gsOut(), fDevCoord.gsIn());
fnBody->appendf("%s.zw = %s[(sk_InvocationID + 2) %% 3];",
fNeighbors.gsOut(), fDevCoord.gsIn());
- fnBody->appendf("%s = mat3(%s[(sk_InvocationID + 2) %% 3], "
- "%s[sk_InvocationID], "
- "%s[(sk_InvocationID + 1) %% 3]) * %s;",
+ fnBody->appendf("%s = float3x3(%s[(sk_InvocationID + 2) %% 3], "
+ "%s[sk_InvocationID], "
+ "%s[(sk_InvocationID + 1) %% 3]) * %s;",
fEdgeDistances.gsOut(), fEdgeDistance.gsIn(), fEdgeDistance.gsIn(),
fEdgeDistance.gsIn(), wind);
- // Otherwise, fEdgeDistances = mat3(...) * sign(wind * rtAdjust.x * rdAdjust.z).
+ // Otherwise, fEdgeDistances = float3x3(...) * sign(wind * rtAdjust.x * rdAdjust.z).
GR_STATIC_ASSERT(kTopLeft_GrSurfaceOrigin == GrCCPRCoverageProcessor::kAtlasOrigin);
fnBody->appendf("%s = sk_InvocationID;", fCornerIdx.gsOut());
@@ -131,23 +133,23 @@ void GrCCPRTriangleCornerProcessor::emitPerVertexGeometryCode(SkString* fnBody,
void GrCCPRTriangleCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
const char* outputCoverage) const {
// FIXME: Adreno breaks if we don't put the frag coord in an intermediate highp variable.
- f->codeAppendf("highp vec2 fragcoord = sk_FragCoord.xy;");
+ f->codeAppendf("highp float2 fragcoord = sk_FragCoord.xy;");
// Approximate coverage by tracking where 4 horizontal lines enter and leave the triangle.
GrShaderVar samples("samples", kVec4f_GrSLType, GrShaderVar::kNonArray,
kHigh_GrSLPrecision);
f->declareGlobal(samples);
- f->codeAppendf("%s = fragcoord.y + vec4(-0.375, -0.125, 0.125, 0.375);", samples.c_str());
+ f->codeAppendf("%s = fragcoord.y + float4(-0.375, -0.125, 0.125, 0.375);", samples.c_str());
GrShaderVar leftedge("leftedge", kVec4f_GrSLType, GrShaderVar::kNonArray,
kHigh_GrSLPrecision);
f->declareGlobal(leftedge);
- f->codeAppendf("%s = vec4(fragcoord.x - 0.5);", leftedge.c_str());
+ f->codeAppendf("%s = float4(fragcoord.x - 0.5);", leftedge.c_str());
GrShaderVar rightedge("rightedge", kVec4f_GrSLType, GrShaderVar::kNonArray,
kHigh_GrSLPrecision);
f->declareGlobal(rightedge);
- f->codeAppendf("%s = vec4(fragcoord.x + 0.5);", rightedge.c_str());
+ f->codeAppendf("%s = float4(fragcoord.x + 0.5);", rightedge.c_str());
SkString sampleEdgeFn;
GrShaderVar edgeArg("edge_distance", kVec3f_GrSLType, GrShaderVar::kNonArray,
@@ -156,7 +158,7 @@ void GrCCPRTriangleCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
SkString b;
b.appendf("highp float m = abs(%s.x) < 1e-3 ? 1e18 : -1 / %s.x;",
edgeArg.c_str(), edgeArg.c_str());
- b.appendf("highp vec4 edge = m * (%s.y * samples + %s.z);",
+ b.appendf("highp float4 edge = m * (%s.y * samples + %s.z);",
edgeArg.c_str(), edgeArg.c_str());
b.appendf("if (%s.x <= 1e-3 || (abs(%s.x) < 1e-3 && %s.y > 0)) {",
edgeArg.c_str(), edgeArg.c_str(), edgeArg.c_str());
@@ -168,10 +170,10 @@ void GrCCPRTriangleCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
}().c_str(), &sampleEdgeFn);
// See if the previous neighbor already handled this pixel.
- f->codeAppendf("if (all(lessThan(abs(fragcoord - %s.zw), vec2(%f)))) {",
+ f->codeAppendf("if (all(lessThan(abs(fragcoord - %s.zw), float2(%f)))) {",
fNeighbors.fsIn(), kAABloatRadius);
// Handle the case where all 3 corners defer to the previous neighbor.
- f->codeAppendf( "if (%s != 0 || !all(lessThan(abs(fragcoord - %s.xy), vec2(%f)))) {",
+ f->codeAppendf( "if (%s != 0 || !all(lessThan(abs(fragcoord - %s.xy), float2(%f)))) {",
fCornerIdx.fsIn(), fNeighbors.fsIn(), kAABloatRadius);
f->codeAppend ( "discard;");
f->codeAppend ( "}");
@@ -179,7 +181,7 @@ void GrCCPRTriangleCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
// Erase what the hull and two edges wrote at this corner in previous shaders (the two .5's
// for the edges and the -1 for the hull cancel each other out).
- f->codeAppendf("%s = dot(vec3(fragcoord, 1) * mat2x3(%s), vec2(1));",
+ f->codeAppendf("%s = dot(float3(fragcoord, 1) * float2x3(%s), float2(1));",
outputCoverage, fEdgeDistances.fsIn());
// Sample the two edges at this corner.
@@ -187,15 +189,15 @@ void GrCCPRTriangleCornerProcessor::emitShaderCoverage(GrGLSLFragmentBuilder* f,
f->codeAppendf("%s(%s[1]);", sampleEdgeFn.c_str(), fEdgeDistances.fsIn());
// Handle the opposite edge if the next neighbor will defer to us.
- f->codeAppendf("if (all(lessThan(abs(fragcoord - %s.xy), vec2(%f)))) {",
+ f->codeAppendf("if (all(lessThan(abs(fragcoord - %s.xy), float2(%f)))) {",
fNeighbors.fsIn(), kAABloatRadius);
// Erase the coverage the opposite edge wrote to this corner.
- f->codeAppendf( "%s += dot(%s[2], vec3(fragcoord, 1)) + 0.5;",
+ f->codeAppendf( "%s += dot(%s[2], float3(fragcoord, 1)) + 0.5;",
outputCoverage, fEdgeDistances.fsIn());
// Sample the opposite edge.
f->codeAppendf( "%s(%s[2]);", sampleEdgeFn.c_str(), fEdgeDistances.fsIn());
f->codeAppend ("}");
- f->codeAppendf("highp vec4 widths = max(%s - %s, 0);", rightedge.c_str(), leftedge.c_str());
- f->codeAppendf("%s += dot(widths, vec4(0.25));", outputCoverage);
+ f->codeAppendf("highp float4 widths = max(%s - %s, 0);", rightedge.c_str(), leftedge.c_str());
+ f->codeAppendf("%s += dot(widths, float4(0.25));", outputCoverage);
}
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index d45cd75cb8..50c47e8d78 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -146,7 +146,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str());
- fragBuilder->codeAppendf("%s = vec2(%s, %s);", gF.c_str(), dfdx.c_str(), dfdy.c_str());
+ fragBuilder->codeAppendf("%s = float2(%s, %s);", gF.c_str(), dfdx.c_str(), dfdy.c_str());
fragBuilder->codeAppendf("%s = sqrt(dot(%s, %s));",
gFM.c_str(), gF.c_str(), gF.c_str());
fragBuilder->codeAppendf("%s = %s.x*%s.x - %s.y*%s.z;",
@@ -175,7 +175,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str(),
v.fsIn(), dklmdy.c_str());
- fragBuilder->codeAppendf("%s = vec2(%s, %s);", gF.c_str(), dfdx.c_str(), dfdy.c_str());
+ fragBuilder->codeAppendf("%s = float2(%s, %s);", gF.c_str(), dfdx.c_str(), dfdy.c_str());
fragBuilder->codeAppendf("%s = sqrt(dot(%s, %s));",
gFM.c_str(), gF.c_str(), gF.c_str());
fragBuilder->codeAppendf("%s = %s.x * %s.x - %s.y * %s.z;",
@@ -207,10 +207,10 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
kHigh_GrSLPrecision,
"Coverage",
&coverageScale);
- fragBuilder->codeAppendf("%s = vec4(%s * %s);",
+ fragBuilder->codeAppendf("%s = float4(%s * %s);",
args.fOutputCoverage, coverageScale, edgeAlpha.c_str());
} else {
- fragBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
+ fragBuilder->codeAppendf("%s = float4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
}
}
@@ -367,9 +367,9 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
switch (fEdgeType) {
case kHairlineAA_GrProcessorEdgeType: {
- fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.y,"
+ fragBuilder->codeAppendf("float2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 duvdy = dFdy(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 gF = float2(2.0 * %s.x * duvdx.x - duvdx.y,"
" 2.0 * %s.x * duvdy.x - duvdy.y);",
v.fsIn(), v.fsIn());
fragBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);",
@@ -381,9 +381,9 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
break;
}
case kFillAA_GrProcessorEdgeType: {
- fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.y,"
+ fragBuilder->codeAppendf("float2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 duvdy = dFdy(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 gF = float2(2.0 * %s.x * duvdx.x - duvdx.y,"
" 2.0 * %s.x * duvdy.x - duvdy.y);",
v.fsIn(), v.fsIn());
fragBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);",
@@ -411,9 +411,9 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
kDefault_GrSLPrecision,
"Coverage",
&coverageScale);
- fragBuilder->codeAppendf("%s = vec4(%s * edgeAlpha);", args.fOutputCoverage, coverageScale);
+ fragBuilder->codeAppendf("%s = float4(%s * edgeAlpha);", args.fOutputCoverage, coverageScale);
} else {
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
}
@@ -565,7 +565,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
kHigh_GrSLPrecision, "KLM", &devkLMMatrixName);
GrGLSLVertToFrag v(kVec3f_GrSLType);
varyingHandler->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = %s * vec3(%s, 1);",
+ vertBuilder->codeAppendf("%s = %s * float3(%s, 1);",
v.vsOut(), devkLMMatrixName, gpArgs->fPositionVar.c_str());
@@ -574,12 +574,12 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
varyingHandler->addVarying("GradCoeffs", &gradCoeffs, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("highp float k = %s[0], l = %s[1], m = %s[2];",
v.vsOut(), v.vsOut(), v.vsOut());
- vertBuilder->codeAppendf("highp vec2 gk = vec2(%s[0][0], %s[1][0]), "
- "gl = vec2(%s[0][1], %s[1][1]), "
- "gm = vec2(%s[0][2], %s[1][2]);",
+ vertBuilder->codeAppendf("highp float2 gk = float2(%s[0][0], %s[1][0]), "
+ "gl = float2(%s[0][1], %s[1][1]), "
+ "gm = float2(%s[0][2], %s[1][2]);",
devkLMMatrixName, devkLMMatrixName, devkLMMatrixName,
devkLMMatrixName, devkLMMatrixName, devkLMMatrixName);
- vertBuilder->codeAppendf("%s = vec4(3 * k * gk, -m * gl - l * gm);",
+ vertBuilder->codeAppendf("%s = float4(3 * k * gk, -m * gl - l * gm);",
gradCoeffs.vsOut());
}
@@ -646,7 +646,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
}
- fragBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
+ fragBuilder->codeAppendf("%s = float4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
}
void GrGLCubicEffect::GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 4095f93e7a..28fcd9e1dc 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -71,26 +71,26 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
*
* This is GLSL, so the matrix is column-major (transposed from standard matrix notation).
*/
- fragBuilder->codeAppend("mat4 kMitchellCoefficients = mat4("
+ fragBuilder->codeAppend("float4x4 kMitchellCoefficients = float4x4("
" 1.0 / 18.0, 16.0 / 18.0, 1.0 / 18.0, 0.0 / 18.0,"
"-9.0 / 18.0, 0.0 / 18.0, 9.0 / 18.0, 0.0 / 18.0,"
"15.0 / 18.0, -36.0 / 18.0, 27.0 / 18.0, -6.0 / 18.0,"
"-7.0 / 18.0, 21.0 / 18.0, -21.0 / 18.0, 7.0 / 18.0);");
- fragBuilder->codeAppendf("vec2 coord = %s - %s * vec2(0.5);", coords2D.c_str(), imgInc);
+ fragBuilder->codeAppendf("float2 coord = %s - %s * float2(0.5);", coords2D.c_str(), imgInc);
// We unnormalize the coord in order to determine our fractional offset (f) within the texel
// We then snap coord to a texel center and renormalize. The snap prevents cases where the
// starting coords are near a texel boundary and accumulations of imgInc would cause us to skip/
// double hit a texel.
fragBuilder->codeAppendf("coord /= %s;", imgInc);
- fragBuilder->codeAppend("vec2 f = fract(coord);");
- fragBuilder->codeAppendf("coord = (coord - f + vec2(0.5)) * %s;", imgInc);
- fragBuilder->codeAppend("vec4 wx = kMitchellCoefficients * vec4(1.0, f.x, f.x * f.x, f.x * f.x * f.x);");
- fragBuilder->codeAppend("vec4 wy = kMitchellCoefficients * vec4(1.0, f.y, f.y * f.y, f.y * f.y * f.y);");
- fragBuilder->codeAppend("vec4 rowColors[4];");
+ fragBuilder->codeAppend("float2 f = fract(coord);");
+ fragBuilder->codeAppendf("coord = (coord - f + float2(0.5)) * %s;", imgInc);
+ fragBuilder->codeAppend("float4 wx = kMitchellCoefficients * float4(1.0, f.x, f.x * f.x, f.x * f.x * f.x);");
+ fragBuilder->codeAppend("float4 wy = kMitchellCoefficients * float4(1.0, f.y, f.y * f.y, f.y * f.y * f.y);");
+ fragBuilder->codeAppend("float4 rowColors[4];");
for (int y = 0; y < 4; ++y) {
for (int x = 0; x < 4; ++x) {
SkString coord;
- coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1);
+ coord.printf("coord + %s * float2(%d, %d)", imgInc, x - 1, y - 1);
SkString sampleVar;
sampleVar.printf("rowColors[%d]", x);
fDomain.sampleTexture(fragBuilder,
@@ -102,7 +102,7 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
args.fTexSamplers[0]);
}
fragBuilder->codeAppendf(
- "vec4 s%d = wx.x * rowColors[0] + wx.y * rowColors[1] + wx.z * rowColors[2] + wx.w * rowColors[3];",
+ "float4 s%d = wx.x * rowColors[0] + wx.y * rowColors[1] + wx.z * rowColors[2] + wx.w * rowColors[3];",
y);
}
SkString bicubicColor("(wy.x * s0 + wy.y * s1 + wy.z * s2 + wy.w * s3)");
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 9de3b463c4..151c529ef8 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -67,7 +67,7 @@ public:
v.fsIn(),
kVec2f_GrSLType);
fragBuilder->codeAppend(";");
- fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
} else {
fragBuilder->codeAppendf("%s = ", args.fOutputCoverage);
fragBuilder->appendTextureLookup(args.fTexSamplers[0], v.fsIn(), kVec2f_GrSLType);
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
index aa39d95a79..f63422ffcd 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp
@@ -28,8 +28,9 @@ public:
"float factor = 1.0 - %s.w;\n@switch (%d) {\n case 0:\n factor = "
"exp((-factor * factor) * 4.0) - 0.017999999999999999;\n break;\n case "
"1:\n factor = smoothstep(1.0, 0.0, factor);\n break;\n}\n%s = "
- "vec4(factor);\n",
- args.fInputColor ? args.fInputColor : "vec4(1)", _outer.mode(), args.fOutputColor);
+ "float4(factor);\n",
+ args.fInputColor ? args.fInputColor : "float4(1)", _outer.mode(),
+ args.fOutputColor);
}
private:
diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
index 2c4d5ef582..3ff233a705 100644
--- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
+++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.fp
@@ -24,5 +24,5 @@ void main() {
factor = smoothstep(1.0, 0.0, factor);
break;
}
- sk_OutColor = vec4(factor);
+ sk_OutColor = float4(factor);
}
diff --git a/src/gpu/effects/GrCircleEffect.cpp b/src/gpu/effects/GrCircleEffect.cpp
index 638d94d357..97bfda4dbb 100644
--- a/src/gpu/effects/GrCircleEffect.cpp
+++ b/src/gpu/effects/GrCircleEffect.cpp
@@ -27,11 +27,11 @@ public:
fCircleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType,
kDefault_GrSLPrecision, "circle");
fragBuilder->codeAppendf(
- "vec2 prevCenter;\nfloat prevRadius = %f;\nfloat d;\n@if (%d == 2 || %d == 3) {\n "
- " d = (length((%s.xy - sk_FragCoord.xy) * %s.w) - 1.0) * %s.z;\n} else {\n d = "
- "(1.0 - length((%s.xy - sk_FragCoord.xy) * %s.w)) * %s.z;\n}\n@if ((%d == 1 || %d "
- "== 3) || %d == 4) {\n d = clamp(d, 0.0, 1.0);\n} else {\n d = d > 0.5 ? 1.0 "
- ": 0.0;\n}\n%s = %s * d;\n",
+ "float2 prevCenter;\nfloat prevRadius = %f;\nfloat d;\n@if (%d == 2 || %d == 3) "
+ "{\n d = (length((%s.xy - sk_FragCoord.xy) * %s.w) - 1.0) * %s.z;\n} else {\n "
+ " d = (1.0 - length((%s.xy - sk_FragCoord.xy) * %s.w)) * %s.z;\n}\n@if ((%d == 1 "
+ "|| %d == 3) || %d == 4) {\n d = clamp(d, 0.0, 1.0);\n} else {\n d = d > 0.5 "
+ "? 1.0 : 0.0;\n}\n%s = %s * d;\n",
prevRadius, _outer.edgeType(), _outer.edgeType(),
args.fUniformHandler->getUniformCStr(fCircleVar),
args.fUniformHandler->getUniformCStr(fCircleVar),
@@ -40,7 +40,7 @@ public:
args.fUniformHandler->getUniformCStr(fCircleVar),
args.fUniformHandler->getUniformCStr(fCircleVar), _outer.edgeType(),
_outer.edgeType(), _outer.edgeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "vec4(1)");
+ args.fInputColor ? args.fInputColor : "float4(1)");
}
private:
diff --git a/src/gpu/effects/GrCircleEffect.fp b/src/gpu/effects/GrCircleEffect.fp
index 74973ca064..884112ecc9 100644
--- a/src/gpu/effects/GrCircleEffect.fp
+++ b/src/gpu/effects/GrCircleEffect.fp
@@ -6,14 +6,14 @@
*/
layout(key) in int edgeType;
-in vec2 center;
+in float2 center;
in float radius;
-vec2 prevCenter;
+float2 prevCenter;
float prevRadius = -1;
// The circle uniform is (center.x, center.y, radius + 0.5, 1 / (radius + 0.5)) for regular
// fills and (..., radius - 0.5, 1 / (radius - 0.5)) for inverse fills.
-uniform vec4 circle;
+uniform float4 circle;
@optimizationFlags { kCompatibleWithCoverageAsAlpha_OptimizationFlag }
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index d83e82d8d9..880648199e 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -25,12 +25,12 @@ public:
if (nullptr == args.fInputColor) {
// could optimize this case, but we aren't for now.
- args.fInputColor = "vec4(1)";
+ args.fInputColor = "float4(1)";
}
// Aggressively round to the nearest exact (N / 255) floating point value. This lets us
// find a round-trip preserving pair on some GPUs that do odd byte to float conversion.
- fragBuilder->codeAppendf("vec4 color = floor(%s * 255.0 + 0.5) / 255.0;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = floor(%s * 255.0 + 0.5) / 255.0;", args.fInputColor);
switch (cce.pmConversion()) {
case GrConfigConversionEffect::kToPremul_PMConversion:
@@ -40,7 +40,7 @@ public:
case GrConfigConversionEffect::kToUnpremul_PMConversion:
fragBuilder->codeAppend(
- "color.rgb = color.a <= 0.0 ? vec3(0,0,0) : floor(color.rgb / color.a * 255.0 + 0.5) / 255.0;");
+ "color.rgb = color.a <= 0.0 ? float3(0,0,0) : floor(color.rgb / color.a * 255.0 + 0.5) / 255.0;");
break;
default:
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 7dba3de04d..bb61cc1f20 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -199,7 +199,7 @@ void GrGLConvexPolyEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppend("\t\tfloat alpha = 1.0;\n");
fragBuilder->codeAppend("\t\tfloat edge;\n");
for (int i = 0; i < cpe.getEdgeCount(); ++i) {
- fragBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(sk_FragCoord.x, sk_FragCoord.y, "
+ fragBuilder->codeAppendf("\t\tedge = dot(%s[%d], float3(sk_FragCoord.x, sk_FragCoord.y, "
"1));\n",
edgeArrayName, i);
if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) {
diff --git a/src/gpu/effects/GrDisableColorXP.cpp b/src/gpu/effects/GrDisableColorXP.cpp
index 14464f78e3..2d66e1e1b6 100644
--- a/src/gpu/effects/GrDisableColorXP.cpp
+++ b/src/gpu/effects/GrDisableColorXP.cpp
@@ -53,7 +53,7 @@ private:
// you do not give gl_FragColor a value, the gl context is lost and we end up drawing
// nothing. So this fix just sets the gl_FragColor arbitrarily to 0.
GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder;
- fragBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary);
+ fragBuilder->codeAppendf("%s = float4(0);", args.fOutputPrimary);
}
void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index c8dd4ebd77..0dfb315960 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -89,12 +89,12 @@ public:
GrGLSLVertToFrag st(kVec2f_GrSLType);
varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(),
+ vertBuilder->codeAppendf("%s = float2(%d, %d) * %s;", st.vsOut(),
atlas->width(), atlas->height(),
dfTexEffect.inTextureCoords()->fName);
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highp vec2 uv = %s;\n", uv.fsIn());
+ fragBuilder->codeAppendf("highp float2 uv = %s;\n", uv.fsIn());
fragBuilder->codeAppend("\tfloat texColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0],
@@ -141,19 +141,19 @@ 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("vec2 dist_grad = vec2(dFdx(distance), dFdy(distance));");
+ fragBuilder->codeAppend("float2 dist_grad = float2(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("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppendf("vec2 Jdx = dFdx(%s);", st.fsIn());
- fragBuilder->codeAppendf("vec2 Jdy = dFdy(%s);", st.fsIn());
- fragBuilder->codeAppend("vec2 grad = vec2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ 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->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
// this gives us a smooth step across approximately one fragment
@@ -172,7 +172,7 @@ public:
fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
}
- fragBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(val);", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
@@ -352,7 +352,7 @@ public:
"TextureSize", &textureSizeUniName);
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highp vec2 uv = %s;", v.fsIn());
+ fragBuilder->codeAppendf("highp float2 uv = %s;", v.fsIn());
fragBuilder->codeAppend("float texColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0],
@@ -362,7 +362,7 @@ public:
fragBuilder->codeAppend("float distance = "
SK_DistanceFieldMultiplier "*(texColor - " SK_DistanceFieldThreshold ");");
- fragBuilder->codeAppendf("highp vec2 st = uv*%s;", textureSizeUniName);
+ fragBuilder->codeAppendf("highp float2 st = uv*%s;", textureSizeUniName);
fragBuilder->codeAppend("float afwidth;");
bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) ==
kUniformScale_DistanceFieldEffectMask;
@@ -398,19 +398,19 @@ 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("vec2 dist_grad = vec2(dFdx(distance), dFdy(distance));");
+ fragBuilder->codeAppend("float2 dist_grad = float2(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("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppend("vec2 Jdx = dFdx(st);");
- fragBuilder->codeAppend("vec2 Jdy = dFdy(st);");
- fragBuilder->codeAppend("vec2 grad = vec2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ 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(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
// this gives us a smooth step across approximately one fragment
@@ -426,7 +426,7 @@ public:
fragBuilder->codeAppend("float val = smoothstep(-afwidth, afwidth, distance);");
}
- fragBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(val);", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc,
@@ -601,7 +601,7 @@ public:
GrGLSLVertToFrag st(kVec2f_GrSLType);
varyingHandler->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = vec2(%d, %d) * %s;", st.vsOut(),
+ vertBuilder->codeAppendf("%s = float2(%d, %d) * %s;", st.vsOut(),
atlas->width(), atlas->height(),
dfTexEffect.inTextureCoords()->fName);
@@ -609,7 +609,7 @@ public:
// create LCD offset adjusted by inverse of transform
// Use highp to work around aliasing issues
- fragBuilder->codeAppendf("highp vec2 uv = %s;\n", uv.fsIn());
+ fragBuilder->codeAppendf("highp float2 uv = %s;\n", uv.fsIn());
SkScalar lcdDelta = 1.0f / (3.0f * atlas->width());
if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
@@ -624,36 +624,36 @@ public:
// 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());
#endif
- fragBuilder->codeAppend("vec2 offset = vec2(st_grad_len*delta, 0.0);");
+ fragBuilder->codeAppend("float2 offset = float2(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("vec2 st_grad = dFdx(%s);", st.fsIn());
- fragBuilder->codeAppend("vec2 offset = delta*st_grad;");
+ fragBuilder->codeAppendf("float2 st_grad = dFdx(%s);", st.fsIn());
+ fragBuilder->codeAppend("float2 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("vec2 st_grad = dFdy(%s);", st.fsIn());
- fragBuilder->codeAppend("vec2 offset = delta*vec2(st_grad.y, -st_grad.x);");
+ fragBuilder->codeAppendf("float2 st_grad = dFdy(%s);", st.fsIn());
+ fragBuilder->codeAppend("float2 offset = delta*float2(st_grad.y, -st_grad.x);");
#endif
fragBuilder->codeAppend("float st_grad_len = length(st_grad);");
} else {
- fragBuilder->codeAppendf("vec2 st = %s;\n", st.fsIn());
+ fragBuilder->codeAppendf("float2 st = %s;\n", st.fsIn());
- fragBuilder->codeAppend("vec2 Jdx = dFdx(st);");
- fragBuilder->codeAppend("vec2 Jdy = dFdy(st);");
- fragBuilder->codeAppend("vec2 offset = delta*Jdx;");
+ fragBuilder->codeAppend("float2 Jdx = dFdx(st);");
+ fragBuilder->codeAppend("float2 Jdy = dFdy(st);");
+ fragBuilder->codeAppend("float2 offset = delta*Jdx;");
}
// green is distance to uv center
- fragBuilder->codeAppend("\tvec4 texColor = ");
+ fragBuilder->codeAppend("\tfloat4 texColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv", kVec2f_GrSLType);
fragBuilder->codeAppend(";\n");
- fragBuilder->codeAppend("\tvec3 distance;\n");
+ fragBuilder->codeAppend("\tfloat3 distance;\n");
fragBuilder->codeAppend("\tdistance.y = texColor.r;\n");
// red is distance to left offset
- fragBuilder->codeAppend("\tvec2 uv_adjusted = uv - offset;\n");
+ fragBuilder->codeAppend("\tfloat2 uv_adjusted = uv - offset;\n");
fragBuilder->codeAppend("\ttexColor = ");
fragBuilder->appendTextureLookup(args.fTexSamplers[0], "uv_adjusted", kVec2f_GrSLType);
fragBuilder->codeAppend(";\n");
@@ -666,7 +666,7 @@ public:
fragBuilder->codeAppend("\tdistance.z = texColor.r;\n");
fragBuilder->codeAppend("\tdistance = "
- "vec3(" SK_DistanceFieldMultiplier ")*(distance - vec3(" SK_DistanceFieldThreshold"));");
+ "float3(" SK_DistanceFieldMultiplier ")*(distance - float3(" SK_DistanceFieldThreshold"));");
// adjust width based on gamma
const char* distanceAdjustUniName = nullptr;
@@ -692,16 +692,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("vec2 dist_grad = vec2(dFdx(distance.r), dFdy(distance.r));");
+ fragBuilder->codeAppend("float2 dist_grad = float2(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("if (dg_len2 < 0.0001) {");
- fragBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
+ fragBuilder->codeAppend("dist_grad = float2(0.7071, 0.7071);");
fragBuilder->codeAppend("} else {");
fragBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
fragBuilder->codeAppend("}");
- fragBuilder->codeAppend("vec2 grad = vec2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
+ fragBuilder->codeAppend("float2 grad = float2(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 +713,11 @@ public:
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppendf("%s = "
- "vec4(clamp((distance + vec3(afwidth)) / vec3(2.0 * afwidth), 0.0, 1.0), 1.0);",
+ "float4(clamp((distance + float3(afwidth)) / float3(2.0 * afwidth), 0.0, 1.0), 1.0);",
args.fOutputCoverage);
} else {
fragBuilder->codeAppendf(
- "%s = vec4(smoothstep(vec3(-afwidth), vec3(afwidth), distance), 1.0);",
+ "%s = float4(smoothstep(float3(-afwidth), float3(afwidth), distance), 1.0);",
args.fOutputCoverage);
}
}
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index 73ab1812a9..38e4c77564 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -31,13 +31,13 @@ public:
"int x = int(sk_FragCoord.x);\n int y = int(sk_FragCoord.y);\n uint m = "
"uint((((((y & 1) << 5 | (x & 1) << 4) | (y & 2) << 2) | (x & 2) << 1) | (y & 4) "
">> 1) | (x & 4) >> 2);\n value = float(m) / 64.0 - 0.4921875;\n} else {\n "
- "value = fract(sin(dot(sk_FragCoord.xy, vec2(12.989800000000001, "
- "78.233000000000004))) * 43758.545299999998) - 0.5;\n}\n%s = vec4(clamp(%s.xyz + "
+ "value = fract(sin(dot(sk_FragCoord.xy, float2(12.989800000000001, "
+ "78.233000000000004))) * 43758.545299999998) - 0.5;\n}\n%s = float4(clamp(%s.xyz + "
"value * range, 0.0, %s.w), %s.w);\n",
_outer.rangeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "vec4(1)",
- args.fInputColor ? args.fInputColor : "vec4(1)",
- args.fInputColor ? args.fInputColor : "vec4(1)");
+ args.fInputColor ? args.fInputColor : "float4(1)",
+ args.fInputColor ? args.fInputColor : "float4(1)",
+ args.fInputColor ? args.fInputColor : "float4(1)");
}
private:
diff --git a/src/gpu/effects/GrDitherEffect.fp b/src/gpu/effects/GrDitherEffect.fp
index 937efae264..f983702f2b 100644
--- a/src/gpu/effects/GrDitherEffect.fp
+++ b/src/gpu/effects/GrDitherEffect.fp
@@ -61,11 +61,11 @@ void main() {
// the assumption that sin(<big number>) oscillates with high frequency
// and sampling it will generate "randomness". Since we're using this
// for rendering and not cryptography it should be OK.
- value = fract(sin(dot(sk_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453) - .5;
+ value = fract(sin(dot(sk_FragCoord.xy, float2(12.9898, 78.233))) * 43758.5453) - .5;
}
// For each color channel, add the random offset to the channel value and then clamp
// between 0 and alpha to keep the color premultiplied.
- sk_OutColor = vec4(clamp(sk_InColor.rgb + value * range, 0, sk_InColor.a), sk_InColor.a);
+ sk_OutColor = float4(clamp(sk_InColor.rgb + value * range, 0, sk_InColor.a), sk_InColor.a);
}
@test(testData) {
diff --git a/src/gpu/effects/GrEllipseEffect.cpp b/src/gpu/effects/GrEllipseEffect.cpp
index 020c34e644..ebc3bf7e37 100644
--- a/src/gpu/effects/GrEllipseEffect.cpp
+++ b/src/gpu/effects/GrEllipseEffect.cpp
@@ -23,7 +23,7 @@ public:
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrEllipseEffect& _outer = args.fFp.cast<GrEllipseEffect>();
(void)_outer;
- prevRadii = vec2(-1.0);
+ prevRadii = float2(-1.0);
useScale = sk_Caps.floatPrecisionVaries;
fEllipseVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType,
kHigh_GrSLPrecision, "ellipse");
@@ -32,23 +32,26 @@ public:
kDefault_GrSLPrecision, "scale");
}
fragBuilder->codeAppendf(
- "vec2 prevCenter;\nvec2 prevRadii = vec2(%f, %f);\nbool useScale = %s;\nvec2 d = "
- "sk_FragCoord.xy - %s.xy;\n@if (useScale) {\n d *= %s.y;\n}\nvec2 Z = d * "
- "%s.zw;\nfloat implicit = dot(Z, d) - 1.0;\nfloat grad_dot = 4.0 * dot(Z, "
- "Z);\ngrad_dot = max(grad_dot, 0.0001);\nfloat approx_dist = implicit * "
- "inversesqrt(grad_dot);\n@if (useScale) {\n approx_dist *= %s.x;\n}\nfloat "
- "alpha;\n@switch (%d) {\n case 0:\n alpha = approx_dist > 0.0 ? 0.0 : "
- "1.0;\n break;\n case 1:\n alpha = clamp(0.5 - approx_dist, 0.0, "
- "1.0);\n break;\n case 2:\n alpha = approx_dist > 0.0 ? 1.0 : "
- "0.0;\n break;\n case 3:\n alpha = clamp(0.5 + approx_dist, 0.0, "
- "1.0);\n break;\n default:\n discard;\n}\n%s = %s * alpha;\n",
+ "float2 prevCenter;\nfloat2 prevRadii = float2(%f, %f);\nbool useScale = "
+ "%s;\nfloat2 d = sk_FragCoord.xy - %s.xy;\n@if (useScale) {\n d *= "
+ "%s.y;\n}\nfloat2 Z = d * %s.zw;\nfloat implicit = dot(Z, d) - 1.0;\nfloat "
+ "grad_dot = 4.0 * dot(Z, Z);\ngrad_dot = max(grad_dot, 0.0001);\nfloat approx_dist "
+ "= implicit * inversesqrt(grad_dot);\n@if (useScale) {\n approx_dist *= "
+ "%s.x;\n}\nfloat alpha;\n@switch (%d) {\n case 0:\n alpha = approx_dist "
+ "> 0.0 ? 0.0 : 1.0;\n break;\n case 1:\n alpha = clamp(0.5 - "
+ "approx_dist, 0.0, 1.0);\n break;\n case 2:\n alpha = approx_dist "
+ "> 0.0 ? 1.0 : 0.0;\n break;\n case 3:\n alpha = clamp(0.5 + "
+ "approx_dist, 0.0, 1.0);\n break;\n default:\n discard;\n}\n%s = "
+ "%s * alpha;\n",
prevRadii.fX, prevRadii.fY, (useScale ? "true" : "false"),
args.fUniformHandler->getUniformCStr(fEllipseVar),
- fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar) : "vec2(0.0)",
+ fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar)
+ : "float2(0.0)",
args.fUniformHandler->getUniformCStr(fEllipseVar),
- fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar) : "vec2(0.0)",
+ fScaleVar.isValid() ? args.fUniformHandler->getUniformCStr(fScaleVar)
+ : "float2(0.0)",
_outer.edgeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "vec4(1)");
+ args.fInputColor ? args.fInputColor : "float4(1)");
}
private:
diff --git a/src/gpu/effects/GrEllipseEffect.fp b/src/gpu/effects/GrEllipseEffect.fp
index 7bf32206fb..85c4c96f75 100644
--- a/src/gpu/effects/GrEllipseEffect.fp
+++ b/src/gpu/effects/GrEllipseEffect.fp
@@ -6,17 +6,17 @@
*/
layout(key) in int edgeType;
-in vec2 center;
-in vec2 radii;
+in float2 center;
+in float2 radii;
-vec2 prevCenter;
-vec2 prevRadii = vec2(-1);
+float2 prevCenter;
+float2 prevRadii = float2(-1);
// The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
// The last two terms can underflow on mediump, so we use highp.
-uniform highp vec4 ellipse;
+uniform highp float4 ellipse;
bool useScale = sk_Caps.floatPrecisionVaries;
-layout(when=useScale) uniform vec2 scale;
+layout(when=useScale) uniform float2 scale;
@optimizationFlags { kCompatibleWithCoverageAsAlpha_OptimizationFlag }
@@ -50,7 +50,7 @@ layout(when=useScale) uniform vec2 scale;
void main() {
// d is the offset to the ellipse center
- vec2 d = sk_FragCoord.xy - ellipse.xy;
+ float2 d = sk_FragCoord.xy - ellipse.xy;
// If we're on a device with a "real" mediump then we'll do the distance computation in a space
// that is normalized by the larger radius. The scale uniform will be scale, 1/scale. The
// inverse squared radii uniform values are already in this normalized space. The center is
@@ -58,7 +58,7 @@ void main() {
@if (useScale) {
d *= scale.y;
}
- vec2 Z = d * ellipse.zw;
+ float2 Z = d * ellipse.zw;
// implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
float implicit = dot(Z, d) - 1;
// grad_dot is the squared length of the gradient of the implicit.
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index ebe86dd8f7..eb6f49f7ad 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -59,13 +59,13 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
- fragBuilder->codeAppendf("%s = vec4(0, 0, 0, 0);", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(0, 0, 0, 0);", args.fOutputColor);
const GrShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni);
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
- fragBuilder->codeAppendf("vec2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
- fragBuilder->codeAppend("vec2 coordSampled = vec2(0, 0);");
+ fragBuilder->codeAppendf("float2 coord = %s - %d.0 * %s;", coords2D.c_str(), ce.radius(), imgInc);
+ fragBuilder->codeAppend("float2 coordSampled = float2(0, 0);");
// Manually unroll loop because some drivers don't; yields 20-30% speedup.
const char* kVecSuffix[4] = {".x", ".y", ".z", ".w"};
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 46dc2d8cb9..9d8e793c13 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -70,9 +70,9 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
- fragBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);");
- fragBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset, imgInc);
- fragBuilder->codeAppend("vec4 c;");
+ fragBuilder->codeAppend("float4 sum = float4(0, 0, 0, 0);");
+ fragBuilder->codeAppendf("float2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset, imgInc);
+ fragBuilder->codeAppend("float4 c;");
const char* kVecSuffix[4] = { ".x", ".y", ".z", ".w" };
for (int y = 0; y < kHeight; y++) {
@@ -83,7 +83,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("float k = %s[%d]%s;", kernel, offset / 4,
kVecSuffix[offset & 0x3]);
SkString coord;
- coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc);
+ coord.printf("coord + float2(%d, %d) * %s", x, y, imgInc);
fDomain.sampleTexture(fragBuilder,
uniformHandler,
args.fShaderCaps,
diff --git a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
index d26377b691..6ae770b820 100644
--- a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
+++ b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
@@ -71,13 +71,13 @@ public:
}
if (nullptr == args.fInputColor) {
- args.fInputColor = "vec4(1)";
+ args.fInputColor = "float4(1)";
}
- fragBuilder->codeAppendf("vec4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = %s;", args.fInputColor);
// 1: Un-premultiply the input color (if necessary)
fragBuilder->codeAppendf("float nonZeroAlpha = max(color.a, 0.00001);");
- fragBuilder->codeAppendf("color = vec4(color.rgb / nonZeroAlpha, nonZeroAlpha);");
+ fragBuilder->codeAppendf("color = float4(color.rgb / nonZeroAlpha, nonZeroAlpha);");
// 2: Apply src transfer function (to get to linear RGB)
if (srcCoeffsName) {
@@ -89,7 +89,7 @@ public:
// 3: Apply gamut matrix
if (gamutXformName) {
fragBuilder->codeAppendf(
- "color.rgb = (%s * vec4(color.rgb, 1.0)).rgb;", gamutXformName);
+ "color.rgb = (%s * float4(color.rgb, 1.0)).rgb;", gamutXformName);
}
// 4: Apply dst transfer fn
@@ -100,7 +100,7 @@ public:
}
// 5: Premultiply again
- fragBuilder->codeAppendf("%s = vec4(color.rgb * color.a, color.a);", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(color.rgb * color.a, color.a);", args.fOutputColor);
}
static inline void GenKey(const GrProcessor& processor, const GrShaderCaps&,
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index ffb91cc6d1..c571b837fd 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -440,7 +440,7 @@ static void append_color_output(const PorterDuffXferProcessor& xp,
SkASSERT(inColor);
switch (outputType) {
case BlendFormula::kNone_OutputType:
- fragBuilder->codeAppendf("%s = vec4(0.0);", output);
+ fragBuilder->codeAppendf("%s = float4(0.0);", output);
break;
case BlendFormula::kCoverage_OutputType:
// We can have a coverage formula while not reading coverage if there are mixed samples.
@@ -456,7 +456,7 @@ static void append_color_output(const PorterDuffXferProcessor& xp,
fragBuilder->codeAppendf("%s = (1.0 - %s.a) * %s;", output, inColor, inCoverage);
break;
case BlendFormula::kISCModulate_OutputType:
- fragBuilder->codeAppendf("%s = (vec4(1.0) - %s) * %s;", output, inColor, inCoverage);
+ fragBuilder->codeAppendf("%s = (float4(1.0) - %s) * %s;", output, inColor, inCoverage);
break;
default:
SkFAIL("Unsupported output type.");
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index edf8eb6c37..8dde914bb4 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -197,13 +197,13 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
// alphas together.
switch (crre.getCircularCornerFlags()) {
case CircularRRectEffect::kAll_CornerFlags:
- fragBuilder->codeAppendf("vec2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
- fragBuilder->codeAppendf("vec2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(max(dxy0, dxy1), 0.0);");
+ fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
+ fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
+ fragBuilder->codeAppend("float2 dxy = max(max(dxy0, dxy1), 0.0);");
fragBuilder->codeAppendf("float alpha = %s;", clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTopLeft_CornerFlag:
- fragBuilder->codeAppendf("vec2 dxy = max(%s.xy - sk_FragCoord.xy, 0.0);",
+ fragBuilder->codeAppendf("float2 dxy = max(%s.xy - sk_FragCoord.xy, 0.0);",
rectName);
fragBuilder->codeAppendf("float rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
rectName);
@@ -213,7 +213,7 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTopRight_CornerFlag:
- fragBuilder->codeAppendf("vec2 dxy = max(vec2(sk_FragCoord.x - %s.z, "
+ fragBuilder->codeAppendf("float2 dxy = max(float2(sk_FragCoord.x - %s.z, "
"%s.y - sk_FragCoord.y), 0.0);",
rectName, rectName);
fragBuilder->codeAppendf("float leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
@@ -224,7 +224,7 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottomRight_CornerFlag:
- fragBuilder->codeAppendf("vec2 dxy = max(sk_FragCoord.xy - %s.zw, 0.0);",
+ fragBuilder->codeAppendf("float2 dxy = max(sk_FragCoord.xy - %s.zw, 0.0);",
rectName);
fragBuilder->codeAppendf("float leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
rectName);
@@ -234,7 +234,7 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kBottomLeft_CornerFlag:
- fragBuilder->codeAppendf("vec2 dxy = max(vec2(%s.x - sk_FragCoord.x, sk_FragCoord.y - "
+ fragBuilder->codeAppendf("float2 dxy = max(float2(%s.x - sk_FragCoord.x, sk_FragCoord.y - "
"%s.w), 0.0);",
rectName, rectName);
fragBuilder->codeAppendf("float rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
@@ -245,18 +245,18 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kLeft_CornerFlags:
- fragBuilder->codeAppendf("vec2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
+ fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
fragBuilder->codeAppendf("float dy1 = sk_FragCoord.y - %s.w;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(vec2(dxy0.x, max(dxy0.y, dy1)), 0.0);");
+ fragBuilder->codeAppend("float2 dxy = max(float2(dxy0.x, max(dxy0.y, dy1)), 0.0);");
fragBuilder->codeAppendf("float rightAlpha = clamp(%s.z - sk_FragCoord.x, 0.0, 1.0);",
rectName);
fragBuilder->codeAppendf("float alpha = rightAlpha * %s;",
clampedCircleDistance.c_str());
break;
case CircularRRectEffect::kTop_CornerFlags:
- fragBuilder->codeAppendf("vec2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
+ fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
fragBuilder->codeAppendf("float dx1 = sk_FragCoord.x - %s.z;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(vec2(max(dxy0.x, dx1), dxy0.y), 0.0);");
+ fragBuilder->codeAppend("float2 dxy = max(float2(max(dxy0.x, dx1), dxy0.y), 0.0);");
fragBuilder->codeAppendf("float bottomAlpha = clamp(%s.w - sk_FragCoord.y, 0.0, 1.0);",
rectName);
fragBuilder->codeAppendf("float alpha = bottomAlpha * %s;",
@@ -264,8 +264,8 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
break;
case CircularRRectEffect::kRight_CornerFlags:
fragBuilder->codeAppendf("float dy0 = %s.y - sk_FragCoord.y;", rectName);
- fragBuilder->codeAppendf("vec2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(vec2(dxy1.x, max(dy0, dxy1.y)), 0.0);");
+ fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
+ fragBuilder->codeAppend("float2 dxy = max(float2(dxy1.x, max(dy0, dxy1.y)), 0.0);");
fragBuilder->codeAppendf("float leftAlpha = clamp(sk_FragCoord.x - %s.x, 0.0, 1.0);",
rectName);
fragBuilder->codeAppendf("float alpha = leftAlpha * %s;",
@@ -273,8 +273,8 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
break;
case CircularRRectEffect::kBottom_CornerFlags:
fragBuilder->codeAppendf("float dx0 = %s.x - sk_FragCoord.x;", rectName);
- fragBuilder->codeAppendf("vec2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
- fragBuilder->codeAppend("vec2 dxy = max(vec2(max(dx0, dxy1.x), dxy1.y), 0.0);");
+ fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
+ fragBuilder->codeAppend("float2 dxy = max(float2(max(dx0, dxy1.x), dxy1.y), 0.0);");
fragBuilder->codeAppendf("float topAlpha = clamp(sk_FragCoord.y - %s.y, 0.0, 1.0);",
rectName);
fragBuilder->codeAppendf("float alpha = topAlpha * %s;",
@@ -532,8 +532,8 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
// The code below is a simplified version of the above that performs maxs on the vector
// components before computing distances and alpha values so that only one distance computation
// need be computed to determine the min alpha.
- fragBuilder->codeAppendf("vec2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
- fragBuilder->codeAppendf("vec2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
+ fragBuilder->codeAppendf("float2 dxy0 = %s.xy - sk_FragCoord.xy;", rectName);
+ fragBuilder->codeAppendf("float2 dxy1 = sk_FragCoord.xy - %s.zw;", rectName);
// If we're on a device with a "real" mediump then we'll do the distance computation in a space
// that is normalized by the largest radius. The scale uniform will be scale, 1/scale. The
@@ -554,12 +554,12 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
kDefault_GrSLPrecision,
"invRadiiXY",
&invRadiiXYSqdName);
- fragBuilder->codeAppend("vec2 dxy = max(max(dxy0, dxy1), 0.0);");
+ fragBuilder->codeAppend("float2 dxy = max(max(dxy0, dxy1), 0.0);");
if (scaleName) {
fragBuilder->codeAppendf("dxy *= %s.y;", scaleName);
}
// Z is the x/y offsets divided by squared radii.
- fragBuilder->codeAppendf("vec2 Z = dxy * %s.xy;", invRadiiXYSqdName);
+ fragBuilder->codeAppendf("float2 Z = dxy * %s.xy;", invRadiiXYSqdName);
break;
}
case SkRRect::kNinePatch_Type: {
@@ -573,11 +573,11 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("dxy0 *= %s.y;", scaleName);
fragBuilder->codeAppendf("dxy1 *= %s.y;", scaleName);
}
- fragBuilder->codeAppend("vec2 dxy = max(max(dxy0, dxy1), 0.0);");
+ fragBuilder->codeAppend("float2 dxy = max(max(dxy0, dxy1), 0.0);");
// Z is the x/y offsets divided by squared radii. We only care about the (at most) one
// corner where both the x and y offsets are positive, hence the maxes. (The inverse
// squared radii will always be positive.)
- fragBuilder->codeAppendf("vec2 Z = max(max(dxy0 * %s.xy, dxy1 * %s.zw), 0.0);",
+ fragBuilder->codeAppendf("float2 Z = max(max(dxy0 * %s.xy, dxy1 * %s.zw), 0.0);",
invRadiiLTRBSqdName, invRadiiLTRBSqdName);
break;
diff --git a/src/gpu/effects/GrSRGBEffect.cpp b/src/gpu/effects/GrSRGBEffect.cpp
index ed924b35ff..1cffb9eef0 100644
--- a/src/gpu/effects/GrSRGBEffect.cpp
+++ b/src/gpu/effects/GrSRGBEffect.cpp
@@ -44,20 +44,20 @@ public:
}
if (nullptr == args.fInputColor) {
- args.fInputColor = "vec4(1)";
+ args.fInputColor = "float4(1)";
}
- fragBuilder->codeAppendf("vec4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 color = %s;", args.fInputColor);
if (srgbe.alpha() == GrSRGBEffect::Alpha::kPremul) {
fragBuilder->codeAppendf("float nonZeroAlpha = max(color.a, 0.00001);");
- fragBuilder->codeAppendf("color = vec4(color.rgb / nonZeroAlpha, color.a);");
+ fragBuilder->codeAppendf("color = float4(color.rgb / nonZeroAlpha, color.a);");
}
- fragBuilder->codeAppendf("color = vec4(%s(color.r), %s(color.g), %s(color.b), color.a);",
+ fragBuilder->codeAppendf("color = float4(%s(color.r), %s(color.g), %s(color.b), color.a);",
srgbFuncName.c_str(),
srgbFuncName.c_str(),
srgbFuncName.c_str());
if (srgbe.alpha() == GrSRGBEffect::Alpha::kPremul) {
- fragBuilder->codeAppendf("color = vec4(color.rgb, 1) * color.a;");
+ fragBuilder->codeAppendf("color = float4(color.rgb, 1) * color.a;");
}
fragBuilder->codeAppendf("%s = color;", args.fOutputColor);
}
diff --git a/src/gpu/effects/GrShadowGeoProc.cpp b/src/gpu/effects/GrShadowGeoProc.cpp
index 6ab993a857..046240cb1d 100644
--- a/src/gpu/effects/GrShadowGeoProc.cpp
+++ b/src/gpu/effects/GrShadowGeoProc.cpp
@@ -26,7 +26,7 @@ public:
// emit attributes
varyingHandler->emitAttributes(rsgp);
- fragBuilder->codeAppend("vec4 shadowParams;");
+ fragBuilder->codeAppend("float4 shadowParams;");
varyingHandler->addPassThroughAttribute(rsgp.inShadowParams(), "shadowParams");
// setup pass through color
@@ -48,7 +48,7 @@ public:
fragBuilder->codeAppend("float factor = 1.0 - clamp(distance, 0.0, shadowParams.w);");
fragBuilder->codeAppend("factor = exp(-factor * factor * 4.0) - 0.018;");
- fragBuilder->codeAppendf("%s = vec4(factor);",
+ fragBuilder->codeAppendf("%s = float4(factor);",
args.fOutputCoverage);
}
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index cab078b109..bbac5b5f4c 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -27,15 +27,15 @@ public:
SkSL::String sk_TransformedCoords2D_0 =
fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
- "vec4 _tmpVar1;%s = %s * %stexture(%s, %s).%s%s;\n", args.fOutputColor,
- args.fInputColor ? args.fInputColor : "vec4(1)",
+ "float4 _tmpVar1;%s = %s * %stexture(%s, %s).%s%s;\n", args.fOutputColor,
+ args.fInputColor ? args.fInputColor : "float4(1)",
fColorSpaceHelper.isValid() ? "(_tmpVar1 = " : "",
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
sk_TransformedCoords2D_0.c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
fColorSpaceHelper.isValid()
- ? SkStringPrintf(", vec4(clamp((%s * vec4(_tmpVar1.rgb, 1.0)).rgb, 0.0, "
- "_tmpVar1.a), _tmpVar1.a))",
+ ? SkStringPrintf(", float4(clamp((%s * float4(_tmpVar1.rgb, 1.0)).rgb, "
+ "0.0, _tmpVar1.a), _tmpVar1.a))",
args.fUniformHandler->getUniformCStr(
fColorSpaceHelper.gamutXformUniform()))
.c_str()
diff --git a/src/gpu/effects/GrSimpleTextureEffect.fp b/src/gpu/effects/GrSimpleTextureEffect.fp
index 20944447ce..6f7c818672 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.fp
+++ b/src/gpu/effects/GrSimpleTextureEffect.fp
@@ -7,7 +7,7 @@
in uniform sampler2D image;
in uniform colorSpaceXform colorXform;
-in mat4 matrix;
+in float4x4 matrix;
@constructorParams {
GrSamplerParams samplerParams
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index fa560580e4..ee7985c14e 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -115,8 +115,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
// may return undefined results". This appears to be an issue with
// the 'any' call since even the simple "result=black; if (any())
// result=white;" code fails to compile.
- builder->codeAppend("vec4 outside = vec4(0.0, 0.0, 0.0, 0.0);");
- builder->codeAppend("vec4 inside = ");
+ builder->codeAppend("float4 outside = float4(0.0, 0.0, 0.0, 0.0);");
+ builder->codeAppend("float4 inside = ");
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
kVec2f_GrSLType, colorXformHelper);
builder->codeAppend(";");
@@ -131,12 +131,12 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
builder->codeAppend("float blend = step(1.0, max(x, y));");
builder->codeAppendf("%s = mix(inside, outside, blend);", outColor);
} else {
- builder->codeAppend("bvec4 outside;\n");
+ builder->codeAppend("bool4 outside;\n");
builder->codeAppendf("outside.xy = lessThan(%s, %s.xy);", inCoords.c_str(),
domain);
builder->codeAppendf("outside.zw = greaterThan(%s, %s.zw);", inCoords.c_str(),
domain);
- builder->codeAppendf("%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0.0) : ",
+ builder->codeAppendf("%s = any(outside) ? float4(0.0, 0.0, 0.0, 0.0) : ",
outColor);
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
kVec2f_GrSLType, colorXformHelper);
@@ -385,7 +385,7 @@ GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLS
kDefault_GrSLPrecision,
"scaleAndTranslate",
&scaleAndTranslateName);
- args.fFragBuilder->codeAppendf("vec2 coords = sk_FragCoord.xy * %s.xy + %s.zw;",
+ args.fFragBuilder->codeAppendf("float2 coords = sk_FragCoord.xy * %s.xy + %s.zw;",
scaleAndTranslateName, scaleAndTranslateName);
fGLDomain.sampleTexture(args.fFragBuilder,
args.fUniformHandler,
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 96bbc235c3..10c2e563c0 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -23,7 +23,7 @@ struct SkRect;
/**
* Limits a texture's lookup coordinates to a domain. Samples outside the domain are either clamped
- * the edge of the domain or result in a vec4 of zeros (decal mode). The domain is clipped to
+ * the edge of the domain or result in a float4 of zeros (decal mode). The domain is clipped to
* normalized texture coords ([0,1]x[0,1] square). Bilinear filtering can cause texels outside the
* domain to affect the read value unless the caller considers this when calculating the domain.
*/
@@ -98,8 +98,8 @@ public:
* Call this from GrGLSLFragmentProcessor::emitCode() to sample the texture W.R.T. the
* domain and mode.
*
- * @param outcolor name of vec4 variable to hold the sampled color.
- * @param inCoords name of vec2 variable containing the coords to be used with the domain.
+ * @param outcolor name of float4 variable to hold the sampled color.
+ * @param inCoords name of float2 variable containing the coords to be used with the domain.
* It is assumed that this is a variable and not an expression.
* @param inModulateColor if non-nullptr the sampled color will be modulated with this
* expression before being written to outColor.
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index 80de68f4c2..88a09e6d7a 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -220,7 +220,7 @@ void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) {
const char* inputColor = nullptr;
if (args.fInputColor) {
inputColor = "inputColor";
- fragBuilder->codeAppendf("vec4 inputColor = vec4(%s.rgb, 1.0);", args.fInputColor);
+ fragBuilder->codeAppendf("float4 inputColor = float4(%s.rgb, 1.0);", args.fInputColor);
}
// declare outputColor and emit the code for each of the two children
@@ -454,7 +454,7 @@ public:
const char* inputColor = args.fInputColor;
// We don't try to optimize for this case at all
if (!inputColor) {
- fragBuilder->codeAppendf("const vec4 ones = vec4(1);");
+ fragBuilder->codeAppendf("const float4 ones = float4(1);");
inputColor = "ones";
}
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp
index 0d7f218e20..93f268a13c 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -112,7 +112,7 @@ public:
fMatrixUni = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
kMat44f_GrSLType, kDefault_GrSLPrecision,
"ColorSpaceMatrix", &colorSpaceMatrix);
- fragBuilder->codeAppendf("%s = vec4(", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(", args.fOutputColor);
fragBuilder->appendTextureLookup(args.fTexSamplers[0],
args.fTransformedCoords[0].c_str(),
args.fTransformedCoords[0].getType());
@@ -279,7 +279,7 @@ public:
kFragment_GrShaderFlag,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"RGBToYUV", 3, &uniName);
- fragBuilder->codeAppendf("%s = vec4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a,"
+ fragBuilder->codeAppendf("%s = float4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a,"
"dot(rgbColor.rgb, %s[1].rgb) + %s[1].a,"
"dot(rgbColor.rgb, %s[2].rgb) + %s[2].a,"
"rgbColor.a);",
@@ -291,7 +291,7 @@ public:
kFragment_GrShaderFlag,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"RGBToUV", 2, &uniName);
- fragBuilder->codeAppendf("%s = vec4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a,"
+ fragBuilder->codeAppendf("%s = float4(dot(rgbColor.rgb, %s[0].rgb) + %s[0].a,"
"dot(rgbColor.rgb, %s[1].rgb) + %s[1].a,"
"0.0,"
"rgbColor.a);",
@@ -304,7 +304,7 @@ public:
kFragment_GrShaderFlag,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"RGBToYUorV", &uniName);
- fragBuilder->codeAppendf("%s = vec4(dot(rgbColor.rgb, %s.rgb) + %s.a);\n",
+ fragBuilder->codeAppendf("%s = float4(dot(rgbColor.rgb, %s.rgb) + %s.a);\n",
args.fOutputColor, uniName, uniName);
break;
}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 3c35def752..6247850409 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3512,7 +3512,7 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
"void main() {"
" v_texCoord = a_vertex.xy * u_texCoordXform.xy + u_texCoordXform.zw;"
" gl_Position.xy = a_vertex * u_posXform.xy + u_posXform.zw;"
- " gl_Position.zw = vec2(0, 1);"
+ " gl_Position.zw = float2(0, 1);"
"}"
);
@@ -3628,27 +3628,27 @@ bool GrGLGpu::createMipmapProgram(int progIdx) {
vshaderTxt.append(
"// Mipmap Program VS\n"
"void main() {"
- " gl_Position.xy = a_vertex * vec2(2, 2) - vec2(1, 1);"
- " gl_Position.zw = vec2(0, 1);"
+ " gl_Position.xy = a_vertex * float2(2, 2) - float2(1, 1);"
+ " gl_Position.zw = float2(0, 1);"
);
// Insert texture coordinate computation:
if (oddWidth && oddHeight) {
vshaderTxt.append(
" v_texCoord0 = a_vertex.xy * u_texCoordXform.yw;"
- " v_texCoord1 = a_vertex.xy * u_texCoordXform.yw + vec2(u_texCoordXform.x, 0);"
- " v_texCoord2 = a_vertex.xy * u_texCoordXform.yw + vec2(0, u_texCoordXform.z);"
+ " v_texCoord1 = a_vertex.xy * u_texCoordXform.yw + float2(u_texCoordXform.x, 0);"
+ " v_texCoord2 = a_vertex.xy * u_texCoordXform.yw + float2(0, u_texCoordXform.z);"
" v_texCoord3 = a_vertex.xy * u_texCoordXform.yw + u_texCoordXform.xz;"
);
} else if (oddWidth) {
vshaderTxt.append(
- " v_texCoord0 = a_vertex.xy * vec2(u_texCoordXform.y, 1);"
- " v_texCoord1 = a_vertex.xy * vec2(u_texCoordXform.y, 1) + vec2(u_texCoordXform.x, 0);"
+ " v_texCoord0 = a_vertex.xy * float2(u_texCoordXform.y, 1);"
+ " v_texCoord1 = a_vertex.xy * float2(u_texCoordXform.y, 1) + float2(u_texCoordXform.x, 0);"
);
} else if (oddHeight) {
vshaderTxt.append(
- " v_texCoord0 = a_vertex.xy * vec2(1, u_texCoordXform.w);"
- " v_texCoord1 = a_vertex.xy * vec2(1, u_texCoordXform.w) + vec2(0, u_texCoordXform.z);"
+ " v_texCoord0 = a_vertex.xy * float2(1, u_texCoordXform.w);"
+ " v_texCoord1 = a_vertex.xy * float2(1, u_texCoordXform.w) + float2(0, u_texCoordXform.z);"
);
} else {
vshaderTxt.append(
@@ -3760,7 +3760,7 @@ bool GrGLGpu::createStencilClipClearProgram() {
vshaderTxt.append(
"// Stencil Clip Clear Program VS\n"
"void main() {"
- " gl_Position = vec4(a_vertex.x, a_vertex.y, 0, 1);"
+ " gl_Position = float4(a_vertex.x, a_vertex.y, 0, 1);"
"}");
SkString fshaderTxt(version);
@@ -3770,7 +3770,7 @@ bool GrGLGpu::createStencilClipClearProgram() {
fshaderTxt.appendf(
"// Stencil Clip Clear Program FS\n"
"void main() {"
- " sk_FragColor = vec4(0);"
+ " sk_FragColor = float4(0);"
"}");
const char* str;
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index d6bde9a094..ec32c3557d 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -68,8 +68,8 @@ public:
}
/**
- * Gets a vec4 that adjusts the position from Skia device coords to GL's normalized device
- * coords. Assuming the transformed position, pos, is a homogeneous vec3, the vec, v, is
+ * Gets a float4 that adjusts the position from Skia device coords to GL's normalized device
+ * coords. Assuming the transformed position, pos, is a homogeneous float3, the vec, v, is
* applied as such:
* pos.x = dot(v.xy, pos.xz)
* pos.y = dot(v.zw, pos.yz)
diff --git a/src/gpu/glsl/GrGLSLBlend.cpp b/src/gpu/glsl/GrGLSLBlend.cpp
index bee5a83c5c..b37169b3c5 100644
--- a/src/gpu/glsl/GrGLSLBlend.cpp
+++ b/src/gpu/glsl/GrGLSLBlend.cpp
@@ -120,14 +120,14 @@ static void soft_light_component_pos_dst_alpha(GrGLSLFragmentBuilder* fsBuilder,
// Adds a function that takes two colors and an alpha as input. It produces a color with the
// hue and saturation of the first color, the luminosity of the second color, and the input
// alpha. It has this signature:
-// vec3 set_luminance(vec3 hueSatColor, float alpha, vec3 lumColor).
+// float3 set_luminance(float3 hueSatColor, float alpha, float3 lumColor).
static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumFunction) {
// Emit a helper that gets the luminance of a color.
SkString getFunction;
GrShaderVar getLumArgs[] = {
GrShaderVar("color", kVec3f_GrSLType),
};
- SkString getLumBody("return dot(vec3(0.3, 0.59, 0.11), color);");
+ SkString getLumBody("return dot(float3(0.3, 0.59, 0.11), color);");
fsBuilder->emitFunction(kFloat_GrSLType,
"luminance",
SK_ARRAY_COUNT(getLumArgs), getLumArgs,
@@ -142,17 +142,17 @@ static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumF
};
SkString setLumBody;
setLumBody.printf("float diff = %s(lumColor - hueSat);", getFunction.c_str());
- setLumBody.append("vec3 outColor = hueSat + diff;");
+ setLumBody.append("float3 outColor = hueSat + diff;");
setLumBody.appendf("float outLum = %s(outColor);", getFunction.c_str());
setLumBody.append("float minComp = min(min(outColor.r, outColor.g), outColor.b);"
"float maxComp = max(max(outColor.r, outColor.g), outColor.b);"
"if (minComp < 0.0 && outLum != minComp) {"
- "outColor = outLum + ((outColor - vec3(outLum, outLum, outLum)) * outLum) /"
+ "outColor = outLum + ((outColor - float3(outLum, outLum, outLum)) * outLum) /"
"(outLum - minComp);"
"}"
"if (maxComp > alpha && maxComp != outLum) {"
"outColor = outLum +"
- "((outColor - vec3(outLum, outLum, outLum)) * (alpha - outLum)) /"
+ "((outColor - float3(outLum, outLum, outLum)) * (alpha - outLum)) /"
"(maxComp - outLum);"
"}"
"return outColor;");
@@ -165,7 +165,7 @@ static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumF
// Adds a function that creates a color with the hue and luminosity of one input color and
// the saturation of another color. It will have this signature:
-// float set_saturation(vec3 hueLumColor, vec3 satColor)
+// float set_saturation(float3 hueLumColor, float3 satColor)
static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatFunction) {
// Emit a helper that gets the saturation of a color
SkString getFunction;
@@ -181,7 +181,7 @@ static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatF
// Emit a helper that sets the saturation given sorted input channels. This used
// to use inout params for min, mid, and max components but that seems to cause
- // problems on PowerVR drivers. So instead it returns a vec3 where r, g ,b are the
+ // problems on PowerVR drivers. So instead it returns a float3 where r, g ,b are the
// adjusted min, mid, and max inputs, respectively.
SkString helperFunction;
GrShaderVar helperArgs[] = {
@@ -191,13 +191,13 @@ static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatF
GrShaderVar("sat", kFloat_GrSLType),
};
static const char kHelperBody[] = "if (minComp < maxComp) {"
- "vec3 result;"
+ "float3 result;"
"result.r = 0.0;"
"result.g = sat * (midComp - minComp) / (maxComp - minComp);"
"result.b = sat;"
"return result;"
"} else {"
- "return vec3(0, 0, 0);"
+ "return float3(0, 0, 0);"
"}";
fsBuilder->emitFunction(kVec3f_GrSLType,
"set_saturation_helper",
@@ -311,7 +311,7 @@ static void emit_advanced_xfermode_code(GrGLSLFragmentBuilder* fsBuilder, const
SkString setSat, setLum;
add_sat_function(fsBuilder, &setSat);
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("vec4 dstSrcAlpha = %s * %s.a;",
+ fsBuilder->codeAppendf("float4 dstSrcAlpha = %s * %s.a;",
dstColor, srcColor);
fsBuilder->codeAppendf("%s.rgb = %s(%s(%s.rgb * %s.a, dstSrcAlpha.rgb),"
"dstSrcAlpha.a, dstSrcAlpha.rgb);",
@@ -326,7 +326,7 @@ static void emit_advanced_xfermode_code(GrGLSLFragmentBuilder* fsBuilder, const
SkString setSat, setLum;
add_sat_function(fsBuilder, &setSat);
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("vec4 dstSrcAlpha = %s * %s.a;",
+ fsBuilder->codeAppendf("float4 dstSrcAlpha = %s * %s.a;",
dstColor, srcColor);
fsBuilder->codeAppendf("%s.rgb = %s(%s(dstSrcAlpha.rgb, %s.rgb * %s.a),"
"dstSrcAlpha.a, dstSrcAlpha.rgb);",
@@ -340,7 +340,7 @@ static void emit_advanced_xfermode_code(GrGLSLFragmentBuilder* fsBuilder, const
// SetLum(S * Da, Sa* Da, D * Sa) + (1 - Sa) * D + (1 - Da) * S
SkString setLum;
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("vec4 srcDstAlpha = %s * %s.a;",
+ fsBuilder->codeAppendf("float4 srcDstAlpha = %s * %s.a;",
srcColor, dstColor);
fsBuilder->codeAppendf("%s.rgb = %s(srcDstAlpha.rgb, srcDstAlpha.a, %s.rgb * %s.a);",
outputColor, setLum.c_str(), dstColor, srcColor);
@@ -352,7 +352,7 @@ static void emit_advanced_xfermode_code(GrGLSLFragmentBuilder* fsBuilder, const
// SetLum(D * Sa, Sa* Da, S * Da) + (1 - Sa) * D + (1 - Da) * S
SkString setLum;
add_lum_function(fsBuilder, &setLum);
- fsBuilder->codeAppendf("vec4 srcDstAlpha = %s * %s.a;",
+ fsBuilder->codeAppendf("float4 srcDstAlpha = %s * %s.a;",
srcColor, dstColor);
fsBuilder->codeAppendf("%s.rgb = %s(%s.rgb * %s.a, srcDstAlpha.a, srcDstAlpha.rgb);",
outputColor, setLum.c_str(), dstColor, srcColor);
@@ -387,13 +387,13 @@ static bool append_porterduff_term(GrGLSLFragmentBuilder* fsBuilder, SkBlendMode
fsBuilder->codeAppendf(" * %s", srcColorName);
break;
case SkBlendModeCoeff::kISC:
- fsBuilder->codeAppendf(" * (vec4(1.0) - %s)", srcColorName);
+ fsBuilder->codeAppendf(" * (float4(1.0) - %s)", srcColorName);
break;
case SkBlendModeCoeff::kDC:
fsBuilder->codeAppendf(" * %s", dstColorName);
break;
case SkBlendModeCoeff::kIDC:
- fsBuilder->codeAppendf(" * (vec4(1.0) - %s)", dstColorName);
+ fsBuilder->codeAppendf(" * (float4(1.0) - %s)", dstColorName);
break;
case SkBlendModeCoeff::kSA:
fsBuilder->codeAppendf(" * %s.a", srcColorName);
@@ -434,7 +434,7 @@ void GrGLSLBlend::AppendMode(GrGLSLFragmentBuilder* fsBuilder, const char* srcCo
false);
// append dst blend
if(!append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor, didAppend)) {
- fsBuilder->codeAppend("vec4(0, 0, 0, 0)");
+ fsBuilder->codeAppend("float4(0, 0, 0, 0)");
}
if (clamp) {
fsBuilder->codeAppend(", 0, 1);");
@@ -486,7 +486,7 @@ void GrGLSLBlend::AppendRegionOp(GrGLSLFragmentBuilder* fsBuilder, const char* s
false);
// append dst blend
if(!append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor, didAppend)) {
- fsBuilder->codeAppend("vec4(0, 0, 0, 0)");
+ fsBuilder->codeAppend("float4(0, 0, 0, 0)");
}
fsBuilder->codeAppend(";");
}
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
index 006fe587f7..6f75c16fe9 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
@@ -29,7 +29,7 @@ void GrGLSLFragmentProcessor::emitChild(int childIndex, const char* inputColor,
SkASSERT(outputColor);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
outputColor->append(fragBuilder->getMangleString());
- fragBuilder->codeAppendf("vec4 %s;", outputColor->c_str());
+ fragBuilder->codeAppendf("float4 %s;", outputColor->c_str());
this->internalEmitChild(childIndex, inputColor, outputColor->c_str(), args);
}
diff --git a/src/gpu/glsl/GrGLSLFragmentProcessor.h b/src/gpu/glsl/GrGLSLFragmentProcessor.h
index 355d490225..ed4b71ffa2 100644
--- a/src/gpu/glsl/GrGLSLFragmentProcessor.h
+++ b/src/gpu/glsl/GrGLSLFragmentProcessor.h
@@ -86,9 +86,9 @@ public:
@param fp The processor that generated this program stage.
@param key The key that was computed by GenKey() from the generating
GrProcessor.
- @param outputColor A predefined vec4 in the FS in which the stage should place its
+ @param outputColor A predefined float4 in the FS in which the stage should place its
output color (or coverage).
- @param inputColor A vec4 that holds the input color to the stage in the FS. This may
+ @param inputColor A float4 that holds the input color to the stage in the FS. This may
be nullptr in which case the implied input is solid white (all
ones). TODO: Better system for communicating optimization info
(e.g. input color is solid white, trans black, known to be opaque,
@@ -152,7 +152,7 @@ public:
}
inline void emitChild(int childIndex, SkString* outputColor, EmitArgs& parentArgs) {
- this->emitChild(childIndex, "vec4(1.0)", outputColor, parentArgs);
+ this->emitChild(childIndex, "float4(1.0)", outputColor, parentArgs);
}
/** Will emit the code of a child proc in its own scope. Pass in the parent's EmitArgs and
@@ -167,7 +167,7 @@ public:
EmitArgs& parentArgs);
inline void emitChild(int childIndex, EmitArgs& args) {
- this->emitChild(childIndex, "vec4(1.0)", args);
+ this->emitChild(childIndex, "float4(1.0)", args);
}
/** Variation that uses the parent's output color variable to hold the child's output.*/
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
index 6c0528ee31..7f16136fd0 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -119,7 +119,7 @@ SkString GrGLSLFragmentShaderBuilder::ensureCoords2D(const GrShaderVar& coords)
SkString coords2D;
coords2D.printf("%s_ensure2D", coords.c_str());
- this->codeAppendf("\tvec2 %s = %s.xy / %s.z;", coords2D.c_str(), coords.c_str(),
+ this->codeAppendf("\tfloat2 %s = %s.xy / %s.z;", coords2D.c_str(), coords.c_str(),
coords.c_str());
return coords2D;
}
@@ -199,7 +199,7 @@ const char* GrGLSLFragmentShaderBuilder::dstColor() {
fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOut_TypeModifier);
fbFetchColorName = DeclaredColorOutputName();
// Set the dstColor to an intermediate variable so we don't override it with the output
- this->codeAppendf("vec4 %s = %s;", kDstColorName, fbFetchColorName);
+ this->codeAppendf("float4 %s = %s;", kDstColorName, fbFetchColorName);
} else {
return fbFetchColorName;
}
@@ -305,9 +305,9 @@ void GrGLSLFragmentShaderBuilder::defineSampleOffsetArray(const char* name, cons
SkSTArray<16, SkPoint, true> offsets;
offsets.push_back_n(specs.fEffectiveSampleCnt);
m.mapPoints(offsets.begin(), specs.fSampleLocations, specs.fEffectiveSampleCnt);
- this->definitions().appendf("const highp vec2 %s[] = vec2[](", name);
+ this->definitions().appendf("const highp float2 %s[] = float2[](", name);
for (int i = 0; i < specs.fEffectiveSampleCnt; ++i) {
- this->definitions().appendf("vec2(%f, %f)", offsets[i].x(), offsets[i].y());
+ this->definitions().appendf("float2(%f, %f)", offsets[i].x(), offsets[i].y());
this->definitions().append(i + 1 != specs.fEffectiveSampleCnt ? ", " : ");\n");
}
}
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
index 9dd1cba418..3ab5b68140 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
@@ -62,9 +62,9 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb,
handler->specifyCoordsForCurrCoordTransform(SkString(v.fsIn()), varyingType);
if (kVec2f_GrSLType == varyingType) {
- vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
+ vb->codeAppendf("%s = (%s * float3(%s, 1)).xy;", v.vsOut(), uniName, localCoords);
} else {
- vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName, localCoords);
+ vb->codeAppendf("%s = %s * float3(%s, 1);", v.vsOut(), uniName, localCoords);
}
++i;
}
@@ -89,7 +89,7 @@ void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
GrGPArgs* gpArgs,
const char* posName) {
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
- vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
+ vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
}
void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
@@ -100,7 +100,7 @@ void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
UniformHandle* viewMatrixUniform) {
if (mat.isIdentity()) {
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
- vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
+ vertBuilder->codeAppendf("float2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
} else {
const char* viewMatrixName;
*viewMatrixUniform = uniformHandler->addUniform(kVertex_GrShaderFlag,
@@ -109,11 +109,11 @@ void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
&viewMatrixName);
if (!mat.hasPerspective()) {
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
- vertBuilder->codeAppendf("vec2 %s = (%s * vec3(%s, 1)).xy;",
+ vertBuilder->codeAppendf("float2 %s = (%s * float3(%s, 1)).xy;",
gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
} else {
gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3");
- vertBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);",
+ vertBuilder->codeAppendf("float3 %s = %s * float3(%s, 1);",
gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
}
}
diff --git a/src/gpu/glsl/GrGLSLGeometryProcessor.h b/src/gpu/glsl/GrGLSLGeometryProcessor.h
index 6777620a88..10a4aa8a1c 100644
--- a/src/gpu/glsl/GrGLSLGeometryProcessor.h
+++ b/src/gpu/glsl/GrGLSLGeometryProcessor.h
@@ -50,7 +50,7 @@ protected:
struct GrGPArgs {
// The variable used by a GP to store its position. It can be
- // either a vec2 or a vec3 depending on the presence of perspective.
+ // either a float2 or a float3 depending on the presence of perspective.
GrShaderVar fPositionVar;
};
diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
index c2e0ab7f8d..d9d17e5356 100644
--- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
@@ -49,7 +49,7 @@ void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLPPFragmentBuilder* fragBu
&stagedLocalVarName);
fragBuilder->codeAppendf("%s = %s;", outputName, stagedLocalVarName);
if (fragBuilder->getProgramBuilder()->shaderCaps()->mustObfuscateUniformColor()) {
- fragBuilder->codeAppendf("%s = max(%s, vec4(0, 0, 0, 0));", outputName, outputName);
+ fragBuilder->codeAppendf("%s = max(%s, float4(0, 0, 0, 0));", outputName, outputName);
}
}
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 5c78c07fc2..a3c20c3dd1 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -239,8 +239,8 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn,
this->uniformHandler(),
this->shaderCaps(),
xp,
- colorIn.size() ? colorIn.c_str() : "vec4(1)",
- coverageIn.size() ? coverageIn.c_str() : "vec4(1)",
+ colorIn.size() ? colorIn.c_str() : "float4(1)",
+ coverageIn.size() ? coverageIn.c_str() : "float4(1)",
fFS.getPrimaryColorOutputName(),
fFS.getSecondaryColorOutputName(),
dstTextureSamplerHandle,
@@ -455,7 +455,7 @@ void GrGLSLProgramBuilder::nameExpression(SkString* output, const char* baseName
} else {
this->nameVariable(&outName, '\0', baseName);
}
- fFS.codeAppendf("vec4 %s;", outName.c_str());
+ fFS.codeAppendf("float4 %s;", outName.c_str());
*output = outName;
}
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
index 542cee672c..8f7d23dfe5 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
@@ -128,7 +128,7 @@ void GrGLSLShaderBuilder::appendColorGamutXform(SkString* out,
SkString functionBody;
// Gamut xform, clamp to destination gamut. We only support/have premultiplied textures, so we
// always just clamp to alpha.
- functionBody.append("\tcolor.rgb = clamp((xform * vec4(color.rgb, 1.0)).rgb, 0.0, color.a);\n");
+ functionBody.append("\tcolor.rgb = clamp((xform * float4(color.rgb, 1.0)).rgb, 0.0, color.a);\n");
functionBody.append("\treturn color;");
SkString colorGamutXformFuncName;
this->emitFunction(kVec4f_GrSLType,
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.h b/src/gpu/glsl/GrGLSLShaderBuilder.h
index 16e5b8606c..4906c03b78 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.h
@@ -47,8 +47,8 @@ public:
/** Does the work of appendTextureLookup and modulates the result by modulation. The result is
- always a vec4. modulation and the swizzle specified by SamplerHandle must both be
- vec4 or float. If modulation is "" or nullptr it this function acts as though
+ always a float4. modulation and the swizzle specified by SamplerHandle must both be
+ float4 or float. If modulation is "" or nullptr it this function acts as though
appendTextureLookup were called. */
void appendTextureLookupAndModulate(const char* modulation,
SamplerHandle,
diff --git a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
index 627b11d685..e06ee2db6c 100644
--- a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
@@ -20,23 +20,23 @@ void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
if (this->getProgramBuilder()->desc()->header().fSnapVerticesToPixelCenters) {
if (kVec3f_GrSLType == posVar.getType()) {
const char* p = posVar.c_str();
- this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
+ this->codeAppendf("{float2 _posTmp = float2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
} else {
SkASSERT(kVec2f_GrSLType == posVar.getType());
- this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str());
+ this->codeAppendf("{float2 _posTmp = %s;", posVar.c_str());
}
- this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);"
- "gl_Position = vec4(_posTmp.x * %s.x + %s.y,"
- "_posTmp.y * %s.z + %s.w, 0, 1);}",
+ this->codeAppendf("_posTmp = floor(_posTmp) + float2(0.5, 0.5);"
+ "gl_Position = float4(_posTmp.x * %s.x + %s.y,"
+ "_posTmp.y * %s.z + %s.w, 0, 1);}",
rtAdjustName, rtAdjustName, rtAdjustName, rtAdjustName);
} else if (kVec3f_GrSLType == posVar.getType()) {
- this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
+ this->codeAppendf("gl_Position = float4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
posVar.c_str(), rtAdjustName,
posVar.c_str(), rtAdjustName,
posVar.c_str());
} else {
SkASSERT(kVec2f_GrSLType == posVar.getType());
- this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
+ this->codeAppendf("gl_Position = float4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
posVar.c_str(), rtAdjustName, rtAdjustName,
posVar.c_str(), rtAdjustName, rtAdjustName);
}
diff --git a/src/gpu/glsl/GrGLSLXferProcessor.cpp b/src/gpu/glsl/GrGLSLXferProcessor.cpp
index 5af0f05680..6c2c460bec 100644
--- a/src/gpu/glsl/GrGLSLXferProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp
@@ -52,7 +52,7 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
// The discard here also helps for batching text draws together which need to read from
// a dst copy for blends. Though this only helps the case where the outer bounding boxes
// of each letter overlap and not two actually parts of the text.
- fragBuilder->codeAppendf("if (all(lessThanEqual(%s.rgb, vec3(0)))) {"
+ fragBuilder->codeAppendf("if (all(lessThanEqual(%s.rgb, float3(0)))) {"
" discard;"
"}", args.fInputCoverage);
}
@@ -72,14 +72,14 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
&dstCoordScaleName);
fragBuilder->codeAppend("// Read color from copy of the destination.\n");
- fragBuilder->codeAppendf("vec2 _dstTexCoord = (sk_FragCoord.xy - %s) * %s;",
+ fragBuilder->codeAppendf("float2 _dstTexCoord = (sk_FragCoord.xy - %s) * %s;",
dstTopLeftName, dstCoordScaleName);
if (flipY) {
fragBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");
}
- fragBuilder->codeAppendf("vec4 %s = ", dstColor);
+ fragBuilder->codeAppendf("float4 %s = ", dstColor);
fragBuilder->appendTextureLookup(args.fDstTextureSamplerHandle, "_dstTexCoord",
kVec2f_GrSLType);
fragBuilder->codeAppend(";");
@@ -91,7 +91,7 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
if (!needsLocalOutColor) {
outColor = args.fOutputPrimary;
} else {
- fragBuilder->codeAppendf("vec4 %s;", outColor);
+ fragBuilder->codeAppendf("float4 %s;", outColor);
}
this->emitBlendCodeForDstRead(fragBuilder,
@@ -139,7 +139,7 @@ void GrGLSLXferProcessor::DefaultCoverageModulation(GrGLSLXPFragmentBuilder* fra
fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage);
fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCoverage);
} else {
- fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary);
+ fragBuilder->codeAppendf("%s = float4(1.0);", outColorSecondary);
}
} else if (srcCoverage) {
if (proc.isLCD()) {
@@ -150,7 +150,7 @@ void GrGLSLXferProcessor::DefaultCoverageModulation(GrGLSLXPFragmentBuilder* fra
fragBuilder->codeAppendf("float lerpGreen = mix(%s.a, %s.a, %s.b);",
dstColor, outColor, srcCoverage);
}
- fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
+ fragBuilder->codeAppendf("%s = %s * %s + (float4(1.0) - %s) * %s;",
outColor, srcCoverage, outColor, srcCoverage, dstColor);
if (proc.isLCD()) {
fragBuilder->codeAppendf("%s.a = max(max(lerpRed, lerpBlue), lerpGreen);", outColor);
diff --git a/src/gpu/instanced/InstanceProcessor.cpp b/src/gpu/instanced/InstanceProcessor.cpp
index 39c1cf2224..28095da135 100644
--- a/src/gpu/instanced/InstanceProcessor.cpp
+++ b/src/gpu/instanced/InstanceProcessor.cpp
@@ -232,11 +232,11 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
}
if (!ip.opInfo().fHasPerspective) {
- v->codeAppendf("mat2x3 shapeMatrix = mat2x3(%s, %s);",
+ v->codeAppendf("float2x3 shapeMatrix = float2x3(%s, %s);",
inputs.attr(Attrib::kShapeMatrixX), inputs.attr(Attrib::kShapeMatrixY));
} else {
v->defineConstantf("int", "PERSPECTIVE_FLAG", "0x%x", kPerspective_InfoFlag);
- v->codeAppendf("mat3 shapeMatrix = mat3(%s, %s, vec3(0, 0, 1));",
+ v->codeAppendf("float3x3 shapeMatrix = float3x3(%s, %s, float3(0, 0, 1));",
inputs.attr(Attrib::kShapeMatrixX), inputs.attr(Attrib::kShapeMatrixY));
v->codeAppendf("if (0 != (%s & PERSPECTIVE_FLAG)) {",
inputs.attr(Attrib::kInstanceInfo));
@@ -303,16 +303,16 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
inputs.attr(Attrib::kInstanceInfo));
}
// Here we take advantage of the fact that outerRect == localRect in recordDRRect.
- v->codeAppendf("vec4 outer = %s;", inputs.attr(Attrib::kLocalRect));
- v->codeAppend ("vec4 inner = ");
+ v->codeAppendf("float4 outer = %s;", inputs.attr(Attrib::kLocalRect));
+ v->codeAppend ("float4 inner = ");
inputs.fetchNextParam();
v->codeAppend (";");
// outer2Inner is a transform from shape coords to inner shape coords:
// e.g. innerShapeCoords = shapeCoords * outer2Inner.xy + outer2Inner.zw
- v->codeAppend ("vec4 outer2Inner = vec4(outer.zw - outer.xy, "
+ v->codeAppend ("float4 outer2Inner = float4(outer.zw - outer.xy, "
"outer.xy + outer.zw - inner.xy - inner.zw) / "
"(inner.zw - inner.xy).xyxy;");
- v->codeAppendf("vec2 innerShapeCoords = %s * outer2Inner.xy + outer2Inner.zw;",
+ v->codeAppendf("float2 innerShapeCoords = %s * outer2Inner.xy + outer2Inner.zw;",
backend->outShapeCoords());
backend->initInnerShape(varyingHandler, v);
@@ -372,8 +372,8 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
const char* localCoords = nullptr;
if (ip.opInfo().fUsesLocalCoords) {
localCoords = "localCoords";
- v->codeAppendf("vec2 t = 0.5 * (%s + vec2(1));", backend->outShapeCoords());
- v->codeAppendf("vec2 localCoords = (1.0 - t) * %s.xy + t * %s.zw;",
+ v->codeAppendf("float2 t = 0.5 * (%s + float2(1));", backend->outShapeCoords());
+ v->codeAppendf("float2 localCoords = (1.0 - t) * %s.xy + t * %s.zw;",
inputs.attr(Attrib::kLocalRect), inputs.attr(Attrib::kLocalRect));
}
if (ip.opInfo().fHasLocalMatrix && ip.opInfo().fHasParams) {
@@ -383,20 +383,20 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
if (!ip.opInfo().fUsesLocalCoords) {
inputs.skipParams(2);
} else {
- v->codeAppendf( "mat2x3 localMatrix;");
+ v->codeAppendf( "float2x3 localMatrix;");
v->codeAppend ( "localMatrix[0] = ");
inputs.fetchNextParam(kVec3f_GrSLType);
v->codeAppend ( ";");
v->codeAppend ( "localMatrix[1] = ");
inputs.fetchNextParam(kVec3f_GrSLType);
v->codeAppend ( ";");
- v->codeAppend ( "localCoords = (vec3(localCoords, 1) * localMatrix).xy;");
+ v->codeAppend ( "localCoords = (float3(localCoords, 1) * localMatrix).xy;");
}
v->codeAppend("}");
}
GrSLType positionType = ip.opInfo().fHasPerspective ? kVec3f_GrSLType : kVec2f_GrSLType;
- v->codeAppendf("%s deviceCoords = vec3(%s, 1) * shapeMatrix;",
+ v->codeAppendf("%s deviceCoords = float3(%s, 1) * shapeMatrix;",
GrGLSLTypeString(positionType), backend->outShapeCoords());
gpArgs->fPositionVar.set(positionType, "deviceCoords");
@@ -409,7 +409,7 @@ void GLSLInstanceProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
void GLSLInstanceProcessor::Backend::init(GrGLSLVaryingHandler* varyingHandler,
GrGLSLVertexBuilder* v) {
if (fModifiedShapeCoords) {
- v->codeAppendf("vec2 %s = %s;", fModifiedShapeCoords, fInputs.attr(Attrib::kShapeCoords));
+ v->codeAppendf("float2 %s = %s;", fModifiedShapeCoords, fInputs.attr(Attrib::kShapeCoords));
}
this->onInit(varyingHandler, v);
@@ -421,11 +421,11 @@ void GLSLInstanceProcessor::Backend::init(GrGLSLVaryingHandler* varyingHandler,
}
void GLSLInstanceProcessor::Backend::setupRRect(GrGLSLVertexBuilder* v, int* usedShapeDefinitions) {
- v->codeAppendf("uvec2 corner = uvec2(%s & 1, (%s >> 1) & 1);",
+ v->codeAppendf("uint2 corner = uint2(%s & 1, (%s >> 1) & 1);",
fInputs.attr(Attrib::kVertexAttrs), fInputs.attr(Attrib::kVertexAttrs));
- v->codeAppend ("vec2 cornerSign = vec2(corner) * 2.0 - 1.0;");
- v->codeAppendf("vec2 radii%s;", fNeedsNeighborRadii ? ", neighborRadii" : "");
- v->codeAppend ("mat2 p = ");
+ v->codeAppend ("float2 cornerSign = float2(corner) * 2.0 - 1.0;");
+ v->codeAppendf("float2 radii%s;", fNeedsNeighborRadii ? ", neighborRadii" : "");
+ v->codeAppend ("float2x2 p = ");
fInputs.fetchNextParam(kMat22f_GrSLType);
v->codeAppend (";");
uint8_t types = fOpInfo.fShapeTypes & kRRect_ShapesMask;
@@ -467,11 +467,11 @@ void GLSLInstanceProcessor::Backend::setupRRect(GrGLSLVertexBuilder* v, int* use
this->adjustRRectVertices(v);
if (fArcCoords.vsOut()) {
- v->codeAppendf("%s = (cornerSign * %s + radii - vec2(1)) / radii;",
+ v->codeAppendf("%s = (cornerSign * %s + radii - float2(1)) / radii;",
fArcCoords.vsOut(), fModifiedShapeCoords);
}
if (fTriangleIsArc.vsOut()) {
- v->codeAppendf("%s = int(all(equal(vec2(1), abs(%s))));",
+ v->codeAppendf("%s = int(all(equal(float2(1), abs(%s))));",
fTriangleIsArc.vsOut(), fInputs.attr(Attrib::kShapeCoords));
}
@@ -486,9 +486,9 @@ void GLSLInstanceProcessor::Backend::setupSimpleRadii(GrGLSLVertexBuilder* v) {
}
void GLSLInstanceProcessor::Backend::setupNinePatchRadii(GrGLSLVertexBuilder* v) {
- v->codeAppend("radii = vec2(p[0][corner.x], p[1][corner.y]);");
+ v->codeAppend("radii = float2(p[0][corner.x], p[1][corner.y]);");
if (fNeedsNeighborRadii) {
- v->codeAppend("neighborRadii = vec2(p[0][1 - corner.x], p[1][1 - corner.y]);");
+ v->codeAppend("neighborRadii = float2(p[0][1 - corner.x], p[1][1 - corner.y]);");
}
}
@@ -507,13 +507,13 @@ void GLSLInstanceProcessor::Backend::setupComplexRadii(GrGLSLVertexBuilder* v) {
* x2 x4
*
*/
- v->codeAppend("mat2 p2 = ");
+ v->codeAppend("float2x2 p2 = ");
fInputs.fetchNextParam(kMat22f_GrSLType);
v->codeAppend(";");
- v->codeAppend("radii = vec2(p[corner.x][corner.y], p2[corner.y][corner.x]);");
+ v->codeAppend("radii = float2(p[corner.x][corner.y], p2[corner.y][corner.x]);");
if (fNeedsNeighborRadii) {
- v->codeAppend("neighborRadii = vec2(p[1 - corner.x][corner.y], "
- "p2[1 - corner.y][corner.x]);");
+ v->codeAppend("neighborRadii = float2(p[1 - corner.x][corner.y], "
+ "p2[1 - corner.y][corner.x]);");
}
}
@@ -540,10 +540,10 @@ void GLSLInstanceProcessor::Backend::initInnerShape(GrGLSLVaryingHandler* varyin
}
void GLSLInstanceProcessor::Backend::setupInnerSimpleRRect(GrGLSLVertexBuilder* v) {
- v->codeAppend("mat2 innerP = ");
+ v->codeAppend("float2x2 innerP = ");
fInputs.fetchNextParam(kMat22f_GrSLType);
v->codeAppend(";");
- v->codeAppend("vec2 innerRadii = innerP[0] * 2.0 / innerP[1];");
+ v->codeAppend("float2 innerRadii = innerP[0] * 2.0 / innerP[1];");
this->onSetupInnerSimpleRRect(v);
}
@@ -554,7 +554,7 @@ void GLSLInstanceProcessor::Backend::emitCode(GrGLSLVertexBuilder* v, GrGLSLPPFr
fModifiesColor ? outColor : nullptr);
if (outCoverage && !fModifiesCoverage) {
// Even though the subclass doesn't use coverage, we are expected to assign some value.
- f->codeAppendf("%s = vec4(1);", outCoverage);
+ f->codeAppendf("%s = float4(1);", outCoverage);
}
if (!fModifiesColor) {
// The subclass didn't assign a value to the output color.
@@ -621,18 +621,18 @@ void GLSLInstanceProcessor::BackendNonAA::onInitInnerShape(GrGLSLVaryingHandler*
void GLSLInstanceProcessor::BackendNonAA::setupInnerRect(GrGLSLVertexBuilder* v) {
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = vec4(1);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1);", fInnerRRect.vsOut());
}
}
void GLSLInstanceProcessor::BackendNonAA::setupInnerOval(GrGLSLVertexBuilder* v) {
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = vec4(0, 0, 1, 1);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(0, 0, 1, 1);", fInnerRRect.vsOut());
}
}
void GLSLInstanceProcessor::BackendNonAA::onSetupInnerSimpleRRect(GrGLSLVertexBuilder* v) {
- v->codeAppendf("%s = vec4(1.0 - innerRadii, 1.0 / innerRadii);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1.0 - innerRadii, 1.0 / innerRadii);", fInnerRRect.vsOut());
}
void GLSLInstanceProcessor::BackendNonAA::onEmitCode(GrGLSLVertexBuilder*,
@@ -646,8 +646,8 @@ void GLSLInstanceProcessor::BackendNonAA::onEmitCode(GrGLSLVertexBuilder*,
f->codeAppend ("lowp float covered = 1.0;");
dropFragment = "covered = 0.0";
} else if (fModifiesColor) {
- f->codeAppendf("lowp vec4 color = %s;", fColor.fsIn());
- dropFragment = "color = vec4(0)";
+ f->codeAppendf("lowp float4 color = %s;", fColor.fsIn());
+ dropFragment = "color = float4(0)";
}
if (fTriangleIsArc.fsIn()) {
SkASSERT(dropFragment);
@@ -658,19 +658,19 @@ void GLSLInstanceProcessor::BackendNonAA::onEmitCode(GrGLSLVertexBuilder*,
SkASSERT(dropFragment);
f->codeAppendf("// Inner shape.\n");
if (kRect_ShapeFlag == fOpInfo.fInnerShapeTypes) {
- f->codeAppendf("if (all(lessThanEqual(abs(%s), vec2(1)))) %s;",
+ f->codeAppendf("if (all(lessThanEqual(abs(%s), float2(1)))) %s;",
fInnerShapeCoords.fsIn(), dropFragment);
} else if (kOval_ShapeFlag == fOpInfo.fInnerShapeTypes) {
f->codeAppendf("if ((dot(%s, %s) <= 1.0)) %s;",
fInnerShapeCoords.fsIn(), fInnerShapeCoords.fsIn(), dropFragment);
} else {
- f->codeAppendf("if (all(lessThan(abs(%s), vec2(1)))) {", fInnerShapeCoords.fsIn());
- f->codeAppendf( "vec2 distanceToArcEdge = abs(%s) - %s.xy;",
+ f->codeAppendf("if (all(lessThan(abs(%s), float2(1)))) {", fInnerShapeCoords.fsIn());
+ f->codeAppendf( "float2 distanceToArcEdge = abs(%s) - %s.xy;",
fInnerShapeCoords.fsIn(), fInnerRRect.fsIn());
- f->codeAppend ( "if (any(lessThan(distanceToArcEdge, vec2(0)))) {");
+ f->codeAppend ( "if (any(lessThan(distanceToArcEdge, float2(0)))) {");
f->codeAppendf( "%s;", dropFragment);
f->codeAppend ( "} else {");
- f->codeAppendf( "vec2 rrectCoords = distanceToArcEdge * %s.zw;",
+ f->codeAppendf( "float2 rrectCoords = distanceToArcEdge * %s.zw;",
fInnerRRect.fsIn());
f->codeAppend ( "if (dot(rrectCoords, rrectCoords) <= 1.0) {");
f->codeAppendf( "%s;", dropFragment);
@@ -680,7 +680,7 @@ void GLSLInstanceProcessor::BackendNonAA::onEmitCode(GrGLSLVertexBuilder*,
}
}
if (fModifiesCoverage) {
- f->codeAppendf("%s = vec4(covered);", outCoverage);
+ f->codeAppendf("%s = float4(covered);", outCoverage);
} else if (fModifiesColor) {
f->codeAppendf("%s = color;", outColor);
}
@@ -747,10 +747,10 @@ private:
void GLSLInstanceProcessor::BackendCoverage::onInit(GrGLSLVaryingHandler* varyingHandler,
GrGLSLVertexBuilder* v) {
- v->codeAppend ("mat2 shapeTransposeMatrix = transpose(mat2(shapeMatrix));");
- v->codeAppend ("vec2 shapeHalfSize = vec2(length(shapeTransposeMatrix[0]), "
+ v->codeAppend ("float2x2 shapeTransposeMatrix = transpose(float2x2(shapeMatrix));");
+ v->codeAppend ("float2 shapeHalfSize = float2(length(shapeTransposeMatrix[0]), "
"length(shapeTransposeMatrix[1]));");
- v->codeAppend ("vec2 bloat = 0.5 / shapeHalfSize;");
+ v->codeAppend ("float2 bloat = 0.5 / shapeHalfSize;");
v->codeAppendf("bloatedShapeCoords = %s * (1.0 + bloat);", fInputs.attr(Attrib::kShapeCoords));
if (kOval_ShapeFlag != fOpInfo.fShapeTypes) {
@@ -779,13 +779,13 @@ void GLSLInstanceProcessor::BackendCoverage::onInit(GrGLSLVaryingHandler* varyin
void GLSLInstanceProcessor::BackendCoverage::setupRect(GrGLSLVertexBuilder* v) {
// Make the border one pixel wide. Inner vs outer is indicated by coordAttrs.
- v->codeAppendf("vec2 rectBloat = (%s != 0) ? bloat : -bloat;",
+ v->codeAppendf("float2 rectBloat = (%s != 0) ? bloat : -bloat;",
fInputs.attr(Attrib::kVertexAttrs));
// Here we use the absolute value, because when the rect is thinner than a pixel, this makes it
// mark the spot where pixel center is within half a pixel of the *opposite* edge. This,
// combined with the "maxCoverage" logic below gives us mathematically correct coverage even for
// subpixel rectangles.
- v->codeAppendf("bloatedShapeCoords = %s * abs(vec2(1.0 + rectBloat));",
+ v->codeAppendf("bloatedShapeCoords = %s * abs(float2(1.0 + rectBloat));",
fInputs.attr(Attrib::kShapeCoords));
// Determine coverage at the vertex. Coverage naturally ramps from 0 to 1 unless the rect is
@@ -802,9 +802,9 @@ void GLSLInstanceProcessor::BackendCoverage::setupRect(GrGLSLVertexBuilder* v) {
void GLSLInstanceProcessor::BackendCoverage::setupOval(GrGLSLVertexBuilder* v) {
// Offset the inner and outer octagons by one pixel. Inner vs outer is indicated by coordAttrs.
- v->codeAppendf("vec2 ovalBloat = (%s != 0) ? bloat : -bloat;",
+ v->codeAppendf("float2 ovalBloat = (%s != 0) ? bloat : -bloat;",
fInputs.attr(Attrib::kVertexAttrs));
- v->codeAppendf("bloatedShapeCoords = %s * max(vec2(1.0 + ovalBloat), vec2(0));",
+ v->codeAppendf("bloatedShapeCoords = %s * max(float2(1.0 + ovalBloat), float2(0));",
fInputs.attr(Attrib::kShapeCoords));
v->codeAppendf("%s = bloatedShapeCoords * shapeHalfSize;", fEllipseCoords.vsOut());
if (fEllipseName.vsOut()) {
@@ -827,8 +827,8 @@ void GLSLInstanceProcessor::BackendCoverage::adjustRRectVertices(GrGLSLVertexBui
// We try to let the AA borders line up with the arc edges on their particular side, but we
// can't allow them to get closer than one half pixel to the edge or they might overlap with
// their neighboring border.
- v->codeAppend("vec2 innerEdge = max(1.0 - bloat, vec2(0));");
- v->codeAppend ("vec2 borderEdge = cornerSign * clamp(1.0 - radii, -innerEdge, innerEdge);");
+ v->codeAppend("float2 innerEdge = max(1.0 - bloat, float2(0));");
+ v->codeAppend ("float2 borderEdge = cornerSign * clamp(1.0 - radii, -innerEdge, innerEdge);");
// 0.5 is a special value that indicates this vertex is an arc edge.
v->codeAppendf("if (abs(%s.x) == 0.5)"
"bloatedShapeCoords.x = borderEdge.x;", fInputs.attr(Attrib::kShapeCoords));
@@ -851,7 +851,7 @@ void GLSLInstanceProcessor::BackendCoverage::onSetupRRect(GrGLSLVertexBuilder* v
// interior edge of the border will necessarily clamp, and we need to match the AA behavior of
// the arc segments (i.e. distance from bloated edge only; ignoring the fact that the pixel
// actully has less coverage because it's not completely inside the opposite edge.)
- v->codeAppend("vec2 d = shapeHalfSize + 0.5 - abs(bloatedShapeCoords) * shapeHalfSize;");
+ v->codeAppend("float2 d = shapeHalfSize + 0.5 - abs(bloatedShapeCoords) * shapeHalfSize;");
v->codeAppend("rectCoverage = min(d.x, d.y);");
SkASSERT(!fShapeIsCircle);
@@ -859,8 +859,8 @@ void GLSLInstanceProcessor::BackendCoverage::onSetupRRect(GrGLSLVertexBuilder* v
// smooth transition from flat edge to arc, we don't allow the radii to be smaller than one half
// pixel. (We don't worry about the transition on the opposite side when a radius is so large
// that the border clamped on that side.)
- v->codeAppendf("vec2 clampedRadii = max(radii, bloat);");
- v->codeAppendf("%s = (cornerSign * bloatedShapeCoords + clampedRadii - vec2(1)) * "
+ v->codeAppendf("float2 clampedRadii = max(radii, bloat);");
+ v->codeAppendf("%s = (cornerSign * bloatedShapeCoords + clampedRadii - float2(1)) * "
"shapeHalfSize;", fEllipseCoords.vsOut());
v->codeAppendf("%s = 1.0 / (clampedRadii * clampedRadii * shapeHalfSize * shapeHalfSize);",
fEllipseName.vsOut());
@@ -868,7 +868,7 @@ void GLSLInstanceProcessor::BackendCoverage::onSetupRRect(GrGLSLVertexBuilder* v
void GLSLInstanceProcessor::BackendCoverage::onInitInnerShape(GrGLSLVaryingHandler* varyingHandler,
GrGLSLVertexBuilder* v) {
- v->codeAppend("vec2 innerShapeHalfSize = shapeHalfSize / outer2Inner.xy;");
+ v->codeAppend("float2 innerShapeHalfSize = shapeHalfSize / outer2Inner.xy;");
if (kOval_ShapeFlag == fOpInfo.fInnerShapeTypes) {
varyingHandler->addVarying("innerEllipseCoords", &fInnerEllipseCoords,
@@ -906,7 +906,7 @@ void GLSLInstanceProcessor::BackendCoverage::setupInnerOval(GrGLSLVertexBuilder*
v->codeAppendf("%s = innerShapeCoords * innerShapeHalfSize;", fInnerEllipseCoords.vsOut());
}
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = vec4(0, 0, innerShapeHalfSize);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(0, 0, innerShapeHalfSize);", fInnerRRect.vsOut());
}
}
@@ -916,7 +916,7 @@ void GLSLInstanceProcessor::BackendCoverage::onSetupInnerSimpleRRect(GrGLSLVerte
v->codeAppendf("%s = 1.0 / (innerRadii * innerRadii * innerShapeHalfSize * "
"innerShapeHalfSize);",
fInnerEllipseName.vsOut());
- v->codeAppendf("%s = vec4(1.0 - innerRadii, innerShapeHalfSize);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1.0 - innerRadii, innerShapeHalfSize);", fInnerRRect.vsOut());
}
void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
@@ -974,12 +974,12 @@ void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
this->emitInnerRect(f, innerCoverageDecl.c_str());
} else {
f->codeAppendf("%s = 0.0;", innerCoverageDecl.c_str());
- f->codeAppendf("mediump vec2 distanceToArcEdge = abs(%s) - %s.xy;",
+ f->codeAppendf("mediump float2 distanceToArcEdge = abs(%s) - %s.xy;",
fInnerShapeCoords.fsIn(), fInnerRRect.fsIn());
- f->codeAppend ("if (any(lessThan(distanceToArcEdge, vec2(1e-5)))) {");
+ f->codeAppend ("if (any(lessThan(distanceToArcEdge, float2(1e-5)))) {");
this->emitInnerRect(f, "innerCoverage");
f->codeAppend ("} else {");
- f->codeAppendf( "mediump vec2 ellipseCoords = distanceToArcEdge * %s.zw;",
+ f->codeAppendf( "mediump float2 ellipseCoords = distanceToArcEdge * %s.zw;",
fInnerRRect.fsIn());
this->emitArc(f, "ellipseCoords", fInnerEllipseName.fsIn(),
false /*ellipseCoordsNeedClamp*/,
@@ -987,9 +987,9 @@ void GLSLInstanceProcessor::BackendCoverage::onEmitCode(GrGLSLVertexBuilder* v,
f->codeAppend ("}");
}
}
- f->codeAppendf("%s = vec4(max(coverage - innerCoverage, 0.0));", outCoverage);
+ f->codeAppendf("%s = float4(max(coverage - innerCoverage, 0.0));", outCoverage);
} else if (!fTweakAlphaForCoverage) {
- f->codeAppendf("%s = vec4(coverage);", outCoverage);
+ f->codeAppendf("%s = float4(coverage);", outCoverage);
}
}
@@ -1029,16 +1029,16 @@ void GLSLInstanceProcessor::BackendCoverage::emitArc(GrGLSLPPFragmentBuilder* f,
// - To restrict the arcs of rounded rects to their positive quadrants.
// - To avoid inversesqrt(0) in the ellipse formula.
if (ellipseCoordsMayBeNegative) {
- f->codeAppendf("mediump vec2 ellipseClampedCoords = max(abs(%s), vec2(1e-4));",
+ f->codeAppendf("mediump float2 ellipseClampedCoords = max(abs(%s), float2(1e-4));",
ellipseCoords);
} else {
- f->codeAppendf("mediump vec2 ellipseClampedCoords = max(%s, vec2(1e-4));",
+ f->codeAppendf("mediump float2 ellipseClampedCoords = max(%s, float2(1e-4));",
ellipseCoords);
}
ellipseCoords = "ellipseClampedCoords";
}
// ellipseCoords are in pixel space and ellipseName is 1 / rx^2, 1 / ry^2.
- f->codeAppendf("highp vec2 Z = %s * %s;", ellipseCoords, ellipseName);
+ f->codeAppendf("highp float2 Z = %s * %s;", ellipseCoords, ellipseName);
// implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
f->codeAppendf("highp float implicit = dot(Z, %s) - 1.0;", ellipseCoords);
// gradDot is the squared length of the gradient of the implicit.
@@ -1049,7 +1049,7 @@ void GLSLInstanceProcessor::BackendCoverage::emitArc(GrGLSLPPFragmentBuilder* f,
void GLSLInstanceProcessor::BackendCoverage::emitInnerRect(GrGLSLPPFragmentBuilder* f,
const char* outCoverage) {
- f->codeAppendf("lowp vec2 c = %s - abs(%s);",
+ f->codeAppendf("lowp float2 c = %s - abs(%s);",
fInnerShapeBloatedHalfSize.fsIn(), fDistanceToInnerEdge.fsIn());
f->codeAppendf("%s = clamp(min(c.x, c.y), 0.0, 1.0);", outCoverage);
}
@@ -1177,9 +1177,9 @@ void GLSLInstanceProcessor::BackendMultisample::onInit(GrGLSLVaryingHandler* var
}
}
if (!fOpInfo.fHasPerspective) {
- v->codeAppend("mat2 shapeInverseMatrix = inverse(mat2(shapeMatrix));");
- v->codeAppend("vec2 fragShapeSpan = abs(vec4(shapeInverseMatrix).xz) + "
- "abs(vec4(shapeInverseMatrix).yw);");
+ v->codeAppend("float2x2 shapeInverseMatrix = inverse(float2x2(shapeMatrix));");
+ v->codeAppend("float2 fragShapeSpan = abs(float4(shapeInverseMatrix).xz) + "
+ "abs(float4(shapeInverseMatrix).yw);");
}
}
@@ -1195,7 +1195,7 @@ void GLSLInstanceProcessor::BackendMultisample::setupRect(GrGLSLVertexBuilder* v
}
if (fArcTest.vsOut()) {
// Pick a value that is not > 0.
- v->codeAppendf("%s = vec2(0);", fArcTest.vsOut());
+ v->codeAppendf("%s = float2(0);", fArcTest.vsOut());
}
if (fTriangleIsArc.vsOut()) {
v->codeAppendf("%s = 0;", fTriangleIsArc.vsOut());
@@ -1208,8 +1208,8 @@ void GLSLInstanceProcessor::BackendMultisample::setupRect(GrGLSLVertexBuilder* v
void GLSLInstanceProcessor::BackendMultisample::setupOval(GrGLSLVertexBuilder* v) {
v->codeAppendf("%s = abs(%s);", fArcCoords.vsOut(), this->outShapeCoords());
if (fArcInverseMatrix.vsOut()) {
- v->codeAppendf("vec2 s = sign(%s);", this->outShapeCoords());
- v->codeAppendf("%s = shapeInverseMatrix * mat2(s.x, 0, 0 , s.y);",
+ v->codeAppendf("float2 s = sign(%s);", this->outShapeCoords());
+ v->codeAppendf("%s = shapeInverseMatrix * float2x2(s.x, 0, 0 , s.y);",
fArcInverseMatrix.vsOut());
}
if (fFragArcHalfSpan.vsOut()) {
@@ -1217,7 +1217,7 @@ void GLSLInstanceProcessor::BackendMultisample::setupOval(GrGLSLVertexBuilder* v
}
if (fArcTest.vsOut()) {
// Pick a value that is > 0.
- v->codeAppendf("%s = vec2(1);", fArcTest.vsOut());
+ v->codeAppendf("%s = float2(1);", fArcTest.vsOut());
}
if (fTriangleIsArc.vsOut()) {
if (!this->isMixedSampled()) {
@@ -1243,13 +1243,13 @@ void GLSLInstanceProcessor::BackendMultisample::adjustRRectVertices(GrGLSLVertex
// For the mixed samples algorithm it's best to bloat the corner triangles a bit so that
// more of the pixels that cross into the arc region are completely inside the shared edges.
// We also snap to a regular rect if the radii shrink smaller than a pixel.
- v->codeAppend ("vec2 midpt = 0.5 * (neighborRadii - radii);");
- v->codeAppend ("vec2 cornerSize = any(lessThan(radii, fragShapeSpan)) ? "
- "vec2(0) : min(radii + 0.5 * fragShapeSpan, 1.0 - midpt);");
+ v->codeAppend ("float2 midpt = 0.5 * (neighborRadii - radii);");
+ v->codeAppend ("float2 cornerSize = any(lessThan(radii, fragShapeSpan)) ? "
+ "float2(0) : min(radii + 0.5 * fragShapeSpan, 1.0 - midpt);");
} else {
// TODO: We could still bloat the corner triangle in the perspective case; we would just
// need to find the screen-space derivative of shape coords at this particular point.
- v->codeAppend ("vec2 cornerSize = any(lessThan(radii, vec2(1e-3))) ? vec2(0) : radii;");
+ v->codeAppend ("float2 cornerSize = any(lessThan(radii, float2(1e-3))) ? float2(0) : radii;");
}
v->codeAppendf("if (abs(%s.x) == 0.5)"
@@ -1271,12 +1271,12 @@ void GLSLInstanceProcessor::BackendMultisample::onSetupRRect(GrGLSLVertexBuilder
v->codeAppendf("%s = 0.5 * fragShapeSpan;", fFragShapeHalfSpan.vsOut());
}
if (fArcInverseMatrix.vsOut()) {
- v->codeAppend ("vec2 s = cornerSign / radii;");
- v->codeAppendf("%s = shapeInverseMatrix * mat2(s.x, 0, 0, s.y);",
+ v->codeAppend ("float2 s = cornerSign / radii;");
+ v->codeAppendf("%s = shapeInverseMatrix * float2x2(s.x, 0, 0, s.y);",
fArcInverseMatrix.vsOut());
}
if (fFragArcHalfSpan.vsOut()) {
- v->codeAppendf("%s = 0.5 * (abs(vec4(%s).xz) + abs(vec4(%s).yw));",
+ v->codeAppendf("%s = 0.5 * (abs(float4(%s).xz) + abs(float4(%s).yw));",
fFragArcHalfSpan.vsOut(), fArcInverseMatrix.vsOut(),
fArcInverseMatrix.vsOut());
}
@@ -1285,8 +1285,8 @@ void GLSLInstanceProcessor::BackendMultisample::onSetupRRect(GrGLSLVertexBuilder
// edges of a fan triangle to a point within that triangle. fArcTest is used to check if a
// fragment is too close to either shared edge, in which case we point sample the shape as a
// rect at that point in order to guarantee the mixed samples discard logic works correctly.
- v->codeAppendf("%s = (cornerSize == vec2(0)) ? vec2(0) : "
- "cornerSign * %s * mat2(1, cornerSize.x - 1.0, cornerSize.y - 1.0, 1);",
+ v->codeAppendf("%s = (cornerSize == float2(0)) ? float2(0) : "
+ "cornerSign * %s * float2x2(1, cornerSize.x - 1.0, cornerSize.y - 1.0, 1);",
fArcTest.vsOut(), fModifiedShapeCoords);
if (!fOpInfo.fHasPerspective) {
// Shift the point at which distances to edges are measured from the center of the pixel
@@ -1299,7 +1299,7 @@ void GLSLInstanceProcessor::BackendMultisample::onSetupRRect(GrGLSLVertexBuilder
}
if (fEarlyAccept.vsOut()) {
SkASSERT(this->isMixedSampled());
- v->codeAppendf("%s = all(equal(vec2(1), abs(%s))) ? 0 : SAMPLE_MASK_ALL;",
+ v->codeAppendf("%s = all(equal(float2(1), abs(%s))) ? 0 : SAMPLE_MASK_ALL;",
fEarlyAccept.vsOut(), fInputs.attr(Attrib::kShapeCoords));
}
}
@@ -1315,7 +1315,7 @@ GLSLInstanceProcessor::BackendMultisample::onInitInnerShape(GrGLSLVaryingHandler
if (!fOpInfo.fHasPerspective) {
varyingHandler->addFlatVarying("innerShapeInverseMatrix", &fInnerShapeInverseMatrix,
kHigh_GrSLPrecision);
- v->codeAppendf("%s = shapeInverseMatrix * mat2(outer2Inner.x, 0, 0, outer2Inner.y);",
+ v->codeAppendf("%s = shapeInverseMatrix * float2x2(outer2Inner.x, 0, 0, outer2Inner.y);",
fInnerShapeInverseMatrix.vsOut());
varyingHandler->addFlatVarying("fragInnerShapeHalfSpan", &fFragInnerShapeHalfSpan,
kHigh_GrSLPrecision);
@@ -1329,14 +1329,14 @@ void GLSLInstanceProcessor::BackendMultisample::setupInnerRect(GrGLSLVertexBuild
// The fragment shader will generalize every inner shape as a round rect. Since this one
// is a rect, we simply emit bogus parameters for the round rect (negative radii) that
// ensure the fragment shader always takes the "sample as rect" codepath.
- v->codeAppendf("%s = vec4(2.0 * (inner.zw - inner.xy) / (outer.zw - outer.xy), vec2(0));",
+ v->codeAppendf("%s = float4(2.0 * (inner.zw - inner.xy) / (outer.zw - outer.xy), float2(0));",
fInnerRRect.vsOut());
}
}
void GLSLInstanceProcessor::BackendMultisample::setupInnerOval(GrGLSLVertexBuilder* v) {
if (fInnerRRect.vsOut()) {
- v->codeAppendf("%s = vec4(0, 0, 1, 1);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(0, 0, 1, 1);", fInnerRRect.vsOut());
}
}
@@ -1345,9 +1345,9 @@ void GLSLInstanceProcessor::BackendMultisample::onSetupInnerSimpleRRect(GrGLSLVe
if (fFragInnerShapeHalfSpan.vsOut()) {
v->codeAppendf("innerRadii = max(innerRadii, 2e-1 * %s);", fFragInnerShapeHalfSpan.vsOut());
} else {
- v->codeAppend ("innerRadii = max(innerRadii, vec2(1e-4));");
+ v->codeAppend ("innerRadii = max(innerRadii, float2(1e-4));");
}
- v->codeAppendf("%s = vec4(1.0 - innerRadii, 1.0 / innerRadii);", fInnerRRect.vsOut());
+ v->codeAppendf("%s = float4(1.0 - innerRadii, 1.0 / innerRadii);", fInnerRRect.vsOut());
}
void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
@@ -1383,7 +1383,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
if (fOpInfo.fHasPerspective && fOpInfo.fInnerShapeTypes) {
// This determines if the fragment should consider the inner shape in its sample mask.
// We take the derivative early in case discards may occur before we get to the inner shape.
- f->codeAppendf("highp vec2 fragInnerShapeApproxHalfSpan = 0.5 * fwidth(%s);",
+ f->codeAppendf("highp float2 fragInnerShapeApproxHalfSpan = 0.5 * fwidth(%s);",
fInnerShapeCoords.fsIn());
}
@@ -1400,7 +1400,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
if (arcTest && fOpInfo.fHasPerspective) {
// The non-perspective version accounts for fwidth() in the vertex shader.
// We make sure to take the derivative here, before a neighbor pixel may early accept.
- f->codeAppendf("highp vec2 arcTest = %s - 0.5 * fwidth(%s);",
+ f->codeAppendf("highp float2 arcTest = %s - 0.5 * fwidth(%s);",
fArcTest.fsIn(), fArcTest.fsIn());
arcTest = "arcTest";
}
@@ -1411,7 +1411,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
if (arcTest) {
// At this point, if the sample mask is all set it means we are inside an arc triangle.
f->codeAppendf("if (gl_SampleMaskIn[0] == SAMPLE_MASK_ALL || "
- "all(greaterThan(%s, vec2(0)))) {", arcTest);
+ "all(greaterThan(%s, float2(0)))) {", arcTest);
this->emitArc(f, arcCoords, false, clampArcCoords, opts);
f->codeAppend ("} else {");
this->emitRect(f, shapeCoords, opts);
@@ -1484,10 +1484,10 @@ void GLSLInstanceProcessor::BackendMultisample::emitRect(GrGLSLPPFragmentBuilder
}
f->codeAppend ("int rectMask = 0;");
f->codeAppend ("for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highp vec2 pt = ");
+ f->codeAppend ( "highp float2 pt = ");
this->interpolateAtSample(f, *coords.fVarying, "i", coords.fInverseMatrix);
f->codeAppend ( ";");
- f->codeAppend ( "if (all(lessThan(abs(pt), vec2(1)))) rectMask |= (1 << i);");
+ f->codeAppend ( "if (all(lessThan(abs(pt), float2(1)))) rectMask |= (1 << i);");
f->codeAppend ("}");
this->acceptCoverageMask(f, "rectMask", opts);
if (coords.fFragHalfSpan) {
@@ -1503,7 +1503,7 @@ void GLSLInstanceProcessor::BackendMultisample::emitArc(GrGLSLPPFragmentBuilder*
SkString absArcCoords;
absArcCoords.printf(coordsMayBeNegative ? "abs(%s)" : "%s", coords.fVarying->fsIn());
if (clampCoords) {
- f->codeAppendf("if (%s(max(%s + %s, vec2(0))) < 1.0) {",
+ f->codeAppendf("if (%s(max(%s + %s, float2(0))) < 1.0) {",
fSquareFun.c_str(), absArcCoords.c_str(), coords.fFragHalfSpan);
} else {
f->codeAppendf("if (%s(%s + %s) < 1.0) {",
@@ -1511,7 +1511,7 @@ void GLSLInstanceProcessor::BackendMultisample::emitArc(GrGLSLPPFragmentBuilder*
}
// The entire pixel is inside the arc.
this->acceptOrRejectWholeFragment(f, true, opts);
- f->codeAppendf("} else if (%s(max(%s - %s, vec2(0))) >= 1.0) {",
+ f->codeAppendf("} else if (%s(max(%s - %s, float2(0))) >= 1.0) {",
fSquareFun.c_str(), absArcCoords.c_str(), coords.fFragHalfSpan);
// The entire pixel is outside the arc.
this->acceptOrRejectWholeFragment(f, false, opts);
@@ -1519,12 +1519,12 @@ void GLSLInstanceProcessor::BackendMultisample::emitArc(GrGLSLPPFragmentBuilder*
}
f->codeAppend ( "int arcMask = 0;");
f->codeAppend ( "for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highp vec2 pt = ");
+ f->codeAppend ( "highp float2 pt = ");
this->interpolateAtSample(f, *coords.fVarying, "i", coords.fInverseMatrix);
f->codeAppend ( ";");
if (clampCoords) {
SkASSERT(!coordsMayBeNegative);
- f->codeAppend ( "pt = max(pt, vec2(0));");
+ f->codeAppend ( "pt = max(pt, float2(0));");
}
f->codeAppendf( "if (%s(pt) < 1.0) arcMask |= (1 << i);", fSquareFun.c_str());
f->codeAppend ( "}");
@@ -1538,31 +1538,31 @@ void GLSLInstanceProcessor::BackendMultisample::emitSimpleRRect(GrGLSLPPFragment
const EmitShapeCoords& coords,
const char* rrect,
const EmitShapeOpts& opts) {
- f->codeAppendf("highp vec2 distanceToArcEdge = abs(%s) - %s.xy;", coords.fVarying->fsIn(),
+ f->codeAppendf("highp float2 distanceToArcEdge = abs(%s) - %s.xy;", coords.fVarying->fsIn(),
rrect);
- f->codeAppend ("if (any(lessThan(distanceToArcEdge, vec2(0)))) {");
+ f->codeAppend ("if (any(lessThan(distanceToArcEdge, float2(0)))) {");
this->emitRect(f, coords, opts);
f->codeAppend ("} else {");
if (coords.fInverseMatrix && coords.fFragHalfSpan) {
- f->codeAppendf("highp vec2 rrectCoords = distanceToArcEdge * %s.zw;", rrect);
- f->codeAppendf("highp vec2 fragRRectHalfSpan = %s * %s.zw;", coords.fFragHalfSpan, rrect);
+ f->codeAppendf("highp float2 rrectCoords = distanceToArcEdge * %s.zw;", rrect);
+ f->codeAppendf("highp float2 fragRRectHalfSpan = %s * %s.zw;", coords.fFragHalfSpan, rrect);
f->codeAppendf("if (%s(rrectCoords + fragRRectHalfSpan) <= 1.0) {", fSquareFun.c_str());
// The entire pixel is inside the round rect.
this->acceptOrRejectWholeFragment(f, true, opts);
- f->codeAppendf("} else if (%s(max(rrectCoords - fragRRectHalfSpan, vec2(0))) >= 1.0) {",
+ f->codeAppendf("} else if (%s(max(rrectCoords - fragRRectHalfSpan, float2(0))) >= 1.0) {",
fSquareFun.c_str());
// The entire pixel is outside the round rect.
this->acceptOrRejectWholeFragment(f, false, opts);
f->codeAppend ("} else {");
- f->codeAppendf( "highp vec2 s = %s.zw * sign(%s);", rrect, coords.fVarying->fsIn());
- f->codeAppendf( "highp mat2 innerRRectInverseMatrix = %s * mat2(s.x, 0, 0, s.y);",
- coords.fInverseMatrix);
+ f->codeAppendf( "highp float2 s = %s.zw * sign(%s);", rrect, coords.fVarying->fsIn());
+ f->codeAppendf( "highp float2x2 innerRRectInverseMatrix = %s * "
+ "float2x2(s.x, 0, 0, s.y);", coords.fInverseMatrix);
f->codeAppend ( "highp int rrectMask = 0;");
f->codeAppend ( "for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highp vec2 pt = rrectCoords + ");
+ f->codeAppend ( "highp float2 pt = rrectCoords + ");
f->appendOffsetToSample("i", GrGLSLFPFragmentBuilder::kSkiaDevice_Coordinates);
f->codeAppend ( "* innerRRectInverseMatrix;");
- f->codeAppendf( "if (%s(max(pt, vec2(0))) < 1.0) rrectMask |= (1 << i);",
+ f->codeAppendf( "if (%s(max(pt, float2(0))) < 1.0) rrectMask |= (1 << i);",
fSquareFun.c_str());
f->codeAppend ( "}");
this->acceptCoverageMask(f, "rrectMask", opts);
@@ -1570,10 +1570,10 @@ void GLSLInstanceProcessor::BackendMultisample::emitSimpleRRect(GrGLSLPPFragment
} else {
f->codeAppend ("int rrectMask = 0;");
f->codeAppend ("for (int i = 0; i < SAMPLE_COUNT; i++) {");
- f->codeAppend ( "highp vec2 shapePt = ");
+ f->codeAppend ( "highp float2 shapePt = ");
this->interpolateAtSample(f, *coords.fVarying, "i", nullptr);
f->codeAppend ( ";");
- f->codeAppendf( "highp vec2 rrectPt = max(abs(shapePt) - %s.xy, vec2(0)) * %s.zw;",
+ f->codeAppendf( "highp float2 rrectPt = max(abs(shapePt) - %s.xy, float2(0)) * %s.zw;",
rrect, rrect);
f->codeAppendf( "if (%s(rrectPt) < 1.0) rrectMask |= (1 << i);", fSquareFun.c_str());
f->codeAppend ("}");
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 9841f707ff..22b2b5980f 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -588,14 +588,14 @@ public:
fragBuilder->codeAppendf("float edgeAlpha;");
// keep the derivative instructions outside the conditional
- fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
- fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 duvdx = dFdx(%s.xy);", v.fsIn());
+ fragBuilder->codeAppendf("float2 duvdy = dFdy(%s.xy);", v.fsIn());
fragBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn(), v.fsIn());
// today we know z and w are in device space. We could use derivatives
fragBuilder->codeAppendf("edgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);", v.fsIn(),
v.fsIn());
fragBuilder->codeAppendf ("} else {");
- fragBuilder->codeAppendf("vec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,"
+ fragBuilder->codeAppendf("float2 gF = float2(2.0*%s.x*duvdx.x - duvdx.y,"
" 2.0*%s.x*duvdy.x - duvdy.y);",
v.fsIn(), v.fsIn());
fragBuilder->codeAppendf("edgeAlpha = (%s.x*%s.x - %s.y);", v.fsIn(), v.fsIn(),
@@ -603,7 +603,7 @@ public:
fragBuilder->codeAppendf("edgeAlpha = "
"clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);}");
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static inline void GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index fdc59a4d2d..7a23b5ac32 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -789,7 +789,7 @@ class GLDashingCircleEffect;
* This effect will draw a dotted line (defined as a dashed lined with round caps and no on
* interval). The radius of the dots is given by the strokeWidth and the spacing by the DashInfo.
* Both of the previous two parameters are in device space. This effect also requires the setting of
- * a vec2 vertex attribute for the the four corners of the bounding rect. This attribute is the
+ * a float2 vertex attribute for the the four corners of the bounding rect. This attribute is the
* "dash position" of each vertex. In other words it is the vertex coords (in device space) if we
* transform the line to be horizontal, with the start of line at the origin then shifted to the
* right by half the off interval. The line then goes in the positive x direction.
@@ -910,8 +910,8 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
fragBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
dashParams.fsIn(), dashParams.fsIn(), dashParams.fsIn(),
dashParams.fsIn());
- fragBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", dashParams.fsIn());
- fragBuilder->codeAppendf("vec2 center = vec2(%s.y, 0.0);", circleParams.fsIn());
+ fragBuilder->codeAppendf("float2 fragPosShifted = float2(xShifted, %s.y);", dashParams.fsIn());
+ fragBuilder->codeAppendf("float2 center = float2(%s.y, 0.0);", circleParams.fsIn());
fragBuilder->codeAppend("float dist = length(center - fragPosShifted);");
if (dce.aaMode() != AAMode::kNone) {
fragBuilder->codeAppendf("float diff = dist - %s.x;", circleParams.fsIn());
@@ -921,7 +921,7 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
fragBuilder->codeAppendf("float alpha = 1.0;");
fragBuilder->codeAppendf("alpha *= dist < %s.x + 0.5 ? 1.0 : 0.0;", circleParams.fsIn());
}
- fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(alpha);", args.fOutputCoverage);
}
void GLDashingCircleEffect::setData(const GrGLSLProgramDataManager& pdman,
@@ -998,7 +998,7 @@ class GLDashingLineEffect;
/*
* This effect will draw a dashed line. The width of the dash is given by the strokeWidth and the
* length and spacing by the DashInfo. Both of the previous two parameters are in device space.
- * This effect also requires the setting of a vec2 vertex attribute for the the four corners of the
+ * This effect also requires the setting of a float2 vertex attribute for the the four corners of the
* bounding rect. This attribute is the "dash position" of each vertex. In other words it is the
* vertex coords (in device space) if we transform the line to be horizontal, with the start of
* line at the origin then shifted to the right by half the off interval. The line then goes in the
@@ -1114,7 +1114,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
fragBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
inDashParams.fsIn(), inDashParams.fsIn(), inDashParams.fsIn(),
inDashParams.fsIn());
- fragBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", inDashParams.fsIn());
+ fragBuilder->codeAppendf("float2 fragPosShifted = float2(xShifted, %s.y);", inDashParams.fsIn());
if (de.aaMode() == AAMode::kCoverage) {
// The amount of coverage removed in x and y by the edges is computed as a pair of negative
// numbers, xSub and ySub.
@@ -1143,7 +1143,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
fragBuilder->codeAppendf("alpha *= (%s.z - fragPosShifted.x) >= -0.5 ? 1.0 : 0.0;",
inRectParams.fsIn());
}
- fragBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(alpha);", args.fOutputCoverage);
}
void GLDashingLineEffect::setData(const GrGLSLProgramDataManager& pdman,
diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp
index b570a65453..f1503fcd9f 100644
--- a/src/gpu/ops/GrMSAAPathRenderer.cpp
+++ b/src/gpu/ops/GrMSAAPathRenderer.cpp
@@ -156,7 +156,7 @@ public:
GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
fsBuilder->codeAppendf("if (%s.x * %s.x >= %s.y) discard;", uv.fsIn(), uv.fsIn(),
uv.fsIn());
- fsBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputCoverage);
+ fsBuilder->codeAppendf("%s = float4(1.0);", args.fOutputCoverage);
}
static inline void GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 1c80594343..770a54f512 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -119,21 +119,21 @@ private:
// emit attributes
varyingHandler->emitAttributes(cgp);
- fragBuilder->codeAppend("highp vec4 circleEdge;");
+ fragBuilder->codeAppend("highp float4 circleEdge;");
varyingHandler->addPassThroughAttribute(cgp.fInCircleEdge, "circleEdge",
kHigh_GrSLPrecision);
if (cgp.fInClipPlane) {
- fragBuilder->codeAppend("vec3 clipPlane;");
+ fragBuilder->codeAppend("float3 clipPlane;");
varyingHandler->addPassThroughAttribute(cgp.fInClipPlane, "clipPlane");
}
if (cgp.fInIsectPlane) {
SkASSERT(cgp.fInClipPlane);
- fragBuilder->codeAppend("vec3 isectPlane;");
+ fragBuilder->codeAppend("float3 isectPlane;");
varyingHandler->addPassThroughAttribute(cgp.fInIsectPlane, "isectPlane");
}
if (cgp.fInUnionPlane) {
SkASSERT(cgp.fInClipPlane);
- fragBuilder->codeAppend("vec3 unionPlane;");
+ fragBuilder->codeAppend("float3 unionPlane;");
varyingHandler->addPassThroughAttribute(cgp.fInUnionPlane, "unionPlane");
}
@@ -178,7 +178,7 @@ private:
}
fragBuilder->codeAppend("edgeAlpha *= clip;");
}
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static void GenKey(const GrGeometryProcessor& gp,
@@ -301,10 +301,10 @@ private:
args.fFPCoordTransformHandler);
// for outer curve
- fragBuilder->codeAppendf("vec2 scaledOffset = %s*%s.xy;", ellipseOffsets.fsIn(),
+ fragBuilder->codeAppendf("float2 scaledOffset = %s*%s.xy;", ellipseOffsets.fsIn(),
ellipseRadii.fsIn());
fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
- fragBuilder->codeAppendf("vec2 grad = 2.0*scaledOffset*%s.xy;", ellipseRadii.fsIn());
+ fragBuilder->codeAppendf("float2 grad = 2.0*scaledOffset*%s.xy;", ellipseRadii.fsIn());
fragBuilder->codeAppend("float grad_dot = dot(grad, grad);");
// avoid calling inversesqrt on zero.
@@ -322,7 +322,7 @@ private:
fragBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);");
}
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static void GenKey(const GrGeometryProcessor& gp,
@@ -445,12 +445,12 @@ private:
args.fFPCoordTransformHandler);
// for outer curve
- fragBuilder->codeAppendf("vec2 scaledOffset = %s.xy;", offsets0.fsIn());
+ fragBuilder->codeAppendf("float2 scaledOffset = %s.xy;", offsets0.fsIn());
fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
- fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s);", offsets0.fsIn());
- fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s);", offsets0.fsIn());
+ fragBuilder->codeAppendf("float2 duvdx = dFdx(%s);", offsets0.fsIn());
+ fragBuilder->codeAppendf("float2 duvdy = dFdy(%s);", offsets0.fsIn());
fragBuilder->codeAppendf(
- "vec2 grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
+ "float2 grad = float2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
" 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);",
offsets0.fsIn(), offsets0.fsIn(), offsets0.fsIn(), offsets0.fsIn());
@@ -473,14 +473,14 @@ private:
fragBuilder->codeAppendf("duvdx = dFdx(%s);", offsets1.fsIn());
fragBuilder->codeAppendf("duvdy = dFdy(%s);", offsets1.fsIn());
fragBuilder->codeAppendf(
- "grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
+ "grad = float2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
" 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);",
offsets1.fsIn(), offsets1.fsIn(), offsets1.fsIn(), offsets1.fsIn());
fragBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));");
fragBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);");
}
- fragBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
+ fragBuilder->codeAppendf("%s = float4(edgeAlpha);", args.fOutputCoverage);
}
static void GenKey(const GrGeometryProcessor& gp,
diff --git a/src/gpu/vk/GrVkCopyManager.cpp b/src/gpu/vk/GrVkCopyManager.cpp
index 47c17abe11..938596ff0c 100644
--- a/src/gpu/vk/GrVkCopyManager.cpp
+++ b/src/gpu/vk/GrVkCopyManager.cpp
@@ -44,17 +44,17 @@ bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
"#extension GL_ARB_shading_language_420pack : enable\n"
"layout(set = 0, binding = 0) uniform vertexUniformBuffer {"
- "mediump vec4 uPosXform;"
- "mediump vec4 uTexCoordXform;"
+ "mediump float4 uPosXform;"
+ "mediump float4 uTexCoordXform;"
"};"
- "layout(location = 0) in highp vec2 inPosition;"
- "layout(location = 1) out mediump vec2 vTexCoord;"
+ "layout(location = 0) in highp float2 inPosition;"
+ "layout(location = 1) out mediump float2 vTexCoord;"
"// Copy Program VS\n"
"void main() {"
"vTexCoord = inPosition * uTexCoordXform.xy + uTexCoordXform.zw;"
"gl_Position.xy = inPosition * uPosXform.xy + uPosXform.zw;"
- "gl_Position.zw = vec2(0, 1);"
+ "gl_Position.zw = float2(0, 1);"
"}"
);
@@ -66,8 +66,8 @@ bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
"precision mediump float;"
"layout(set = 1, binding = 0) uniform mediump sampler2D uTextureSampler;"
- "layout(location = 1) in mediump vec2 vTexCoord;"
- "layout(location = 0, index = 0) out mediump vec4 fsColorOut;"
+ "layout(location = 1) in mediump float2 vTexCoord;"
+ "layout(location = 0, index = 0) out mediump float4 fsColorOut;"
"// Copy Program FS\n"
"void main() {"
@@ -135,7 +135,7 @@ bool GrVkCopyManager::createCopyProgram(GrVkGpu* gpu) {
SkASSERT(fVertexBuffer.get());
fVertexBuffer->updateData(vdata, sizeof(vdata));
- // We use 2 vec4's for uniforms
+ // We use 2 float4's for uniforms
fUniformBuffer.reset(GrVkUniformBuffer::Create(gpu, 8 * sizeof(float)));
SkASSERT(fUniformBuffer.get());
diff --git a/src/gpu/vk/GrVkPipelineState.h b/src/gpu/vk/GrVkPipelineState.h
index 9481aa170f..a5d334613e 100644
--- a/src/gpu/vk/GrVkPipelineState.h
+++ b/src/gpu/vk/GrVkPipelineState.h
@@ -132,8 +132,8 @@ private:
}
/**
- * Gets a vec4 that adjusts the position from Skia device coords to Vulkans normalized device
- * coords. Assuming the transformed position, pos, is a homogeneous vec3, the vec, v, is
+ * Gets a float4 that adjusts the position from Skia device coords to Vulkans normalized device
+ * coords. Assuming the transformed position, pos, is a homogeneous float3, the vec, v, is
* applied as such:
* pos.x = dot(v.xy, pos.xz)
* pos.y = dot(v.zw, pos.yz)
diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp
index 55fd3d7f24..f45d7955f1 100644
--- a/src/gpu/vk/GrVkUniformHandler.cpp
+++ b/src/gpu/vk/GrVkUniformHandler.cpp
@@ -61,7 +61,7 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
/** Returns the size in bytes taken up in vulkanbuffers for floating point GrSLTypes.
For non floating point type returns 0. Currently this reflects the std140 alignment
- so a mat22 takes up 8 floats. */
+ so a float2x2 takes up 8 floats. */
static inline uint32_t grsltype_to_vk_size(GrSLType type) {
switch(type) {
case kInt_GrSLType:
diff --git a/src/shaders/SkLightingShader.cpp b/src/shaders/SkLightingShader.cpp
index 96b87edd8c..88610a073c 100644
--- a/src/shaders/SkLightingShader.cpp
+++ b/src/shaders/SkLightingShader.cpp
@@ -172,14 +172,14 @@ private:
kVec3f_GrSLType, kDefault_GrSLPrecision,
"AmbientColor", &ambientColorUniName);
- fragBuilder->codeAppendf("vec4 diffuseColor = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("float4 diffuseColor = %s;", args.fInputColor);
SkString dstNormalName("dstNormal");
this->emitChild(0, &dstNormalName, args);
- fragBuilder->codeAppendf("vec3 normal = %s.xyz;", dstNormalName.c_str());
+ fragBuilder->codeAppendf("float3 normal = %s.xyz;", dstNormalName.c_str());
- fragBuilder->codeAppend( "vec3 result = vec3(0.0);");
+ fragBuilder->codeAppend( "float3 result = float3(0.0);");
// diffuse light
if (lightingFP.fDirectionalLights.count() != 0) {
@@ -197,7 +197,7 @@ private:
fragBuilder->codeAppendf("result += %s * diffuseColor.rgb;", ambientColorUniName);
// Clamping to alpha (equivalent to an unpremul'd clamp to 1.0)
- fragBuilder->codeAppendf("%s = vec4(clamp(result.rgb, 0.0, diffuseColor.a), "
+ fragBuilder->codeAppendf("%s = float4(clamp(result.rgb, 0.0, diffuseColor.a), "
"diffuseColor.a);", args.fOutputColor);
}
diff --git a/src/shaders/SkPerlinNoiseShader.cpp b/src/shaders/SkPerlinNoiseShader.cpp
index d8c6047ca5..0ce007a55a 100644
--- a/src/shaders/SkPerlinNoiseShader.cpp
+++ b/src/shaders/SkPerlinNoiseShader.cpp
@@ -851,7 +851,7 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
const char* inc8bit = "0.00390625"; // 1.0 / 256.0
// This is the math to convert the two 16bit integer packed into rgba 8 bit input into a
// [-1,1] vector and perform a dot product between that vector and the provided vector.
- const char* dotLattice = "dot(((%s.ga + %s.rb * vec2(%s)) * vec2(2.0) - vec2(1.0)), %s);";
+ const char* dotLattice = "dot(((%s.ga + %s.rb * float2(%s)) * float2(2.0) - float2(1.0)), %s);";
// Add noise function
static const GrShaderVar gPerlinNoiseArgs[] = {
@@ -867,13 +867,13 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
SkString noiseCode;
- noiseCode.appendf("\tvec4 %s;\n", floorVal);
+ noiseCode.appendf("\tfloat4 %s;\n", floorVal);
noiseCode.appendf("\t%s.xy = floor(%s);\n", floorVal, noiseVec);
- noiseCode.appendf("\t%s.zw = %s.xy + vec2(1.0);\n", floorVal, floorVal);
- noiseCode.appendf("\tvec2 %s = fract(%s);\n", fractVal, noiseVec);
+ noiseCode.appendf("\t%s.zw = %s.xy + float2(1.0);\n", floorVal, floorVal);
+ noiseCode.appendf("\tfloat2 %s = fract(%s);\n", fractVal, noiseVec);
// smooth curve : t * t * (3 - 2 * t)
- noiseCode.appendf("\n\tvec2 %s = %s * %s * (vec2(3.0) - vec2(2.0) * %s);",
+ noiseCode.appendf("\n\tfloat2 %s = %s * %s * (float2(3.0) - float2(2.0) * %s);",
noiseSmooth, fractVal, fractVal, fractVal);
// Adjust frequencies if we're stitching tiles
@@ -889,15 +889,15 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
}
// Get texture coordinates and normalize
- noiseCode.appendf("\n\t%s = fract(floor(mod(%s, 256.0)) / vec4(256.0));\n",
+ noiseCode.appendf("\n\t%s = fract(floor(mod(%s, 256.0)) / float4(256.0));\n",
floorVal, floorVal);
// Get permutation for x
{
SkString xCoords("");
- xCoords.appendf("vec2(%s.x, 0.5)", floorVal);
+ xCoords.appendf("float2(%s.x, 0.5)", floorVal);
- noiseCode.appendf("\n\tvec2 %s;\n\t%s.x = ", latticeIdx, latticeIdx);
+ noiseCode.appendf("\n\tfloat2 %s;\n\t%s.x = ", latticeIdx, latticeIdx);
fragBuilder->appendTextureLookup(&noiseCode, args.fTexSamplers[0], xCoords.c_str(),
kVec2f_GrSLType);
noiseCode.append(".r;");
@@ -906,7 +906,7 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
// Get permutation for x + 1
{
SkString xCoords("");
- xCoords.appendf("vec2(%s.z, 0.5)", floorVal);
+ xCoords.appendf("float2(%s.z, 0.5)", floorVal);
noiseCode.appendf("\n\t%s.y = ", latticeIdx);
fragBuilder->appendTextureLookup(&noiseCode, args.fTexSamplers[0], xCoords.c_str(),
@@ -921,19 +921,19 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
// (or 0.484368 here). The following rounding operation prevents these precision issues from
// affecting the result of the noise by making sure that we only have multiples of 1/255.
// (Note that 1/255 is about 0.003921569, which is the value used here).
- noiseCode.appendf("\n\t%s = floor(%s * vec2(255.0) + vec2(0.5)) * vec2(0.003921569);",
+ noiseCode.appendf("\n\t%s = floor(%s * float2(255.0) + float2(0.5)) * float2(0.003921569);",
latticeIdx, latticeIdx);
#endif
// Get (x,y) coordinates with the permutated x
- noiseCode.appendf("\n\tvec4 %s = fract(%s.xyxy + %s.yyww);", bcoords, latticeIdx, floorVal);
+ noiseCode.appendf("\n\tfloat4 %s = fract(%s.xyxy + %s.yyww);", bcoords, latticeIdx, floorVal);
- noiseCode.appendf("\n\n\tvec2 %s;", uv);
+ noiseCode.appendf("\n\n\tfloat2 %s;", uv);
// Compute u, at offset (0,0)
{
SkString latticeCoords("");
- latticeCoords.appendf("vec2(%s.x, %s)", bcoords, chanCoord);
- noiseCode.appendf("\n\tvec4 %s = ", lattice);
+ latticeCoords.appendf("float2(%s.x, %s)", bcoords, chanCoord);
+ noiseCode.appendf("\n\tfloat4 %s = ", lattice);
fragBuilder->appendTextureLookup(&noiseCode, args.fTexSamplers[1], latticeCoords.c_str(),
kVec2f_GrSLType);
noiseCode.appendf(".bgra;\n\t%s.x = ", uv);
@@ -944,7 +944,7 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
// Compute v, at offset (-1,0)
{
SkString latticeCoords("");
- latticeCoords.appendf("vec2(%s.y, %s)", bcoords, chanCoord);
+ latticeCoords.appendf("float2(%s.y, %s)", bcoords, chanCoord);
noiseCode.append("\n\tlattice = ");
fragBuilder->appendTextureLookup(&noiseCode, args.fTexSamplers[1], latticeCoords.c_str(),
kVec2f_GrSLType);
@@ -953,14 +953,14 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
}
// Compute 'a' as a linear interpolation of 'u' and 'v'
- noiseCode.appendf("\n\tvec2 %s;", ab);
+ noiseCode.appendf("\n\tfloat2 %s;", ab);
noiseCode.appendf("\n\t%s.x = mix(%s.x, %s.y, %s.x);", ab, uv, uv, noiseSmooth);
noiseCode.appendf("\n\t%s.y -= 1.0;", fractVal);
// Compute v, at offset (-1,-1)
{
SkString latticeCoords("");
- latticeCoords.appendf("vec2(%s.w, %s)", bcoords, chanCoord);
+ latticeCoords.appendf("float2(%s.w, %s)", bcoords, chanCoord);
noiseCode.append("\n\tlattice = ");
fragBuilder->appendTextureLookup(&noiseCode, args.fTexSamplers[1], latticeCoords.c_str(),
kVec2f_GrSLType);
@@ -972,7 +972,7 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
// Compute u, at offset (0,-1)
{
SkString latticeCoords("");
- latticeCoords.appendf("vec2(%s.z, %s)", bcoords, chanCoord);
+ latticeCoords.appendf("float2(%s.z, %s)", bcoords, chanCoord);
noiseCode.append("\n\tlattice = ");
fragBuilder->appendTextureLookup(&noiseCode, args.fTexSamplers[1], latticeCoords.c_str(),
kVec2f_GrSLType);
@@ -997,15 +997,15 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
}
// There are rounding errors if the floor operation is not performed here
- fragBuilder->codeAppendf("\n\t\tvec2 %s = floor(%s.xy) * %s;",
+ fragBuilder->codeAppendf("\n\t\tfloat2 %s = floor(%s.xy) * %s;",
noiseVec, vCoords.c_str(), baseFrequencyUni);
// Clear the color accumulator
- fragBuilder->codeAppendf("\n\t\t%s = vec4(0.0);", args.fOutputColor);
+ fragBuilder->codeAppendf("\n\t\t%s = float4(0.0);", args.fOutputColor);
if (pne.stitchTiles()) {
// Set up TurbulenceInitial stitch values.
- fragBuilder->codeAppendf("\n\t\tvec2 %s = %s;", stitchData, stitchDataUni);
+ fragBuilder->codeAppendf("\n\t\tfloat2 %s = %s;", stitchData, stitchDataUni);
}
fragBuilder->codeAppendf("\n\t\tfloat %s = 1.0;", ratio);
@@ -1019,7 +1019,7 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
}
if (pne.stitchTiles()) {
fragBuilder->codeAppendf(
- "vec4(\n\t\t\t\t%s(%s, %s, %s),\n\t\t\t\t%s(%s, %s, %s),"
+ "float4(\n\t\t\t\t%s(%s, %s, %s),\n\t\t\t\t%s(%s, %s, %s),"
"\n\t\t\t\t%s(%s, %s, %s),\n\t\t\t\t%s(%s, %s, %s))",
noiseFuncName.c_str(), chanCoordR, noiseVec, stitchData,
noiseFuncName.c_str(), chanCoordG, noiseVec, stitchData,
@@ -1027,7 +1027,7 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
noiseFuncName.c_str(), chanCoordA, noiseVec, stitchData);
} else {
fragBuilder->codeAppendf(
- "vec4(\n\t\t\t\t%s(%s, %s),\n\t\t\t\t%s(%s, %s),"
+ "float4(\n\t\t\t\t%s(%s, %s),\n\t\t\t\t%s(%s, %s),"
"\n\t\t\t\t%s(%s, %s),\n\t\t\t\t%s(%s, %s))",
noiseFuncName.c_str(), chanCoordR, noiseVec,
noiseFuncName.c_str(), chanCoordG, noiseVec,
@@ -1039,18 +1039,18 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
}
fragBuilder->codeAppendf(" * %s;", ratio);
- fragBuilder->codeAppendf("\n\t\t\t%s *= vec2(2.0);", noiseVec);
+ fragBuilder->codeAppendf("\n\t\t\t%s *= float2(2.0);", noiseVec);
fragBuilder->codeAppendf("\n\t\t\t%s *= 0.5;", ratio);
if (pne.stitchTiles()) {
- fragBuilder->codeAppendf("\n\t\t\t%s *= vec2(2.0);", stitchData);
+ fragBuilder->codeAppendf("\n\t\t\t%s *= float2(2.0);", stitchData);
}
fragBuilder->codeAppend("\n\t\t}"); // end of the for loop on octaves
if (pne.type() == SkPerlinNoiseShaderImpl::kFractalNoise_Type) {
// The value of turbulenceFunctionResult comes from ((turbulenceFunctionResult) + 1) / 2
// by fractalNoise and (turbulenceFunctionResult) by turbulence.
- fragBuilder->codeAppendf("\n\t\t%s = %s * vec4(0.5) + vec4(0.5);",
+ fragBuilder->codeAppendf("\n\t\t%s = %s * float4(0.5) + float4(0.5);",
args.fOutputColor,args.fOutputColor);
}
@@ -1058,7 +1058,7 @@ void GrGLPerlinNoise::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("\n\t\t%s = clamp(%s, 0.0, 1.0);", args.fOutputColor, args.fOutputColor);
// Pre-multiply the result
- fragBuilder->codeAppendf("\n\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n",
+ fragBuilder->codeAppendf("\n\t\t%s = float4(%s.rgb * %s.aaa, %s.a);\n",
args.fOutputColor, args.fOutputColor,
args.fOutputColor, args.fOutputColor);
}
@@ -1265,7 +1265,7 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
SkString permCode("return ");
// FIXME even though I'm creating these textures with kRepeat_TileMode, they're clamped. Not
// sure why. Using fract() (here and the next texture lookup) as a workaround.
- fragBuilder->appendTextureLookup(&permCode, args.fTexSamplers[0], "vec2(fract(x / 256.0), 0.0)",
+ fragBuilder->appendTextureLookup(&permCode, args.fTexSamplers[0], "float2(fract(x / 256.0), 0.0)",
kVec2f_GrSLType);
permCode.append(".r * 255.0;");
fragBuilder->emitFunction(kFloat_GrSLType, "perm", SK_ARRAY_COUNT(permArgs), permArgs,
@@ -1278,9 +1278,9 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
};
SkString gradFuncName;
SkString gradCode("return dot(");
- fragBuilder->appendTextureLookup(&gradCode, args.fTexSamplers[1], "vec2(fract(x / 16.0), 0.0)",
+ fragBuilder->appendTextureLookup(&gradCode, args.fTexSamplers[1], "float2(fract(x / 16.0), 0.0)",
kVec2f_GrSLType);
- gradCode.append(".rgb * 255.0 - vec3(1.0), p);");
+ gradCode.append(".rgb * 255.0 - float3(1.0), p);");
fragBuilder->emitFunction(kFloat_GrSLType, "grad", SK_ARRAY_COUNT(gradArgs), gradArgs,
gradCode.c_str(), &gradFuncName);
@@ -1300,9 +1300,9 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
};
SkString noiseFuncName;
SkString noiseCode;
- noiseCode.append("vec3 P = mod(floor(p), 256.0);");
+ noiseCode.append("float3 P = mod(floor(p), 256.0);");
noiseCode.append("p -= floor(p);");
- noiseCode.appendf("vec3 f = %s(p);", fadeFuncName.c_str());
+ noiseCode.appendf("float3 f = %s(p);", fadeFuncName.c_str());
noiseCode.appendf("float A = %s(P.x) + P.y;", permFuncName.c_str());
noiseCode.appendf("float AA = %s(A) + P.z;", permFuncName.c_str());
noiseCode.appendf("float AB = %s(A + 1.0) + P.z;", permFuncName.c_str());
@@ -1312,20 +1312,20 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
noiseCode.appendf("float result = %s(", lerpFuncName.c_str());
noiseCode.appendf("%s(%s(%s(%s(AA), p),", lerpFuncName.c_str(), lerpFuncName.c_str(),
gradFuncName.c_str(), permFuncName.c_str());
- noiseCode.appendf("%s(%s(BA), p + vec3(-1.0, 0.0, 0.0)), f.x),", gradFuncName.c_str(),
+ noiseCode.appendf("%s(%s(BA), p + float3(-1.0, 0.0, 0.0)), f.x),", gradFuncName.c_str(),
permFuncName.c_str());
- noiseCode.appendf("%s(%s(%s(AB), p + vec3(0.0, -1.0, 0.0)),", lerpFuncName.c_str(),
+ noiseCode.appendf("%s(%s(%s(AB), p + float3(0.0, -1.0, 0.0)),", lerpFuncName.c_str(),
gradFuncName.c_str(), permFuncName.c_str());
- noiseCode.appendf("%s(%s(BB), p + vec3(-1.0, -1.0, 0.0)), f.x), f.y),",
+ noiseCode.appendf("%s(%s(BB), p + float3(-1.0, -1.0, 0.0)), f.x), f.y),",
gradFuncName.c_str(), permFuncName.c_str());
- noiseCode.appendf("%s(%s(%s(%s(AA + 1.0), p + vec3(0.0, 0.0, -1.0)),",
+ noiseCode.appendf("%s(%s(%s(%s(AA + 1.0), p + float3(0.0, 0.0, -1.0)),",
lerpFuncName.c_str(), lerpFuncName.c_str(), gradFuncName.c_str(),
permFuncName.c_str());
- noiseCode.appendf("%s(%s(BA + 1.0), p + vec3(-1.0, 0.0, -1.0)), f.x),",
+ noiseCode.appendf("%s(%s(BA + 1.0), p + float3(-1.0, 0.0, -1.0)), f.x),",
gradFuncName.c_str(), permFuncName.c_str());
- noiseCode.appendf("%s(%s(%s(AB + 1.0), p + vec3(0.0, -1.0, -1.0)),",
+ noiseCode.appendf("%s(%s(%s(AB + 1.0), p + float3(0.0, -1.0, -1.0)),",
lerpFuncName.c_str(), gradFuncName.c_str(), permFuncName.c_str());
- noiseCode.appendf("%s(%s(BB + 1.0), p + vec3(-1.0, -1.0, -1.0)), f.x), f.y), f.z);",
+ noiseCode.appendf("%s(%s(BB + 1.0), p + float3(-1.0, -1.0, -1.0)), f.x), f.y), f.z);",
gradFuncName.c_str(), permFuncName.c_str());
noiseCode.append("return result;");
fragBuilder->emitFunction(kFloat_GrSLType, "noise", SK_ARRAY_COUNT(noiseArgs), noiseArgs,
@@ -1348,22 +1348,22 @@ void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
fragBuilder->emitFunction(kFloat_GrSLType, "noiseOctaves", SK_ARRAY_COUNT(noiseOctavesArgs),
noiseOctavesArgs, noiseOctavesCode.c_str(), &noiseOctavesFuncName);
- fragBuilder->codeAppendf("vec2 coords = %s * %s;", vCoords.c_str(), baseFrequencyUni);
- fragBuilder->codeAppendf("float r = %s(vec3(coords, %s));", noiseOctavesFuncName.c_str(),
+ fragBuilder->codeAppendf("float2 coords = %s * %s;", vCoords.c_str(), baseFrequencyUni);
+ fragBuilder->codeAppendf("float r = %s(float3(coords, %s));", noiseOctavesFuncName.c_str(),
zUni);
- fragBuilder->codeAppendf("float g = %s(vec3(coords, %s + 0000.0));",
+ fragBuilder->codeAppendf("float g = %s(float3(coords, %s + 0000.0));",
noiseOctavesFuncName.c_str(), zUni);
- fragBuilder->codeAppendf("float b = %s(vec3(coords, %s + 0000.0));",
+ fragBuilder->codeAppendf("float b = %s(float3(coords, %s + 0000.0));",
noiseOctavesFuncName.c_str(), zUni);
- fragBuilder->codeAppendf("float a = %s(vec3(coords, %s + 0000.0));",
+ fragBuilder->codeAppendf("float a = %s(float3(coords, %s + 0000.0));",
noiseOctavesFuncName.c_str(), zUni);
- fragBuilder->codeAppendf("%s = vec4(r, g, b, a);", args.fOutputColor);
+ fragBuilder->codeAppendf("%s = float4(r, g, b, a);", args.fOutputColor);
// Clamp values
fragBuilder->codeAppendf("%s = clamp(%s, 0.0, 1.0);", args.fOutputColor, args.fOutputColor);
// Pre-multiply the result
- fragBuilder->codeAppendf("\n\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n",
+ fragBuilder->codeAppendf("\n\t\t%s = float4(%s.rgb * %s.aaa, %s.a);\n",
args.fOutputColor, args.fOutputColor,
args.fOutputColor, args.fOutputColor);
}
diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp
index 9f9b73f4b5..56a8fe317b 100644
--- a/src/shaders/gradients/SkGradientShader.cpp
+++ b/src/shaders/gradients/SkGradientShader.cpp
@@ -1563,7 +1563,7 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
}
// Calculate color
- fragBuilder->codeAppend ("vec4 start, end;");
+ fragBuilder->codeAppend ("float4 start, end;");
fragBuilder->codeAppend ("float relative_t;");
fragBuilder->codeAppendf("if (clamp_t < %s) {", stopT);
fragBuilder->codeAppendf(" start = %s[0];", colors);
@@ -1574,7 +1574,7 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
fragBuilder->codeAppendf(" end = %s[3];", colors);
fragBuilder->codeAppendf(" relative_t = (clamp_t - %s) / (1 - %s);", stopT, stopT);
fragBuilder->codeAppend ("}");
- fragBuilder->codeAppend ("vec4 colorTemp = mix(start, end, relative_t);");
+ fragBuilder->codeAppend ("float4 colorTemp = mix(start, end, relative_t);");
if (GrGradientEffect::kAfterInterp_PremulType == ge.getPremulType()) {
fragBuilder->codeAppend("colorTemp.rgb *= colorTemp.a;");
@@ -1606,7 +1606,7 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
fragBuilder->codeAppendf("}");
}
- fragBuilder->codeAppendf("vec4 colorTemp = mix(%s[1], %s[2], clamp_t);", colors,
+ fragBuilder->codeAppendf("float4 colorTemp = mix(%s[1], %s[2], clamp_t);", colors,
colors);
if (SkShader::kClamp_TileMode == ge.fTileMode) {
fragBuilder->codeAppendf("if (%s < 0.0) {", t);
@@ -1644,7 +1644,7 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
fragBuilder->codeAppendf("}");
}
- fragBuilder->codeAppendf("vec4 colorTemp = mix(%s[0], %s[1], clamp_t);", colors,
+ fragBuilder->codeAppendf("float4 colorTemp = mix(%s[0], %s[1], clamp_t);", colors,
colors);
if (SkShader::kClamp_TileMode == ge.fTileMode) {
fragBuilder->codeAppendf("if (%s > 1.0) {", t);
@@ -1667,7 +1667,7 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
const char* t = gradientTValue;
const char* colors = uniformHandler->getUniformCStr(fColorsUni);
- fragBuilder->codeAppendf("vec4 colorTemp = mix(%s[0], %s[1], clamp(%s, 0.0, 1.0));",
+ fragBuilder->codeAppendf("float4 colorTemp = mix(%s[0], %s[1], clamp(%s, 0.0, 1.0));",
colors, colors, t);
// We could skip this step if both colors are known to be opaque. Two
@@ -1693,7 +1693,7 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
const char* colors = uniformHandler->getUniformCStr(fColorsUni);
fragBuilder->codeAppendf("float oneMinus2t = 1.0 - (2.0 * %s);", t);
- fragBuilder->codeAppendf("vec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s[0];",
+ fragBuilder->codeAppendf("float4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s[0];",
colors);
if (!shaderCaps->canUseMinAndAbsTogether()) {
// The Tegra3 compiler will sometimes never return if we have
@@ -1724,7 +1724,7 @@ void GrGradientEffect::GLSLProcessor::emitColor(GrGLSLFPFragmentBuilder* fragBui
const char* fsyuni = uniformHandler->getUniformCStr(fFSYUni);
- fragBuilder->codeAppendf("vec2 coord = vec2(%s, %s);", gradientTValue, fsyuni);
+ fragBuilder->codeAppendf("float2 coord = float2(%s, %s);", gradientTValue, fsyuni);
fragBuilder->codeAppendf("%s = ", outputColor);
fragBuilder->appendTextureLookupAndModulate(inputColor, texSamplers[0], "coord",
kVec2f_GrSLType, &fColorSpaceHelper);
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp
index 41e184351c..8263f88946 100644
--- a/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -256,7 +256,7 @@ void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::emitCode(EmitArgs& args)
SkString bVar;
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
if (kVec3f_GrSLType == args.fTransformedCoords[0].getType()) {
- fragBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy / %s.z, %s.x / %s.z);\n",
+ fragBuilder->codeAppendf("\tfloat3 interpolants = float3(%s.xy / %s.z, %s.x / %s.z);\n",
args.fTransformedCoords[0].c_str(),
args.fTransformedCoords[0].c_str(),
args.fTransformedCoords[1].c_str(),
@@ -270,7 +270,7 @@ void Edge2PtConicalEffect::GLSLEdge2PtConicalProcessor::emitCode(EmitArgs& args)
// output will default to transparent black (we simply won't write anything
// else to it if invalid, instead of discarding or returning prematurely)
- fragBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", args.fOutputColor);
+ fragBuilder->codeAppendf("\t%s = float4(0.0,0.0,0.0,0.0);\n", args.fOutputColor);
// c = (x^2)+(y^2) - params[1]
fragBuilder->codeAppendf("\tfloat %s = dot(%s, %s) - %s;\n",
@@ -534,7 +534,7 @@ void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::emitCode
p0.appendf("%s.x", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
p1.appendf("%s.y", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
- // if we have a vec3 from being in perspective, convert it to a vec2 first
+ // if we have a float3 from being in perspective, convert it to a float2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2DString = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
const char* coords2D = coords2DString.c_str();
@@ -543,7 +543,7 @@ void FocalOutside2PtConicalEffect::GLSLFocalOutside2PtConicalProcessor::emitCode
// output will default to transparent black (we simply won't write anything
// else to it if invalid, instead of discarding or returning prematurely)
- fragBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", args.fOutputColor);
+ fragBuilder->codeAppendf("\t%s = float4(0.0,0.0,0.0,0.0);\n", args.fOutputColor);
fragBuilder->codeAppendf("\tfloat xs = %s.x * %s.x;\n", coords2D, coords2D);
fragBuilder->codeAppendf("\tfloat ys = %s.y * %s.y;\n", coords2D, coords2D);
@@ -741,7 +741,7 @@ void FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor::emitCode(E
// transformed coordinates
GrShaderVar focal = uniformHandler->getUniformVariable(fFocalUni);
- // if we have a vec3 from being in perspective, convert it to a vec2 first
+ // if we have a float3 from being in perspective, convert it to a float2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2DString = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
const char* coords2D = coords2DString.c_str();
@@ -1003,7 +1003,7 @@ void CircleInside2PtConicalEffect::GLSLCircleInside2PtConicalProcessor::emitCode
// params.z = C
GrShaderVar params = uniformHandler->getUniformVariable(fParamUni);
- // if we have a vec3 from being in perspective, convert it to a vec2 first
+ // if we have a float3 from being in perspective, convert it to a float2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2DString = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
const char* coords2D = coords2DString.c_str();
@@ -1250,14 +1250,14 @@ void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::emitCo
// params.z = C
GrShaderVar params = uniformHandler->getUniformVariable(fParamUni);
- // if we have a vec3 from being in perspective, convert it to a vec2 first
+ // if we have a float3 from being in perspective, convert it to a float2 first
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2DString = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
const char* coords2D = coords2DString.c_str();
// output will default to transparent black (we simply won't write anything
// else to it if invalid, instead of discarding or returning prematurely)
- fragBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", args.fOutputColor);
+ fragBuilder->codeAppendf("\t%s = float4(0.0,0.0,0.0,0.0);\n", args.fOutputColor);
// p = coords2D
// e = center end
diff --git a/src/sksl/README b/src/sksl/README
index f590bbeae2..012895412e 100644
--- a/src/sksl/README
+++ b/src/sksl/README
@@ -13,12 +13,10 @@ before handing it over to the graphics driver.
Differences from GLSL
=====================
-SkSL is based on GLSL 4.5. For the most part, write SkSL exactly as you would
-desktop GLSL, and the SkSL compiler will take care of version and dialect
-differences (for instance, you always use "in" and "out", and skslc will handle
-translating them to "varying" and "attribute" as appropriate). Be aware of the
-following differences between SkSL and GLSL:
-
+* Vector types are named <base type><columns>, so float2 instead of vec2 and
+ bool4 instead of bvec4
+* Matrix types are named <base type><columns>x<rows>, so float2x3 instead of
+ mat2x3 and double4x4 instead of dmat4
* "@if" and "@switch" are static versions of if and switch. They behave exactly
the same as if and switch in all respects other than it being a compile-time
error to use a non-constant expression as a test.
@@ -35,7 +33,7 @@ following differences between SkSL and GLSL:
will compile as if you had written either 'do_something();' or
'do_something_else();', depending on whether that cap is enabled or not.
-* no #version statement is required, and will be ignored if present
+* no #version statement is required, and it will be ignored if present
* the output color is sk_FragColor (do not declare it)
* use sk_VertexID instead of gl_VertexID
* the fragment coordinate is sk_FragCoord, and is always relative to the upper
@@ -43,15 +41,15 @@ following differences between SkSL and GLSL:
* lowp, mediump, and highp are always permitted (but will only be respected if
you run on a device which supports them)
* you do not need to include ".0" to make a number a float (meaning that
- "vec2(x, y) * 4" is perfectly legal in SkSL, unlike GLSL where it would often
- have to be expressed "vec2(x, y) * 4.0". There is no performance penalty for
+ "float2x, y) * 4" is perfectly legal in SkSL, unlike GLSL where it would often
+ have to be expressed "float2x, y) * 4.0". There is no performance penalty for
this, as the number is converted to a float at compile time)
* type suffixes on numbers (1.0f, 0xFFu) are both unnecessary and unsupported
-* creating a smaller vector from a larger vector (e.g. vec2(vec3(1))) is
+* creating a smaller vector from a larger vector (e.g. float2float31))) is
intentionally disallowed, as it is just a wordier way of performing a swizzle.
Use swizzles instead.
-* Use texture() instead of textureProj(), e.g. texture(sampler2D, vec3) is
- equivalent to GLSL's textureProj(sampler2D, vec3)
+* Use texture() instead of textureProj(), e.g. texture(sampler2D, float3 is
+ equivalent to GLSL's textureProj(sampler2D, float3
* some built-in functions and one or two rarely-used language features are not
yet supported (sorry!)
@@ -96,7 +94,7 @@ Within an '.fp' fragment processor file:
(the sampler params to attach to the named sampler2D)
* global 'in' variables represent data passed to the fragment processor at
construction time. These variables become constructor parameters and are
- stored in fragment processor fields. vec2s map to SkPoints, and vec4s map to
+ stored in fragment processor fields. float2 map to SkPoints, and float4 map to
SkRects (in x, y, width, height) order.
* 'uniform' variables become, as one would expect, top-level uniforms. By
default they do not have any data provided to them; you will need to provide
diff --git a/src/sksl/SkSLCPP.h b/src/sksl/SkSLCPP.h
index 47f8a4080b..642f7c6ac8 100644
--- a/src/sksl/SkSLCPP.h
+++ b/src/sksl/SkSLCPP.h
@@ -18,8 +18,8 @@
#define floatPrecisionVaries floatPrecisionVaries()
// functions to make GLSL constructors work from C++ code
-inline SkPoint vec2(float xy) { return SkPoint::Make(xy, xy); }
+inline SkPoint float2(float xy) { return SkPoint::Make(xy, xy); }
-inline SkPoint vec2(float x, float y) { return SkPoint::Make(x, y); }
+inline SkPoint float2(float x, float y) { return SkPoint::Make(x, y); }
#endif
diff --git a/src/sksl/SkSLCPPCodeGenerator.cpp b/src/sksl/SkSLCPPCodeGenerator.cpp
index 235c9d8950..7c10606f79 100644
--- a/src/sksl/SkSLCPPCodeGenerator.cpp
+++ b/src/sksl/SkSLCPPCodeGenerator.cpp
@@ -54,6 +54,13 @@ void CPPCodeGenerator::writeHeader() {
void CPPCodeGenerator::writePrecisionModifier() {
}
+void CPPCodeGenerator::writeType(const Type& type) {
+ if (type.kind() == Type::kStruct_Kind) {
+ INHERITED::writeType(type);
+ } else {
+ this->write(type.name());
+ }
+}
void CPPCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
Precedence parentPrecedence) {
if (b.fOperator == Token::PERCENT) {
@@ -114,14 +121,14 @@ static const char* default_value(const Type& type) {
const char* name = type.name().c_str();
if (!strcmp(name, "float")) {
return "0.0";
- } else if (!strcmp(name, "vec2")) {
- return "vec2(0.0)";
- } else if (!strcmp(name, "vec3")) {
- return "vec3(0.0)";
- } else if (!strcmp(name, "vec4")) {
- return "vec4(0.0)";
- } else if (!strcmp(name, "mat4") || !strcmp(name, "colorSpaceXform")) {
- return "mat4(1.0)";
+ } else if (!strcmp(name, "float2")) {
+ return "float2(0.0)";
+ } else if (!strcmp(name, "float3")) {
+ return "float30.0)";
+ } else if (!strcmp(name, "float4")) {
+ return "float4(0.0)";
+ } else if (!strcmp(name, "floatt4x4") || !strcmp(name, "colorSpaceXform")) {
+ return "float4x4(1.0)";
}
ABORT("unsupported default_value type\n");
}
@@ -143,8 +150,8 @@ void CPPCodeGenerator::writeRuntimeValue(const Type& type, const String& cppCode
} else if (type == *fContext.fBool_Type) {
this->write("%s");
fFormatArgs.push_back("(" + cppCode + " ? \"true\" : \"false\")");
- } else if (type == *fContext.fVec2_Type) {
- this->write("vec2(%f, %f)");
+ } else if (type == *fContext.fFloat2_Type) {
+ this->write("float2(%f, %f)");
fFormatArgs.push_back(cppCode + ".fX");
fFormatArgs.push_back(cppCode + ".fY");
} else {
@@ -178,7 +185,7 @@ void CPPCodeGenerator::writeVariableReference(const VariableReference& ref) {
switch (ref.fVariable.fModifiers.fLayout.fBuiltin) {
case SK_INCOLOR_BUILTIN:
this->write("%s");
- fFormatArgs.push_back(String("args.fInputColor ? args.fInputColor : \"vec4(1)\""));
+ fFormatArgs.push_back(String("args.fInputColor ? args.fInputColor : \"float4(1)\""));
break;
case SK_OUTCOLOR_BUILTIN:
this->write("%s");
@@ -242,7 +249,7 @@ void CPPCodeGenerator::writeSwitchStatement(const SwitchStatement& s) {
void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (c.fFunction.fBuiltin && c.fFunction.fName == "COLORSPACE") {
String tmpVar = "_tmpVar" + to_string(++fVarCount);
- fFunctionHeader += "vec4 " + tmpVar + ";";
+ fFunctionHeader += "float4 " + tmpVar + ";";
ASSERT(c.fArguments.size() == 2);
this->write("%s");
fFormatArgs.push_back("fColorSpaceHelper.isValid() ? \"(" + tmpVar + " = \" : \"\"");
@@ -250,8 +257,9 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
ASSERT(c.fArguments[1]->fKind == Expression::kVariableReference_Kind);
String xform("args.fUniformHandler->getUniformCStr(fColorSpaceHelper.gamutXformUniform())");
this->write("%s");
- fFormatArgs.push_back("fColorSpaceHelper.isValid() ? SkStringPrintf(\", vec4(clamp((%s * vec4(" + tmpVar + ".rgb, 1.0)).rgb, 0.0, " + tmpVar +
- ".a), " + tmpVar + ".a))\", " + xform + ").c_str() : \"\"");
+ fFormatArgs.push_back("fColorSpaceHelper.isValid() ? SkStringPrintf(\", "
+ "float4(clamp((%s * float4(" + tmpVar + ".rgb, 1.0)).rgb, 0.0, " +
+ tmpVar + ".a), " + tmpVar + ".a))\", " + xform + ").c_str() : \"\"");
return;
}
INHERITED::writeFunctionCall(c);
@@ -336,11 +344,11 @@ void CPPCodeGenerator::addUniform(const Variable& var) {
const char* type;
if (var.fType == *fContext.fFloat_Type) {
type = "kFloat_GrSLType";
- } else if (var.fType == *fContext.fVec2_Type) {
+ } else if (var.fType == *fContext.fFloat2_Type) {
type = "kVec2f_GrSLType";
- } else if (var.fType == *fContext.fVec4_Type) {
+ } else if (var.fType == *fContext.fFloat4_Type) {
type = "kVec4f_GrSLType";
- } else if (var.fType == *fContext.fMat4x4_Type ||
+ } else if (var.fType == *fContext.fFloat4x4_Type ||
var.fType == *fContext.fColorSpaceXform_Type) {
type = "kMat44f_GrSLType";
} else {
@@ -440,11 +448,11 @@ void CPPCodeGenerator::writeSetData(std::vector<const Variable*>& uniforms) {
this->writef(" {\n");
}
const char* name = u->fName.c_str();
- if (u->fType == *fContext.fVec4_Type) {
+ if (u->fType == *fContext.fFloat4_Type) {
this->writef(" const SkRect %sValue = _outer.%s();\n"
" %s.set4fv(%sVar, 1, (float*) &%sValue);\n",
name, name, pdman, HCodeGenerator::FieldName(name).c_str(), name);
- } else if (u->fType == *fContext.fMat4x4_Type) {
+ } else if (u->fType == *fContext.fFloat4x4_Type) {
this->writef(" float %sValue[16];\n"
" _outer.%s().asColMajorf(%sValue);\n"
" %s.setMatrix4f(%sVar, %sValue);\n",
@@ -528,14 +536,14 @@ void CPPCodeGenerator::writeGetKey() {
}
switch (param->fModifiers.fLayout.fKey) {
case Layout::kKey_Key:
- if (param->fType == *fContext.fMat4x4_Type) {
- ABORT("no automatic key handling for mat4\n");
- } else if (param->fType == *fContext.fVec2_Type) {
+ if (param->fType == *fContext.fFloat4x4_Type) {
+ ABORT("no automatic key handling for float4x4\n");
+ } else if (param->fType == *fContext.fFloat2_Type) {
this->writef(" b->add32(%s.fX);\n",
HCodeGenerator::FieldName(name).c_str());
this->writef(" b->add32(%s.fY);\n",
HCodeGenerator::FieldName(name).c_str());
- } else if (param->fType == *fContext.fVec4_Type) {
+ } else if (param->fType == *fContext.fFloat4_Type) {
this->writef(" b->add32(%s.x());\n",
HCodeGenerator::FieldName(name).c_str());
this->writef(" b->add32(%s.y());\n",
diff --git a/src/sksl/SkSLCPPCodeGenerator.h b/src/sksl/SkSLCPPCodeGenerator.h
index 7f60563e51..8b30151c71 100644
--- a/src/sksl/SkSLCPPCodeGenerator.h
+++ b/src/sksl/SkSLCPPCodeGenerator.h
@@ -33,6 +33,8 @@ private:
void writePrecisionModifier() override;
+ void writeType(const Type& type) override;
+
void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrecedence) override;
void writeIndexExpression(const IndexExpression& i) override;
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 0584ff157b..d96515cd88 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -65,37 +65,34 @@ Compiler::Compiler(Flags flags)
fContext.f ## t ## _Type.get())
ADD_TYPE(Void);
ADD_TYPE(Float);
- ADD_TYPE(Vec2);
- ADD_TYPE(Vec3);
- ADD_TYPE(Vec4);
+ ADD_TYPE(Float2);
+ ADD_TYPE(Float3);
+ ADD_TYPE(Float4);
ADD_TYPE(Double);
- ADD_TYPE(DVec2);
- ADD_TYPE(DVec3);
- ADD_TYPE(DVec4);
+ ADD_TYPE(Double2);
+ ADD_TYPE(Double3);
+ ADD_TYPE(Double4);
ADD_TYPE(Int);
- ADD_TYPE(IVec2);
- ADD_TYPE(IVec3);
- ADD_TYPE(IVec4);
+ ADD_TYPE(Int2);
+ ADD_TYPE(Int3);
+ ADD_TYPE(Int4);
ADD_TYPE(UInt);
- ADD_TYPE(UVec2);
- ADD_TYPE(UVec3);
- ADD_TYPE(UVec4);
+ ADD_TYPE(UInt2);
+ ADD_TYPE(UInt3);
+ ADD_TYPE(UInt4);
ADD_TYPE(Bool);
- ADD_TYPE(BVec2);
- ADD_TYPE(BVec3);
- ADD_TYPE(BVec4);
- ADD_TYPE(Mat2x2);
- types->addWithoutOwnership(String("mat2x2"), fContext.fMat2x2_Type.get());
- ADD_TYPE(Mat2x3);
- ADD_TYPE(Mat2x4);
- ADD_TYPE(Mat3x2);
- ADD_TYPE(Mat3x3);
- types->addWithoutOwnership(String("mat3x3"), fContext.fMat3x3_Type.get());
- ADD_TYPE(Mat3x4);
- ADD_TYPE(Mat4x2);
- ADD_TYPE(Mat4x3);
- ADD_TYPE(Mat4x4);
- types->addWithoutOwnership(String("mat4x4"), fContext.fMat4x4_Type.get());
+ ADD_TYPE(Bool2);
+ ADD_TYPE(Bool3);
+ ADD_TYPE(Bool4);
+ ADD_TYPE(Float2x2);
+ ADD_TYPE(Float2x3);
+ ADD_TYPE(Float2x4);
+ ADD_TYPE(Float3x2);
+ ADD_TYPE(Float3x3);
+ ADD_TYPE(Float3x4);
+ ADD_TYPE(Float4x2);
+ ADD_TYPE(Float4x3);
+ ADD_TYPE(Float4x4);
ADD_TYPE(GenType);
ADD_TYPE(GenDType);
ADD_TYPE(GenIType);
@@ -649,48 +646,48 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
if (is_constant(*bin->fLeft, 1)) {
if (bin->fLeft->fType.kind() == Type::kVector_Kind &&
bin->fRight->fType.kind() == Type::kScalar_Kind) {
- // vec4(1) * x -> vec4(x)
+ // float4(1) * x -> float4(x)
vectorize_right(&b, iter, outUpdated, outNeedsRescan);
} else {
// 1 * x -> x
- // 1 * vec4(x) -> vec4(x)
- // vec4(1) * vec4(x) -> vec4(x)
+ // 1 * float4(x) -> float4(x)
+ // float4(1) * float4(x) -> float4(x)
delete_left(&b, iter, outUpdated, outNeedsRescan);
}
}
else if (is_constant(*bin->fLeft, 0)) {
if (bin->fLeft->fType.kind() == Type::kScalar_Kind &&
bin->fRight->fType.kind() == Type::kVector_Kind) {
- // 0 * vec4(x) -> vec4(0)
+ // 0 * float4(x) -> float4(0)
vectorize_left(&b, iter, outUpdated, outNeedsRescan);
} else {
// 0 * x -> 0
- // vec4(0) * x -> vec4(0)
- // vec4(0) * vec4(x) -> vec4(0)
+ // float4(0) * x -> float4(0)
+ // float4(0) * float4(x) -> float4(0)
delete_right(&b, iter, outUpdated, outNeedsRescan);
}
}
else if (is_constant(*bin->fRight, 1)) {
if (bin->fLeft->fType.kind() == Type::kScalar_Kind &&
bin->fRight->fType.kind() == Type::kVector_Kind) {
- // x * vec4(1) -> vec4(x)
+ // x * float4(1) -> float4(x)
vectorize_left(&b, iter, outUpdated, outNeedsRescan);
} else {
// x * 1 -> x
- // vec4(x) * 1 -> vec4(x)
- // vec4(x) * vec4(1) -> vec4(x)
+ // float4(x) * 1 -> float4(x)
+ // float4(x) * float4(1) -> float4(x)
delete_right(&b, iter, outUpdated, outNeedsRescan);
}
}
else if (is_constant(*bin->fRight, 0)) {
if (bin->fLeft->fType.kind() == Type::kVector_Kind &&
bin->fRight->fType.kind() == Type::kScalar_Kind) {
- // vec4(x) * 0 -> vec4(0)
+ // float4(x) * 0 -> float4(0)
vectorize_right(&b, iter, outUpdated, outNeedsRescan);
} else {
// x * 0 -> 0
- // x * vec4(0) -> vec4(0)
- // vec4(x) * vec4(0) -> vec4(0)
+ // x * float4(0) -> float4(0)
+ // float4(x) * float4(0) -> float4(0)
delete_left(&b, iter, outUpdated, outNeedsRescan);
}
}
@@ -699,23 +696,23 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
if (is_constant(*bin->fLeft, 0)) {
if (bin->fLeft->fType.kind() == Type::kVector_Kind &&
bin->fRight->fType.kind() == Type::kScalar_Kind) {
- // vec4(0) + x -> vec4(x)
+ // float4(0) + x -> float4(x)
vectorize_right(&b, iter, outUpdated, outNeedsRescan);
} else {
// 0 + x -> x
- // 0 + vec4(x) -> vec4(x)
- // vec4(0) + vec4(x) -> vec4(x)
+ // 0 + float4(x) -> float4(x)
+ // float4(0) + float4(x) -> float4(x)
delete_left(&b, iter, outUpdated, outNeedsRescan);
}
} else if (is_constant(*bin->fRight, 0)) {
if (bin->fLeft->fType.kind() == Type::kScalar_Kind &&
bin->fRight->fType.kind() == Type::kVector_Kind) {
- // x + vec4(0) -> vec4(x)
+ // x + float4(0) -> float4(x)
vectorize_left(&b, iter, outUpdated, outNeedsRescan);
} else {
// x + 0 -> x
- // vec4(x) + 0 -> vec4(x)
- // vec4(x) + vec4(0) -> vec4(x)
+ // float4(x) + 0 -> float4(x)
+ // float4(x) + float4(0) -> float4(x)
delete_right(&b, iter, outUpdated, outNeedsRescan);
}
}
@@ -724,12 +721,12 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
if (is_constant(*bin->fRight, 0)) {
if (bin->fLeft->fType.kind() == Type::kScalar_Kind &&
bin->fRight->fType.kind() == Type::kVector_Kind) {
- // x - vec4(0) -> vec4(x)
+ // x - float4(0) -> float4(x)
vectorize_left(&b, iter, outUpdated, outNeedsRescan);
} else {
// x - 0 -> x
- // vec4(x) - 0 -> vec4(x)
- // vec4(x) - vec4(0) -> vec4(x)
+ // float4(x) - 0 -> float4(x)
+ // float4(x) - float4(0) -> float4(x)
delete_right(&b, iter, outUpdated, outNeedsRescan);
}
}
@@ -738,23 +735,23 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
if (is_constant(*bin->fRight, 1)) {
if (bin->fLeft->fType.kind() == Type::kScalar_Kind &&
bin->fRight->fType.kind() == Type::kVector_Kind) {
- // x / vec4(1) -> vec4(x)
+ // x / float4(1) -> float4(x)
vectorize_left(&b, iter, outUpdated, outNeedsRescan);
} else {
// x / 1 -> x
- // vec4(x) / 1 -> vec4(x)
- // vec4(x) / vec4(1) -> vec4(x)
+ // float4(x) / 1 -> float4(x)
+ // float4(x) / float4(1) -> float4(x)
delete_right(&b, iter, outUpdated, outNeedsRescan);
}
} else if (is_constant(*bin->fLeft, 0)) {
if (bin->fLeft->fType.kind() == Type::kScalar_Kind &&
bin->fRight->fType.kind() == Type::kVector_Kind) {
- // 0 / vec4(x) -> vec4(0)
+ // 0 / float4(x) -> float4(0)
vectorize_left(&b, iter, outUpdated, outNeedsRescan);
} else {
// 0 / x -> 0
- // vec4(0) / x -> vec4(0)
- // vec4(0) / vec4(x) -> vec4(0)
+ // float4(0) / x -> float4(0)
+ // float4(0) / float4(x) -> float4(0)
delete_right(&b, iter, outUpdated, outNeedsRescan);
}
}
diff --git a/src/sksl/SkSLContext.h b/src/sksl/SkSLContext.h
index 1155af4817..2de584fab2 100644
--- a/src/sksl/SkSLContext.h
+++ b/src/sksl/SkSLContext.h
@@ -22,44 +22,44 @@ public:
: fInvalid_Type(new Type(String("<INVALID>")))
, fVoid_Type(new Type(String("void")))
, fDouble_Type(new Type(String("double"), true))
- , fDVec2_Type(new Type(String("dvec2"), *fDouble_Type, 2))
- , fDVec3_Type(new Type(String("dvec3"), *fDouble_Type, 3))
- , fDVec4_Type(new Type(String("dvec4"), *fDouble_Type, 4))
+ , fDouble2_Type(new Type(String("double2"), *fDouble_Type, 2))
+ , fDouble3_Type(new Type(String("double3"), *fDouble_Type, 3))
+ , fDouble4_Type(new Type(String("double4"), *fDouble_Type, 4))
, fFloat_Type(new Type(String("float"), true, { fDouble_Type.get() }))
- , fVec2_Type(new Type(String("vec2"), *fFloat_Type, 2))
- , fVec3_Type(new Type(String("vec3"), *fFloat_Type, 3))
- , fVec4_Type(new Type(String("vec4"), *fFloat_Type, 4))
+ , fFloat2_Type(new Type(String("float2"), *fFloat_Type, 2))
+ , fFloat3_Type(new Type(String("float3"), *fFloat_Type, 3))
+ , fFloat4_Type(new Type(String("float4"), *fFloat_Type, 4))
, fUInt_Type(new Type(String("uint"), true, { fFloat_Type.get(), fDouble_Type.get() }))
- , fUVec2_Type(new Type(String("uvec2"), *fUInt_Type, 2))
- , fUVec3_Type(new Type(String("uvec3"), *fUInt_Type, 3))
- , fUVec4_Type(new Type(String("uvec4"), *fUInt_Type, 4))
+ , fUInt2_Type(new Type(String("uint2"), *fUInt_Type, 2))
+ , fUInt3_Type(new Type(String("uint3"), *fUInt_Type, 3))
+ , fUInt4_Type(new Type(String("uint4"), *fUInt_Type, 4))
, fInt_Type(new Type(String("int"), true, { fUInt_Type.get(), fFloat_Type.get(),
fDouble_Type.get() }))
- , fIVec2_Type(new Type(String("ivec2"), *fInt_Type, 2))
- , fIVec3_Type(new Type(String("ivec3"), *fInt_Type, 3))
- , fIVec4_Type(new Type(String("ivec4"), *fInt_Type, 4))
+ , fInt2_Type(new Type(String("int2"), *fInt_Type, 2))
+ , fInt3_Type(new Type(String("int3"), *fInt_Type, 3))
+ , fInt4_Type(new Type(String("int4"), *fInt_Type, 4))
, fBool_Type(new Type(String("bool"), false))
- , fBVec2_Type(new Type(String("bvec2"), *fBool_Type, 2))
- , fBVec3_Type(new Type(String("bvec3"), *fBool_Type, 3))
- , fBVec4_Type(new Type(String("bvec4"), *fBool_Type, 4))
- , fMat2x2_Type(new Type(String("mat2"), *fFloat_Type, 2, 2))
- , fMat2x3_Type(new Type(String("mat2x3"), *fFloat_Type, 2, 3))
- , fMat2x4_Type(new Type(String("mat2x4"), *fFloat_Type, 2, 4))
- , fMat3x2_Type(new Type(String("mat3x2"), *fFloat_Type, 3, 2))
- , fMat3x3_Type(new Type(String("mat3"), *fFloat_Type, 3, 3))
- , fMat3x4_Type(new Type(String("mat3x4"), *fFloat_Type, 3, 4))
- , fMat4x2_Type(new Type(String("mat4x2"), *fFloat_Type, 4, 2))
- , fMat4x3_Type(new Type(String("mat4x3"), *fFloat_Type, 4, 3))
- , fMat4x4_Type(new Type(String("mat4"), *fFloat_Type, 4, 4))
- , fDMat2x2_Type(new Type(String("dmat2"), *fFloat_Type, 2, 2))
- , fDMat2x3_Type(new Type(String("dmat2x3"), *fFloat_Type, 2, 3))
- , fDMat2x4_Type(new Type(String("dmat2x4"), *fFloat_Type, 2, 4))
- , fDMat3x2_Type(new Type(String("dmat3x2"), *fFloat_Type, 3, 2))
- , fDMat3x3_Type(new Type(String("dmat3"), *fFloat_Type, 3, 3))
- , fDMat3x4_Type(new Type(String("dmat3x4"), *fFloat_Type, 3, 4))
- , fDMat4x2_Type(new Type(String("dmat4x2"), *fFloat_Type, 4, 2))
- , fDMat4x3_Type(new Type(String("dmat4x3"), *fFloat_Type, 4, 3))
- , fDMat4x4_Type(new Type(String("dmat4"), *fFloat_Type, 4, 4))
+ , fBool2_Type(new Type(String("bool2"), *fBool_Type, 2))
+ , fBool3_Type(new Type(String("bool3"), *fBool_Type, 3))
+ , fBool4_Type(new Type(String("bool4"), *fBool_Type, 4))
+ , fFloat2x2_Type(new Type(String("float2x2"), *fFloat_Type, 2, 2))
+ , fFloat2x3_Type(new Type(String("float2x3"), *fFloat_Type, 2, 3))
+ , fFloat2x4_Type(new Type(String("float2x4"), *fFloat_Type, 2, 4))
+ , fFloat3x2_Type(new Type(String("float3x2"), *fFloat_Type, 3, 2))
+ , fFloat3x3_Type(new Type(String("float3x3"), *fFloat_Type, 3, 3))
+ , fFloat3x4_Type(new Type(String("float3x4"), *fFloat_Type, 3, 4))
+ , fFloat4x2_Type(new Type(String("float4x2"), *fFloat_Type, 4, 2))
+ , fFloat4x3_Type(new Type(String("float4x3"), *fFloat_Type, 4, 3))
+ , fFloat4x4_Type(new Type(String("float4x4"), *fFloat_Type, 4, 4))
+ , fDouble2x2_Type(new Type(String("double2x2"), *fFloat_Type, 2, 2))
+ , fDouble2x3_Type(new Type(String("double2x3"), *fFloat_Type, 2, 3))
+ , fDouble2x4_Type(new Type(String("double2x4"), *fFloat_Type, 2, 4))
+ , fDouble3x2_Type(new Type(String("double3x2"), *fFloat_Type, 3, 2))
+ , fDouble3x3_Type(new Type(String("double3x3"), *fFloat_Type, 3, 3))
+ , fDouble3x4_Type(new Type(String("double3x4"), *fFloat_Type, 3, 4))
+ , fDouble4x2_Type(new Type(String("double4x2"), *fFloat_Type, 4, 2))
+ , fDouble4x3_Type(new Type(String("double4x3"), *fFloat_Type, 4, 3))
+ , fDouble4x4_Type(new Type(String("double4x4"), *fFloat_Type, 4, 4))
, fSampler1D_Type(new Type(String("sampler1D"), SpvDim1D, false, false, false, true))
, fSampler2D_Type(new Type(String("sampler2D"), SpvDim2D, false, false, false, true))
, fSampler3D_Type(new Type(String("sampler3D"), SpvDim3D, false, false, false, true))
@@ -116,39 +116,39 @@ public:
static_type(*fSampler2DArrayShadow_Type)))
, fGSamplerCubeArrayShadow_Type(new Type(String("$gsamplerCubeArrayShadow"),
static_type(*fSamplerCubeArrayShadow_Type)))
- , fGenType_Type(new Type(String("$genType"), { fFloat_Type.get(), fVec2_Type.get(),
- fVec3_Type.get(), fVec4_Type.get() }))
- , fGenDType_Type(new Type(String("$genDType"), { fDouble_Type.get(), fDVec2_Type.get(),
- fDVec3_Type.get(), fDVec4_Type.get() }))
- , fGenIType_Type(new Type(String("$genIType"), { fInt_Type.get(), fIVec2_Type.get(),
- fIVec3_Type.get(), fIVec4_Type.get() }))
- , fGenUType_Type(new Type(String("$genUType"), { fUInt_Type.get(), fUVec2_Type.get(),
- fUVec3_Type.get(), fUVec4_Type.get() }))
- , fGenBType_Type(new Type(String("$genBType"), { fBool_Type.get(), fBVec2_Type.get(),
- fBVec3_Type.get(), fBVec4_Type.get() }))
- , fMat_Type(new Type(String("$mat"), { fMat2x2_Type.get(), fMat2x3_Type.get(),
- fMat2x4_Type.get(), fMat3x2_Type.get(),
- fMat3x3_Type.get(), fMat3x4_Type.get(),
- fMat4x2_Type.get(), fMat4x3_Type.get(),
- fMat4x4_Type.get(), fDMat2x2_Type.get(),
- fDMat2x3_Type.get(), fDMat2x4_Type.get(),
- fDMat3x2_Type.get(), fDMat3x3_Type.get(),
- fDMat3x4_Type.get(), fDMat4x2_Type.get(),
- fDMat4x3_Type.get(), fDMat4x4_Type.get() }))
- , fVec_Type(new Type(String("$vec"), { fInvalid_Type.get(), fVec2_Type.get(),
- fVec3_Type.get(), fVec4_Type.get() }))
+ , fGenType_Type(new Type(String("$genType"), { fFloat_Type.get(), fFloat2_Type.get(),
+ fFloat3_Type.get(), fFloat4_Type.get() }))
+ , fGenDType_Type(new Type(String("$genDType"), { fDouble_Type.get(), fDouble2_Type.get(),
+ fDouble3_Type.get(), fDouble4_Type.get() }))
+ , fGenIType_Type(new Type(String("$genIType"), { fInt_Type.get(), fInt2_Type.get(),
+ fInt3_Type.get(), fInt4_Type.get() }))
+ , fGenUType_Type(new Type(String("$genUType"), { fUInt_Type.get(), fUInt2_Type.get(),
+ fUInt3_Type.get(), fUInt4_Type.get() }))
+ , fGenBType_Type(new Type(String("$genBType"), { fBool_Type.get(), fBool2_Type.get(),
+ fBool3_Type.get(), fBool4_Type.get() }))
+ , fMat_Type(new Type(String("$mat"), { fFloat2x2_Type.get(), fFloat2x3_Type.get(),
+ fFloat2x4_Type.get(), fFloat3x2_Type.get(),
+ fFloat3x3_Type.get(), fFloat3x4_Type.get(),
+ fFloat4x2_Type.get(), fFloat4x3_Type.get(),
+ fFloat4x4_Type.get(), fDouble2x2_Type.get(),
+ fDouble2x3_Type.get(), fDouble2x4_Type.get(),
+ fDouble3x2_Type.get(), fDouble3x3_Type.get(),
+ fDouble3x4_Type.get(), fDouble4x2_Type.get(),
+ fDouble4x3_Type.get(), fDouble4x4_Type.get() }))
+ , fVec_Type(new Type(String("$vec"), { fInvalid_Type.get(), fFloat2_Type.get(),
+ fFloat3_Type.get(), fFloat4_Type.get() }))
, fGVec_Type(new Type(String("$gvec")))
- , fGVec2_Type(new Type(String("$gvec2")))
- , fGVec3_Type(new Type(String("$gvec3")))
- , fGVec4_Type(new Type(String("$gvec4"), static_type(*fVec4_Type)))
- , fDVec_Type(new Type(String("$dvec"), { fInvalid_Type.get(), fDVec2_Type.get(),
- fDVec3_Type.get(), fDVec4_Type.get() }))
- , fIVec_Type(new Type(String("$ivec"), { fInvalid_Type.get(), fIVec2_Type.get(),
- fIVec3_Type.get(), fIVec4_Type.get() }))
- , fUVec_Type(new Type(String("$uvec"), { fInvalid_Type.get(), fUVec2_Type.get(),
- fUVec3_Type.get(), fUVec4_Type.get() }))
- , fBVec_Type(new Type(String("$bvec"), { fInvalid_Type.get(), fBVec2_Type.get(),
- fBVec3_Type.get(), fBVec4_Type.get() }))
+ , fGVec2_Type(new Type(String("$gfloat2")))
+ , fGVec3_Type(new Type(String("$gfloat3")))
+ , fGVec4_Type(new Type(String("$gfloat4"), static_type(*fFloat4_Type)))
+ , fDVec_Type(new Type(String("$dvec"), { fInvalid_Type.get(), fDouble2_Type.get(),
+ fDouble3_Type.get(), fDouble4_Type.get() }))
+ , fIVec_Type(new Type(String("$ivec"), { fInvalid_Type.get(), fInt2_Type.get(),
+ fInt3_Type.get(), fInt4_Type.get() }))
+ , fUVec_Type(new Type(String("$uvec"), { fInvalid_Type.get(), fUInt2_Type.get(),
+ fUInt3_Type.get(), fUInt4_Type.get() }))
+ , fBVec_Type(new Type(String("$bvec"), { fInvalid_Type.get(), fBool2_Type.get(),
+ fBool3_Type.get(), fBool4_Type.get() }))
, fSkCaps_Type(new Type(String("$sk_Caps")))
, fSkArgs_Type(new Type(String("$sk_Args")))
, fColorSpaceXform_Type(new Type(String("colorSpaceXform"), *fFloat_Type, 4, 4))
@@ -162,49 +162,49 @@ public:
const std::unique_ptr<Type> fVoid_Type;
const std::unique_ptr<Type> fDouble_Type;
- const std::unique_ptr<Type> fDVec2_Type;
- const std::unique_ptr<Type> fDVec3_Type;
- const std::unique_ptr<Type> fDVec4_Type;
+ const std::unique_ptr<Type> fDouble2_Type;
+ const std::unique_ptr<Type> fDouble3_Type;
+ const std::unique_ptr<Type> fDouble4_Type;
const std::unique_ptr<Type> fFloat_Type;
- const std::unique_ptr<Type> fVec2_Type;
- const std::unique_ptr<Type> fVec3_Type;
- const std::unique_ptr<Type> fVec4_Type;
+ const std::unique_ptr<Type> fFloat2_Type;
+ const std::unique_ptr<Type> fFloat3_Type;
+ const std::unique_ptr<Type> fFloat4_Type;
const std::unique_ptr<Type> fUInt_Type;
- const std::unique_ptr<Type> fUVec2_Type;
- const std::unique_ptr<Type> fUVec3_Type;
- const std::unique_ptr<Type> fUVec4_Type;
+ const std::unique_ptr<Type> fUInt2_Type;
+ const std::unique_ptr<Type> fUInt3_Type;
+ const std::unique_ptr<Type> fUInt4_Type;
const std::unique_ptr<Type> fInt_Type;
- const std::unique_ptr<Type> fIVec2_Type;
- const std::unique_ptr<Type> fIVec3_Type;
- const std::unique_ptr<Type> fIVec4_Type;
+ const std::unique_ptr<Type> fInt2_Type;
+ const std::unique_ptr<Type> fInt3_Type;
+ const std::unique_ptr<Type> fInt4_Type;
const std::unique_ptr<Type> fBool_Type;
- const std::unique_ptr<Type> fBVec2_Type;
- const std::unique_ptr<Type> fBVec3_Type;
- const std::unique_ptr<Type> fBVec4_Type;
-
- const std::unique_ptr<Type> fMat2x2_Type;
- const std::unique_ptr<Type> fMat2x3_Type;
- const std::unique_ptr<Type> fMat2x4_Type;
- const std::unique_ptr<Type> fMat3x2_Type;
- const std::unique_ptr<Type> fMat3x3_Type;
- const std::unique_ptr<Type> fMat3x4_Type;
- const std::unique_ptr<Type> fMat4x2_Type;
- const std::unique_ptr<Type> fMat4x3_Type;
- const std::unique_ptr<Type> fMat4x4_Type;
-
- const std::unique_ptr<Type> fDMat2x2_Type;
- const std::unique_ptr<Type> fDMat2x3_Type;
- const std::unique_ptr<Type> fDMat2x4_Type;
- const std::unique_ptr<Type> fDMat3x2_Type;
- const std::unique_ptr<Type> fDMat3x3_Type;
- const std::unique_ptr<Type> fDMat3x4_Type;
- const std::unique_ptr<Type> fDMat4x2_Type;
- const std::unique_ptr<Type> fDMat4x3_Type;
- const std::unique_ptr<Type> fDMat4x4_Type;
+ const std::unique_ptr<Type> fBool2_Type;
+ const std::unique_ptr<Type> fBool3_Type;
+ const std::unique_ptr<Type> fBool4_Type;
+
+ const std::unique_ptr<Type> fFloat2x2_Type;
+ const std::unique_ptr<Type> fFloat2x3_Type;
+ const std::unique_ptr<Type> fFloat2x4_Type;
+ const std::unique_ptr<Type> fFloat3x2_Type;
+ const std::unique_ptr<Type> fFloat3x3_Type;
+ const std::unique_ptr<Type> fFloat3x4_Type;
+ const std::unique_ptr<Type> fFloat4x2_Type;
+ const std::unique_ptr<Type> fFloat4x3_Type;
+ const std::unique_ptr<Type> fFloat4x4_Type;
+
+ const std::unique_ptr<Type> fDouble2x2_Type;
+ const std::unique_ptr<Type> fDouble2x3_Type;
+ const std::unique_ptr<Type> fDouble2x4_Type;
+ const std::unique_ptr<Type> fDouble3x2_Type;
+ const std::unique_ptr<Type> fDouble3x3_Type;
+ const std::unique_ptr<Type> fDouble3x4_Type;
+ const std::unique_ptr<Type> fDouble4x2_Type;
+ const std::unique_ptr<Type> fDouble4x3_Type;
+ const std::unique_ptr<Type> fDouble4x4_Type;
const std::unique_ptr<Type> fSampler1D_Type;
const std::unique_ptr<Type> fSampler2D_Type;
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 4d3d3e3274..330f14517d 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -75,7 +75,54 @@ void GLSLCodeGenerator::writeType(const Type& type) {
fIndentation--;
this->write("}");
} else {
- this->write(type.name());
+ switch (type.kind()) {
+ case Type::kVector_Kind: {
+ Type component = type.componentType();
+ if (component == *fContext.fFloat_Type) {
+ this->write("vec");
+ }
+ else if (component == *fContext.fDouble_Type) {
+ this->write("dvec");
+ }
+ else if (component == *fContext.fInt_Type) {
+ this->write("ivec");
+ }
+ else if (component == *fContext.fUInt_Type) {
+ this->write("uvec");
+ }
+ else if (component == *fContext.fBool_Type) {
+ this->write("bvec");
+ }
+ this->write(to_string(type.columns()));
+ break;
+ }
+ case Type::kMatrix_Kind: {
+ Type component = type.componentType();
+ if (component == *fContext.fFloat_Type) {
+ this->write("mat");
+ }
+ else if (component == *fContext.fDouble_Type) {
+ this->write("dmat");
+ }
+ this->write(to_string(type.columns()));
+ if (type.columns() != type.rows()) {
+ this->write("x");
+ this->write(to_string(type.rows()));
+ }
+ break;
+ }
+ case Type::kArray_Kind: {
+ this->writeType(type.componentType());
+ this->write("[");
+ if (type.columns() != -1) {
+ this->write(to_string(type.columns()));
+ }
+ this->write("]");
+ break;
+ }
+ default:
+ this->write(type.name());
+ }
}
}
@@ -196,25 +243,25 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (c.fArguments[1]->fType == *fContext.fFloat_Type) {
proj = false;
} else {
- ASSERT(c.fArguments[1]->fType == *fContext.fVec2_Type);
+ ASSERT(c.fArguments[1]->fType == *fContext.fFloat2_Type);
proj = true;
}
break;
case SpvDim2D:
dim = "2D";
- if (c.fArguments[1]->fType == *fContext.fVec2_Type) {
+ if (c.fArguments[1]->fType == *fContext.fFloat2_Type) {
proj = false;
} else {
- ASSERT(c.fArguments[1]->fType == *fContext.fVec3_Type);
+ ASSERT(c.fArguments[1]->fType == *fContext.fFloat3_Type);
proj = true;
}
break;
case SpvDim3D:
dim = "3D";
- if (c.fArguments[1]->fType == *fContext.fVec3_Type) {
+ if (c.fArguments[1]->fType == *fContext.fFloat3_Type) {
proj = false;
} else {
- ASSERT(c.fArguments[1]->fType == *fContext.fVec4_Type);
+ ASSERT(c.fArguments[1]->fType == *fContext.fFloat4_Type);
proj = true;
}
break;
@@ -259,7 +306,8 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
}
void GLSLCodeGenerator::writeConstructor(const Constructor& c) {
- this->write(c.fType.name() + "(");
+ this->writeType(c.fType);
+ this->write("(");
const char* separator = "";
for (const auto& arg : c.fArguments) {
this->write(separator);
@@ -292,7 +340,7 @@ void GLSLCodeGenerator::writeFragCoord() {
// The Adreno compiler seems to be very touchy about access to "gl_FragCoord".
// Accessing glFragCoord.zw can cause a program to fail to link. Additionally,
// depending on the surrounding code, accessing .xy with a uniform involved can
- // do the same thing. Copying gl_FragCoord.xy into a temp vec2 beforehand
+ // do the same thing. Copying gl_FragCoord.xy into a temp float2beforehand
// (and only accessing .xy) seems to "fix" things.
const char* precision = fProgram.fSettings.fCaps->usesPrecisionModifiers() ? "highp "
: "";
diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h
index 6fe25d3a69..115d89ab28 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.h
+++ b/src/sksl/SkSLGLSLCodeGenerator.h
@@ -96,7 +96,7 @@ protected:
virtual void writePrecisionModifier();
- void writeType(const Type& type);
+ virtual void writeType(const Type& type);
void writeExtension(const Extension& ext);
diff --git a/src/sksl/SkSLHCodeGenerator.cpp b/src/sksl/SkSLHCodeGenerator.cpp
index 13f6cd3c75..65dbf78025 100644
--- a/src/sksl/SkSLHCodeGenerator.cpp
+++ b/src/sksl/SkSLHCodeGenerator.cpp
@@ -23,13 +23,13 @@ HCodeGenerator::HCodeGenerator(const Program* program, ErrorReporter* errors, St
, fSectionAndParameterHelper(*program, *errors) {}
String HCodeGenerator::ParameterType(const Type& type) {
- if (type.fName == "vec2") {
+ if (type.fName == "float2") {
return "SkPoint";
- } else if (type.fName == "ivec4") {
+ } else if (type.fName == "int4") {
return "SkIRect";
- } else if (type.fName == "vec4") {
+ } else if (type.fName == "float4") {
return "SkRect";
- } else if (type.fName == "mat4") {
+ } else if (type.fName == "float4x4") {
return "SkMatrix44";
} else if (type.kind() == Type::kSampler_Kind) {
return "sk_sp<GrTextureProxy>";
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 22e2642310..3604cd91d8 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -923,7 +923,7 @@ std::unique_ptr<Expression> IRGenerator::coerce(std::unique_ptr<Expression> expr
ASSERT(ctor);
return this->call(Position(), std::move(ctor), std::move(args));
}
- if (type == *fContext.fColorSpaceXform_Type && expr->fType == *fContext.fMat4x4_Type) {
+ if (type == *fContext.fColorSpaceXform_Type && expr->fType == *fContext.fFloat4x4_Type) {
return expr;
}
std::vector<std::unique_ptr<Expression>> args;
@@ -1290,10 +1290,10 @@ std::unique_ptr<Expression> IRGenerator::convertTernaryExpression(
}
// scales the texture coordinates by the texture size for sampling rectangle textures.
-// For vec2 coordinates, implements the transformation:
+// For float2coordinates, implements the transformation:
// texture(sampler, coord) -> texture(sampler, textureSize(sampler) * coord)
-// For vec3 coordinates, implements the transformation:
-// texture(sampler, coord) -> texture(sampler, vec3(textureSize(sampler), 1.0) * coord))
+// For float3coordinates, implements the transformation:
+// texture(sampler, coord) -> texture(sampler, float3textureSize(sampler), 1.0) * coord))
void IRGenerator::fixRectSampling(std::vector<std::unique_ptr<Expression>>& arguments) {
ASSERT(arguments.size() == 2);
ASSERT(arguments[0]->fType == *fContext.fSampler2DRect_Type);
@@ -1304,17 +1304,17 @@ void IRGenerator::fixRectSampling(std::vector<std::unique_ptr<Expression>>& argu
const FunctionDeclaration& textureSize = (FunctionDeclaration&) *textureSizeSymbol;
std::vector<std::unique_ptr<Expression>> sizeArguments;
sizeArguments.emplace_back(new VariableReference(Position(), sampler));
- std::unique_ptr<Expression> vec2Size = call(Position(), textureSize, std::move(sizeArguments));
+ std::unique_ptr<Expression> float2ize = call(Position(), textureSize, std::move(sizeArguments));
const Type& type = arguments[1]->fType;
std::unique_ptr<Expression> scale;
- if (type == *fContext.fVec2_Type) {
- scale = std::move(vec2Size);
+ if (type == *fContext.fFloat2_Type) {
+ scale = std::move(float2ize);
} else {
- ASSERT(type == *fContext.fVec3_Type);
- std::vector<std::unique_ptr<Expression>> vec3Arguments;
- vec3Arguments.push_back(std::move(vec2Size));
- vec3Arguments.emplace_back(new FloatLiteral(fContext, Position(), 1.0));
- scale.reset(new Constructor(Position(), *fContext.fVec3_Type, std::move(vec3Arguments)));
+ ASSERT(type == *fContext.fFloat3_Type);
+ std::vector<std::unique_ptr<Expression>> float3rguments;
+ float3rguments.push_back(std::move(float2ize));
+ float3rguments.emplace_back(new FloatLiteral(fContext, Position(), 1.0));
+ scale.reset(new Constructor(Position(), *fContext.fFloat3_Type, std::move(float3rguments)));
}
arguments[1].reset(new BinaryExpression(Position(), std::move(scale), Token::STAR,
std::move(arguments[1]), type));
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 0e550b149e..1f8f224399 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -1333,7 +1333,7 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
std::vector<std::unique_ptr<Expression>> args;
args.emplace_back(new FloatLiteral(fContext, Position(), 0.0));
args.emplace_back(new FloatLiteral(fContext, Position(), 0.0));
- Constructor ctor(Position(), *fContext.fVec2_Type, std::move(args));
+ Constructor ctor(Position(), *fContext.fFloat2_Type, std::move(args));
SpvId coords = this->writeConstantVector(ctor);
if (1 == c.fArguments.size()) {
this->writeInstruction(SpvOpImageRead,
@@ -1376,24 +1376,24 @@ SpvId SPIRVCodeGenerator::writeSpecialIntrinsic(const FunctionCall& c, SpecialIn
SpvOp_ op = SpvOpImageSampleImplicitLod;
switch (c.fArguments[0]->fType.dimensions()) {
case SpvDim1D:
- if (c.fArguments[1]->fType == *fContext.fVec2_Type) {
+ if (c.fArguments[1]->fType == *fContext.fFloat2_Type) {
op = SpvOpImageSampleProjImplicitLod;
} else {
ASSERT(c.fArguments[1]->fType == *fContext.fFloat_Type);
}
break;
case SpvDim2D:
- if (c.fArguments[1]->fType == *fContext.fVec3_Type) {
+ if (c.fArguments[1]->fType == *fContext.fFloat3_Type) {
op = SpvOpImageSampleProjImplicitLod;
} else {
- ASSERT(c.fArguments[1]->fType == *fContext.fVec2_Type);
+ ASSERT(c.fArguments[1]->fType == *fContext.fFloat2_Type);
}
break;
case SpvDim3D:
- if (c.fArguments[1]->fType == *fContext.fVec4_Type) {
+ if (c.fArguments[1]->fType == *fContext.fFloat4_Type) {
op = SpvOpImageSampleProjImplicitLod;
} else {
- ASSERT(c.fArguments[1]->fType == *fContext.fVec3_Type);
+ ASSERT(c.fArguments[1]->fType == *fContext.fFloat3_Type);
}
break;
case SpvDimCube: // fall through
@@ -1935,8 +1935,8 @@ public:
// a virtual vector out of the concatenation of the left and right vectors, and then
// select components from this virtual vector to make the result vector. For
// instance, given:
- // vec3 L = ...;
- // vec3 R = ...;
+ // float3L = ...;
+ // float3R = ...;
// L.xz = R.xy;
// we end up with the virtual vector (L.x, L.y, L.z, R.x, R.y, R.z). Then we want
// our result vector to look like (R.x, L.y, R.y), so we need to select indices
@@ -2083,7 +2083,7 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
fRTHeightFieldIndex = 0;
}
ASSERT(fRTHeightFieldIndex != (SpvId) -1);
- // write vec4(gl_FragCoord.x, u_skRTHeight - gl_FragCoord.y, 0.0, 1.0)
+ // write float4(gl_FragCoord.x, u_skRTHeight - gl_FragCoord.y, 0.0, 1.0)
SpvId xId = this->nextId();
this->writeInstruction(SpvOpCompositeExtract, this->getType(*fContext.fFloat_Type), xId,
result, 0, out);
@@ -2110,7 +2110,7 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
SpvId oneId = writeFloatLiteral(one);
SpvId flipped = this->nextId();
this->writeOpCode(SpvOpCompositeConstruct, 7, out);
- this->writeWord(this->getType(*fContext.fVec4_Type), out);
+ this->writeWord(this->getType(*fContext.fFloat4_Type), out);
this->writeWord(flipped, out);
this->writeWord(xId, out);
this->writeWord(flippedYId, out);
@@ -2266,7 +2266,7 @@ SpvId SPIRVCodeGenerator::writeBinaryExpression(const BinaryExpression& b, Outpu
}
// component type we are operating on: float, int, uint
const Type* operandType;
- // IR allows mismatched types in expressions (e.g. vec2 * float), but they need special handling
+ // IR allows mismatched types in expressions (e.g. float2* float), but they need special handling
// in SPIR-V
if (b.fLeft->fType != b.fRight->fType) {
if (b.fLeft->fType.kind() == Type::kVector_Kind &&
diff --git a/src/sksl/ast/SkSLASTInterfaceBlock.h b/src/sksl/ast/SkSLASTInterfaceBlock.h
index e727ae9aad..f111f73e18 100644
--- a/src/sksl/ast/SkSLASTInterfaceBlock.h
+++ b/src/sksl/ast/SkSLASTInterfaceBlock.h
@@ -17,7 +17,7 @@ namespace SkSL {
* An interface block, as in:
*
* out gl_PerVertex {
- * layout(builtin=0) vec4 gl_Position;
+ * layout(builtin=0) float4 gl_Position;
* layout(builtin=1) float gl_PointSize;
* };
*/
diff --git a/src/sksl/ir/SkSLConstructor.h b/src/sksl/ir/SkSLConstructor.h
index 05f409649a..beed0f702d 100644
--- a/src/sksl/ir/SkSLConstructor.h
+++ b/src/sksl/ir/SkSLConstructor.h
@@ -16,7 +16,7 @@
namespace SkSL {
/**
- * Represents the construction of a compound type, such as "vec2(x, y)".
+ * Represents the construction of a compound type, such as "float2x, y)".
*
* Vector constructors will always consist of either exactly 1 scalar, or a collection of vectors
* and scalars totalling exactly the right number of scalar components.
diff --git a/src/sksl/ir/SkSLIndexExpression.h b/src/sksl/ir/SkSLIndexExpression.h
index 49633b6719..c305365049 100644
--- a/src/sksl/ir/SkSLIndexExpression.h
+++ b/src/sksl/ir/SkSLIndexExpression.h
@@ -21,17 +21,17 @@ static const Type& index_type(const Context& context, const Type& type) {
if (type.kind() == Type::kMatrix_Kind) {
if (type.componentType() == *context.fFloat_Type) {
switch (type.rows()) {
- case 2: return *context.fVec2_Type;
- case 3: return *context.fVec3_Type;
- case 4: return *context.fVec4_Type;
+ case 2: return *context.fFloat2_Type;
+ case 3: return *context.fFloat3_Type;
+ case 4: return *context.fFloat4_Type;
default: ASSERT(false);
}
} else {
ASSERT(type.componentType() == *context.fDouble_Type);
switch (type.rows()) {
- case 2: return *context.fDVec2_Type;
- case 3: return *context.fDVec3_Type;
- case 4: return *context.fDVec4_Type;
+ case 2: return *context.fDouble2_Type;
+ case 3: return *context.fDouble3_Type;
+ case 4: return *context.fDouble4_Type;
default: ASSERT(false);
}
}
diff --git a/src/sksl/ir/SkSLInterfaceBlock.h b/src/sksl/ir/SkSLInterfaceBlock.h
index fc6ccecc8d..a28a6a1b54 100644
--- a/src/sksl/ir/SkSLInterfaceBlock.h
+++ b/src/sksl/ir/SkSLInterfaceBlock.h
@@ -18,7 +18,7 @@ namespace SkSL {
* An interface block, as in:
*
* out gl_PerVertex {
- * layout(builtin=0) vec4 gl_Position;
+ * layout(builtin=0) float4 gl_Position;
* layout(builtin=1) float gl_PointSize;
* };
*
diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h
index 442e92f348..9d7ca37bdc 100644
--- a/src/sksl/ir/SkSLSwizzle.h
+++ b/src/sksl/ir/SkSLSwizzle.h
@@ -18,8 +18,8 @@ namespace SkSL {
/**
* Given a type and a swizzle component count, returns the type that will result from swizzling. For
- * instance, swizzling a vec3 with two components will result in a vec2. It is possible to swizzle
- * with more components than the source vector, as in 'vec2(1).xxxx'.
+ * instance, swizzling a float3with two components will result in a float2 It is possible to swizzle
+ * with more components than the source vector, as in 'float21).xxxx'.
*/
static const Type& get_type(const Context& context, Expression& value, size_t count) {
const Type& base = value.fType.componentType();
@@ -28,40 +28,40 @@ static const Type& get_type(const Context& context, Expression& value, size_t co
}
if (base == *context.fFloat_Type) {
switch (count) {
- case 2: return *context.fVec2_Type;
- case 3: return *context.fVec3_Type;
- case 4: return *context.fVec4_Type;
+ case 2: return *context.fFloat2_Type;
+ case 3: return *context.fFloat3_Type;
+ case 4: return *context.fFloat4_Type;
}
} else if (base == *context.fDouble_Type) {
switch (count) {
- case 2: return *context.fDVec2_Type;
- case 3: return *context.fDVec3_Type;
- case 4: return *context.fDVec4_Type;
+ case 2: return *context.fDouble2_Type;
+ case 3: return *context.fDouble3_Type;
+ case 4: return *context.fDouble4_Type;
}
} else if (base == *context.fInt_Type) {
switch (count) {
- case 2: return *context.fIVec2_Type;
- case 3: return *context.fIVec3_Type;
- case 4: return *context.fIVec4_Type;
+ case 2: return *context.fInt2_Type;
+ case 3: return *context.fInt3_Type;
+ case 4: return *context.fInt4_Type;
}
} else if (base == *context.fUInt_Type) {
switch (count) {
- case 2: return *context.fUVec2_Type;
- case 3: return *context.fUVec3_Type;
- case 4: return *context.fUVec4_Type;
+ case 2: return *context.fUInt2_Type;
+ case 3: return *context.fUInt3_Type;
+ case 4: return *context.fUInt4_Type;
}
} else if (base == *context.fBool_Type) {
switch (count) {
- case 2: return *context.fBVec2_Type;
- case 3: return *context.fBVec3_Type;
- case 4: return *context.fBVec4_Type;
+ case 2: return *context.fBool2_Type;
+ case 3: return *context.fBool3_Type;
+ case 4: return *context.fBool4_Type;
}
}
ABORT("cannot swizzle %s\n", value.description().c_str());
}
/**
- * Represents a vector swizzle operation such as 'vec2(1, 2, 3).zyx'.
+ * Represents a vector swizzle operation such as 'float21, 2, 3).zyx'.
*/
struct Swizzle : public Expression {
Swizzle(const Context& context, std::unique_ptr<Expression> base, std::vector<int> components)
@@ -74,7 +74,7 @@ struct Swizzle : public Expression {
std::unique_ptr<Expression> constantPropagate(const IRGenerator& irGenerator,
const DefinitionMap& definitions) override {
if (fBase->fKind == Expression::kConstructor_Kind && fBase->isConstant()) {
- // we're swizzling a constant vector, e.g. vec4(1).x. Simplify it.
+ // we're swizzling a constant vector, e.g. float4(1).x. Simplify it.
ASSERT(fBase->fKind == Expression::kConstructor_Kind);
if (fType == *irGenerator.fContext.fInt_Type) {
ASSERT(fComponents.size() == 1);
diff --git a/src/sksl/ir/SkSLType.cpp b/src/sksl/ir/SkSLType.cpp
index 7516377fbc..60d40cd867 100644
--- a/src/sksl/ir/SkSLType.cpp
+++ b/src/sksl/ir/SkSLType.cpp
@@ -46,30 +46,30 @@ const Type& Type::toCompound(const Context& context, int columns, int rows) cons
switch (rows) {
case 1:
switch (columns) {
- case 2: return *context.fVec2_Type;
- case 3: return *context.fVec3_Type;
- case 4: return *context.fVec4_Type;
+ case 2: return *context.fFloat2_Type;
+ case 3: return *context.fFloat3_Type;
+ case 4: return *context.fFloat4_Type;
default: ABORT("unsupported vector column count (%d)", columns);
}
case 2:
switch (columns) {
- case 2: return *context.fMat2x2_Type;
- case 3: return *context.fMat3x2_Type;
- case 4: return *context.fMat4x2_Type;
+ case 2: return *context.fFloat2x2_Type;
+ case 3: return *context.fFloat3x2_Type;
+ case 4: return *context.fFloat4x2_Type;
default: ABORT("unsupported matrix column count (%d)", columns);
}
case 3:
switch (columns) {
- case 2: return *context.fMat2x3_Type;
- case 3: return *context.fMat3x3_Type;
- case 4: return *context.fMat4x3_Type;
+ case 2: return *context.fFloat2x3_Type;
+ case 3: return *context.fFloat3x3_Type;
+ case 4: return *context.fFloat4x3_Type;
default: ABORT("unsupported matrix column count (%d)", columns);
}
case 4:
switch (columns) {
- case 2: return *context.fMat2x4_Type;
- case 3: return *context.fMat3x4_Type;
- case 4: return *context.fMat4x4_Type;
+ case 2: return *context.fFloat2x4_Type;
+ case 3: return *context.fFloat3x4_Type;
+ case 4: return *context.fFloat4x4_Type;
default: ABORT("unsupported matrix column count (%d)", columns);
}
default: ABORT("unsupported row count (%d)", rows);
@@ -78,30 +78,30 @@ const Type& Type::toCompound(const Context& context, int columns, int rows) cons
switch (rows) {
case 1:
switch (columns) {
- case 2: return *context.fDVec2_Type;
- case 3: return *context.fDVec3_Type;
- case 4: return *context.fDVec4_Type;
+ case 2: return *context.fDouble2_Type;
+ case 3: return *context.fDouble3_Type;
+ case 4: return *context.fDouble4_Type;
default: ABORT("unsupported vector column count (%d)", columns);
}
case 2:
switch (columns) {
- case 2: return *context.fDMat2x2_Type;
- case 3: return *context.fDMat3x2_Type;
- case 4: return *context.fDMat4x2_Type;
+ case 2: return *context.fDouble2x2_Type;
+ case 3: return *context.fDouble3x2_Type;
+ case 4: return *context.fDouble4x2_Type;
default: ABORT("unsupported matrix column count (%d)", columns);
}
case 3:
switch (columns) {
- case 2: return *context.fDMat2x3_Type;
- case 3: return *context.fDMat3x3_Type;
- case 4: return *context.fDMat4x3_Type;
+ case 2: return *context.fDouble2x3_Type;
+ case 3: return *context.fDouble3x3_Type;
+ case 4: return *context.fDouble4x3_Type;
default: ABORT("unsupported matrix column count (%d)", columns);
}
case 4:
switch (columns) {
- case 2: return *context.fDMat2x4_Type;
- case 3: return *context.fDMat3x4_Type;
- case 4: return *context.fDMat4x4_Type;
+ case 2: return *context.fDouble2x4_Type;
+ case 3: return *context.fDouble3x4_Type;
+ case 4: return *context.fDouble4x4_Type;
default: ABORT("unsupported matrix column count (%d)", columns);
}
default: ABORT("unsupported row count (%d)", rows);
@@ -110,9 +110,9 @@ const Type& Type::toCompound(const Context& context, int columns, int rows) cons
switch (rows) {
case 1:
switch (columns) {
- case 2: return *context.fIVec2_Type;
- case 3: return *context.fIVec3_Type;
- case 4: return *context.fIVec4_Type;
+ case 2: return *context.fInt2_Type;
+ case 3: return *context.fInt3_Type;
+ case 4: return *context.fInt4_Type;
default: ABORT("unsupported vector column count (%d)", columns);
}
default: ABORT("unsupported row count (%d)", rows);
@@ -121,9 +121,9 @@ const Type& Type::toCompound(const Context& context, int columns, int rows) cons
switch (rows) {
case 1:
switch (columns) {
- case 2: return *context.fUVec2_Type;
- case 3: return *context.fUVec3_Type;
- case 4: return *context.fUVec4_Type;
+ case 2: return *context.fUInt2_Type;
+ case 3: return *context.fUInt3_Type;
+ case 4: return *context.fUInt4_Type;
default: ABORT("unsupported vector column count (%d)", columns);
}
default: ABORT("unsupported row count (%d)", rows);
@@ -132,9 +132,9 @@ const Type& Type::toCompound(const Context& context, int columns, int rows) cons
switch (rows) {
case 1:
switch (columns) {
- case 2: return *context.fBVec2_Type;
- case 3: return *context.fBVec3_Type;
- case 4: return *context.fBVec4_Type;
+ case 2: return *context.fBool2_Type;
+ case 3: return *context.fBool3_Type;
+ case 4: return *context.fBool4_Type;
default: ABORT("unsupported vector column count (%d)", columns);
}
default: ABORT("unsupported row count (%d)", rows);
diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h
index 44bc26272b..9d122635c2 100644
--- a/src/sksl/ir/SkSLType.h
+++ b/src/sksl/ir/SkSLType.h
@@ -21,7 +21,7 @@ namespace SkSL {
class Context;
/**
- * Represents a type, such as int or vec4.
+ * Represents a type, such as int or float4.
*/
class Type : public Symbol {
public:
@@ -176,7 +176,7 @@ public:
}
/**
- * For matrices and vectors, returns the number of columns (e.g. both mat3 and vec3 return 3).
+ * For matrices and vectors, returns the number of columns (e.g. both mat3 and float3return 3).
* For scalars, returns 1. For arrays, returns either the size of the array (if known) or -1.
* For all other types, causes an assertion failure.
*/
diff --git a/src/sksl/sksl.include b/src/sksl/sksl.include
index 18a55169b8..5d905e3435 100644
--- a/src/sksl/sksl.include
+++ b/src/sksl/sksl.include
@@ -104,29 +104,29 @@ $genType frexp($genType x, out $genIType exp);
//$genDType frexp($genDType x, out $genIType exp);
$genType ldexp($genType x, in $genIType exp);
//$genDType ldexp($genDType x, in $genIType exp);
-uint packUnorm2x16(vec2 v);
-uint packSnorm2x16(vec2 v);
-uint packUnorm4x8(vec4 v);
-uint packSnorm4x8(vec4 v);
-vec2 unpackUnorm2x16(uint p);
-vec2 unpackSnorm2x16(uint p);
-vec4 unpackUnorm4x8(uint p);
-vec4 unpackSnorm4x8(uint p);
-//double packDouble2x32(uvec2 v);
-uvec2 unpackDouble2x32(double v);
-uint packHalf2x16(vec2 v);
-vec2 unpackHalf2x16(uint v);
+uint packUnorm2x16(float2 v);
+uint packSnorm2x16(float2 v);
+uint packUnorm4x8(float4 v);
+uint packSnorm4x8(float4 v);
+float2 unpackUnorm2x16(uint p);
+float2 unpackSnorm2x16(uint p);
+float4 unpackUnorm4x8(uint p);
+float4 unpackSnorm4x8(uint p);
+//double packDouble2x32(uint2 v);
+uint2 unpackDouble2x32(double v);
+uint packHalf2x16(float2 v);
+float2 unpackHalf2x16(uint v);
float length($genType x);
//double length($genDType x);
float distance($genType p0, $genType p1);
//double distance($genDType p0, $genDType p1);
float dot($genType x, $genType y);
//double dot($genDType x, $genDType y);
-vec3 cross(vec3 x, vec3 y);
-//dvec3 cross(dvec3 x, dvec3 y);
+float3 cross(float3 x, float3 y);
+//double3 cross(double3 x, double3 y);
$genType normalize($genType x);
//$genDType normalize($genDType x);
-vec4 ftransform();
+float4 ftransform();
$genType faceforward($genType N, $genType I, $genType Nref);
//$genDType faceforward($genDType N, $genDType I, $genDType Nref);
$genType reflect($genType I, $genType N);
@@ -134,30 +134,30 @@ $genType reflect($genType I, $genType N);
$genType refract($genType I, $genType N, float eta);
//$genDType refract($genDType I, $genDType N, float eta);
$mat matrixCompMult($mat x, $mat y);
-mat2 outerProduct(vec2 c, vec2 r);
-mat3 outerProduct(vec3 c, vec3 r);
-mat4 outerProduct(vec4 c, vec4 r);
-mat2x3 outerProduct(vec3 c, vec2 r);
-mat3x2 outerProduct(vec2 c, vec3 r);
-mat2x4 outerProduct(vec4 c, vec2 r);
-mat4x2 outerProduct(vec2 c, vec4 r);
-mat3x4 outerProduct(vec4 c, vec3 r);
-mat4x3 outerProduct(vec3 c, vec4 r);
-mat2 transpose(mat2 m);
-mat3 transpose(mat3 m);
-mat4 transpose(mat4 m);
-mat2x3 transpose(mat3x2 m);
-mat3x2 transpose(mat2x3 m);
-mat2x4 transpose(mat4x2 m);
-mat4x2 transpose(mat2x4 m);
-mat3x4 transpose(mat4x3 m);
-mat4x3 transpose(mat3x4 m);
-float determinant(mat2 m);
-float determinant(mat3 m);
-float determinant(mat4 m);
-mat2 inverse(mat2 m);
-mat3 inverse(mat3 m);
-mat4 inverse(mat4 m);
+float2x2 outerProduct(float2 c, float2 r);
+float3x3 outerProduct(float3 c, float3 r);
+float4x3 outerProduct(float4 c, float4 r);
+float2x3 outerProduct(float3 c, float2 r);
+float3x2 outerProduct(float2 c, float3 r);
+float2x4 outerProduct(float4 c, float2 r);
+float4x2 outerProduct(float2 c, float4 r);
+float3x4 outerProduct(float4 c, float3 r);
+float4x3 outerProduct(float3 c, float4 r);
+float2x2 transpose(float2x2 m);
+float3x3 transpose(float3x3 m);
+float4x4 transpose(float4x4 m);
+float2x3 transpose(float3x2 m);
+float3x2 transpose(float2x3 m);
+float2x4 transpose(float4x2 m);
+float4x2 transpose(float2x4 m);
+float3x4 transpose(float4x3 m);
+float4x3 transpose(float3x4 m);
+float determinant(float2x2 m);
+float determinant(float3x3 m);
+float determinant(float4x4 m);
+float2x2 inverse(float2x2 m);
+float3x3 inverse(float3x3 m);
+float4x4 inverse(float4x4 m);
$bvec lessThan($vec x, $vec y);
$bvec lessThan($ivec x, $ivec y);
$bvec lessThan($uvec x, $uvec y);
@@ -201,38 +201,38 @@ $genIType bitfieldInsert($genIType base, $genIType insert, int offset, int bits)
$genIType bitfieldReverse($genIType value);
//$genUType bitfieldReverse($genUType value);
int textureSize($gsampler1D sampler, int lod);
-ivec2 textureSize($gsampler2D sampler, int lod);
-ivec3 textureSize($gsampler3D sampler, int lod);
-ivec2 textureSize($gsamplerCube sampler, int lod);
+int2 textureSize($gsampler2D sampler, int lod);
+int3 textureSize($gsampler3D sampler, int lod);
+int2 textureSize($gsamplerCube sampler, int lod);
int textureSize(sampler1DShadow sampler, int lod);
-ivec2 textureSize(sampler2DShadow sampler, int lod);
-ivec2 textureSize(samplerCubeShadow sampler, int lod);
-ivec3 textureSize($gsamplerCubeArray sampler, int lod);
-ivec3 textureSize(samplerCubeArrayShadow sampler, int lod);
+int2 textureSize(sampler2DShadow sampler, int lod);
+int2 textureSize(samplerCubeShadow sampler, int lod);
+int3 textureSize($gsamplerCubeArray sampler, int lod);
+int3 textureSize(samplerCubeArrayShadow sampler, int lod);
*/
-ivec2 textureSize($gsampler2DRect sampler);
+int2 textureSize($gsampler2DRect sampler);
/*
-ivec2 textureSize(sampler2DRectShadow sampler);
-ivec2 textureSize($gsampler1DArray sampler, int lod);
-ivec3 textureSize($gsampler2DArray sampler, int lod);
-ivec2 textureSize(sampler1DArrayShadow sampler, int lod);
-ivec3 textureSize(sampler2DArrayShadow sampler, int lod);
+int2 textureSize(sampler2DRectShadow sampler);
+int2 textureSize($gsampler1DArray sampler, int lod);
+int3 textureSize($gsampler2DArray sampler, int lod);
+int2 textureSize(sampler1DArrayShadow sampler, int lod);
+int3 textureSize(sampler2DArrayShadow sampler, int lod);
int textureSize($gsamplerBuffer sampler);
-ivec2 textureSize($gsampler2DMS sampler);
-ivec3 textureSize($gsampler2DMSArray sampler);
-vec2 textureQueryLod($gsampler1D sampler, float P);
-vec2 textureQueryLod($gsampler2D sampler, vec2 P);
-vec2 textureQueryLod($gsampler3D sampler, vec3 P);
-vec2 textureQueryLod($gsamplerCube sampler, vec3 P);
-vec2 textureQueryLod($gsampler1DArray sampler, float P);
-vec2 textureQueryLod($gsampler2DArray sampler, vec2 P);
-vec2 textureQueryLod($gsamplerCubeArray sampler, vec3 P);
-vec2 textureQueryLod(sampler1DShadow sampler, float P);
-vec2 textureQueryLod(sampler2DShadow sampler, vec2 P);
-vec2 textureQueryLod(samplerCubeShadow sampler, vec3 P);
-vec2 textureQueryLod(sampler1DArrayShadow sampler, float P);
-vec2 textureQueryLod(sampler2DArrayShadow sampler, vec2 P);
-vec2 textureQueryLod(samplerCubeArrayShadow sampler, vec3 P);
+int2 textureSize($gsampler2DMS sampler);
+int3 textureSize($gsampler2DMSArray sampler);
+float2 textureQueryLod($gsampler1D sampler, float P);
+float2 textureQueryLod($gsampler2D sampler, float2 P);
+float2 textureQueryLod($gsampler3D sampler, float3 P);
+float2 textureQueryLod($gsamplerCube sampler, float3 P);
+float2 textureQueryLod($gsampler1DArray sampler, float P);
+float2 textureQueryLod($gsampler2DArray sampler, float2 P);
+float2 textureQueryLod($gsamplerCubeArray sampler, float3 P);
+float2 textureQueryLod(sampler1DShadow sampler, float P);
+float2 textureQueryLod(sampler2DShadow sampler, float2 P);
+float2 textureQueryLod(samplerCubeShadow sampler, float3 P);
+float2 textureQueryLod(sampler1DArrayShadow sampler, float P);
+float2 textureQueryLod(sampler2DArrayShadow sampler, float2 P);
+float2 textureQueryLod(samplerCubeArrayShadow sampler, float3 P);
int textureQueryLevels($gsampler1D sampler);
int textureQueryLevels($gsampler2D sampler);
int textureQueryLevels($gsampler3D sampler);
@@ -248,53 +248,53 @@ int textureQueryLevels(sampler2DArrayShadow sampler);
int textureQueryLevels(samplerCubeArrayShadow sampler);
*/
-$gvec4 texture($gsampler1D sampler, float P);
-$gvec4 texture($gsampler1D sampler, float P, float bias);
-$gvec4 texture($gsampler2D sampler, vec2 P);
+$gfloat4 texture($gsampler1D sampler, float P);
+$gfloat4 texture($gsampler1D sampler, float P, float bias);
+$gfloat4 texture($gsampler2D sampler, float2 P);
// The above currently only expand to handle the float/fixed case. So we also declare this integer
// version of texture().
-ivec4 texture(isampler2D sampler, vec2 P);
-vec4 texture(samplerExternalOES sampler, vec2 P, float bias);
-vec4 texture(samplerExternalOES sampler, vec2 P);
+int4 texture(isampler2D sampler, float2 P);
+float4 texture(samplerExternalOES sampler, float2 P, float bias);
+float4 texture(samplerExternalOES sampler, float2 P);
/*
-$gvec4 texture($gsampler2D sampler, vec2 P, float bias);
-$gvec4 texture($gsampler3D sampler, vec3 P);
-$gvec4 texture($gsampler3D sampler, vec3 P, float bias);
-$gvec4 texture($gsamplerCube sampler, vec3 P);
-$gvec4 texture($gsamplerCube sampler, vec3 P, float bias);
-float texture(sampler1DShadow sampler, vec3 P);
-float texture(sampler1DShadow sampler, vec3 P, float bias);
-float texture(sampler2DShadow sampler, vec3 P);
-float texture(sampler2DShadow sampler, vec3 P, float bias);
-float texture(samplerCubeShadow sampler, vec4 P);
-float texture(samplerCubeShadow sampler, vec4 P, float bias);
-$gvec4 texture($gsampler1DArray sampler, vec2 P);
-$gvec4 texture($gsampler1DArray sampler, vec2 P, float bias);
-$gvec4 texture($gsampler2DArray sampler, vec3 P);
-$gvec4 texture($gsampler2DArray sampler, vec3 P, float bias);
-$gvec4 texture($gsamplerCubeArray sampler, vec4 P);
-$gvec4 texture($gsamplerCubeArray sampler, vec4 P, float bias);
-float texture(sampler1DArrayShadow sampler, vec3 P);
-float texture(sampler1DArrayShadow sampler, vec3 P, float bias);
-float texture(sampler2DArrayShadow sampler, vec4 P);
+$gfloat4 texture($gsampler2D sampler, float2 P, float bias);
+$gfloat4 texture($gsampler3D sampler, float3 P);
+$gfloat4 texture($gsampler3D sampler, float3 P, float bias);
+$gfloat4 texture($gsamplerCube sampler, float3 P);
+$gfloat4 texture($gsamplerCube sampler, float3 P, float bias);
+float texture(sampler1DShadow sampler, float3 P);
+float texture(sampler1DShadow sampler, float3 P, float bias);
+float texture(sampler2DShadow sampler, float3 P);
+float texture(sampler2DShadow sampler, float3 P, float bias);
+float texture(samplerCubeShadow sampler, float4 P);
+float texture(samplerCubeShadow sampler, float4 P, float bias);
+$gfloat4 texture($gsampler1DArray sampler, float2 P);
+$gfloat4 texture($gsampler1DArray sampler, float2 P, float bias);
+$gfloat4 texture($gsampler2DArray sampler, float3 P);
+$gfloat4 texture($gsampler2DArray sampler, float3 P, float bias);
+$gfloat4 texture($gsamplerCubeArray sampler, float4 P);
+$gfloat4 texture($gsamplerCubeArray sampler, float4 P, float bias);
+float texture(sampler1DArrayShadow sampler, float3 P);
+float texture(sampler1DArrayShadow sampler, float3 P, float bias);
+float texture(sampler2DArrayShadow sampler, float4 P);
*/
-$gvec4 texture($gsampler2DRect sampler, vec2 P);
-$gvec4 texture($gsampler2DRect sampler, vec3 P);
+$gfloat4 texture($gsampler2DRect sampler, float2 P);
+$gfloat4 texture($gsampler2DRect sampler, float3 P);
/*
-float texture(sampler2DRectShadow sampler, vec3 P);
-float texture($gsamplerCubeArrayShadow sampler, vec4 P, float compare);
+float texture(sampler2DRectShadow sampler, float3 P);
+float texture($gsamplerCubeArrayShadow sampler, float4 P, float compare);
*/
// Currently we do not support the generic types of loading subpassInput so we have some explicit
// versions that we currently use
-vec4 subpassLoad(subpassInput subpass);
-vec4 subpassLoad(subpassInputMS subpass, int sample);
+float4 subpassLoad(subpassInput subpass);
+float4 subpassLoad(subpassInputMS subpass, int sample);
/*
-$gvec4 subpassLoad(gsubpassInput subpass);
-$gvec4 subpassLoad(gsubpassInputMS subpass, int sample);
+$gfloat4subpassLoad(gsubpassInput subpass);
+$gfloat4subpassLoad(gsubpassInputMS subpass, int sample);
*/
)
@@ -302,183 +302,183 @@ $gvec4 subpassLoad(gsubpassInputMS subpass, int sample);
STRINGIFY(
-$gvec4 texture($gsampler1D sampler, vec2 P);
-$gvec4 texture($gsampler1D sampler, vec2 P, float bias);
-$gvec4 texture($gsampler2D sampler, vec3 P);
-$gvec4 texture($gsampler2D sampler, vec3 P, float bias);
+$gfloat4 texture($gsampler1D sampler, float2 P);
+$gfloat4 texture($gsampler1D sampler, float2 P, float bias);
+$gfloat4 texture($gsampler2D sampler, float3 P);
+$gfloat4 texture($gsampler2D sampler, float3 P, float bias);
/*
-$gvec4 textureProj($gsampler3D sampler, vec4 P);
-$gvec4 textureProj($gsampler3D sampler, vec4 P, float bias);
-float textureProj(sampler1DShadow sampler, vec4 P);
-float textureProj(sampler1DShadow sampler, vec4 P, float bias);
-float textureProj(sampler2DShadow sampler, vec4 P);
-float textureProj(sampler2DShadow sampler, vec4 P, float bias);
-$gvec4 textureProj($gsampler2DRect sampler, vec4 P);
-float textureProj(sampler2DRectShadow sampler, vec4 P);
-$gvec4 textureLod($gsampler1D sampler, float P, float lod);
-$gvec4 textureLod($gsampler2D sampler, vec2 P, float lod);
-$gvec4 textureLod($gsampler3D sampler, vec3 P, float lod);
-$gvec4 textureLod($gsamplerCube sampler, vec3 P, float lod);
-float textureLod(sampler1DShadow sampler, vec3 P, float lod);
-float textureLod(sampler2DShadow sampler, vec3 P, float lod);
-$gvec4 textureLod($gsampler1DArray sampler, vec2 P, float lod);
-$gvec4 textureLod($gsampler2DArray sampler, vec3 P, float lod);
-float textureLod(sampler1DArrayShadow sampler, vec3 P, float lod);
-$gvec4 textureLod($gsamplerCubeArray sampler, vec4 P, float lod);
-$gvec4 textureOffset($gsampler1D sampler, float P, int offset);
-$gvec4 textureOffset($gsampler1D sampler, float P, int offset, float bias);
-$gvec4 textureOffset($gsampler2D sampler, vec2 P, ivec2 offset);
-$gvec4 textureOffset($gsampler2D sampler, vec2 P, ivec2 offset, float bias);
-$gvec4 textureOffset($gsampler3D sampler, vec3 P, ivec3 offset);
-$gvec4 textureOffset($gsampler3D sampler, vec3 P, ivec3 offset, float bias);
-$gvec4 textureOffset($gsampler2DRect sampler, vec2 P, ivec2 offset);
-float textureOffset(sampler2DRectShadow sampler, vec3 P, ivec2 offset);
-float textureOffset(sampler1DShadow sampler, vec3 P, int offset);
-float textureOffset(sampler1DShadow sampler, vec3 P, int offset, float bias);
-float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset);
-float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset, float bias);
-$gvec4 textureOffset($gsampler1DArray sampler, vec2 P, int offset);
-$gvec4 textureOffset($gsampler1DArray sampler, vec2 P, int offset, float bias);
-$gvec4 textureOffset($gsampler2DArray sampler, vec3 P, ivec2 offset);
-$gvec4 textureOffset($gsampler2DArray sampler, vec3 P, ivec2 offset, float bias);
-float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset);
-float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset, float bias);
-float textureOffset(sampler2DArrayShadow sampler, vec4 P, ivec2 offset);
+$gfloat4 textureProj($gsampler3D sampler, float4 P);
+$gfloat4 textureProj($gsampler3D sampler, float4 P, float bias);
+float textureProj(sampler1DShadow sampler, float4 P);
+float textureProj(sampler1DShadow sampler, float4 P, float bias);
+float textureProj(sampler2DShadow sampler, float4 P);
+float textureProj(sampler2DShadow sampler, float4 P, float bias);
+$gfloat4 textureProj($gsampler2DRect sampler, float4 P);
+float textureProj(sampler2DRectShadow sampler, float4 P);
+$gfloat4 textureLod($gsampler1D sampler, float P, float lod);
+$gfloat4 textureLod($gsampler2D sampler, float2 P, float lod);
+$gfloat4 textureLod($gsampler3D sampler, float3 P, float lod);
+$gfloat4 textureLod($gsamplerCube sampler, float3 P, float lod);
+float textureLod(sampler1DShadow sampler, float3 P, float lod);
+float textureLod(sampler2DShadow sampler, float3 P, float lod);
+$gfloat4 textureLod($gsampler1DArray sampler, float2 P, float lod);
+$gfloat4 textureLod($gsampler2DArray sampler, float3 P, float lod);
+float textureLod(sampler1DArrayShadow sampler, float3 P, float lod);
+$gfloat4 textureLod($gsamplerCubeArray sampler, float4 P, float lod);
+$gfloat4 textureOffset($gsampler1D sampler, float P, int offset);
+$gfloat4 textureOffset($gsampler1D sampler, float P, int offset, float bias);
+$gfloat4 textureOffset($gsampler2D sampler, float2 P, int2 offset);
+$gfloat4 textureOffset($gsampler2D sampler, float2 P, int2 offset, float bias);
+$gfloat4 textureOffset($gsampler3D sampler, float3 P, int3 offset);
+$gfloat4 textureOffset($gsampler3D sampler, float3 P, int3 offset, float bias);
+$gfloat4 textureOffset($gsampler2DRect sampler, float2 P, int2 offset);
+float textureOffset(sampler2DRectShadow sampler, float3 P, int2 offset);
+float textureOffset(sampler1DShadow sampler, float3 P, int offset);
+float textureOffset(sampler1DShadow sampler, float3 P, int offset, float bias);
+float textureOffset(sampler2DShadow sampler, float3 P, int2 offset);
+float textureOffset(sampler2DShadow sampler, float3 P, int2 offset, float bias);
+$gfloat4 textureOffset($gsampler1DArray sampler, float2 P, int offset);
+$gfloat4 textureOffset($gsampler1DArray sampler, float2 P, int offset, float bias);
+$gfloat4 textureOffset($gsampler2DArray sampler, float3 P, int2 offset);
+$gfloat4 textureOffset($gsampler2DArray sampler, float3 P, int2 offset, float bias);
+float textureOffset(sampler1DArrayShadow sampler, float3 P, int offset);
+float textureOffset(sampler1DArrayShadow sampler, float3 P, int offset, float bias);
+float textureOffset(sampler2DArrayShadow sampler, float4 P, int2 offset);
*/
-vec4 texelFetch(samplerBuffer sampler, int P);
+float4 texelFetch(samplerBuffer sampler, int P);
-$gvec4 texelFetch($gsampler1D sampler, int P, int lod);
-$gvec4 texelFetch($gsampler2D sampler, ivec2 P, int lod);
-$gvec4 texelFetch($gsampler2DRect sampler, ivec2 P);
+$gfloat4 texelFetch($gsampler1D sampler, int P, int lod);
+$gfloat4 texelFetch($gsampler2D sampler, int2 P, int lod);
+$gfloat4 texelFetch($gsampler2DRect sampler, int2 P);
/*
-$gvec4 texelFetch($gsampler3D sampler, ivec3 P, int lod);
-$gvec4 texelFetch($gsampler1DArray sampler, ivec2 P, int lod);
-$gvec4 texelFetch($gsampler2DArray sampler, ivec3 P, int lod);
-$gvec4 texelFetch($gsampler2DMS sampler, ivec2 P, int sample);
-$gvec4 texelFetch($gsampler2DMSArray sampler, ivec3 P, int sample);
-$gvec4 texelFetchOffset($gsampler1D sampler, int P, int lod, int offset);
-$gvec4 texelFetchOffset($gsampler2D sampler, ivec2 P, int lod, ivec2 offset);
-$gvec4 texelFetchOffset($gsampler3D sampler, ivec3 P, int lod, ivec3 offset);
-$gvec4 texelFetchOffset($gsampler2DRect sampler, ivec2 P, ivec2 offset);
-$gvec4 texelFetchOffset($gsampler1DArray sampler, ivec2 P, int lod, int offset);
-$gvec4 texelFetchOffset($gsampler2DArray sampler, ivec3 P, int lod, ivec2 offset);
-$gvec4 textureProjOffset($gsampler1D sampler, vec2 P, int offset);
-$gvec4 textureProjOffset($gsampler1D sampler, vec2 P, int offset, float bias);
-$gvec4 textureProjOffset($gsampler1D sampler, vec4 P, int offset);
-$gvec4 textureProjOffset($gsampler1D sampler, vec4 P, int offset, float bias);
-$gvec4 textureProjOffset($gsampler2D sampler, vec3 P, ivec2 offset);
-$gvec4 textureProjOffset($gsampler2D sampler, vec3 P, ivec2 offset, float bias);
-$gvec4 textureProjOffset($gsampler2D sampler, vec4 P, ivec2 offset);
-$gvec4 textureProjOffset($gsampler2D sampler, vec4 P, ivec2 offset, float bias);
-$gvec4 textureProjOffset($gsampler3D sampler, vec4 P, ivec3 offset);
-$gvec4 textureProjOffset($gsampler3D sampler, vec4 P, ivec3 offset, float bias);
-$gvec4 textureProjOffset($gsampler2DRect sampler, vec3 P, ivec2 offset);
-$gvec4 textureProjOffset($gsampler2DRect sampler, vec4 P, ivec2 offset);
-float textureProjOffset(sampler2DRectShadow sampler, vec4 P, ivec2 offset);
-float textureProjOffset(sampler1DShadow sampler, vec4 P, int offset);
-float textureProjOffset(sampler1DShadow sampler, vec4 P, int offset, float bias);
-float textureProjOffset(sampler2DShadow sampler, vec4 P, ivec2 offset);
-float textureProjOffset(sampler2DShadow sampler, vec4 P, ivec2 offset, float bias);
-$gvec4 textureLodOffset($gsampler1D sampler, float P, float lod, int offset);
-$gvec4 textureLodOffset($gsampler2D sampler, vec2 P, float lod, ivec2 offset);
-$gvec4 textureLodOffset($gsampler3D sampler, vec3 P, float lod, ivec3 offset);
-float textureLodOffset(sampler1DShadow sampler, vec3 P, float lod, int offset);
-float textureLodOffset(sampler2DShadow sampler, vec3 P, float lod, ivec2 offset);
-$gvec4 textureLodOffset($gsampler1DArray sampler, vec2 P, float lod, int offset);
-$gvec4 textureLodOffset($gsampler2DArray sampler, vec3 P, float lod, ivec2 offset);
-float textureLodOffset(sampler1DArrayShadow sampler, vec3 P, float lod, int offset);
-$gvec4 textureProjLod($gsampler1D sampler, vec2 P, float lod);
-$gvec4 textureProjLod($gsampler1D sampler, vec4 P, float lod);
-$gvec4 textureProjLod($gsampler2D sampler, vec3 P, float lod);
-$gvec4 textureProjLod($gsampler2D sampler, vec4 P, float lod);
-$gvec4 textureProjLod($gsampler3D sampler, vec4 P, float lod);
-float textureProjLod(sampler1DShadow sampler, vec4 P, float lod);
-float textureProjLod(sampler2DShadow sampler, vec4 P, float lod);
-$gvec4 textureProjLodOffset($gsampler1D sampler, vec2 P, float lod, int offset);
-$gvec4 textureProjLodOffset($gsampler1D sampler, vec4 P, float lod, int offset);
-$gvec4 textureProjLodOffset($gsampler2D sampler, vec3 P, float lod, ivec2 offset);
-$gvec4 textureProjLodOffset($gsampler2D sampler, vec4 P, float lod, ivec2 offset);
-$gvec4 textureProjLodOffset($gsampler3D sampler, vec4 P, float lod, ivec3 offset);
-float textureProjLodOffset(sampler1DShadow sampler, vec4 P, float lod, int offset);
-float textureProjLodOffset(sampler2DShadow sampler, vec4 P, float lod, ivec2 offset);
-$gvec4 textureGrad($gsampler1D sampler, float P, float dPdx, float dPdy);
-$gvec4 textureGrad($gsampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy);
-$gvec4 textureGrad($gsampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy);
-$gvec4 textureGrad($gsamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy);
-$gvec4 textureGrad($gsampler2DRect sampler, vec2 P, vec2 dPdx, vec2 dPdy);
-float textureGrad(sampler2DRectShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy);
-float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy);
-float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy);
-float textureGrad(samplerCubeShadow sampler, vec4 P, vec3 dPdx, vec3 dPdy);
-$gvec4 textureGrad($gsampler1DArray sampler, vec2 P, float dPdx, float dPdy);
-$gvec4 textureGrad($gsampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy);
-float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy);
-float textureGrad(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy);
-$gvec4 textureGrad($gsamplerCubeArray sampler, vec4 P, vec3 dPdx, vec3 dPdy);
-$gvec4 textureGradOffset($gsampler1D sampler, float P, float dPdx, float dPdy, int offset);
-$gvec4 textureGradOffset($gsampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-$gvec4 textureGradOffset($gsampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy, ivec3 offset);
-$gvec4 textureGradOffset($gsampler2DRect sampler, vec2 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-float textureGradOffset(sampler2DRectShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-float textureGradOffset(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy, int offset );
-float textureGradOffset(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-$gvec4 textureGradOffset($gsampler1DArray sampler, vec2 P, float dPdx, float dPdy, int offset);
-$gvec4 textureGradOffset($gsampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-float textureGradOffset(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy, int offset);
-float textureGradOffset(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-$gvec4 textureProjGrad($gsampler1D sampler, vec2 P, float dPdx, float dPdy);
-$gvec4 textureProjGrad($gsampler1D sampler, vec4 P, float dPdx, float dPdy);
-$gvec4 textureProjGrad($gsampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy);
-$gvec4 textureProjGrad($gsampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy);
-$gvec4 textureProjGrad($gsampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy);
-$gvec4 textureProjGrad($gsampler2DRect sampler, vec3 P, vec2 dPdx, vec2 dPdy);
-$gvec4 textureProjGrad($gsampler2DRect sampler, vec4 P, vec2 dPdx, vec2 dPdy);
-float textureProjGrad(sampler2DRectShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy);
-float textureProjGrad(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy);
-float textureProjGrad(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy);
-$gvec4 textureProjGradOffset($gsampler1D sampler, vec2 P, float dPdx, float dPdy, int offset);
-$gvec4 textureProjGradOffset($gsampler1D sampler, vec4 P, float dPdx, float dPdy, int offset);
-$gvec4 textureProjGradOffset($gsampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-$gvec4 textureProjGradOffset($gsampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-$gvec4 textureProjGradOffset($gsampler2DRect sampler, vec3 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-$gvec4 textureProjGradOffset($gsampler2DRect sampler, vec4 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-float textureProjGradOffset(sampler2DRectShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-$gvec4 textureProjGradOffset($gsampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy, ivec3 offset);
-float textureProjGradOffset(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy, int offset);
-float textureProjGradOffset(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy, ivec2 offset);
-$gvec4 textureGather($gsampler2D sampler, vec2 P);
-$gvec4 textureGather($gsampler2D sampler, vec2 P, int comp);
-$gvec4 textureGather($gsampler2DArray sampler, vec3 P);
-$gvec4 textureGather($gsampler2DArray sampler, vec3 P, int comp);
-$gvec4 textureGather($gsamplerCube sampler, vec3 P);
-$gvec4 textureGather($gsamplerCube sampler, vec3 P, int comp);
-$gvec4 textureGather($gsamplerCubeArray sampler, vec4 P);
-$gvec4 textureGather($gsamplerCubeArray sampler, vec4 P, int comp);
-$gvec4 textureGather($gsampler2DRect sampler, vec2 P);
-$gvec4 textureGather($gsampler2DRect sampler, vec2 P, int comp);
-vec4 textureGather(sampler2DShadow sampler, vec2 P, float refZ);
-vec4 textureGather(sampler2DArrayShadow sampler, vec3 P, float refZ);
-vec4 textureGather(samplerCubeShadow sampler, vec3 P, float refZ);
-vec4 textureGather(samplerCubeArrayShadow sampler, vec4 P, float refZ);
-vec4 textureGather(sampler2DRectShadow sampler, vec2 P, float refZ);
-$gvec4 textureGatherOffset($gsampler2D sampler, vec2 P, ivec2 offset);
-$gvec4 textureGatherOffset($gsampler2D sampler, vec2 P, ivec2 offset, int comp);
-$gvec4 textureGatherOffset($gsampler2DArray sampler, vec3 P, ivec2 offset);
-$gvec4 textureGatherOffset($gsampler2DArray sampler, vec3 P, ivec2 offset, int comp);
-$gvec4 textureGatherOffset($gsampler2DRect sampler, vec2 P, ivec2 offset);
-$gvec4 textureGatherOffset($gsampler2DRect sampler, vec2 P, ivec2 offset, int comp);
-vec4 textureGatherOffset(sampler2DShadow sampler, vec2 P, float refZ, ivec2 offset);
-vec4 textureGatherOffset(sampler2DArrayShadow sampler, vec3 P, float refZ, ivec2 offset);
-vec4 textureGatherOffset(sampler2DRectShadow sampler, vec2 P, float refZ, ivec2 offset);
-$gvec4 textureGatherOffsets($gsampler2D sampler, vec2 P, ivec2 offsets[4]);
-$gvec4 textureGatherOffsets($gsampler2D sampler, vec2 P, ivec2 offsets[4], int comp);
-$gvec4 textureGatherOffsets($gsampler2DArray sampler, vec3 P, ivec2 offsets[4]);
-$gvec4 textureGatherOffsets($gsampler2DArray sampler, vec3 P, ivec2 offsets[4], int comp);
-$gvec4 textureGatherOffsets($gsampler2DRect sampler, vec2 P, ivec2 offsets[4]);
-$gvec4 textureGatherOffsets($gsampler2DRect sampler, vec2 P, ivec2 offsets[4], int comp);
-vec4 textureGatherOffsets(sampler2DShadow sampler, vec2 P, float refZ, ivec2 offsets[4]);
-vec4 textureGatherOffsets(sampler2DArrayShadow sampler, vec3 P, float refZ, ivec2 offsets[4]);
-vec4 textureGatherOffsets(sampler2DRectShadow sampler, vec2 P, float refZ, ivec2 offsets[4]);
+$gfloat4 texelFetch($gsampler3D sampler, int3 P, int lod);
+$gfloat4 texelFetch($gsampler1DArray sampler, int2 P, int lod);
+$gfloat4 texelFetch($gsampler2DArray sampler, int3 P, int lod);
+$gfloat4 texelFetch($gsampler2DMS sampler, int2 P, int sample);
+$gfloat4 texelFetch($gsampler2DMSArray sampler, int3 P, int sample);
+$gfloat4 texelFetchOffset($gsampler1D sampler, int P, int lod, int offset);
+$gfloat4 texelFetchOffset($gsampler2D sampler, int2 P, int lod, int2 offset);
+$gfloat4 texelFetchOffset($gsampler3D sampler, int3 P, int lod, int3 offset);
+$gfloat4 texelFetchOffset($gsampler2DRect sampler, int2 P, int2 offset);
+$gfloat4 texelFetchOffset($gsampler1DArray sampler, int2 P, int lod, int offset);
+$gfloat4 texelFetchOffset($gsampler2DArray sampler, int3 P, int lod, int2 offset);
+$gfloat4 textureProjOffset($gsampler1D sampler, float2 P, int offset);
+$gfloat4 textureProjOffset($gsampler1D sampler, float2 P, int offset, float bias);
+$gfloat4 textureProjOffset($gsampler1D sampler, float4 P, int offset);
+$gfloat4 textureProjOffset($gsampler1D sampler, float4 P, int offset, float bias);
+$gfloat4 textureProjOffset($gsampler2D sampler, float3 P, int2 offset);
+$gfloat4 textureProjOffset($gsampler2D sampler, float3 P, int2 offset, float bias);
+$gfloat4 textureProjOffset($gsampler2D sampler, float4 P, int2 offset);
+$gfloat4 textureProjOffset($gsampler2D sampler, float4 P, int2 offset, float bias);
+$gfloat4 textureProjOffset($gsampler3D sampler, float4 P, int3 offset);
+$gfloat4 textureProjOffset($gsampler3D sampler, float4 P, int3 offset, float bias);
+$gfloat4 textureProjOffset($gsampler2DRect sampler, float3 P, int2 offset);
+$gfloat4 textureProjOffset($gsampler2DRect sampler, float4 P, int2 offset);
+float textureProjOffset(sampler2DRectShadow sampler, float4 P, int2 offset);
+float textureProjOffset(sampler1DShadow sampler, float4 P, int offset);
+float textureProjOffset(sampler1DShadow sampler, float4 P, int offset, float bias);
+float textureProjOffset(sampler2DShadow sampler, float4 P, int2 offset);
+float textureProjOffset(sampler2DShadow sampler, float4 P, int2 offset, float bias);
+$gfloat4 textureLodOffset($gsampler1D sampler, float P, float lod, int offset);
+$gfloat4 textureLodOffset($gsampler2D sampler, float2 P, float lod, int2 offset);
+$gfloat4 textureLodOffset($gsampler3D sampler, float3 P, float lod, int3 offset);
+float textureLodOffset(sampler1DShadow sampler, float3 P, float lod, int offset);
+float textureLodOffset(sampler2DShadow sampler, float3 P, float lod, int2 offset);
+$gfloat4 textureLodOffset($gsampler1DArray sampler, float2 P, float lod, int offset);
+$gfloat4 textureLodOffset($gsampler2DArray sampler, float3 P, float lod, int2 offset);
+float textureLodOffset(sampler1DArrayShadow sampler, float3 P, float lod, int offset);
+$gfloat4 textureProjLod($gsampler1D sampler, float2 P, float lod);
+$gfloat4 textureProjLod($gsampler1D sampler, float4 P, float lod);
+$gfloat4 textureProjLod($gsampler2D sampler, float3 P, float lod);
+$gfloat4 textureProjLod($gsampler2D sampler, float4 P, float lod);
+$gfloat4 textureProjLod($gsampler3D sampler, float4 P, float lod);
+float textureProjLod(sampler1DShadow sampler, float4 P, float lod);
+float textureProjLod(sampler2DShadow sampler, float4 P, float lod);
+$gfloat4 textureProjLodOffset($gsampler1D sampler, float2 P, float lod, int offset);
+$gfloat4 textureProjLodOffset($gsampler1D sampler, float4 P, float lod, int offset);
+$gfloat4 textureProjLodOffset($gsampler2D sampler, float3 P, float lod, int2 offset);
+$gfloat4 textureProjLodOffset($gsampler2D sampler, float4 P, float lod, int2 offset);
+$gfloat4 textureProjLodOffset($gsampler3D sampler, float4 P, float lod, int3 offset);
+float textureProjLodOffset(sampler1DShadow sampler, float4 P, float lod, int offset);
+float textureProjLodOffset(sampler2DShadow sampler, float4 P, float lod, int2 offset);
+$gfloat4 textureGrad($gsampler1D sampler, float P, float dPdx, float dPdy);
+$gfloat4 textureGrad($gsampler2D sampler, float2 P, float2 dPdx, float2 dPdy);
+$gfloat4 textureGrad($gsampler3D sampler, float3 P, float3 dPdx, float3 dPdy);
+$gfloat4 textureGrad($gsamplerCube sampler, float3 P, float3 dPdx, float3 dPdy);
+$gfloat4 textureGrad($gsampler2DRect sampler, float2 P, float2 dPdx, float2 dPdy);
+float textureGrad(sampler2DRectShadow sampler, float3 P, float2 dPdx, float2 dPdy);
+float textureGrad(sampler1DShadow sampler, float3 P, float dPdx, float dPdy);
+float textureGrad(sampler2DShadow sampler, float3 P, float2 dPdx, float2 dPdy);
+float textureGrad(samplerCubeShadow sampler, float4 P, float3 dPdx, float3 dPdy);
+$gfloat4 textureGrad($gsampler1DArray sampler, float2 P, float dPdx, float dPdy);
+$gfloat4 textureGrad($gsampler2DArray sampler, float3 P, float2 dPdx, float2 dPdy);
+float textureGrad(sampler1DArrayShadow sampler, float3 P, float dPdx, float dPdy);
+float textureGrad(sampler2DArrayShadow sampler, float4 P, float2 dPdx, float2 dPdy);
+$gfloat4 textureGrad($gsamplerCubeArray sampler, float4 P, float3 dPdx, float3 dPdy);
+$gfloat4 textureGradOffset($gsampler1D sampler, float P, float dPdx, float dPdy, int offset);
+$gfloat4 textureGradOffset($gsampler2D sampler, float2 P, float2 dPdx, float2 dPdy, int2 offset);
+$gfloat4 textureGradOffset($gsampler3D sampler, float3 P, float3 dPdx, float3 dPdy, int3 offset);
+$gfloat4 textureGradOffset($gsampler2DRect sampler, float2 P, float2 dPdx, float2 dPdy, int2 offset);
+float textureGradOffset(sampler2DRectShadow sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
+float textureGradOffset(sampler1DShadow sampler, float3 P, float dPdx, float dPdy, int offset );
+float textureGradOffset(sampler2DShadow sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
+$gfloat4 textureGradOffset($gsampler1DArray sampler, float2 P, float dPdx, float dPdy, int offset);
+$gfloat4 textureGradOffset($gsampler2DArray sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
+float textureGradOffset(sampler1DArrayShadow sampler, float3 P, float dPdx, float dPdy, int offset);
+float textureGradOffset(sampler2DArrayShadow sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
+$gfloat4 textureProjGrad($gsampler1D sampler, float2 P, float dPdx, float dPdy);
+$gfloat4 textureProjGrad($gsampler1D sampler, float4 P, float dPdx, float dPdy);
+$gfloat4 textureProjGrad($gsampler2D sampler, float3 P, float2 dPdx, float2 dPdy);
+$gfloat4 textureProjGrad($gsampler2D sampler, float4 P, float2 dPdx, float2 dPdy);
+$gfloat4 textureProjGrad($gsampler3D sampler, float4 P, float3 dPdx, float3 dPdy);
+$gfloat4 textureProjGrad($gsampler2DRect sampler, float3 P, float2 dPdx, float2 dPdy);
+$gfloat4 textureProjGrad($gsampler2DRect sampler, float4 P, float2 dPdx, float2 dPdy);
+float textureProjGrad(sampler2DRectShadow sampler, float4 P, float2 dPdx, float2 dPdy);
+float textureProjGrad(sampler1DShadow sampler, float4 P, float dPdx, float dPdy);
+float textureProjGrad(sampler2DShadow sampler, float4 P, float2 dPdx, float2 dPdy);
+$gfloat4 textureProjGradOffset($gsampler1D sampler, float2 P, float dPdx, float dPdy, int offset);
+$gfloat4 textureProjGradOffset($gsampler1D sampler, float4 P, float dPdx, float dPdy, int offset);
+$gfloat4 textureProjGradOffset($gsampler2D sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
+$gfloat4 textureProjGradOffset($gsampler2D sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
+$gfloat4 textureProjGradOffset($gsampler2DRect sampler, float3 P, float2 dPdx, float2 dPdy, int2 offset);
+$gfloat4 textureProjGradOffset($gsampler2DRect sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
+float textureProjGradOffset(sampler2DRectShadow sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
+$gfloat4 textureProjGradOffset($gsampler3D sampler, float4 P, float3 dPdx, float3 dPdy, int3 offset);
+float textureProjGradOffset(sampler1DShadow sampler, float4 P, float dPdx, float dPdy, int offset);
+float textureProjGradOffset(sampler2DShadow sampler, float4 P, float2 dPdx, float2 dPdy, int2 offset);
+$gfloat4 textureGather($gsampler2D sampler, float2 P);
+$gfloat4 textureGather($gsampler2D sampler, float2 P, int comp);
+$gfloat4 textureGather($gsampler2DArray sampler, float3 P);
+$gfloat4 textureGather($gsampler2DArray sampler, float3 P, int comp);
+$gfloat4 textureGather($gsamplerCube sampler, float3 P);
+$gfloat4 textureGather($gsamplerCube sampler, float3 P, int comp);
+$gfloat4 textureGather($gsamplerCubeArray sampler, float4 P);
+$gfloat4 textureGather($gsamplerCubeArray sampler, float4 P, int comp);
+$gfloat4 textureGather($gsampler2DRect sampler, float2 P);
+$gfloat4 textureGather($gsampler2DRect sampler, float2 P, int comp);
+float4 textureGather(sampler2DShadow sampler, float2 P, float refZ);
+float4 textureGather(sampler2DArrayShadow sampler, float3 P, float refZ);
+float4 textureGather(samplerCubeShadow sampler, float3 P, float refZ);
+float4 textureGather(samplerCubeArrayShadow sampler, float4 P, float refZ);
+float4 textureGather(sampler2DRectShadow sampler, float2 P, float refZ);
+$gfloat4 textureGatherOffset($gsampler2D sampler, float2 P, int2 offset);
+$gfloat4 textureGatherOffset($gsampler2D sampler, float2 P, int2 offset, int comp);
+$gfloat4 textureGatherOffset($gsampler2DArray sampler, float3 P, int2 offset);
+$gfloat4 textureGatherOffset($gsampler2DArray sampler, float3 P, int2 offset, int comp);
+$gfloat4 textureGatherOffset($gsampler2DRect sampler, float2 P, int2 offset);
+$gfloat4 textureGatherOffset($gsampler2DRect sampler, float2 P, int2 offset, int comp);
+float4 textureGatherOffset(sampler2DShadow sampler, float2 P, float refZ, int2 offset);
+float4 textureGatherOffset(sampler2DArrayShadow sampler, float3 P, float refZ, int2 offset);
+float4 textureGatherOffset(sampler2DRectShadow sampler, float2 P, float refZ, int2 offset);
+$gfloat4 textureGatherOffsets($gsampler2D sampler, float2 P, int2 offsets[4]);
+$gfloat4 textureGatherOffsets($gsampler2D sampler, float2 P, int2 offsets[4], int comp);
+$gfloat4 textureGatherOffsets($gsampler2DArray sampler, float3 P, int2 offsets[4]);
+$gfloat4 textureGatherOffsets($gsampler2DArray sampler, float3 P, int2 offsets[4], int comp);
+$gfloat4 textureGatherOffsets($gsampler2DRect sampler, float2 P, int2 offsets[4]);
+$gfloat4 textureGatherOffsets($gsampler2DRect sampler, float2 P, int2 offsets[4], int comp);
+float4 textureGatherOffsets(sampler2DShadow sampler, float2 P, float refZ, int2 offsets[4]);
+float4 textureGatherOffsets(sampler2DArrayShadow sampler, float3 P, float refZ, int2 offsets[4]);
+float4 textureGatherOffsets(sampler2DRectShadow sampler, float2 P, float refZ, int2 offsets[4]);
uint atomicCounterIncrement(atomic_uint c);
uint atomicCounter(atomic_uint c);
uint atomicAdd(inout uint mem, uint data);
@@ -500,18 +500,18 @@ int atomicCompSwap(inout int mem, int compare, int data);
*/
// section 8.12 Additional Image Functions will go here if and when we add
// support for them
-vec4 imageLoad(image2D image, ivec2 P);
-ivec4 imageLoad(iimage2D image, ivec2 P);
+float4 imageLoad(image2D image, int2 P);
+int4 imageLoad(iimage2D image, int2 P);
$genType dFdx($genType p);
$genType dFdy($genType p);
float interpolateAtSample(float interpolant, int sample);
-vec2 interpolateAtSample(vec2 interpolant, int sample);
-vec3 interpolateAtSample(vec3 interpolant, int sample);
-vec4 interpolateAtSample(vec4 interpolant, int sample);
-float interpolateAtOffset(float interpolant, vec2 offset);
-vec2 interpolateAtOffset(vec2 interpolant, vec2 offset);
-vec3 interpolateAtOffset(vec3 interpolant, vec2 offset);
-vec4 interpolateAtOffset(vec4 interpolant, vec2 offset);
+float2 interpolateAtSample(float2 interpolant, int sample);
+float3 interpolateAtSample(float3 interpolant, int sample);
+float4 interpolateAtSample(float4 interpolant, int sample);
+float interpolateAtOffset(float interpolant, float2 offset);
+float2 interpolateAtOffset(float2 interpolant, float2 offset);
+float3 interpolateAtOffset(float3 interpolant, float2 offset);
+float4 interpolateAtOffset(float4 interpolant, float2 offset);
/*
$genType fwidth($genType p);
diff --git a/src/sksl/sksl_fp.include b/src/sksl/sksl_fp.include
index 0d8d99d7b8..4d6b94d92d 100644
--- a/src/sksl/sksl_fp.include
+++ b/src/sksl/sksl_fp.include
@@ -2,24 +2,24 @@ STRINGIFY(
// defines built-in interfaces supported by SkiaSL fragment shaders
-layout(builtin=15) in vec4 sk_FragCoord;
+layout(builtin=15) in float4 sk_FragCoord;
layout(builtin=3) float sk_ClipDistance[1];
// 9999 is a temporary value that causes us to ignore these declarations beyond
// adding them to the symbol table. This works fine in GLSL (where they do not
// require any further handling) but will fail in SPIR-V. We'll have a better
// solution for this soon.
-layout(builtin=9999) vec4 gl_LastFragData[1];
-layout(builtin=9999) vec4 gl_LastFragColor;
-layout(builtin=9999) vec4 gl_LastFragColorARM;
+layout(builtin=9999) float4 gl_LastFragData[1];
+layout(builtin=9999) float4 gl_LastFragColor;
+layout(builtin=9999) float4 gl_LastFragColorARM;
layout(builtin=9999) int gl_SampleMaskIn[1];
layout(builtin=9999) out int gl_SampleMask[1];
-layout(builtin=9999) vec4 gl_SecondaryFragColorEXT;
+layout(builtin=9999) float4 gl_SecondaryFragColorEXT;
-layout(builtin=10003) vec4 sk_InColor;
-layout(builtin=10004) out vec4 sk_OutColor;
-layout(builtin=10005) vec2[] sk_TransformedCoords2D;
+layout(builtin=10003) float4 sk_InColor;
+layout(builtin=10004) out float4 sk_OutColor;
+layout(builtin=10005) float2[] sk_TransformedCoords2D;
layout(builtin=10006) sampler2D[] sk_TextureSamplers;
-vec4 COLORSPACE(vec4 color, colorSpaceXform colorSpace);
+float4 COLORSPACE(float4 color, colorSpaceXform colorSpace);
)
diff --git a/src/sksl/sksl_frag.include b/src/sksl/sksl_frag.include
index f1192fef59..2cd1e52413 100644
--- a/src/sksl/sksl_frag.include
+++ b/src/sksl/sksl_frag.include
@@ -2,20 +2,20 @@ STRINGIFY(
// defines built-in interfaces supported by SkiaSL fragment shaders
-layout(builtin=15) in vec4 sk_FragCoord;
+layout(builtin=15) in float4 sk_FragCoord;
layout(builtin=3) float sk_ClipDistance[1];
// 9999 is a temporary value that causes us to ignore these declarations beyond
// adding them to the symbol table. This works fine in GLSL (where they do not
// require any further handling) but will fail in SPIR-V. We'll have a better
// solution for this soon.
-layout(builtin=9999) vec4 gl_LastFragData[1];
-layout(builtin=9999) vec4 gl_LastFragColor;
-layout(builtin=9999) vec4 gl_LastFragColorARM;
+layout(builtin=9999) float4 gl_LastFragData[1];
+layout(builtin=9999) float4 gl_LastFragColor;
+layout(builtin=9999) float4 gl_LastFragColorARM;
layout(builtin=9999) int gl_SampleMaskIn[1];
layout(builtin=9999) out int gl_SampleMask[1];
-layout(builtin=9999) out vec4 gl_SecondaryFragColorEXT;
+layout(builtin=9999) out float4 gl_SecondaryFragColorEXT;
-layout(location=0,index=0,builtin=10001) out vec4 sk_FragColor;
+layout(location=0,index=0,builtin=10001) out float4 sk_FragColor;
)
diff --git a/src/sksl/sksl_geom.include b/src/sksl/sksl_geom.include
index e980d6bed9..f1b3604357 100644
--- a/src/sksl/sksl_geom.include
+++ b/src/sksl/sksl_geom.include
@@ -3,13 +3,13 @@ STRINGIFY(
// defines built-in interfaces supported by SkiaSL geometry shaders
layout(builtin=10002) in sk_PerVertex {
- layout(builtin=0) vec4 gl_Position;
+ layout(builtin=0) float4 gl_Position;
layout(builtin=1) float gl_PointSize;
layout(builtin=3) float sk_ClipDistance[];
} sk_in[];
out sk_PerVertex {
- layout(builtin=0) vec4 gl_Position;
+ layout(builtin=0) float4 gl_Position;
layout(builtin=1) float gl_PointSize;
layout(builtin=3) float sk_ClipDistance[];
};
diff --git a/src/sksl/sksl_vert.include b/src/sksl/sksl_vert.include
index 2c38a8b346..976877c6e7 100644
--- a/src/sksl/sksl_vert.include
+++ b/src/sksl/sksl_vert.include
@@ -3,7 +3,7 @@ STRINGIFY(
// defines built-in interfaces supported by SkiaSL vertex shaders
out sk_PerVertex {
- layout(builtin=0) vec4 gl_Position;
+ layout(builtin=0) float4 gl_Position;
layout(builtin=1) float gl_PointSize;
layout(builtin=3) float sk_ClipDistance[1];
};