aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-04-27 16:24:51 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-28 15:02:23 +0000
commitfe53e5828fd31326cdc4594ca06435eb0af50afe (patch)
tree045094ed7d60581dc8efafffd1889c0922ae3a03 /tests
parent93cb252c179c4c8a9aa0e51f76ae703e409306d5 (diff)
additional skslc vector optimizations
Bug: skia: Change-Id: I845d0952c281835a630882ae4026277c93ccf542 Reviewed-on: https://skia-review.googlesource.com/14406 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/SkSLGLSLTest.cpp146
1 files changed, 136 insertions, 10 deletions
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp
index 6951cac827..b945211eca 100644
--- a/tests/SkSLGLSLTest.cpp
+++ b/tests/SkSLGLSLTest.cpp
@@ -173,8 +173,8 @@ DEF_TEST(SkSLMatrices, r) {
"mat2x4 x = mat2x4(1);"
"mat3x2 y = mat3x2(1, 0, 0, 1, vec2(2, 2));"
"mat3x4 z = x * y;"
- "vec3 v1 = mat3(1) * vec3(1);"
- "vec3 v2 = vec3(1) * mat3(1);"
+ "vec3 v1 = mat3(1) * vec3(2);"
+ "vec3 v2 = vec3(2) * mat3(1);"
"sk_FragColor = vec4(z[0].x, v1 + v2);"
"}",
*SkSL::ShaderCapsFactory::Default(),
@@ -182,8 +182,8 @@ DEF_TEST(SkSLMatrices, r) {
"out vec4 sk_FragColor;\n"
"void main() {\n"
" mat3x4 z = mat2x4(1.0) * mat3x2(1.0, 0.0, 0.0, 1.0, vec2(2.0, 2.0));\n"
- " vec3 v1 = mat3(1.0) * vec3(1.0);\n"
- " vec3 v2 = vec3(1.0) * mat3(1.0);\n"
+ " vec3 v1 = mat3(1.0) * vec3(2.0);\n"
+ " vec3 v2 = vec3(2.0) * mat3(1.0);\n"
" sk_FragColor = vec4(z[0].x, v1 + v2);\n"
"}\n");
}
@@ -523,6 +523,25 @@ DEF_TEST(SkSLIntFolding, r) {
"sk_FragColor.r = 6 >= 7 ? 10 : -10;"
"sk_FragColor.r = 6 <= 6 ? 11 : -11;"
"sk_FragColor.r = 6 <= 5 ? 12 : -12;"
+ "sk_FragColor.r = int(sqrt(1)) + 0;"
+ "sk_FragColor.r = 0 + int(sqrt(2));"
+ "sk_FragColor.r = int(sqrt(3)) - 0;"
+ "sk_FragColor.r = int(sqrt(4)) * 0;"
+ "sk_FragColor.r = int(sqrt(5)) * 1;"
+ "sk_FragColor.r = 1 * int(sqrt(6));"
+ "sk_FragColor.r = 0 * int(sqrt(7));"
+ "sk_FragColor.r = int(sqrt(8)) / 1;"
+ "sk_FragColor.r = 0 / int(sqrt(9));"
+ "int x = int(sqrt(2));"
+ "x += 1;"
+ "x += 0;"
+ "x -= 1;"
+ "x -= 0;"
+ "x *= 1;"
+ "x *= 2;"
+ "x /= 1;"
+ "x /= 2;"
+ "sk_FragColor.r = x;"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -549,6 +568,21 @@ DEF_TEST(SkSLIntFolding, r) {
" sk_FragColor.x = -10.0;\n"
" sk_FragColor.x = 11.0;\n"
" sk_FragColor.x = -12.0;\n"
+ " sk_FragColor.x = float(int(sqrt(1.0)));\n"
+ " sk_FragColor.x = float(int(sqrt(2.0)));\n"
+ " sk_FragColor.x = float(int(sqrt(3.0)));\n"
+ " sk_FragColor.x = 0.0;\n"
+ " sk_FragColor.x = float(int(sqrt(5.0)));\n"
+ " sk_FragColor.x = float(int(sqrt(6.0)));\n"
+ " sk_FragColor.x = 0.0;\n"
+ " sk_FragColor.x = float(int(sqrt(8.0)));\n"
+ " sk_FragColor.x = 0.0;\n"
+ " int x = int(sqrt(2.0));\n"
+ " x += 1;\n"
+ " x -= 1;\n"
+ " x *= 2;\n"
+ " x /= 2;\n"
+ " sk_FragColor.x = float(x);\n"
"}\n");
}
@@ -572,6 +606,23 @@ DEF_TEST(SkSLFloatFolding, r) {
"sk_FragColor.r = 6.0 < 6.0 ? 10 : -10;"
"sk_FragColor.r = 6.0 <= 6.0 ? 11 : -11;"
"sk_FragColor.r = 6.0 <= 5.0 ? 12 : -12;"
+ "sk_FragColor.r = sqrt(1) + 0;"
+ "sk_FragColor.r = 0 + sqrt(2);"
+ "sk_FragColor.r = sqrt(3) - 0;"
+ "sk_FragColor.r = sqrt(4) * 0;"
+ "sk_FragColor.r = sqrt(5) * 1;"
+ "sk_FragColor.r = 1 * sqrt(6);"
+ "sk_FragColor.r = 0 * sqrt(7);"
+ "sk_FragColor.r = sqrt(8) / 1;"
+ "sk_FragColor.r = 0 / sqrt(9);"
+ "sk_FragColor.r += 1;"
+ "sk_FragColor.r += 0;"
+ "sk_FragColor.r -= 1;"
+ "sk_FragColor.r -= 0;"
+ "sk_FragColor.r *= 1;"
+ "sk_FragColor.r *= 2;"
+ "sk_FragColor.r /= 1;"
+ "sk_FragColor.r /= 2;"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -594,6 +645,19 @@ DEF_TEST(SkSLFloatFolding, r) {
" sk_FragColor.x = -10.0;\n"
" sk_FragColor.x = 11.0;\n"
" sk_FragColor.x = -12.0;\n"
+ " sk_FragColor.x = sqrt(1.0);\n"
+ " sk_FragColor.x = sqrt(2.0);\n"
+ " sk_FragColor.x = sqrt(3.0);\n"
+ " sk_FragColor.x = 0.0;\n"
+ " sk_FragColor.x = sqrt(5.0);\n"
+ " sk_FragColor.x = sqrt(6.0);\n"
+ " sk_FragColor.x = 0.0;\n"
+ " sk_FragColor.x = sqrt(8.0);\n"
+ " sk_FragColor.x = 0.0;\n"
+ " sk_FragColor.x += 1.0;\n"
+ " sk_FragColor.x -= 1.0;\n"
+ " sk_FragColor.x *= 2.0;\n"
+ " sk_FragColor.x /= 2.0;\n"
"}\n");
}
@@ -639,6 +703,39 @@ DEF_TEST(SkSLVecFolding, r) {
"sk_FragColor.x = vec4(vec3(1), 1) == vec4(vec2(1), 1, 0) ? 8.0 : -8.0;"
"sk_FragColor.x = vec2(1) != vec2(1, 0) ? 9.0 : -9.0;"
"sk_FragColor.x = vec4(1) != vec4(vec2(1), vec2(1)) ? 10.0 : -10.0;"
+ "sk_FragColor = vec4(sqrt(1)) * vec4(1);"
+ "sk_FragColor = vec4(1) * vec4(sqrt(2));"
+ "sk_FragColor = vec4(0) * vec4(sqrt(3));"
+ "sk_FragColor = vec4(sqrt(4)) * vec4(0);"
+ "sk_FragColor = vec4(0) / vec4(sqrt(5));"
+ "sk_FragColor = vec4(0) + vec4(sqrt(6));"
+ "sk_FragColor = vec4(sqrt(7)) + vec4(0);"
+ "sk_FragColor = vec4(sqrt(8)) - vec4(0);"
+ "sk_FragColor = vec4(0) + sqrt(9);"
+ "sk_FragColor = vec4(0) * sqrt(10);"
+ "sk_FragColor = vec4(0) / sqrt(11);"
+ "sk_FragColor = vec4(1) * sqrt(12);"
+ "sk_FragColor = 0 + vec4(sqrt(13));"
+ "sk_FragColor = 0 * vec4(sqrt(14));"
+ "sk_FragColor = 0 / vec4(sqrt(15));"
+ "sk_FragColor = 1 * vec4(sqrt(16));"
+ "sk_FragColor = vec4(sqrt(17)) + 0;"
+ "sk_FragColor = vec4(sqrt(18)) * 0;"
+ "sk_FragColor = vec4(sqrt(19)) * 1;"
+ "sk_FragColor = vec4(sqrt(19.5)) - 0;"
+ "sk_FragColor = sqrt(20) * vec4(1);"
+ "sk_FragColor = sqrt(21) + vec4(0);"
+ "sk_FragColor = sqrt(22) - vec4(0);"
+ "sk_FragColor = sqrt(23) / vec4(1);"
+ "sk_FragColor = vec4(sqrt(24)) / 1;"
+ "sk_FragColor += vec4(1);"
+ "sk_FragColor += vec4(0);"
+ "sk_FragColor -= vec4(1);"
+ "sk_FragColor -= vec4(0);"
+ "sk_FragColor *= vec4(1);"
+ "sk_FragColor *= vec4(2);"
+ "sk_FragColor /= vec4(1);"
+ "sk_FragColor /= vec4(2);"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
@@ -660,6 +757,35 @@ DEF_TEST(SkSLVecFolding, r) {
" sk_FragColor.x = -8.0;\n"
" sk_FragColor.x = 9.0;\n"
" sk_FragColor.x = -10.0;\n"
+ " sk_FragColor = vec4(sqrt(1.0));\n"
+ " sk_FragColor = vec4(sqrt(2.0));\n"
+ " sk_FragColor = vec4(0.0);\n"
+ " sk_FragColor = vec4(0.0);\n"
+ " sk_FragColor = vec4(0.0);\n"
+ " sk_FragColor = vec4(sqrt(6.0));\n"
+ " sk_FragColor = vec4(sqrt(7.0));\n"
+ " sk_FragColor = vec4(sqrt(8.0));\n"
+ " sk_FragColor = vec4(sqrt(9.0));\n"
+ " sk_FragColor = vec4(0.0);\n"
+ " sk_FragColor = vec4(0.0);\n"
+ " sk_FragColor = vec4(sqrt(12.0));\n"
+ " sk_FragColor = vec4(sqrt(13.0));\n"
+ " sk_FragColor = vec4(0.0);\n"
+ " sk_FragColor = vec4(0.0);\n"
+ " sk_FragColor = vec4(sqrt(16.0));\n"
+ " sk_FragColor = vec4(sqrt(17.0));\n"
+ " sk_FragColor = vec4(0.0);\n"
+ " sk_FragColor = vec4(sqrt(19.0));\n"
+ " sk_FragColor = vec4(sqrt(19.5));\n"
+ " sk_FragColor = vec4(sqrt(20.0));\n"
+ " sk_FragColor = vec4(sqrt(21.0));\n"
+ " sk_FragColor = vec4(sqrt(22.0));\n"
+ " sk_FragColor = vec4(sqrt(23.0));\n"
+ " sk_FragColor = vec4(sqrt(24.0));\n"
+ " sk_FragColor += vec4(1.0);\n"
+ " sk_FragColor -= vec4(1.0);\n"
+ " sk_FragColor *= vec4(2.0);\n"
+ " sk_FragColor /= vec4(2.0);\n"
"}\n");
}
@@ -1030,38 +1156,38 @@ DEF_TEST(SkSLRectangleTexture, r) {
test(r,
"uniform sampler2D test;"
"void main() {"
- " sk_FragColor = texture(test, vec2(1));"
+ " sk_FragColor = texture(test, vec2(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
"uniform sampler2D test;\n"
"void main() {\n"
- " sk_FragColor = texture(test, vec2(1.0));\n"
+ " sk_FragColor = texture(test, vec2(0.5));\n"
"}\n");
test(r,
"uniform sampler2DRect test;"
"void main() {"
- " sk_FragColor = texture(test, vec2(1));"
+ " sk_FragColor = texture(test, vec2(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
"uniform sampler2DRect test;\n"
"void main() {\n"
- " sk_FragColor = texture(test, textureSize(test) * vec2(1.0));\n"
+ " sk_FragColor = texture(test, textureSize(test) * vec2(0.5));\n"
"}\n");
test(r,
"uniform sampler2DRect test;"
"void main() {"
- " sk_FragColor = texture(test, vec3(1));"
+ " sk_FragColor = texture(test, vec3(0.5));"
"}",
*SkSL::ShaderCapsFactory::Default(),
"#version 400\n"
"out vec4 sk_FragColor;\n"
"uniform sampler2DRect test;\n"
"void main() {\n"
- " sk_FragColor = texture(test, vec3(textureSize(test), 1.0) * vec3(1.0));\n"
+ " sk_FragColor = texture(test, vec3(textureSize(test), 1.0) * vec3(0.5));\n"
"}\n");
}