1
Graphics / VertexArray::draw performance
« on: May 21, 2018, 09:22:31 pm »
Hi,
Before explaining the actual issue I'd like to point out that I'm actually using D and dsfml instead of raw C++/SFML, but because dsfml is basically a 1:1 wrapper of SFML, I assume the problem that I face to actually emerge from SFML.
I'm drawing a VertexArray with 4.2 billion vertices and it takes… well, a lot of time. Sadly I can't just render it to a RenderTexture once and then draw the result on screen as constant zooming in and out forces me to actually re-render the array.
I did some profiling and found out that the function that takes the most of CPU time is __memcpy_avx_unaligned_erms and basically all of the time it takes is when it's called by copy_array_to_vbo_array.isra.0 from i965_dri.so shared object (.dll but on Linux). I took a quick look at SFML source and saw that it copies the array to GPU on every single drawcall, even if the contents of VertexArray haven't been modified, which is understandable as there may be references to VertexArray's elements that it has no knowledge of, so it has to assume that they have indeed changed to always produce correct results.
Is there some known way to address this issue and keep vertices on GPU that doesn't involve messing with OpenGL? Never bothered to learn it, sadly. If there isn't, what do you think about adding some function like VertexArray::prepare_draw(RenderWindow&, RenderStates) that would copy all the needed data to GPU and prepare a reusable drawable object that wouldn't need to copy anything around?
Thanks for your time,
Kamil
Before explaining the actual issue I'd like to point out that I'm actually using D and dsfml instead of raw C++/SFML, but because dsfml is basically a 1:1 wrapper of SFML, I assume the problem that I face to actually emerge from SFML.
I'm drawing a VertexArray with 4.2 billion vertices and it takes… well, a lot of time. Sadly I can't just render it to a RenderTexture once and then draw the result on screen as constant zooming in and out forces me to actually re-render the array.
I did some profiling and found out that the function that takes the most of CPU time is __memcpy_avx_unaligned_erms and basically all of the time it takes is when it's called by copy_array_to_vbo_array.isra.0 from i965_dri.so shared object (.dll but on Linux). I took a quick look at SFML source and saw that it copies the array to GPU on every single drawcall, even if the contents of VertexArray haven't been modified, which is understandable as there may be references to VertexArray's elements that it has no knowledge of, so it has to assume that they have indeed changed to always produce correct results.
Is there some known way to address this issue and keep vertices on GPU that doesn't involve messing with OpenGL? Never bothered to learn it, sadly. If there isn't, what do you think about adding some function like VertexArray::prepare_draw(RenderWindow&, RenderStates) that would copy all the needed data to GPU and prepare a reusable drawable object that wouldn't need to copy anything around?
Thanks for your time,
Kamil