amerkoleci / Vortice.Vulkan

Cross platform .NET bindings for Vulkan, VMA, SPIRV-Cross and shaderc
MIT License
298 stars 26 forks source link

VkAccelerationStructureMatrixMotionInstanceNV is a bit-field structure #28

Closed CLOWREAD closed 3 years ago

CLOWREAD commented 3 years ago

auto size_cpp = sizeof(VkAccelerationStructureMatrixMotionInstanceNV); size_cpp == 112

var vortice_s = sizeof(Vortice.Vulkan.VkAccelerationStructureMatrixMotionInstanceNV); vortice_s == 120

typedef struct VkAccelerationStructureMatrixMotionInstanceNV {
    VkTransformMatrixKHR          transformT0;
    VkTransformMatrixKHR          transformT1;
    uint32_t                      instanceCustomIndex:24;
    uint32_t                      mask:8;
    uint32_t                      instanceShaderBindingTableRecordOffset:24;
    VkGeometryInstanceFlagsKHR    flags:8;
    uint64_t                      accelerationStructureReference;
} 

The struct might be handled manually

// Handled manually.
if (cppClass.Name == "VkClearColorValue"
    || cppClass.Name == "VkTransformMatrixKHR"
    || cppClass.Name == "VkAccelerationStructureInstanceKHR"
    )
{
    continue;
}

The struct "VkAccelerationStructureSRTMotionInstanceNV" has similar problem;

CLOWREAD commented 3 years ago
[StructLayout(LayoutKind.Explicit)]
public partial struct VkAccelerationStructureSRTMotionInstanceNV
{
    [FieldOffset(0)]
    public VkSRTDataNV transformT0;
    [FieldOffset(64)]
    public VkSRTDataNV transformT1;
    [FieldOffset(128)]
    public uint instanceCustomIndex;
    [FieldOffset(131)]
    public uint mask;
    [FieldOffset(132)]
    public uint instanceShaderBindingTableRecordOffset;
    [FieldOffset(135)]
    public VkGeometryInstanceFlagsKHR flags;
    [FieldOffset(136)]
    public ulong accelerationStructureReference;
}

    [StructLayout(LayoutKind.Explicit)]
public partial struct VkAccelerationStructureMatrixMotionInstanceNV
{
    [FieldOffset(0)]
    public VkTransformMatrixKHR transformT0;
    [FieldOffset(48)]
    public VkTransformMatrixKHR transformT1;
    [FieldOffset(96)]
    public uint instanceCustomIndex;
    [FieldOffset(99)]
    public uint mask;
    [FieldOffset(100)]
    public uint instanceShaderBindingTableRecordOffset;
    [FieldOffset(103)]
    public VkGeometryInstanceFlagsKHR flags;
    [FieldOffset(104)]
    public ulong accelerationStructureReference;
}
amerkoleci commented 3 years ago

Thanks for bringing this issue, commit https://github.com/amerkoleci/Vortice.Vulkan/commit/69b5d41ffcde791f4a1cbd8304ed95a23f706bc7 fixes this and version 1.4.2 will contain the fix.