Remove flexible runtime effects entirely
All internal usage has migrated to MakeFor..., this removes the old
program kind, and updates some tests.
Bug: skia:11813
Change-Id: I56733b071270e1ae3fab5d851e23acf6c02e3361
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402536
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp
index 150c171..5fd4c88 100644
--- a/src/core/SkRuntimeEffect.cpp
+++ b/src/core/SkRuntimeEffect.cpp
@@ -179,8 +179,6 @@
switch (kind) {
case SkSL::ProgramKind::kRuntimeColorFilter: flags |= kAllowColorFilter_Flag; break;
case SkSL::ProgramKind::kRuntimeShader: flags |= kAllowShader_Flag; break;
- case SkSL::ProgramKind::kRuntimeEffect: flags |= (kAllowColorFilter_Flag |
- kAllowShader_Flag); break;
default: SkUNREACHABLE;
}
@@ -189,16 +187,11 @@
flags |= kUsesSampleCoords_Flag;
}
- // Color filters are not allowed to depend on position (local or device) in any way, but they
- // can sample children with matrices or explicit coords. Because the children are color filters,
- // we know (by induction) that they don't use those coords, so we keep the overall invariant.
- //
- // TODO(skbug.com/11813): When ProgramKind is always kRuntimeColorFilter or kRuntimeShader,
- // this can be simpler. There is no way for color filters to refer to sk_FragCoord or sample
- // coords in that mode.
- if ((flags & kAllowColorFilter_Flag) &&
- ((flags & kUsesSampleCoords_Flag) || SkSL::Analysis::ReferencesFragCoords(*program))) {
- flags &= ~kAllowColorFilter_Flag;
+ // Color filters are not allowed to depend on position (local or device) in any way.
+ // The signature of main, and the declarations in sksl_rt_colorfilter should guarantee this.
+ if (flags & kAllowColorFilter_Flag) {
+ SkASSERT(!(flags & kUsesSampleCoords_Flag));
+ SkASSERT(!SkSL::Analysis::ReferencesFragCoords(*program));
}
size_t offset = 0;
@@ -267,10 +260,6 @@
return Result{std::move(effect), SkString()};
}
-SkRuntimeEffect::Result SkRuntimeEffect::Make(SkString sksl, const Options& options) {
- return Make(std::move(sksl), options, SkSL::ProgramKind::kRuntimeEffect);
-}
-
SkRuntimeEffect::Result SkRuntimeEffect::MakeForColorFilter(SkString sksl, const Options& options) {
auto result = Make(std::move(sksl), options, SkSL::ProgramKind::kRuntimeColorFilter);
SkASSERT(!result.effect || result.effect->allowColorFilter());
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 7f64d19..4d6bb6d 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -65,7 +65,6 @@
#include "src/sksl/generated/sksl_public.dehydrated.sksl"
#include "src/sksl/generated/sksl_rt_colorfilter.dehydrated.sksl"
#include "src/sksl/generated/sksl_rt_shader.dehydrated.sksl"
-#include "src/sksl/generated/sksl_runtime.dehydrated.sksl"
#include "src/sksl/generated/sksl_vert.dehydrated.sksl"
#define MODULE_DATA(name) MakeModuleData(SKSL_INCLUDE_sksl_##name,\
@@ -263,15 +262,6 @@
symbols->addAlias("mat4", types.fFloat4x4.get());
}
-const ParsedModule& Compiler::loadRuntimeEffectModule() {
- if (!fRuntimeEffectModule.fSymbols) {
- fRuntimeEffectModule = this->parseModule(
- ProgramKind::kRuntimeEffect, MODULE_DATA(runtime), this->loadPublicModule());
- add_glsl_type_aliases(fRuntimeEffectModule.fSymbols.get(), fContext->fTypes);
- }
- return fRuntimeEffectModule;
-}
-
const ParsedModule& Compiler::loadRuntimeColorFilterModule() {
if (!fRuntimeColorFilterModule.fSymbols) {
fRuntimeColorFilterModule = this->parseModule(ProgramKind::kRuntimeColorFilter,
@@ -297,7 +287,6 @@
case ProgramKind::kFragment: return this->loadFragmentModule(); break;
case ProgramKind::kGeometry: return this->loadGeometryModule(); break;
case ProgramKind::kFragmentProcessor: return this->loadFPModule(); break;
- case ProgramKind::kRuntimeEffect: return this->loadRuntimeEffectModule(); break;
case ProgramKind::kRuntimeColorFilter: return this->loadRuntimeColorFilterModule(); break;
case ProgramKind::kRuntimeShader: return this->loadRuntimeShaderModule(); break;
case ProgramKind::kGeneric: return this->loadPublicModule(); break;
diff --git a/src/sksl/SkSLCompiler.h b/src/sksl/SkSLCompiler.h
index 93f20d5..8500821 100644
--- a/src/sksl/SkSLCompiler.h
+++ b/src/sksl/SkSLCompiler.h
@@ -189,7 +189,6 @@
const ParsedModule& loadFPModule();
const ParsedModule& loadGeometryModule();
const ParsedModule& loadPublicModule();
- const ParsedModule& loadRuntimeEffectModule();
const ParsedModule& loadRuntimeColorFilterModule();
const ParsedModule& loadRuntimeShaderModule();
@@ -226,7 +225,6 @@
ParsedModule fFPModule; // [GPU] + FP features
ParsedModule fPublicModule; // [Root] + Public features
- ParsedModule fRuntimeEffectModule; // [Public] + Runtime effect decls
ParsedModule fRuntimeColorFilterModule; // [Public] + Runtime shader decls
ParsedModule fRuntimeShaderModule; // [Public] + Runtime color filter decls
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index cab4592..ce2edf8 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -293,8 +293,7 @@
"'key' is only permitted within fragment processors");
}
}
- if (this->programKind() == ProgramKind::kRuntimeEffect ||
- this->programKind() == ProgramKind::kRuntimeColorFilter ||
+ if (this->programKind() == ProgramKind::kRuntimeColorFilter ||
this->programKind() == ProgramKind::kRuntimeShader) {
if (modifiers.fFlags & Modifiers::kIn_Flag) {
this->errorReporter().error(offset, "'in' variables not permitted in runtime effects");
@@ -309,8 +308,7 @@
this->errorReporter().error(offset, "'key' is not permitted on 'uniform' variables");
}
if (modifiers.fLayout.fFlags & Layout::kSRGBUnpremul_Flag) {
- if (this->programKind() != ProgramKind::kRuntimeEffect &&
- this->programKind() != ProgramKind::kRuntimeColorFilter &&
+ if (this->programKind() != ProgramKind::kRuntimeColorFilter &&
this->programKind() != ProgramKind::kRuntimeShader) {
this->errorReporter().error(offset,
"'srgb_unpremul' is only permitted in runtime effects");
@@ -1036,8 +1034,7 @@
}
Modifiers m = pd.fModifiers;
- if (isMain && (this->programKind() == ProgramKind::kRuntimeEffect ||
- this->programKind() == ProgramKind::kRuntimeColorFilter ||
+ if (isMain && (this->programKind() == ProgramKind::kRuntimeColorFilter ||
this->programKind() == ProgramKind::kRuntimeShader ||
this->programKind() == ProgramKind::kFragmentProcessor)) {
// We verify that the signature is fully correct later. For now, if this is an .fp or
@@ -1082,27 +1079,6 @@
// Check the function signature of `main`.
if (isMain) {
switch (this->programKind()) {
- case ProgramKind::kRuntimeEffect: {
- // Legacy/generic runtime effects take a wide variety of main() signatures.
- // (half4|float4) main(float2?, (half4|float4)?)
- if (!typeIsValidForColor(*returnType)) {
- this->errorReporter().error(f.fOffset,
- "'main' must return: 'vec4', 'float4', or 'half4'");
- return;
- }
- bool validParams =
- (parameters.size() == 0) ||
- (parameters.size() == 1 && paramIsCoords(0)) ||
- (parameters.size() == 1 && paramIsInputColor(0)) ||
- (parameters.size() == 2 && paramIsCoords(0) && paramIsInputColor(1));
- if (!validParams) {
- this->errorReporter().error(
- f.fOffset,
- "'main' parameters must be: ([float2 coords], [half4 color])");
- return;
- }
- break;
- }
case ProgramKind::kRuntimeColorFilter: {
// (half4|float4) main(half4|float4)
if (!typeIsValidForColor(*returnType)) {
diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp
index af0f2cd..e8b3620 100644
--- a/src/sksl/SkSLMain.cpp
+++ b/src/sksl/SkSLMain.cpp
@@ -282,14 +282,12 @@
kind = SkSL::ProgramKind::kGeometry;
} else if (inputPath.endsWith(".fp")) {
kind = SkSL::ProgramKind::kFragmentProcessor;
- } else if (inputPath.endsWith(".rte")) {
- kind = SkSL::ProgramKind::kRuntimeEffect;
} else if (inputPath.endsWith(".rtcf")) {
kind = SkSL::ProgramKind::kRuntimeColorFilter;
} else if (inputPath.endsWith(".rts")) {
kind = SkSL::ProgramKind::kRuntimeShader;
} else {
- printf("input filename must end in '.vert', '.frag', '.geom', '.fp', '.rte', '.rtcf', "
+ printf("input filename must end in '.vert', '.frag', '.geom', '.fp', '.rtcf', "
"'.rts', or '.sksl'\n");
return ResultCode::kInputError;
}
diff --git a/src/sksl/SkSLProgramSettings.h b/src/sksl/SkSLProgramSettings.h
index 3396ef7..427e63f 100644
--- a/src/sksl/SkSLProgramSettings.h
+++ b/src/sksl/SkSLProgramSettings.h
@@ -78,8 +78,7 @@
bool strictES2Mode() const {
return fSettings.fEnforceES2Restrictions &&
- (fKind == ProgramKind::kRuntimeEffect ||
- fKind == ProgramKind::kRuntimeColorFilter ||
+ (fKind == ProgramKind::kRuntimeColorFilter ||
fKind == ProgramKind::kRuntimeShader ||
fKind == ProgramKind::kGeneric);
}
diff --git a/src/sksl/dsl/DSLFunction.cpp b/src/sksl/dsl/DSLFunction.cpp
index 3aada20..7e2971e 100644
--- a/src/sksl/dsl/DSLFunction.cpp
+++ b/src/sksl/dsl/DSLFunction.cpp
@@ -45,7 +45,8 @@
param->fStorage = SkSL::VariableStorage::kParameter;
if (paramVars.empty()) {
SkSL::ProgramKind kind = DSLWriter::Context().fConfig->fKind;
- if (isMain && (kind == ProgramKind::kRuntimeEffect ||
+ if (isMain && (kind == ProgramKind::kRuntimeColorFilter ||
+ kind == ProgramKind::kRuntimeShader ||
kind == ProgramKind::kFragmentProcessor)) {
const SkSL::Type& type = param->fType.skslType();
// We verify that the signature is fully correct later. For now, if this is an .fp
diff --git a/src/sksl/dsl/DSLRuntimeEffects.cpp b/src/sksl/dsl/DSLRuntimeEffects.cpp
index 2408c03..59424fb 100644
--- a/src/sksl/dsl/DSLRuntimeEffects.cpp
+++ b/src/sksl/dsl/DSLRuntimeEffects.cpp
@@ -20,7 +20,7 @@
#ifndef SKSL_STANDALONE
void StartRuntimeShader(SkSL::Compiler* compiler) {
- Start(compiler, SkSL::ProgramKind::kRuntimeEffect);
+ Start(compiler, SkSL::ProgramKind::kRuntimeShader);
SkSL::ProgramSettings& settings = DSLWriter::IRGenerator().fContext.fConfig->fSettings;
SkASSERT(settings.fInlineThreshold == SkSL::kDefaultInlineThreshold);
settings.fInlineThreshold = 0;
diff --git a/src/sksl/sksl_runtime.sksl b/src/sksl/sksl_runtime.sksl
deleted file mode 100644
index 13202de..0000000
--- a/src/sksl/sksl_runtime.sksl
+++ /dev/null
@@ -1,13 +0,0 @@
-layout(builtin=15) float4 sk_FragCoord;
-
-// Today, we continue to allow all versions of sample from any runtime effect.
-// When shader and colorFilter are different program kinds, move these declarations into separate
-// modules so that each stage can only see the permitted versions.
-// Ultimately, these declarations can go away, when we support invoking children like functions
-// (using the same arguments here, eg shader_name(coords) rather than sample(shader, coords)).
-// skbug.com/11813
-
-half4 sample(shader s);
-half4 sample(shader s, float2 coords);
-
-half4 sample(colorFilter f);