public void CheckChangeTensorLayout2D() { var strg2DCpy = (ArrayStorage)strg2D.Clone(); Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.Shape.Dimensions, new int[] { 3, 3 })); Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), new long[] { 0, 3, 6, 1, 4, 7, 2, 5, 8 })); Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.Shape.Dimensions, new int[] { 3, 3 })); Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), strg2D.GetData <long>())); strg2DCpy = (ArrayStorage)strg2DNonFull.Clone(); Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.Shape.Dimensions, new int[] { 5, 2 })); Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), new long[] { 0, 5, 1, 6, 2, 7, 3, 8, 4, 9 })); Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.Shape.Dimensions, new int[] { 5, 2 })); Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), strg2DNonFull.GetData <long>())); strg2DCpy = new ArrayStorage(typeof(long)); strg2DCpy.Allocate(new Shape(5, 2)); strg2DCpy.SetData(strg2DNonFull.GetData()); Assert.IsTrue(Enumerable.SequenceEqual(strg2DCpy.GetData <long>(), new long[] { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 })); }
protected override void OnAttach(IRenderTechnique technique) { lock (lck) { if (bufferDesc != null) { modelConstBuffer = technique.ConstantBufferPool.Register(bufferDesc); storage = technique.EffectsManager.StructArrayPool.Register(bufferDesc.StructSize); storageId = storage.GetId(); } IsValid = bufferDesc != null && ModelConstBuffer != null; } }
public StorageTester() { strg1D = new ArrayStorage(np.float64); strg1D.Allocate(new Shape(10)); strg1D.SetData(new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); strg2D = new ArrayStorage(np.int64); strg2D.Allocate(new Shape(3, 3)); strg2D.SetData(new long[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }); strg2DNonFull = new ArrayStorage(np.float32); strg2DNonFull.Allocate(new Shape(5, 2)); strg2DNonFull.SetData(new float[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); }
/// <summary> /// Initializes a new instance of the <see cref="MaterialVariable"/> class. /// </summary> /// <param name="manager">The manager.</param> /// <param name="technique">The technique.</param> /// <param name="meshMaterialConstantBufferDesc">The Constant Buffer description</param> /// <param name="materialCore"></param> public MaterialVariable(IEffectsManager manager, IRenderTechnique technique, ConstantBufferDescription meshMaterialConstantBufferDesc, MaterialCore materialCore) { Technique = technique; EffectsManager = manager; if (materialCore != null) { material = materialCore; material.PropertyChanged += MaterialCore_PropertyChanged; } materialCBDescription = meshMaterialConstantBufferDesc; if (manager != null) { storage = manager.StructArrayPool.Register(materialCBDescription.StructSize); storageId = storage.GetId(); } }