From 8a83ca4e9afc9e3c08b4e8c33a74392f9b3154d7 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Mon, 12 Feb 2018 14:32:17 -0500 Subject: Add "sharpen" option to SkSL, to LOD bias all textures This adds a fixed bias (-0.5) to the computed LOD of all mip-mapped texture fetches. (Technically, to all texture fetches, but that only matters for mip-mapped ones). Clients can opt-in with a new GrContextOption. Bug: skia:7541 Bug: chromium:562162 Change-Id: Ie3cd0679c4ab66f62d2dc32e7e68e5c99355115e Reviewed-on: https://skia-review.googlesource.com/106322 Reviewed-by: Brian Salomon Reviewed-by: Ethan Nicholas Commit-Queue: Brian Osman --- tests/SkSLGLSLTest.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'tests/SkSLGLSLTest.cpp') diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp index 62c5cd6955..e63719781d 100644 --- a/tests/SkSLGLSLTest.cpp +++ b/tests/SkSLGLSLTest.cpp @@ -983,6 +983,62 @@ DEF_TEST(SkSLTexture, r) { "}\n"); } +DEF_TEST(SkSLSharpen, r) { + SkSL::Program::Settings settings; + settings.fSharpenTextures = true; + sk_sp caps = SkSL::ShaderCapsFactory::Default(); + settings.fCaps = caps.get(); + SkSL::Program::Inputs inputs; + test(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));" + "sk_FragColor = half4(a.x, b.x, c.x, d.x);" + "}", + settings, + "#version 400\n" + "out vec4 sk_FragColor;\n" + "uniform sampler1D one;\n" + "uniform sampler2D two;\n" + "void main() {\n" + " vec4 a = texture(one, 0.0, -0.5);\n" + " vec4 b = texture(two, vec2(0.0), -0.5);\n" + " vec4 c = textureProj(one, vec2(0.0), -0.5);\n" + " vec4 d = textureProj(two, vec3(0.0), -0.5);\n" + " sk_FragColor = vec4(a.x, b.x, c.x, d.x);\n" + "}\n", + &inputs); + + caps = SkSL::ShaderCapsFactory::Version110(); + settings.fCaps = caps.get(); + test(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));" + "sk_FragColor = half4(a.x, b.x, c.x, d.x);" + "}", + settings, + "#version 110\n" + "uniform sampler1D one;\n" + "uniform sampler2D two;\n" + "void main() {\n" + " vec4 a = texture1D(one, 0.0, -0.5);\n" + " vec4 b = texture2D(two, vec2(0.0), -0.5);\n" + " vec4 c = texture1DProj(one, vec2(0.0), -0.5);\n" + " vec4 d = texture2DProj(two, vec3(0.0), -0.5);\n" + " gl_FragColor = vec4(a.x, b.x, c.x, d.x);\n" + "}\n", + &inputs); +} + DEF_TEST(SkSLOffset, r) { test(r, "struct Test {" -- cgit v1.2.3