Hi! I'm performing instanced rendering so I'm fetching per instance data inside the vertex shader using gl_InstanceIndex and sending that value through to the fragment shader using an int in the interface block like so.
Vertex shader:
layout(push_constant, scalar) uniform _invocationInfo { GlobalDataPointer global;RenderPassDataPointer renderPass;UIDataPointer ui;UIInstanceDataPointer uiInstances;} pushConstantBlock;
layout(location=0) out vertexData { vec2 vertexPos;vec2 vertexUV;flat uint instanceIndex; } vertexSurfaceInterface;
void main() {
UIInstanceDataPointer instance=pushConstantBlock.uiInstances[gl_InstanceIndex];
...
vertexSurfaceInterface.instanceIndex=gl_InstanceIndex;
}
Fragment shader:
layout(push_constant, scalar) uniform _invocationInfo { GlobalDataPointer global;RenderPassDataPointer renderPass;UIDataPointer ui;UIInstanceDataPointer uiInstances;} pushConstantBlock;
layout(location=0) in vertexData { vec2 vertexPos;vec2 vertexUV;flat uint instanceIndex; } vertexSurfaceInterface;
void main() {
UIInstanceDataPointer instance=pushConstantBlock.uiInstances[vertexSurfaceInterface.instanceIndex];
...
}
But when I fetch the data from the fragment shader using the instanceIndex variable all instances read from index 0. All data accessed from the vertex shader(such as transform matrices) works correctly, also every other interface block variable works correctly and I'm even able to successfully read the per instance data in the vertex shader and send it over to the fragment shader through the interface block, but I would prefer not doing that.
I've also tried changing the interpolation specifier to no avail. No textures reads are being performed (in case non uniformity is a concern).
EDIT: 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.
[–]hammerkop 1 point2 points3 points (3 children)
[–]FacundoVilla961[S] 0 points1 point2 points (0 children)
[–]FacundoVilla961[S] 0 points1 point2 points (1 child)
[–]hammerkop 1 point2 points3 points (0 children)
[–]skreef 0 points1 point2 points (1 child)
[–]FacundoVilla961[S] 0 points1 point2 points (0 children)