xray-16 icon indicating copy to clipboard operation
xray-16 copied to clipboard

OpenGL Renderer: use shaders cross-compiler

Open Xottab-DUTY opened this issue 7 years ago • 5 comments
trafficstars

Source code compilers:

  • glslang and SPIRV-Cross
    • We should check if it supports compilation from HLSL to SPIR-V for OpenGL. (https://github.com/KhronosGroup/glslang/issues/1417)
    • shaderc
  • DirectXShaderCompiler and SPIRV-Cross
  • vkd3d-shader
  • hlsloptconv (HLSL Optimizing Converter, SM3.0 – SM4.0)
  • hlslparser
    • HLSLParser (Only SM3.0, no preprocessor, so doesn't support #includes)
  • hlsl2glslfork (Only SM3.0)
  • shgen
  • XShaderCompiler (SM4 – SM5) (won't work for us currently, see https://github.com/LukasBanana/XShaderCompiler/issues/98)
  • https://zz85.github.io/hlslparser/
  • https://github.com/DiligentGraphics/DiligentCore/tree/master/Graphics/HLSL2GLSLConverterLib
    • https://diligentgraphics.com/diligent-engine/shader-converter/
    • http://diligentgraphics.com/diligent-engine/shader-converter/supported-features/
    • https://www.gamedeveloper.com/programming/state-of-the-art-hlsl-to-glsl-converter

Bytecode compilers are not suitable, we need to compile from sources. However, here's the list of some bytecode compilers:

Other useful links: Decompilers:

  • https://github.com/etnlGD/HLSLDecompiler
  • https://github.com/luxuia/dxbc_reader
  • https://github.com/AndresTraks/HlslDecompiler/
  • https://gitlab.winehq.org/fcasas/binary-d3dbc-parser

Other projects:

  • https://github.com/felipeagc/tinyshader
  • https://github.com/shader-slang/slang
  • https://github.com/septag/glslcc
  • https://github.com/julianrendell/GLSL2HLSL
  • https://github.com/Kode/krafix
  • https://github.com/KTXSoftware/kfx
  • https://github.com/MicrosoftEdge/WebGL/tree/master/GLSLParse
  • https://github.com/zigguratvertigo/hlsl-to-ispc
  • https://github.com/mellinoe/ShaderGen
  • https://github.com/DragonJoker/ShaderWriter
  • https://github.com/polymonster/pmfx-shader
  • https://github.com/cezbloch/shaderator

Playground, testing, live coding:

  • https://github.com/tgjones/shader-playground
  • https://github.com/astralis3d/HLSLexplorer
  • https://github.com/atyuwen/hlsl_live_coding

Other suggestions?

This issue is a sub-task of #280

Xottab-DUTY avatar Oct 21 '18 01:10 Xottab-DUTY

@Xottab-DUTY I don't think that the DXVK bytecode compiler supports SM 3.0. Also, DXBC is the name of HLSL bytecode. I believe stands for DirectX ByteCode.

ryao avatar Oct 21 '18 01:10 ryao

I don't think that the DXVK bytecode compiler supports SM 3.0.

Oh, that was a typo..

Also, DXBC is the name of HLSL bytecode. I believe stands for DirectX ByteCode.

I just removed this text then, since HLSLcc is bytecode compiler too.

Xottab-DUTY avatar Oct 21 '18 01:10 Xottab-DUTY

2 additional, but i haven't work with them, just found accidentally: https://github.com/Thekla/hlslparser https://github.com/aras-p/hlsl2glslfork

375gnu avatar Apr 01 '20 21:04 375gnu

Looks like dxc now comes with a SPIR-V backend enabled. The C++ API for cross compiling looks managable.

What simple converted program output looks like:

MerijnHendriks avatar Oct 09 '21 23:10 MerijnHendriks

None of existing cross-compilers is capable of cross-compiling S.T.AL.K.E.R. shaders. And! we have a strong requirement to not change anything in the game assets (shaders are game assets too)...

We could try to improve dxc or glslang to make it work, but the fact that there are no compilers that can compile these shaders actually tempts me to make my own compiler. image

Xottab-DUTY avatar Oct 10 '21 00:10 Xottab-DUTY