Skip to content

SPIRV-Reflect incorrectly reports padded_size for members of a storage block #305

@matusfedorko

Description

@matusfedorko

Given the following shader I think SPIRV-Reflect does not properly report padded_size for the members of SBO:

struct S
{
	float aa;
	float bb;
};

layout(binding = 0, std140) buffer SBO
{
	S s1[2][3];
	S s2;
} sbo;

void main()
{
    gl_Position = vec4(sbo.s1[0][0].aa, 0, 0, 0);
}

I get 4 for both aa and bb, which makes it impossible to correctly compute offsets for members of SBO. In a full reflection of SBO I'd expect to get the following offsets:

s1[0][0].aa -> 0
s1[0][0].bb -> 4
s1[0][1].aa -> 16
s1[0][1].bb -> 20
s1[0][2].aa -> 32
s1[0][2].bb -> 36
s1[1][0].aa -> 48
s1[1][0].bb -> 52
s1[1][1].aa -> 64
s1[1][1].bb -> 68
s1[1][2].aa -> 80
s1[1][2].bb -> 84
s2.aa       -> 96
s2.bb       -> 100

Instead what I see is this:

s1[0][0].aa -> 0
s1[0][0].bb -> 4
s1[0][1].aa -> 8
s1[0][1].bb -> 12
s1[0][2].aa -> 16
s1[0][2].bb -> 20
s1[1][0].aa -> 24
s1[1][0].bb -> 28
s1[1][1].aa -> 32
s1[1][1].bb -> 36
s1[1][2].aa -> 40
s1[1][2].bb -> 44
s2.aa       -> 48
s2.bb       -> 52

Interestingly this works fine for uniform blocks, i.e. if I replace buffer with uniform in my example, padded_size gets reported correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions