From 37a59ef1af685fea0942f0dbc27f20a722ed18e1 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 18 Jun 2019 11:35:12 +0000 Subject: [PATCH] Revert "Shuffle SkSL sources around so compiler and bytecode can be used w/o GPU" This reverts commit 90507286cc669076a24d319065726a22e3a62b42. Reason for revert: Seems to be breaking some builds Original change's description: > Shuffle SkSL sources around so compiler and bytecode can be used w/o GPU > > Change-Id: I7236a30040ab532086e68d6e9de2898dd7acaa32 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221098 > Commit-Queue: Brian Osman > Reviewed-by: Mike Reed > Reviewed-by: Mike Klein TBR=mtklein@google.com,kjlubick@google.com,brianosman@google.com,ethannicholas@google.com,reed@google.com Change-Id: Ie230315a72ebcfae32bc9ce7bafec1f87106cff2 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221536 Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips --- BUILD.gn | 25 +++++-------------- gn/sksl.gni | 19 +++++++------- .../include/SkParticleSerialization.h | 1 - modules/particles/src/SkParticleAffector.cpp | 7 ++++++ src/sksl/SkSLCompiler.cpp | 4 --- src/sksl/SkSLUtil.cpp | 2 +- src/sksl/ir/SkSLProgram.h | 2 +- tools/cpu_modules.cpp | 22 ---------------- 8 files changed, 24 insertions(+), 58 deletions(-) delete mode 100644 tools/cpu_modules.cpp diff --git a/BUILD.gn b/BUILD.gn index 289728687d..730c3988ca 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -501,7 +501,6 @@ if (skia_compile_processors) { "src/sksl/SkSLMain.cpp", ] sources += skia_sksl_sources - sources += skia_sksl_gpu_sources include_dirs = [ "." ] deps = [ ":run_sksllex", @@ -579,8 +578,7 @@ optional("gpu") { public_configs = [] public_deps = [] - sources = - skia_gpu_sources + skia_sksl_gpu_sources + skia_gpu_processor_outputs + sources = skia_gpu_sources + skia_sksl_sources + skia_gpu_processor_outputs if (!skia_enable_ccpr) { sources -= skia_ccpr_sources sources += [ "src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp" ] @@ -637,6 +635,11 @@ optional("gpu") { } } + if (skia_enable_spirv_validation) { + deps += [ "//third_party/spirv-tools" ] + public_defines += [ "SK_ENABLE_SPIRV_VALIDATION" ] + } + cflags_objcc = [] if (skia_use_metal) { public_defines += [ "SK_METAL" ] @@ -913,7 +916,6 @@ component("skia") { } sources += skia_effects_sources sources += skia_effects_imagefilter_sources - sources += skia_sksl_sources sources += [ "src/android/SkAndroidFrameworkUtils.cpp", "src/android/SkAnimatedImage.cpp", @@ -1044,11 +1046,6 @@ component("skia") { if (is_fuchsia) { sources += [ "src/ports/SkDebug_stdio.cpp" ] } - - if (skia_enable_spirv_validation) { - deps += [ "//third_party/spirv-tools" ] - defines += [ "SK_ENABLE_SPIRV_VALIDATION" ] - } } # DebugCanvas used in experimental/wasm-skp-debugger @@ -1145,16 +1142,6 @@ group("modules") { ] } -executable("cpu_modules") { - sources = [ - "tools/cpu_modules.cpp", - ] - deps = [ - ":skia", - "modules/particles", - ] -} - # Targets guarded by skia_enable_tools may use //third_party freely. if (skia_enable_tools) { skia_public_includes = [ diff --git a/gn/sksl.gni b/gn/sksl.gni index 019b684374..3d2951e4cb 100644 --- a/gn/sksl.gni +++ b/gn/sksl.gni @@ -12,10 +12,18 @@ skia_sksl_sources = [ "$_src/sksl/SkSLByteCodeGenerator.cpp", "$_src/sksl/SkSLCFGGenerator.cpp", "$_src/sksl/SkSLCompiler.cpp", + "$_src/sksl/SkSLCPPCodeGenerator.cpp", + "$_src/sksl/SkSLCPPUniformCTypes.cpp", + "$_src/sksl/SkSLGLSLCodeGenerator.cpp", + "$_src/sksl/SkSLHCodeGenerator.cpp", "$_src/sksl/SkSLIRGenerator.cpp", "$_src/sksl/SkSLJIT.cpp", "$_src/sksl/SkSLLexer.cpp", + "$_src/sksl/SkSLMetalCodeGenerator.cpp", + "$_src/sksl/SkSLOutputStream.cpp", "$_src/sksl/SkSLParser.cpp", + "$_src/sksl/SkSLPipelineStageCodeGenerator.cpp", + "$_src/sksl/SkSLSPIRVCodeGenerator.cpp", "$_src/sksl/SkSLString.cpp", "$_src/sksl/SkSLUtil.cpp", "$_src/sksl/ir/SkSLSymbolTable.cpp", @@ -24,16 +32,7 @@ skia_sksl_sources = [ "$_src/sksl/ir/SkSLVariableReference.cpp", ] -skia_sksl_gpu_sources = [ - "$_src/sksl/SkSLCPPCodeGenerator.cpp", - "$_src/sksl/SkSLCPPUniformCTypes.cpp", - "$_src/sksl/SkSLGLSLCodeGenerator.cpp", - "$_src/sksl/SkSLHCodeGenerator.cpp", - "$_src/sksl/SkSLMetalCodeGenerator.cpp", - "$_src/sksl/SkSLOutputStream.cpp", - "$_src/sksl/SkSLPipelineStageCodeGenerator.cpp", - "$_src/sksl/SkSLSPIRVCodeGenerator.cpp", -] +skia_sksl_gpu_sources = [] skia_gpu_processor_sources = [ "$_src/gpu/effects/GrAARectEffect.fp", diff --git a/modules/particles/include/SkParticleSerialization.h b/modules/particles/include/SkParticleSerialization.h index 072130b4fc..0cb057de86 100644 --- a/modules/particles/include/SkParticleSerialization.h +++ b/modules/particles/include/SkParticleSerialization.h @@ -10,7 +10,6 @@ #include "modules/particles/include/SkReflected.h" -#include "include/core/SkString.h" #include "include/private/SkTArray.h" #include "src/utils/SkJSON.h" #include "src/utils/SkJSONWriter.h" diff --git a/modules/particles/src/SkParticleAffector.cpp b/modules/particles/src/SkParticleAffector.cpp index 28da3e4587..0ed3ad1487 100644 --- a/modules/particles/src/SkParticleAffector.cpp +++ b/modules/particles/src/SkParticleAffector.cpp @@ -15,9 +15,12 @@ #include "modules/particles/include/SkCurve.h" #include "modules/particles/include/SkParticleData.h" #include "src/core/SkMakeUnique.h" + +#if SK_SUPPORT_GPU #include "src/sksl/SkSLByteCode.h" #include "src/sksl/SkSLCompiler.h" #include "src/sksl/SkSLExternalValue.h" +#endif void SkParticleAffector::apply(const SkParticleUpdateParams& params, SkParticleState ps[], int count) { @@ -436,6 +439,7 @@ private: SkColorCurve fCurve; }; +#if SK_SUPPORT_GPU static const char* kDefaultCode = "// float rand; Every read returns a random float [0 .. 1)\n" "layout(ctype=float) in uniform float dt;\n" @@ -523,6 +527,7 @@ private: fRandomValue = std::move(rand); } }; +#endif void SkParticleAffector::RegisterAffectorTypes() { REGISTER_REFLECTED(SkParticleAffector); @@ -536,7 +541,9 @@ void SkParticleAffector::RegisterAffectorTypes() { REGISTER_REFLECTED(SkSizeAffector); REGISTER_REFLECTED(SkFrameAffector); REGISTER_REFLECTED(SkColorAffector); +#if SK_SUPPORT_GPU REGISTER_REFLECTED(SkInterpreterAffector); +#endif } sk_sp SkParticleAffector::MakeLinearVelocity(const SkCurve& angle, diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp index 28190dc9be..5111bf40a6 100644 --- a/src/sksl/SkSLCompiler.cpp +++ b/src/sksl/SkSLCompiler.cpp @@ -1379,8 +1379,6 @@ std::unique_ptr Compiler::specialize( return result; } -#if defined(SKSL_STANDALONE) || SK_SUPPORT_GPU - bool Compiler::toSPIRV(Program& program, OutputStream& out) { if (!this->optimize(program)) { return false; @@ -1499,8 +1497,6 @@ bool Compiler::toPipelineStage(const Program& program, String* out, return result; } -#endif - std::unique_ptr Compiler::toByteCode(Program& program) { if (!this->optimize(program)) { return nullptr; diff --git a/src/sksl/SkSLUtil.cpp b/src/sksl/SkSLUtil.cpp index b2c516245d..ed6d485778 100644 --- a/src/sksl/SkSLUtil.cpp +++ b/src/sksl/SkSLUtil.cpp @@ -15,7 +15,7 @@ namespace SkSL { -#if defined(SKSL_STANDALONE) || !SK_SUPPORT_GPU +#ifdef SKSL_STANDALONE StandaloneShaderCaps standaloneCaps; #endif diff --git a/src/sksl/ir/SkSLProgram.h b/src/sksl/ir/SkSLProgram.h index b4397b9e2b..89cfbcb038 100644 --- a/src/sksl/ir/SkSLProgram.h +++ b/src/sksl/ir/SkSLProgram.h @@ -80,7 +80,7 @@ struct Program { int fValue; }; -#if defined(SKSL_STANDALONE) || !SK_SUPPORT_GPU +#ifdef SKSL_STANDALONE const StandaloneShaderCaps* fCaps = &standaloneCaps; #else const GrShaderCaps* fCaps = nullptr; diff --git a/tools/cpu_modules.cpp b/tools/cpu_modules.cpp deleted file mode 100644 index fe1fd22758..0000000000 --- a/tools/cpu_modules.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "modules/particles/include/SkParticleAffector.h" -#include "modules/particles/include/SkParticleDrawable.h" -#include "modules/particles/include/SkParticleEffect.h" -#include "modules/particles/include/SkParticleSerialization.h" -#include "modules/particles/include/SkReflected.h" - -// Doesn't do anything important; just exists to show we can use modules/particles without the GPU -// backend being available. -int main(int argc, char** argv) { - // Register types for serialization - REGISTER_REFLECTED(SkReflected); - SkParticleAffector::RegisterAffectorTypes(); - SkParticleDrawable::RegisterDrawableTypes(); - return 0; -}