Beispiel #1
0
        public ShaderOp CreateOp(ShaderBlock block, OpInstructionType opType, ShaderType resultType, List <IShaderIR> arguments)
        {
            var resultOp = CreateOp(opType, resultType, arguments);

            block.mOps.Add(resultOp);
            return(resultOp);
        }
Beispiel #2
0
        public ShaderOp CreateOp(OpInstructionType opType, ShaderType resultType, List <IShaderIR> arguments)
        {
            var resultOp = new ShaderOp();

            InitializeOp(resultOp, opType, resultType, arguments);
            return(resultOp);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 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);
     }
 }
Beispiel #5
0
 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);
 }
Beispiel #8
0
 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
         }));
     });
 }
Beispiel #9
0
 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);
     });
 }
Beispiel #10
0
 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
         }));
     });
 }
Beispiel #11
0
 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
         }));
     });
 }