示例#1
0
        /// <summary>
        /// Gets or sets at index.
        /// </summary>
        public T this[[NotNull] UIntegerx1 index]
        {
            get
            {
                if (index.Generator != this.Generator)
                {
                    throw new ArgumentException("Different generators combined.");
                }

                IndexInArrayOperation op = new IndexInArrayOperation();
                op.BindInputs(this.pin, index.Pin);
                return((T)Generator.CreateFrom(op.Outputs[0]));
            }
            set
            {
                if (index.Generator != this.Generator)
                {
                    throw new ArgumentException("Different generators combined.");
                }

                WriteToIndexInArrayOperation op = new WriteToIndexInArrayOperation();
                op.BindInputs(this.pin, index.Pin, value.Pin);

                // New array is created, we copy to our pin.
                this.pin = op.Outputs[0];
            }
        }
示例#2
0
        public ShaderCode Arrays()
        {
            CodeGenerator      generator = new CodeGenerator(BindingStage.VertexShader);
            UIntegerx1         i         = generator.InputUInteger1(PinComponent.TexCoord0);
            PinArray <Floatx1> arr       = generator.CreateFloatx1Array("MyArray", 10);

            arr[i] = arr[(int)2] * 2.0f + arr[(uint)0] * -4.0f;

            return(generator.ShaderCode);
        }
示例#3
0
        /// <summary>
        /// We create the loop.
        /// </summary>
        /// <param name="data"></param>
        internal Loop(UIntegerx1 n, params PinBinder[] data)
        {
            Pin[] input = new Pin[data.Length + 1];
            input[0] = n.Pin;
            for (int i = 1; i < data.Length; i++)
            {
                input[i] = data[i - 1].Pin;
            }

            // We bind inputs.
            operation.InputOperation.BindInputs(input);

            // We create binders for output.
            Pin[] outputs = operation.InputOperation.Outputs;
            binders = new PinBinder[outputs.Length];
            for (int i = 0; i < outputs.Length; i++)
            {
                binders[i] = n.Generator.CreateFrom(outputs[i]);
            }
        }
示例#4
0
        public ShaderCode Loops()
        {
            CodeGenerator generator = new CodeGenerator(BindingStage.VertexShader);

            UIntegerx1 n = generator.Fixed((uint)10);
            UIntegerx1 c = generator.Fixed((uint)1);

            // We begin loop.
            Loop <UIntegerx1> loop = generator.BeginLoop(n, c);

            {
                // Loop data must be used.
                loop.Value += loop.IterationIndex;
            }
            // End loop.
            generator.EndLoop(loop);

            // We can move the reference back.
            c = loop.Value;

            generator.Output(PinComponent.Position, c);

            return(generator.ShaderCode);
        }
示例#5
0
 /// <summary>
 /// Begins loop.
 /// </summary>
 /// <param name="count"></param>
 /// <param name="values"></param>
 /// <returns></returns>
 public Loop BeginLoop(UIntegerx1 count, params PinBinder[] values)
 {
     return(new Loop(count, values));
 }
示例#6
0
 /// <summary>
 /// Begins loop.
 /// </summary>
 public Loop <T, T2> BeginLoop <T, T2>(UIntegerx1 count, T value, T2 value2)
     where T : PinBinder
     where T2 : PinBinder
 {
     return(new Loop <T, T2>(count, value, value2));
 }
示例#7
0
 /// <summary>
 /// Begins loop.
 /// </summary>
 public Loop <T> BeginLoop <T>(UIntegerx1 count, T value)
     where T : PinBinder
 {
     return(new Loop <T>(count, value));
 }