blob: c167ebe29920bc26a304ce38d31ef8ca3b31f6c9 [file] [log] [blame]
John Stiles232dd2b2021-01-25 10:57:47 -05001/*
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 Nicholasdaed2592021-03-04 14:30:25 -050020#include "include/private/SkSLDefines.h" // for kDefaultInlineThreshold
John Stiles232dd2b2021-01-25 10:57:47 -050021#include "include/utils/SkRandom.h"
Brian Osmane9ab3912021-07-02 10:17:45 -040022#include "src/core/SkRuntimeEffectPriv.h"
John Stiles65d7ab22021-04-28 15:14:09 -040023#include "src/gpu/GrCaps.h"
24#include "src/gpu/GrDirectContextPriv.h"
John Stiles232dd2b2021-01-25 10:57:47 -050025#include "tests/Test.h"
26#include "tools/Resources.h"
27#include "tools/ToolUtils.h"
28
John Stiles0dc09b12021-09-15 17:42:42 -040029static constexpr int kWidth = 2;
30static constexpr int kHeight = 2;
John Stiles232dd2b2021-01-25 10:57:47 -050031
John Stilesb41d5bb2021-01-26 16:28:12 -050032template <typename T>
33static 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 Stilesd80f9662021-02-03 11:42:32 -050040static void test_one_permutation(skiatest::Reporter* r,
41 SkSurface* surface,
42 const char* testFile,
43 const char* permutationSuffix,
44 const SkRuntimeEffect::Options& options) {
John Stiles232dd2b2021-01-25 10:57:47 -050045 SkString resourcePath = SkStringPrintf("sksl/%s", testFile);
46 sk_sp<SkData> shaderData = GetResourceAsData(resourcePath.c_str());
47 if (!shaderData) {
John Stilesd80f9662021-02-03 11:42:32 -050048 ERRORF(r, "%s%s: Unable to load file", testFile, permutationSuffix);
John Stiles232dd2b2021-01-25 10:57:47 -050049 return;
50 }
51
52 SkString shaderString{reinterpret_cast<const char*>(shaderData->bytes()), shaderData->size()};
Brian Osman169c8902021-04-21 14:27:08 -040053 SkRuntimeEffect::Result result = SkRuntimeEffect::MakeForShader(shaderString, options);
John Stilesd80f9662021-02-03 11:42:32 -050054 if (!result.effect) {
55 ERRORF(r, "%s%s: %s", testFile, permutationSuffix, result.errorText.c_str());
John Stiles232dd2b2021-01-25 10:57:47 -050056 return;
57 }
58
John Stilesd80f9662021-02-03 11:42:32 -050059 SkRuntimeShaderBuilder builder(result.effect);
John Stilese1658b52021-01-29 11:44:13 -050060 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 Stiles01cdf012021-02-10 09:53:41 -050066 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 Stilese1658b52021-01-29 11:44:13 -050071 set_uniform(&builder, "unknownInput", 1.0f);
John Stilesa0e407d2021-02-10 12:21:51 -050072 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 Stilesb41d5bb2021-01-26 16:28:12 -050077
John Stiles232dd2b2021-01-25 10:57:47 -050078 sk_sp<SkShader> shader = builder.makeShader(/*localMatrix=*/nullptr, /*isOpaque=*/true);
79 if (!shader) {
John Stilesd80f9662021-02-03 11:42:32 -050080 ERRORF(r, "%s%s: Unable to build shader", testFile, permutationSuffix);
John Stiles232dd2b2021-01-25 10:57:47 -050081 return;
82 }
83
84 SkPaint paintShader;
85 paintShader.setShader(shader);
John Stiles0dc09b12021-09-15 17:42:42 -040086 surface->getCanvas()->drawRect(SkRect::MakeWH(kWidth, kHeight), paintShader);
John Stiles232dd2b2021-01-25 10:57:47 -050087
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 Stiles0dc09b12021-09-15 17:42:42 -040093 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 Stiles232dd2b2021-01-25 10:57:47 -0500123}
124
John Stiles65d7ab22021-04-28 15:14:09 -0400125static void test_permutations(skiatest::Reporter* r,
126 SkSurface* surface,
127 const char* testFile,
128 bool worksInES2) {
Brian Osmane9ab3912021-07-02 10:17:45 -0400129 SkRuntimeEffect::Options options =
130 worksInES2 ? SkRuntimeEffect::Options{} : SkRuntimeEffectPriv::ES3Options();
John Stiles9d26af92021-03-23 09:25:33 -0400131 options.forceNoInline = false;
John Stilesd80f9662021-02-03 11:42:32 -0500132 test_one_permutation(r, surface, testFile, "", options);
John Stiles9d26af92021-03-23 09:25:33 -0400133
134 options.forceNoInline = true;
135 test_one_permutation(r, surface, testFile, " (NoInline)", options);
John Stilesd80f9662021-02-03 11:42:32 -0500136}
137
John Stiles232dd2b2021-01-25 10:57:47 -0500138static void test_cpu(skiatest::Reporter* r, const char* testFile) {
John Stiles0dc09b12021-09-15 17:42:42 -0400139 const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
John Stiles232dd2b2021-01-25 10:57:47 -0500140 sk_sp<SkSurface> surface(SkSurface::MakeRaster(info));
141
John Stiles65d7ab22021-04-28 15:14:09 -0400142 test_permutations(r, surface.get(), testFile, /*worksInES2=*/true);
John Stiles232dd2b2021-01-25 10:57:47 -0500143}
144
145static void test_gpu(skiatest::Reporter* r, GrDirectContext* ctx, const char* testFile) {
John Stiles0dc09b12021-09-15 17:42:42 -0400146 const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
John Stiles232dd2b2021-01-25 10:57:47 -0500147 sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
148
John Stiles65d7ab22021-04-28 15:14:09 -0400149 test_permutations(r, surface.get(), testFile, /*worksInES2=*/true);
150}
151
152static void test_es3(skiatest::Reporter* r, GrDirectContext* ctx, const char* testFile) {
John Stiles0733d482021-08-18 12:17:21 -0400153 if (!ctx->priv().caps()->shaderCaps()->supportsSkSLES3()) {
John Stiles65d7ab22021-04-28 15:14:09 -0400154 return;
155 }
156 // ES3-only tests never run on the CPU, because SkVM lacks support for many non-ES2 features.
John Stiles0dc09b12021-09-15 17:42:42 -0400157 const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
John Stiles65d7ab22021-04-28 15:14:09 -0400158 sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
159
160 test_permutations(r, surface.get(), testFile, /*worksInES2=*/false);
John Stiles232dd2b2021-01-25 10:57:47 -0500161}
162
John Stilesb4418502021-02-04 10:57:08 -0500163#define SKSL_TEST_CPU(name, path) \
John Stiles232dd2b2021-01-25 10:57:47 -0500164 DEF_TEST(name ## _CPU, r) { \
165 test_cpu(r, path); \
John Stilesb4418502021-02-04 10:57:08 -0500166 }
167#define SKSL_TEST_GPU(name, path) \
John Stiles232dd2b2021-01-25 10:57:47 -0500168 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name ## _GPU, r, ctxInfo) { \
169 test_gpu(r, ctxInfo.directContext(), path); \
170 }
John Stiles65d7ab22021-04-28 15:14:09 -0400171#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 Stilesb4418502021-02-04 10:57:08 -0500175#define SKSL_TEST(name, path) SKSL_TEST_CPU(name, path) SKSL_TEST_GPU(name, path)
John Stiles232dd2b2021-01-25 10:57:47 -0500176
John Stiles34c098d2021-02-09 10:38:59 -0500177SKSL_TEST(SkSLAssignmentOps, "folding/AssignmentOps.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500178SKSL_TEST(SkSLBoolFolding, "folding/BoolFolding.sksl")
John Stiles27193d42021-05-07 11:16:26 -0400179SKSL_TEST(SkSLCastFolding, "folding/CastFolding.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500180SKSL_TEST(SkSLIntFoldingES2, "folding/IntFoldingES2.sksl")
John Stiles65d7ab22021-04-28 15:14:09 -0400181SKSL_TEST_ES3(SkSLIntFoldingES3, "folding/IntFoldingES3.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500182SKSL_TEST(SkSLFloatFolding, "folding/FloatFolding.sksl")
Brian Osman169c8902021-04-21 14:27:08 -0400183// skbug.com/11919: Fails on Nexus5/7, and Intel GPUs
184SKSL_TEST_CPU(SkSLMatrixFoldingES2, "folding/MatrixFoldingES2.sksl")
Brian Osman8e756f32021-02-10 10:19:27 -0500185SKSL_TEST(SkSLSelfAssignment, "folding/SelfAssignment.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500186SKSL_TEST(SkSLShortCircuitBoolFolding, "folding/ShortCircuitBoolFolding.sksl")
John Stilesfb7d3782021-04-29 11:14:38 -0400187SKSL_TEST(SkSLSwizzleFolding, "folding/SwizzleFolding.sksl")
John Stiles03467a52021-03-04 15:19:48 +0000188SKSL_TEST(SkSLVectorScalarFolding, "folding/VectorScalarFolding.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500189SKSL_TEST(SkSLVectorVectorFolding, "folding/VectorVectorFolding.sksl")
John Stiles232dd2b2021-01-25 10:57:47 -0500190
John Stilesd2c5a802021-05-19 21:42:57 -0400191SKSL_TEST_ES3(SkSLDoWhileBodyMustBeInlinedIntoAScope,
192 "inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl")
193SKSL_TEST_ES3(SkSLDoWhileTestCannotBeInlined, "inliner/DoWhileTestCannotBeInlined.sksl")
John Stiles0c9d8882021-03-25 17:04:36 -0400194SKSL_TEST(SkSLForBodyMustBeInlinedIntoAScope, "inliner/ForBodyMustBeInlinedIntoAScope.sksl")
John Stiles65d7ab22021-04-28 15:14:09 -0400195SKSL_TEST_ES3(SkSLForInitializerExpressionsCanBeInlined,
196 "inliner/ForInitializerExpressionsCanBeInlined.sksl")
John Stiles0c9d8882021-03-25 17:04:36 -0400197SKSL_TEST(SkSLForWithoutReturnInsideCanBeInlined, "inliner/ForWithoutReturnInsideCanBeInlined.sksl")
198SKSL_TEST(SkSLForWithReturnInsideCannotBeInlined, "inliner/ForWithReturnInsideCannotBeInlined.sksl")
199SKSL_TEST(SkSLIfBodyMustBeInlinedIntoAScope, "inliner/IfBodyMustBeInlinedIntoAScope.sksl")
200SKSL_TEST(SkSLIfElseBodyMustBeInlinedIntoAScope, "inliner/IfElseBodyMustBeInlinedIntoAScope.sksl")
201SKSL_TEST(SkSLIfElseChainWithReturnsCanBeInlined, "inliner/IfElseChainWithReturnsCanBeInlined.sksl")
202SKSL_TEST(SkSLIfTestCanBeInlined, "inliner/IfTestCanBeInlined.sksl")
203SKSL_TEST(SkSLIfWithReturnsCanBeInlined, "inliner/IfWithReturnsCanBeInlined.sksl")
204SKSL_TEST(SkSLInlineKeywordOverridesThreshold, "inliner/InlineKeywordOverridesThreshold.sksl")
205SKSL_TEST(SkSLInlinerAvoidsVariableNameOverlap, "inliner/InlinerAvoidsVariableNameOverlap.sksl")
206SKSL_TEST(SkSLInlinerElidesTempVarForReturnsInsideBlock,
207 "inliner/InlinerElidesTempVarForReturnsInsideBlock.sksl")
208SKSL_TEST(SkSLInlinerUsesTempVarForMultipleReturns,
209 "inliner/InlinerUsesTempVarForMultipleReturns.sksl")
210SKSL_TEST(SkSLInlinerUsesTempVarForReturnsInsideBlockWithVar,
211 "inliner/InlinerUsesTempVarForReturnsInsideBlockWithVar.sksl")
212SKSL_TEST(SkSLInlineThreshold, "inliner/InlineThreshold.sksl")
Brian Osman169c8902021-04-21 14:27:08 -0400213// skbug.com/11919: Fails on Adreno + Vulkan
214SKSL_TEST_CPU(SkSLInlineWithInoutArgument, "inliner/InlineWithInoutArgument.sksl")
John Stiles0c9d8882021-03-25 17:04:36 -0400215SKSL_TEST(SkSLInlineWithModifiedArgument, "inliner/InlineWithModifiedArgument.sksl")
216SKSL_TEST(SkSLInlineWithNestedBigCalls, "inliner/InlineWithNestedBigCalls.sksl")
217SKSL_TEST(SkSLInlineWithUnmodifiedArgument, "inliner/InlineWithUnmodifiedArgument.sksl")
218SKSL_TEST(SkSLInlineWithUnnecessaryBlocks, "inliner/InlineWithUnnecessaryBlocks.sksl")
219SKSL_TEST(SkSLNoInline, "inliner/NoInline.sksl")
220SKSL_TEST(SkSLShortCircuitEvaluationsCannotInlineRightHandSide,
221 "inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl")
John Stiles325c8082021-05-17 14:49:05 -0400222SKSL_TEST_ES3(SkSLStaticSwitchInline, "inliner/StaticSwitch.sksl")
John Stiles0c9d8882021-03-25 17:04:36 -0400223SKSL_TEST(SkSLStructsCanBeInlinedSafely, "inliner/StructsCanBeInlinedSafely.sksl")
224SKSL_TEST(SkSLSwizzleCanBeInlinedDirectly, "inliner/SwizzleCanBeInlinedDirectly.sksl")
225SKSL_TEST(SkSLTernaryResultsCannotBeInlined, "inliner/TernaryResultsCannotBeInlined.sksl")
226SKSL_TEST(SkSLTernaryTestCanBeInlined, "inliner/TernaryTestCanBeInlined.sksl")
227SKSL_TEST(SkSLTrivialArgumentsInlineDirectly, "inliner/TrivialArgumentsInlineDirectly.sksl")
John Stiles65d7ab22021-04-28 15:14:09 -0400228SKSL_TEST_ES3(SkSLWhileBodyMustBeInlinedIntoAScope,
229 "inliner/WhileBodyMustBeInlinedIntoAScope.sksl")
230SKSL_TEST_ES3(SkSLWhileTestCannotBeInlined, "inliner/WhileTestCannotBeInlined.sksl")
John Stiles0c9d8882021-03-25 17:04:36 -0400231
John Stilesbff24ab2021-03-17 13:20:10 -0400232// TODO(skia:11052): SPIR-V does not yet honor `out` param semantics correctly
233SKSL_TEST_CPU(SkSLInlinerHonorsGLSLOutParamSemantics,
John Stiles0c9d8882021-03-25 17:04:36 -0400234 "inliner/InlinerHonorsGLSLOutParamSemantics.sksl")
John Stilesbff24ab2021-03-17 13:20:10 -0400235
John Stilesd4374782021-02-05 09:31:21 -0500236SKSL_TEST(SkSLIntrinsicAbsFloat, "intrinsics/AbsFloat.sksl")
237SKSL_TEST(SkSLIntrinsicCeil, "intrinsics/Ceil.sksl")
John Stilesc61d1bf2021-08-19 10:16:35 -0400238SKSL_TEST_ES3(SkSLIntrinsicDeterminant, "intrinsics/Determinant.sksl")
John Stiles4e249482021-08-13 11:43:21 -0400239SKSL_TEST_ES3(SkSLIntrinsicDFdx, "intrinsics/DFdx.sksl")
240SKSL_TEST_ES3(SkSLIntrinsicDFdy, "intrinsics/DFdy.sksl")
John Stilesb39236b2021-08-20 10:10:02 -0400241SKSL_TEST_ES3(SkSLIntrinsicFloatBitsToInt, "intrinsics/FloatBitsToInt.sksl")
242SKSL_TEST_ES3(SkSLIntrinsicFloatBitsToUint, "intrinsics/FloatBitsToUint.sksl")
John Stiles25868512021-09-15 20:24:24 -0400243SKSL_TEST_ES3(SkSLIntrinsicFwidth, "intrinsics/Fwidth.sksl")
John Stilesb39236b2021-08-20 10:10:02 -0400244SKSL_TEST_ES3(SkSLIntrinsicIntBitsToFloat, "intrinsics/IntBitsToFloat.sksl")
John Stilesdec5ff22021-08-25 13:54:34 -0400245SKSL_TEST_ES3(SkSLIntrinsicIsInf, "intrinsics/IsInf.sksl")
John Stilesdf84ccd2021-09-09 09:59:14 -0400246// Fails on Adreno 6xx + Vulkan
247SKSL_TEST_CPU(SkSLIntrinsicClampFloat, "intrinsics/ClampFloat.sksl")
John Stilesb701fa02021-09-14 13:09:36 -0400248SKSL_TEST(SkSLIntrinsicMatrixCompMultES2, "intrinsics/MatrixCompMultES2.sksl")
249SKSL_TEST_ES3(SkSLIntrinsicMatrixCompMultES3, "intrinsics/MatrixCompMultES3.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500250SKSL_TEST(SkSLIntrinsicMaxFloat, "intrinsics/MaxFloat.sksl")
251SKSL_TEST(SkSLIntrinsicMinFloat, "intrinsics/MinFloat.sksl")
John Stilesdf84ccd2021-09-09 09:59:14 -0400252// Fails on Adreno + Vulkan (skia:11919)
Brian Osman169c8902021-04-21 14:27:08 -0400253SKSL_TEST_CPU(SkSLIntrinsicMixFloat, "intrinsics/MixFloat.sksl")
John Stiles14c31752021-09-08 13:14:14 -0400254SKSL_TEST_ES3(SkSLIntrinsicModf, "intrinsics/Modf.sksl")
John Stiles144ea422021-09-10 09:53:19 -0400255SKSL_TEST_ES3(SkSLIntrinsicOuterProduct, "intrinsics/OuterProduct.sksl")
John Stilesdf84ccd2021-09-09 09:59:14 -0400256// Fails on Mac OpenGL + Radeon 5300M (skia:12434)
257//SKSL_TEST_ES3(SkSLIntrinsicPackUnorm2x16, "intrinsics/PackUnorm2x16.sksl")
John Stiles36816622021-08-23 11:00:10 -0400258SKSL_TEST_ES3(SkSLIntrinsicRound, "intrinsics/Round.sksl")
259SKSL_TEST_ES3(SkSLIntrinsicRoundEven, "intrinsics/RoundEven.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500260SKSL_TEST(SkSLIntrinsicSignFloat, "intrinsics/SignFloat.sksl")
John Stiles017ffd72021-05-25 11:48:30 -0400261SKSL_TEST(SkSLIntrinsicStep, "intrinsics/Step.sksl")
John Stiles36816622021-08-23 11:00:10 -0400262SKSL_TEST_ES3(SkSLIntrinsicTrunc, "intrinsics/Trunc.sksl")
John Stiles39822cf2021-08-17 15:08:46 -0400263SKSL_TEST_ES3(SkSLIntrinsicTranspose, "intrinsics/Transpose.sksl")
John Stilesdec5ff22021-08-25 13:54:34 -0400264SKSL_TEST_ES3(SkSLIntrinsicUintBitsToFloat, "intrinsics/UintBitsToFloat.sksl")
John Stilese1658b52021-01-29 11:44:13 -0500265
John Stiles2195f942021-08-05 10:55:03 -0400266SKSL_TEST_ES3(SkSLArrayNarrowingConversions, "runtime/ArrayNarrowingConversions.rts")
John Stiles733fd742021-09-04 14:44:19 -0400267SKSL_TEST_ES3(SkSLLoopFloat, "runtime/LoopFloat.rts")
268SKSL_TEST_ES3(SkSLLoopInt, "runtime/LoopInt.rts")
John Stiles2195f942021-08-05 10:55:03 -0400269
John Stiles39346472021-04-29 14:39:35 -0400270SKSL_TEST_ES3(SkSLArrayComparison, "shared/ArrayComparison.sksl")
John Stilesc1f64112021-05-17 09:59:02 -0400271SKSL_TEST_ES3(SkSLArrayConstructors, "shared/ArrayConstructors.sksl")
John Stiles26487162021-08-10 16:03:44 -0400272SKSL_TEST_ES3(SkSLArrayCast, "shared/ArrayCast.sksl")
John Stiles2d3f5e82021-08-25 11:54:16 -0400273SKSL_TEST_ES3(SkSLArrayFollowedByScalar, "shared/ArrayFollowedByScalar.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500274SKSL_TEST(SkSLArrayTypes, "shared/ArrayTypes.sksl")
275SKSL_TEST(SkSLAssignment, "shared/Assignment.sksl")
276SKSL_TEST(SkSLCastsRoundTowardZero, "shared/CastsRoundTowardZero.sksl")
277SKSL_TEST(SkSLCommaMixedTypes, "shared/CommaMixedTypes.sksl")
John Stiles31508392021-03-17 16:59:07 -0400278// 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.
280SKSL_TEST_CPU(SkSLCommaSideEffects, "shared/CommaSideEffects.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500281SKSL_TEST(SkSLConstantIf, "shared/ConstantIf.sksl")
John Stiles82491c52021-05-14 07:55:45 -0400282SKSL_TEST_ES3(SkSLConstArray, "shared/ConstArray.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500283SKSL_TEST(SkSLConstVariableComparison, "shared/ConstVariableComparison.sksl")
284SKSL_TEST(SkSLDeadIfStatement, "shared/DeadIfStatement.sksl")
John Stilesf2b08cc2021-05-17 14:46:05 -0400285SKSL_TEST(SkSLDeadReturn, "shared/DeadReturn.sksl")
John Stilesb82e9312021-05-20 15:30:22 -0400286// TODO(skia:12012): some Radeons crash when compiling this code; disable them
287//SKSL_TEST_ES3(SkSLDeadReturnES3, "shared/DeadReturnES3.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500288SKSL_TEST(SkSLDeadStripFunctions, "shared/DeadStripFunctions.sksl")
289SKSL_TEST(SkSLDependentInitializers, "shared/DependentInitializers.sksl")
John Stilesd2c5a802021-05-19 21:42:57 -0400290SKSL_TEST_ES3(SkSLDoWhileControlFlow, "shared/DoWhileControlFlow.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500291SKSL_TEST(SkSLEmptyBlocksES2, "shared/EmptyBlocksES2.sksl")
292SKSL_TEST(SkSLForLoopControlFlow, "shared/ForLoopControlFlow.sksl")
293SKSL_TEST(SkSLFunctionArgTypeMatch, "shared/FunctionArgTypeMatch.sksl")
294SKSL_TEST(SkSLFunctionReturnTypeMatch, "shared/FunctionReturnTypeMatch.sksl")
295SKSL_TEST(SkSLFunctions, "shared/Functions.sksl")
Brian Osman7da06572021-07-21 15:19:34 -0400296SKSL_TEST(SkSLFunctionPrototype, "shared/FunctionPrototype.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500297SKSL_TEST(SkSLGeometricIntrinsics, "shared/GeometricIntrinsics.sksl")
298SKSL_TEST(SkSLHelloWorld, "shared/HelloWorld.sksl")
299SKSL_TEST(SkSLHex, "shared/Hex.sksl")
300SKSL_TEST(SkSLMatrices, "shared/Matrices.sksl")
John Stilesab3e6392021-05-14 17:53:03 -0400301SKSL_TEST_ES3(SkSLMatricesNonsquare, "shared/MatricesNonsquare.sksl")
John Stilesa0e407d2021-02-10 12:21:51 -0500302SKSL_TEST(SkSLMatrixEquality, "shared/MatrixEquality.sksl")
John Stiles191b4e22021-05-14 20:03:01 -0400303SKSL_TEST(SkSLMatrixScalarSplat, "shared/MatrixScalarSplat.sksl")
John Stiles6de2e1d2021-07-09 12:41:55 -0400304SKSL_TEST(SkSLMatrixToVectorCast, "shared/MatrixToVectorCast.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500305SKSL_TEST(SkSLMultipleAssignments, "shared/MultipleAssignments.sksl")
John Stilesf89a8122021-08-30 15:47:00 -0400306SKSL_TEST(SkSLNegation, "shared/Negation.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500307SKSL_TEST(SkSLNumberCasts, "shared/NumberCasts.sksl")
308SKSL_TEST(SkSLOperatorsES2, "shared/OperatorsES2.sksl")
John Stilesc1f64112021-05-17 09:59:02 -0400309SKSL_TEST_ES3(SkSLOperatorsES3, "shared/OperatorsES3.sksl")
John Stiles9ae6ea02021-08-05 11:49:05 -0400310SKSL_TEST(SkSLOssfuzz36852, "shared/Ossfuzz36852.sksl")
Brian Osman169c8902021-04-21 14:27:08 -0400311
312// skbug.com/11919: Fails on Adreno + Vulkan
313SKSL_TEST_CPU(SkSLOutParams, "shared/OutParams.sksl")
314SKSL_TEST_CPU(SkSLOutParamsNoInline, "shared/OutParamsNoInline.sksl")
315SKSL_TEST_CPU(SkSLOutParamsTricky, "shared/OutParamsTricky.sksl")
316
John Stilesd4374782021-02-05 09:31:21 -0500317SKSL_TEST(SkSLResizeMatrix, "shared/ResizeMatrix.sksl")
John Stilesb3dcbb12021-03-04 16:00:20 -0500318SKSL_TEST(SkSLReturnsValueOnEveryPathES2, "shared/ReturnsValueOnEveryPathES2.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500319SKSL_TEST(SkSLScalarConversionConstructorsES2, "shared/ScalarConversionConstructorsES2.sksl")
John Stiles325c8082021-05-17 14:49:05 -0400320SKSL_TEST_ES3(SkSLScalarConversionConstructorsES3, "shared/ScalarConversionConstructorsES3.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500321SKSL_TEST(SkSLStackingVectorCasts, "shared/StackingVectorCasts.sksl")
322SKSL_TEST(SkSLStaticIf, "shared/StaticIf.sksl")
John Stiles325c8082021-05-17 14:49:05 -0400323SKSL_TEST_ES3(SkSLStaticSwitch, "shared/StaticSwitch.sksl")
John Stiles31c87102021-08-25 12:01:21 -0400324SKSL_TEST(SkSLStructArrayFollowedByScalar, "shared/StructArrayFollowedByScalar.sksl")
John Stiles39346472021-04-29 14:39:35 -0400325SKSL_TEST(SkSLStructsInFunctions, "shared/StructsInFunctions.sksl")
John Stilesed2baba2021-09-20 19:09:13 -0400326SKSL_TEST_ES3(SkSLSwitch, "shared/Switch.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500327SKSL_TEST(SkSLSwizzleBoolConstants, "shared/SwizzleBoolConstants.sksl")
John Stilesc2c1b0c2021-02-05 16:24:03 -0500328SKSL_TEST(SkSLSwizzleByConstantIndex, "shared/SwizzleByConstantIndex.sksl")
329SKSL_TEST(SkSLSwizzleConstants, "shared/SwizzleConstants.sksl")
330SKSL_TEST(SkSLSwizzleLTRB, "shared/SwizzleLTRB.sksl")
331SKSL_TEST(SkSLSwizzleOpt, "shared/SwizzleOpt.sksl")
332SKSL_TEST(SkSLSwizzleScalar, "shared/SwizzleScalar.sksl")
John Stiles010c0ec2021-07-12 15:05:54 -0400333SKSL_TEST(SkSLSwizzleScalarBool, "shared/SwizzleScalarBool.sksl")
John Stiles7f56b412021-07-12 14:59:19 -0400334SKSL_TEST(SkSLSwizzleScalarInt, "shared/SwizzleScalarInt.sksl")
John Stilesecd7c222021-02-08 14:20:28 -0500335SKSL_TEST(SkSLTernaryAsLValueEntirelyFoldable, "shared/TernaryAsLValueEntirelyFoldable.sksl")
336SKSL_TEST(SkSLTernaryAsLValueFoldableTest, "shared/TernaryAsLValueFoldableTest.sksl")
John Stiles28054ad2021-03-05 15:22:48 -0500337SKSL_TEST(SkSLTernaryExpression, "shared/TernaryExpression.sksl")
John Stilesecd7c222021-02-08 14:20:28 -0500338SKSL_TEST(SkSLUnaryPositiveNegative, "shared/UnaryPositiveNegative.sksl")
339SKSL_TEST(SkSLUnusedVariables, "shared/UnusedVariables.sksl")
340SKSL_TEST(SkSLVectorConstructors, "shared/VectorConstructors.sksl")
John Stiles5a825da2021-07-08 18:20:21 -0400341SKSL_TEST(SkSLVectorToMatrixCast, "shared/VectorToMatrixCast.sksl")
Brian Osman169c8902021-04-21 14:27:08 -0400342// skbug.com/11919: Fails on Nexus5/7, and Intel GPUs
343SKSL_TEST_CPU(SkSLVectorScalarMath, "shared/VectorScalarMath.sksl")
John Stilesc1f64112021-05-17 09:59:02 -0400344SKSL_TEST_ES3(SkSLWhileLoopControlFlow, "shared/WhileLoopControlFlow.sksl")
John Stiles7b928972021-01-27 09:56:04 -0500345
John Stiles232dd2b2021-01-25 10:57:47 -0500346/*
John Stiles232dd2b2021-01-25 10:57:47 -0500347TODO(skia:11209): enable these tests when Runtime Effects have support for ES3
348
John Stilesd4374782021-02-05 09:31:21 -0500349SKSL_TEST(SkSLMatrixFoldingES3, "folding/MatrixFoldingES3.sksl")
John Stiles7b928972021-01-27 09:56:04 -0500350
John Stilesd4374782021-02-05 09:31:21 -0500351SKSL_TEST(SkSLIntrinsicAbsInt, "intrinsics/AbsInt.sksl")
352SKSL_TEST(SkSLIntrinsicClampInt, "intrinsics/ClampInt.sksl")
353SKSL_TEST(SkSLIntrinsicMaxInt, "intrinsics/MaxInt.sksl")
354SKSL_TEST(SkSLIntrinsicMinInt, "intrinsics/MinInt.sksl")
355SKSL_TEST(SkSLIntrinsicMixBool, "intrinsics/MixBool.sksl")
356SKSL_TEST(SkSLIntrinsicSignInt, "intrinsics/SignInt.sksl")
John Stilese1658b52021-01-29 11:44:13 -0500357
John Stilesd4374782021-02-05 09:31:21 -0500358SKSL_TEST(SkSLDeadLoopVariable, "shared/DeadLoopVariable.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500359SKSL_TEST(SkSLEmptyBlocksES3, "shared/EmptyBlocksES3.sksl")
360SKSL_TEST(SkSLHexUnsigned, "shared/HexUnsigned.sksl")
John Stilesd4374782021-02-05 09:31:21 -0500361SKSL_TEST(SkSLResizeMatrixNonsquare, "shared/ResizeMatrixNonsquare.sksl")
John Stilesb3dcbb12021-03-04 16:00:20 -0500362SKSL_TEST(SkSLReturnsValueOnEveryPathES3, "shared/ReturnsValueOnEveryPathES3.sksl")
John Stilesc2c1b0c2021-02-05 16:24:03 -0500363SKSL_TEST(SkSLSwizzleByIndex, "shared/SwizzleByIndex.sksl")
John Stiles232dd2b2021-01-25 10:57:47 -0500364*/