Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SkSL::RP::DynamicIndexLValue Class Referencefinal
Inheritance diagram for SkSL::RP::DynamicIndexLValue:
SkSL::RP::LValue

Public Member Functions

 DynamicIndexLValue (std::unique_ptr< LValue > p, const IndexExpression &i)
 
 ~DynamicIndexLValue () override
 
bool isWritable () const override
 
bool evaluateDynamicIndices (Generator *gen)
 
SlotRange fixedSlotRange (Generator *gen) override
 
AutoStackdynamicSlotRange () override
 
bool push (Generator *gen, SlotRange fixedOffset, AutoStack *dynamicOffset, SkSpan< const int8_t > swizzle) override
 
bool store (Generator *gen, SlotRange fixedOffset, AutoStack *dynamicOffset, SkSpan< const int8_t > swizzle) override
 
- Public Member Functions inherited from SkSL::RP::LValue
virtual ~LValue ()=default
 
virtual SkSpan< const int8_t > swizzle ()
 

Additional Inherited Members

- Public Attributes inherited from SkSL::RP::LValue
std::unique_ptr< ExpressionfScratchExpression
 

Detailed Description

Definition at line 1016 of file SkSLRasterPipelineCodeGenerator.cpp.

Constructor & Destructor Documentation

◆ DynamicIndexLValue()

SkSL::RP::DynamicIndexLValue::DynamicIndexLValue ( std::unique_ptr< LValue p,
const IndexExpression i 
)
inlineexplicit

Definition at line 1018 of file SkSLRasterPipelineCodeGenerator.cpp.

1019 : fParent(std::move(p))
1020 , fIndexExpr(&i) {
1021 SkASSERT(fIndexExpr->index()->type().isInteger());
1022 }
#define SkASSERT(cond)
Definition SkAssert.h:116
std::unique_ptr< Expression > & index()

◆ ~DynamicIndexLValue()

SkSL::RP::DynamicIndexLValue::~DynamicIndexLValue ( )
inlineoverride

Definition at line 1024 of file SkSLRasterPipelineCodeGenerator.cpp.

1024 {
1025 if (fDedicatedStack.has_value()) {
1026 SkASSERT(fGenerator);
1027
1028 // Jettison the index expression.
1029 fDedicatedStack->enter();
1030 fGenerator->discardExpression(/*slots=*/1);
1031 fDedicatedStack->exit();
1032 }
1033 }

Member Function Documentation

◆ dynamicSlotRange()

AutoStack * SkSL::RP::DynamicIndexLValue::dynamicSlotRange ( )
inlineoverridevirtual

Returns a stack which holds a single integer, representing the dynamic offset of the lvalue. This value does not incorporate the fixed offset. If null is returned, the lvalue doesn't have a dynamic offset. evaluateDynamicIndices must be called before this is used.

Implements SkSL::RP::LValue.

Definition at line 1082 of file SkSLRasterPipelineCodeGenerator.cpp.

1082 {
1083 // We incorporated any parent dynamic offsets when `evaluateDynamicIndices` was called.
1084 SkASSERT(fDedicatedStack.has_value());
1085 return &*fDedicatedStack;
1086 }

◆ evaluateDynamicIndices()

bool SkSL::RP::DynamicIndexLValue::evaluateDynamicIndices ( Generator gen)
inline

Definition at line 1039 of file SkSLRasterPipelineCodeGenerator.cpp.

1039 {
1040 // The index must only be computed once; the index-expression could have side effects.
1041 // Once it has been computed, the offset lives on `fDedicatedStack`.
1042 SkASSERT(!fDedicatedStack.has_value());
1043 SkASSERT(!fGenerator);
1044 fGenerator = gen;
1045 fDedicatedStack.emplace(fGenerator);
1046
1047 if (!fParent->swizzle().empty()) {
1048 SkDEBUGFAIL("an indexed-swizzle should have been handled by RewriteIndexedSwizzle");
1049 return unsupported();
1050 }
1051
1052 // Push the index expression onto the dedicated stack.
1053 fDedicatedStack->enter();
1054 if (!fGenerator->pushExpression(*fIndexExpr->index())) {
1055 return unsupported();
1056 }
1057
1058 // Multiply the index-expression result by the per-value slot count.
1059 int slotCount = fIndexExpr->type().slotCount();
1060 if (slotCount != 1) {
1061 fGenerator->builder()->push_constant_i(fIndexExpr->type().slotCount());
1062 fGenerator->builder()->binary_op(BuilderOp::mul_n_ints, 1);
1063 }
1064
1065 // Check to see if a parent LValue already has a dynamic index. If so, we need to
1066 // incorporate its value into our own.
1067 if (AutoStack* parentDynamicIndexStack = fParent->dynamicSlotRange()) {
1068 parentDynamicIndexStack->pushClone(/*slots=*/1);
1069 fGenerator->builder()->binary_op(BuilderOp::add_n_ints, 1);
1070 }
1071 fDedicatedStack->exit();
1072 return true;
1073 }
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118
virtual const Type & type() const
void binary_op(BuilderOp op, int32_t slots)
void push_constant_i(int32_t val, int count=1)
bool pushExpression(const Expression &e, bool usesResult=true)
virtual size_t slotCount() const
Definition SkSLType.h:457
Definition gen.py:1

◆ fixedSlotRange()

SlotRange SkSL::RP::DynamicIndexLValue::fixedSlotRange ( Generator gen)
inlineoverridevirtual

Returns the fixed slot range of the lvalue, after it is winnowed down to the selected field/index. The range is calculated assuming every dynamic index will evaluate to zero.

Implements SkSL::RP::LValue.

Definition at line 1075 of file SkSLRasterPipelineCodeGenerator.cpp.

1075 {
1076 // Compute the fixed slot range as if we are indexing into position zero.
1077 SlotRange range = fParent->fixedSlotRange(gen);
1078 range.count = fIndexExpr->type().slotCount();
1079 return range;
1080 }

◆ isWritable()

bool SkSL::RP::DynamicIndexLValue::isWritable ( ) const
inlineoverridevirtual

Returns true if this lvalue is actually writable–temporaries and uniforms are not.

Implements SkSL::RP::LValue.

Definition at line 1035 of file SkSLRasterPipelineCodeGenerator.cpp.

1035 {
1036 return fParent->isWritable();
1037 }

◆ push()

bool SkSL::RP::DynamicIndexLValue::push ( Generator gen,
SlotRange  fixedOffset,
AutoStack dynamicOffset,
SkSpan< const int8_t >  swizzle 
)
inlineoverridevirtual

Pushes values directly onto the stack.

Implements SkSL::RP::LValue.

Definition at line 1088 of file SkSLRasterPipelineCodeGenerator.cpp.

1091 {
1092 return fParent->push(gen, fixedOffset, dynamicOffset, swizzle);
1093 }
virtual SkSpan< const int8_t > swizzle()

◆ store()

bool SkSL::RP::DynamicIndexLValue::store ( Generator gen,
SlotRange  fixedOffset,
AutoStack dynamicOffset,
SkSpan< const int8_t >  swizzle 
)
inlineoverridevirtual

Stores topmost values from the stack directly into the lvalue.

Implements SkSL::RP::LValue.

Definition at line 1095 of file SkSLRasterPipelineCodeGenerator.cpp.

1098 {
1099 return fParent->store(gen, fixedOffset, dynamicOffset, swizzle);
1100 }

The documentation for this class was generated from the following file: