gl_DrawID is always 0 (glMultiDrawElementsIndirect)

I use glMultiDrawElementsIndirect to draw multiple meshs.
The meshs are drawn correctly just not at the correct position. The position is selected from an array using gl_DrawID as index. Further tests have shown that gl_DrawID always remains 0. Also gl_baseInstance is always the value from the first DrawElementsIndirectCommand.
The strangest thing is that when I use RenderDoc it all works as expected.

Could this be a driver issue? Or something extremely esoteric I’m not aware of?
I have used glMultiDrawElementsIndirect and gl_DrawID before on the same computer without issue.

Here is the shader code in question:

#version 460 core
#pragma queue ui

layout(location=0) in vec2 in_pos;
layout(location=1) in vec2 in_uv;

layout(std140, binding = 0) uniform PerFrameData
	mat4 view;
	mat4 proj;
	mat4 proj2d;
	vec4 cameraPos;
    vec4 fogColor;
	float nearPlane;
    float farPlane;

layout(std430, binding = 1) restrict readonly buffer ModelMatrices
	mat4 in_model[];

layout(location=0) out flat uint matIdx;
layout(location=1) out vec2 f_uv;

void main(void){
	mat4 model = in_model[gl_DrawID];
	mat4 mvp = proj2d * model;

	gl_Position = mvp * vec4(in_pos, 0, 1.0f);
	f_uv = in_uv;
	matIdx = gl_DrawID;

It must have somehow something to do with the way I fill the buffers. A different glMultiDrawElementsIndirect in the same application running drawing in the same frame gets the correct gl_DrawIDs.

I just don’t know what could possibly cause this behavior. Why does renderdoc not have this issue?

Okay I figured it out.


 GL.VertexArrayVertexBuffer(vao, 0, vbo.handle, IntPtr.Zero, vertexLayout.size);

after these calls

GL.EnableVertexArrayAttrib(vao, i);
GL.VertexArrayAttribFormat(vao, i, (int)descr.dim, descr.type, false, offset);
GL.VertexArrayAttribBinding(vao, i, 0);
GL.VertexArrayBindingDivisor(vao, i, 0);

makes it work correctly. I have still no IDEA why that is. No clue. Might be a driver quirk.
Would be grateful if someone could explain. Also why does it work in renderdoc regardless??