MeFisto94 / jme-discussion

This Repository is used to keep track of potential future feature additions to the jMonkeyEngine. Look at the Issues.
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Support SPIRV as Shader Language #2

Open MeFisto94 opened 4 years ago

MeFisto94 commented 4 years ago

See https://eleni.mutantstargoat.com/hikiko/2018/03/04/opengl-spirv/ TLDR is: When using proper (GLSL 450) openGL Shaders, we can cross compile them to SPIRV (and potentially ship it with a game) and the Graphics APIs should all support SPIRV ("compiled shader"), which can directly be evaluated by those. This yields in faster speed as the drivers don't have to manually compile instructions and also maximum platform compatibility.

Projects like https://github.com/KhronosGroup/SPIRV-Cross allow SPIRV to be cross compiled to GLSL, HLSL (Direct X) and Metal (Mac OS X), so that even when SPIRV Extensions aren't available, one can use the native backends for shaders at least.

This is in particular interesting as Vulkan as a Backend also supports SPIRV

MeFisto94 commented 4 years ago

Me: If we had a gradle task to SPIRV, we could even support HLSL for the engine

@riccardobl on Discord: yes but there are several many problems

  1. jme compiles shaders multiple times(when youi change the defines )
  2. it needs opengl 450
  3. i think it is not fully portable

Me:

  1. I think is not true: The syntax has to be GLSL450, but the output needs the extension ARB_spirv 1 could be a problem indeed, packaging the SPIRV compilers is undesireable, maybe they have a solution for that though.

@riccardobl i don't have that extension, btw (https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gl_spirv.txt) Mesa 20.0.0-devel (git-0f60aa4 2019-12-07 bionic-oibaf-ppa) they are the default for amd cards on linux

Me: okay, WebGL doesn't support it either, which is sad http://renderingpipeline.com/webgl-extension-viewer/ potential gains could be:

@riccardobl: it won't, because we have different uniforms and uncompiled shaders are more platform agnostic because every platform will compile with its compiler