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;
}