Slow transform feedback-based picking?

374 Views Asked by At

I'm trying to implement picking routine using transform feedback. Currently it works ok, but the problem is very low speed (slower than GL_SELECT).

How it works now:

  1. Bind TBO using glBindBufferRange() with offset (0 in the beginning).
  2. Reset memory(size of TF varyings structure) using glBufferSubData() (to be sure picking will be correct). The main problem is here.
  3. Draw objects with geometry shader that checks intersection with picking ray. If intersection has been found, shader writes this to TF varying (initially it has no intersection, see step 2).
  4. Increase offset and go to step 1 with the next object.

So, at the end I have an array of picking data for each object.

The question is how to avoid calling glBufferSubData() on each iteration? Possible solutions (but I don't know how to implement them) are:

  • Write only one TF varying. So it is not necessary to reset others
  • Reset data with any other way

Any ideas?

1

There are 1 best solutions below

7
Nicol Bolas On

If all you want to do is clear a region of a buffer, use glClearBufferSubData. That being said, it's not clear why you need to clear it, instead of just overwriting what's there.

FYI: Picking is best implemented by rendering the scene, assigning objects different "colors", and reading the pixel of interest back. Your method is always going to be slower.