Improved test for padding in constant buffer

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-18 10:49:18 +02:00
1 親 2cecf85bfa
コミット 9c430de6d7
1ファイル変更
+4 -2
+4 -2
ファイルの表示
@@ -14,7 +14,7 @@ namespace ComputeSharp.Tests.Internals
[TestMethod]
public void ConstantBufferGetSetFromGenericValues()
{
object[] values = { 7, 3.14, Vector2.UnitX, 3.14f };
object[] values = { 7, 3.14, Vector2.UnitX, 3.14f, new Vector4(7.14f, 7.15f, 7.77f, 2.55f) };
using ConstantBuffer<Vector4> buffer = (ConstantBuffer<Vector4>)Gpu.Default.AllocateConstantBufferFromReflectedValues(values);
Vector4[] data = buffer.GetData();
@@ -23,12 +23,14 @@ namespace ComputeSharp.Tests.Internals
int i = Unsafe.As<byte, int>(ref Unsafe.Add(ref r0, 0)); // 0 -> 3, sizeof(int) == 4
double d = Unsafe.As<byte, double>(ref Unsafe.Add(ref r0, 4)); // 4 -> 11, sizeof(double) == 8
Vector2 v2 = Unsafe.As<byte, Vector2>(ref Unsafe.Add(ref r0, 16)); // 16 -> 23, sizeof(Vector2) == 8
float f = Unsafe.As<byte, float>(ref Unsafe.Add(ref r0, 024)); // 24 -> 27, sizeof(float) == 4
float f = Unsafe.As<byte, float>(ref Unsafe.Add(ref r0, 24)); // 24 -> 27, sizeof(float) == 4
Vector4 v4 = Unsafe.As<byte, Vector4>(ref Unsafe.Add(ref r0, 32)); // 32 -> 47, sizeof(Vector4) == 16
Assert.IsTrue((int)values[0] == i);
Assert.IsTrue(Math.Abs((double)values[1] - d) < 0.0001);
Assert.IsTrue((Vector2)values[2] == v2);
Assert.IsTrue(MathF.Abs((float)values[3] - f) < 0.0001);
Assert.IsTrue((Vector4)values[4] == v4);
}
}
}