renamed SkSL texture() and process() to sample()

Bug: skia:
Change-Id: I2ae0caf08f8434302cae8151ae1ea0fda8d56928
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230397
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
Ethan Nicholas 2019-07-29 13:05:15 -04:00 committed by Skia Commit-Bot
parent 1dfb4d25d1
commit 1386366e01
43 changed files with 217 additions and 200 deletions

View File

@ -103,7 +103,7 @@ DEF_BENCH(return new SkSLBench("huge", R"(
half2 _dstTexCoord = (half2(sk_FragCoord.xy) - uDstTextureUpperLeft_Stage1) *
uDstTextureCoordScale_Stage1;
_dstTexCoord.y = 1.0 - _dstTexCoord.y;
half4 _dstColor = texture(uDstTextureSampler_Stage1, _dstTexCoord);
half4 _dstColor = sample(uDstTextureSampler_Stage1, _dstTexCoord);
sk_FragColor.a = outputColor_Stage0.a + (1.0 - outputColor_Stage0.a) * _dstColor.a;
half4 srcDstAlpha = outputColor_Stage0 * _dstColor.a;
sk_FragColor.rgb = set_luminance_Stage1(_dstColor.rgb * outputColor_Stage0.a,

View File

@ -36,7 +36,7 @@ layout(key) const in bool enforcePMColor;
in fragmentProcessor child;
void main(inout half4 color) {
half4 dst = process(child);
half4 dst = sample(child);
color = saturate(half(k.x) * color * dst + half(k.y) * color + half(k.z) * dst + half(k.w));
if (enforcePMColor) {
color.rgb = min(color.rgb, color.a);

View File

@ -45,7 +45,7 @@ in uniform half outerThreshold;
void main() {
half4 color = sk_InColor;
half4 mask_color = texture(mask, sk_TransformedCoords2D[0]);
half4 mask_color = sample(mask, sk_TransformedCoords2D[0]);
if (mask_color.a < 0.5) {
if (color.a > outerThreshold) {
half scale = outerThreshold / color.a;

View File

@ -281,7 +281,7 @@ void main() {
half2 vec = half2(half((sk_FragCoord.x - circleData.x) * circleData.w),
half((sk_FragCoord.y - circleData.y) * circleData.w));
half dist = length(vec) + (0.5 - circleData.z) * circleData.w;
sk_OutColor = sk_InColor * texture(blurProfileSampler, half2(dist, 0.5)).a;
sk_OutColor = sk_InColor * sample(blurProfileSampler, half2(dist, 0.5)).a;
}
@test(testData) {

View File

@ -10,7 +10,7 @@ in fragmentProcessor? child2;
in uniform float weight;
void main() {
sk_OutColor = mix(child1 != null ? process(child1) : sk_InColor,
child2 != null ? process(child2) : sk_InColor,
sk_OutColor = mix(child1 != null ? sample(child1) : sk_InColor,
child2 != null ? sample(child2) : sk_InColor,
half(weight));
}

View File

@ -10,7 +10,7 @@ in fragmentProcessor? child2;
in fragmentProcessor lerp;
void main() {
sk_OutColor = mix(child1 != null ? process(child1) : sk_InColor,
child2 != null ? process(child2) : sk_InColor,
process(lerp).r);
sk_OutColor = mix(child1 != null ? sample(child1) : sk_InColor,
child2 != null ? sample(child2) : sk_InColor,
sample(lerp).r);
}

View File

@ -38,7 +38,7 @@ void main() {
weight = min(min(delta_squared.x, delta_squared.y), 1.0);
}
sk_OutColor = texture(src, mix(coord, zoom_coord, weight));
sk_OutColor = sample(src, mix(coord, zoom_coord, weight));
}
@setData(pdman) {

View File

@ -39,8 +39,8 @@ in uniform half weight;
@optimizationFlags { OptFlags(fp0, fp1) }
void main() {
half4 in0 = process(fp0, sk_InColor);
half4 in1 = (fp1 != null) ? process(fp1, sk_InColor) : sk_InColor;
half4 in0 = sample(fp0, sk_InColor);
half4 in1 = (fp1 != null) ? sample(fp1, sk_InColor) : sk_InColor;
sk_OutColor = mix(in0, in1, weight);
}

View File

@ -51,5 +51,5 @@ void main() {
} else {
constColor = literalColor;
}
sk_OutColor = process(fp, constColor);
sk_OutColor = sample(fp, constColor);
}

View File

@ -192,7 +192,7 @@ void main() {
half2 proxyDims = half2(2.0 * threshold + 1.0);
half2 texCoord = translatedFragPos / proxyDims;
sk_OutColor = sk_InColor * texture(ninePatchSampler, texCoord);
sk_OutColor = sk_InColor * sample(ninePatchSampler, texCoord);
}
@setData(pdman) {

View File

@ -125,9 +125,9 @@ void main() {
float center = 2 * floor(profileSize / 2 + 0.25) - 1;
float2 wh = smallDims - float2(center, center);
half hcoord = half(((abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x)) / profileSize);
half hlookup = texture(blurProfile, float2(hcoord, 0.5)).a;
half hlookup = sample(blurProfile, float2(hcoord, 0.5)).a;
half vcoord = half(((abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y)) / profileSize);
half vlookup = texture(blurProfile, float2(vcoord, 0.5)).a;
half vlookup = sample(blurProfile, float2(vcoord, 0.5)).a;
sk_OutColor = sk_InColor * hlookup * vlookup;
} else {
half2 translatedPos = half2(sk_FragCoord.xy - rect.xy);
@ -137,9 +137,9 @@ void main() {
half center = 2 * floor(profileSize / 2 + 0.25) - 1;
half2 wh = smallDims - half2(center, center);
half hcoord = ((half(abs(translatedPos.x - 0.5 * width)) - 0.5 * wh.x)) / profileSize;
half hlookup = texture(blurProfile, float2(hcoord, 0.5)).a;
half hlookup = sample(blurProfile, float2(hcoord, 0.5)).a;
half vcoord = ((half(abs(translatedPos.y - 0.5 * height)) - 0.5 * wh.y)) / profileSize;
half vlookup = texture(blurProfile, float2(vcoord, 0.5)).a;
half vlookup = sample(blurProfile, float2(vcoord, 0.5)).a;
sk_OutColor = sk_InColor * hlookup * vlookup;
}
}

View File

@ -52,7 +52,7 @@ in half4x4 matrix;
}
void main() {
sk_OutColor = sk_InColor * texture(image, sk_TransformedCoords2D[0]);
sk_OutColor = sk_InColor * sample(image, sk_TransformedCoords2D[0]);
}
@test(testData) {

View File

@ -43,11 +43,11 @@ public:
"outerThreshold");
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
"half4 color = %s;\nhalf4 mask_color = texture(%s, %s).%s;\nif (mask_color.w < "
"0.5) {\n if (color.w > %s) {\n half scale = %s / color.w;\n "
"color.xyz *= scale;\n color.w = %s;\n }\n} else if (color.w < %s) {\n "
" half scale = %s / max(0.0010000000474974513, color.w);\n color.xyz *= "
"scale;\n color.w = %s;\n}\n%s = color;\n",
"half4 color = %s;\nhalf4 mask_color = sample(%s, %s).%s;\nif (mask_color.w < 0.5) "
"{\n if (color.w > %s) {\n half scale = %s / color.w;\n color.xyz "
"*= scale;\n color.w = %s;\n }\n} else if (color.w < %s) {\n half "
"scale = %s / max(0.0010000000474974513, color.w);\n color.xyz *= scale;\n "
"color.w = %s;\n}\n%s = color;\n",
args.fInputColor,
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]),
sk_TransformedCoords2D_0.c_str(),

View File

@ -275,7 +275,7 @@ public:
fragBuilder->codeAppendf(
"half2 vec = half2(half((sk_FragCoord.x - float(%s.x)) * float(%s.w)), "
"half((sk_FragCoord.y - float(%s.y)) * float(%s.w)));\nhalf dist = length(vec) + "
"(0.5 - %s.z) * %s.w;\n%s = %s * texture(%s, float2(half2(dist, 0.5))).%s.w;\n",
"(0.5 - %s.z) * %s.w;\n%s = %s * sample(%s, float2(half2(dist, 0.5))).%s.w;\n",
args.fUniformHandler->getUniformCStr(circleDataVar),
args.fUniformHandler->getUniformCStr(circleDataVar),
args.fUniformHandler->getUniformCStr(circleDataVar),

View File

@ -27,22 +27,22 @@ public:
(void)weight;
weightVar =
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat_GrSLType, "weight");
SkString _child0("_child0");
SkString _sample290("_sample290");
if (_outer.child1_index >= 0) {
this->invokeChild(_outer.child1_index, &_child0, args);
this->invokeChild(_outer.child1_index, &_sample290, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _child0.c_str());
fragBuilder->codeAppendf("half4 %s;", _sample290.c_str());
}
SkString _child1("_child1");
SkString _sample358("_sample358");
if (_outer.child2_index >= 0) {
this->invokeChild(_outer.child2_index, &_child1, args);
this->invokeChild(_outer.child2_index, &_sample358, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _child1.c_str());
fragBuilder->codeAppendf("half4 %s;", _sample358.c_str());
}
fragBuilder->codeAppendf("%s = mix(%s ? %s : %s, %s ? %s : %s, half(%s));\n",
args.fOutputColor, _outer.child1_index >= 0 ? "true" : "false",
_child0.c_str(), args.fInputColor,
_outer.child2_index >= 0 ? "true" : "false", _child1.c_str(),
_sample290.c_str(), args.fInputColor,
_outer.child2_index >= 0 ? "true" : "false", _sample358.c_str(),
args.fInputColor, args.fUniformHandler->getUniformCStr(weightVar));
}

View File

@ -23,24 +23,24 @@ public:
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrComposeLerpRedEffect& _outer = args.fFp.cast<GrComposeLerpRedEffect>();
(void)_outer;
SkString _child0("_child0");
SkString _sample292("_sample292");
if (_outer.child1_index >= 0) {
this->invokeChild(_outer.child1_index, &_child0, args);
this->invokeChild(_outer.child1_index, &_sample292, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _child0.c_str());
fragBuilder->codeAppendf("half4 %s;", _sample292.c_str());
}
SkString _child1("_child1");
SkString _sample360("_sample360");
if (_outer.child2_index >= 0) {
this->invokeChild(_outer.child2_index, &_child1, args);
this->invokeChild(_outer.child2_index, &_sample360, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _child1.c_str());
fragBuilder->codeAppendf("half4 %s;", _sample360.c_str());
}
SkString _child2("_child2");
this->invokeChild(_outer.lerp_index, &_child2, args);
SkString _sample411("_sample411");
this->invokeChild(_outer.lerp_index, &_sample411, args);
fragBuilder->codeAppendf("%s = mix(%s ? %s : %s, %s ? %s : %s, %s.x);\n", args.fOutputColor,
_outer.child1_index >= 0 ? "true" : "false", _child0.c_str(),
_outer.child1_index >= 0 ? "true" : "false", _sample292.c_str(),
args.fInputColor, _outer.child2_index >= 0 ? "true" : "false",
_child1.c_str(), args.fInputColor, _child2.c_str());
_sample360.c_str(), args.fInputColor, _sample411.c_str());
}
private:

View File

@ -65,7 +65,7 @@ public:
args.fUniformHandler->getUniformCStr(xInvInsetVar),
args.fUniformHandler->getUniformCStr(yInvInsetVar));
fragBuilder->codeAppendf(
"d.y), 1.0);\n}\n%s = texture(%s, mix(coord, zoom_coord, weight)).%s;\n",
"d.y), 1.0);\n}\n%s = sample(%s, mix(coord, zoom_coord, weight)).%s;\n",
args.fOutputColor,
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());

View File

@ -28,18 +28,18 @@ public:
weightVar =
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType, "weight");
SkString _input0 = SkStringPrintf("%s", args.fInputColor);
SkString _child0("_child0");
this->invokeChild(_outer.fp0_index, _input0.c_str(), &_child0, args);
fragBuilder->codeAppendf("half4 in0 = %s;", _child0.c_str());
SkString _sample1278("_sample1278");
this->invokeChild(_outer.fp0_index, _input0.c_str(), &_sample1278, args);
fragBuilder->codeAppendf("half4 in0 = %s;", _sample1278.c_str());
SkString _input1 = SkStringPrintf("%s", args.fInputColor);
SkString _child1("_child1");
SkString _sample1335("_sample1335");
if (_outer.fp1_index >= 0) {
this->invokeChild(_outer.fp1_index, _input1.c_str(), &_child1, args);
this->invokeChild(_outer.fp1_index, _input1.c_str(), &_sample1335, args);
} else {
fragBuilder->codeAppendf("half4 %s;", _child1.c_str());
fragBuilder->codeAppendf("half4 %s;", _sample1335.c_str());
}
fragBuilder->codeAppendf("\nhalf4 in1 = %s ? %s : %s;\n%s = mix(in0, in1, %s);\n",
_outer.fp1_index >= 0 ? "true" : "false", _child1.c_str(),
_outer.fp1_index >= 0 ? "true" : "false", _sample1335.c_str(),
args.fInputColor, args.fOutputColor,
args.fUniformHandler->getUniformCStr(weightVar));
}

View File

@ -43,9 +43,9 @@ public:
_outer.literalColor.fR, _outer.literalColor.fG, _outer.literalColor.fB,
_outer.literalColor.fA);
SkString _input0("constColor");
SkString _child0("_child0");
this->invokeChild(_outer.fp_index, _input0.c_str(), &_child0, args);
fragBuilder->codeAppendf("\n%s = %s;\n", args.fOutputColor, _child0.c_str());
SkString _sample1992("_sample1992");
this->invokeChild(_outer.fp_index, _input0.c_str(), &_sample1992, args);
fragBuilder->codeAppendf("\n%s = %s;\n", args.fOutputColor, _sample1992.c_str());
}
private:

View File

@ -91,7 +91,7 @@ public:
"\n} else if (translatedFragPos.y >= middle.y + threshold) {\n "
"translatedFragPos.y -= middle.y - 1.0;\n}\nhalf2 proxyDims = half2(2.0 * "
"threshold + 1.0);\nhalf2 texCoord = translatedFragPos / proxyDims;\n%s = %s * "
"texture(%s, float2(texCoord)).%s;\n",
"sample(%s, float2(texCoord)).%s;\n",
args.fOutputColor, args.fInputColor,
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());

View File

@ -51,7 +51,7 @@ public:
"height - float(%s));\n float center = float(2.0 * floor(%s / 2.0 + 0.25) - "
"1.0);\n float2 wh = smallDims - float2(center, center);\n half hcoord = "
"half((abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x) / float(%s));\n half "
"hlookup = texture(%s, float2(float(hcoord), 0.5)).",
"hlookup = sample(%s, float2(float(hcoord), 0.5)).%s",
(highPrecision ? "true" : "false"), args.fUniformHandler->getUniformCStr(rectVar),
args.fUniformHandler->getUniformCStr(rectVar),
args.fUniformHandler->getUniformCStr(rectVar),
@ -61,16 +61,16 @@ public:
args.fUniformHandler->getUniformCStr(profileSizeVar),
args.fUniformHandler->getUniformCStr(profileSizeVar),
args.fUniformHandler->getUniformCStr(profileSizeVar),
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]));
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
fragBuilder->codeAppendf(
"%s.w;\n half vcoord = half((abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y) "
"/ float(%s));\n half vlookup = texture(%s, float2(float(vcoord), 0.5)).%s.w;\n "
" %s = (%s * hlookup) * vlookup;\n} else {\n half2 translatedPos = "
".w;\n half vcoord = half((abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y) / "
"float(%s));\n half vlookup = sample(%s, float2(float(vcoord), 0.5)).%s.w;\n "
"%s = (%s * hlookup) * vlookup;\n} else {\n half2 translatedPos = "
"half2(sk_FragCoord.xy - %s.xy);\n half width = half(%s.z - %s.x);\n half "
"height = half(%s.w - %s.y);\n half2 smallDims = half2(width - %s, height - "
"%s);\n half center = 2.0 * floor(%s / 2.0 + 0.25) - 1.0;\n half2 wh = "
"smallDims - half2(center, center);\n half ",
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
"smallDims - half2(center, center);\n half hco",
args.fUniformHandler->getUniformCStr(profileSizeVar),
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
@ -83,10 +83,10 @@ public:
args.fUniformHandler->getUniformCStr(profileSizeVar),
args.fUniformHandler->getUniformCStr(profileSizeVar));
fragBuilder->codeAppendf(
"hcoord = (abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x) / %s;\n half "
"hlookup = texture(%s, float2(float(hcoord), 0.5)).%s.w;\n half vcoord = "
"ord = (abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x) / %s;\n half hlookup = "
"sample(%s, float2(float(hcoord), 0.5)).%s.w;\n half vcoord = "
"(abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y) / %s;\n half vlookup = "
"texture(%s, float2(float(vcoord), 0.5)).%s.w;\n %s = (%s * hlookup) * "
"sample(%s, float2(float(vcoord), 0.5)).%s.w;\n %s = (%s * hlookup) * "
"vlookup;\n}\n",
args.fUniformHandler->getUniformCStr(profileSizeVar),
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]),

View File

@ -27,7 +27,7 @@ public:
(void)matrix;
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
"%s = %s * texture(%s, %s).%s;\n", args.fOutputColor, args.fInputColor,
"%s = %s * sample(%s, %s).%s;\n", args.fOutputColor, args.fInputColor,
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]),
sk_TransformedCoords2D_0.c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());

View File

@ -3287,7 +3287,7 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
fshaderTxt.appendf(
"// Copy Program FS\n"
"void main() {"
" sk_FragColor = texture(u_texture, v_texCoord);"
" sk_FragColor = sample(u_texture, v_texCoord);"
"}"
);
@ -3427,19 +3427,19 @@ bool GrGLGpu::createMipmapProgram(int progIdx) {
if (oddWidth && oddHeight) {
fshaderTxt.append(
" sk_FragColor = (texture(u_texture, v_texCoord0) + "
" texture(u_texture, v_texCoord1) + "
" texture(u_texture, v_texCoord2) + "
" texture(u_texture, v_texCoord3)) * 0.25;"
" sk_FragColor = (sample(u_texture, v_texCoord0) + "
" sample(u_texture, v_texCoord1) + "
" sample(u_texture, v_texCoord2) + "
" sample(u_texture, v_texCoord3)) * 0.25;"
);
} else if (oddWidth || oddHeight) {
fshaderTxt.append(
" sk_FragColor = (texture(u_texture, v_texCoord0) + "
" texture(u_texture, v_texCoord1)) * 0.5;"
" sk_FragColor = (sample(u_texture, v_texCoord0) + "
" sample(u_texture, v_texCoord1)) * 0.5;"
);
} else {
fshaderTxt.append(
" sk_FragColor = texture(u_texture, v_texCoord0);"
" sk_FragColor = sample(u_texture, v_texCoord0);"
);
}

View File

@ -71,7 +71,7 @@ void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
const char* coordName,
GrSLType varyingType) const {
const char* sampler = fProgramBuilder->samplerVariable(samplerHandle);
out->appendf("texture(%s, %s)", sampler, coordName);
out->appendf("sample(%s, %s)", sampler, coordName);
append_texture_swizzle(out, fProgramBuilder->samplerSwizzle(samplerHandle));
}

View File

@ -25,7 +25,7 @@ layout(key) in bool makePremul;
in bool colorsAreOpaque;
void main() {
half4 t = process(gradLayout);
half4 t = sample(gradLayout);
// If t.x is below 0, use the left border color without invoking the child processor. If any t.x
// is above 1, use the right border color. Otherwise, t is in the [0, 1] range assumed by the
// colorizer FP, so delegate to the child processor.
@ -38,7 +38,7 @@ void main() {
} else if (t.x > 1.0) {
sk_OutColor = rightBorderColor;
} else {
sk_OutColor = process(colorizer, t);
sk_OutColor = sample(colorizer, t);
}
@if(makePremul) {

View File

@ -14,5 +14,5 @@ in uniform sampler2D gradient;
void main() {
half2 coord = half2(sk_InColor.x, 0.5);
sk_OutColor = texture(gradient, coord);
sk_OutColor = sample(gradient, coord);
}

View File

@ -16,7 +16,7 @@ layout(key) in bool makePremul;
in bool colorsAreOpaque;
void main() {
half4 t = process(gradLayout);
half4 t = sample(gradLayout);
if (!gradLayout.preservesOpaqueInput && t.y < 0) {
// layout has rejected this fragment (rely on sksl to remove this branch if the layout FP
@ -40,7 +40,7 @@ void main() {
// t.x has been tiled (repeat or mirrored), but pass through remaining 3 components
// unmodified.
sk_OutColor = process(colorizer, t);
sk_OutColor = sample(colorizer, t);
}
@if (makePremul) {

View File

@ -35,22 +35,22 @@ public:
kHalf4_GrSLType, "leftBorderColor");
rightBorderColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag,
kHalf4_GrSLType, "rightBorderColor");
SkString _child1("_child1");
this->invokeChild(_outer.gradLayout_index, &_child1, args);
SkString _sample1099("_sample1099");
this->invokeChild(_outer.gradLayout_index, &_sample1099, args);
fragBuilder->codeAppendf(
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else if (t.x < "
"0.0) {\n %s = %s;\n} else if (t.x > 1.0) {\n %s = %s;\n} else {",
_child1.c_str(),
_sample1099.c_str(),
(_outer.childProcessor(_outer.gradLayout_index).preservesOpaqueInput() ? "true"
: "false"),
args.fOutputColor, args.fOutputColor,
args.fUniformHandler->getUniformCStr(leftBorderColorVar), args.fOutputColor,
args.fUniformHandler->getUniformCStr(rightBorderColorVar));
SkString _input0("t");
SkString _child0("_child0");
this->invokeChild(_outer.colorizer_index, _input0.c_str(), &_child0, args);
SkString _sample1767("_sample1767");
this->invokeChild(_outer.colorizer_index, _input0.c_str(), &_sample1767, args);
fragBuilder->codeAppendf("\n %s = %s;\n}\n@if (%s) {\n %s.xyz *= %s.w;\n}\n",
args.fOutputColor, _child0.c_str(),
args.fOutputColor, _sample1767.c_str(),
(_outer.makePremul ? "true" : "false"), args.fOutputColor,
args.fOutputColor);
}

View File

@ -24,7 +24,7 @@ public:
const GrTextureGradientColorizer& _outer = args.fFp.cast<GrTextureGradientColorizer>();
(void)_outer;
fragBuilder->codeAppendf(
"half2 coord = half2(%s.x, 0.5);\n%s = texture(%s, float2(coord)).%s;\n",
"half2 coord = half2(%s.x, 0.5);\n%s = sample(%s, float2(coord)).%s;\n",
args.fInputColor, args.fOutputColor,
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());

View File

@ -29,23 +29,23 @@ public:
(void)makePremul;
auto colorsAreOpaque = _outer.colorsAreOpaque;
(void)colorsAreOpaque;
SkString _child1("_child1");
this->invokeChild(_outer.gradLayout_index, &_child1, args);
SkString _sample453("_sample453");
this->invokeChild(_outer.gradLayout_index, &_sample453, args);
fragBuilder->codeAppendf(
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else {\n @if "
"(%s) {\n half t_1 = t.x - 1.0;\n half tiled_t = (t_1 - 2.0 * "
"floor(t_1 * 0.5)) - 1.0;\n if (sk_Caps.mustDoOpBetweenFloorAndAbs) {\n "
" tiled_t = clamp(tiled_t, -1.0, 1.0);\n }\n t.x = "
"abs(tiled_t);\n } else {\n t.x = fract(t.x);\n }",
_child1.c_str(),
_sample453.c_str(),
(_outer.childProcessor(_outer.gradLayout_index).preservesOpaqueInput() ? "true"
: "false"),
args.fOutputColor, (_outer.mirror ? "true" : "false"));
SkString _input0("t");
SkString _child0("_child0");
this->invokeChild(_outer.colorizer_index, _input0.c_str(), &_child0, args);
SkString _sample1464("_sample1464");
this->invokeChild(_outer.colorizer_index, _input0.c_str(), &_sample1464, args);
fragBuilder->codeAppendf("\n %s = %s;\n}\n@if (%s) {\n %s.xyz *= %s.w;\n}\n",
args.fOutputColor, _child0.c_str(),
args.fOutputColor, _sample1464.c_str(),
(_outer.makePremul ? "true" : "false"), args.fOutputColor,
args.fOutputColor);
}

View File

@ -58,8 +58,8 @@ Differences from GLSL
* The last swizzle component, in addition to the normal rgba / xyzw components,
can also be the constants '0' or '1'. foo.rgb1 is equivalent to
float4(foo.rgb, 1).
* Use texture() instead of textureProj(), e.g. texture(sampler2D, float3) is
equivalent to GLSL's textureProj(sampler2D, float3)
* All texture functions are named "sample", e.g. sample(sampler2D, float3) is
equivalent to GLSL's textureProj(sampler2D, float3).
* Render target width and height are available via sk_Width and sk_Height
* some built-in functions and one or two rarely-used language features are not
yet supported (sorry!)
@ -144,7 +144,7 @@ Within an '.fp' fragment processor file:
which causes the key to consider only whether or not the matrix is an
identity matrix.
* child processors can be declared with 'in fragmentProcessor <name>;', and can
be invoked by calling 'process(<name>)' or 'process(<name>, <inputColor>)'.
be invoked by calling 'sample(<name>)' or 'sample(<name>, <inputColor>)'.
The first variant emits the child with a solid white input color. The second
variant emits the child with the result of the 2nd argument's expression,
which must evaluate to a half4. The process function returns a half4.

View File

@ -27,6 +27,7 @@ CPPCodeGenerator::CPPCodeGenerator(const Context* context, const Program* progra
, fFullName(String::printf("Gr%s", fName.c_str()))
, fSectionAndParameterHelper(*program, *errors) {
fLineEnding = "\\n";
fTextureFunctionOverride = "sample";
}
void CPPCodeGenerator::writef(const char* s, va_list va) {
@ -404,18 +405,19 @@ int CPPCodeGenerator::getChildFPIndex(const Variable& var) const {
}
void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (c.fFunction.fBuiltin && c.fFunction.fName == "process") {
if (c.fFunction.fBuiltin && c.fFunction.fName == "sample" &&
c.fArguments[0]->fType.kind() != Type::Kind::kSampler_Kind) {
// Sanity checks that are detected by function definition in sksl_fp.inc
SkASSERT(c.fArguments.size() == 1 || c.fArguments.size() == 2);
SkASSERT("fragmentProcessor" == c.fArguments[0]->fType.name() ||
"fragmentProcessor?" == c.fArguments[0]->fType.name());
// Actually fail during compilation if arguments with valid types are
// provided that are not variable references, since process() is a
// provided that are not variable references, since sample() is a
// special function that impacts code emission.
if (c.fArguments[0]->fKind != Expression::kVariableReference_Kind) {
fErrors.error(c.fArguments[0]->fOffset,
"process()'s fragmentProcessor argument must be a variable reference\n");
"sample()'s fragmentProcessor argument must be a variable reference\n");
return;
}
if (c.fArguments.size() > 1) {
@ -445,7 +447,7 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
}
// Write the output handling after the possible input handling
String childName = "_child" + to_string(index);
String childName = "_sample" + to_string(c.fOffset);
addExtraEmitCodeLine("SkString " + childName + "(\"" + childName + "\");");
if (c.fArguments[0]->fType.kind() == Type::kNullable_Kind) {
addExtraEmitCodeLine("if (_outer." + String(child.fName) + "_index >= 0) {\n ");
@ -468,7 +470,7 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
return;
}
INHERITED::writeFunctionCall(c);
if (c.fFunction.fBuiltin && c.fFunction.fName == "texture") {
if (c.fFunction.fBuiltin && c.fFunction.fName == "sample") {
this->write(".%s");
SkASSERT(c.fArguments.size() >= 1);
SkASSERT(c.fArguments[0]->fKind == Expression::kVariableReference_Kind);

View File

@ -470,7 +470,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
(*fFunctionClasses)["min"] = FunctionClass::kMin;
(*fFunctionClasses)["pow"] = FunctionClass::kPow;
(*fFunctionClasses)["saturate"] = FunctionClass::kSaturate;
(*fFunctionClasses)["texture"] = FunctionClass::kTexture;
(*fFunctionClasses)["sample"] = FunctionClass::kTexture;
(*fFunctionClasses)["transpose"] = FunctionClass::kTranspose;
}
#ifndef SKSL_STANDALONE
@ -670,12 +670,16 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) {
proj = false;
break;
}
this->write("texture");
if (fProgram.fSettings.fCaps->generation() < k130_GrGLSLGeneration) {
this->write(dim);
}
if (proj) {
this->write("Proj");
if (fTextureFunctionOverride != "") {
this->write(fTextureFunctionOverride.c_str());
} else {
this->write("texture");
if (fProgram.fSettings.fCaps->generation() < k130_GrGLSLGeneration) {
this->write(dim);
}
if (proj) {
this->write("Proj");
}
}
nameWritten = true;
break;

View File

@ -219,6 +219,8 @@ protected:
bool fSetupFragPositionGlobal = false;
bool fSetupFragPositionLocal = false;
bool fSetupFragCoordWorkaround = false;
// if non-empty, replace all texture / texture2D / textureProj / etc. calls with this name
String fTextureFunctionOverride;
// We map function names to function class so we can quickly deal with function calls that need
// extra processing

View File

@ -24,7 +24,7 @@ namespace SkSL {
void MetalCodeGenerator::setupIntrinsics() {
#define METAL(x) std::make_pair(kMetal_IntrinsicKind, k ## x ## _MetalIntrinsic)
#define SPECIAL(x) std::make_pair(kSpecial_IntrinsicKind, k ## x ## _SpecialIntrinsic)
fIntrinsicMap[String("texture")] = SPECIAL(Texture);
fIntrinsicMap[String("sample")] = SPECIAL(Texture);
fIntrinsicMap[String("mod")] = SPECIAL(Mod);
fIntrinsicMap[String("equal")] = METAL(Equal);
fIntrinsicMap[String("notEqual")] = METAL(NotEqual);

View File

@ -78,8 +78,11 @@ void PipelineStageCodeGenerator::writeBinaryExpression(const BinaryExpression& b
}
void PipelineStageCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (c.fFunction.fBuiltin && c.fFunction.fName == "process") {
if (c.fFunction.fBuiltin && c.fFunction.fName == "sample" &&
c.fArguments[0]->fType.kind() != Type::Kind::kSampler_Kind) {
SkASSERT(c.fArguments.size() == 1);
SkASSERT("fragmentProcessor" == c.fArguments[0]->fType.name() ||
"fragmentProcessor?" == c.fArguments[0]->fType.name());
SkASSERT(Expression::kVariableReference_Kind == c.fArguments[0]->fKind);
int index = 0;
bool found = false;

View File

@ -103,7 +103,7 @@ void SPIRVCodeGenerator::setupIntrinsics() {
SpvOpUndef, SpvOpUndef, SpvOpUndef);
fIntrinsicMap[String("makeSampler2D")] = SPECIAL(SampledImage);
fIntrinsicMap[String("texture")] = SPECIAL(Texture);
fIntrinsicMap[String("sample")] = SPECIAL(Texture);
fIntrinsicMap[String("subpassLoad")] = SPECIAL(SubpassLoad);
fIntrinsicMap[String("any")] = std::make_tuple(kSPIRV_IntrinsicKind, SpvOpUndef,

View File

@ -23,8 +23,8 @@ layout(builtin=10006) sampler2D[] sk_TextureSamplers;
layout(builtin=10011) half sk_Width;
layout(builtin=10012) half sk_Height;
half4 process(fragmentProcessor fp);
half4 process(fragmentProcessor fp, half4 input);
half4 process(fragmentProcessor? fp);
half4 process(fragmentProcessor? fp, half4 input);
half4 sample(fragmentProcessor fp);
half4 sample(fragmentProcessor fp, half4 input);
half4 sample(fragmentProcessor? fp);
half4 sample(fragmentProcessor? fp, half4 input);
)

View File

@ -257,27 +257,27 @@ $genIType findMSB($genUType value);
sampler2D makeSampler2D(texture2D texture, sampler sampler);
int2 textureSize($gsampler2DRect sampler);
half4 texture($gsampler1D sampler, float P);
half4 texture($gsampler1D sampler, float P, float bias);
half4 texture($gsampler2D sampler, float2 P);
half4 sample($gsampler1D sampler, float P);
half4 sample($gsampler1D sampler, float P, float bias);
half4 sample($gsampler2D sampler, float2 P);
// The above currently only expand to handle the float/fixed case. So we also declare this integer
// version of texture().
int4 texture(isampler2D sampler, float2 P);
half4 texture(samplerExternalOES sampler, float2 P, float bias);
half4 texture(samplerExternalOES sampler, float2 P);
// version of sample().
int4 sample(isampler2D sampler, float2 P);
half4 sample(samplerExternalOES sampler, float2 P, float bias);
half4 sample(samplerExternalOES sampler, float2 P);
half4 texture($gsampler2DRect sampler, float2 P);
half4 texture($gsampler2DRect sampler, float3 P);
half4 sample($gsampler2DRect sampler, float2 P);
half4 sample($gsampler2DRect sampler, float3 P);
// Currently we do not support the generic types of loading subpassInput so we have some explicit
// versions that we currently use
float4 subpassLoad(subpassInput subpass);
float4 subpassLoad(subpassInputMS subpass, int sample);
half4 texture($gsampler1D sampler, float2 P);
half4 texture($gsampler1D sampler, float2 P, float bias);
half4 texture($gsampler2D sampler, float3 P);
half4 texture($gsampler2D sampler, float3 P, float bias);
half4 sample($gsampler1D sampler, float2 P);
half4 sample($gsampler1D sampler, float2 P, float bias);
half4 sample($gsampler2D sampler, float3 P);
half4 sample($gsampler2D sampler, float3 P, float bias);
float4 imageLoad(image2D image, int2 P);
int4 imageLoad(iimage2D image, int2 P);

View File

@ -4,5 +4,5 @@ in fragmentProcessor _child2;
layout(builtin=10004) out half4 sk_OutColor;
half4 process(fragmentProcessor fp);
half4 sample(fragmentProcessor fp);
)

View File

@ -17,5 +17,5 @@ STRINGIFY(
layout(builtin=10010) int sk_y;
layout(builtin=10004) out half4 sk_OutColor;
half4 process(fragmentProcessor fp);
half4 sample(fragmentProcessor fp);
)

View File

@ -458,7 +458,7 @@ DEF_TEST(SkSLFPChildProcessors, r) {
"in fragmentProcessor child1;"
"in fragmentProcessor child2;"
"void main() {"
" sk_OutColor = process(child1) * process(child2);"
" sk_OutColor = sample(child1) * sample(child2);"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@ -466,10 +466,12 @@ DEF_TEST(SkSLFPChildProcessors, r) {
"this->registerChildProcessor(std::move(child2));"
},
{
"SkString _child0(\"_child0\");",
"this->invokeChild(_outer.child1_index, &_child0, args);",
"SkString _child1(\"_child1\");",
"this->invokeChild(_outer.child2_index, &_child1, args);",
"SkString _sample93(\"_sample93\");\n",
"this->invokeChild(_outer.child1_index, &_sample93, args);\n",
"SkString _sample110(\"_sample110\");\n",
"this->invokeChild(_outer.child2_index, &_sample110, args);\n",
"fragBuilder->codeAppendf(\"%s = %s * %s;\\n\", args.fOutputColor, _sample93.c_str(), "
"_sample110.c_str());\n",
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
});
@ -481,8 +483,8 @@ DEF_TEST(SkSLFPChildProcessorsWithInput, r) {
"in fragmentProcessor child2;"
"void main() {"
" half4 childIn = sk_InColor;"
" half4 childOut1 = process(child1, childIn);"
" half4 childOut2 = process(child2, childOut1);"
" half4 childOut1 = sample(child1, childIn);"
" half4 childOut2 = sample(child2, childOut1);"
" sk_OutColor = childOut2;"
"}",
*SkSL::ShaderCapsFactory::Default(),
@ -492,11 +494,12 @@ DEF_TEST(SkSLFPChildProcessorsWithInput, r) {
},
{
"SkString _input0(\"childIn\");",
"SkString _child0(\"_child0\");",
"this->invokeChild(_outer.child1_index, _input0.c_str(), &_child0, args);",
"SkString _sample128(\"_sample128\");",
"this->invokeChild(_outer.child1_index, _input0.c_str(), &_sample128, args);",
"fragBuilder->codeAppendf(\"\\nhalf4 childOut1 = %s;\", _sample128.c_str());",
"SkString _input1(\"childOut1\");",
"SkString _child1(\"_child1\");",
"this->invokeChild(_outer.child2_index, _input1.c_str(), &_child1, args);",
"SkString _sample174(\"_sample174\");",
"this->invokeChild(_outer.child2_index, _input1.c_str(), &_sample174, args);",
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
});
@ -506,7 +509,7 @@ DEF_TEST(SkSLFPChildProcessorWithInputExpression, r) {
test(r,
"in fragmentProcessor child;"
"void main() {"
" sk_OutColor = process(child, sk_InColor * half4(0.5));"
" sk_OutColor = sample(child, sk_InColor * half4(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@ -514,8 +517,9 @@ DEF_TEST(SkSLFPChildProcessorWithInputExpression, r) {
},
{
"SkString _input0 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
"SkString _child0(\"_child0\");",
"this->invokeChild(_outer.child_index, _input0.c_str(), &_child0, args);",
"SkString _sample64(\"_sample64\");",
"this->invokeChild(_outer.child_index, _input0.c_str(), &_sample64, args);",
"fragBuilder->codeAppendf(\"%s = %s;\\n\", args.fOutputColor, _sample64.c_str());",
"this->registerChildProcessor(src.childProcessor(child_index).clone());",
});
}
@ -525,7 +529,7 @@ DEF_TEST(SkSLFPNestedChildProcessors, r) {
"in fragmentProcessor child1;"
"in fragmentProcessor child2;"
"void main() {"
" sk_OutColor = process(child2, sk_InColor * process(child1, sk_InColor * half4(0.5)));"
" sk_OutColor = sample(child2, sk_InColor * sample(child1, sk_InColor * half4(0.5)));"
"}",
*SkSL::ShaderCapsFactory::Default(),
{
@ -534,11 +538,12 @@ DEF_TEST(SkSLFPNestedChildProcessors, r) {
},
{
"SkString _input0 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
"SkString _child0(\"_child0\");",
"this->invokeChild(_outer.child1_index, _input0.c_str(), &_child0, args);",
"SkString _input1 = SkStringPrintf(\"%s * %s\", args.fInputColor, _child0.c_str());",
"SkString _child1(\"_child1\");",
"this->invokeChild(_outer.child2_index, _input1.c_str(), &_child1, args);",
"SkString _sample121(\"_sample121\");",
"this->invokeChild(_outer.child1_index, _input0.c_str(), &_sample121, args);",
"SkString _input1 = SkStringPrintf(\"%s * %s\", args.fInputColor, _sample121.c_str());",
"SkString _sample93(\"_sample93\");",
"this->invokeChild(_outer.child2_index, _input1.c_str(), &_sample93, args);",
"fragBuilder->codeAppendf(\"%s = %s;\\n\", args.fOutputColor, _sample93.c_str());",
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
});
@ -550,7 +555,7 @@ DEF_TEST(SkSLFPChildFPAndGlobal, r) {
"bool hasCap = sk_Caps.externalTextureSupport;"
"void main() {"
" if (hasCap) {"
" sk_OutColor = process(child, sk_InColor);"
" sk_OutColor = sample(child, sk_InColor);"
" } else {"
" sk_OutColor = half4(1);"
" }"
@ -561,13 +566,14 @@ DEF_TEST(SkSLFPChildFPAndGlobal, r) {
},
{
"hasCap = sk_Caps.externalTextureSupport;",
"fragBuilder->codeAppendf(\"bool hasCap = %s;\\nif (hasCap) {\", "
"(hasCap ? \"true\" : \"false\"));",
"fragBuilder->codeAppendf(\"bool hasCap = %s;\\nif (hasCap) {\", (hasCap ? \"true\" : "
"\"false\"));",
"SkString _input0 = SkStringPrintf(\"%s\", args.fInputColor);",
"SkString _child0(\"_child0\");",
"this->invokeChild(_outer.child_index, _input0.c_str(), &_child0, args);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}"
"\\n\", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
"SkString _sample130(\"_sample130\");",
"this->invokeChild(_outer.child_index, _input0.c_str(), &_sample130, args);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}\\n\","
" args.fOutputColor, _sample130.c_str(), args.fOutputColor);",
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
});
}
@ -577,7 +583,7 @@ DEF_TEST(SkSLFPChildProcessorInlineFieldAccess, r) {
"in fragmentProcessor child;"
"void main() {"
" if (child.preservesOpaqueInput) {"
" sk_OutColor = process(child, sk_InColor);"
" sk_OutColor = sample(child, sk_InColor);"
" } else {"
" sk_OutColor = half4(1);"
" }"
@ -588,13 +594,12 @@ DEF_TEST(SkSLFPChildProcessorInlineFieldAccess, r) {
},
{
"fragBuilder->codeAppendf(\"if (%s) {\", "
"(_outer.childProcessor(_outer.child_index).preservesOpaqueInput() ? "
"\"true\" : \"false\"));",
"(_outer.childProcessor(_outer.child_index).preservesOpaqueInput() ? ",
"SkString _input0 = SkStringPrintf(\"%s\", args.fInputColor);",
"SkString _child0(\"_child0\");",
"this->invokeChild(_outer.child_index, _input0.c_str(), &_child0, args);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}\\n\""
", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
"SkString _sample105(\"_sample105\");",
"this->invokeChild(_outer.child_index, _input0.c_str(), &_sample105, args);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}\\n\","
" args.fOutputColor, _sample105.c_str(), args.fOutputColor);",
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
});
}
@ -605,7 +610,7 @@ DEF_TEST(SkSLFPChildProcessorFieldAccess, r) {
"bool opaque = child.preservesOpaqueInput;"
"void main() {"
" if (opaque) {"
" sk_OutColor = process(child);"
" sk_OutColor = sample(child);"
" } else {"
" sk_OutColor = half4(0.5);"
" }"
@ -616,12 +621,12 @@ DEF_TEST(SkSLFPChildProcessorFieldAccess, r) {
},
{
"opaque = _outer.childProcessor(_outer.child_index).preservesOpaqueInput();",
"fragBuilder->codeAppendf(\"bool opaque = %s;\\nif (opaque) {\", "
"(opaque ? \"true\" : \"false\"));",
"SkString _child0(\"_child0\");",
"this->invokeChild(_outer.child_index, &_child0, args);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(0.5);\\n}\\n\""
", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
"fragBuilder->codeAppendf(\"bool opaque = %s;\\nif (opaque) {\", (opaque ? \"true\" : "
"\"false\"));",
"SkString _sample126(\"_sample126\");",
"this->invokeChild(_outer.child_index, &_sample126, args);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(0.5);\\n}\\n\","
" args.fOutputColor, _sample126.c_str(), args.fOutputColor);",
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
});
}
@ -631,7 +636,7 @@ DEF_TEST(SkSLFPNullableChildProcessor, r) {
"in fragmentProcessor? child;"
"void main() {"
" if (child != null) {"
" sk_OutColor = process(child);"
" sk_OutColor = sample(child);"
" } else {"
" sk_OutColor = half4(0.5);"
" }"
@ -639,13 +644,14 @@ DEF_TEST(SkSLFPNullableChildProcessor, r) {
*SkSL::ShaderCapsFactory::Default(),
{},
{
"SkString _child0(\"_child0\");",
"fragBuilder->codeAppendf(\"if (%s) {\", _outer.child_index >= 0 ? \"true\" : "
"\"false\");",
"SkString _sample93(\"_sample93\");",
"if (_outer.child_index >= 0) {",
"this->invokeChild(_outer.child_index, &_child0, args);",
"} else {",
"fragBuilder->codeAppendf(\"half4 %s;\", _child0.c_str());",
"this->invokeChild(_outer.child_index, &_sample93, args);",
"}",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(0.5);\\n}\\n\""
", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(0.5);\\n}\\n\","
" args.fOutputColor, _sample93.c_str(), args.fOutputColor);"
});
}

View File

@ -1047,10 +1047,10 @@ DEF_TEST(SkSLTexture, r) {
"uniform sampler1D one;"
"uniform sampler2D two;"
"void main() {"
"float4 a = texture(one, 0);"
"float4 b = texture(two, float2(0));"
"float4 c = texture(one, float2(0));"
"float4 d = texture(two, float3(0));"
"float4 a = sample(one, 0);"
"float4 b = sample(two, float2(0));"
"float4 c = sample(one, float2(0));"
"float4 d = sample(two, float3(0));"
"sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));"
"}",
*SkSL::ShaderCapsFactory::Default(),
@ -1069,10 +1069,10 @@ DEF_TEST(SkSLTexture, r) {
"uniform sampler1D one;"
"uniform sampler2D two;"
"void main() {"
"float4 a = texture(one, 0);"
"float4 b = texture(two, float2(0));"
"float4 c = texture(one, float2(0));"
"float4 d = texture(two, float3(0));"
"float4 a = sample(one, 0);"
"float4 b = sample(two, float2(0));"
"float4 c = sample(one, float2(0));"
"float4 d = sample(two, float3(0));"
"sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));"
"}",
*SkSL::ShaderCapsFactory::Version110(),
@ -1098,10 +1098,10 @@ DEF_TEST(SkSLSharpen, r) {
"uniform sampler1D one;"
"uniform sampler2D two;"
"void main() {"
"float4 a = texture(one, 0);"
"float4 b = texture(two, float2(0));"
"float4 c = texture(one, float2(0));"
"float4 d = texture(two, float3(0));"
"float4 a = sample(one, 0);"
"float4 b = sample(two, float2(0));"
"float4 c = sample(one, float2(0));"
"float4 d = sample(two, float3(0));"
"sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));"
"}",
settings,
@ -1124,10 +1124,10 @@ DEF_TEST(SkSLSharpen, r) {
"uniform sampler1D one;"
"uniform sampler2D two;"
"void main() {"
"float4 a = texture(one, 0);"
"float4 b = texture(two, float2(0));"
"float4 c = texture(one, float2(0));"
"float4 d = texture(two, float3(0));"
"float4 a = sample(one, 0);"
"float4 b = sample(two, float2(0));"
"float4 c = sample(one, float2(0));"
"float4 d = sample(two, float3(0));"
"sk_FragColor = half4(half(a.x), half(b.x), half(c.x), half(d.x));"
"}",
settings,
@ -1607,7 +1607,7 @@ DEF_TEST(SkSLRectangleTexture, r) {
test(r,
"uniform sampler2D test;"
"void main() {"
" sk_FragColor = texture(test, float2(0.5));"
" sk_FragColor = sample(test, float2(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@ -1619,7 +1619,7 @@ DEF_TEST(SkSLRectangleTexture, r) {
test(r,
"uniform sampler2DRect test;"
"void main() {"
" sk_FragColor = texture(test, float2(0.5));"
" sk_FragColor = sample(test, float2(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@ -1631,7 +1631,7 @@ DEF_TEST(SkSLRectangleTexture, r) {
test(r,
"uniform sampler2DRect test;"
"void main() {"
" sk_FragColor = texture(test, float3(0.5));"
" sk_FragColor = sample(test, float3(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@ -1687,7 +1687,7 @@ DEF_TEST(SkSLComplexDelete, r) {
"uniform sampler2D sampler;"
"void main() {"
"float4 tmpColor;"
"sk_FragColor = half4(1.0) * (tmpColor = texture(sampler, float2(1)) , "
"sk_FragColor = half4(1.0) * (tmpColor = sample(sampler, float2(1)) , "
"half4(colorXform != float4x4(1.0) ? float4(clamp((float4x4(colorXform) * "
"float4(tmpColor.xyz, 1.0)).xyz, "
"0.0, tmpColor.w), tmpColor.w) : tmpColor));"
@ -2090,7 +2090,7 @@ DEF_TEST(SkSLIncompleteShortIntPrecision, r) {
"in short2 offset;"
"void main() {"
" short scalar = offset.y;"
" sk_FragColor = texture(tex, texcoord + float2(offset * scalar));"
" sk_FragColor = sample(tex, texcoord + float2(offset * scalar));"
"}",
*SkSL::ShaderCapsFactory::UsesPrecisionModifiers(),
"#version 400\n"
@ -2110,7 +2110,7 @@ DEF_TEST(SkSLIncompleteShortIntPrecision, r) {
"in short2 offset;"
"void main() {"
" short scalar = offset.y;"
" sk_FragColor = texture(tex, texcoord + float2(offset * scalar));"
" sk_FragColor = sample(tex, texcoord + float2(offset * scalar));"
"}",
*SkSL::ShaderCapsFactory::IncompleteShortIntPrecision(),
"#version 310es\n"