KhronosGroup / SPIRV-Reflect

SPIRV-Reflect is a lightweight library that provides a C/C++ reflection API for SPIR-V shader bytecode in Vulkan applications.
Apache License 2.0
672 stars 147 forks source link

Fix struct variable size with out-of-order offsets #264

Closed spencer-lunarg closed 4 months ago

spencer-lunarg commented 4 months ago

This is follow-up for https://github.com/KhronosGroup/SPIRV-Reflect/pull/263

I realize the struct size itself is still wrong

name     : ubo (UniformBufferObject)
    // size = 16, padded size = 16
    struct UniformBufferObject {
        float a; // abs offset = 0, rel offset = 0, size = 4, padded size =  4 UNUSED
        float b; // abs offset = 4, rel offset = 4, size = 4, padded size = 12 UNUSED
    } ubo;      

name     : ubo2 (UniformBufferObject2)
    // size = 4, padded size = 4
    struct UniformBufferObject2 {
        float b; // abs offset = 4, rel offset = 4, size = 4, padded size = 12 UNUSED
        float a; // abs offset = 0, rel offset = 0, size = 4, padded size =  4 UNUSED
    } ubo2;     

The size of ubo2 is not // size = 4, padded size = 4 and should be 16