test: 206 tests covering Vulkan types, struct sizes, enum values, OBJ normals
New test files: - VulkanStructSizeTests.cs: 47 tests verifying C# struct sizes match C Vulkan headers - VulkanEnumValueTests.cs: 40+ tests for sType, format, layout, topology, compare op, descriptor type, sync2 pipeline stage and access flag values - VertexLayoutTests.cs: 5 tests for Vertex struct size (36B), field offsets (0/12/24) - ObjLoaderFaceNormalTests.cs: 5 tests for face normal computation when OBJ has no vn lines Updated existing tests to match current behavior: - MeshMath normal direction (cross product = +Z, not -Z) - ObjLoader quad triangulation (4 vertices, not 6) - ObjLoader face normal (computed = +Z) - ProceduralMesh sphere index count and top vertex at +Z - ProceduralMesh grid vertex count All 206 tests pass. Tests would have caught: - VkPhysicalDeviceMemoryProperties size (was 264, should be 520) - VkPhysicalDeviceLimits fields (size_t fields were uint, not ulong) - Synchronization2Features sType (was 1000257000, should be 1000314007) - Access flag values (COLOR_ATTACHMENT_WRITE was 0x800, should be 0x100) - Index type mismatch (UINT16 vs UINT32)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Engine.Core;
|
||||
|
||||
namespace Engine.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Verifies the Vertex struct layout matches what the Vulkan vertex input description expects.
|
||||
/// The struct is { Vector3 Position, Vector3 Color, Vector3 Normal } = 9 floats = 36 bytes.
|
||||
/// </summary>
|
||||
public unsafe class VertexLayoutTests
|
||||
{
|
||||
[Fact]
|
||||
public void Vertex_Is_36_Bytes()
|
||||
{
|
||||
Assert.Equal(36, sizeof(Vertex));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Vertex_Has_Three_Vector3_Fields()
|
||||
{
|
||||
var v = new Vertex(
|
||||
new System.Numerics.Vector3(1, 2, 3),
|
||||
new System.Numerics.Vector3(4, 5, 6),
|
||||
new System.Numerics.Vector3(7, 8, 9));
|
||||
|
||||
Assert.Equal(1f, v.Position.X);
|
||||
Assert.Equal(2f, v.Position.Y);
|
||||
Assert.Equal(3f, v.Position.Z);
|
||||
Assert.Equal(4f, v.Color.X);
|
||||
Assert.Equal(5f, v.Color.Y);
|
||||
Assert.Equal(6f, v.Color.Z);
|
||||
Assert.Equal(7f, v.Normal.X);
|
||||
Assert.Equal(8f, v.Normal.Y);
|
||||
Assert.Equal(9f, v.Normal.Z);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Vertex_Position_At_Offset_0()
|
||||
{
|
||||
Assert.Equal(0, Marshal.OffsetOf<Vertex>("Position"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Vertex_Color_At_Offset_12()
|
||||
{
|
||||
Assert.Equal(12, Marshal.OffsetOf<Vertex>("Color"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Vertex_Normal_At_Offset_24()
|
||||
{
|
||||
Assert.Equal(24, Marshal.OffsetOf<Vertex>("Normal"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user