/// <summary> /// Gets or sets at index. /// </summary> /// <param name="index"></param> /// <returns></returns> public T this[Integerx1 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]; } }
/// <summary> /// Loads at specific address with mipmap and offset. /// </summary> public T Load([NotNull] Integerx1 position, Integerx1 offset) { if (position.Generator != this.Generator || ((object)offset != null && offset.Generator != this.Generator)) { throw new ArgumentException("Mixing generators not allowed."); } LoadOperation op = new LoadOperation(); if ((object)offset != null) { op.BindInputs(pin, position.Pin, offset.Pin); } else { op.BindInputs(pin, position.Pin); } return((T)this.Generator.CreateFrom(op.Outputs[0])); }
/// <summary> /// Sample at specific address. /// </summary> public T Sample([NotNull] SamplerBinder sampler, [NotNull] Floatx1 address, Integerx1 offset) { if (address.Generator != this.Generator || ((object)offset != null && offset.Generator != this.Generator) || sampler.Generator != this.Generator) { throw new ArgumentException("Mixing generators not allowed."); } SampleOperation op = new SampleOperation(); if ((object)offset != null) { op.BindInputs(sampler.Pin, pin, address.Pin, offset.Pin); } else { op.BindInputs(sampler.Pin, pin, address.Pin); } return((T)this.Generator.CreateFrom(op.Outputs[0])); }
/// <summary> /// Loads at specific address with mipmap. /// </summary> public T Load([NotNull] Integerx1 position) { return(Load(position, null)); }
/// <summary> /// Loads at specific address at mipmap 0. /// </summary> public T Load([NotNull] Integerx1 position) { Integerx2 addr = position.Generator.Expand <Integerx2>(position, ExpandType.AddZeros); return(Load(addr)); }