0

I have a buffer that I would like to fill over successive transform feedbacks, and I am wondering how exactly to do this.

glBindBufferRange has five arguments, I understand that the first three are equivalent to the arguments of glBindBufferBase, but I have a few questions about the offset and size arguments.

If my first transform feedback produced n primitives, as retrieved from GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, my primitives are points, and I want to continue from that position in the buffer, should the offset of glBindBufferRange be set to n*4*sizeof(GLfloat)? (assuming I am retrieving a vec4 geometry shader output)

The docs just say that offset and size should be in basic machine units (although they have two different types, GLintptr and GLsizeiptr), but I'm not exactly sure what that means, so I assumed bytes, is this correct?

leohutson
  • 95
  • 2
  • 10

1 Answers1

1

Yes, the amount of data written to a buffer during transform feedback is the number of primitives written * the number of components of those primitives * the size of a primitive. And yes, "basic machine units" is standardese for "byte".

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • Yes sorry, it is a bit unclear. These are completely separate transform feedbacks. I really want to know how to calculate where to start writing into the buffer of the second feedback, ie the offset to use so I don't leave a gap in the buffer or overwrite what I have already written. – leohutson Jun 19 '13 at 02:24
  • 1
    @leohutson: See my last sentence. – Nicol Bolas Jun 19 '13 at 02:37
  • Thanks so much for your help, I think I understand it pretty well now. If you don't mind, I would like to ask a slightly tangential question. In my current code, after my initial transform feedback, I have a while loop that acts as a barrier and just "pauses" the program until the GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query is available. If I was to get rid of this and just calculate the expected number of primitives myself, would it be safe to bind the re-bind the buffer and do the second feedback immediately afterwards, or are there concurrency issues? – leohutson Jun 19 '13 at 03:02