GLAbstraction.jl icon indicating copy to clipboard operation
GLAbstraction.jl copied to clipboard

Batch flushing data to GLBuffer

Open JMurph2015 opened this issue 7 years ago • 2 comments

Is there a good way for me to flush a large array into a GLBuffer? Currently the setindex methods incur a huge amount of overhead for my purposes.

Context: I'm rendering a bunch of arbitrarily colored squares on a window, and need to update the colors on every frame using data from a TCP socket connection. See the repo below for more info, not that it has much documentation at this point, but it's only about 100 lines of code) https://github.com/JMurph2015/LEDSimulator.jl

JMurph2015 avatar Aug 10 '17 04:08 JMurph2015

Sorry, your code is a bit complex for a quick look at why this is slow. I see you're using glBufferSubData, which should be relatively fast for large arrays. Maybe you can speed things up, if you leave the buffer mapped, similar to this: https://github.com/JuliaGL/GLAbstraction.jl/blob/master/src/GLBuffer.jl#L117

Btw, any reason why you don't use GLVisualize for this? Seems like you could easily save yourself from most of the code you've written there ;)

SimonDanisch avatar Aug 10 '17 08:08 SimonDanisch

So, I actually figured out the glBufferSubData after the comment here, but it would be nice if the version in GLAbstraction supported something like this in broadcasting to make the call streamlined. When I was using the setindex! methods defined for GLBuffers I was ending up binding, calling glBufferSubData, and unbinding 36,000 times or so. My stuff runs pretty acceptably fast now. (and sorry for subjecting your eyes to that code, it looks like a warzone right now.)

Re GLVisualize: Mainly that it was such a simple layout that it was pretty easy to do in closer to raw OpenGL without having to learn a new API for it. GLVisualize didn't seem to be geared toward polygons so much as data sets.

JMurph2015 avatar Aug 10 '17 09:08 JMurph2015