66#if defined(SK_GRAPHITE)
142 5.0f, 6.0f, 7.0f, 8.0f,
143 9.0f, 10.0f, 11.0f, 12.0f,
144 13.0f, 14.0f, 15.0f, 16.0f};
171 uniform.
set(data.span.data(), data.span.size());
193#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
206 uniform half4 colorGreen, colorRed;
208 half4 main(float2 xy) {
209 return isnan(colorGreen.r / colorGreen.b) ? colorGreen : colorRed;
227 const char* testFile,
228 const char* permutationSuffix) {
232 ERRORF(r,
"%s%s: Unable to load file", testFile, permutationSuffix);
235 return SkString{
reinterpret_cast<const char*
>(shaderData->bytes()), shaderData->size()};
239 std::string_view backendAPI,
240 std::string_view
name,
242 enum TestTypeMatcher {
CPU, Ganesh, Graphite,
GPU };
245 std::optional<std::regex> deviceName;
246 std::optional<std::string_view> backendAPI;
247 std::optional<TestTypeMatcher> testTypeMatcher;
248 std::optional<bool> platform;
255 #define ADRENO "Adreno \\(TM\\) "
256 #define NVIDIA "(Tegra|Quadro|RTX|GTX) "
258 TestDisableMap disables;
259 constexpr std::nullopt_t _ = std::nullopt;
260 using regex = std::regex;
262#if defined(SK_BUILD_FOR_UNIX)
263 constexpr bool kLinux =
true;
265 constexpr bool kLinux =
false;
267#if defined(SK_BUILD_FOR_MAC)
268 constexpr bool kMac =
true;
270 constexpr bool kMac =
false;
272#if defined(SK_BUILD_FOR_IOS)
273 constexpr bool kiOS =
true;
275 constexpr bool kiOS =
false;
277#if defined(SK_BUILD_FOR_WIN)
278 constexpr bool kWindows =
true;
280 constexpr bool kWindows =
false;
282#if defined(SK_BUILD_FOR_ANDROID)
283 constexpr bool kAndroid =
true;
285 constexpr bool kAndroid =
false;
290 for (
const char*
test : {
"LogicalAndShortCircuit",
291 "LogicalOrShortCircuit"}) {
292 disables[
test].push_back({_,
"OpenGL",
GPU, kMac || kiOS});
296 for (
const char*
test : {
"MatrixScalarNoOpFolding",
299 "OutParamsAreDistinctFromGlobal",
300 "IntrinsicMixFloatES3"}) {
301 disables[
test].push_back({_,
"ANGLE",
GPU, kMac});
305 disables[
"SwitchWithFallthrough"].push_back({_,
"OpenGL",
GPU, kiOS});
309 for (
const char*
test : {
"Matrices",
312 "MatrixSwizzleStore",
313 "MatrixScalarNoOpFolding",
314 "UnaryPositiveNegative",
316 disables[
test].push_back({regex(
"Mali-400"), _,
GPU, _});
321 for (
const char*
test : {
"Switch",
323 "SwitchWithFallthrough",
324 "SwitchWithFallthroughAndVarDecls",
329 "MatrixScalarNoOpFolding",
334 "ModifiedStructParametersCannotBeInlined"}) {
335 disables[
test].push_back({regex(
"Tegra 3"), _,
GPU, _});
340 for (
const char*
test : {
"MatrixConstructorsES2",
341 "MatrixConstructorsES3",
342 "MatrixScalarNoOpFolding",
343 "PreserveSideEffects",
344 "StructFieldNoFolding"}) {
345 disables[
test].push_back({regex(
NVIDIA),
"OpenGL", _, _});
346 disables[
test].push_back({regex(
NVIDIA),
"ANGLE GL", _, _});
349 disables[
"IntrinsicMixFloatES3"].push_back({regex(
"RTX "),
"Vulkan", _, kWindows});
352 for (
const char*
test : {
"PreserveSideEffects",
353 "CommaSideEffects"}) {
354 disables[
test].push_back({regex(
"Quadro P400"), _, _, kLinux});
358 for (
const char*
test : {
"UniformArray",
359 "TemporaryIndexLookup",
360 "MatrixIndexLookup"}) {
361 disables[
test].push_back({regex(
"Quadro P400"),
"Dawn Vulkan", Graphite, kWindows});
365 for (
const char*
test : {
"OutParamsAreDistinct",
366 "OutParamsAreDistinctFromGlobal"}) {
367 disables[
test].push_back({regex(
"PowerVR Rogue GE8300"), _,
GPU, _});
371 for (
const char*
test : {
"DeadReturnES3",
373 "MatrixConstructorsES3",
374 "MatrixScalarNoOpFolding",
376 "SwizzleIndexLookup",
377 "SwizzleIndexStore"}) {
378 disables[
test].push_back({regex(
"Radeon.*(R9|HD)"),
"OpenGL",
GPU, _});
379 disables[
test].push_back({regex(
"Radeon.*(R9|HD)"),
"ANGLE GL",
GPU, _});
383 for (
const char*
test : {
"IntrinsicDFdy",
385 "IntrinsicFwidth"}) {
386 disables[
test].push_back({regex(
"AMD RADV RENOIR"), _,
GPU, _});
391 for (
const char*
test : {
"ArrayCast",
394 "IntrinsicMixFloatES2",
395 "IntrinsicClampFloat",
396 "SwitchWithFallthrough",
397 "SwizzleIndexLookup",
398 "SwizzleIndexStore"}) {
399 disables[
test].push_back({regex(
ADRENO "[3456]"), _, _, kAndroid});
403 for (
const char*
test : {
"VoidInSequenceExpressions",
406 "OutParamsDoubleSwizzle",
408 "OutParamsFunctionCallInArgument"}) {
409 disables[
test].push_back({regex(
ADRENO "[56]"),
"Vulkan", _, kAndroid});
412 for (
const char*
test : {
"MatrixToVectorCast",
413 "StructsInFunctions"}) {
414 disables[
test].push_back({regex(
ADRENO "[345]"),
"OpenGL", _, kAndroid});
418 for (
const char*
test : {
"Matrices",
419 "MatrixNoOpFolding"}) {
420 disables[
test].push_back({regex(
ADRENO "3"),
"OpenGL", _, kAndroid});
424 disables[
"IntrinsicIsInf"].push_back({regex(
ADRENO "6"),
"OpenGL", _, kAndroid});
427 disables[
"EmptyBlocksES3"].push_back({regex(
ADRENO "(540|630)"), _, _, kAndroid});
430 disables[
"OutParamsAreDistinctFromGlobal"].push_back({regex(
ADRENO "[3456]"),
"OpenGL",
433 disables[
"StructFieldFolding"].push_back({regex(
ADRENO "[56]"),
"OpenGL",
437 for (
const char*
test : {
"PrefixExpressionsES2",
438 "MatrixToVectorCast",
439 "MatrixConstructorsES2"}) {
440 disables[
test].push_back({regex(
ADRENO "620"),
"Vulkan", Graphite, kAndroid});
446 disables[
"IntrinsicFloor"].push_back({regex(
"Intel.*(Iris|HD)"),
"ANGLE D3D", _, _});
449 for (
const char*
test : {
"IntrinsicNot",
450 "IntrinsicMixFloatES3"}) {
451 disables[
test].push_back({regex(
"Intel.*(Iris|6000)"),
"Metal", _, kMac});
455 disables[
"SwizzleIndexStore"].push_back({regex(
"Intel"),
"OpenGL", _, kMac});
456 disables[
"SwizzleIndexStore"].push_back({regex(
"Intel.*Iris"), _, _, kWindows});
459 for (
const char*
test : {
"VectorToMatrixCast",
461 "TrivialArgumentsInlineDirectly"}) {
462 disables[
test].push_back({regex(
"Intel"),
"ANGLE", _, kWindows});
465 for (
const char*
test : {
"MatrixFoldingES2",
467 "TemporaryIndexLookup",
468 "SwizzleIndexLookup"}) {
469 disables[
test].push_back({regex(
"Intel.*(Iris|4400)"),
"OpenGL", _, kWindows});
470 disables[
test].push_back({regex(
"Intel.*(Iris|4400)"),
"ANGLE", _, kWindows});
473 for (
const char*
test : {
"ReturnsValueOnEveryPathES3",
474 "OutParamsAreDistinctFromGlobal",
475 "StructFieldFolding"}) {
476 disables[
test].push_back({regex(
"Intel"),
"OpenGL", _, kWindows});
477 disables[
test].push_back({regex(
"Intel"),
"ANGLE GL", _, kWindows});
480 for (
const char*
test : {
"SwitchDefaultOnly",
481 "ReturnsValueOnEveryPathES3"}) {
482 disables[
test].push_back({regex(
"Intel"),
"Vulkan", _, kLinux});
485 for (
const char*
test : {
"SwitchDefaultOnly"}) {
486 disables[
test].push_back({regex(
"Intel"),
"ANGLE", _, kWindows});
489 for (
const char*
test : {
"SwizzleAsLValueES3"}) {
490 disables[
test].push_back({regex(
"Intel"), _, _, kWindows});
491 disables[
test].push_back({_,
"ANGLE", _, kWindows});
495 for (
const char*
test : {
"IntrinsicDFdy",
497 "IntrinsicFwidth"}) {
498 disables[
test].push_back({regex(
"Intel"), _,
GPU, _});
501 disables[
"LoopFloat"].push_back({regex(
"Intel.*(Iris|6000)"), _, _, kMac});
509 if (
const std::vector<TestDisable>* testDisables = testDisableMap->find(
name)) {
510 for (
const TestDisable&
d : *testDisables) {
511 if (
d.platform.has_value() && !*
d.platform) {
517 if (
d.deviceName.has_value() &&
518 !std::regex_search(deviceName.begin(), deviceName.end(), *
d.deviceName)) {
543 std::string_view deviceName,
544 std::string_view backendAPI,
547 const char* testFile,
549 const char* permutationSuffix,
557 ERRORF(r,
"%s%s: %s", testFile, permutationSuffix,
result.errorText.c_str());
563 SkDebugf(
"%s: skipped %.*s%s\n", testFile, (
int)backendAPI.size(), backendAPI.data(),
570 ERRORF(r,
"%s%s: Unable to build shader", testFile, permutationSuffix);
586 static_assert(
kWidth == 2);
591 "RRGGBBAA RRGGBBAA\n"
592 "%02X%02X%02X%02X %02X%02X%02X%02X\n"
593 "%02X%02X%02X%02X %02X%02X%02X%02X",
595 (
int)deviceName.size(), deviceName.data(),
596 (
int)backendAPI.size(), backendAPI.data(),
615 std::string_view deviceName,
616 std::string_view backendAPI,
619 const char* testFile,
624 options.forceUnoptimized =
false;
627 options.forceUnoptimized =
true;
634 const char* testFile,
646#if defined(SK_GANESH)
650 const char* testFile,
656 bool shouldRunGPU_ES3 =
659 if (!shouldRunGPU && !shouldRunGPU_ES3) {
673 std::string_view deviceName = ctx->
priv().
caps()->deviceName();
680 if (shouldRunGPU_ES3) {
687#if defined(SK_GRAPHITE)
693 const char* testFile,
697 bool shouldRunGPU_ES3 =
700 if (!shouldRunGPU && !shouldRunGPU_ES3) {
715 std::unique_ptr<skgpu::graphite::Recorder> recorder = ctx->
makeRecorder();
721 std::string_view deviceName = ctx->
priv().
caps()->deviceName();
728 if (shouldRunGPU_ES3) {
744 std::unique_ptr<SkSL::Program> program =
compiler.convertProgram(
759 std::string cloned = expr.
clone()->description();
761 "Mismatch after clone!\nOriginal: %s\nCloned: %s\n",
762 original.c_str(), cloned.c_str());
764 return INHERITED::visitExpression(expr);
772 CloneVisitor{r}.visit(*program);
777 ERRORF(r,
"NEW: %s", testFile);
782 const char* testFile,
784 const char* reason) {
786 ERRORF(r,
"%s: %s", testFile, reason);
791 const char* testFile,
803 std::unique_ptr<SkSL::Program> program =
compiler.convertProgram(
806 ERRORF(r,
"%s: Unexpected compilation error\n%s", testFile,
compiler.errorText().c_str());
811 ERRORF(r,
"%s: Program must have a 'main' function", testFile);
828 if (var.type().isEffectChild()) {
829 ERRORF(r,
"%s: Test program cannot contain child effects", testFile);
833 if (var.modifierFlags().isUniform()) {
841 bool foundMatch =
false;
843 if (data.name == programUniform.name) {
844 SkASSERT(data.span.size() *
sizeof(
float) == programUniform.sizeInBytes());
846 uniformValues.
push_back_n(data.span.size(), data.span.data());
860 std::unique_ptr<SkSL::RP::Program> rasterProg =
871 rasterProg->appendStages(&pipeline, &alloc,
nullptr,
SkSpan(uniformValues));
876 pipeline.
append(SkRasterPipelineOp::store_8888, &outCtx);
877 pipeline.
run(0, 0, 1, 1);
881 uint32_t expected = 0xFF00FF00;
882 if (out[0] != expected) {
883 ERRORF(r,
"%s: Raster Pipeline failed. Expected solid green, got ARGB:%02X%02X%02X%02X",
885 (out[0] >> 24) & 0xFF,
886 (out[0] >> 16) & 0xFF,
887 (out[0] >> 8) & 0xFF,
896#if defined(SK_GANESH)
897#define DEF_GANESH_SKSL_TEST(flags, ctsEnforcement, name, path) \
898 DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS(SkSL##name##_Ganesh, \
903 test_ganesh(r, ctxInfo, #name, path, flags); \
906#define DEF_GANESH_SKSL_TEST(flags, ctsEnforcement, name, path)
909#if defined(SK_GRAPHITE)
914#define DEF_GRAPHITE_SKSL_TEST(flags, ctsEnforcement, name, path) \
915 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS(SkSL##name##_Graphite, \
916 is_native_context_or_dawn, \
923 test_graphite(r, context, testContext, #name, path, flags); \
926#define DEF_GRAPHITE_SKSL_TEST(flags, ctsEnforcement, name, path)
929#define SKSL_TEST(flags, ctsEnforcement, name, path) \
930 DEF_CONDITIONAL_TEST(SkSL##name##_CPU, r, is_cpu(flags)) { test_cpu(r, #name, path, flags); } \
931 DEF_TEST(SkSL##name##_RP, r) { test_raster_pipeline(r, path, flags); } \
932 DEF_TEST(SkSL##name##_Clone, r) { test_clone(r, path, flags); } \
933 DEF_GANESH_SKSL_TEST(flags, ctsEnforcement, name, path) \
934 DEF_GRAPHITE_SKSL_TEST(flags, std::max(kApiLevel_V, ctsEnforcement), name, path)
991SKSL_TEST(
ES3 |
GPU_ES3,
kNever, ForInitializerExpressionsCanBeInlined, "inliner/ForInitializerExpressionsCanBeInlined.sksl")
1001SKSL_TEST(
CPU |
GPU,
kApiLevel_T, InlinerElidesTempVarForReturnsInsideBlock, "inliner/InlinerElidesTempVarForReturnsInsideBlock.sksl")
1003SKSL_TEST(
CPU |
GPU,
kApiLevel_T, InlinerUsesTempVarForReturnsInsideBlockWithVar, "inliner/InlinerUsesTempVarForReturnsInsideBlockWithVar.sksl")
1014SKSL_TEST(
CPU |
GPU,
kApiLevel_T, ShortCircuitEvaluationsCannotInlineRightHandSide, "inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl")
1100SKSL_TEST(
ES3 |
GPU_ES3,
kNever, ConstantCompositeAccessViaConstantIndex, "shared/ConstantCompositeAccessViaConstantIndex.sksl")
1101SKSL_TEST(
ES3 |
GPU_ES3,
kNever, ConstantCompositeAccessViaDynamicIndex, "shared/ConstantCompositeAccessViaDynamicIndex.sksl")
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
sk_sp< SkData > GetResourceAsData(const char *resource)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
#define SkColorGetR(color)
#define SkColorGetG(color)
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
#define SkColorGetA(color)
#define SkColorGetB(color)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static constexpr int SkRasterPipeline_kMaxStride_highp
#define INHERITED(method,...)
static constexpr float kUniformTestMatrix3x3[]
constexpr auto kApiLevel_T
static void test_clone(skiatest::Reporter *r, const char *testFile, SkSLTestFlags flags)
static SkBitmap bitmap_from_shader(skiatest::Reporter *r, SkSurface *surface, sk_sp< SkRuntimeEffect > effect)
static constexpr float kUniformTestMatrix4x4[]
static bool failure_is_expected(std::string_view deviceName, std::string_view backendAPI, std::string_view name, skiatest::TestType testType)
static constexpr float kUniformColorGreen[]
static constexpr bool is_strict_es2(SkSLTestFlags flags)
static constexpr float kUniformColorWhite[]
constexpr auto kNextRelease
constexpr SkSLTestFlags CPU
static void test_cpu(skiatest::Reporter *r, const char *name, const char *testFile, SkSLTestFlags flags)
#define SKSL_TEST(flags, ctsEnforcement, name, path)
constexpr auto kApiLevel_V
static void test_raster_pipeline(skiatest::Reporter *r, const char *testFile, SkSLTestFlags flags)
static constexpr float kUniformTestArrayNegative[]
static constexpr float kUniformColorBlack[]
static constexpr float kUniformTestMatrix2x2[]
static constexpr float kUniformTestInputs[]
static bool gpu_generates_nan(skiatest::Reporter *r, GrDirectContext *ctx)
static void report_rp_pass(skiatest::Reporter *r, const char *testFile, SkSLTestFlags flags)
static constexpr float kUniformColorRed[]
static constexpr bool is_gpu(SkSLTestFlags flags)
static constexpr float kUniformColorBlue[]
constexpr SkSLTestFlags ES3
constexpr SkSLTestFlags UsesNaN
constexpr SkSLTestFlags GPU
static constexpr int kWidth
static constexpr bool is_cpu(SkSLTestFlags flags)
static constexpr UniformData kUniformData[]
static constexpr float kUniformTestArray[]
static void report_rp_fail(skiatest::Reporter *r, const char *testFile, SkSLTestFlags flags, const char *reason)
static void test_permutations(skiatest::Reporter *r, std::string_view deviceName, std::string_view backendAPI, SkSurface *surface, const char *name, const char *testFile, skiatest::TestType testType, bool strictES2)
static void test_one_permutation(skiatest::Reporter *r, std::string_view deviceName, std::string_view backendAPI, SkSurface *surface, const char *name, const char *testFile, skiatest::TestType testType, const char *permutationSuffix, const SkRuntimeEffect::Options &options)
static constexpr int kHeight
constexpr auto kApiLevel_U
constexpr SkSLTestFlags GPU_ES3
static constexpr float kUniformUnknownInput[]
static SkString load_source(skiatest::Reporter *r, const char *testFile, const char *permutationSuffix)
SK_API SkString static SkString SkStringPrintf()
static constexpr bool SkToBool(const T &x)
#define REPORTER_ASSERT(r, cond,...)
const GrCaps * caps() const
const GrShaderCaps * shaderCaps() const
GrDirectContextPriv priv()
void setShader(sk_sp< SkShader > shader)
void run(size_t x, size_t y, size_t w, size_t h) const
void append(SkRasterPipelineOp, void *=nullptr)
void appendConstantColor(SkArenaAlloc *, const float rgba[4])
static SkRuntimeEffect::Uniform VarAsUniform(const SkSL::Variable &, const SkSL::Context &, size_t *offset)
static SkRuntimeEffect::Options ES3Options()
static Result MakeForShader(SkString sksl, const Options &)
virtual std::unique_ptr< Expression > clone(Position pos) const =0
std::string description() const final
std::unique_ptr< Statement > & declaration()
virtual bool visitExpression(typename T::Expression &expression)
const char * c_str() const
GrDirectContext * directContext() const
skgpu::ContextType type() const
const SkSL::ShaderCaps * shaderCaps() const
const Caps * caps() const
BackendApi backend() const
std::unique_ptr< Recorder > makeRecorder(const RecorderOptions &={})
virtual skgpu::ContextType contextType()=0
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
FlutterSemanticsFlag flags
constexpr SkColor4f kTransparent
std::unique_ptr< RP::Program > MakeRasterPipelineProgram(const SkSL::Program &program, const FunctionDefinition &function, DebugTracePriv *debugTrace, bool writeTraceOps)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
bool IsDawnBackend(skgpu::ContextType type)
bool IsNativeBackend(skgpu::ContextType type)
const char * ContextTypeName(skgpu::ContextType type)
constexpr bool contains(std::string_view str, std::string_view needle)
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeWH(float w, float h)
sk_sp< SkRuntimeEffect > effect
SkSL::Version supportedSkSLVerion() const