Remove blend and colorFilter sksl modules

This moves the functions for dealing with child effects into the public
module (where those types already live). With that change, blend and
colorFilter have no module-specific declarations.

Change-Id: I7665e68427ea4d8d1ed4d31afb658edb79bac5a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443412
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
Brian Osman 2021-08-30 16:40:44 -04:00 committed by SkCQ
parent 0d45655e42
commit a8b897bfc1
13 changed files with 136 additions and 341 deletions

View File

@ -669,8 +669,6 @@ if (skia_compile_sksl_tests) {
"src/sksl/sksl_frag.sksl",
"src/sksl/sksl_gpu.sksl",
"src/sksl/sksl_public.sksl",
"src/sksl/sksl_rt_blend.sksl",
"src/sksl/sksl_rt_colorfilter.sksl",
"src/sksl/sksl_rt_shader.sksl",
"src/sksl/sksl_vert.sksl",
]

View File

@ -186,7 +186,9 @@ void SkParticleEffectParams::prepare(const skresources::ResourceProvider* resour
for (int i = 0; i < uniformInfo->fUniformSlotCount; ++i) {
uniformIDs.push_back(b.uniform32(skslUniformPtr, i * sizeof(int)).id);
}
SkSL::ProgramToSkVM(*program, *fn, &b, SkMakeSpan(uniformIDs));
if (!SkSL::ProgramToSkVM(*program, *fn, &b, SkMakeSpan(uniformIDs))) {
return skvm::Program{};
}
return b.done();
};

View File

@ -61,8 +61,6 @@
#include "src/sksl/generated/sksl_frag.dehydrated.sksl"
#include "src/sksl/generated/sksl_gpu.dehydrated.sksl"
#include "src/sksl/generated/sksl_public.dehydrated.sksl"
#include "src/sksl/generated/sksl_rt_blend.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_vert.dehydrated.sksl"
@ -241,13 +239,6 @@ const ParsedModule& Compiler::loadVertexModule() {
return fVertexModule;
}
const ParsedModule& Compiler::loadPublicModule() {
if (!fPublicModule.fSymbols) {
fPublicModule = this->parseModule(ProgramKind::kGeneric, MODULE_DATA(public), fRootModule);
}
return fPublicModule;
}
static void add_glsl_type_aliases(SkSL::SymbolTable* symbols, const SkSL::BuiltinTypes& types) {
// Add some aliases to the runtime effect modules so that it's friendlier, and more like GLSL
symbols->addAlias("vec2", types.fFloat2.get());
@ -267,42 +258,30 @@ static void add_glsl_type_aliases(SkSL::SymbolTable* symbols, const SkSL::Builti
symbols->addAlias("mat4", types.fFloat4x4.get());
}
const ParsedModule& Compiler::loadRuntimeColorFilterModule() {
if (!fRuntimeColorFilterModule.fSymbols) {
fRuntimeColorFilterModule = this->parseModule(ProgramKind::kRuntimeColorFilter,
MODULE_DATA(rt_colorfilter),
this->loadPublicModule());
add_glsl_type_aliases(fRuntimeColorFilterModule.fSymbols.get(), fContext->fTypes);
const ParsedModule& Compiler::loadPublicModule() {
if (!fPublicModule.fSymbols) {
fPublicModule = this->parseModule(ProgramKind::kGeneric, MODULE_DATA(public), fRootModule);
add_glsl_type_aliases(fPublicModule.fSymbols.get(), fContext->fTypes);
}
return fRuntimeColorFilterModule;
return fPublicModule;
}
const ParsedModule& Compiler::loadRuntimeShaderModule() {
if (!fRuntimeShaderModule.fSymbols) {
fRuntimeShaderModule = this->parseModule(
ProgramKind::kRuntimeShader, MODULE_DATA(rt_shader), this->loadPublicModule());
add_glsl_type_aliases(fRuntimeShaderModule.fSymbols.get(), fContext->fTypes);
}
return fRuntimeShaderModule;
}
const ParsedModule& Compiler::loadRuntimeBlenderModule() {
if (!fRuntimeBlenderModule.fSymbols) {
fRuntimeBlenderModule = this->parseModule(
ProgramKind::kRuntimeBlender, MODULE_DATA(rt_blend), this->loadPublicModule());
add_glsl_type_aliases(fRuntimeBlenderModule.fSymbols.get(), fContext->fTypes);
}
return fRuntimeBlenderModule;
}
const ParsedModule& Compiler::moduleForProgramKind(ProgramKind kind) {
switch (kind) {
case ProgramKind::kVertex: return this->loadVertexModule(); break;
case ProgramKind::kFragment: return this->loadFragmentModule(); break;
case ProgramKind::kRuntimeColorFilter: return this->loadRuntimeColorFilterModule(); break;
case ProgramKind::kRuntimeShader: return this->loadRuntimeShaderModule(); break;
case ProgramKind::kRuntimeBlender: return this->loadRuntimeBlenderModule(); break;
case ProgramKind::kGeneric: return this->loadPublicModule(); break;
case ProgramKind::kVertex: return this->loadVertexModule(); break;
case ProgramKind::kFragment: return this->loadFragmentModule(); break;
case ProgramKind::kRuntimeColorFilter: return this->loadPublicModule(); break;
case ProgramKind::kRuntimeShader: return this->loadRuntimeShaderModule(); break;
case ProgramKind::kRuntimeBlender: return this->loadPublicModule(); break;
case ProgramKind::kGeneric: return this->loadPublicModule(); break;
}
SkUNREACHABLE;
}

View File

@ -220,9 +220,7 @@ private:
const ParsedModule& loadFragmentModule();
const ParsedModule& loadVertexModule();
const ParsedModule& loadPublicModule();
const ParsedModule& loadRuntimeColorFilterModule();
const ParsedModule& loadRuntimeShaderModule();
const ParsedModule& loadRuntimeBlenderModule();
std::shared_ptr<SymbolTable> makeRootSymbolTable();
std::shared_ptr<SymbolTable> makePrivateSymbolTable(std::shared_ptr<SymbolTable> parent);
@ -259,9 +257,7 @@ private:
ParsedModule fFragmentModule; // [GPU] + Fragment stage decls
ParsedModule fPublicModule; // [Root] + Public features
ParsedModule fRuntimeColorFilterModule; // [Public] + Runtime shader decls
ParsedModule fRuntimeShaderModule; // [Public] + Runtime color filter decls
ParsedModule fRuntimeBlenderModule; // [Public] + Runtime blender decls
ParsedModule fRuntimeShaderModule; // [Public] + Runtime shader decls
// holds ModifiersPools belonging to the core includes for lifetime purposes
ModifiersPool fCoreModifiers;

View File

@ -1648,13 +1648,32 @@ bool ProgramToSkVM(const Program& program,
returnVals.push_back(b->splat(0.0f).id);
}
bool sampledChildEffects = false;
auto sampleShader = [&](int, skvm::Coord) {
sampledChildEffects = true;
return skvm::Color{};
};
auto sampleColorFilter = [&](int, skvm::Color) {
sampledChildEffects = true;
return skvm::Color{};
};
auto sampleBlender = [&](int, skvm::Color, skvm::Color) {
sampledChildEffects = true;
return skvm::Color{};
};
skvm::F32 zero = b->splat(0.0f);
skvm::Coord zeroCoord = {zero, zero};
SkVMGenerator generator(program, b, uniforms, /*device=*/zeroCoord, /*local=*/zeroCoord,
/*sampleShader=*/nullptr, /*sampleColorFilter=*/nullptr,
/*sampleBlender=*/nullptr);
sampleShader, sampleColorFilter, sampleBlender);
generator.writeFunction(function, SkMakeSpan(argVals), SkMakeSpan(returnVals));
// If the SkSL tried to use any shader, colorFilter, or blender objects - we don't have a
// mechanism (yet) for binding to those.
if (sampledChildEffects) {
return false;
}
// generateCode has updated the contents of 'argVals' for any 'out' or 'inout' parameters.
// Propagate those changes back to our varying buffers:
size_t argIdx = 0;

View File

@ -1,4 +1,4 @@
static uint8_t SKSL_INCLUDE_sksl_public[] = {53,3,
static uint8_t SKSL_INCLUDE_sksl_public[] = {134,3,
7,100,101,103,114,101,101,115,
8,36,103,101,110,84,121,112,101,
7,114,97,100,105,97,110,115,
@ -117,7 +117,21 @@ static uint8_t SKSL_INCLUDE_sksl_public[] = {53,3,
1,112,
4,100,70,100,120,
4,100,70,100,121,
48,28,2,
1,115,
6,115,104,97,100,101,114,
6,99,111,111,114,100,115,
6,102,108,111,97,116,50,
5,115,104,97,100,101,
1,102,
11,99,111,108,111,114,70,105,108,116,101,114,
6,102,105,108,116,101,114,
1,98,
7,98,108,101,110,100,101,114,
3,115,114,99,
3,100,115,116,
5,98,108,101,110,100,
6,115,97,109,112,108,101,
48,50,2,
52,1,0,
17,2,0,
49,2,0,10,0,3,
@ -1931,7 +1945,74 @@ static uint8_t SKSL_INCLUDE_sksl_public[] = {53,3,
37,
16,0,16,0,0,50,3,1,57,2,
46,5,0,
46,59,2,67,0,
46,59,2,
52,60,2,
17,55,3,
49,61,2,57,3,3,
52,62,2,
17,64,3,
49,63,2,71,3,3,
29,64,2,
17,78,3,2,60,2,62,2,
46,44,2,
52,65,2,
17,84,3,
49,66,2,86,3,3,
52,67,2,
17,15,3,
46,44,2,3,
29,68,2,
17,98,3,2,65,2,67,2,
46,44,2,
52,69,2,
17,105,3,
49,70,2,107,3,3,
52,71,2,
17,115,3,
46,44,2,3,
52,72,2,
17,119,3,
46,44,2,3,
29,73,2,
17,123,3,3,69,2,71,2,72,2,
46,44,2,
52,74,2,
17,55,3,
46,61,2,3,
52,75,2,
17,64,3,
46,63,2,3,
29,76,2,
17,129,3,2,74,2,75,2,
46,44,2,
52,77,2,
17,84,3,
46,66,2,3,
52,78,2,
17,15,3,
46,44,2,3,
51,79,2,2,
46,76,2,
29,80,2,
17,129,3,2,77,2,78,2,
46,44,2,
46,80,2,
52,81,2,
17,105,3,
46,70,2,3,
52,82,2,
17,115,3,
46,44,2,3,
52,83,2,
17,119,3,
46,44,2,3,
51,84,2,3,
46,76,2,
46,80,2,
29,85,2,
17,129,3,3,81,2,82,2,83,2,
46,44,2,
46,85,2,71,0,
118,0,
33,0,
71,0,
@ -1941,6 +2022,7 @@ static uint8_t SKSL_INCLUDE_sksl_public[] = {53,3,
66,0,
46,0,
76,0,
37,2,
133,0,
53,1,
18,0,
@ -1956,6 +2038,7 @@ static uint8_t SKSL_INCLUDE_sksl_public[] = {53,3,
88,0,
98,0,
113,1,
33,2,
7,1,
9,1,
128,0,
@ -1986,7 +2069,9 @@ static uint8_t SKSL_INCLUDE_sksl_public[] = {53,3,
129,1,
22,1,
27,1,
48,2,
207,0,
30,2,
123,0,
13,0,
51,0,

View File

@ -1,92 +0,0 @@
static uint8_t SKSL_INCLUDE_sksl_rt_blend[] = {93,0,
1,115,
6,115,104,97,100,101,114,
6,99,111,111,114,100,115,
6,102,108,111,97,116,50,
5,115,104,97,100,101,
5,104,97,108,102,52,
1,102,
11,99,111,108,111,114,70,105,108,116,101,114,
5,99,111,108,111,114,
6,102,105,108,116,101,114,
1,98,
7,98,108,101,110,100,101,114,
3,115,114,99,
3,100,115,116,
5,98,108,101,110,100,
6,115,97,109,112,108,101,
48,22,0,
52,1,0,
17,2,0,
49,2,0,4,0,3,
52,3,0,
17,11,0,
49,4,0,18,0,3,
29,5,0,
17,25,0,2,1,0,3,0,
49,6,0,31,0,
52,7,0,
17,37,0,
49,8,0,39,0,3,
52,9,0,
17,51,0,
46,6,0,3,
29,10,0,
17,57,0,2,7,0,9,0,
46,6,0,
52,11,0,
17,64,0,
49,12,0,66,0,3,
52,13,0,
17,74,0,
46,6,0,3,
52,14,0,
17,78,0,
46,6,0,3,
29,15,0,
17,82,0,3,11,0,13,0,14,0,
46,6,0,
52,16,0,
17,2,0,
46,2,0,3,
52,17,0,
17,11,0,
46,4,0,3,
29,18,0,
17,88,0,2,16,0,17,0,
46,6,0,
52,19,0,
17,37,0,
46,8,0,3,
52,20,0,
17,51,0,
46,6,0,3,
51,21,0,2,
46,18,0,
29,22,0,
17,88,0,2,19,0,20,0,
46,6,0,
46,22,0,
52,23,0,
17,64,0,
46,12,0,3,
52,24,0,
17,74,0,
46,6,0,3,
52,25,0,
17,78,0,
46,6,0,3,
51,26,0,3,
46,18,0,
46,22,0,
29,27,0,
17,88,0,3,23,0,24,0,25,0,
46,6,0,
46,27,0,4,0,
9,0,
5,0,
20,0,
2,0,
20,
21,};
static constexpr size_t SKSL_INCLUDE_sksl_rt_blend_LENGTH = sizeof(SKSL_INCLUDE_sksl_rt_blend);

View File

@ -1,92 +0,0 @@
static uint8_t SKSL_INCLUDE_sksl_rt_colorfilter[] = {93,0,
1,115,
6,115,104,97,100,101,114,
6,99,111,111,114,100,115,
6,102,108,111,97,116,50,
5,115,104,97,100,101,
5,104,97,108,102,52,
1,102,
11,99,111,108,111,114,70,105,108,116,101,114,
5,99,111,108,111,114,
6,102,105,108,116,101,114,
1,98,
7,98,108,101,110,100,101,114,
3,115,114,99,
3,100,115,116,
5,98,108,101,110,100,
6,115,97,109,112,108,101,
48,22,0,
52,1,0,
17,2,0,
49,2,0,4,0,3,
52,3,0,
17,11,0,
49,4,0,18,0,3,
29,5,0,
17,25,0,2,1,0,3,0,
49,6,0,31,0,
52,7,0,
17,37,0,
49,8,0,39,0,3,
52,9,0,
17,51,0,
46,6,0,3,
29,10,0,
17,57,0,2,7,0,9,0,
46,6,0,
52,11,0,
17,64,0,
49,12,0,66,0,3,
52,13,0,
17,74,0,
46,6,0,3,
52,14,0,
17,78,0,
46,6,0,3,
29,15,0,
17,82,0,3,11,0,13,0,14,0,
46,6,0,
52,16,0,
17,2,0,
46,2,0,3,
52,17,0,
17,11,0,
46,4,0,3,
29,18,0,
17,88,0,2,16,0,17,0,
46,6,0,
52,19,0,
17,37,0,
46,8,0,3,
52,20,0,
17,51,0,
46,6,0,3,
51,21,0,2,
46,18,0,
29,22,0,
17,88,0,2,19,0,20,0,
46,6,0,
46,22,0,
52,23,0,
17,64,0,
46,12,0,3,
52,24,0,
17,74,0,
46,6,0,3,
52,25,0,
17,78,0,
46,6,0,3,
51,26,0,3,
46,18,0,
46,22,0,
29,27,0,
17,88,0,3,23,0,24,0,25,0,
46,6,0,
46,27,0,4,0,
9,0,
5,0,
20,0,
2,0,
20,
21,};
static constexpr size_t SKSL_INCLUDE_sksl_rt_colorfilter_LENGTH = sizeof(SKSL_INCLUDE_sksl_rt_colorfilter);

View File

@ -1,98 +1,11 @@
static uint8_t SKSL_INCLUDE_sksl_rt_shader[] = {113,0,
static uint8_t SKSL_INCLUDE_sksl_rt_shader[] = {20,0,
12,115,107,95,70,114,97,103,67,111,111,114,100,
6,102,108,111,97,116,52,
1,115,
6,115,104,97,100,101,114,
6,99,111,111,114,100,115,
6,102,108,111,97,116,50,
5,115,104,97,100,101,
5,104,97,108,102,52,
1,102,
11,99,111,108,111,114,70,105,108,116,101,114,
5,99,111,108,111,114,
6,102,105,108,116,101,114,
1,98,
7,98,108,101,110,100,101,114,
3,115,114,99,
3,100,115,116,
5,98,108,101,110,100,
6,115,97,109,112,108,101,
48,23,0,
48,1,0,
52,1,0,
36,
35,0,2,0,0,255,255,255,255,255,15,0,255,0,2,0,
49,2,0,15,0,0,
52,3,0,
17,22,0,
49,4,0,24,0,3,
52,5,0,
17,31,0,
49,6,0,38,0,3,
29,7,0,
17,45,0,2,3,0,5,0,
49,8,0,51,0,
52,9,0,
17,57,0,
49,10,0,59,0,3,
52,11,0,
17,71,0,
46,8,0,3,
29,12,0,
17,77,0,2,9,0,11,0,
46,8,0,
52,13,0,
17,84,0,
49,14,0,86,0,3,
52,15,0,
17,94,0,
46,8,0,3,
52,16,0,
17,98,0,
46,8,0,3,
29,17,0,
17,102,0,3,13,0,15,0,16,0,
46,8,0,
52,18,0,
17,22,0,
46,4,0,3,
52,19,0,
17,31,0,
46,6,0,3,
29,20,0,
17,108,0,2,18,0,19,0,
46,8,0,
52,21,0,
17,57,0,
46,10,0,3,
52,22,0,
17,71,0,
46,8,0,3,
51,23,0,2,
46,20,0,
29,24,0,
17,108,0,2,21,0,22,0,
46,8,0,
46,24,0,
52,25,0,
17,84,0,
46,14,0,3,
52,26,0,
17,94,0,
46,8,0,3,
52,27,0,
17,98,0,
46,8,0,3,
51,28,0,3,
46,20,0,
46,24,0,
29,29,0,
17,108,0,3,25,0,26,0,27,0,
46,8,0,
46,29,0,5,0,
10,0,
6,0,
21,0,
3,0,
49,2,0,15,0,0,1,0,
0,0,
20,
54,

View File

@ -205,3 +205,12 @@ $es3 $genType dFdx($genType p);
$es3 $genType dFdy($genType p);
$es3 $genHType dFdx($genHType p);
$es3 $genHType dFdy($genHType p);
// SkSL intrinsics that reflect Skia's C++ object model:
half4 shade(shader s, float2 coords);
half4 filter(colorFilter f, half4 color);
half4 blend(blender b, half4 src, half4 dst);
half4 sample(shader s, float2 coords);
half4 sample(colorFilter f, half4 color);
half4 sample(blender b, half4 src, half4 dst);

View File

@ -1,7 +0,0 @@
half4 shade(shader s, float2 coords);
half4 filter(colorFilter f, half4 color);
half4 blend(blender b, half4 src, half4 dst);
half4 sample(shader s, float2 coords);
half4 sample(colorFilter f, half4 color);
half4 sample(blender b, half4 src, half4 dst);

View File

@ -1,7 +0,0 @@
half4 shade(shader s, float2 coords);
half4 filter(colorFilter f, half4 color);
half4 blend(blender b, half4 src, half4 dst);
half4 sample(shader s, float2 coords);
half4 sample(colorFilter f, half4 color);
half4 sample(blender b, half4 src, half4 dst);

View File

@ -1,9 +1 @@
layout(builtin=15) float4 sk_FragCoord;
half4 shade(shader s, float2 coords);
half4 filter(colorFilter f, half4 color);
half4 blend(blender b, half4 src, half4 dst);
half4 sample(shader s, float2 coords);
half4 sample(colorFilter f, half4 color);
half4 sample(blender b, half4 src, half4 dst);