View Full Version : GLSL -> SPIR-V -> OpenGL

Dark Photon
01-11-2018, 05:55 AM
I'm curious if anyone has experience with precompiling GLSL to SPIR-V, and then feeding in those SPIR-V shader modules to OpenGL drivers for one or more GPU vendors.

If so...:

what GLSL-to-SPIR-V precompiler did you use (e.g. glslang (https://github.com/KhronosGroup/glslang)),
did you run into any problems with precompiling (unsupported GLSL features/extensions/etc.),
what GPU vendors' GL drivers have you tried this with,
did you notice much of a performance hit with glShaderBinary() or glSpecializeShader() (in OpenGL 4.6; see ARB_gl_spirv (https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gl_spirv.txt) and ARB_get_program_binary (https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_get_program_binary.txt)).
any other advice you could give to others based on your experience?

I'm actually wondering whether this might be a reasonable path to help avoid some of first-time GLSL shader compilation cost associated with feeding GLSL source code to GL drivers at runtime, but yet provide some measure of cross-platform/-GPU/-driver-version support for the precompiled "binaries" fed into the GLSL driver. I'm also curious whether this path might bypass some/all of the cost of dynamic shader reoptimization (https://www.opengl.org/discussion_boards/showthread.php/199464-Effects-of-driver-sided-program-re-linking?p=1286662&styleid=1) (aka shader patching) that sometimes occurs at runtime when you're rendering, which is extremely bad for users of high-performance OpenGL applications.

(Looks like Sascha Williams has played with this a bit (LINK (https://github.com/SaschaWillems/openglcpp/blob/master/SPIRVShader/main.cpp)), but I didn't see much else out there.)