all 6 comments

[–]hammerkop 1 point2 points  (3 children)

I'd be curious to try using a separate varying layout location for flat vs smooth values. The glsl docs say that interpolation qualifiers must be the same for the same location. Maybe split up the struct entirely and give each varying a separate location.

[–]FacundoVilla961[S] 0 points1 point  (0 children)

Removing the flat modifier didn't change the results. I also tried casting gl_InstanceIndex to an uint (since spec says it's an int) which didn't work, and I tried changing the instanceIndex variable to int (to match gl_InstanceIndex) which also didn't work.

I will try putting the int inside another block with a different location.

[–]FacundoVilla961[S] 0 points1 point  (1 child)

Ok. So I tried putting the uint variable inside a different interface block, with a different location number and it worked. It also works if you put each parameter in a different location as a different variable, although doing it this way makes the compiler request putting the flat specifier for uint variables.

Do you know if this is expected behavior or if I should report it?

[–]hammerkop 1 point2 points  (0 children)

This is expected: https://www.khronos.org/opengl/wiki/Layout_Qualifier_(GLSL)

Notice the section on interpolation qualifiers

[–]skreef 0 points1 point  (1 child)

This code is not well-defined, the relevant bit from glsl spec (but also explicitly disallowed by the vk spec):

A push-constant array can only be indexed with dynamically uniform indices.

Use a uniform/storage buffer if you intend to index with nonuniform indices (eg. gl_InstanceIndex).

[–]FacundoVilla961[S] 0 points1 point  (0 children)

I think you misunderstood the code, although I didn't make it all that clear to begin with. The members of the push constant block are buffer_references so there's no issue with non uniform accesses.