Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise use of OpenGL #15

Open
hex539 opened this issue Dec 26, 2019 · 1 comment
Open

Optimise use of OpenGL #15

hex539 opened this issue Dec 26, 2019 · 1 comment
Assignees

Comments

@hex539
Copy link
Owner

hex539 commented Dec 26, 2019

Performance is OK when running as a standalone desktop app connected to HDMI. Still, things get a little bit choppy if casting the screen to another device at the same time, and this is one of the main use cases for the program.

flame

On an i7-6770HQ iwth software rendering, the desktop app can do 4K60fps but the above flame graph shows that it spends a lot more time than it should rendering fonts and using OpenGL 1.1 immediate mode APIs.

Next steps are to:

  1. Add a benchmark target for rendering N frames and then exiting.
  2. Switch all of the glBegin/glEnd usage into VBOs.
@hex539 hex539 self-assigned this Dec 26, 2019
@hex539
Copy link
Owner Author

hex539 commented Dec 31, 2019

After optimising out the glEnable/glDisable calls, the GPU trace tool shows us the following time breakdown per 18ms frame, with and without particles enabled, respectively:

image

Calls highlighted in blue are glVertex2d (average time per call 147ns). If we go to the worst case for particles there are typically about 30k extra vertices to draw, which take about 9ms out of the 16ms budget (4.5ms from glVertex, 4.5ms from glColor).

Then we have about 5k other vertices being drawn with glVertex2d/glVertex2f and fewer glColor calls in 6ms, which typically we just barely meet.

So it makes sense to start by putting the particles in a vertex buffer and trace again to see if the impact is reduced enough by doing that.

hex539 added a commit that referenced this issue Jan 2, 2020
No glDisable(GL_TEXTURE_2D) or glDisable(GL_BLEND) in the middle of
rendering a frame.

Improves performance- see issue #15
hex539 added a commit that referenced this issue Jan 2, 2020
This is less expensive than making tens of thousands of calls per frame
to glVertex2d(). Still less expensive would be moving to GPU simulation
for particle effects, but I'm not sure if this is still worth it after
taking into account the potential compatibility issues with old OpenGL
versions on Windows systems.

Improves performance. See issue #15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant