Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

GPU acceleration #45

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

GPU acceleration #45

wants to merge 3 commits into from

Conversation

gregorni
Copy link
Collaborator

@gregorni gregorni commented Feb 24, 2023

Would close #42

Things to work on:

  • GPU acceleration right now leaks memory, that needs to be fixed
  • When rendering with the GPU, there's just a white flashing something
  • right now, one can't switch between CPU and GPU rendering without closing the app

@gregorni gregorni marked this pull request as draft February 24, 2023 16:16
@gregorni gregorni changed the title Add first draft of GPU acceleration GPU acceleration Feb 24, 2023
@fsobolev
Copy link
Owner

Thanks for working on this!

right now, one can't switch between CPU and GPU rendering without closing the app

I don't think it's necessary. Ideally, GPU rendering should work good for most users, and CPU rendering will be a fallback for some extreme cases. Also, switching rendering without restart will require switching between DrawingArea and GLArea on the fly, that's additional work.

https://github.com/moderngl/moderngl/blob/master/examples/integration_pycairo.py

As I understand this example, it renders cairo surface into GL texture of rectangle, maybe we can use the shader from here without changing.

@fsobolev
Copy link
Owner

fsobolev commented Mar 3, 2023

Here are examples of using modernGL with GTK.GlArea and Gtk.DrawingArea. This problem is, I'm not sure if it worth the effort, maybe by using modernGL+Cairo we'll just re-do things that Gtk.DrawingArea automatically does for us and we'll not get any significant performance improvement. If you have time and motivation, feel free to try. I will continue looking for another way to avoid using Cairo at all.

@gregorni
Copy link
Collaborator Author

gregorni commented Mar 3, 2023

I guess whether we get a performance boost depends on what is actually the bottleneck right now, cairo or CPU.

Anyway, I think for as long as we want to keep both CPU and GPU rendering available, we should render using moderngl+cairo, otherwise every new drawing mode will have to be implemented twice.

Once we drop CPU rendering, we should probably stop using cairo and turn to something more native in OpenGL/ModernGL.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Framerate issue when scaling to whole monitor.
2 participants