skia2/tests/SkSLTest.cpp

494 lines
27 KiB
C++
Raw Normal View History

/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkData.h"
#include "include/core/SkFont.h"
#include "include/core/SkPaint.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "include/effects/SkGradientShader.h"
#include "include/effects/SkImageFilters.h"
#include "include/effects/SkRuntimeEffect.h"
#include "include/private/SkSLDefines.h" // for kDefaultInlineThreshold
#include "include/sksl/DSLCore.h"
#include "include/utils/SkRandom.h"
#include "src/core/SkRuntimeEffectPriv.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrDirectContextPriv.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLDehydrator.h"
#include "src/sksl/SkSLRehydrator.h"
#include "src/sksl/SkSLThreadContext.h"
#include "tests/Test.h"
#include "tools/Resources.h"
#include "tools/ToolUtils.h"
static constexpr int kWidth = 2;
static constexpr int kHeight = 2;
template <typename T>
static void set_uniform(SkRuntimeShaderBuilder* builder, const char* name, const T& value) {
SkRuntimeShaderBuilder::BuilderUniform uniform = builder->uniform(name);
if (uniform.fVar) {
uniform = value;
}
}
template <typename T>
static void set_uniform_array(SkRuntimeShaderBuilder* builder, const char* name, SkSpan<T> values) {
SkRuntimeShaderBuilder::BuilderUniform uniform = builder->uniform(name);
if (uniform.fVar) {
uniform.set(values.data(), values.size());
}
}
static SkString load_source(skiatest::Reporter* r,
const char* testFile,
const char* permutationSuffix) {
SkString resourcePath = SkStringPrintf("sksl/%s", testFile);
sk_sp<SkData> shaderData = GetResourceAsData(resourcePath.c_str());
if (!shaderData) {
ERRORF(r, "%s%s: Unable to load file", testFile, permutationSuffix);
return SkString("");
}
return SkString{reinterpret_cast<const char*>(shaderData->bytes()), shaderData->size()};
}
static void test_one_permutation(skiatest::Reporter* r,
SkSurface* surface,
const char* testFile,
const char* permutationSuffix,
const SkRuntimeEffect::Options& options) {
SkString shaderString = load_source(r, testFile, permutationSuffix);
if (shaderString.isEmpty()) {
return;
}
SkRuntimeEffect::Result result = SkRuntimeEffect::MakeForShader(shaderString, options);
if (!result.effect) {
ERRORF(r, "%s%s: %s", testFile, permutationSuffix, result.errorText.c_str());
return;
}
static constexpr float kArray[5] = {1, 2, 3, 4, 5};
SkRuntimeShaderBuilder builder(result.effect);
Reland "Add some SkSL intrinsics to our dm tests." This reverts commit b576168c8ca86daa494f2d64f2967e83bd65efa9. Reason for revert: disabled floor test due to undiagnosed ANGLE + DX9 + Intel6000 failures Original change's description: > Revert "Add some SkSL intrinsics to our dm tests." > > This reverts commit 0492a744a52db0eaf360d2d3fce3ec5ca75dc5f0. > > Reason for revert: Intel HD6000 + ANGLE DX9 fails the floor() test. > > Original change's description: > > Add some SkSL intrinsics to our dm tests. > > > > This CL adds dm coverage for: > > - abs(half) > > - sign(half) > > - floor > > - ceil > > > > And creates test output for abs(int) and sign(int); these aren't covered > > by dm because they don't exist in ES2 and so are unsupported by Runtime > > Effects. > > > > Change-Id: Ia3e660408cef50dec8fa4b6bdc12906e96179f6e > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360419 > > Reviewed-by: Ethan Nicholas <ethannicholas@google.com> > > Commit-Queue: John Stiles <johnstiles@google.com> > > Auto-Submit: John Stiles <johnstiles@google.com> > > TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com > > Change-Id: I62121efee9315b16e61e7d38659b6f629bdf8bd8 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362056 > Reviewed-by: John Stiles <johnstiles@google.com> > Commit-Queue: John Stiles <johnstiles@google.com> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com Change-Id: I22f22f631d85d93a8fe5686a99311ec2cf85fa4d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362103 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-29 16:44:13 +00:00
set_uniform(&builder, "colorBlack", SkV4{0, 0, 0, 1});
set_uniform(&builder, "colorRed", SkV4{1, 0, 0, 1});
set_uniform(&builder, "colorGreen", SkV4{0, 1, 0, 1});
set_uniform(&builder, "colorBlue", SkV4{0, 0, 1, 1});
set_uniform(&builder, "colorWhite", SkV4{1, 1, 1, 1});
set_uniform(&builder, "testInputs", SkV4{-1.25, 0, 0.75, 2.25});
Reland "Add support for matrix == and != in Metal shaders." This reverts commit 4908a24d4b24ad34a3dce693d931654b872bff08. Reason for revert: test fails on Adreno 5xx/6xx, will land tests separately and disable on Adreno Original change's description: > Revert "Add support for matrix == and != in Metal shaders." > > This reverts commit c50185718830a6220b28be885cebd3959a0f0698. > > Reason for revert: breaking many bots > > Original change's description: > > Add support for matrix == and != in Metal shaders. > > > > We need to polyfill an operator== and != when these are first > > encountered in the code. > > > > Change-Id: I539c838ee1871bcb0c4b66abb8a4a0f91146cd4f > > Bug: skia:11306 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368496 > > Auto-Submit: John Stiles <johnstiles@google.com> > > Reviewed-by: Brian Osman <brianosman@google.com> > > TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com > > Change-Id: Id583109a0d167c2c58a57644b14cd5f49d670737 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:11306 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368801 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,brianosman@google.com,ethannicholas@google.com,johnstiles@google.com Bug: skia:11306 Change-Id: If7c628b8c7a2ce40d6c88599a7660ff91c4ac67a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368804 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-10 14:53:41 +00:00
set_uniform(&builder, "testMatrix2x2", std::array<float,4>{1, 2,
3, 4});
set_uniform(&builder, "testMatrix3x3", std::array<float,9>{1, 2, 3,
4, 5, 6,
7, 8, 9});
Reland "Add some SkSL intrinsics to our dm tests." This reverts commit b576168c8ca86daa494f2d64f2967e83bd65efa9. Reason for revert: disabled floor test due to undiagnosed ANGLE + DX9 + Intel6000 failures Original change's description: > Revert "Add some SkSL intrinsics to our dm tests." > > This reverts commit 0492a744a52db0eaf360d2d3fce3ec5ca75dc5f0. > > Reason for revert: Intel HD6000 + ANGLE DX9 fails the floor() test. > > Original change's description: > > Add some SkSL intrinsics to our dm tests. > > > > This CL adds dm coverage for: > > - abs(half) > > - sign(half) > > - floor > > - ceil > > > > And creates test output for abs(int) and sign(int); these aren't covered > > by dm because they don't exist in ES2 and so are unsupported by Runtime > > Effects. > > > > Change-Id: Ia3e660408cef50dec8fa4b6bdc12906e96179f6e > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360419 > > Reviewed-by: Ethan Nicholas <ethannicholas@google.com> > > Commit-Queue: John Stiles <johnstiles@google.com> > > Auto-Submit: John Stiles <johnstiles@google.com> > > TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com > > Change-Id: I62121efee9315b16e61e7d38659b6f629bdf8bd8 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362056 > Reviewed-by: John Stiles <johnstiles@google.com> > Commit-Queue: John Stiles <johnstiles@google.com> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com Change-Id: I22f22f631d85d93a8fe5686a99311ec2cf85fa4d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362103 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-29 16:44:13 +00:00
set_uniform(&builder, "unknownInput", 1.0f);
set_uniform(&builder, "testMatrix2x2", std::array<float,4>{1, 2,
3, 4});
set_uniform(&builder, "testMatrix3x3", std::array<float,9>{1, 2, 3,
4, 5, 6,
7, 8, 9});
set_uniform_array(&builder, "testArray", SkMakeSpan(kArray));
sk_sp<SkShader> shader = builder.makeShader();
if (!shader) {
ERRORF(r, "%s%s: Unable to build shader", testFile, permutationSuffix);
return;
}
SkPaint paintShader;
paintShader.setShader(shader);
surface->getCanvas()->drawRect(SkRect::MakeWH(kWidth, kHeight), paintShader);
SkBitmap bitmap;
REPORTER_ASSERT(r, bitmap.tryAllocPixels(surface->imageInfo()));
REPORTER_ASSERT(r, surface->readPixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(),
/*srcX=*/0, /*srcY=*/0));
bool success = true;
SkColor color[kHeight][kWidth];
for (int y = 0; y < kHeight; ++y) {
for (int x = 0; x < kWidth; ++x) {
color[y][x] = bitmap.getColor(x, y);
if (color[y][x] != SkColorSetARGB(0xFF, 0x00, 0xFF, 0x00)) {
success = false;
}
}
}
if (!success) {
static_assert(kWidth == 2);
static_assert(kHeight == 2);
ERRORF(r, "Expected: solid green. Actual:\n"
"RRGGBBAA RRGGBBAA\n"
"%02X%02X%02X%02X %02X%02X%02X%02X\n"
"%02X%02X%02X%02X %02X%02X%02X%02X",
SkColorGetR(color[0][0]), SkColorGetG(color[0][0]),
SkColorGetB(color[0][0]), SkColorGetA(color[0][0]),
SkColorGetR(color[0][1]), SkColorGetG(color[0][1]),
SkColorGetB(color[0][1]), SkColorGetA(color[0][1]),
SkColorGetR(color[1][0]), SkColorGetG(color[1][0]),
SkColorGetB(color[1][0]), SkColorGetA(color[1][0]),
SkColorGetR(color[1][1]), SkColorGetG(color[1][1]),
SkColorGetB(color[1][1]), SkColorGetA(color[1][1]));
}
}
static void test_permutations(skiatest::Reporter* r,
SkSurface* surface,
const char* testFile,
bool strictES2) {
SkRuntimeEffect::Options options =
strictES2 ? SkRuntimeEffect::Options{} : SkRuntimeEffectPriv::ES3Options();
options.forceNoInline = false;
test_one_permutation(r, surface, testFile, "", options);
options.forceNoInline = true;
test_one_permutation(r, surface, testFile, " (NoInline)", options);
}
static void test_cpu(skiatest::Reporter* r, const char* testFile, bool strictES2) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
sk_sp<SkSurface> surface(SkSurface::MakeRaster(info));
test_permutations(r, surface.get(), testFile, strictES2);
}
static void test_gpu(skiatest::Reporter* r, GrDirectContext* ctx, const char* testFile) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
test_permutations(r, surface.get(), testFile, /*strictES2=*/true);
}
static void test_es3(skiatest::Reporter* r, GrDirectContext* ctx, const char* testFile) {
if (!ctx->priv().caps()->shaderCaps()->supportsSkSLES3()) {
return;
}
// ES3-only tests never run on the CPU, because SkVM lacks support for many non-ES2 features.
const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
test_permutations(r, surface.get(), testFile, /*strictES2=*/false);
}
static void test_clone(skiatest::Reporter* r, const char* testFile, bool strictES2) {
SkString shaderString = load_source(r, testFile, "");
if (shaderString.isEmpty()) {
return;
}
std::unique_ptr<SkSL::ShaderCaps> caps = SkSL::ShaderCapsFactory::Standalone();
SkSL::Program::Settings settings;
settings.fAllowVarDeclarationCloneForTesting = true;
settings.fEnforceES2Restrictions = strictES2;
SkSL::Compiler compiler(caps.get());
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(
SkSL::ProgramKind::kRuntimeShader, shaderString.c_str(), settings);
if (!program) {
ERRORF(r, "%s", compiler.errorText().c_str());
return;
}
// Starting DSL allows us to get access to the ThreadContext::Settings
SkSL::dsl::Start(&compiler, SkSL::ProgramKind::kFragment, settings);
for (const std::unique_ptr<SkSL::ProgramElement>& element : program->fOwnedElements) {
std::string original = element->description();
std::string cloned = element->clone()->description();
REPORTER_ASSERT(r, original == cloned,
"Mismatch after clone!\nOriginal: %s\nCloned: %s\n", original.c_str(),
cloned.c_str());
}
SkSL::dsl::End();
}
static void test_rehydrate(skiatest::Reporter* r, const char* testFile, bool strictES2) {
SkString shaderString = load_source(r, testFile, "");
if (shaderString.isEmpty()) {
return;
}
std::unique_ptr<SkSL::ShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
SkSL::Compiler compiler(caps.get());
SkSL::Program::Settings settings;
settings.fEnforceES2Restrictions = strictES2;
// Inlining causes problems because it can create expressions like bool(1) that can't be
// directly instantiated. After a dehydrate/recycle pass, that expression simply becomes "true"
// due to optimization - which is fine, but would cause us to fail an equality comparison. We
// disable inlining to avoid this issue.
settings.fInlineThreshold = 0;
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(
SkSL::ProgramKind::kRuntimeShader, shaderString.c_str(), settings);
if (!program) {
ERRORF(r, "%s", compiler.errorText().c_str());
return;
}
SkSL::Dehydrator dehydrator;
dehydrator.write(*program);
SkSL::StringStream stream;
dehydrator.finish(stream);
SkSL::Rehydrator rehydrator(compiler, (const uint8_t*) stream.str().data(),
stream.str().length());
std::unique_ptr<SkSL::Program> rehydrated = rehydrator.program();
REPORTER_ASSERT(r, rehydrated->description() == program->description(),
"Mismatch between original and dehydrated/rehydrated:\n-- Original:\n%s\n"
"-- Rehydrated:\n%s", program->description().c_str(),
rehydrated->description().c_str());
}
// Helper macros for various test environment invocations. Do not use these to declare test cases.
// Use one of the SKSL_TEST_* macros below instead.
#define DECL_TEST_CPU(name, path) \
DEF_TEST(name##_CPU, r) { test_cpu(r, path, /*strictES2=*/true); }
#define DECL_TEST_CPU_NO_STRICT_ES2(name, path) \
DEF_TEST(name##_CPU_NO_STRICT_ES2, r) { test_cpu(r, path, /*strictES2=*/false); }
#define DECL_TEST_GPU(name, path) \
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name##_GPU, r, ctxInfo) { \
test_gpu(r, ctxInfo.directContext(), path); \
}
#define DECL_TEST_GPU_ES3(name, path) \
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name##_GPU_ES3, r, ctxInfo) { \
test_es3(r, ctxInfo.directContext(), path); \
}
#define DECL_TEST_CLONE(name, path, strictES2) \
DEF_TEST(name##_CLONE, r) { test_clone(r, path, strictES2); }
#define DECL_TEST_REHYDRATE(name, path, strictES2) \
DEF_TEST(name##_REHYDRATE, r) { test_rehydrate(r, path, strictES2); }
// Use the following macros when declaring test cases:
#define SKSL_TEST_CPU(name, path) \
DECL_TEST_CPU(name, path) \
DECL_TEST_CLONE(name, path, /*strictES2=*/true) \
DECL_TEST_REHYDRATE(name, path, /*strictES2=*/true)
// Tests that only use the CPU backend but without "strict ES2 mode", which limits SkSL language
// features to GLSL ES 1.0. The CPU backend lacks support for many ES3 features. This is
// appropriate for tests that use a subset of ES3 that is supported.
#define SKSL_TEST_CPU_NO_STRICT_ES2(name, path) \
DECL_TEST_CPU_NO_STRICT_ES2(name, path) \
DECL_TEST_CLONE(name, path, /*strictES2=*/false) \
DECL_TEST_REHYDRATE(name, path, /*strictES2=*/false)
// Tests that run on GPUs with ES3 support only.
#define SKSL_TEST_GPU_ES3(name, path) \
DECL_TEST_GPU_ES3(name, path) \
DECL_TEST_CLONE(name, path, /*strictES2=*/false) \
DECL_TEST_REHYDRATE(name, path, /*strictES2=*/false)
#define SKSL_TEST(name, path) \
DECL_TEST_CPU(name, path) \
DECL_TEST_GPU(name, path) \
DECL_TEST_CLONE(name, path, /*strictES2=*/true) \
DECL_TEST_REHYDRATE(name, path, /*strictES2=*/true)
SKSL_TEST(SkSLArraySizeFolding, "folding/ArraySizeFolding.sksl")
SKSL_TEST(SkSLAssignmentOps, "folding/AssignmentOps.sksl")
SKSL_TEST(SkSLBoolFolding, "folding/BoolFolding.sksl")
SKSL_TEST(SkSLCastFolding, "folding/CastFolding.sksl")
SKSL_TEST(SkSLIntFoldingES2, "folding/IntFoldingES2.sksl")
SKSL_TEST_GPU_ES3(SkSLIntFoldingES3, "folding/IntFoldingES3.sksl")
SKSL_TEST(SkSLFloatFolding, "folding/FloatFolding.sksl")
SKSL_TEST(SkSLMatrixFoldingES2, "folding/MatrixFoldingES2.sksl")
SKSL_TEST_GPU_ES3(SkSLMatrixFoldingES3, "folding/MatrixFoldingES3.sksl")
SKSL_TEST(SkSLSelfAssignment, "folding/SelfAssignment.sksl")
SKSL_TEST(SkSLShortCircuitBoolFolding, "folding/ShortCircuitBoolFolding.sksl")
SKSL_TEST(SkSLSwitchCaseFolding, "folding/SwitchCaseFolding.sksl")
SKSL_TEST(SkSLSwizzleFolding, "folding/SwizzleFolding.sksl")
SKSL_TEST(SkSLVectorScalarFolding, "folding/VectorScalarFolding.sksl")
SKSL_TEST(SkSLVectorVectorFolding, "folding/VectorVectorFolding.sksl")
SKSL_TEST_GPU_ES3(SkSLDoWhileBodyMustBeInlinedIntoAScope,
"inliner/DoWhileBodyMustBeInlinedIntoAScope.sksl")
SKSL_TEST_GPU_ES3(SkSLDoWhileTestCannotBeInlined, "inliner/DoWhileTestCannotBeInlined.sksl")
SKSL_TEST(SkSLForBodyMustBeInlinedIntoAScope, "inliner/ForBodyMustBeInlinedIntoAScope.sksl")
SKSL_TEST_GPU_ES3(SkSLForInitializerExpressionsCanBeInlined,
"inliner/ForInitializerExpressionsCanBeInlined.sksl")
SKSL_TEST(SkSLForWithoutReturnInsideCanBeInlined, "inliner/ForWithoutReturnInsideCanBeInlined.sksl")
SKSL_TEST(SkSLForWithReturnInsideCannotBeInlined, "inliner/ForWithReturnInsideCannotBeInlined.sksl")
SKSL_TEST(SkSLIfBodyMustBeInlinedIntoAScope, "inliner/IfBodyMustBeInlinedIntoAScope.sksl")
SKSL_TEST(SkSLIfElseBodyMustBeInlinedIntoAScope, "inliner/IfElseBodyMustBeInlinedIntoAScope.sksl")
SKSL_TEST(SkSLIfElseChainWithReturnsCanBeInlined, "inliner/IfElseChainWithReturnsCanBeInlined.sksl")
SKSL_TEST(SkSLIfTestCanBeInlined, "inliner/IfTestCanBeInlined.sksl")
SKSL_TEST(SkSLIfWithReturnsCanBeInlined, "inliner/IfWithReturnsCanBeInlined.sksl")
SKSL_TEST(SkSLInlineKeywordOverridesThreshold, "inliner/InlineKeywordOverridesThreshold.sksl")
SKSL_TEST(SkSLInlinerAvoidsVariableNameOverlap, "inliner/InlinerAvoidsVariableNameOverlap.sksl")
SKSL_TEST(SkSLInlinerElidesTempVarForReturnsInsideBlock,
"inliner/InlinerElidesTempVarForReturnsInsideBlock.sksl")
SKSL_TEST(SkSLInlinerUsesTempVarForMultipleReturns,
"inliner/InlinerUsesTempVarForMultipleReturns.sksl")
SKSL_TEST(SkSLInlinerUsesTempVarForReturnsInsideBlockWithVar,
"inliner/InlinerUsesTempVarForReturnsInsideBlockWithVar.sksl")
SKSL_TEST(SkSLInlineThreshold, "inliner/InlineThreshold.sksl")
SKSL_TEST(SkSLInlineWithModifiedArgument, "inliner/InlineWithModifiedArgument.sksl")
SKSL_TEST(SkSLInlineWithNestedBigCalls, "inliner/InlineWithNestedBigCalls.sksl")
SKSL_TEST(SkSLInlineWithUnmodifiedArgument, "inliner/InlineWithUnmodifiedArgument.sksl")
SKSL_TEST(SkSLInlineWithUnnecessaryBlocks, "inliner/InlineWithUnnecessaryBlocks.sksl")
SKSL_TEST(SkSLNoInline, "inliner/NoInline.sksl")
SKSL_TEST(SkSLShortCircuitEvaluationsCannotInlineRightHandSide,
"inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl")
SKSL_TEST_GPU_ES3(SkSLStaticSwitchInline, "inliner/StaticSwitch.sksl")
SKSL_TEST(SkSLStructsCanBeInlinedSafely, "inliner/StructsCanBeInlinedSafely.sksl")
SKSL_TEST(SkSLSwizzleCanBeInlinedDirectly, "inliner/SwizzleCanBeInlinedDirectly.sksl")
SKSL_TEST(SkSLTernaryResultsCannotBeInlined, "inliner/TernaryResultsCannotBeInlined.sksl")
SKSL_TEST(SkSLTernaryTestCanBeInlined, "inliner/TernaryTestCanBeInlined.sksl")
SKSL_TEST(SkSLTrivialArgumentsInlineDirectly, "inliner/TrivialArgumentsInlineDirectly.sksl")
SKSL_TEST_GPU_ES3(SkSLWhileBodyMustBeInlinedIntoAScope,
"inliner/WhileBodyMustBeInlinedIntoAScope.sksl")
SKSL_TEST_GPU_ES3(SkSLWhileTestCannotBeInlined, "inliner/WhileTestCannotBeInlined.sksl")
SKSL_TEST(SkSLIntrinsicAbsFloat, "intrinsics/AbsFloat.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicAbsInt, "intrinsics/AbsInt.sksl")
SKSL_TEST(SkSLIntrinsicCeil, "intrinsics/Ceil.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicDeterminant, "intrinsics/Determinant.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicDFdx, "intrinsics/DFdx.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicDFdy, "intrinsics/DFdy.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicFloatBitsToInt, "intrinsics/FloatBitsToInt.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicFloatBitsToUint, "intrinsics/FloatBitsToUint.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicFwidth, "intrinsics/Fwidth.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicIntBitsToFloat, "intrinsics/IntBitsToFloat.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicIsInf, "intrinsics/IsInf.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicClampInt, "intrinsics/ClampInt.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicClampUInt, "intrinsics/ClampUInt.sksl")
SKSL_TEST(SkSLIntrinsicClampFloat, "intrinsics/ClampFloat.sksl")
SKSL_TEST(SkSLIntrinsicMatrixCompMultES2, "intrinsics/MatrixCompMultES2.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicMatrixCompMultES3, "intrinsics/MatrixCompMultES3.sksl")
SKSL_TEST(SkSLIntrinsicMaxFloat, "intrinsics/MaxFloat.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicMaxInt, "intrinsics/MaxInt.sksl")
SKSL_TEST(SkSLIntrinsicMinFloat, "intrinsics/MinFloat.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicMinInt, "intrinsics/MinInt.sksl")
SKSL_TEST(SkSLIntrinsicMixFloat, "intrinsics/MixFloat.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicModf, "intrinsics/Modf.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicOuterProduct, "intrinsics/OuterProduct.sksl")
// Fails on Mac OpenGL + Radeon 5300M (skia:12434)
// SKSL_TEST_GPU_ES3(SkSLIntrinsicPackUnorm2x16, "intrinsics/PackUnorm2x16.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicRound, "intrinsics/Round.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicRoundEven, "intrinsics/RoundEven.sksl")
SKSL_TEST(SkSLIntrinsicSignFloat, "intrinsics/SignFloat.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicSignInt, "intrinsics/SignInt.sksl")
SKSL_TEST(SkSLIntrinsicStep, "intrinsics/Step.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicTrunc, "intrinsics/Trunc.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicTranspose, "intrinsics/Transpose.sksl")
SKSL_TEST_GPU_ES3(SkSLIntrinsicUintBitsToFloat, "intrinsics/UintBitsToFloat.sksl")
SKSL_TEST_GPU_ES3(SkSLArrayNarrowingConversions, "runtime/ArrayNarrowingConversions.rts")
SKSL_TEST(SkSLLoopFloat, "runtime/LoopFloat.rts")
SKSL_TEST(SkSLLoopInt, "runtime/LoopInt.rts")
SKSL_TEST(SkSLQualifierOrder, "runtime/QualifierOrder.rts")
SKSL_TEST(SkSLPrecisionQualifiers, "runtime/PrecisionQualifiers.rts")
// These tests specifically rely on SkVM backend behavior that is difficult to enforce on Metal and
// GLSL implementations and specifically differs from Vulkan behavior (skia:12977). They also
// rely on equality operators on array types which are not available in GLSL ES 1.00. Therefore
// these tests are restricted to run on CPU and with "strict ES2 mode" disabled.
SKSL_TEST_CPU_NO_STRICT_ES2(SkSLRecursiveComparison_Arrays,
"runtime/RecursiveComparison_Arrays.rts")
SKSL_TEST_CPU_NO_STRICT_ES2(SkSLRecursiveComparison_Structs,
"runtime/RecursiveComparison_Structs.rts")
SKSL_TEST_CPU_NO_STRICT_ES2(SkSLRecursiveComparison_Types, "runtime/RecursiveComparison_Types.rts")
SKSL_TEST_CPU_NO_STRICT_ES2(SkSLRecursiveComparison_Vectors,
"runtime/RecursiveComparison_Vectors.rts")
SKSL_TEST_GPU_ES3(SkSLArrayComparison, "shared/ArrayComparison.sksl")
SKSL_TEST_GPU_ES3(SkSLArrayConstructors, "shared/ArrayConstructors.sksl")
SKSL_TEST_GPU_ES3(SkSLArrayCast, "shared/ArrayCast.sksl")
SKSL_TEST_GPU_ES3(SkSLArrayFollowedByScalar, "shared/ArrayFollowedByScalar.sksl")
SKSL_TEST(SkSLArrayTypes, "shared/ArrayTypes.sksl")
SKSL_TEST(SkSLAssignment, "shared/Assignment.sksl")
SKSL_TEST(SkSLCastsRoundTowardZero, "shared/CastsRoundTowardZero.sksl")
SKSL_TEST(SkSLCommaMixedTypes, "shared/CommaMixedTypes.sksl")
SKSL_TEST(SkSLCommaSideEffects, "shared/CommaSideEffects.sksl")
SKSL_TEST(SkSLConstantIf, "shared/ConstantIf.sksl")
SKSL_TEST_GPU_ES3(SkSLConstArray, "shared/ConstArray.sksl")
SKSL_TEST(SkSLConstVariableComparison, "shared/ConstVariableComparison.sksl")
SKSL_TEST_GPU_ES3(SkSLDeadLoopVariable, "shared/DeadLoopVariable.sksl")
SKSL_TEST(SkSLDeadIfStatement, "shared/DeadIfStatement.sksl")
SKSL_TEST(SkSLDeadReturn, "shared/DeadReturn.sksl")
// TODO(skia:12012): some Radeons crash when compiling this code; disable them
// SKSL_TEST_GPU_ES3(SkSLDeadReturnES3, "shared/DeadReturnES3.sksl")
SKSL_TEST(SkSLDeadStripFunctions, "shared/DeadStripFunctions.sksl")
SKSL_TEST(SkSLDependentInitializers, "shared/DependentInitializers.sksl")
SKSL_TEST_GPU_ES3(SkSLDoWhileControlFlow, "shared/DoWhileControlFlow.sksl")
SKSL_TEST(SkSLEmptyBlocksES2, "shared/EmptyBlocksES2.sksl")
SKSL_TEST_GPU_ES3(SkSLEmptyBlocksES3, "shared/EmptyBlocksES3.sksl")
SKSL_TEST(SkSLForLoopControlFlow, "shared/ForLoopControlFlow.sksl")
SKSL_TEST(SkSLFunctionAnonymousParameters, "shared/FunctionAnonymousParameters.sksl")
SKSL_TEST(SkSLFunctionArgTypeMatch, "shared/FunctionArgTypeMatch.sksl")
SKSL_TEST(SkSLFunctionReturnTypeMatch, "shared/FunctionReturnTypeMatch.sksl")
SKSL_TEST(SkSLFunctions, "shared/Functions.sksl")
SKSL_TEST(SkSLFunctionPrototype, "shared/FunctionPrototype.sksl")
SKSL_TEST(SkSLGeometricIntrinsics, "shared/GeometricIntrinsics.sksl")
SKSL_TEST(SkSLHelloWorld, "shared/HelloWorld.sksl")
SKSL_TEST(SkSLHex, "shared/Hex.sksl")
SKSL_TEST_GPU_ES3(SkSLHexUnsigned, "shared/HexUnsigned.sksl")
SKSL_TEST(SkSLInoutParameters, "shared/InoutParameters.sksl")
SKSL_TEST(SkSLMatrices, "shared/Matrices.sksl")
SKSL_TEST_GPU_ES3(SkSLMatricesNonsquare, "shared/MatricesNonsquare.sksl")
// TODO(skia:12443) These tests actually don't work on MANY devices. The GLSL conformance suite
// does a terrible job of enforcing this rule. We still test them on CPU.
SKSL_TEST_CPU(SkSLMatrixConstructorsES2, "shared/MatrixConstructorsES2.sksl")
SKSL_TEST_CPU_NO_STRICT_ES2(SkSLMatrixConstructorsES3, "shared/MatrixConstructorsES3.sksl")
SKSL_TEST(SkSLMatrixEquality, "shared/MatrixEquality.sksl")
SKSL_TEST(SkSLMatrixScalarMath, "shared/MatrixScalarMath.sksl")
SKSL_TEST(SkSLMatrixToVectorCast, "shared/MatrixToVectorCast.sksl")
SKSL_TEST(SkSLMultipleAssignments, "shared/MultipleAssignments.sksl")
SKSL_TEST(SkSLNegation, "shared/Negation.sksl")
SKSL_TEST(SkSLNumberCasts, "shared/NumberCasts.sksl")
SKSL_TEST(SkSLOperatorsES2, "shared/OperatorsES2.sksl")
SKSL_TEST_GPU_ES3(SkSLOperatorsES3, "shared/OperatorsES3.sksl")
SKSL_TEST(SkSLOssfuzz36852, "shared/Ossfuzz36852.sksl")
SKSL_TEST(SkSLOutParams, "shared/OutParams.sksl")
SKSL_TEST(SkSLOutParamsAreDistinct, "shared/OutParamsAreDistinct.sksl")
SKSL_TEST(SkSLOutParamsTricky, "shared/OutParamsTricky.sksl")
SKSL_TEST(SkSLResizeMatrix, "shared/ResizeMatrix.sksl")
SKSL_TEST_GPU_ES3(SkSLResizeMatrixNonsquare, "shared/ResizeMatrixNonsquare.sksl")
SKSL_TEST(SkSLReturnsValueOnEveryPathES2, "shared/ReturnsValueOnEveryPathES2.sksl")
SKSL_TEST_GPU_ES3(SkSLReturnsValueOnEveryPathES3, "shared/ReturnsValueOnEveryPathES3.sksl")
SKSL_TEST(SkSLScalarConversionConstructorsES2, "shared/ScalarConversionConstructorsES2.sksl")
SKSL_TEST(SkSLScopedSymbol, "shared/ScopedSymbol.sksl")
SKSL_TEST_GPU_ES3(SkSLScalarConversionConstructorsES3,
"shared/ScalarConversionConstructorsES3.sksl")
SKSL_TEST(SkSLStackingVectorCasts, "shared/StackingVectorCasts.sksl")
SKSL_TEST(SkSLStaticIf, "shared/StaticIf.sksl")
SKSL_TEST_GPU_ES3(SkSLStaticSwitch, "shared/StaticSwitch.sksl")
SKSL_TEST(SkSLStructArrayFollowedByScalar, "shared/StructArrayFollowedByScalar.sksl")
Reland "Implement operator== and != for Metal structs and arrays." This is a reland of 830c69ca66d339067cdc06775f59443a06fc15a2 Original change's description: > Implement operator== and != for Metal structs and arrays. > > GLSL/SkSL assumes that == and != on struct/array types should work. > We need to emit equality and inequality operators whenever we find code > that compares a struct or array. > > Structs and arrays can be arbitrarily nested, and either type can > contain a matrix. All of these things need custom equality operators in > Metal. Therefore, we need to recursively generate comparison operators > when any of these types are encountered. > > For arrays we get lucky, and we can cover all possible array types and > sizes with a single templated operator== method. Structs and matrices > have no such luck, and are generated separately on a per-type basis. > > For each of these types, operator== is implemented as an equality check > on each field, and operator!= is implemented in terms of operator==. > Equality and inequality are always emitted together. (Previously, matrix > equality and inequality were emitted and implemented independently, but > this is no longer the case.) > > Change-Id: I69ee01c0a390d7db6bcb2253ed6336ab20cc4d1d > Bug: skia:11908, skia:11924 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402016 > Auto-Submit: John Stiles <johnstiles@google.com> > Commit-Queue: Brian Osman <brianosman@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> Bug: skia:11908, skia:11924, skia:11929 Change-Id: I6336b6125e9774c1ca73e3d497e3466f11f6f25f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402559 Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-29 18:39:35 +00:00
SKSL_TEST(SkSLStructsInFunctions, "shared/StructsInFunctions.sksl")
Re-re-reland "Rewrite switch statements in GLSL strict-ES2 mode." This reverts commit 6f06bab632490b82a3cc73be76f8c5ad119ac092. Reason for revert: glslGeneration is more trustworthy than GR_GL_VER Original change's description: > Revert "Re-reland "Rewrite switch statements in GLSL strict-ES2 mode.""" > > This reverts commit 64560c7cd59b369c792f207cb0295b26978e2724. > > Reason for revert: Nexus5, also > > Original change's description: > > Re-reland "Rewrite switch statements in GLSL strict-ES2 mode."" > > > > This reverts commit c4c355940c9f5be879d1c1997724a4cf61e68b53. > > > > Reason for revert: disabled offending tests > > > > Original change's description: > > > Revert "Reland "Rewrite switch statements in GLSL strict-ES2 mode."" > > > > > > This reverts commit c81edd0e8cd999a92ae943f284ee31c25f0f9373. > > > > > > Reason for revert: ANGLE still unhappy > > > Original change's description: > > > > Reland "Rewrite switch statements in GLSL strict-ES2 mode." > > > > > > > > This reverts commit d26d0e6a47aea2575f29b4582a4f662a17a8fff2. > > > > > > > > Reason for revert: uses dedicated caps bit > > > > > > > > Original change's description: > > > > > Revert "Rewrite switch statements in GLSL strict-ES2 mode." > > > > > > > > > > This reverts commit 45e3838006df8bc393fe6f4ca1cff999b41167f4. > > > > > > > > > > Reason for revert: Also need to rewrite them in actual ES2 mode. > > > > > > > > > > Original change's description: > > > > > > Rewrite switch statements in GLSL strict-ES2 mode. > > > > > > > > > > > > Once this lands, switch statements will work everywhere--Metal, SPIR-V, > > > > > > GLSL, and SkVM. > > > > > > > > > > > > Change-Id: I2797d0a872de8be77bb9f7aa6acb93421d571d70 > > > > > > Bug: skia:12450 > > > > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452356 > > > > > > Commit-Queue: John Stiles <johnstiles@google.com> > > > > > > Auto-Submit: John Stiles <johnstiles@google.com> > > > > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > > > > > > > > Bug: skia:12450 > > > > > Change-Id: I92656ed40289872405c0873f2c56a52b04e35b1d > > > > > No-Presubmit: true > > > > > No-Tree-Checks: true > > > > > No-Try: true > > > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452556 > > > > > Auto-Submit: Brian Osman <brianosman@google.com> > > > > > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > > > > > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > > > > > > > > Bug: skia:12450 > > > > Change-Id: I0d3b0969d2040dbb4ee808132146687767c97442 > > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452560 > > > > Commit-Queue: John Stiles <johnstiles@google.com> > > > > Commit-Queue: Brian Osman <brianosman@google.com> > > > > Auto-Submit: John Stiles <johnstiles@google.com> > > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > > > > Bug: skia:12450 > > > Change-Id: I869cf3e2c47fe94981aa2ffa6c1f0b3e4d6e6862 > > > No-Presubmit: true > > > No-Tree-Checks: true > > > No-Try: true > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452717 > > > Auto-Submit: Brian Osman <brianosman@google.com> > > > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > > > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > > > > Bug: skia:12450 > > Change-Id: Ia0e23e20794ea707e54be50123b5323369354a03 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452721 > > Commit-Queue: John Stiles <johnstiles@google.com> > > Commit-Queue: Brian Osman <brianosman@google.com> > > Auto-Submit: John Stiles <johnstiles@google.com> > > Reviewed-by: Brian Osman <brianosman@google.com> > > Bug: skia:12450 > Change-Id: Id0c0cdfbf146000ec532e57e380c18ff391ca1da > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452896 > Auto-Submit: Brian Osman <brianosman@google.com> > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Bug: skia:12450 Change-Id: I4bac3a468ae20967fe6ec372561dd44f67c6b730 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452897 Auto-Submit: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-25 14:33:00 +00:00
SKSL_TEST(SkSLSwitch, "shared/Switch.sksl")
SKSL_TEST(SkSLSwitchDefaultOnly, "shared/SwitchDefaultOnly.sksl")
SKSL_TEST(SkSLSwitchWithFallthrough, "shared/SwitchWithFallthrough.sksl")
SKSL_TEST(SkSLSwitchWithLoops, "shared/SwitchWithLoops.sksl")
SKSL_TEST(SkSLSwizzleBoolConstants, "shared/SwizzleBoolConstants.sksl")
SKSL_TEST(SkSLSwizzleByConstantIndex, "shared/SwizzleByConstantIndex.sksl")
SKSL_TEST_GPU_ES3(SkSLSwizzleByIndex, "shared/SwizzleByIndex.sksl")
SKSL_TEST(SkSLSwizzleConstants, "shared/SwizzleConstants.sksl")
SKSL_TEST(SkSLSwizzleLTRB, "shared/SwizzleLTRB.sksl")
SKSL_TEST(SkSLSwizzleOpt, "shared/SwizzleOpt.sksl")
SKSL_TEST(SkSLSwizzleScalar, "shared/SwizzleScalar.sksl")
SKSL_TEST(SkSLSwizzleScalarBool, "shared/SwizzleScalarBool.sksl")
SKSL_TEST(SkSLSwizzleScalarInt, "shared/SwizzleScalarInt.sksl")
SKSL_TEST(SkSLTernaryAsLValueEntirelyFoldable, "shared/TernaryAsLValueEntirelyFoldable.sksl")
SKSL_TEST(SkSLTernaryAsLValueFoldableTest, "shared/TernaryAsLValueFoldableTest.sksl")
SKSL_TEST(SkSLTernaryExpression, "shared/TernaryExpression.sksl")
SKSL_TEST(SkSLUnaryPositiveNegative, "shared/UnaryPositiveNegative.sksl")
SKSL_TEST(SkSLUniformArray, "shared/UniformArray.sksl")
SKSL_TEST(SkSLUnusedVariables, "shared/UnusedVariables.sksl")
SKSL_TEST(SkSLVectorConstructors, "shared/VectorConstructors.sksl")
Reland "Add tests for matrix-vector conversions." This reverts commit f009db5b854b350e9f884fd5268e80271537578b. Reason for revert: test disabled on Win10 + Intel 4400/6100 Original change's description: > Revert "Add tests for matrix-vector conversions." > > This reverts commit a89781215a8182beb0893a004654fef157313259. > > Reason for revert: breakage on Windows > > Original change's description: > > Add tests for matrix-vector conversions. > > > > GLSL supports casting vec4 into mat2 and vice versa, so SkSL should have > > equivalent support. Adding tests as a starting point. > > > > Change-Id: If8bcbf99afcec94d948d5da9e6205cb4a232af18 > > Bug: skia:12067 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425837 > > Auto-Submit: John Stiles <johnstiles@google.com> > > Commit-Queue: Brian Osman <brianosman@google.com> > > Reviewed-by: Brian Osman <brianosman@google.com> > > TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com > > Change-Id: I2563041f538b1b20074385f1b61af5fc506ffad5 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:12067 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426057 > Reviewed-by: John Stiles <johnstiles@google.com> > Commit-Queue: John Stiles <johnstiles@google.com> Bug: skia:12067 Change-Id: I1379914ee39ce340f09b11b3754820db9c645378 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426058 Reviewed-by: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-08 22:20:21 +00:00
SKSL_TEST(SkSLVectorToMatrixCast, "shared/VectorToMatrixCast.sksl")
SKSL_TEST(SkSLVectorScalarMath, "shared/VectorScalarMath.sksl")
SKSL_TEST_GPU_ES3(SkSLWhileLoopControlFlow, "shared/WhileLoopControlFlow.sksl")