SPIRV-Reflect evaluates BDA size as 16 bytes instead of 8

37 Views Asked by At

I ran into a problem when SPIRV-Reflect from LunarG's Vulkan SDK (v1.3.275.0) evaluates push constant size with a single BDA as 16 bytes instead of expected 8.

I think that BDA size has to be 8 bytes wide since it is a pointer.

Providing shader and reflection code:

Shader code

layout(buffer_reference, scalar, buffer_reference_align = 4) readonly buffer CameraData {
    mat4 view;
    mat4 proj;
    mat4 view_proj;
    vec3 position;
};

layout(push_constant) uniform PushContants {
    CameraData camera;
} pc;

Reflection code

uint32 push_constant_range_count = 0;
spvReflectEnumeratePushConstantBlocks(&reflect_module, &push_constant_range_count, nullptr);

std::vector<SpvReflectBlockVariable*> reflect_push_constant_ranges(push_constant_range_count);
spvReflectEnumeratePushConstantBlocks(&reflect_module, &push_constant_range_count, reflect_push_constant_ranges.data());

for (auto& reflect_range : reflect_push_constant_ranges) {
    push_constant_range.size += reflect_range->size;
    push_constant_range.offset = 0;
    push_constant_range.stageFlags = VK_SHADER_STAGE_ALL;
}

I know that I have slightly incorrect code "Reflection code" section, which may lead to errors when using two push-constant ranges in different shader stages. However, I have written it just for test and I only use a single push-constant range in vertex stage which was defined in code I provided.

I also provide some debug information from reflected push-constant range: Push constant reflection data

And here is description of camera member in PushConstants struct: description of camera member in PushConstants struct

On images above it is clearly visible that for some reason PushConstants size is 16 bytes instead of expected 8. What is the reason of such behavior?

0

There are 0 best solutions below