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.22k stars 365 forks source link

Try out libniceshade as a replacement for hlslparser #761

Open kblaschke opened 5 months ago

kblaschke commented 5 months ago

Currently, libprojectM uses the "hlslparser" library from the game Natural Selection 2 to convert the HLSL warp and composite shader code in presets to GLSL. While this parser works well in most cases, it has not been maintained for ten years now, and thus doesn't support any modern versions of both HLSL and GLSL, which currently limits us to PS 2.0 and GLSL 3.30 syntax.

There is a recent and still-maintained library called libniceshade, which is a convenience wrapper around Microsoft DirectXShaderCompiler and SPIRV-Cross. This library supports converting shaders for use in modern 3D APIs, including OpenGL 4.3, Vulkan and Metal, and also supports modern HLSL versions as well.

We should try to integrate this library into libprojectM and use it instead of hlslparser in the MilkdropShader class. Switching to this library would also mean that we have to increase the required OpenGL version to 4.3 on desktop platforms and change the shader language verions and syntax of our built-in shaders accordingly. Mobile/embedded builds can still use OpenGL ES 3.1.

This library also requires C++17, which will make libprojectM incompatible with older systems, e.g. macOS 10.15 and earlier and some old Linux distros. At the time we will potentially release this change, these operating system versions will most probably no longer be relevant.