skia2/resources/sksl/shared/GaussianBlur.sksl
John Stiles bfc9be0f77 Migrate SkSL test inputs to the resources/ directory.
This will allow us to load these inputs for unit testing in `dm`.

Change-Id: Id256ba7c30d3ec94b98048e47af44cf9efe580d5
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357282
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-22 18:57:29 +00:00

137 lines
5.3 KiB
Plaintext

layout(binding=0) uniform sampler2D uTextureSampler_0_Stage1;
layout (binding=0) uniform uniformBuffer
{
layout(offset=0) float4 sk_RTAdjust;
layout(offset=16) half2 uIncrement_Stage1_c0;
layout(offset=32) half4 uKernel_Stage1_c0[7];
layout(offset=144) float3x3 umatrix_Stage1_c0_c0;
layout(offset=192) half4 uborder_Stage1_c0_c0_c0;
layout(offset=208) float4 usubset_Stage1_c0_c0_c0;
layout(offset=224) float4 unorm_Stage1_c0_c0_c0;
};
layout(location = 0) in float2 vLocalCoord_Stage0;
layout(location = 0, index = 0) out half4 sk_FragColor;
half4 TextureEffect_Stage1_c0_c0_c0(half4 _input, float2 _coords)
{
half4 _output;
float2 inCoord = _coords;
inCoord *= unorm_Stage1_c0_c0_c0.xy;
float2 subsetCoord;
subsetCoord.x = inCoord.x;
subsetCoord.y = inCoord.y;
float2 clampedCoord;
clampedCoord = subsetCoord;
half4 textureColor = sample(uTextureSampler_0_Stage1, (clampedCoord) * unorm_Stage1_c0_c0_c0.zw);
float snappedX = floor(inCoord.x + 0.001) + 0.5;
if (snappedX < usubset_Stage1_c0_c0_c0.x || snappedX > usubset_Stage1_c0_c0_c0.z)
{
textureColor = uborder_Stage1_c0_c0_c0;
}
return textureColor;
}
half4 MatrixEffect_Stage1_c0_c0(half4 _input, float2 _coords)
{
half4 _output;
return TextureEffect_Stage1_c0_c0_c0(_input, ((umatrix_Stage1_c0_c0) * _coords.xy1).xy);
}
inline half4 GaussianConvolution_Stage1_c0(half4 _input)
{
half4 _output;
_output = half4(0, 0, 0, 0);
float2 coord = vLocalCoord_Stage0 - 12.0 * uIncrement_Stage1_c0;
float2 coordSampled = half2(0, 0);
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[0].x;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[0].y;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[0].z;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[0].w;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[1].x;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[1].y;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[1].z;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[1].w;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[2].x;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[2].y;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[2].z;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[2].w;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[3].x;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[3].y;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[3].z;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[3].w;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[4].x;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[4].y;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[4].z;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[4].w;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[5].x;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[5].y;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[5].z;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[5].w;
coord += uIncrement_Stage1_c0;
coordSampled = coord;
_output += MatrixEffect_Stage1_c0_c0(_input, coordSampled) * uKernel_Stage1_c0[6].x;
coord += uIncrement_Stage1_c0;
_output *= _input;
return _output;
}
void main()
{
half4 outputColor_Stage0;
half4 outputCoverage_Stage0;
{
// Stage 0, QuadPerEdgeAAGeometryProcessor
outputColor_Stage0 = half4(1);
outputCoverage_Stage0 = half4(1);
}
half4 output_Stage1;
output_Stage1 = GaussianConvolution_Stage1_c0(outputColor_Stage0);
{
// Xfer Processor: Porter Duff
sk_FragColor = output_Stage1 * outputCoverage_Stage0;
}
}