diff options
author | Rob Clark <robdclark@chromium.org> | 2020-04-09 08:18:24 -0700 |
---|---|---|
committer | Rob Clark <robdclark@chromium.org> | 2020-04-09 08:21:42 -0700 |
commit | 31b22da39e37e3471497475b0f70cb7911a14f10 (patch) | |
tree | ad9af436a448f8b04008d69991b1e90416681773 /shaders/skia/1237.shader_test | |
parent | 7d3768722419076cb935399ff580ad0b99dfdb2c (diff) |
shaders: add skia shaders
Add shaders extracted from skia's unit tests[1]
[1] https://skia.org/dev/testing/testing
Diffstat (limited to 'shaders/skia/1237.shader_test')
-rw-r--r-- | shaders/skia/1237.shader_test | 322 |
1 files changed, 322 insertions, 0 deletions
diff --git a/shaders/skia/1237.shader_test b/shaders/skia/1237.shader_test new file mode 100644 index 0000000..80e3a20 --- /dev/null +++ b/shaders/skia/1237.shader_test @@ -0,0 +1,322 @@ +[require] +GLSL >= 1.40 + +[fragment shader] +#version 140 + +out vec4 sk_FragColor; +uniform vec2 uImageIncrement_Stage1_c0_c0; +uniform vec4 uKernel_Stage1_c0_c0[4]; +uniform vec2 uKernelOffset_Stage1_c0_c0; +uniform float uGain_Stage1_c0_c0; +uniform float uBias_Stage1_c0_c0; +uniform vec4 uTexDom_Stage1_c0_c0; +uniform sampler2D uTextureSampler_0_Stage1; +uniform sampler2D uTextureSampler_1_Stage1; +noperspective in vec4 vQuadEdge_Stage0; +noperspective in vec4 vinColor_Stage0; +noperspective in vec2 vTransformedCoords_0_Stage0; +vec4 MatrixConvolution_Stage1_c0_c0(vec4 _input) { + vec4 _output; + vec4 sum = vec4(0.0, 0.0, 0.0, 0.0); + vec2 coord = vTransformedCoords_0_Stage0 - uKernelOffset_Stage1_c0_c0 * uImageIncrement_Stage1_c0_c0; + vec4 c; + { + float k = uKernel_Stage1_c0_c0[0].x; + { + vec2 origCoord = coord; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[0].y; + { + vec2 origCoord = coord + vec2(1.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[0].z; + { + vec2 origCoord = coord + vec2(2.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[0].w; + { + vec2 origCoord = coord + vec2(3.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[1].x; + { + vec2 origCoord = coord + vec2(4.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[1].y; + { + vec2 origCoord = coord + vec2(5.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[1].z; + { + vec2 origCoord = coord + vec2(6.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[1].w; + { + vec2 origCoord = coord + vec2(7.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[2].x; + { + vec2 origCoord = coord + vec2(8.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[2].y; + { + vec2 origCoord = coord + vec2(9.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[2].z; + { + vec2 origCoord = coord + vec2(10.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[2].w; + { + vec2 origCoord = coord + vec2(11.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[3].x; + { + vec2 origCoord = coord + vec2(12.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[3].y; + { + vec2 origCoord = coord + vec2(13.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[3].z; + { + vec2 origCoord = coord + vec2(14.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + float k = uKernel_Stage1_c0_c0[3].w; + { + vec2 origCoord = coord + vec2(15.0, 0.0) * uImageIncrement_Stage1_c0_c0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + c.xyz /= c.w; + c.xyz = clamp(c.xyz, 0.0, 1.0); + sum += c * k; + } + { + vec2 origCoord = vTransformedCoords_0_Stage0; + vec2 clampedCoord; + clampedCoord = clamp(origCoord, uTexDom_Stage1_c0_c0.xy, uTexDom_Stage1_c0_c0.zw); + vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord); + c = textureColor; + } + _output.w = c.w; + _output.xyz = clamp(sum.xyz * uGain_Stage1_c0_c0 + uBias_Stage1_c0_c0, 0.0, 1.0); + _output.xyz *= _output.w; + _output *= _input; + return _output; +} +vec4 ColorTableEffect_Stage1_c1_c0(vec4 _input) { + vec4 _output; + float nonZeroAlpha = max(_input.w, 9.9999997473787516e-05); + vec4 coord = vec4(_input.xyz / nonZeroAlpha, nonZeroAlpha); + coord = coord * 0.9960939884185791 + vec4(0.0019529999699443579, 0.0019529999699443579, 0.0019529999699443579, 0.0019529999699443579); + _output.w = texture(uTextureSampler_1_Stage1, vec2(coord.w, 0.125)).w; + _output.x = texture(uTextureSampler_1_Stage1, vec2(coord.x, 0.375)).w; + _output.y = texture(uTextureSampler_1_Stage1, vec2(coord.y, 0.625)).w; + _output.z = texture(uTextureSampler_1_Stage1, vec2(coord.z, 0.875)).w; + _output.xyz *= _output.w; + return _output; +} +float _guarded_divide(float n, float d) { + return n / d; +} +float _color_dodge_component(float sc, float sa, float dc, float da) { + if (dc == 0.0) { + return sc * (1.0 - da); + } else { + float d = sa - sc; + if (d == 0.0) { + return (sa * da + sc * (1.0 - da)) + dc * (1.0 - sa); + } + d = min(da, _guarded_divide(dc * sa, d)); + return (d * sa + sc * (1.0 - da)) + dc * (1.0 - sa); + } +} +vec4 blend_color_dodge(vec4 src, vec4 dst) { + return vec4(_color_dodge_component(src.x, src.w, dst.x, dst.w), _color_dodge_component(src.y, src.w, dst.y, dst.w), _color_dodge_component(src.z, src.w, dst.z, dst.w), src.w + (1.0 - src.w) * dst.w); +} +void main() { + vec4 outputColor_Stage0; + vec4 outputCoverage_Stage0; + { + outputColor_Stage0 = vinColor_Stage0; + float edgeAlpha; + vec2 duvdx = dFdx(vQuadEdge_Stage0.xy); + vec2 duvdy = dFdy(vQuadEdge_Stage0.xy); + if (vQuadEdge_Stage0.z > 0.0 && vQuadEdge_Stage0.w > 0.0) { + edgeAlpha = min(min(vQuadEdge_Stage0.z, vQuadEdge_Stage0.w) + 0.5, 1.0); + } else { + vec2 gF = vec2((2.0 * vQuadEdge_Stage0.x) * duvdx.x - duvdx.y, (2.0 * vQuadEdge_Stage0.x) * duvdy.x - duvdy.y); + edgeAlpha = vQuadEdge_Stage0.x * vQuadEdge_Stage0.x - vQuadEdge_Stage0.y; + edgeAlpha = clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0); + } + outputCoverage_Stage0 = vec4(edgeAlpha); + } + vec4 output_Stage1; + { + vec4 inputColor = vec4(outputColor_Stage0.xyz, 1.0); + output_Stage1 = blend_color_dodge(MatrixConvolution_Stage1_c0_c0(inputColor), ColorTableEffect_Stage1_c1_c0(inputColor)); + output_Stage1 *= outputColor_Stage0.w; + } + { + sk_FragColor = output_Stage1 * outputCoverage_Stage0; + } +} + +[vertex shader] +#version 140 + +uniform vec4 sk_RTAdjust; +uniform mat3 uCoordTransformMatrix_0_Stage0; +in vec2 inPosition; +in vec4 inColor; +in vec4 inQuadEdge; +noperspective out vec4 vQuadEdge_Stage0; +noperspective out vec4 vinColor_Stage0; +noperspective out vec2 vTransformedCoords_0_Stage0; +void main() { + vQuadEdge_Stage0 = inQuadEdge; + vinColor_Stage0 = inColor; + vec2 pos2 = inPosition; + vTransformedCoords_0_Stage0 = (uCoordTransformMatrix_0_Stage0 * vec3(inPosition, 1.0)).xy; + gl_Position = vec4(pos2.x, pos2.y, 0.0, 1.0); + gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * sk_RTAdjust.yw, 0.0, gl_Position.w); +} + |