projectM-visualizer / projectm

projectM - Cross-platform Music Visualization Library. Open-source and Milkdrop-compatible.
https://discord.gg/mMrxAqaa3W
GNU Lesser General Public License v2.1
3.33k stars 372 forks source link

Add Vulkan/Metal rendering support #683

Open kblaschke opened 1 year ago

kblaschke commented 1 year ago

Currently, libprojectM only supports rendering using OpenGL 3 and GLES 2. Since OpenGL is generally considered a deprecated API and Vulkan/Metal has a better API to perform multi-threaded rendering and shader compilation, it will be a good step forward to add support for these next-gen rendering APIs.

Any API-specific initialization calls, e.g. providing the required Vulkan structs, should be implemented in a specific header, e.g. libprojectM/renderer_vulkan.h. Adding support for multiple rendering backends will also require a major refactoring of the library, abstracting rendering-related calls. projectM only renders a few primitives (triangle fans/strips, line strips and points) and uses vertex and fragment shader programs, so there's not much to implement.

Line rendering should be improved beforehand, as covered by issue #682.

Vulkan support should be introduced together with the EGL migration covered by issue #681.

olilarkin commented 1 year ago

You could also consider sticking to GLES and using libangle to translate it to Metal (could even be used on windows so it works on top of direct 3D etc)

olilarkin commented 1 year ago

Just thought I'd mention it since I've had some recent success with the metal port of angle

kblaschke commented 1 year ago

GLES is very limited, and also doesn't allow proper multithreading. Using Vulkan/Metal directly would give some performance improvements, especially when switching presets, as shaders and other resources could be set up in a dedicated parallel thread instead of the render thread, which currently causes hiccups.

jherico commented 6 months ago

is any work being done on this currently or is it up for grabs?

revmischa commented 6 months ago

is any work being done on this currently or is it up for grabs?

No work is being done, please feel free!

kblaschke commented 6 months ago

is any work being done on this currently or is it up for grabs?

Anyone who wants to do this, please go ahead!

If you're implementing it, please keep OpenGL/GLES support in projectM. While OpenGL is deprecated, it's still the only way to get projectM running on some devices and systems, one of them being WebGL/Emscripten.

Also note libprojectM is a library, so all render system initialization should not be part of the library, but done in the outside application. Whatever is needed to render output (e.g. the Vulkan device & swapchain information) needs to be passed in via the API.