public ShaderOp CreateOp(ShaderBlock block, OpInstructionType opType, ShaderType resultType, List <IShaderIR> arguments) { var resultOp = CreateOp(opType, resultType, arguments); block.mOps.Add(resultOp); return(resultOp); }
public ShaderOp CreateOp(OpInstructionType opType, ShaderType resultType, List <IShaderIR> arguments) { var resultOp = new ShaderOp(); InitializeOp(resultOp, opType, resultType, arguments); return(resultOp); }
public ShaderOp SimpleCompareCast(ShaderType resultType, OpInstructionType instructionType, IShaderIR expressionOp, IShaderIR constantOp, FrontEndContext context) { var castOp = CreateOp(context.mCurrentBlock, instructionType, resultType, new List <IShaderIR> { expressionOp, constantOp }); context.Push(castOp); return(castOp); }
public void InitializeOp(ShaderOp op, OpInstructionType opType, ShaderType resultType, List <IShaderIR> arguments) { op.mOpType = opType; op.mResultType = resultType; if (arguments != null) { op.mParameters.AddRange(arguments); } }
public ShaderOp CreateOp(ShaderBlock block, OpInstructionType opType, ShaderType resultType, List <IShaderIR> arguments) { return(mFrontEnd.CreateOp(block, opType, resultType, arguments)); }
/// <summary> /// Does a simple intrinsic (one where all ops are value types). /// </summary> static void SimpleValueTypeIntrinsic(FrontEndTranslator translator, FrontEndContext context, OpInstructionType opType, ShaderType returnType, List <IShaderIR> arguments) { var valueOps = new List <IShaderIR>(); foreach (var argument in arguments) { valueOps.Add(translator.GetOrGenerateValueTypeFromIR(context.mCurrentBlock, argument)); } var op = translator.CreateOp(context.mCurrentBlock, opType, returnType, valueOps); context.Push(op); }
/// <summary> /// Creates a simple intrinsic function (one whos ops are just value types of the args one-for-one) callback for the given symbol information. /// </summary> static public void CreateSimpleIntrinsicFunction(FrontEndTranslator translator, FunctionKey functionKey, OpInstructionType opType, ShaderType returnType) { ShaderLibrary.InstrinsicDelegate callback = (FrontEndTranslator translator, List <IShaderIR> arguments, FrontEndContext context) => { SimpleValueTypeIntrinsic(translator, context, opType, returnType, arguments); }; translator.mCurrentLibrary.CreateIntrinsicFunction(functionKey, callback); }
void IncDecOp(FrontEndTranslator translator, ShaderType resultType, string opToken, ShaderType operandType, OpInstructionType instructionType) { CreateUnaryOpIntrinsic(new UnaryOpKey(opToken, operandType), (IShaderIR operandIR, FrontEndContext context) => { var operandValueOp = translator.GetOrGenerateValueTypeFromIR(context.mCurrentBlock, operandIR); IShaderIR oneConstantOp = null; if (resultType.mBaseType == OpType.Int) { oneConstantOp = translator.CreateConstantOp(operandType, 1); } else if (resultType.mBaseType == OpType.Float) { oneConstantOp = translator.CreateConstantOp(operandType, 1.0f); } return(translator.CreateOp(context.mCurrentBlock, instructionType, resultType, new List <IShaderIR> { operandValueOp, oneConstantOp })); }); }
void LogicOrAndOp(FrontEndTranslator translator, ShaderType resultType, ShaderType lhsType, string opToken, ShaderType rhsType, OpInstructionType instructionType, bool isOr) { CreateComplexBinaryOpIntrinsic(new BinaryOpKey(lhsType, opToken, rhsType), (SyntaxNode lhsExpression, SyntaxNode rhsExpression, FrontEndContext context) => { LogicalOrAnd(lhsExpression, rhsExpression, context, isOr); return(context.Pop() as ShaderOp); }); }
void AddSimpleValueTypeBinaryOp(FrontEndTranslator translator, ShaderType resultType, ShaderType lhsType, string opToken, ShaderType rhsType, OpInstructionType instructionType) { CreateBinaryOpIntrinsic(new BinaryOpKey(lhsType, opToken, rhsType), (IShaderIR lhsExpression, IShaderIR rhsExpression, FrontEndContext context) => { var lhsValueOp = translator.GetOrGenerateValueTypeFromIR(context.mCurrentBlock, lhsExpression); var rhsValueOp = translator.GetOrGenerateValueTypeFromIR(context.mCurrentBlock, rhsExpression); return(translator.CreateOp(context.mCurrentBlock, instructionType, resultType, new List <IShaderIR> { lhsValueOp, rhsValueOp })); }); }
void AddSimpleValueTypeUnaryOp(FrontEndTranslator translator, ShaderType resultType, string opToken, ShaderType operandType, OpInstructionType instructionType) { CreateUnaryOpIntrinsic(new UnaryOpKey(opToken, operandType), (IShaderIR operandIR, FrontEndContext context) => { var operandValueOp = translator.GetOrGenerateValueTypeFromIR(context.mCurrentBlock, operandIR); return(translator.CreateOp(context.mCurrentBlock, instructionType, resultType, new List <IShaderIR> { operandValueOp })); }); }