From ca1a36f8260593590bc10a61ed55bac9cbe4d946 Mon Sep 17 00:00:00 2001 From: John Stiles Date: Wed, 26 Apr 2023 16:30:48 -0400 Subject: [PATCH] Wrap SkRP ops in #ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE. If we don't have Raster Pipeline SkSL enabled, we no longer pay a build-size cost for these ops. If both SkVM and SkRP are disabled, paints which use Runtime Effects will be dropped. Change-Id: I801250aef5a0ef18d6463545d965f64a39298c4e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/675121 Reviewed-by: Brian Osman Commit-Queue: John Stiles --- BUILD.gn | 1 + bench/SkSLBench.cpp | 48 ++++--- src/core/SkRasterPipelineOpList.h | 119 ++++++++++-------- src/core/SkRuntimeEffect.cpp | 2 + src/opts/SkRasterPipeline_opts.h | 11 +- .../codegen/SkSLRasterPipelineBuilder.cpp | 13 +- src/sksl/codegen/SkSLRasterPipelineBuilder.h | 13 ++ .../SkSLRasterPipelineCodeGenerator.cpp | 7 +- tests/RasterPipelineBuilderTest.cpp | 4 + tests/RasterPipelineCodeGeneratorTest.cpp | 4 + tests/SkRasterPipelineTest.cpp | 4 + tests/SkSLDebugTracePlayerTest.cpp | 4 +- tests/SkSLTest.cpp | 4 + tools/skslc/Main.cpp | 4 + 14 files changed, 155 insertions(+), 83 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index b38acccc29b8..024da24b36f1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -815,6 +815,7 @@ if (skia_compile_sksl_tests) { "SKSL_STANDALONE", "SK_DISABLE_TRACING", "SK_ENABLE_SKVM", + "SK_ENABLE_SKSL_IN_RASTER_PIPELINE", "SK_ENABLE_SPIRV_CROSS", "SK_ENABLE_SPIRV_VALIDATION", "SK_ENABLE_WGSL_VALIDATION", diff --git a/bench/SkSLBench.cpp b/bench/SkSLBench.cpp index b539853295fd..285925f026a3 100644 --- a/bench/SkSLBench.cpp +++ b/bench/SkSLBench.cpp @@ -61,7 +61,9 @@ enum class Output { kGLSL, kMetal, kSPIRV, +#if defined(SK_ENABLE_SKSL_IN_RASTER_PIPELINE) kSkRP, +#endif #if defined(SK_ENABLE_SKVM) kSkVM, // raw SkVM bytecode kSkVMOpt, // optimized SkVM bytecode @@ -77,7 +79,9 @@ class SkSLCompileBench : public Benchmark { case Output::kGLSL: return "glsl_"; case Output::kMetal: return "metal_"; case Output::kSPIRV: return "spirv_"; +#if defined(SK_ENABLE_SKSL_IN_RASTER_PIPELINE) case Output::kSkRP: return "skrp_"; +#endif #if defined(SK_ENABLE_SKVM) case Output::kSkVM: return "skvm_"; case Output::kSkVMOpt: return "skvm_opt_"; @@ -112,7 +116,7 @@ class SkSLCompileBench : public Benchmark { } bool usesRuntimeShader() const { - return fOutput >= Output::kSkRP; + return fOutput > Output::kSPIRV; } void fixUpSource() { @@ -149,7 +153,9 @@ class SkSLCompileBench : public Benchmark { case Output::kGLSL: SkAssertResult(fCompiler.toGLSL(*program, &result)); break; case Output::kMetal: SkAssertResult(fCompiler.toMetal(*program, &result)); break; case Output::kSPIRV: SkAssertResult(fCompiler.toSPIRV(*program, &result)); break; +#if defined(SK_ENABLE_SKSL_IN_RASTER_PIPELINE) case Output::kSkRP: SkAssertResult(CompileToSkRP(*program)); break; +#endif #if defined(SK_ENABLE_SKVM) case Output::kSkVM: case Output::kSkVMOpt: @@ -174,6 +180,7 @@ class SkSLCompileBench : public Benchmark { } #endif +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE static bool CompileToSkRP(const SkSL::Program& program) { const SkSL::FunctionDeclaration* main = program.getFunction("main"); if (!main) { @@ -203,6 +210,7 @@ class SkSLCompileBench : public Benchmark { /*uniforms=*/SkSpan{uniformBuffer, rasterProg->numUniforms()}); return true; } +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE private: std::string fName; @@ -217,28 +225,32 @@ class SkSLCompileBench : public Benchmark { /////////////////////////////////////////////////////////////////////////////// -#define COMPILER_BENCH_COMMON(name, text) \ -static constexpr char name ## _SRC[] = text; \ -DEF_BENCH(return new SkSLCompileBench(#name, name ## _SRC, /*optimize=*/false, Output::kNone);) \ -DEF_BENCH(return new SkSLCompileBench(#name, name ## _SRC, /*optimize=*/true, Output::kNone);) \ -DEF_BENCH(return new SkSLCompileBench(#name, name ## _SRC, /*optimize=*/true, Output::kGLSL);) \ -DEF_BENCH(return new SkSLCompileBench(#name, name ## _SRC, /*optimize=*/true, Output::kMetal);) \ -DEF_BENCH(return new SkSLCompileBench(#name, name ## _SRC, /*optimize=*/true, Output::kSPIRV);) \ -DEF_BENCH(return new SkSLCompileBench(#name, name ## _SRC, /*optimize=*/true, Output::kSkRP);) +#if defined(SK_ENABLE_SKSL_IN_RASTER_PIPELINE) + #define COMPILER_BENCH_SKRP(name, text) \ + DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kSkRP);) +#else + #define COMPILER_BENCH_SKRP(name, text) /* SkRP is disabled; no benchmarking */ +#endif #if defined(SK_ENABLE_SKVM) - -#define COMPILER_BENCH(name, text) \ -COMPILER_BENCH_COMMON(name, text) \ -DEF_BENCH(return new SkSLCompileBench(#name, name ## _SRC, /*optimize=*/true, Output::kSkVM);) \ -DEF_BENCH(return new SkSLCompileBench(#name, name ## _SRC, /*optimize=*/true, Output::kSkVMOpt);) \ -DEF_BENCH(return new SkSLCompileBench(#name, name ## _SRC, /*optimize=*/true, Output::kSkVMJIT);) - + #define COMPILER_BENCH_SKVM(name, text) \ + DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kSkVM);) \ + DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kSkVMOpt);) \ + DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kSkVMJIT);) #else + #define COMPILER_BENCH_SKVM(name, text) /* SkVM is disabled; no benchmarking */ +#endif -#define COMPILER_BENCH(name, text) COMPILER_BENCH_COMMON(name, text) +#define COMPILER_BENCH(name, text) \ + static constexpr char name ## _SRC[] = text; \ + DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/false, Output::kNone);) \ + DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kNone);) \ + DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kGLSL);) \ + DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kMetal);) \ + DEF_BENCH(return new SkSLCompileBench(#name, name##_SRC, /*optimize=*/true, Output::kSPIRV);) \ + COMPILER_BENCH_SKRP(name, text) \ + COMPILER_BENCH_SKVM(name, text) -#endif // This fragment shader is from the third tile on the top row of GM_gradients_2pt_conical_outside. // To get an ES2 compatible shader, nonconstantArrayIndexSupport in GrShaderCaps is forced off. diff --git a/src/core/SkRasterPipelineOpList.h b/src/core/SkRasterPipelineOpList.h index 38a7dfac12b9..05d11b261b02 100644 --- a/src/core/SkRasterPipelineOpList.h +++ b/src/core/SkRasterPipelineOpList.h @@ -8,8 +8,7 @@ #ifndef SkRasterPipelineOpList_DEFINED #define SkRasterPipelineOpList_DEFINED -// There are two macros here: The first defines ops that have lowp (and highp) implementations. -// The second defines ops that are only present in the highp pipeline. +// `SK_RASTER_PIPELINE_OPS_LOWP` defines ops that have parallel lowp and highp implementations. #define SK_RASTER_PIPELINE_OPS_LOWP(M) \ M(move_src_dst) M(move_dst_src) M(swap_src_dst) \ M(clamp_01) M(clamp_gamut) \ @@ -53,55 +52,11 @@ M(emboss) \ M(swizzle) -#define SK_RASTER_PIPELINE_OPS_HIGHP_ONLY(M) \ - M(callback) \ - M(stack_checkpoint) M(stack_rewind) \ - M(unbounded_set_rgb) M(unbounded_uniform_color) \ - M(unpremul) M(unpremul_polar) M(dither) \ - M(load_16161616) M(load_16161616_dst) M(store_16161616) M(gather_16161616) \ - M(load_a16) M(load_a16_dst) M(store_a16) M(gather_a16) \ - M(load_rg1616) M(load_rg1616_dst) M(store_rg1616) M(gather_rg1616) \ - M(load_f16) M(load_f16_dst) M(store_f16) M(gather_f16) \ - M(load_af16) M(load_af16_dst) M(store_af16) M(gather_af16) \ - M(load_rgf16) M(load_rgf16_dst) M(store_rgf16) M(gather_rgf16) \ - M(load_f32) M(load_f32_dst) M(store_f32) M(gather_f32) \ - M(load_rgf32) M(store_rgf32) \ - M(load_1010102) M(load_1010102_dst) M(store_1010102) M(gather_1010102) \ - M(load_1010102_xr) M(load_1010102_xr_dst) M(store_1010102_xr) \ - M(store_u16_be) \ - M(store_src_rg) M(load_src_rg) \ - M(byte_tables) \ - M(colorburn) M(colordodge) M(softlight) \ - M(hue) M(saturation) M(color) M(luminosity) \ - M(matrix_3x3) M(matrix_3x4) M(matrix_4x5) M(matrix_4x3) \ - M(parametric) M(gamma_) M(PQish) M(HLGish) M(HLGinvish) \ - M(rgb_to_hsl) M(hsl_to_rgb) \ - M(css_lab_to_xyz) M(css_oklab_to_linear_srgb) \ - M(css_hcl_to_lab) \ - M(css_hsl_to_srgb) M(css_hwb_to_srgb) \ - M(gauss_a_to_rgba) \ - M(mirror_x) M(repeat_x) \ - M(mirror_y) M(repeat_y) \ - M(negate_x) \ - M(bicubic_clamp_8888) \ - M(bilinear_setup) \ - M(bilinear_nx) M(bilinear_px) M(bilinear_ny) M(bilinear_py) \ - M(bicubic_setup) \ - M(bicubic_n3x) M(bicubic_n1x) M(bicubic_p1x) M(bicubic_p3x) \ - M(bicubic_n3y) M(bicubic_n1y) M(bicubic_p1y) M(bicubic_p3y) \ - M(accumulate) \ - M(mipmap_linear_init) M(mipmap_linear_update) M(mipmap_linear_finish) \ - M(xy_to_2pt_conical_strip) \ - M(xy_to_2pt_conical_focal_on_circle) \ - M(xy_to_2pt_conical_well_behaved) \ - M(xy_to_2pt_conical_smaller) \ - M(xy_to_2pt_conical_greater) \ - M(alter_2pt_conical_compensate_focal) \ - M(alter_2pt_conical_unswap) \ - M(mask_2pt_conical_nan) \ - M(mask_2pt_conical_degenerates) M(apply_vector_mask) \ - M(set_base_pointer) \ - /* Dedicated SkSL stages begin here: */ \ +// `SK_RASTER_PIPELINE_OPS_SKSL` defines ops used by SkSL. +// This set can be empty if software SkSL (SK_ENABLE_SKSL_IN_RASTER_PIPELINE) is not enabled. +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE + +#define SK_RASTER_PIPELINE_OPS_SKSL(M) \ M(init_lane_masks) M(store_device_xy01) M(exchange_src) \ M(load_condition_mask) M(store_condition_mask) M(merge_condition_mask) \ M(load_loop_mask) M(store_loop_mask) M(mask_off_loop_mask) \ @@ -190,9 +145,65 @@ M(cmpne_n_ints) M(cmpne_int) M(cmpne_2_ints) M(cmpne_3_ints) M(cmpne_4_ints) \ M(trace_line) M(trace_var) M(trace_enter) M(trace_exit) M(trace_scope) -// The combined list of all RasterPipeline ops: -#define SK_RASTER_PIPELINE_OPS_ALL(M) \ - SK_RASTER_PIPELINE_OPS_LOWP(M) \ +#else +#define SK_RASTER_PIPELINE_OPS_SKSL(M) +#endif + +// `SK_RASTER_PIPELINE_OPS_HIGHP_ONLY` defines ops that are only available in highp; this subset +// includes all of SkSL. +#define SK_RASTER_PIPELINE_OPS_HIGHP_ONLY(M) \ + M(callback) \ + M(stack_checkpoint) M(stack_rewind) \ + M(unbounded_set_rgb) M(unbounded_uniform_color) \ + M(unpremul) M(unpremul_polar) M(dither) \ + M(load_16161616) M(load_16161616_dst) M(store_16161616) M(gather_16161616) \ + M(load_a16) M(load_a16_dst) M(store_a16) M(gather_a16) \ + M(load_rg1616) M(load_rg1616_dst) M(store_rg1616) M(gather_rg1616) \ + M(load_f16) M(load_f16_dst) M(store_f16) M(gather_f16) \ + M(load_af16) M(load_af16_dst) M(store_af16) M(gather_af16) \ + M(load_rgf16) M(load_rgf16_dst) M(store_rgf16) M(gather_rgf16) \ + M(load_f32) M(load_f32_dst) M(store_f32) M(gather_f32) \ + M(load_rgf32) M(store_rgf32) \ + M(load_1010102) M(load_1010102_dst) M(store_1010102) M(gather_1010102) \ + M(load_1010102_xr) M(load_1010102_xr_dst) M(store_1010102_xr) \ + M(store_u16_be) \ + M(store_src_rg) M(load_src_rg) \ + M(byte_tables) \ + M(colorburn) M(colordodge) M(softlight) \ + M(hue) M(saturation) M(color) M(luminosity) \ + M(matrix_3x3) M(matrix_3x4) M(matrix_4x5) M(matrix_4x3) \ + M(parametric) M(gamma_) M(PQish) M(HLGish) M(HLGinvish) \ + M(rgb_to_hsl) M(hsl_to_rgb) \ + M(css_lab_to_xyz) M(css_oklab_to_linear_srgb) \ + M(css_hcl_to_lab) \ + M(css_hsl_to_srgb) M(css_hwb_to_srgb) \ + M(gauss_a_to_rgba) \ + M(mirror_x) M(repeat_x) \ + M(mirror_y) M(repeat_y) \ + M(negate_x) \ + M(bicubic_clamp_8888) \ + M(bilinear_setup) \ + M(bilinear_nx) M(bilinear_px) M(bilinear_ny) M(bilinear_py) \ + M(bicubic_setup) \ + M(bicubic_n3x) M(bicubic_n1x) M(bicubic_p1x) M(bicubic_p3x) \ + M(bicubic_n3y) M(bicubic_n1y) M(bicubic_p1y) M(bicubic_p3y) \ + M(accumulate) \ + M(mipmap_linear_init) M(mipmap_linear_update) M(mipmap_linear_finish) \ + M(xy_to_2pt_conical_strip) \ + M(xy_to_2pt_conical_focal_on_circle) \ + M(xy_to_2pt_conical_well_behaved) \ + M(xy_to_2pt_conical_smaller) \ + M(xy_to_2pt_conical_greater) \ + M(alter_2pt_conical_compensate_focal) \ + M(alter_2pt_conical_unswap) \ + M(mask_2pt_conical_nan) \ + M(mask_2pt_conical_degenerates) M(apply_vector_mask) \ + M(set_base_pointer) \ + SK_RASTER_PIPELINE_OPS_SKSL(M) + +// The combined set of all RasterPipeline ops: +#define SK_RASTER_PIPELINE_OPS_ALL(M) \ + SK_RASTER_PIPELINE_OPS_LOWP(M) \ SK_RASTER_PIPELINE_OPS_HIGHP_ONLY(M) // An enumeration of every RasterPipeline op: diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp index a8d367d12803..1d842a13f8b2 100644 --- a/src/core/SkRuntimeEffect.cpp +++ b/src/core/SkRuntimeEffect.cpp @@ -260,6 +260,7 @@ const SkSL::RP::Program* SkRuntimeEffect::getRPProgram(SkSL::DebugTracePriv* deb originalData->size() / sizeof(float)}; } +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE class RuntimeEffectRPCallbacks : public SkSL::RP::Callbacks { public: RuntimeEffectRPCallbacks(const SkStageRec& s, @@ -327,6 +328,7 @@ class RuntimeEffectRPCallbacks : public SkSL::RP::Callbacks { SkSpan fChildren; SkSpan fSampleUsages; }; +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE bool SkRuntimeEffectPriv::CanDraw(const SkCapabilities* caps, const SkSL::Program* program) { SkASSERT(caps && program); diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h index 5f6bca750837..36d0eef5748a 100644 --- a/src/opts/SkRasterPipeline_opts.h +++ b/src/opts/SkRasterPipeline_opts.h @@ -3294,6 +3294,12 @@ STAGE(callback, SkRasterPipeline_CallbackCtx* c) { load4(c->read_from,0, &r,&g,&b,&a); } +STAGE_TAIL(set_base_pointer, std::byte* p) { + base = p; +} + +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE + // All control flow stages used by SkSL maintain some state in the common registers: // r: condition mask // g: loop mask @@ -3304,9 +3310,6 @@ STAGE(callback, SkRasterPipeline_CallbackCtx* c) { #define update_execution_mask() a = sk_bit_cast(sk_bit_cast(r) & \ sk_bit_cast(g) & \ sk_bit_cast(b)) -STAGE_TAIL(set_base_pointer, std::byte* p) { - base = p; -} STAGE_TAIL(init_lane_masks, NoCtx) { uint32_t iota[] = {0,1,2,3,4,5,6,7}; @@ -4308,6 +4311,8 @@ DECLARE_TERNARY_INT(mix) #undef DECLARE_TERNARY_FLOAT #undef DECLARE_TERNARY_INT +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE + STAGE(gauss_a_to_rgba, NoCtx) { // x = 1 - x; // exp(-x * x * 4) - 0.018f; diff --git a/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp b/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp index 1b1504e6cff1..1becc63260d2 100644 --- a/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp +++ b/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp @@ -5,6 +5,10 @@ * found in the LICENSE file. */ +#include "src/sksl/codegen/SkSLRasterPipelineBuilder.h" + +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE + #include "include/core/SkStream.h" #include "include/private/base/SkMalloc.h" #include "include/private/base/SkTo.h" @@ -16,7 +20,6 @@ #include "src/core/SkTHash.h" #include "src/sksl/SkSLPosition.h" #include "src/sksl/SkSLString.h" -#include "src/sksl/codegen/SkSLRasterPipelineBuilder.h" #include "src/sksl/tracing/SkSLDebugTracePriv.h" #include "src/sksl/tracing/SkSLTraceHook.h" #include "src/utils/SkBitSet.h" @@ -38,8 +41,7 @@ using namespace skia_private; -namespace SkSL { -namespace RP { +namespace SkSL::RP { #define ALL_SINGLE_SLOT_UNARY_OP_CASES \ BuilderOp::acos_float: \ @@ -3370,5 +3372,6 @@ void Program::dump(SkWStream* out) const { } } -} // namespace RP -} // namespace SkSL +} // namespace SkSL::RP + +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE diff --git a/src/sksl/codegen/SkSLRasterPipelineBuilder.h b/src/sksl/codegen/SkSLRasterPipelineBuilder.h index 875f791a17da..3fc77c6dee5f 100644 --- a/src/sksl/codegen/SkSLRasterPipelineBuilder.h +++ b/src/sksl/codegen/SkSLRasterPipelineBuilder.h @@ -8,6 +8,10 @@ #ifndef SKSL_RASTERPIPELINEBUILDER #define SKSL_RASTERPIPELINEBUILDER +#include "include/core/SkTypes.h" + +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE + #include "include/core/SkSpan.h" #include "include/core/SkTypes.h" #include "include/private/base/SkTArray.h" @@ -683,4 +687,13 @@ class Builder { } // namespace RP } // namespace SkSL +#else // !defined(SK_ENABLE_SKSL_IN_RASTER_PIPELINE) + +namespace SkSL::RP { + +class Program {}; + +} // namespace SkSL::RP + +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE #endif // SKSL_RASTERPIPELINEBUILDER diff --git a/src/sksl/codegen/SkSLRasterPipelineCodeGenerator.cpp b/src/sksl/codegen/SkSLRasterPipelineCodeGenerator.cpp index 9b4ba2f5e8b3..08c8d6aab5a5 100644 --- a/src/sksl/codegen/SkSLRasterPipelineCodeGenerator.cpp +++ b/src/sksl/codegen/SkSLRasterPipelineCodeGenerator.cpp @@ -5,6 +5,10 @@ * found in the LICENSE file. */ +#include "src/sksl/codegen/SkSLRasterPipelineCodeGenerator.h" + +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE + #include "include/core/SkPoint.h" #include "include/core/SkSpan.h" #include "include/private/SkSLDefines.h" @@ -21,7 +25,6 @@ #include "src/sksl/SkSLOperator.h" #include "src/sksl/SkSLPosition.h" #include "src/sksl/codegen/SkSLRasterPipelineBuilder.h" -#include "src/sksl/codegen/SkSLRasterPipelineCodeGenerator.h" #include "src/sksl/ir/SkSLBinaryExpression.h" #include "src/sksl/ir/SkSLBlock.h" #include "src/sksl/ir/SkSLBreakStatement.h" @@ -3730,3 +3733,5 @@ std::unique_ptr MakeRasterPipelineProgram(const SkSL::Program& prog } } // namespace SkSL + +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE diff --git a/tests/RasterPipelineBuilderTest.cpp b/tests/RasterPipelineBuilderTest.cpp index 15438b8c6d1d..2a41015a0916 100644 --- a/tests/RasterPipelineBuilderTest.cpp +++ b/tests/RasterPipelineBuilderTest.cpp @@ -14,6 +14,8 @@ #include "src/sksl/tracing/SkSLDebugTracePriv.h" #include "tests/Test.h" +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE + static sk_sp get_program_dump(SkSL::RP::Program& program) { SkDynamicMemoryWStream stream; program.dump(&stream); @@ -863,3 +865,5 @@ trace_exit TraceExit(FunctionC) when $0 is true } } } + +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE diff --git a/tests/RasterPipelineCodeGeneratorTest.cpp b/tests/RasterPipelineCodeGeneratorTest.cpp index 18f10d653ac3..38a3176e3bb7 100644 --- a/tests/RasterPipelineCodeGeneratorTest.cpp +++ b/tests/RasterPipelineCodeGeneratorTest.cpp @@ -24,6 +24,8 @@ #include #include +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE + //#define DUMP_PROGRAMS 1 #if defined(DUMP_PROGRAMS) #include "src/core/SkStreamPriv.h" @@ -310,3 +312,5 @@ DEF_TEST(SkSLRasterPipelineCodeGeneratorComparisonIntrinsicTest, r) { /*startingColor=*/SkColor4f{0.0, 0.0, 0.0, 0.0}, /*expectedResult=*/SkColor4f{0.0, 1.0, 0.0, 1.0}); } + +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE diff --git a/tests/SkRasterPipelineTest.cpp b/tests/SkRasterPipelineTest.cpp index d17099b6b16c..ab0b32e0958b 100644 --- a/tests/SkRasterPipelineTest.cpp +++ b/tests/SkRasterPipelineTest.cpp @@ -104,6 +104,8 @@ DEF_TEST(SkRasterPipeline_PackBigContext, r) { REPORTER_ASSERT(r, unpacked.data == object.data); } +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE + DEF_TEST(SkRasterPipeline_LoadStoreConditionMask, reporter) { alignas(64) int32_t mask[] = {~0, 0, ~0, 0, ~0, ~0, ~0, 0}; alignas(64) int32_t maskCopy[SkRasterPipeline_kMaxStride_highp] = {}; @@ -2747,6 +2749,8 @@ DEF_TEST(SkRasterPipeline_BranchIfActiveLanesEqual, r) { } } +#endif + DEF_TEST(SkRasterPipeline_empty, r) { // No asserts... just a test that this is safe to run. SkRasterPipeline_<256> p; diff --git a/tests/SkSLDebugTracePlayerTest.cpp b/tests/SkSLDebugTracePlayerTest.cpp index 074370715347..a70a591b055a 100644 --- a/tests/SkSLDebugTracePlayerTest.cpp +++ b/tests/SkSLDebugTracePlayerTest.cpp @@ -29,7 +29,7 @@ #include #include -#ifdef SKSL_ENABLE_TRACING +#if defined(SKSL_ENABLE_TRACING) && defined(SK_ENABLE_SKSL_IN_RASTER_PIPELINE) using LineNumberMap = SkSL::SkSLDebugTracePlayer::LineNumberMap; @@ -952,4 +952,4 @@ half4 main(float2 xy) { // Line 8 REPORTER_ASSERT(r, player.getCurrentLine() == 6); } -#endif // SKSL_ENABLE_TRACING +#endif // defined(SKSL_ENABLE_TRACING) && defined(SK_ENABLE_SKSL_IN_RASTER_PIPELINE) diff --git a/tests/SkSLTest.cpp b/tests/SkSLTest.cpp index c04f8f44b5cc..b0e458cd4fe0 100644 --- a/tests/SkSLTest.cpp +++ b/tests/SkSLTest.cpp @@ -351,6 +351,7 @@ static void test_clone(skiatest::Reporter* r, const char* testFile, int flags) { SkSL::dsl::End(); } +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE static void report_rp_pass(skiatest::Reporter* r, const char* testFile, int flags) { if (!(flags & SkSLTestFlags::RP)) { ERRORF(r, "NEW: %s", testFile); @@ -365,8 +366,10 @@ static void report_rp_fail(skiatest::Reporter* r, ERRORF(r, "%s: %s", testFile, reason); } } +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE static void test_raster_pipeline(skiatest::Reporter* r, const char* testFile, int flags) { +#ifdef SK_ENABLE_SKSL_IN_RASTER_PIPELINE SkString shaderString = load_source(r, testFile, ""); if (shaderString.isEmpty()) { return; @@ -468,6 +471,7 @@ static void test_raster_pipeline(skiatest::Reporter* r, const char* testFile, in // Success! report_rp_pass(r, testFile, flags); +#endif // SK_ENABLE_SKSL_IN_RASTER_PIPELINE } #define SKSL_TEST(flags, ctsEnforcement, name, path) \ diff --git a/tools/skslc/Main.cpp b/tools/skslc/Main.cpp index a9e58ccfd4d6..f9fc33c6ac5a 100644 --- a/tools/skslc/Main.cpp +++ b/tools/skslc/Main.cpp @@ -586,6 +586,7 @@ static ResultCode process_command(SkSpan args) { return ResultCode::kSuccess; }; +#if defined(SK_ENABLE_SKVM) || defined(SK_ENABLE_SKSL_IN_RASTER_PIPELINE) auto compileProgramAsRuntimeShader = [&](const auto& writeFn) -> ResultCode { if (kind == SkSL::ProgramKind::kVertex) { emitCompileError("Runtime shaders do not support vertex programs\n"); @@ -597,6 +598,7 @@ static ResultCode process_command(SkSpan args) { } return compileProgram(writeFn); }; +#endif if (skstd::ends_with(outputPath, ".spirv")) { return compileProgram( @@ -662,6 +664,7 @@ static ResultCode process_command(SkSpan args) { return true; }); #endif +#if defined(SK_ENABLE_SKSL_IN_RASTER_PIPELINE) } else if (skstd::ends_with(outputPath, ".skrp")) { settings.fMaxVersionAllowed = SkSL::Version::k300; return compileProgramAsRuntimeShader( @@ -682,6 +685,7 @@ static ResultCode process_command(SkSpan args) { rasterProg->dump(as_SkWStream(out).get()); return true; }); +#endif } else if (skstd::ends_with(outputPath, ".stage")) { return compileProgram( [](SkSL::Compiler&, SkSL::Program& program, SkSL::OutputStream& out) {