Threaded View

Number of invocation of vertex shader

Hi,

I'm wondering about the number of time a vertex shader can be called It is written on the specification that a vertex shader can be executed many times per vertex, depending on implementation specific details.

For example a vertex can be shared between many triangles, say two for the example.. The associated vertex shader can be called once and cached between all the triangles or twice.

This is not an issue as long as your shader does not do any side effect (such as writing on a shader buffer storage of GL 4.3), but if you want to do some side effect, you need guarantees on the number of shader invocation.

My question is about drawing GL_POINTS in not indexed mode (ie: glDrawArrays). Can I be sure (I mean, does the specification enforce this?) that my vertex shader will be called only one time per vertex?

For example, I want to create a particule system where each particule is defined by a position and a velocity and draw by a glDrawArrays(). My vertex shader may looks like that:

The issue is with the * line, where the position of each particule is updated by the velocity. If my vertex shader is called multiples times, the result will be wrong.

Another safe solution is to update the position using a compute shader and use a really simple vertex shader to draw the particules, but the first solution will be more efficient because it reduce the amount of loaded data.

tl; dr;

Is there any guarantee that the number of vertex shader invocations done by a DrawArrays on any primitive without vertices sharing will be one?