Copying transform feedback into input of another shader (GL2.1)

So, for undisclosed reasons, I need to calculate something in a shader and retrieve the output using transform feedback. This is only to calculate one value. I know it’s not efficient to use the GPU this way but I have other reasons.

It is possible to pass this one value into another shader program without a roundtrip? I had thought to just bind the output buffer and pass the values as one attribute. But I can’t actually seem to do this, because for some reason passing 0 as the stride to glVertexAttribPointer doesn’t actually mean zero stride!

I’m trying to use as little GL features as possible. It’s for this reason I’m on 2.1 right now. But if it comes down to it and I have no other choice, I’ll just have to use something newer then.

I read the EXT_transform_feedback specification. It apparently says that this is possible with uniform buffers or EXT_bindable_uniform. This would have been a great solution, but my target hardware doesn’t support it (well, it does, the drivers don’t).

In that case, a roundtrip may be necessary. Oh, well.

The only “core” 2.1 solution I can think of is to upload the data to a 1x1 texture (via GL_PIXEL_UNPACK_BUFFER to avoid the round trip). Although the texture formats available in 2.1 might not have sufficient precision (you’re limited to unsigned normalised values with up to 16 bits per component; later versions have integer, floating-point and signed normalised formats).

Attribute arrays can’t have a stride of zero, but you could use instanced rendering with the value as an instanced attribute (glVertexAttribDivisor). But that requires 3.3, whereas UBOs only require 3.0 (transform feedback also requires 3.0).

I see. Thanks for the info. I guess I’ll just leave the roundtrip as a fallback, and use PIXEL_UNPACK_BUFFER if available.