Revert "Revert "Shuffle SkSL sources around so compiler and bytecode can be used w/o GPU""
This reverts commit 37a59ef1af
.
Change-Id: If38da265ebbb196e72c7d035ba51028438787e2e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221541
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
34d63e6b4e
commit
fb32ddf622
25
BUILD.gn
25
BUILD.gn
@ -501,6 +501,7 @@ if (skia_compile_processors) {
|
||||
"src/sksl/SkSLMain.cpp",
|
||||
]
|
||||
sources += skia_sksl_sources
|
||||
sources += skia_sksl_gpu_sources
|
||||
include_dirs = [ "." ]
|
||||
deps = [
|
||||
":run_sksllex",
|
||||
@ -578,7 +579,8 @@ optional("gpu") {
|
||||
public_configs = []
|
||||
public_deps = []
|
||||
|
||||
sources = skia_gpu_sources + skia_sksl_sources + skia_gpu_processor_outputs
|
||||
sources =
|
||||
skia_gpu_sources + skia_sksl_gpu_sources + skia_gpu_processor_outputs
|
||||
if (!skia_enable_ccpr) {
|
||||
sources -= skia_ccpr_sources
|
||||
sources += [ "src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp" ]
|
||||
@ -635,11 +637,6 @@ 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" ]
|
||||
@ -916,6 +913,7 @@ component("skia") {
|
||||
}
|
||||
sources += skia_effects_sources
|
||||
sources += skia_effects_imagefilter_sources
|
||||
sources += skia_sksl_sources
|
||||
sources += [
|
||||
"src/android/SkAndroidFrameworkUtils.cpp",
|
||||
"src/android/SkAnimatedImage.cpp",
|
||||
@ -1046,6 +1044,11 @@ 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
|
||||
@ -1142,6 +1145,16 @@ 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 = [
|
||||
|
19
gn/sksl.gni
19
gn/sksl.gni
@ -12,18 +12,10 @@ 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",
|
||||
@ -32,7 +24,16 @@ skia_sksl_sources = [
|
||||
"$_src/sksl/ir/SkSLVariableReference.cpp",
|
||||
]
|
||||
|
||||
skia_sksl_gpu_sources = []
|
||||
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_gpu_processor_sources = [
|
||||
"$_src/gpu/effects/GrAARectEffect.fp",
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
class SkString;
|
||||
|
||||
class SkParsePath {
|
||||
class SK_API SkParsePath {
|
||||
public:
|
||||
static bool FromSVGString(const char str[], SkPath*);
|
||||
static void ToSVGString(const SkPath&, SkString*);
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#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"
|
||||
|
@ -15,12 +15,9 @@
|
||||
#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) {
|
||||
@ -439,7 +436,6 @@ 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"
|
||||
@ -527,7 +523,6 @@ private:
|
||||
fRandomValue = std::move(rand);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void SkParticleAffector::RegisterAffectorTypes() {
|
||||
REGISTER_REFLECTED(SkParticleAffector);
|
||||
@ -541,9 +536,7 @@ void SkParticleAffector::RegisterAffectorTypes() {
|
||||
REGISTER_REFLECTED(SkSizeAffector);
|
||||
REGISTER_REFLECTED(SkFrameAffector);
|
||||
REGISTER_REFLECTED(SkColorAffector);
|
||||
#if SK_SUPPORT_GPU
|
||||
REGISTER_REFLECTED(SkInterpreterAffector);
|
||||
#endif
|
||||
}
|
||||
|
||||
sk_sp<SkParticleAffector> SkParticleAffector::MakeLinearVelocity(const SkCurve& angle,
|
||||
|
@ -165,7 +165,11 @@ struct ByteCodeFunction {
|
||||
void disassemble() const;
|
||||
};
|
||||
|
||||
struct ByteCode {
|
||||
struct SK_API ByteCode {
|
||||
ByteCode() = default;
|
||||
ByteCode(const ByteCode&) = delete;
|
||||
ByteCode& operator=(const ByteCode&) = delete;
|
||||
|
||||
int fGlobalCount = 0;
|
||||
// one entry per input slot, contains the global slot to which the input slot maps
|
||||
std::vector<uint8_t> fInputSlots;
|
||||
|
@ -1379,6 +1379,8 @@ std::unique_ptr<Program> Compiler::specialize(
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined(SKSL_STANDALONE) || SK_SUPPORT_GPU
|
||||
|
||||
bool Compiler::toSPIRV(Program& program, OutputStream& out) {
|
||||
if (!this->optimize(program)) {
|
||||
return false;
|
||||
@ -1497,6 +1499,8 @@ bool Compiler::toPipelineStage(const Program& program, String* out,
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
std::unique_ptr<ByteCode> Compiler::toByteCode(Program& program) {
|
||||
if (!this->optimize(program)) {
|
||||
return nullptr;
|
||||
|
@ -47,7 +47,7 @@ bool operator==(const char* s1, StringFragment s2);
|
||||
|
||||
bool operator!=(const char* s1, StringFragment s2);
|
||||
|
||||
class String : public std::string {
|
||||
class SK_API String : public std::string {
|
||||
public:
|
||||
String() = default;
|
||||
String(const String&) = default;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
#ifdef SKSL_STANDALONE
|
||||
#if defined(SKSL_STANDALONE) || !SK_SUPPORT_GPU
|
||||
StandaloneShaderCaps standaloneCaps;
|
||||
#endif
|
||||
|
||||
|
@ -80,7 +80,7 @@ struct Program {
|
||||
int fValue;
|
||||
};
|
||||
|
||||
#ifdef SKSL_STANDALONE
|
||||
#if defined(SKSL_STANDALONE) || !SK_SUPPORT_GPU
|
||||
const StandaloneShaderCaps* fCaps = &standaloneCaps;
|
||||
#else
|
||||
const GrShaderCaps* fCaps = nullptr;
|
||||
|
22
tools/cpu_modules.cpp
Normal file
22
tools/cpu_modules.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user