#include "src/sksl/codegen/SkSLRasterPipelineCodeGenerator.h"
#include "include/core/SkPoint.h"
#include "include/core/SkSpan.h"
#include "include/private/base/SkTArray.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkEnumBitMask.h"
#include "src/base/SkStringView.h"
#include "src/base/SkUtils.h"
#include "src/core/SkTHash.h"
#include "src/sksl/SkSLAnalysis.h"
#include "src/sksl/SkSLBuiltinTypes.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLConstantFolder.h"
#include "src/sksl/SkSLContext.h"
#include "src/sksl/SkSLDefines.h"
#include "src/sksl/SkSLIntrinsicList.h"
#include "src/sksl/SkSLOperator.h"
#include "src/sksl/SkSLPosition.h"
#include "src/sksl/analysis/SkSLProgramUsage.h"
#include "src/sksl/codegen/SkSLRasterPipelineBuilder.h"
#include "src/sksl/ir/SkSLBinaryExpression.h"
#include "src/sksl/ir/SkSLBlock.h"
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLChildCall.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLConstructorSplat.h"
#include "src/sksl/ir/SkSLContinueStatement.h"
#include "src/sksl/ir/SkSLDoStatement.h"
#include "src/sksl/ir/SkSLExpression.h"
#include "src/sksl/ir/SkSLExpressionStatement.h"
#include "src/sksl/ir/SkSLFieldAccess.h"
#include "src/sksl/ir/SkSLForStatement.h"
#include "src/sksl/ir/SkSLFunctionCall.h"
#include "src/sksl/ir/SkSLFunctionDeclaration.h"
#include "src/sksl/ir/SkSLFunctionDefinition.h"
#include "src/sksl/ir/SkSLIRNode.h"
#include "src/sksl/ir/SkSLIfStatement.h"
#include "src/sksl/ir/SkSLIndexExpression.h"
#include "src/sksl/ir/SkSLLayout.h"
#include "src/sksl/ir/SkSLLiteral.h"
#include "src/sksl/ir/SkSLModifierFlags.h"
#include "src/sksl/ir/SkSLPostfixExpression.h"
#include "src/sksl/ir/SkSLPrefixExpression.h"
#include "src/sksl/ir/SkSLProgram.h"
#include "src/sksl/ir/SkSLProgramElement.h"
#include "src/sksl/ir/SkSLReturnStatement.h"
#include "src/sksl/ir/SkSLStatement.h"
#include "src/sksl/ir/SkSLSwitchCase.h"
#include "src/sksl/ir/SkSLSwitchStatement.h"
#include "src/sksl/ir/SkSLSwizzle.h"
#include "src/sksl/ir/SkSLTernaryExpression.h"
#include "src/sksl/ir/SkSLType.h"
#include "src/sksl/ir/SkSLVarDeclarations.h"
#include "src/sksl/ir/SkSLVariable.h"
#include "src/sksl/ir/SkSLVariableReference.h"
#include "src/sksl/tracing/SkSLDebugTracePriv.h"
#include "src/sksl/transform/SkSLTransform.h"
#include <algorithm>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <float.h>
#include <iterator>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
usingnamespaceskia_private;
namespace SkSL {
namespace RP {
static bool unsupported() { … }
class AutoContinueMask;
class Generator;
class LValue;
class SlotManager { … };
class AutoStack { … };
class Generator { … };
AutoStack::AutoStack(Generator* g)
: … { … }
AutoStack::~AutoStack() { … }
void AutoStack::enter() { … }
void AutoStack::exit() { … }
void AutoStack::pushClone(int slots) { … }
void AutoStack::pushClone(SlotRange range, int offsetFromStackTop) { … }
void AutoStack::pushCloneIndirect(SlotRange range, int dynamicStackID, int offsetFromStackTop) { … }
class AutoContinueMask { … };
class AutoLoopTarget { … };
class LValue { … };
class ScratchLValue final : public LValue { … };
class VariableLValue final : public LValue { … };
class ImmutableLValue final : public LValue { … };
class SwizzleLValue final : public LValue { … };
class UnownedLValueSlice : public LValue { … };
class LValueSlice final : public UnownedLValueSlice { … };
class DynamicIndexLValue final : public LValue { … };
void SlotManager::addSlotDebugInfoForGroup(const std::string& varName,
const Type& type,
Position pos,
int* groupIndex,
bool isFunctionReturnValue) { … }
void SlotManager::addSlotDebugInfo(const std::string& varName,
const Type& type,
Position pos,
bool isFunctionReturnValue) { … }
SlotRange SlotManager::createSlots(std::string name,
const Type& type,
Position pos,
bool isFunctionReturnValue) { … }
std::optional<SlotRange> SlotManager::mapVariableToSlots(const Variable& v, SlotRange range) { … }
void SlotManager::unmapVariableSlots(const Variable& v) { … }
SlotRange SlotManager::getVariableSlots(const Variable& v) { … }
SlotRange SlotManager::getFunctionSlots(const IRNode& callSite, const FunctionDeclaration& f) { … }
static bool is_sliceable_swizzle(SkSpan<const int8_t> components) { … }
std::unique_ptr<LValue> Generator::makeLValue(const Expression& e, bool allowScratch) { … }
bool Generator::push(LValue& lvalue) { … }
bool Generator::store(LValue& lvalue) { … }
int Generator::getFunctionDebugInfo(const FunctionDeclaration& decl) { … }
int Generator::createStack() { … }
void Generator::recycleStack(int stackID) { … }
void Generator::setCurrentStack(int stackID) { … }
std::optional<SlotRange> Generator::writeFunction(
const IRNode& callSite,
const FunctionDefinition& function,
SkSpan<std::unique_ptr<Expression> const> arguments) { … }
void Generator::emitTraceLine(Position pos) { … }
void Generator::pushTraceScopeMask() { … }
void Generator::discardTraceScopeMask() { … }
void Generator::emitTraceScope(int delta) { … }
void Generator::calculateLineOffsets() { … }
bool Generator::writeGlobals() { … }
bool Generator::writeStatement(const Statement& s) { … }
bool Generator::writeBlock(const Block& b) { … }
bool Generator::writeBreakStatement(const BreakStatement&) { … }
bool Generator::writeContinueStatement(const ContinueStatement&) { … }
bool Generator::writeDoStatement(const DoStatement& d) { … }
bool Generator::writeMasklessForStatement(const ForStatement& f) { … }
bool Generator::writeForStatement(const ForStatement& f) { … }
bool Generator::writeExpressionStatement(const ExpressionStatement& e) { … }
bool Generator::writeDynamicallyUniformIfStatement(const IfStatement& i) { … }
bool Generator::writeIfStatement(const IfStatement& i) { … }
bool Generator::writeReturnStatement(const ReturnStatement& r) { … }
bool Generator::writeSwitchStatement(const SwitchStatement& s) { … }
bool Generator::writeImmutableVarDeclaration(const VarDeclaration& d) { … }
bool Generator::writeVarDeclaration(const VarDeclaration& v) { … }
bool Generator::pushExpression(const Expression& e, bool usesResult) { … }
BuilderOp Generator::GetTypedOp(const SkSL::Type& type, const TypedOps& ops) { … }
bool Generator::unaryOp(const SkSL::Type& type, const TypedOps& ops) { … }
bool Generator::binaryOp(const SkSL::Type& type, const TypedOps& ops) { … }
bool Generator::ternaryOp(const SkSL::Type& type, const TypedOps& ops) { … }
void Generator::foldWithMultiOp(BuilderOp op, int elements) { … }
bool Generator::pushLValueOrExpression(LValue* lvalue, const Expression& expr) { … }
bool Generator::pushMatrixMultiply(LValue* lvalue,
const Expression& left,
const Expression& right,
int leftColumns,
int leftRows,
int rightColumns,
int rightRows) { … }
void Generator::foldComparisonOp(Operator op, int elements) { … }
bool Generator::pushStructuredComparison(LValue* left,
Operator op,
LValue* right,
const Type& type) { … }
bool Generator::pushBinaryExpression(const BinaryExpression& e) { … }
bool Generator::pushBinaryExpression(const Expression& left, Operator op, const Expression& right) { … }
std::optional<Generator::ImmutableBits> Generator::getImmutableBitsForSlot(const Expression& expr,
size_t slot) { … }
bool Generator::getImmutableValueForExpression(const Expression& expr,
TArray<ImmutableBits>* immutableValues) { … }
void Generator::storeImmutableValueToSlots(const TArray<ImmutableBits>& immutableValues,
SlotRange slots) { … }
std::optional<SlotRange> Generator::findPreexistingImmutableData(
const TArray<ImmutableBits>& immutableValues) { … }
bool Generator::pushImmutableData(const Expression& e) { … }
bool Generator::pushConstructorCompound(const AnyConstructor& c) { … }
bool Generator::pushChildCall(const ChildCall& c) { … }
bool Generator::pushConstructorCast(const AnyConstructor& c) { … }
bool Generator::pushConstructorDiagonalMatrix(const ConstructorDiagonalMatrix& c) { … }
bool Generator::pushConstructorMatrixResize(const ConstructorMatrixResize& c) { … }
bool Generator::pushConstructorSplat(const ConstructorSplat& c) { … }
bool Generator::pushFieldAccess(const FieldAccess& f) { … }
bool Generator::pushFunctionCall(const FunctionCall& c) { … }
bool Generator::pushIndexExpression(const IndexExpression& i) { … }
bool Generator::pushIntrinsic(const FunctionCall& c) { … }
bool Generator::pushLengthIntrinsic(int slotCount) { … }
bool Generator::pushAbsFloatIntrinsic(int slots) { … }
bool Generator::pushVectorizedExpression(const Expression& expr, const Type& vectorType) { … }
bool Generator::pushIntrinsic(const TypedOps& ops, const Expression& arg0) { … }
bool Generator::pushIntrinsic(BuilderOp builderOp, const Expression& arg0) { … }
bool Generator::pushIntrinsic(IntrinsicKind intrinsic, const Expression& arg0) { … }
bool Generator::pushIntrinsic(const TypedOps& ops, const Expression& arg0, const Expression& arg1) { … }
bool Generator::pushIntrinsic(BuilderOp builderOp, const Expression& arg0, const Expression& arg1) { … }
bool Generator::pushIntrinsic(IntrinsicKind intrinsic,
const Expression& arg0,
const Expression& arg1) { … }
bool Generator::pushIntrinsic(IntrinsicKind intrinsic,
const Expression& arg0,
const Expression& arg1,
const Expression& arg2) { … }
bool Generator::pushLiteral(const Literal& l) { … }
bool Generator::pushPostfixExpression(const PostfixExpression& p, bool usesResult) { … }
bool Generator::pushPrefixExpression(const PrefixExpression& p) { … }
bool Generator::pushPrefixExpression(Operator op, const Expression& expr) { … }
bool Generator::pushSwizzle(const Swizzle& s) { … }
bool Generator::pushTernaryExpression(const TernaryExpression& t) { … }
bool Generator::pushDynamicallyUniformTernaryExpression(const Expression& test,
const Expression& ifTrue,
const Expression& ifFalse) { … }
bool Generator::pushTernaryExpression(const Expression& test,
const Expression& ifTrue,
const Expression& ifFalse) { … }
bool Generator::pushVariableReference(const VariableReference& var) { … }
bool Generator::pushVariableReferencePartial(const VariableReference& v, SlotRange subset) { … }
bool Generator::writeProgram(const FunctionDefinition& function) { … }
std::unique_ptr<RP::Program> Generator::finish() { … }
}
std::unique_ptr<RP::Program> MakeRasterPipelineProgram(const SkSL::Program& program,
const FunctionDefinition& function,
DebugTracePriv* debugTrace,
bool writeTraceOps) { … }
}