Beispiel #1
0
        private ArgumentResult Compute(FLInstructionArgument arg)
        {
            ArgumentResult ret = new ArgumentResult();

            ret.Type = arg.Type;
            switch (arg.Type)
            {
            case FLInstructionArgumentType.Number:
                ret.Value = arg.GetValue();
                break;

            case FLInstructionArgumentType.Name:
                ret.Value = Parent.Variables.GetVariable(arg.GetValue().ToString());
                ret.Type  = FLInstructionArgumentType.Number;    //Translate the Variable to a Number
                break;

            case FLInstructionArgumentType.Buffer:
                ret.Value = arg.GetValue();
                break;

            case FLInstructionArgumentType.Function:
                ret.Value = ComputeFunction(arg);
                break;

            default:
                throw new InvalidOperationException("Can not parse: " + arg.GetValue());
            }

            return(ret);
        }
        public override void Process()
        {
            FLInstructionArgument left = Arguments[0];
            FLInstructionArgument right = Arguments[1];
            decimal l = 0, r = 0;

            if (left.Type == FLInstructionArgumentType.Number)
            {
                l = (decimal)left.Value;
            }
            else if (left.Type == FLInstructionArgumentType.Name && Parent.Variables.IsDefined(left.Value.ToString()))
            {
                l = Parent.Variables.GetVariable(left.Value.ToString());
            }
            if (right.Type == FLInstructionArgumentType.Number)
            {
                r = (decimal)right.Value;
            }
            else if (right.Type == FLInstructionArgumentType.Name && Parent.Variables.IsDefined(right.Value.ToString()))
            {
                r = Parent.Variables.GetVariable(right.Value.ToString());
            }

            if (l < r)
            {
                base.Process();
            }
        }
Beispiel #3
0
        public override void Process()
        {
            if (Arguments.Count == 0)
            {
                Logger.Log(LogType.Log, $"Writing Random Data to Active Buffer:" + Root.ActiveBuffer.DefinedBufferName,
                           MIN_INSTRUCTION_SEVERITY);
                CLAPI.WriteRandom(Root.Instance, Root.ActiveBuffer.Buffer, RandomInstructionHelper.Randombytesource,
                                  Root.ActiveChannels, false);
            }

            for (int i = 0; i < Arguments.Count; i++)
            {
                FLInstructionArgument obj = Arguments[i];

                if (obj.Type != FLInstructionArgumentType.Buffer)
                {
                    throw
                        new FLInvalidArgumentType("Argument: " + obj.Value, "MemoyBuffer/Image");
                }

                FLBuffer func = (FLBuffer)obj.Value;

                Logger.Log(LogType.Log, $"Writing Random Data to Active Buffer:" + func.DefinedBufferName,
                           MIN_INSTRUCTION_SEVERITY);

                CLAPI.WriteRandom(Root.Instance, func.Buffer, RandomInstructionHelper.Randombytesource,
                                  Root.ActiveChannels, false);
            }
        }
Beispiel #4
0
        private FLBuffer ComputeFunction(FLInstructionArgument arg)
        {
            FLFunction flFunction = (FLFunction)arg.Value; //Process the Function Object

            FLBuffer buffer =
                Root.RegisterUnmanagedBuffer(new FLBuffer(Root.Instance, Root.Dimensions.x,
                                                          Root.Dimensions.y, $"{flFunction.Name}_InputBuffer"));

            Logger.Log(LogType.Log, $"Storing Current Execution Context", MIN_INSTRUCTION_SEVERITY + 3);
            Root.PushContext(); //Store Dynamic Variables

            Logger.Log(LogType.Log, $"Executing Function: {flFunction.Name}", MIN_INSTRUCTION_SEVERITY + 2);

            Root.ActiveBuffer = buffer;
            flFunction.Process();

            Logger.Log(LogType.Log, $"[{Kernel.Name}]Argument Buffer{Root.ActiveBuffer.DefinedBufferName}",
                       MIN_INSTRUCTION_SEVERITY + 2);

            FLBuffer ret = Root.ActiveBuffer;

            //Kernel.SetBuffer(kernelArgIndex,
            //    Root.ActiveBuffer.Buffer); //Set the Active Buffer as the Kernel Argument

            Logger.Log(LogType.Log, $"Returning from Function Context", MIN_INSTRUCTION_SEVERITY + 3);
            Root.ReturnFromContext(); //Restore active channels and buffer
            return(ret);
        }
        public override FLInstruction Create(FLProgram script, SerializableFLInstruction instruction)
        {
            List <FLInstructionArgument> args = new List <FLInstructionArgument>();

            for (int i = 0; i < instruction.Arguments.Count; i++)
            {
                FLInstructionArgument arg = new FLInstructionArgument(instruction.Arguments[i].GetValue(script));
                args.Add(arg);
            }

            return((FLInstruction)Activator.CreateInstance(type, new object[] { args }));
        }
Beispiel #6
0
        public override FLInstruction Create(FLProgram script, FLFunction func, SerializableFLInstruction instruction)
        {
            List <FLInstructionArgument> args = new List <FLInstructionArgument>();

            for (int i = 0; i < instruction.Arguments.Count; i++)
            {
                FLInstructionArgument arg = new FLInstructionArgument(instruction.Arguments[i].GetValue(script, func));
                args.Add(arg);
            }

            return(new GPUArrangeFLInstruction(args, ArrangeKernel));
        }
Beispiel #7
0
        private FLBuffer ComputeFunction(FLInstructionArgument arg)
        {
            IFunction flFunction = (IFunction)arg.GetValue();  //Process the Function Object

            FLBuffer buffer =
                Root.RegisterUnmanagedBuffer(
                    new FLBuffer(
                        Root.Instance,
                        Root.Dimensions.x,
                        Root.Dimensions.y,
                        Root.Dimensions.z,
                        $"{flFunction.Name}_InputBuffer",
                        MemoryFlag.ReadWrite,
                        flFunction.Modifiers.GetModifiers()
                        .Contains(FLKeywords.OptimizeBufferCreationKeyword)
                        )
                    );

            Logger.Log(LogType.Log, "Storing Current Execution Context", MIN_INSTRUCTION_SEVERITY + 3);
            Root.PushContext(); //Store Dynamic Variables

            Logger.Log(LogType.Log, $"Executing Function: {flFunction.Name}", MIN_INSTRUCTION_SEVERITY + 2);

            Root.ActiveBuffer = buffer;
            flFunction.Process();

            Logger.Log(
                LogType.Log,
                $"[{Kernel.Name}]Argument Buffer{Root.ActiveBuffer.DefinedBufferName}",
                MIN_INSTRUCTION_SEVERITY + 2
                );

            FLBuffer ret = Root.ActiveBuffer;

            Logger.Log(LogType.Log, "Returning from Function Context", MIN_INSTRUCTION_SEVERITY + 3);
            Root.ReturnFromContext(); //Restore active channels and buffer
            return(ret);
        }