Flutter Engine
The Flutter Engine
|
Classes | |
struct | AssignmentInfo |
struct | LoopControlFlowInfo |
class | SymbolTableStackBuilder |
Enumerations | |
enum class | ReturnComplexity { kSingleSafeReturn , kScopedReturns , kEarlyReturns } |
Provides utilities for analyzing SkSL statically before it's composed into a full program.
|
strong |
Determines if a given function has multiple and/or early returns.
Enumerator | |
---|---|
kSingleSafeReturn | |
kScopedReturns | |
kEarlyReturns |
Definition at line 238 of file SkSLAnalysis.h.
bool SkSL::Analysis::CallsColorTransformIntrinsics | ( | const Program & | program | ) |
Definition at line 374 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::CallsSampleOutsideMain | ( | const Program & | program | ) |
Definition at line 369 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::CanExitWithoutReturningValue | ( | const FunctionDeclaration & | funcDecl, |
const Statement & | body | ||
) |
Detects functions that fail to return a value on at least one path.
Definition at line 166 of file SkSLCanExitWithoutReturningValue.cpp.
bool SkSL::Analysis::CheckProgramStructure | ( | const Program & | program, |
bool | enforceSizeLimit | ||
) |
Checks for recursion or overly-deep function-call chains, and rejects programs which have them. Also, computes the size of the program in a completely flattened state–loops fully unrolled, function calls inlined–and rejects programs that exceed an arbitrary upper bound.
Definition at line 36 of file SkSLCheckProgramStructure.cpp.
void SkSL::Analysis::CheckSymbolTableCorrectness | ( | const Program & | program | ) |
Emits an internal error if a VarDeclaration exists without a matching entry in the nearest SymbolTable.
Definition at line 33 of file SkSLCheckSymbolTableCorrectness.cpp.
bool SkSL::Analysis::ContainsRTAdjust | ( | const Expression & | expr | ) |
Determines if expr
contains a reference to the variable sk_RTAdjust.
Definition at line 390 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::ContainsVariable | ( | const Expression & | expr, |
const Variable & | var | ||
) |
Determines if expr
contains a reference to variable var
.
Definition at line 408 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::DetectVarDeclarationWithoutScope | ( | const Statement & | stmt, |
ErrorReporter * | errors = nullptr |
||
) |
Detect an orphaned variable declaration outside of a scope, e.g. if (true) int a;. Returns true if an error was reported.
Definition at line 466 of file SkSLAnalysis.cpp.
void SkSL::Analysis::DoFinalizationChecks | ( | const Program & | program | ) |
Runs at finalization time to perform any last-minute correctness checks:
out
params which are never written to (structs are currently exempt) Definition at line 207 of file SkSLFinalizationChecks.cpp.
skia_private::TArray< const SkSL::Variable * > SkSL::Analysis::GetComputeShaderMainParams | ( | const Context & | context, |
const Program & | program | ||
) |
Error checks compute shader in/outs and returns a vector containing them ordered by location.
LoopControlFlowInfo SkSL::Analysis::GetLoopControlFlowInfo | ( | const Statement & | stmt | ) |
Definition at line 72 of file SkSLGetLoopControlFlowInfo.cpp.
std::unique_ptr< LoopUnrollInfo > SkSL::Analysis::GetLoopUnrollInfo | ( | const Context & | context, |
Position | pos, | ||
const ForLoopPositions & | positions, | ||
const Statement * | loopInitializer, | ||
std::unique_ptr< Expression > * | loopTestPtr, | ||
const Expression * | loopNext, | ||
const Statement * | loopStatement, | ||
ErrorReporter * | errors | ||
) |
Ensures that a for-loop meets the strict requirements of The OpenGL ES Shading Language 1.00, Appendix A, Section 4. If the requirements are met, information about the loop's structure is returned. If the requirements are not met, the problem is reported via errors
(if not nullptr), and null is returned. The loop test-expression may be altered by this check. For example, a loop like this: for (float x = 1.0; x != 0.0; x -= 0.01) {...} appears to be ES2-safe, but due to floating-point rounding error, it may not actually terminate. We rewrite the test condition to x > 0.0
in order to ensure loop termination.
Definition at line 59 of file SkSLGetLoopUnrollInfo.cpp.
Analysis::ReturnComplexity SkSL::Analysis::GetReturnComplexity | ( | const FunctionDefinition & | funcDef | ) |
Definition at line 116 of file SkSLGetReturnComplexity.cpp.
SampleUsage SkSL::Analysis::GetSampleUsage | ( | const Program & | program, |
const Variable & | child, | ||
bool | writesToSampleCoords = true , |
||
int * | elidedSampleCoordCount = nullptr |
||
) |
Determines how program
samples child
. By default, assumes that the sample coords might be modified, so child.eval(sampleCoords)
is treated as Explicit. If writesToSampleCoords is false, treats that as PassThrough, instead. If elidedSampleCoordCount is provided, the pointed to value will be incremented by the number of sample calls where the above rewrite was performed.
Definition at line 325 of file SkSLAnalysis.cpp.
std::unique_ptr< ProgramUsage > SkSL::Analysis::GetUsage | ( | const Module & | module | ) |
Definition at line 152 of file SkSLProgramUsage.cpp.
std::unique_ptr< ProgramUsage > SkSL::Analysis::GetUsage | ( | const Program & | program | ) |
Definition at line 145 of file SkSLProgramUsage.cpp.
bool SkSL::Analysis::HasSideEffects | ( | const Expression & | expr | ) |
Determines if expr
has any side effects. (Is the expression state-altering or pure?)
Definition at line 22 of file SkSLHasSideEffects.cpp.
bool SkSL::Analysis::IsAssignable | ( | Expression & | expr, |
AssignmentInfo * | info = nullptr , |
||
ErrorReporter * | errors = nullptr |
||
) |
Definition at line 507 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::IsCompileTimeConstant | ( | const Expression & | expr | ) |
Determines if expr
is a compile-time constant (composed of just constructors and literals).
Definition at line 429 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::IsConstantExpression | ( | const Expression & | expr | ) |
Returns true if expr is a constant-expression, as defined by GLSL 1.0, section 5.10. A constant expression is one of:
Definition at line 157 of file SkSLIsConstantExpression.cpp.
bool SkSL::Analysis::IsDynamicallyUniformExpression | ( | const Expression & | expr | ) |
Determines if expr
is a dynamically-uniform expression; this returns true if the expression could be evaluated at compile time if uniform values were known.
Definition at line 21 of file SkSLIsDynamicallyUniformExpression.cpp.
bool SkSL::Analysis::IsSameExpressionTree | ( | const Expression & | left, |
const Expression & | right | ||
) |
Returns true if both expression trees are the same. Used by the optimizer to look for self- assignment or self-comparison; won't necessarily catch complex cases. Rejects expressions that may cause side effects.
Definition at line 28 of file SkSLIsSameExpressionTree.cpp.
bool SkSL::Analysis::IsTrivialExpression | ( | const Expression & | expr | ) |
A "trivial" expression is one where we'd feel comfortable cloning it multiple times in the code, without worrying about incurring a performance penalty. Examples:
Trivial-ness is stackable. Somewhat large expressions can occasionally make the cut:
Definition at line 25 of file SkSLIsTrivialExpression.cpp.
int SkSL::Analysis::NodeCountUpToLimit | ( | const FunctionDefinition & | function, |
int | limit | ||
) |
Definition at line 499 of file SkSLAnalysis.cpp.
Definition at line 337 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::ReferencesFragCoords | ( | const Program & | program | ) |
Definition at line 365 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::ReferencesSampleCoords | ( | const Program & | program | ) |
Definition at line 347 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::ReturnsInputAlpha | ( | const FunctionDefinition & | function, |
const ProgramUsage & | usage | ||
) |
Determines if function
is a color filter which returns the alpha component of the input color unchanged. This is a very conservative analysis, and only supports returning a swizzle of the input color, or returning a constructor that ends with input.a
.
Definition at line 126 of file SkSLReturnsInputAlpha.cpp.
bool SkSL::Analysis::ReturnsOpaqueColor | ( | const FunctionDefinition & | function | ) |
Determines if function
always returns an opaque color (a vec4 where the last component is known to be 1). This is conservative, and based on constant expression analysis.
Definition at line 385 of file SkSLAnalysis.cpp.
Returns true if the passed-in statement might alter var
.
Definition at line 503 of file SkSLAnalysis.cpp.
bool SkSL::Analysis::SwitchCaseContainsConditionalExit | ( | const Statement & | stmt | ) |
Finds conditional exits from a switch-case. Returns true if this statement contains a conditional that wraps a potential exit from the switch (via continue, break or return).
Definition at line 94 of file SkSLSwitchCaseContainsExit.cpp.
bool SkSL::Analysis::SwitchCaseContainsUnconditionalExit | ( | const Statement & | stmt | ) |
Finds unconditional exits from a switch-case. Returns true if this statement unconditionally causes an exit from this switch (via continue, break or return).
Definition at line 90 of file SkSLSwitchCaseContainsExit.cpp.
bool SkSL::Analysis::UpdateVariableRefKind | ( | Expression * | expr, |
VariableRefKind | kind, | ||
ErrorReporter * | errors = nullptr |
||
) |
Updates the refKind
field of the VariableReference at the top level of expr
. If expr
can be assigned to (IsAssignable
), true is returned and no errors are reported. If not, false is returned. and an error is reported if errors
is non-null.
Definition at line 512 of file SkSLAnalysis.cpp.
void SkSL::Analysis::ValidateIndexingForES2 | ( | const ProgramElement & | pe, |
ErrorReporter & | errors | ||
) |
Ensures that any index-expressions inside of for-loops qualify as 'constant-index-expressions' as defined by GLSL 1.0, Appendix A, Section 5. A constant-index-expression is:
Definition at line 161 of file SkSLIsConstantExpression.cpp.