How to get the current index in the vertex shader

Hello,

I would like to optimize the size of the vertices buffer.
In the vertex shader I calculate the line segment between two vertices.
To be able to do this today, I must enter the two vertices in the buffer for each line segment, even if several segments follow each other and share the same vertice.
This therefore doubles the size of the vertex buffer.

On the other hand, if I managed to know the current index of the index buffer (not the value that points to the vertex buffer such as [[vertexid]] but the index that checks [[vertexid]] = indexBuffer[index]), I could retrieve the index of the vertex buffer for the next vertex.

For example I think of something like this:

Code Block
vertex VertexOut vertexShader (
const device float3 * verticesArray[[buffer (0)]],
const device uint * indicesArray[[buffer (1)]],
unsigned int index, /* What I'm looking for */
unsigned int vid [[vertex_id]]) {
float3 firstVertex = verticesArray[vid];
float3 nextVertex = verticesArray[indicesArray[index + 1]];
...
}


If anyone had an idea.
How to get the current index in the vertex shader
 
 
Q