glMultiDrawElementsIndirect error?

My indirect draw command structure is declared like this:

typedef struct {
	uint32_t count;
	uint32_t instanceCount;
	uint32_t firstIndex;
	int32_t baseVertex;
	uint32_t baseInstance;
} DrawElementsIndirectCommand;

This code works as expected:

for (const auto& command : vislist->drawcommands)
	glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, command.count, GL_UNSIGNED_INT, (void*)(command.firstIndex * 4), command.instanceCount, command.baseVertex, command.baseInstance);

This code produces GL_ERROR_INVALID_OPERATION. The stride value is 20.

int stride = sizeof(vislist->drawcommands[0]);
Assert(stride == 20);
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, vislist->, vislist->drawcommands.size(), stride);

The number of draw commands is one. The drawcommands value is declared like this:

std::vector<DrawElementsIndirectCommand> drawcommands;

Any ideas what is wrong?

There’s your problem. Core OpenGL does not allow you to use CPU memory for indirect rendering. You have to put the indirect commands in buffer objects.

1 Like