Slow OpenGL Geometry Shader DrawArrays / Transform Feedback

376 views Asked by At

I am using OpenGL (via OpenTK) to perform spatial queries on lots of point cloud data on the GPU. Each frame of data is around 200k points. This works well flor low numbers of queries (<10queries @ 60fps) but does not scale as more are performed per data frame (100queries @ 6fps).

I would have expected modern GPUs to be able to chew through 20 million points (200k * 100 queries) points from 100 draw calls without breaking a sweat; especially since each glDrawArrays uses the same VBO.

A 'spatial query' consists of setting some uniforms and a glDrawArrays call. The geom shader then chooses to emit or not emit a vertex based on the result of the query. I have tried with / without branching and it makes no difference. The VBO used is separated attributes, one is STATIC_DRAW and other is DYNAMIC_DRAW (updated before each batch frame of spatial queries). Transform feedback then collects the data.

Profiling shows that glGetQueryObject is by far the slowest call (probably blocking, 5600 inclusive samples compared to 127 from glDrawArrys) but I'm not sure how to improve this. I tried making lots of little result buffers in GPU memory and binding a new transform feedback buffer for each query, but this had no effect - perhaps due to running on a single core? The other option would be to read the video memory from the previous query from another thread, but this throws an Access Violation and I'm unsure if the gains would be that significant.

Any thoughts on how to improve performance? Am I missing something obvious like a debug mode that needs switching off?

0

There are 0 answers