Add children to the key when creating a Runtime Shader.
They aren't called yet, but they are visible in the output SkSL. A followup CL will invoke them when `eval` is called. Change-Id: I8c28c332d718a9a773365c6a18e476da97bff9ad Bug: skia:13508 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/559096 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
b67b9c6158
commit
2cf696124c
@ -1186,6 +1186,22 @@ public:
|
||||
SkPipelineDataGatherer* gatherer) const override {
|
||||
RuntimeShaderBlock::BeginBlock(keyContext, builder, gatherer,
|
||||
{fEffect, this->getLocalMatrix(), fUniforms});
|
||||
|
||||
for (const SkRuntimeEffect::ChildPtr& child : fChildren) {
|
||||
std::optional<ChildType> type = child.type();
|
||||
if (type == ChildType::kShader) {
|
||||
as_SB(child.shader())->addToKey(keyContext, builder, gatherer);
|
||||
} else if (type == ChildType::kColorFilter) {
|
||||
as_CFB(child.colorFilter())->addToKey(keyContext, builder, gatherer);
|
||||
} else if (type == ChildType::kBlender) {
|
||||
as_BB(child.blender())->addToKey(keyContext, builder, gatherer);
|
||||
} else {
|
||||
// Patch in a "passthrough" child effect that returns the input color as-is.
|
||||
PassthroughShaderBlock::BeginBlock(keyContext, builder, gatherer);
|
||||
builder->endBlock();
|
||||
}
|
||||
}
|
||||
|
||||
builder->endBlock();
|
||||
}
|
||||
|
||||
|
@ -683,8 +683,13 @@ void GenerateRuntimeShaderPreamble(const SkShaderInfo& shaderInfo,
|
||||
SkASSERT(std::string_view(entry->fName) == kRuntimeShaderName); // the callbacks assume this
|
||||
SkSL::PipelineStage::ConvertProgram(program, "coords", "inColor", "half4(1)", &callbacks);
|
||||
|
||||
// We don't support children here yet.
|
||||
// Advance over the parent entry.
|
||||
*entryIndex += 1;
|
||||
|
||||
// Emit the preambles for all of our child effects (and advance the entry-index past them).
|
||||
for (int j = 0; j < entry->fNumChildren; ++j) {
|
||||
emit_preamble_for_entry(shaderInfo, entryIndex, preamble);
|
||||
}
|
||||
#endif // defined(SK_GRAPHITE_ENABLED) && defined(SK_ENABLE_SKSL)
|
||||
}
|
||||
|
||||
@ -951,7 +956,7 @@ int SkShaderCodeDictionary::findOrCreateRuntimeEffectSnippet(const SkRuntimeEffe
|
||||
kRuntimeShaderName,
|
||||
GenerateRuntimeShaderExpression,
|
||||
GenerateRuntimeShaderPreamble,
|
||||
/*numChildren=*/0,
|
||||
(int)effect->children().size(),
|
||||
/*dataPayloadExpectations=*/{});
|
||||
fRuntimeEffectMap.set(key, newCodeSnippetID);
|
||||
return newCodeSnippetID;
|
||||
|
Loading…
Reference in New Issue
Block a user