Add passthrough shader snippet.

This gives us a building block that mimics the effect of evaluating a
missing child effect.

Change-Id: Ic091f0692febc3370debcd4742751b175e98fde9
Bug: skia:13508
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/559076
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
John Stiles 2022-07-15 13:45:01 -04:00 committed by SkCQ
parent a72eda6bfc
commit 7d8ec28bd5
6 changed files with 1840 additions and 1784 deletions

View File

@ -18,6 +18,7 @@ enum class SkBuiltInCodeSnippetID : int32_t {
kError,
// SkShader code snippets
kPassthroughShader,
kSolidColorShader,
kLinearGradientShader4,
kLinearGradientShader8,

View File

@ -33,6 +33,23 @@ constexpr SkPMColor4f kErrorColor = { 1, 0, 0, 1 };
//--------------------------------------------------------------------------------------------------
void PassthroughShaderBlock::BeginBlock(const SkKeyContext& keyContext,
SkPaintParamsKeyBuilder* builder,
SkPipelineDataGatherer* gatherer) {
#ifdef SK_GRAPHITE_ENABLED
if (builder->backend() == SkBackend::kGraphite) {
builder->beginBlock(SkBuiltInCodeSnippetID::kPassthroughShader);
return;
}
#endif // SK_GRAPHITE_ENABLED
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
// TODO: add implementation of other backends
}
}
//--------------------------------------------------------------------------------------------------
#ifdef SK_GRAPHITE_ENABLED
namespace {
@ -71,7 +88,6 @@ void SolidColorShaderBlock::BeginBlock(const SkKeyContext& keyContext,
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
// TODO: add implementation of other backends
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -32,6 +32,14 @@ namespace skgpu::graphite { class TextureProxy; }
// The KeyHelpers can be used to manually construct an SkPaintParamsKey
struct PassthroughShaderBlock {
static void BeginBlock(const SkKeyContext&,
SkPaintParamsKeyBuilder*,
SkPipelineDataGatherer*);
};
struct SolidColorShaderBlock {
static void BeginBlock(const SkKeyContext&,

View File

@ -718,6 +718,9 @@ static constexpr char kMatrixColorFilterName[] = "sk_matrix_colorfilter";
//--------------------------------------------------------------------------------------------------
static constexpr char kErrorName[] = "sk_error";
//--------------------------------------------------------------------------------------------------
static constexpr char kPassthroughName[] = "sk_passthrough";
//--------------------------------------------------------------------------------------------------
// This method generates the glue code for the case where the SkBlendMode-based blending is
// handled with fixed function blending.
@ -969,6 +972,17 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kNoChildren,
{ } // no data payload
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kPassthroughShader] = {
"Passthrough",
{ }, // no uniforms
SnippetRequirementFlags::kPriorStageOutput,
{ }, // no samplers
kPassthroughName,
GenerateDefaultExpression,
GenerateDefaultPreamble,
kNoChildren,
{ } // no data payload
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kSolidColorShader] = {
"SolidColor",
SkSpan(kSolidShaderUniforms),

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,10 @@ half4 sk_error() {
return half4(1.0, 0.0, 1.0, 1.0);
}
half4 sk_passthrough(half4 color) {
return color;
}
half4 sk_solid_shader(float4 colorParam) {
return half4(colorParam);
}