Skip to content

Conversation

rsxrwscjpzdzwpxaujrr
Copy link

@rsxrwscjpzdzwpxaujrr rsxrwscjpzdzwpxaujrr commented Jul 27, 2025

Closes audacious-media-player/audacious#1546

Video demonstration

AFAIU gl-spectrum plugin using GLX is one of the blockers for transitioning to using wayland by default. Well, not anymore, because I implemented GL context creation through GtkGLArea widget. Unfortunately, there are no good ways to force GtkGLArea to create a legacy GL context, it only falls back to legacy context if creating a core GL context failed, and this plugin used only legacy GL functions for rendering. So I implemented a new renderer which uses modern GL functions. The modern renderer is not uploading the whole scene to GPU on every frame like the legacy one does, but uploads it only once and then uploads only the height map on every frame, which is used calculate the actual geometry in a vertex shader, which should make it faster. The context version is being checked in runtime and the modern renderer is used if requirements are met, if not it's just using the old one. The modern renderer is also used by default in the case of context creation through GLX and Win32. If everything works fine, GLX and Win32 GL context creation code can be safely removed to reduce unnecessary complexity, and it won't change the minimal required OpenGL version as we can always fall back to the legacy rendering.

I also want to note that with the modern renderer cool effects can be added in the future. For now it's just replicating the old one.

Please test in on Windows and macOS before merging, as I can't verify if it's working there (it should).

@rsxrwscjpzdzwpxaujrr rsxrwscjpzdzwpxaujrr changed the title Add modern GL renderer and GtkGLArea support for gl-spectrum gl-spectrum: Add modern GL renderer and GtkGLArea support Jul 27, 2025
@radioactiveman
Copy link
Member

Thanks for working on this. 👍 I'm looking forward to try it out when finding some free time.

AFAIU gl-spectrum plugin using GLX is one of the blockers for transitioning to using wayland by default.

The main reason for using XWayland by default is that the Winamp interface is unusable on Wayland, see #1560 for more details. Supporting the gl-spectrum plugin on Wayland is of course still beneficial.

Questions from a first quick look:

  • We already require GTK 3.18 if GTK3 is enabled. And these versions depend on libepoxy. Maybe we can simplify the code and build system checks if we say "always use the modern renderer for GTK3"?
  • glm however would be a new dependency. Is it possible to avoid this library?

@rsxrwscjpzdzwpxaujrr
Copy link
Author

rsxrwscjpzdzwpxaujrr commented Jul 29, 2025

The main reason for using XWayland by default is that the Winamp interface is unusable on Wayland

Can't we use XWayland only when using the Winamp interface then?

Maybe we can simplify the code and build system checks if we say "always use the modern renderer for GTK3"?

The modern renderer and the GL context creation through GtkGLArea are 2 separate things. If you meant "always use context creation through GtkGLArea for GTK3", I can do it and it would simplify the code without any drawbacks. If you actually meant the modern renderer, I can also do it, but it won't make sense, it would increase the minimal OpenGL requirements without simplifying anything. Modern renderer's minimal requirements are OpenGL 2.1 with ARB_vertex_array_object extension (which became part of the standard since OpenGL 3.0) or OpenGL ES 3.0. We can go even further and always use the modern renderer even with gtk2, if that's what you want, in that case we could remove the legacy rendering and simplify the code. The modern renderer doesn't care how the context was created.

glm however would be a new dependency. Is it possible to avoid this library?

I can do it if that's what you want. In OpenGL core context matrix manipulation functions were removed and people need to implement the matrix math themselves or use something like glm. glm is a header-only dependency hence it's only needed in build-time.

@rsxrwscjpzdzwpxaujrr
Copy link
Author

rsxrwscjpzdzwpxaujrr commented Jul 29, 2025

I found a performance regression with GtkGLArea after docking the plugin, and the performance stays poor even after undocking it back until you restart the app. GTK3 seems to be copying the rendered image back and forth instead of directly displaying it on the screen after docking the plugin.

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

Successfully merging this pull request may close these issues.

Use GtkGLArea for OpenGL Spectrum Analyzer plugin

2 participants