16
Graphics / Re: Speeding Up Rendering Performance
« on: November 15, 2016, 12:49:53 pm »
In my test application I got around 130 FPS with one single sf::vertexarray and 400k Triangles. Using 1000 VBOs/VAOs and the same number of triangles was around 25% faster. I can't tell you why I reach much better results in my actual game now. I think it's because I cache the shader in my game while I didn't in the test application. Therefore with all optimizations the VAO/VBO solution is around 90% faster but the main gain comes from caching the shader binding.
Generally, I think the problem with sf::vertexarray is the shuffling of vertexdata from RAM to VRAM. Additionally the framerate with sf::vertexarrays is much more unstable, I think whenever there is a slight more load on the CPU, the framerate decreases.
Edit: Another advantage of using VAOs/VBOs is I can easily implement a dynmaic and smooth Level of Detail system for when the user zooms further out. With gl_DrawArrays i can simply tell the graphics card to only draw triangles 0 to 100, or 0 to end or 0 to any value
At first I thought using VBO's/VAO's would be a complex task to implement but it turned out much easier.
Here is the relevant code in case anybody might want to use it:
Basically you also can leave VAO's out and only use VBO's which are already provided by OGL 1.5 I think (?). VAO's are OGL 3.0(?). But then you need to do a few more calls when rendering which you can shuffle to the initialization part when using VAO's. In my tests I got the same framerate with VBO's and VAOs/VBOs but with VAOs/VBOs the CPU utilization was about 1-2% lower (8,3% equals one fully utilized thread on my machine).
I have to admit I'm not quite sure about all the OGL basics either. Espacially the different matrices and blendmodes are a bit confusing to me but I did not really look into it. The code above works fine for me and according to different examples regarding VAOs/VBOs I think everything is correct. For my special case this is enough, therfore I will now switch back to game development and pure sfml instead of pure OGL
Thanks for your help.
Generally, I think the problem with sf::vertexarray is the shuffling of vertexdata from RAM to VRAM. Additionally the framerate with sf::vertexarrays is much more unstable, I think whenever there is a slight more load on the CPU, the framerate decreases.
Edit: Another advantage of using VAOs/VBOs is I can easily implement a dynmaic and smooth Level of Detail system for when the user zooms further out. With gl_DrawArrays i can simply tell the graphics card to only draw triangles 0 to 100, or 0 to end or 0 to any value

At first I thought using VBO's/VAO's would be a complex task to implement but it turned out much easier.
Here is the relevant code in case anybody might want to use it:
(click to show/hide)
Basically you also can leave VAO's out and only use VBO's which are already provided by OGL 1.5 I think (?). VAO's are OGL 3.0(?). But then you need to do a few more calls when rendering which you can shuffle to the initialization part when using VAO's. In my tests I got the same framerate with VBO's and VAOs/VBOs but with VAOs/VBOs the CPU utilization was about 1-2% lower (8,3% equals one fully utilized thread on my machine).
I have to admit I'm not quite sure about all the OGL basics either. Espacially the different matrices and blendmodes are a bit confusing to me but I did not really look into it. The code above works fine for me and according to different examples regarding VAOs/VBOs I think everything is correct. For my special case this is enough, therfore I will now switch back to game development and pure sfml instead of pure OGL

Thanks for your help.