66#if defined(SK_GRAPHITE)
81namespace SkSL {
class Context; }
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};
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;
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 for (
const char*
test : {
"SwitchWithFallthrough",
306 "SwitchWithFallthroughGroups"}) {
307 disables[
test].push_back({_,
"OpenGL",
GPU, kiOS});
312 for (
const char*
test : {
"Matrices",
315 "MatrixSwizzleStore",
316 "MatrixScalarNoOpFolding",
317 "UnaryPositiveNegative",
319 disables[
test].push_back({
regex(
"Mali-400"), _,
GPU, _});
324 for (
const char*
test : {
"Switch",
326 "SwitchWithFallthrough",
327 "SwitchWithFallthroughAndVarDecls",
328 "SwitchWithFallthroughGroups",
333 "MatrixScalarNoOpFolding",
338 "ModifiedStructParametersCannotBeInlined"}) {
339 disables[
test].push_back({
regex(
"Tegra 3"), _,
GPU, _});
344 for (
const char*
test : {
"MatrixConstructorsES2",
345 "MatrixConstructorsES3",
346 "MatrixScalarNoOpFolding",
347 "PreserveSideEffects",
348 "StructFieldNoFolding"}) {
353 disables[
"IntrinsicMixFloatES3"].push_back({
regex(
"RTX "),
"Vulkan", _, kWindows});
356 for (
const char*
test : {
"PreserveSideEffects",
357 "CommaSideEffects"}) {
358 disables[
test].push_back({
regex(
"Quadro P400"), _, _, kLinux});
362 for (
const char*
test : {
"UniformArray",
363 "TemporaryIndexLookup",
364 "MatrixIndexLookup"}) {
365 disables[
test].push_back({
regex(
"Quadro P400"),
"Dawn Vulkan", Graphite, kWindows});
369 for (
const char*
test : {
"OutParamsAreDistinct",
370 "OutParamsAreDistinctFromGlobal"}) {
371 disables[
test].push_back({
regex(
"PowerVR Rogue GE8300"), _,
GPU, _});
375 for (
const char*
test : {
"DeadReturnES3",
377 "MatrixConstructorsES3",
378 "MatrixScalarNoOpFolding",
380 "SwizzleIndexLookup",
381 "SwizzleIndexStore"}) {
382 disables[
test].push_back({
regex(
"Radeon.*(R9|HD)"),
"OpenGL",
GPU, _});
383 disables[
test].push_back({
regex(
"Radeon.*(R9|HD)"),
"ANGLE GL",
GPU, _});
387 for (
const char*
test : {
"IntrinsicDFdy",
389 "IntrinsicFwidth"}) {
390 disables[
test].push_back({
regex(
"AMD RADV RENOIR"), _,
GPU, _});
395 for (
const char*
test : {
"ArrayCast",
398 "IntrinsicMixFloatES2",
399 "IntrinsicClampFloat",
400 "SwitchWithFallthrough",
401 "SwitchWithFallthroughGroups",
402 "SwizzleIndexLookup",
403 "SwizzleIndexStore"}) {
408 for (
const char*
test : {
"VoidInSequenceExpressions",
411 "OutParamsDoubleSwizzle",
413 "OutParamsFunctionCallInArgument"}) {
414 disables[
test].push_back({
regex(
ADRENO "[56]"),
"Vulkan", _, kAndroid});
417 for (
const char*
test : {
"MatrixToVectorCast",
418 "StructsInFunctions"}) {
419 disables[
test].push_back({
regex(
ADRENO "[345]"),
"OpenGL", _, kAndroid});
423 for (
const char*
test : {
"Matrices",
424 "MatrixNoOpFolding"}) {
429 disables[
"IntrinsicIsInf"].push_back({
regex(
ADRENO "6"),
"OpenGL", _, kAndroid});
432 disables[
"EmptyBlocksES3"].push_back({
regex(
ADRENO "(540|630)"), _, _, kAndroid});
435 disables[
"OutParamsAreDistinctFromGlobal"].push_back({
regex(
ADRENO "[3456]"),
"OpenGL",
438 disables[
"StructFieldFolding"].push_back({
regex(
ADRENO "[56]"),
"OpenGL",
442 for (
const char*
test : {
"PrefixExpressionsES2",
443 "MatrixToVectorCast",
444 "MatrixConstructorsES2"}) {
445 disables[
test].push_back({
regex(
ADRENO "620"),
"Vulkan", Graphite, kAndroid});
451 disables[
"IntrinsicFloor"].push_back({
regex(
"Intel.*(Iris|HD)"),
"ANGLE D3D", _, _});
454 for (
const char*
test : {
"IntrinsicNot",
455 "IntrinsicMixFloatES3"}) {
456 disables[
test].push_back({
regex(
"Intel.*(Iris|6000)"),
"Metal", _, kMac});
460 disables[
"SwizzleIndexStore"].push_back({
regex(
"Intel"),
"OpenGL", _, kMac});
461 disables[
"SwizzleIndexStore"].push_back({
regex(
"Intel.*Iris"), _, _, kWindows});
464 for (
const char*
test : {
"VectorToMatrixCast",
466 "TrivialArgumentsInlineDirectly"}) {
467 disables[
test].push_back({
regex(
"Intel"),
"ANGLE", _, kWindows});
470 for (
const char*
test : {
"MatrixFoldingES2",
472 "TemporaryIndexLookup",
473 "SwizzleIndexLookup"}) {
474 disables[
test].push_back({
regex(
"Intel.*(Iris|4400)"),
"OpenGL", _, kWindows});
475 disables[
test].push_back({
regex(
"Intel.*(Iris|4400)"),
"ANGLE", _, kWindows});
478 for (
const char*
test : {
"ReturnsValueOnEveryPathES3",
479 "OutParamsAreDistinctFromGlobal",
480 "StructFieldFolding"}) {
481 disables[
test].push_back({
regex(
"Intel"),
"OpenGL", _, kWindows});
482 disables[
test].push_back({
regex(
"Intel"),
"ANGLE GL", _, kWindows});
485 for (
const char*
test : {
"SwitchDefaultOnly",
486 "ReturnsValueOnEveryPathES3"}) {
487 disables[
test].push_back({
regex(
"Intel"),
"Vulkan", _, kLinux});
490 for (
const char*
test : {
"SwitchDefaultOnly"}) {
491 disables[
test].push_back({
regex(
"Intel"),
"ANGLE", _, kWindows});
494 for (
const char*
test : {
"SwizzleAsLValueES3"}) {
495 disables[
test].push_back({
regex(
"Intel"), _, _, kWindows});
496 disables[
test].push_back({_,
"ANGLE", _, kWindows});
500 for (
const char*
test : {
"IntrinsicDFdy",
502 "IntrinsicFwidth"}) {
506 disables[
"LoopFloat"].push_back({
regex(
"Intel.*(Iris|6000)"), _, _, kMac});
514 if (
const std::vector<TestDisable>* testDisables = testDisableMap->find(
name)) {
515 for (
const TestDisable&
d : *testDisables) {
516 if (
d.platform.has_value() && !*
d.platform) {
522 if (
d.deviceName.has_value() &&
523 !std::regex_search(deviceName.begin(), deviceName.end(), *
d.deviceName)) {
548 std::string_view deviceName,
549 std::string_view backendAPI,
552 const char* testFile,
554 const char* permutationSuffix,
562 ERRORF(r,
"%s%s: %s", testFile, permutationSuffix,
result.errorText.c_str());
568 SkDebugf(
"%s: skipped %.*s%s\n", testFile, (
int)backendAPI.size(), backendAPI.data(),
575 ERRORF(r,
"%s%s: Unable to build shader", testFile, permutationSuffix);
591 static_assert(
kWidth == 2);
596 "RRGGBBAA RRGGBBAA\n"
597 "%02X%02X%02X%02X %02X%02X%02X%02X\n"
598 "%02X%02X%02X%02X %02X%02X%02X%02X",
600 (
int)deviceName.size(), deviceName.data(),
601 (
int)backendAPI.size(), backendAPI.data(),
620 std::string_view deviceName,
621 std::string_view backendAPI,
624 const char* testFile,
629 options.forceUnoptimized =
false;
632 options.forceUnoptimized =
true;
639 const char* testFile,
651#if defined(SK_GANESH)
655 const char* testFile,
661 bool shouldRunGPU_ES3 =
664 if (!shouldRunGPU && !shouldRunGPU_ES3) {
678 std::string_view deviceName = ctx->
priv().
caps()->deviceName();
685 if (shouldRunGPU_ES3) {
692#if defined(SK_GRAPHITE)
698 const char* testFile,
702 bool shouldRunGPU_ES3 =
705 if (!shouldRunGPU && !shouldRunGPU_ES3) {
720 std::unique_ptr<skgpu::graphite::Recorder> recorder = ctx->
makeRecorder();
726 std::string_view deviceName = ctx->
priv().
caps()->deviceName();
733 if (shouldRunGPU_ES3) {
749 std::unique_ptr<SkSL::Program> program =
compiler.convertProgram(
764 std::string cloned = expr.
clone()->description();
766 "Mismatch after clone!\nOriginal: %s\nCloned: %s\n",
767 original.c_str(), cloned.c_str());
769 return INHERITED::visitExpression(expr);
777 CloneVisitor{r}.visit(*program);
782 ERRORF(r,
"NEW: %s", testFile);
787 const char* testFile,
789 const char* reason) {
791 ERRORF(r,
"%s: %s", testFile, reason);
796 const char* testFile,
808 std::unique_ptr<SkSL::Program> program =
compiler.convertProgram(
811 ERRORF(r,
"%s: Unexpected compilation error\n%s", testFile,
compiler.errorText().c_str());
816 ERRORF(r,
"%s: Program must have a 'main' function", testFile);
833 if (var.type().isEffectChild()) {
834 ERRORF(r,
"%s: Test program cannot contain child effects", testFile);
838 if (var.modifierFlags().isUniform()) {
846 bool foundMatch =
false;
848 if (
data.name == programUniform.name) {
849 SkASSERT(
data.span.size() *
sizeof(
float) == programUniform.sizeInBytes());
865 std::unique_ptr<SkSL::RP::Program> rasterProg =
876 rasterProg->appendStages(&pipeline, &alloc,
nullptr,
SkSpan(uniformValues));
881 pipeline.
append(SkRasterPipelineOp::store_8888, &outCtx);
882 pipeline.
run(0, 0, 1, 1);
886 uint32_t expected = 0xFF00FF00;
887 if (
out[0] != expected) {
888 ERRORF(r,
"%s: Raster Pipeline failed. Expected solid green, got ARGB:%02X%02X%02X%02X",
890 (
out[0] >> 24) & 0xFF,
891 (
out[0] >> 16) & 0xFF,
892 (
out[0] >> 8) & 0xFF,
901#if defined(SK_GANESH)
902#define DEF_GANESH_SKSL_TEST(flags, ctsEnforcement, name, path) \
903 DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS(SkSL##name##_Ganesh, \
908 test_ganesh(r, ctxInfo, #name, path, flags); \
911#define DEF_GANESH_SKSL_TEST(flags, ctsEnforcement, name, path)
914#if defined(SK_GRAPHITE)
919#define DEF_GRAPHITE_SKSL_TEST(flags, ctsEnforcement, name, path) \
920 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS(SkSL##name##_Graphite, \
921 is_native_context_or_dawn, \
928 test_graphite(r, context, testContext, #name, path, flags); \
931#define DEF_GRAPHITE_SKSL_TEST(flags, ctsEnforcement, name, path)
934#define SKSL_TEST(flags, ctsEnforcement, name, path) \
935 DEF_CONDITIONAL_TEST(SkSL##name##_CPU, r, is_cpu(flags)) { test_cpu(r, #name, path, flags); } \
936 DEF_TEST(SkSL##name##_RP, r) { test_raster_pipeline(r, path, flags); } \
937 DEF_TEST(SkSL##name##_Clone, r) { test_clone(r, path, flags); } \
938 DEF_GANESH_SKSL_TEST(flags, ctsEnforcement, name, path) \
939 DEF_GRAPHITE_SKSL_TEST(flags, std::max(kApiLevel_V, ctsEnforcement), name, path)
996SKSL_TEST(
ES3 |
GPU_ES3,
kNever, ForInitializerExpressionsCanBeInlined, "inliner/ForInitializerExpressionsCanBeInlined.sksl")
1006SKSL_TEST(
CPU |
GPU,
kApiLevel_T, InlinerElidesTempVarForReturnsInsideBlock, "inliner/InlinerElidesTempVarForReturnsInsideBlock.sksl")
1008SKSL_TEST(
CPU |
GPU,
kApiLevel_T, InlinerUsesTempVarForReturnsInsideBlockWithVar, "inliner/InlinerUsesTempVarForReturnsInsideBlockWithVar.sksl")
1019SKSL_TEST(
CPU |
GPU,
kApiLevel_T, ShortCircuitEvaluationsCannotInlineRightHandSide, "inliner/ShortCircuitEvaluationsCannotInlineRightHandSide.sksl")
1106SKSL_TEST(
ES3 |
GPU_ES3,
kNever, ConstantCompositeAccessViaConstantIndex, "shared/ConstantCompositeAccessViaConstantIndex.sksl")
1107SKSL_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)
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
static constexpr bool SkToBool(const T &x)
#define REPORTER_ASSERT(r, cond,...)
const GrCaps * caps() const
const GrShaderCaps * shaderCaps() const
GrDirectContextPriv priv()
const uint8_t * bytes() const
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)
static uint8_t Hex(uint8_t value)
DEF_SWITCHES_START aot vmservice shared library name
skgpu::ganesh::TextureOp::Saturate Saturate
bool IsDawnBackend(skgpu::ContextType type)
bool IsNativeBackend(skgpu::ContextType type)
const char * ContextTypeName(skgpu::ContextType type)
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, bool > constexpr Any(E e)
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
std::shared_ptr< const fml::Mapping > data