I was trying to think why would OpenGL need to know the primitive type when calling glBeginTransformFeedback. In essence, it's just data that is stored into a buffer.
My guess would be that OpenGL somehow needs it in order to compute how much space is needed so draw commands can be run in parallel without stomping on each others data. But when you submit a draw command, OpenGL should be able to infer the required space from the primitive type specified in the draw.
In the case of using a geometry shader I think the amount of space required can't be known a priory because each individual execution could output a different number of primitives (I imagine that should be quite challenging to implement in the hardware!). But in that case, I don't think specifying the primitive type in glBeginTransformFeedback
would help anyways. The output primitive type can be infered as well from the bound program.
So as I see it, specifiying the primitive type in glBeginTransformFeedback
just puts a limitiation in the type of primitives you can render. Why is this limitiation?
I think it is to avoid querying the output type from the bound program. The primitive type given to the draw command is not always the same as the primitive type that is stored into the transform feedback buffer: both geometry and tessellation shaders can turn triangles / patches into points.
If the draw command specifies triangles but the program emits points, which is the programmer expecting to be stored? Specifying the primitive type with glBeginTransformFeedback makes it possible to check before drawing anything.
Transform feedback could work by storing whatever the program emits as you suggest, and that might even be preferable in some cases, but then there would have to some query mechanism "what type of geometry is in the feedback buffer?" afterwards.