#Vulkan wrong bindings

1 messages · Page 1 of 1 (latest)

unborn knot
#

Hello, I am implementing a ray tracing pipeline using Odin and Vulkan, and I can't get it to work and I think it might be a problem comming from the bindings related to the acceleration structure construction

typedef struct VkAccelerationStructureInstanceKHR {
    VkTransformMatrixKHR          transform;
    uint32_t                      instanceCustomIndex:24;
    uint32_t                      mask:8;
    uint32_t                      instanceShaderBindingTableRecordOffset:24;
    VkGeometryInstanceFlagsKHR    flags:8;
    uint64_t                      accelerationStructureReference;
} VkAccelerationStructureInstanceKHR;
AccelerationStructureInstanceKHR :: struct {
    transform:                                      TransformMatrixKHR,
    instanceCustomIndexAndMask:                     u32, // Most significant byte is mask
    instanceShaderBindingTableRecordOffsetAndFlags: u32, // Most significant byte is flags
    accelerationStructureReference:                 u64,
}

I dont think they are compatible in size. Even the comments I dont think they are correct, wouldnt in this case the mask be the least significant byte or am I missing something?

waxen crystal
#

Looks correct to me

#

Also, if you update Odin to the latest release the bindings have changed to use Odin's bit_field type to more closely resemble the C side

unborn knot
#

but the mask shouldnt be the least significant byte? as it appears after the instanceCustomIndex?

#

I also dont know how vulkan uses this fields internally :c

forest plank
#

with latest vulkan C header, this trick of merging 2 struct member into 1 won't work. I wonder how to port current vulkan header to Odin

forest plank
#
typedef struct VkClusterAccelerationStructureBuildTriangleClusterInfoNV {
    uint32_t                                                         clusterID;
    VkClusterAccelerationStructureClusterFlagsNV                     clusterFlags;
    uint32_t                                                         triangleCount:9;
    uint32_t                                                         vertexCount:9;
    uint32_t                                                         positionTruncateBitCount:6;
    uint32_t                                                         indexType:4;
    uint32_t                                                         opacityMicromapIndexType:4;
    VkClusterAccelerationStructureGeometryIndexAndGeometryFlagsNV    baseGeometryIndexAndGeometryFlags;
    uint16_t                                                         indexBufferStride;
    uint16_t                                                         vertexBufferStride;
    uint16_t                                                         geometryIndexAndFlagsBufferStride;
    uint16_t                                                         opacityMicromapIndexBufferStride;
    VkDeviceAddress                                                  indexBuffer;
    VkDeviceAddress                                                  vertexBuffer;
    VkDeviceAddress                                                  geometryIndexAndFlagsBuffer;
    VkDeviceAddress                                                  opacityMicromapArray;
    VkDeviceAddress                                                  opacityMicromapIndexBuffer;
} VkClusterAccelerationStructureBuildTriangleClusterInfoNV;

take this struct in vulkan header. how would we port this to Odin?

#

my experience with Odin is limitted, I genuinely don't know how to replicate this bit struct in Odin

waxen crystal
forest plank
#

oh you are Laytan, are you the guy that wrote vulkan binding for Odin?

waxen crystal
#

No, that was not me

forest plank
#

I mean the vulkan triangle example

#

I learned vulkan following your code

waxen crystal
#

Oh yeah that one I've written

#

Great it was helpful