virtual bool Process()override { FNiagaraCompiler_VectorVM* VMCompiler = (FNiagaraCompiler_VectorVM*)Compiler; check(ResultLocation == ENiagaraExpressionResultLocation::SharedData); FNiagaraDataSetProperties* DataSetProps = VMCompiler->GetSharedDataIndex(Event, false, ResultIndex); int32 VarIndex = VMCompiler->GetSharedDataVariableIndex(DataSetProps, Result); FNiagaraExpression* IndexExpr = GetSourceExpression(0).Get(); FNiagaraExpression* DataExpr = GetSourceExpression(1).Get(); check(SourceExpressions.Num() == 2); uint8 IndexIndex = VMCompiler->GetResultVMIndex(IndexExpr); uint8 DataIndex = VMCompiler->GetResultVMIndex(DataExpr); //TODO - Make this better, either ensure this is in a register by now or allow the VM to handle from constants? //Though, why you'd have the conditional come from a constant, IDK. if (!(DataExpr->ResultLocation == ENiagaraExpressionResultLocation::Temporaries || DataExpr->ResultLocation == ENiagaraExpressionResultLocation::InputData)) { VMCompiler->Error(LOCTEXT("CompileFaliure_CannotWriteConstantToSharedData", "Writing of constants to shared data is not currently supported"), NULL, NULL); return false; } check(IndexExpr->ResultLocation == ENiagaraExpressionResultLocation::Temporaries); VMCompiler->WriteCode((uint8)EVectorVMOp::shareddatawrite); VMCompiler->WriteCode(ResultIndex);//Set idx VMCompiler->WriteCode(VarIndex);//Index of variable buffer in the set. VMCompiler->WriteCode(IndexIndex);//Index of the temporary buffer that contains the data index. VMCompiler->WriteCode(DataIndex);//Temp buffer index for the data to write. return true; }
virtual void Process()override { check(ResultLocation == ENiagaraExpressionResultLocation::Constants); //Get the index of the constant. Also gets a component index if this is for a packed scalar constant. Compiler->GetConstantResultIndex(Result, bInternal, ResultIndex, ComponentIndex); if (Result.Type == ENiagaraDataType::Matrix) { check(SourceExpressions.Num() == 4); TNiagaraExprPtr Src0 = GetSourceExpression(0); TNiagaraExprPtr Src1 = GetSourceExpression(1); TNiagaraExprPtr Src2 = GetSourceExpression(2); TNiagaraExprPtr Src3 = GetSourceExpression(3); Src0->ResultLocation = ENiagaraExpressionResultLocation::Constants; Src0->ResultIndex = ResultIndex; Src1->ResultLocation = ENiagaraExpressionResultLocation::Constants; Src1->ResultIndex = ResultIndex + 1; Src2->ResultLocation = ENiagaraExpressionResultLocation::Constants; Src2->ResultIndex = ResultIndex + 2; Src3->ResultLocation = ENiagaraExpressionResultLocation::Constants; Src3->ResultIndex = ResultIndex + 3; } else if (Result.Type == ENiagaraDataType::Curve) { ResultLocation = ENiagaraExpressionResultLocation::BufferConstants; } }
virtual void Process()override { FNiagaraCompiler_VectorVM* VMCompiler = (FNiagaraCompiler_VectorVM*)Compiler; //Should be invalid at this point. check(ResultIndex == INDEX_NONE); check(ComponentIndex == INDEX_NONE); //Special case where we're splatting but we don't know the component until now. E.g. Getting constants. //Choose the component now based on the source expressions component index if (OpCode == VectorVM::EOp::splatx) { check(SourceExpressions.Num() == 1); TNiagaraExprPtr Src0 = GetSourceExpression(0); if (Src0->ComponentIndex != INDEX_NONE) { switch (Src0->ComponentIndex) { case 0: OpCode = VectorVM::EOp::splatx; break; case 1: OpCode = VectorVM::EOp::splaty; break; case 2: OpCode = VectorVM::EOp::splatz; break; case 3: OpCode = VectorVM::EOp::splatw; break; } } } ResultIndex = VMCompiler->AquireTemporary(); ResultLocation = ENiagaraExpressionResultLocation::Temporaries; check(ResultIndex < VectorVM::NumTempRegisters); VMCompiler->WriteCode((uint8)OpCode); VMCompiler->WriteCode(VMCompiler->GetResultVMIndex( this )); //Add the bitfield defining whether each source operand comes from a constant or a register. int32 NumOperands = SourceExpressions.Num(); check(NumOperands <= 4); uint8 OpTypeMask = VectorVM::CreateSrcOperandMask(NumOperands > 0 ? VMCompiler->GetVMOperandType(GetSourceExpression(0).Get()) : VectorVM::RegisterOperandType, NumOperands > 1 ? VMCompiler->GetVMOperandType(GetSourceExpression(1).Get()) : VectorVM::RegisterOperandType, NumOperands > 2 ? VMCompiler->GetVMOperandType(GetSourceExpression(2).Get()) : VectorVM::RegisterOperandType, NumOperands > 3 ? VMCompiler->GetVMOperandType(GetSourceExpression(3).Get()) : VectorVM::RegisterOperandType); VMCompiler->WriteCode(OpTypeMask); //Add the locations for each of the source operands. for (int32 SrcIdx = 0; SrcIdx < SourceExpressions.Num(); ++SrcIdx) { VMCompiler->WriteCode(VMCompiler->GetResultVMIndex(GetSourceExpression(SrcIdx).Get())); } }
virtual bool Process()override { FNiagaraCompiler_VectorVM* VMCompiler = (FNiagaraCompiler_VectorVM*)Compiler; check(ResultLocation == ENiagaraExpressionResultLocation::Temporaries); ResultIndex = VMCompiler->AquireTemporary(); if (ResultIndex == INDEX_NONE) { return false; } FNiagaraExpression* ValidExpr = GetSourceExpression(0).Get(); check(SourceExpressions.Num() == 1); uint8 ValidIndex = VMCompiler->GetResultVMIndex(ValidExpr); int32 SharedDataSetIndex; VMCompiler->GetSharedDataIndex(DataSet, false, SharedDataSetIndex); check(SharedDataSetIndex <= 255) //TODO - Make this better, either ensure this is in a register by now or allow the VM to handle from constants? //Though, why you'd have the conditional come from a constant, IDK. if (!(ValidExpr->ResultLocation == ENiagaraExpressionResultLocation::Temporaries || ValidExpr->ResultLocation == ENiagaraExpressionResultLocation::InputData)) { VMCompiler->Error(LOCTEXT("CompileFaliure_CannotUseConstantForSharedDataValidMask", "Use of constants for the shared data valid mask is not supported currently."), NULL, NULL); return false; } VMCompiler->WriteCode(bWrap ? (uint8)EVectorVMOp::aquireshareddataindexwrap : (uint8)EVectorVMOp::aquireshareddataindex); VMCompiler->WriteCode(ResultIndex); VMCompiler->WriteCode(ValidIndex); VMCompiler->WriteCode((uint8)SharedDataSetIndex); return true; }
virtual bool Process()override { FNiagaraCompiler_VectorVM* VMCompiler = (FNiagaraCompiler_VectorVM*)Compiler; ResultIndex = VMCompiler->AquireTemporary(); if (ResultIndex == INDEX_NONE) { return false; } ResultLocation = ENiagaraExpressionResultLocation::Temporaries; check(ResultIndex < VectorVM::NumTempRegisters); uint8 DestIndex = VMCompiler->GetResultVMIndex(this); int32 SetIndex; FNiagaraDataSetProperties* SetProps = VMCompiler->GetSharedDataIndex(Event, true, SetIndex); check(SetIndex <= 255); uint8 VarIndex = VMCompiler->GetSharedDataVariableIndex(SetProps, Result); check(SourceExpressions.Num() == 1); FNiagaraExpression* IndexExpr = GetSourceExpression(0).Get(); uint8 IndexIndex = VMCompiler->GetResultVMIndex(IndexExpr); VMCompiler->WriteCode((uint8)EVectorVMOp::shareddataread); VMCompiler->WriteCode(DestIndex);//Result location VMCompiler->WriteCode((int8)SetIndex);//Index of data set VMCompiler->WriteCode(VarIndex);//Index of variable within data set view VMCompiler->WriteCode(IndexIndex);//Index of data in variable buffer return true; }
virtual bool Process()override { FNiagaraCompiler_VectorVM* VMCompiler = (FNiagaraCompiler_VectorVM*)Compiler; //Should be invalid at this point. check(ResultIndex == INDEX_NONE); ResultIndex = VMCompiler->AquireTemporary(); if (ResultIndex == INDEX_NONE) { return false; } ResultLocation = ENiagaraExpressionResultLocation::Temporaries; check(ResultIndex < VectorVM::NumTempRegisters); VMCompiler->WriteCode((uint8)OpCode); //Add the bitfield defining whether each source operand comes from a constant or a register. int32 NumOperands = SourceExpressions.Num(); check(NumOperands <= 4); uint8 OpTypeMask = VectorVM::CreateSrcOperandMask(NumOperands > 0 ? VMCompiler->GetVMOperandType(GetSourceExpression(0).Get()) : EVectorVMOperandLocation::TemporaryRegister, NumOperands > 1 ? VMCompiler->GetVMOperandType(GetSourceExpression(1).Get()) : EVectorVMOperandLocation::TemporaryRegister, NumOperands > 2 ? VMCompiler->GetVMOperandType(GetSourceExpression(2).Get()) : EVectorVMOperandLocation::TemporaryRegister, NumOperands > 3 ? VMCompiler->GetVMOperandType(GetSourceExpression(3).Get()) : EVectorVMOperandLocation::TemporaryRegister); VMCompiler->WriteCode(OpTypeMask); //Write dest VMCompiler->WriteCode(VMCompiler->GetResultVMIndex(this)); //Add the locations for each of the source operands. for (int32 SrcIdx = 0; SrcIdx < SourceExpressions.Num(); ++SrcIdx) { VMCompiler->WriteCode(VMCompiler->GetResultVMIndex(GetSourceExpression(SrcIdx).Get())); } return true; }
virtual void Process()override { FNiagaraCompiler_VectorVM* VMCompiler = (FNiagaraCompiler_VectorVM*)Compiler; check(ResultLocation == ENiagaraExpressionResultLocation::OutputData); ResultIndex = VMCompiler->GetAttributeIndex(Result); FNiagaraExpression* SrcExpr = GetSourceExpression(0).Get(); check(SourceExpressions.Num() == 1); uint8 DestIndex = VMCompiler->GetResultVMIndex(this); uint8 SrcIndex = VMCompiler->GetResultVMIndex(SrcExpr); VMCompiler->WriteCode((uint8)VectorVM::EOp::output); VMCompiler->WriteCode(DestIndex); VMCompiler->WriteCode(VectorVM::CreateSrcOperandMask( VMCompiler->GetVMOperandType(SrcExpr) ) ); VMCompiler->WriteCode(SrcIndex); }