John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 Google LLC |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "gm/gm.h" |
| 9 | #include "include/core/SkBitmap.h" |
| 10 | #include "include/core/SkCanvas.h" |
| 11 | #include "include/core/SkData.h" |
| 12 | #include "include/core/SkFont.h" |
| 13 | #include "include/core/SkPaint.h" |
| 14 | #include "include/core/SkSize.h" |
| 15 | #include "include/core/SkString.h" |
| 16 | #include "include/core/SkSurface.h" |
| 17 | #include "include/effects/SkGradientShader.h" |
| 18 | #include "include/effects/SkImageFilters.h" |
| 19 | #include "include/effects/SkRuntimeEffect.h" |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 20 | #include "include/private/SkSLDefines.h" // for kDefaultInlineThreshold |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 21 | #include "include/utils/SkRandom.h" |
Brian Osman | e9ab391 | 2021-07-02 10:17:45 -0400 | [diff] [blame] | 22 | #include "src/core/SkRuntimeEffectPriv.h" |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 23 | #include "src/gpu/GrCaps.h" |
| 24 | #include "src/gpu/GrDirectContextPriv.h" |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 25 | #include "tests/Test.h" |
| 26 | #include "tools/Resources.h" |
| 27 | #include "tools/ToolUtils.h" |
| 28 | |
John Stiles | 0dc09b1 | 2021-09-15 17:42:42 -0400 | [diff] [blame] | 29 | static constexpr int kWidth = 2; |
| 30 | static constexpr int kHeight = 2; |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 31 | |
John Stiles | b41d5bb | 2021-01-26 16:28:12 -0500 | [diff] [blame] | 32 | template <typename T> |
| 33 | static void set_uniform(SkRuntimeShaderBuilder* builder, const char* name, const T& value) { |
| 34 | SkRuntimeShaderBuilder::BuilderUniform uniform = builder->uniform(name); |
| 35 | if (uniform.fVar) { |
| 36 | uniform = value; |
| 37 | } |
| 38 | } |
| 39 | |
John Stiles | d80f966 | 2021-02-03 11:42:32 -0500 | [diff] [blame] | 40 | static void test_one_permutation(skiatest::Reporter* r, |
| 41 | SkSurface* surface, |
| 42 | const char* testFile, |
| 43 | const char* permutationSuffix, |
| 44 | const SkRuntimeEffect::Options& options) { |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 45 | SkString resourcePath = SkStringPrintf("sksl/%s", testFile); |
| 46 | sk_sp<SkData> shaderData = GetResourceAsData(resourcePath.c_str()); |
| 47 | if (!shaderData) { |
John Stiles | d80f966 | 2021-02-03 11:42:32 -0500 | [diff] [blame] | 48 | ERRORF(r, "%s%s: Unable to load file", testFile, permutationSuffix); |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 49 | return; |
| 50 | } |
| 51 | |
| 52 | SkString shaderString{reinterpret_cast<const char*>(shaderData->bytes()), shaderData->size()}; |
Brian Osman | 169c890 | 2021-04-21 14:27:08 -0400 | [diff] [blame] | 53 | SkRuntimeEffect::Result result = SkRuntimeEffect::MakeForShader(shaderString, options); |
John Stiles | d80f966 | 2021-02-03 11:42:32 -0500 | [diff] [blame] | 54 | if (!result.effect) { |
| 55 | ERRORF(r, "%s%s: %s", testFile, permutationSuffix, result.errorText.c_str()); |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 56 | return; |
| 57 | } |
| 58 | |
John Stiles | d80f966 | 2021-02-03 11:42:32 -0500 | [diff] [blame] | 59 | SkRuntimeShaderBuilder builder(result.effect); |
John Stiles | e1658b5 | 2021-01-29 11:44:13 -0500 | [diff] [blame] | 60 | set_uniform(&builder, "colorBlack", SkV4{0, 0, 0, 1}); |
| 61 | set_uniform(&builder, "colorRed", SkV4{1, 0, 0, 1}); |
| 62 | set_uniform(&builder, "colorGreen", SkV4{0, 1, 0, 1}); |
| 63 | set_uniform(&builder, "colorBlue", SkV4{0, 0, 1, 1}); |
| 64 | set_uniform(&builder, "colorWhite", SkV4{1, 1, 1, 1}); |
| 65 | set_uniform(&builder, "testInputs", SkV4{-1.25, 0, 0.75, 2.25}); |
John Stiles | 01cdf01 | 2021-02-10 09:53:41 -0500 | [diff] [blame] | 66 | set_uniform(&builder, "testMatrix2x2", std::array<float,4>{1, 2, |
| 67 | 3, 4}); |
| 68 | set_uniform(&builder, "testMatrix3x3", std::array<float,9>{1, 2, 3, |
| 69 | 4, 5, 6, |
| 70 | 7, 8, 9}); |
John Stiles | e1658b5 | 2021-01-29 11:44:13 -0500 | [diff] [blame] | 71 | set_uniform(&builder, "unknownInput", 1.0f); |
John Stiles | a0e407d | 2021-02-10 12:21:51 -0500 | [diff] [blame] | 72 | set_uniform(&builder, "testMatrix2x2", std::array<float,4>{1, 2, |
| 73 | 3, 4}); |
| 74 | set_uniform(&builder, "testMatrix3x3", std::array<float,9>{1, 2, 3, |
| 75 | 4, 5, 6, |
| 76 | 7, 8, 9}); |
John Stiles | b41d5bb | 2021-01-26 16:28:12 -0500 | [diff] [blame] | 77 | |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 78 | sk_sp<SkShader> shader = builder.makeShader(/*localMatrix=*/nullptr, /*isOpaque=*/true); |
| 79 | if (!shader) { |
John Stiles | d80f966 | 2021-02-03 11:42:32 -0500 | [diff] [blame] | 80 | ERRORF(r, "%s%s: Unable to build shader", testFile, permutationSuffix); |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 81 | return; |
| 82 | } |
| 83 | |
| 84 | SkPaint paintShader; |
| 85 | paintShader.setShader(shader); |
John Stiles | 0dc09b1 | 2021-09-15 17:42:42 -0400 | [diff] [blame] | 86 | surface->getCanvas()->drawRect(SkRect::MakeWH(kWidth, kHeight), paintShader); |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 87 | |
| 88 | SkBitmap bitmap; |
| 89 | REPORTER_ASSERT(r, bitmap.tryAllocPixels(surface->imageInfo())); |
| 90 | REPORTER_ASSERT(r, surface->readPixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), |
| 91 | /*srcX=*/0, /*srcY=*/0)); |
| 92 | |
John Stiles | 0dc09b1 | 2021-09-15 17:42:42 -0400 | [diff] [blame] | 93 | bool success = true; |
| 94 | SkColor color[kHeight][kWidth]; |
| 95 | for (int y = 0; y < kHeight; ++y) { |
| 96 | for (int x = 0; x < kWidth; ++x) { |
| 97 | color[y][x] = bitmap.getColor(x, y); |
| 98 | if (color[y][x] != SkColorSetARGB(0xFF, 0x00, 0xFF, 0x00)) { |
| 99 | success = false; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | if (!success) { |
| 105 | static_assert(kWidth == 2); |
| 106 | static_assert(kHeight == 2); |
| 107 | ERRORF(r, "Expected: solid green. Actual:\n" |
| 108 | "RRGGBBAA RRGGBBAA\n" |
| 109 | "%02X%02X%02X%02X %02X%02X%02X%02X\n" |
| 110 | "%02X%02X%02X%02X %02X%02X%02X%02X", |
| 111 | SkColorGetR(color[0][0]), SkColorGetG(color[0][0]), |
| 112 | SkColorGetB(color[0][0]), SkColorGetA(color[0][0]), |
| 113 | |
| 114 | SkColorGetR(color[0][1]), SkColorGetG(color[0][1]), |
| 115 | SkColorGetB(color[0][1]), SkColorGetA(color[0][1]), |
| 116 | |
| 117 | SkColorGetR(color[1][0]), SkColorGetG(color[1][0]), |
| 118 | SkColorGetB(color[1][0]), SkColorGetA(color[1][0]), |
| 119 | |
| 120 | SkColorGetR(color[1][1]), SkColorGetG(color[1][1]), |
| 121 | SkColorGetB(color[1][1]), SkColorGetA(color[1][1])); |
| 122 | } |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 123 | } |
| 124 | |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 125 | static void test_permutations(skiatest::Reporter* r, |
| 126 | SkSurface* surface, |
| 127 | const char* testFile, |
| 128 | bool worksInES2) { |
Brian Osman | e9ab391 | 2021-07-02 10:17:45 -0400 | [diff] [blame] | 129 | SkRuntimeEffect::Options options = |
| 130 | worksInES2 ? SkRuntimeEffect::Options{} : SkRuntimeEffectPriv::ES3Options(); |
John Stiles | 9d26af9 | 2021-03-23 09:25:33 -0400 | [diff] [blame] | 131 | options.forceNoInline = false; |
John Stiles | d80f966 | 2021-02-03 11:42:32 -0500 | [diff] [blame] | 132 | test_one_permutation(r, surface, testFile, "", options); |
John Stiles | 9d26af9 | 2021-03-23 09:25:33 -0400 | [diff] [blame] | 133 | |
| 134 | options.forceNoInline = true; |
| 135 | test_one_permutation(r, surface, testFile, " (NoInline)", options); |
John Stiles | d80f966 | 2021-02-03 11:42:32 -0500 | [diff] [blame] | 136 | } |
| 137 | |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 138 | static void test_cpu(skiatest::Reporter* r, const char* testFile) { |
John Stiles | 0dc09b1 | 2021-09-15 17:42:42 -0400 | [diff] [blame] | 139 | const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 140 | sk_sp<SkSurface> surface(SkSurface::MakeRaster(info)); |
| 141 | |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 142 | test_permutations(r, surface.get(), testFile, /*worksInES2=*/true); |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | static void test_gpu(skiatest::Reporter* r, GrDirectContext* ctx, const char* testFile) { |
John Stiles | 0dc09b1 | 2021-09-15 17:42:42 -0400 | [diff] [blame] | 146 | const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 147 | sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info)); |
| 148 | |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 149 | test_permutations(r, surface.get(), testFile, /*worksInES2=*/true); |
| 150 | } |
| 151 | |
| 152 | static void test_es3(skiatest::Reporter* r, GrDirectContext* ctx, const char* testFile) { |
John Stiles | 0733d48 | 2021-08-18 12:17:21 -0400 | [diff] [blame] | 153 | if (!ctx->priv().caps()->shaderCaps()->supportsSkSLES3()) { |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 154 | return; |
| 155 | } |
| 156 | // ES3-only tests never run on the CPU, because SkVM lacks support for many non-ES2 features. |
John Stiles | 0dc09b1 | 2021-09-15 17:42:42 -0400 | [diff] [blame] | 157 | const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 158 | sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info)); |
| 159 | |
| 160 | test_permutations(r, surface.get(), testFile, /*worksInES2=*/false); |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 161 | } |
| 162 | |
John Stiles | b441850 | 2021-02-04 10:57:08 -0500 | [diff] [blame] | 163 | #define SKSL_TEST_CPU(name, path) \ |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 164 | DEF_TEST(name ## _CPU, r) { \ |
| 165 | test_cpu(r, path); \ |
John Stiles | b441850 | 2021-02-04 10:57:08 -0500 | [diff] [blame] | 166 | } |
| 167 | #define SKSL_TEST_GPU(name, path) \ |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 168 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name ## _GPU, r, ctxInfo) { \ |
| 169 | test_gpu(r, ctxInfo.directContext(), path); \ |
| 170 | } |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 171 | #define SKSL_TEST_ES3(name, path) \ |
| 172 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name ## _GPU, r, ctxInfo) { \ |
| 173 | test_es3(r, ctxInfo.directContext(), path); \ |
| 174 | } |
John Stiles | b441850 | 2021-02-04 10:57:08 -0500 | [diff] [blame] | 175 | #define SKSL_TEST(name, path) SKSL_TEST_CPU(name, path) SKSL_TEST_GPU(name, path) |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 176 | |
John Stiles | 34c098d | 2021-02-09 10:38:59 -0500 | [diff] [blame] | 177 | SKSL_TEST(SkSLAssignmentOps, "folding/AssignmentOps.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 178 | SKSL_TEST(SkSLBoolFolding, "folding/BoolFolding.sksl") |
John Stiles | 27193d4 | 2021-05-07 11:16:26 -0400 | [diff] [blame] | 179 | SKSL_TEST(SkSLCastFolding, "folding/CastFolding.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 180 | SKSL_TEST(SkSLIntFoldingES2, "folding/IntFoldingES2.sksl") |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 181 | SKSL_TEST_ES3(SkSLIntFoldingES3, "folding/IntFoldingES3.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 182 | SKSL_TEST(SkSLFloatFolding, "folding/FloatFolding.sksl") |
Brian Osman | 169c890 | 2021-04-21 14:27:08 -0400 | [diff] [blame] | 183 | // skbug.com/11919: Fails on Nexus5/7, and Intel GPUs |
| 184 | SKSL_TEST_CPU(SkSLMatrixFoldingES2, "folding/MatrixFoldingES2.sksl") |
Brian Osman | 8e756f3 | 2021-02-10 10:19:27 -0500 | [diff] [blame] | 185 | SKSL_TEST(SkSLSelfAssignment, "folding/SelfAssignment.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 186 | SKSL_TEST(SkSLShortCircuitBoolFolding, "folding/ShortCircuitBoolFolding.sksl") |
John Stiles | fb7d378 | 2021-04-29 11:14:38 -0400 | [diff] [blame] | 187 | SKSL_TEST(SkSLSwizzleFolding, "folding/SwizzleFolding.sksl") |
John Stiles | 03467a5 | 2021-03-04 15:19:48 +0000 | [diff] [blame] | 188 | SKSL_TEST(SkSLVectorScalarFolding, "folding/VectorScalarFolding.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 189 | SKSL_TEST(SkSLVectorVectorFolding, "folding/VectorVectorFolding.sksl") |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 190 | |
John Stiles | d2c5a80 | 2021-05-19 21:42:57 -0400 | [diff] [blame] | 191 | SKSL_TEST_ES3(SkSLDoWhileBodyMustBeInlinedIntoAScope, |
| 192 | "inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl") |
| 193 | SKSL_TEST_ES3(SkSLDoWhileTestCannotBeInlined, "inliner/DoWhileTestCannotBeInlined.sksl") |
John Stiles | 0c9d888 | 2021-03-25 17:04:36 -0400 | [diff] [blame] | 194 | SKSL_TEST(SkSLForBodyMustBeInlinedIntoAScope, "inliner/ForBodyMustBeInlinedIntoAScope.sksl") |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 195 | SKSL_TEST_ES3(SkSLForInitializerExpressionsCanBeInlined, |
| 196 | "inliner/ForInitializerExpressionsCanBeInlined.sksl") |
John Stiles | 0c9d888 | 2021-03-25 17:04:36 -0400 | [diff] [blame] | 197 | SKSL_TEST(SkSLForWithoutReturnInsideCanBeInlined, "inliner/ForWithoutReturnInsideCanBeInlined.sksl") |
| 198 | SKSL_TEST(SkSLForWithReturnInsideCannotBeInlined, "inliner/ForWithReturnInsideCannotBeInlined.sksl") |
| 199 | SKSL_TEST(SkSLIfBodyMustBeInlinedIntoAScope, "inliner/IfBodyMustBeInlinedIntoAScope.sksl") |
| 200 | SKSL_TEST(SkSLIfElseBodyMustBeInlinedIntoAScope, "inliner/IfElseBodyMustBeInlinedIntoAScope.sksl") |
| 201 | SKSL_TEST(SkSLIfElseChainWithReturnsCanBeInlined, "inliner/IfElseChainWithReturnsCanBeInlined.sksl") |
| 202 | SKSL_TEST(SkSLIfTestCanBeInlined, "inliner/IfTestCanBeInlined.sksl") |
| 203 | SKSL_TEST(SkSLIfWithReturnsCanBeInlined, "inliner/IfWithReturnsCanBeInlined.sksl") |
| 204 | SKSL_TEST(SkSLInlineKeywordOverridesThreshold, "inliner/InlineKeywordOverridesThreshold.sksl") |
| 205 | SKSL_TEST(SkSLInlinerAvoidsVariableNameOverlap, "inliner/InlinerAvoidsVariableNameOverlap.sksl") |
| 206 | SKSL_TEST(SkSLInlinerElidesTempVarForReturnsInsideBlock, |
| 207 | "inliner/InlinerElidesTempVarForReturnsInsideBlock.sksl") |
| 208 | SKSL_TEST(SkSLInlinerUsesTempVarForMultipleReturns, |
| 209 | "inliner/InlinerUsesTempVarForMultipleReturns.sksl") |
| 210 | SKSL_TEST(SkSLInlinerUsesTempVarForReturnsInsideBlockWithVar, |
| 211 | "inliner/InlinerUsesTempVarForReturnsInsideBlockWithVar.sksl") |
| 212 | SKSL_TEST(SkSLInlineThreshold, "inliner/InlineThreshold.sksl") |
Brian Osman | 169c890 | 2021-04-21 14:27:08 -0400 | [diff] [blame] | 213 | // skbug.com/11919: Fails on Adreno + Vulkan |
| 214 | SKSL_TEST_CPU(SkSLInlineWithInoutArgument, "inliner/InlineWithInoutArgument.sksl") |
John Stiles | 0c9d888 | 2021-03-25 17:04:36 -0400 | [diff] [blame] | 215 | SKSL_TEST(SkSLInlineWithModifiedArgument, "inliner/InlineWithModifiedArgument.sksl") |
| 216 | SKSL_TEST(SkSLInlineWithNestedBigCalls, "inliner/InlineWithNestedBigCalls.sksl") |
| 217 | SKSL_TEST(SkSLInlineWithUnmodifiedArgument, "inliner/InlineWithUnmodifiedArgument.sksl") |
| 218 | SKSL_TEST(SkSLInlineWithUnnecessaryBlocks, "inliner/InlineWithUnnecessaryBlocks.sksl") |
| 219 | SKSL_TEST(SkSLNoInline, "inliner/NoInline.sksl") |
| 220 | SKSL_TEST(SkSLShortCircuitEvaluationsCannotInlineRightHandSide, |
| 221 | "inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl") |
John Stiles | 325c808 | 2021-05-17 14:49:05 -0400 | [diff] [blame] | 222 | SKSL_TEST_ES3(SkSLStaticSwitchInline, "inliner/StaticSwitch.sksl") |
John Stiles | 0c9d888 | 2021-03-25 17:04:36 -0400 | [diff] [blame] | 223 | SKSL_TEST(SkSLStructsCanBeInlinedSafely, "inliner/StructsCanBeInlinedSafely.sksl") |
| 224 | SKSL_TEST(SkSLSwizzleCanBeInlinedDirectly, "inliner/SwizzleCanBeInlinedDirectly.sksl") |
| 225 | SKSL_TEST(SkSLTernaryResultsCannotBeInlined, "inliner/TernaryResultsCannotBeInlined.sksl") |
| 226 | SKSL_TEST(SkSLTernaryTestCanBeInlined, "inliner/TernaryTestCanBeInlined.sksl") |
| 227 | SKSL_TEST(SkSLTrivialArgumentsInlineDirectly, "inliner/TrivialArgumentsInlineDirectly.sksl") |
John Stiles | 65d7ab2 | 2021-04-28 15:14:09 -0400 | [diff] [blame] | 228 | SKSL_TEST_ES3(SkSLWhileBodyMustBeInlinedIntoAScope, |
| 229 | "inliner/WhileBodyMustBeInlinedIntoAScope.sksl") |
| 230 | SKSL_TEST_ES3(SkSLWhileTestCannotBeInlined, "inliner/WhileTestCannotBeInlined.sksl") |
John Stiles | 0c9d888 | 2021-03-25 17:04:36 -0400 | [diff] [blame] | 231 | |
John Stiles | bff24ab | 2021-03-17 13:20:10 -0400 | [diff] [blame] | 232 | // TODO(skia:11052): SPIR-V does not yet honor `out` param semantics correctly |
| 233 | SKSL_TEST_CPU(SkSLInlinerHonorsGLSLOutParamSemantics, |
John Stiles | 0c9d888 | 2021-03-25 17:04:36 -0400 | [diff] [blame] | 234 | "inliner/InlinerHonorsGLSLOutParamSemantics.sksl") |
John Stiles | bff24ab | 2021-03-17 13:20:10 -0400 | [diff] [blame] | 235 | |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 236 | SKSL_TEST(SkSLIntrinsicAbsFloat, "intrinsics/AbsFloat.sksl") |
| 237 | SKSL_TEST(SkSLIntrinsicCeil, "intrinsics/Ceil.sksl") |
John Stiles | c61d1bf | 2021-08-19 10:16:35 -0400 | [diff] [blame] | 238 | SKSL_TEST_ES3(SkSLIntrinsicDeterminant, "intrinsics/Determinant.sksl") |
John Stiles | 4e24948 | 2021-08-13 11:43:21 -0400 | [diff] [blame] | 239 | SKSL_TEST_ES3(SkSLIntrinsicDFdx, "intrinsics/DFdx.sksl") |
| 240 | SKSL_TEST_ES3(SkSLIntrinsicDFdy, "intrinsics/DFdy.sksl") |
John Stiles | b39236b | 2021-08-20 10:10:02 -0400 | [diff] [blame] | 241 | SKSL_TEST_ES3(SkSLIntrinsicFloatBitsToInt, "intrinsics/FloatBitsToInt.sksl") |
| 242 | SKSL_TEST_ES3(SkSLIntrinsicFloatBitsToUint, "intrinsics/FloatBitsToUint.sksl") |
John Stiles | 2586851 | 2021-09-15 20:24:24 -0400 | [diff] [blame] | 243 | SKSL_TEST_ES3(SkSLIntrinsicFwidth, "intrinsics/Fwidth.sksl") |
John Stiles | b39236b | 2021-08-20 10:10:02 -0400 | [diff] [blame] | 244 | SKSL_TEST_ES3(SkSLIntrinsicIntBitsToFloat, "intrinsics/IntBitsToFloat.sksl") |
John Stiles | dec5ff2 | 2021-08-25 13:54:34 -0400 | [diff] [blame] | 245 | SKSL_TEST_ES3(SkSLIntrinsicIsInf, "intrinsics/IsInf.sksl") |
John Stiles | df84ccd | 2021-09-09 09:59:14 -0400 | [diff] [blame] | 246 | // Fails on Adreno 6xx + Vulkan |
| 247 | SKSL_TEST_CPU(SkSLIntrinsicClampFloat, "intrinsics/ClampFloat.sksl") |
John Stiles | b701fa0 | 2021-09-14 13:09:36 -0400 | [diff] [blame] | 248 | SKSL_TEST(SkSLIntrinsicMatrixCompMultES2, "intrinsics/MatrixCompMultES2.sksl") |
| 249 | SKSL_TEST_ES3(SkSLIntrinsicMatrixCompMultES3, "intrinsics/MatrixCompMultES3.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 250 | SKSL_TEST(SkSLIntrinsicMaxFloat, "intrinsics/MaxFloat.sksl") |
| 251 | SKSL_TEST(SkSLIntrinsicMinFloat, "intrinsics/MinFloat.sksl") |
John Stiles | df84ccd | 2021-09-09 09:59:14 -0400 | [diff] [blame] | 252 | // Fails on Adreno + Vulkan (skia:11919) |
Brian Osman | 169c890 | 2021-04-21 14:27:08 -0400 | [diff] [blame] | 253 | SKSL_TEST_CPU(SkSLIntrinsicMixFloat, "intrinsics/MixFloat.sksl") |
John Stiles | 14c3175 | 2021-09-08 13:14:14 -0400 | [diff] [blame] | 254 | SKSL_TEST_ES3(SkSLIntrinsicModf, "intrinsics/Modf.sksl") |
John Stiles | 144ea42 | 2021-09-10 09:53:19 -0400 | [diff] [blame] | 255 | SKSL_TEST_ES3(SkSLIntrinsicOuterProduct, "intrinsics/OuterProduct.sksl") |
John Stiles | df84ccd | 2021-09-09 09:59:14 -0400 | [diff] [blame] | 256 | // Fails on Mac OpenGL + Radeon 5300M (skia:12434) |
| 257 | //SKSL_TEST_ES3(SkSLIntrinsicPackUnorm2x16, "intrinsics/PackUnorm2x16.sksl") |
John Stiles | 3681662 | 2021-08-23 11:00:10 -0400 | [diff] [blame] | 258 | SKSL_TEST_ES3(SkSLIntrinsicRound, "intrinsics/Round.sksl") |
| 259 | SKSL_TEST_ES3(SkSLIntrinsicRoundEven, "intrinsics/RoundEven.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 260 | SKSL_TEST(SkSLIntrinsicSignFloat, "intrinsics/SignFloat.sksl") |
John Stiles | 017ffd7 | 2021-05-25 11:48:30 -0400 | [diff] [blame] | 261 | SKSL_TEST(SkSLIntrinsicStep, "intrinsics/Step.sksl") |
John Stiles | 3681662 | 2021-08-23 11:00:10 -0400 | [diff] [blame] | 262 | SKSL_TEST_ES3(SkSLIntrinsicTrunc, "intrinsics/Trunc.sksl") |
John Stiles | 39822cf | 2021-08-17 15:08:46 -0400 | [diff] [blame] | 263 | SKSL_TEST_ES3(SkSLIntrinsicTranspose, "intrinsics/Transpose.sksl") |
John Stiles | dec5ff2 | 2021-08-25 13:54:34 -0400 | [diff] [blame] | 264 | SKSL_TEST_ES3(SkSLIntrinsicUintBitsToFloat, "intrinsics/UintBitsToFloat.sksl") |
John Stiles | e1658b5 | 2021-01-29 11:44:13 -0500 | [diff] [blame] | 265 | |
John Stiles | 2195f94 | 2021-08-05 10:55:03 -0400 | [diff] [blame] | 266 | SKSL_TEST_ES3(SkSLArrayNarrowingConversions, "runtime/ArrayNarrowingConversions.rts") |
John Stiles | 733fd74 | 2021-09-04 14:44:19 -0400 | [diff] [blame] | 267 | SKSL_TEST_ES3(SkSLLoopFloat, "runtime/LoopFloat.rts") |
| 268 | SKSL_TEST_ES3(SkSLLoopInt, "runtime/LoopInt.rts") |
John Stiles | 2195f94 | 2021-08-05 10:55:03 -0400 | [diff] [blame] | 269 | |
John Stiles | 3934647 | 2021-04-29 14:39:35 -0400 | [diff] [blame] | 270 | SKSL_TEST_ES3(SkSLArrayComparison, "shared/ArrayComparison.sksl") |
John Stiles | c1f6411 | 2021-05-17 09:59:02 -0400 | [diff] [blame] | 271 | SKSL_TEST_ES3(SkSLArrayConstructors, "shared/ArrayConstructors.sksl") |
John Stiles | 2648716 | 2021-08-10 16:03:44 -0400 | [diff] [blame] | 272 | SKSL_TEST_ES3(SkSLArrayCast, "shared/ArrayCast.sksl") |
John Stiles | 2d3f5e8 | 2021-08-25 11:54:16 -0400 | [diff] [blame] | 273 | SKSL_TEST_ES3(SkSLArrayFollowedByScalar, "shared/ArrayFollowedByScalar.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 274 | SKSL_TEST(SkSLArrayTypes, "shared/ArrayTypes.sksl") |
| 275 | SKSL_TEST(SkSLAssignment, "shared/Assignment.sksl") |
| 276 | SKSL_TEST(SkSLCastsRoundTowardZero, "shared/CastsRoundTowardZero.sksl") |
| 277 | SKSL_TEST(SkSLCommaMixedTypes, "shared/CommaMixedTypes.sksl") |
John Stiles | 3150839 | 2021-03-17 16:59:07 -0400 | [diff] [blame] | 278 | // This test causes the Adreno 330 driver to crash, and does not pass on Quadro P400 in wasm. |
| 279 | // The CPU test confirms that we can get it right, even if not all drivers do. |
| 280 | SKSL_TEST_CPU(SkSLCommaSideEffects, "shared/CommaSideEffects.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 281 | SKSL_TEST(SkSLConstantIf, "shared/ConstantIf.sksl") |
John Stiles | 82491c5 | 2021-05-14 07:55:45 -0400 | [diff] [blame] | 282 | SKSL_TEST_ES3(SkSLConstArray, "shared/ConstArray.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 283 | SKSL_TEST(SkSLConstVariableComparison, "shared/ConstVariableComparison.sksl") |
| 284 | SKSL_TEST(SkSLDeadIfStatement, "shared/DeadIfStatement.sksl") |
John Stiles | f2b08cc | 2021-05-17 14:46:05 -0400 | [diff] [blame] | 285 | SKSL_TEST(SkSLDeadReturn, "shared/DeadReturn.sksl") |
John Stiles | b82e931 | 2021-05-20 15:30:22 -0400 | [diff] [blame] | 286 | // TODO(skia:12012): some Radeons crash when compiling this code; disable them |
| 287 | //SKSL_TEST_ES3(SkSLDeadReturnES3, "shared/DeadReturnES3.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 288 | SKSL_TEST(SkSLDeadStripFunctions, "shared/DeadStripFunctions.sksl") |
| 289 | SKSL_TEST(SkSLDependentInitializers, "shared/DependentInitializers.sksl") |
John Stiles | d2c5a80 | 2021-05-19 21:42:57 -0400 | [diff] [blame] | 290 | SKSL_TEST_ES3(SkSLDoWhileControlFlow, "shared/DoWhileControlFlow.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 291 | SKSL_TEST(SkSLEmptyBlocksES2, "shared/EmptyBlocksES2.sksl") |
| 292 | SKSL_TEST(SkSLForLoopControlFlow, "shared/ForLoopControlFlow.sksl") |
| 293 | SKSL_TEST(SkSLFunctionArgTypeMatch, "shared/FunctionArgTypeMatch.sksl") |
| 294 | SKSL_TEST(SkSLFunctionReturnTypeMatch, "shared/FunctionReturnTypeMatch.sksl") |
| 295 | SKSL_TEST(SkSLFunctions, "shared/Functions.sksl") |
Brian Osman | 7da0657 | 2021-07-21 15:19:34 -0400 | [diff] [blame] | 296 | SKSL_TEST(SkSLFunctionPrototype, "shared/FunctionPrototype.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 297 | SKSL_TEST(SkSLGeometricIntrinsics, "shared/GeometricIntrinsics.sksl") |
| 298 | SKSL_TEST(SkSLHelloWorld, "shared/HelloWorld.sksl") |
| 299 | SKSL_TEST(SkSLHex, "shared/Hex.sksl") |
| 300 | SKSL_TEST(SkSLMatrices, "shared/Matrices.sksl") |
John Stiles | ab3e639 | 2021-05-14 17:53:03 -0400 | [diff] [blame] | 301 | SKSL_TEST_ES3(SkSLMatricesNonsquare, "shared/MatricesNonsquare.sksl") |
John Stiles | a0e407d | 2021-02-10 12:21:51 -0500 | [diff] [blame] | 302 | SKSL_TEST(SkSLMatrixEquality, "shared/MatrixEquality.sksl") |
John Stiles | 191b4e2 | 2021-05-14 20:03:01 -0400 | [diff] [blame] | 303 | SKSL_TEST(SkSLMatrixScalarSplat, "shared/MatrixScalarSplat.sksl") |
John Stiles | 6de2e1d | 2021-07-09 12:41:55 -0400 | [diff] [blame] | 304 | SKSL_TEST(SkSLMatrixToVectorCast, "shared/MatrixToVectorCast.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 305 | SKSL_TEST(SkSLMultipleAssignments, "shared/MultipleAssignments.sksl") |
John Stiles | f89a812 | 2021-08-30 15:47:00 -0400 | [diff] [blame] | 306 | SKSL_TEST(SkSLNegation, "shared/Negation.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 307 | SKSL_TEST(SkSLNumberCasts, "shared/NumberCasts.sksl") |
| 308 | SKSL_TEST(SkSLOperatorsES2, "shared/OperatorsES2.sksl") |
John Stiles | c1f6411 | 2021-05-17 09:59:02 -0400 | [diff] [blame] | 309 | SKSL_TEST_ES3(SkSLOperatorsES3, "shared/OperatorsES3.sksl") |
John Stiles | 9ae6ea0 | 2021-08-05 11:49:05 -0400 | [diff] [blame] | 310 | SKSL_TEST(SkSLOssfuzz36852, "shared/Ossfuzz36852.sksl") |
Brian Osman | 169c890 | 2021-04-21 14:27:08 -0400 | [diff] [blame] | 311 | |
| 312 | // skbug.com/11919: Fails on Adreno + Vulkan |
| 313 | SKSL_TEST_CPU(SkSLOutParams, "shared/OutParams.sksl") |
| 314 | SKSL_TEST_CPU(SkSLOutParamsNoInline, "shared/OutParamsNoInline.sksl") |
| 315 | SKSL_TEST_CPU(SkSLOutParamsTricky, "shared/OutParamsTricky.sksl") |
| 316 | |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 317 | SKSL_TEST(SkSLResizeMatrix, "shared/ResizeMatrix.sksl") |
John Stiles | b3dcbb1 | 2021-03-04 16:00:20 -0500 | [diff] [blame] | 318 | SKSL_TEST(SkSLReturnsValueOnEveryPathES2, "shared/ReturnsValueOnEveryPathES2.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 319 | SKSL_TEST(SkSLScalarConversionConstructorsES2, "shared/ScalarConversionConstructorsES2.sksl") |
John Stiles | 325c808 | 2021-05-17 14:49:05 -0400 | [diff] [blame] | 320 | SKSL_TEST_ES3(SkSLScalarConversionConstructorsES3, "shared/ScalarConversionConstructorsES3.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 321 | SKSL_TEST(SkSLStackingVectorCasts, "shared/StackingVectorCasts.sksl") |
| 322 | SKSL_TEST(SkSLStaticIf, "shared/StaticIf.sksl") |
John Stiles | 325c808 | 2021-05-17 14:49:05 -0400 | [diff] [blame] | 323 | SKSL_TEST_ES3(SkSLStaticSwitch, "shared/StaticSwitch.sksl") |
John Stiles | 31c8710 | 2021-08-25 12:01:21 -0400 | [diff] [blame] | 324 | SKSL_TEST(SkSLStructArrayFollowedByScalar, "shared/StructArrayFollowedByScalar.sksl") |
John Stiles | 3934647 | 2021-04-29 14:39:35 -0400 | [diff] [blame] | 325 | SKSL_TEST(SkSLStructsInFunctions, "shared/StructsInFunctions.sksl") |
John Stiles | ed2baba | 2021-09-20 19:09:13 -0400 | [diff] [blame^] | 326 | SKSL_TEST_ES3(SkSLSwitch, "shared/Switch.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 327 | SKSL_TEST(SkSLSwizzleBoolConstants, "shared/SwizzleBoolConstants.sksl") |
John Stiles | c2c1b0c | 2021-02-05 16:24:03 -0500 | [diff] [blame] | 328 | SKSL_TEST(SkSLSwizzleByConstantIndex, "shared/SwizzleByConstantIndex.sksl") |
| 329 | SKSL_TEST(SkSLSwizzleConstants, "shared/SwizzleConstants.sksl") |
| 330 | SKSL_TEST(SkSLSwizzleLTRB, "shared/SwizzleLTRB.sksl") |
| 331 | SKSL_TEST(SkSLSwizzleOpt, "shared/SwizzleOpt.sksl") |
| 332 | SKSL_TEST(SkSLSwizzleScalar, "shared/SwizzleScalar.sksl") |
John Stiles | 010c0ec | 2021-07-12 15:05:54 -0400 | [diff] [blame] | 333 | SKSL_TEST(SkSLSwizzleScalarBool, "shared/SwizzleScalarBool.sksl") |
John Stiles | 7f56b41 | 2021-07-12 14:59:19 -0400 | [diff] [blame] | 334 | SKSL_TEST(SkSLSwizzleScalarInt, "shared/SwizzleScalarInt.sksl") |
John Stiles | ecd7c22 | 2021-02-08 14:20:28 -0500 | [diff] [blame] | 335 | SKSL_TEST(SkSLTernaryAsLValueEntirelyFoldable, "shared/TernaryAsLValueEntirelyFoldable.sksl") |
| 336 | SKSL_TEST(SkSLTernaryAsLValueFoldableTest, "shared/TernaryAsLValueFoldableTest.sksl") |
John Stiles | 28054ad | 2021-03-05 15:22:48 -0500 | [diff] [blame] | 337 | SKSL_TEST(SkSLTernaryExpression, "shared/TernaryExpression.sksl") |
John Stiles | ecd7c22 | 2021-02-08 14:20:28 -0500 | [diff] [blame] | 338 | SKSL_TEST(SkSLUnaryPositiveNegative, "shared/UnaryPositiveNegative.sksl") |
| 339 | SKSL_TEST(SkSLUnusedVariables, "shared/UnusedVariables.sksl") |
| 340 | SKSL_TEST(SkSLVectorConstructors, "shared/VectorConstructors.sksl") |
John Stiles | 5a825da | 2021-07-08 18:20:21 -0400 | [diff] [blame] | 341 | SKSL_TEST(SkSLVectorToMatrixCast, "shared/VectorToMatrixCast.sksl") |
Brian Osman | 169c890 | 2021-04-21 14:27:08 -0400 | [diff] [blame] | 342 | // skbug.com/11919: Fails on Nexus5/7, and Intel GPUs |
| 343 | SKSL_TEST_CPU(SkSLVectorScalarMath, "shared/VectorScalarMath.sksl") |
John Stiles | c1f6411 | 2021-05-17 09:59:02 -0400 | [diff] [blame] | 344 | SKSL_TEST_ES3(SkSLWhileLoopControlFlow, "shared/WhileLoopControlFlow.sksl") |
John Stiles | 7b92897 | 2021-01-27 09:56:04 -0500 | [diff] [blame] | 345 | |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 346 | /* |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 347 | TODO(skia:11209): enable these tests when Runtime Effects have support for ES3 |
| 348 | |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 349 | SKSL_TEST(SkSLMatrixFoldingES3, "folding/MatrixFoldingES3.sksl") |
John Stiles | 7b92897 | 2021-01-27 09:56:04 -0500 | [diff] [blame] | 350 | |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 351 | SKSL_TEST(SkSLIntrinsicAbsInt, "intrinsics/AbsInt.sksl") |
| 352 | SKSL_TEST(SkSLIntrinsicClampInt, "intrinsics/ClampInt.sksl") |
| 353 | SKSL_TEST(SkSLIntrinsicMaxInt, "intrinsics/MaxInt.sksl") |
| 354 | SKSL_TEST(SkSLIntrinsicMinInt, "intrinsics/MinInt.sksl") |
| 355 | SKSL_TEST(SkSLIntrinsicMixBool, "intrinsics/MixBool.sksl") |
| 356 | SKSL_TEST(SkSLIntrinsicSignInt, "intrinsics/SignInt.sksl") |
John Stiles | e1658b5 | 2021-01-29 11:44:13 -0500 | [diff] [blame] | 357 | |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 358 | SKSL_TEST(SkSLDeadLoopVariable, "shared/DeadLoopVariable.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 359 | SKSL_TEST(SkSLEmptyBlocksES3, "shared/EmptyBlocksES3.sksl") |
| 360 | SKSL_TEST(SkSLHexUnsigned, "shared/HexUnsigned.sksl") |
John Stiles | d437478 | 2021-02-05 09:31:21 -0500 | [diff] [blame] | 361 | SKSL_TEST(SkSLResizeMatrixNonsquare, "shared/ResizeMatrixNonsquare.sksl") |
John Stiles | b3dcbb1 | 2021-03-04 16:00:20 -0500 | [diff] [blame] | 362 | SKSL_TEST(SkSLReturnsValueOnEveryPathES3, "shared/ReturnsValueOnEveryPathES3.sksl") |
John Stiles | c2c1b0c | 2021-02-05 16:24:03 -0500 | [diff] [blame] | 363 | SKSL_TEST(SkSLSwizzleByIndex, "shared/SwizzleByIndex.sksl") |
John Stiles | 232dd2b | 2021-01-25 10:57:47 -0500 | [diff] [blame] | 364 | */ |