turanszkij / WickedEngine

3D engine with modern graphics
https://wickedengine.net
Other
5.74k stars 603 forks source link

[Linux] make install not creating a working editor install #870

Closed CBBosman closed 3 months ago

CBBosman commented 3 months ago

WickedEngineEditor runs fine from build directory, but trying to run /usr/local/lib/WickedEngine/Editor/WickedEngineEditor (or /usr/local/bin/wicked-engine.sh, or from the included .desktop file) after doing a make install results in segfault with following output:

Starting Wicked Engine Editor
config.ini loaded in 1.919736 milliseconds

Created GraphicsDevice_Vulkan (356 ms)
Adapter: NVIDIA GeForce GTX 1070

[wi::initializer] Initializing Wicked Engine, please wait...
Version: 0.71.496

No embedded shaders found, shaders will be compiled at runtime if needed.
        Shader source path: /usr/local/lib/WickedEngine/Editor/../WickedEngine/shaders/
        Shader binary path: /usr/local/lib/WickedEngine/Editor/shaders/spirv/

wi::jobsystem Initialized with 8 cores in 0.70 ms
        High priority threads: 7
        Low priority threads: 6
        Streaming threads: 1

wi::input Initialized (0 ms)
[Error] wi::shadercompiler: could not load library ./libdxcompiler.so
[Error] ./libdxcompiler.so: cannot open shared object file: No such file or directory
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_primitivesCS.cso

[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/hairparticleVS.cso

[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/raytraceCS.cso

[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/emittedparticleVS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/hairparticleVS.cso
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_primitivesCS.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_hierarchyCS.cso

[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/hairparticlePS_simple.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/emittedparticleVS.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/imageVS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_hierarchyCS.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/emittedparticlePS_soft.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/raytraceCS.cso
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/hairparticlePS_simple.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_propagateaabbCS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/imageVS.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/hairparticlePS_prepass.cso

[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/imagePS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/emittedparticlePS_soft.cso
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/hairparticlePS_prepass.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/emittedparticlePS_soft_distortion.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_propagateaabbCS.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/objectVS_prepass_alphatest.cso

wi::GPUBVH Initialized (3 ms)
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/hairparticlePS_prepass_depthonly.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/emittedparticlePS_soft_distortion.cso
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/imagePS.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/objectVS_simple_tessellation.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/objectVS_prepass_alphatest.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/emittedparticlePS_simple.cso

[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/sphereVS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/objectVS_simple_tessellation.cso
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/hairparticlePS_prepass_depthonly.cso
Segmentation fault

I tried creating a symlink /usr/local/lib/WickedEngine/Editors/libdxcompiler.so -> /usr/local/lib/WickedEngine/libdxcompiler.so but then it can't find the shaders:

Starting Wicked Engine Editor
config.ini loaded in 0.365258 milliseconds

Created GraphicsDevice_Vulkan (346 ms)
Adapter: NVIDIA GeForce GTX 1070

[wi::initializer] Initializing Wicked Engine, please wait...
Version: 0.71.496

No embedded shaders found, shaders will be compiled at runtime if needed.
        Shader source path: /usr/local/lib/WickedEngine/Editor/../WickedEngine/shaders/
        Shader binary path: /usr/local/lib/WickedEngine/Editor/shaders/spirv/

wi::jobsystem Initialized with 8 cores in 0.73 ms
        High priority threads: 7
        Low priority threads: 6
        Streaming threads: 1

wi::input Initialized (0 ms)
wi::shadercompiler: loaded ./libdxcompiler.so (version: 1.8)
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/../WickedEngine/shaders/bvh_primitivesCS.hlsl
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/../WickedEngine/shaders/fontVS.hlsl
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_primitivesCS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/../WickedEngine/shaders/imageVS.hlsl
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/fontVS.cso

[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/imageVS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/imageVS.cso
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_primitivesCS.cso
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/fontVS.cso
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/../WickedEngine/shaders/imagePS.hlsl
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/../WickedEngine/shaders/bvh_hierarchyCS.hlsl
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/imagePS.cso

[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_hierarchyCS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/../WickedEngine/shaders/fontPS.hlsl
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/imagePS.cso
[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_hierarchyCS.cso
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/fontPS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/../WickedEngine/shaders/bvh_propagateaabbCS.hlsl
[Error] shader compile FAILED: /usr/local/lib/WickedEngine/Editor/shaders/spirv/bvh_propagateaabbCS.cso

[Warning] File not found: /usr/local/lib/WickedEngine/Editor/shaders/spirv/fontPS.cso
Segmentation fault

System: Linux (Artix)

turanszkij commented 3 months ago

If you don't embed the shaders with offlineshadercompiler into the exe, then you need to ensure shader sources are found relative to the Editor's exe and also the shader compiler.

If you build the WickedEngine/offlineshadercompiler tool, then you can run it to embed the shaders with these arguments: spirv shaderdump Which will compile spirv shaders for Vulkan and create the wiShaderDump.h file containing all compiled shaders as a c++ byte array. Now if you rebuild the engine and the Editor, the shaders are in the exe, and it can be used stand alone, without .hlsl files or the shader compiler.

Here you can find the complete Linux build script that creates a standalone Editor: https://github.com/turanszkij/WickedEngine/blob/master/.github/workflows/build-nightly.yml#L55

CBBosman commented 3 months ago

Excellent.

Previously I did try to symlink the shaders dir and compiler lib to the proper locations as described above, but then got some file system error. I assumed that it was trying to compile the shaders at first run and needed permissions to write to the install dir, which I didn't investigate further, because I don't want to run it with elevated permissions. I may have just screwed something up, though.

Embedding the shaders like you described, following the build script, works great, thanks!

Cheers!

turanszkij commented 3 months ago

The downside of embedding the shaders is that you can not modify shaders easily this way because the Editor doesn't recompile them from source file changes. Also if you pull a new engine version, and there were shader changes, they will not be rebuilt automatically. So it is only recommended for giving out release versions with embedded shaders, not for development.