- December 20, 2011 at 6:48 pm #30716
I wrote application (Samsung Galaxy Nexus – Android 4.0, OpenGL ES 1.1) that renders scene into 2 viewports. Each glDrawElements/glDrawArrays is below scheme:
1. glViewport (left part of screen),
3. glViewport (right part of screen).
I render to FBO with texture as color attachment. I found that switching viewport is very time consuming. Can anyone explain why ??
The same application works 5-10 times faster on Qualcomm chipset (Adreno200). ??January 10, 2012 at 11:26 am #35343
Can you explain what your use case is? Is this to display the render in 3D by getting the user’s eyes to each look at one side of the screen?
Just to clarify – are you only calling glViewport twice per frame, or are you calling it repeatedly?
It’s best on our GPUs to avoid unecessarily changing the viewport while rendering to a surface. Have you tried rendering the left side of the screen to one FBO, the right side to another and then blitting the two textures to the framebuffer? This approach would avoid changing the viewport during the render loop and may give you better performance.
Joe2012-01-10 15:17:03January 10, 2012 at 3:12 pm #35344
Yes, You are correct, this is 3D use case.
I repeat every call to glDrawArrays/glDrawElements for left and right eye. So glViewport is called twice on each call to glDrawArrays/glDrawElements.
Using 2 FBOs is not acceptable due to switching time between FBOs. It kills performance much more than switching viewport.January 10, 2012 at 3:24 pm #35345
Ah, ok. If you change your render to do the following it should be much more efficient, as it will remove redundant glViewport() calls:
1. Set the viewport for the left eye
2. Render all objects for the left eye
3. Set the viewport for the right eye
4. Render all objects for the right eye
This approach will only require the viewport to be set twice per frame (once for the left side of the screen, once for the right).
Switching between FBOs shouldn’t have a high cost on our hardware.