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

Low performance/More in-depth documentation #18

Closed
helgrima opened this issue Jun 26, 2018 · 6 comments
Closed

Low performance/More in-depth documentation #18

helgrima opened this issue Jun 26, 2018 · 6 comments
Labels

Comments

@helgrima
Copy link
Contributor

I cloned newest demosys-py and started modify basic cube template. Code is available:
https://github.com/helgrima/saturday77/blob/master/bouncingcubes/effect.py

I am quite sure that code is just silly, and that is why I got so low performance, like 15 fps.
Display adapter: NVIDIA GeForce GTX 950

Very same happened with version 0.4.0 also.

I understand that documentation is going to be changed, as it seems that all effect templates had changes since yesterday. So could this be included in that documentation update as well?

@einarf
Copy link
Member

einarf commented Jun 26, 2018

Docs are high pri as soon as 1.0.1 is out (very soon)

You can used instanced rendering to draw those cubes with one draw call, but I guess that is hard to start with when docs are not relevant any more. There's A LOT of new features that comes with using ModernGL that are easily available.

This is actually a perfect example we could use to illustrate the use of these features.

@einarf
Copy link
Member

einarf commented Jun 26, 2018

I did some profiling. It's actually the matrix operation in python that are dreadfully slow! Drawing 100 cubes the naive way like this is probably not the way to go, but this was still very useful to look at.

I will provide an improved example shortly.

@einarf
Copy link
Member

einarf commented Jun 26, 2018

Faster naive version: https://github.com/Contraz/demosys-py-test/tree/master/testdemo/bouncingcubes

This one eliminates the matrix operations in the loop. I'll see if I can make an instanced example as well.

@einarf
Copy link
Member

einarf commented Jun 27, 2018

Modified a bit more. It seems I can draw around 1000 cubes the naive way and still get 60 fps when removing matrix operations in the loop. I think this is mostly related to pyrr creating new ndarray (numpy arrays) for each calculation causing memory allocations. That is the most devastating performance hit you have in python.

Still it's nice to see that it's possible to at least get at least 1000 draw calls at 60fps

@einarf
Copy link
Member

einarf commented Jun 29, 2018

I added support for instanced rendering (in master now).

Here is your bouncing cube example drawing 250.000 cubes instances with modified positions each frame through transform feedbacks.
https://github.com/Contraz/demosys-py-test/tree/master/testdemo/bouncingcubes_instanced

So we have moved from 100 cubes at 15ps to 250k cubes at 60 fps (at least on my laptop) 😄

@einarf
Copy link
Member

einarf commented Jul 3, 2018

Closing this as #8 covers the docs.

@einarf einarf closed this as completed Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants