Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
matusfedorko opened this issue Feb 19, 2025 · 0 comments

Comments

@matusfedorko
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant