Add 'num-pointers' field to SkShaderSnippet.

Most snippets have zero, but anything involving a runtime effect will
expect one pointer. At present this value isn't used anywhere.

Change-Id: I796e8c26433fa74512e39be65e7df76fba99f996
Bug: skia:13428
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550018
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2022-06-14 18:37:25 -04:00 committed by SkCQ
parent f3873a978b
commit d99ae45386
2 changed files with 26 additions and 3 deletions

View File

@ -642,6 +642,7 @@ bool SkShaderCodeDictionary::isValidID(int snippetID) const {
}
static constexpr int kNoChildren = 0;
static constexpr int kNoPointers = 0;
// TODO: this version needs to be removed
int SkShaderCodeDictionary::addUserDefinedSnippet(
@ -655,6 +656,7 @@ int SkShaderCodeDictionary::addUserDefinedSnippet(
name,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
dataPayloadExpectations));
// TODO: the memory for user-defined entries could go in the dictionary's arena but that
@ -682,7 +684,10 @@ SkBlenderID SkShaderCodeDictionary::addUserDefinedBlender(sk_sp<SkRuntimeEffect>
"foo",
GenerateDefaultGlueCode,
kNoChildren,
{})); // missing data payload
kNoPointers,
/*dataPayloadExpectations=*/{}));
// TODO(skia:13428): set `numPointers` to 1 here once actual pointer support is ready.
// TODO: the memory for user-defined entries could go in the dictionary's arena but that
// would have to be a thread safe allocation since the arena also stores entries for
@ -704,6 +709,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kErrorName,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kSolidColorShader] = {
@ -714,6 +720,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kSolidShaderName,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kLinearGradientShader4] = {
@ -724,6 +731,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kLinearGradient4Name,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kLinearGradientShader8] = {
@ -734,6 +742,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kLinearGradient8Name,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kRadialGradientShader4] = {
@ -744,6 +753,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kRadialGradient4Name,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kRadialGradientShader8] = {
@ -754,6 +764,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kRadialGradient8Name,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kSweepGradientShader4] = {
@ -764,6 +775,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kSweepGradient4Name,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kSweepGradientShader8] = {
@ -774,6 +786,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kSweepGradient8Name,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kConicalGradientShader4] = {
@ -784,6 +797,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kConicalGradient4Name,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kConicalGradientShader8] = {
@ -794,6 +808,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kConicalGradient8Name,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kLocalMatrixShader] = {
@ -804,6 +819,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kLocalMatrixShaderName,
GenerateDefaultGlueCode,
kNumLocalMatrixShaderChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kImageShader] = {
@ -814,6 +830,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kImageShaderName,
GenerateImageShaderGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kBlendShader] = {
@ -824,6 +841,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kBlendShaderName,
GenerateDefaultGlueCode,
kNumBlendShaderChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kRuntimeShader] = {
@ -834,6 +852,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kRuntimeShaderName,
GenerateDefaultGlueCode,
kNoChildren,
kNoPointers,
SkMakeSpan(kRuntimeShaderDataPayload)
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kFixedFunctionBlender] = {
@ -844,6 +863,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
"FF-blending", // fixed function blending doesn't use static SkSL
GenerateFixedFunctionBlenderGlueCode,
kNoChildren,
kNoPointers,
{ }
};
fBuiltInCodeSnippets[(int) SkBuiltInCodeSnippetID::kShaderBasedBlender] = {
@ -854,6 +874,7 @@ SkShaderCodeDictionary::SkShaderCodeDictionary() {
kBlendHelperName,
GenerateShaderBasedBlenderGlueCode,
kNoChildren,
kNoPointers,
{ }
};
}

View File

@ -61,6 +61,7 @@ struct SkShaderSnippet {
const char* functionName,
GenerateGlueCodeForEntry glueCodeGenerator,
int numChildren,
int numPointers,
SkSpan<const SkPaintParamsKey::DataPayloadField> dataPayloadExpectations)
: fName(name)
, fUniforms(uniforms)
@ -69,8 +70,8 @@ struct SkShaderSnippet {
, fStaticFunctionName(functionName)
, fGlueCodeGenerator(glueCodeGenerator)
, fNumChildren(numChildren)
, fDataPayloadExpectations(dataPayloadExpectations) {
}
, fNumPointers(numPointers)
, fDataPayloadExpectations(dataPayloadExpectations) {}
std::string getMangledUniformName(int uniformIndex, int mangleId) const;
@ -85,6 +86,7 @@ struct SkShaderSnippet {
const char* fStaticFunctionName = nullptr;
GenerateGlueCodeForEntry fGlueCodeGenerator = nullptr;
int fNumChildren = 0;
int fNumPointers = 0;
SkSpan<const SkPaintParamsKey::DataPayloadField> fDataPayloadExpectations;
};