View Full Version : Transform Feedback, different source target ranges

01-27-2012, 07:01 AM

I want to draw a certain range of a Array Buffer A into a different range of a Transform Feedback Buffer B.
The draw size is the same, but the draw offset varies.
I PingPong those buffers with an increasing offset, but the example shows only one step.

Draw A1,A2 and Record into B2,B3:
A : A0 A1 A2 A3 A4 A5
B : B0 B1 A1 A2 B4 B5

I set up all my Buffers, and at draw time I use:

// Transform Feedback
glBindBuffer( GL_TRANSFORM_FEEDBACK_BUFFER , buffer_B ) ;
glBindBufferRange( GL_TRANSFORM_FEEDBACK_BUFFER , 0 , bufferFB , offsetBytes , sizeBytes ) ;

// Draw into Feddback Buffer
glUseProgram( transFeedbackProg ) ;
glBeginTransformFeedback( GL_POINTS ) ;
glBindBuffer( GL_ARRAY_BUFFER , buffer_A ) ;
glDrawArrays( GL_POINTS , offset - 1 , size ) ;
glEndTransformFeedback() ;

// Draw Result
glUseProgram( drawProg ) ;
glBindBuffer( GL_ARRAY_BUFFER , buffer_B ) ;
glDrawArrays( GL_POINTS , 0 , completeBuffer ) ;

offset and size are per Vertex and offsetBytes and sizeBytes are per Vertex per Byte.
In the transFeedbackProg I update Vertex Positions.
When I don't use ranges but allways render the whole buffers I get expected results.
But the setup above does not update my Vertices properly.

One problem might be, that render Range does not re-base the gl_VertexID, when I render a
range from 4-8 the gl_VertexIDs are still from 4-8 and not from 0-4. Now I fear that I cannot
read from and write to different ranges, as in both cases the absolute gl_VertexID is used,
and as the ranges are disjunct no data gets updated at all.

Could somebody confirm, clarify or object ?

Thank you,

Cheers, ParticlePeter

01-29-2012, 10:45 AM
Hi ParticlePeter,

I have to object, on my side your case is working. Maybe you've screwed up your ranges or vertex range to transform feedback record bytes range mapping.

Cheers, Peter Particle

01-29-2012, 10:46 AM
Hey, Peter Particle,

thanks a lot, that was exactly my issue, wow, cool, its working now :-)

Cheers, ParticlePeter