This would potentially break with GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT indices; how do you specify a value of gl_SomeNiceName greater than 255 or 65535 in those cases?
Break is not the correct word, the correct word is that it is much more limited. The value taken from the index stream has the range by the index stream type, thus if drawing with GL_UNSIGNED_BYTE, then the value is an integer in the range [0,255] and for GL_UNSIGNED_SHORT is it in integer in the rage [0, 65535].
Alfonse’s suggestion of having the value start at 0 and increment whenever restart is encountered is nice though, and though using that would be harder, it is growing on me.
Additionally, looking at the way of tweaking glMultiDrawElements, one can see that there are roads open for other tweaks. Another way forward is a draw_indirect2 idea as follows by tweaking GL_ARB_draw_indirect
typedef struct { GLuint count; GLuint primCount; GLuint firstIndex; GLint baseVertex; GLuint reservedMustBeZero; GLuint someNiceName;} DrawElements2IndirectCommand
DrawElementsIndirect2(enum mode, enum type, const void *indirect);means:
DrawElements2IndirectCommand *cmd = (DrawElementsIndirectCommand *)indirect;
"gl_SomeNiceName=someNiceName";
DrawElementsInstancedBaseVertex(mode, cmd->count, type, cmd->firstIndex * size-of-type, cmd->primCount, cmd->baseVertex);
which by itself is not so interesting, but then augment GL_ARB_multi_draw_indirect to a GL_ARB_multi_draw_indirect2. Going further, the data for someNiceName does NOT then really need to be a 32-bit unsigned integer. Instead it can be like a “pseudo-attribute”, a munge of bytes and the DrawElementsIndirect2 (and MultiDrawElementsIndirect2) would then have further arguments specifying how to interpret that munge of bytes as follows:
typedef struct {
GLuint count;
GLuint primCount;
GLuint firstIndex;
GLint baseVertex;
GLuint reservedMustBeZero;
GLubyte someNiceName[]; //variable length
} DrawElements2IndirectCommand;
DrawElementsIndirect2(enum mode, enum type, const void *indirect);means:
DrawElements2IndirectCommand *cmd = (DrawElementsIndirectCommand *)indirect;
"gl_SomeNiceName=someNiceName";
DrawElementsInstancedBaseVertex(mode, cmd->count, type, cmd->firstIndex * size-of-type, cmd->primCount, cmd->baseVertex, someNiceNameSize, someNiceNameType, someNiceNameNormalized);
where someNiceNameSize, someNiceNameType, someNiceNameNormalized specify, analogous to VertexAttribPointerhow to interpret the bytes at the end of the structure.