platonvin / lum

Lum - 3D voxel game engine
15 stars 2 forks source link

Building on linux #1

Open ThanosFisherman opened 1 month ago

ThanosFisherman commented 1 month ago

Hey I came across your project and I was wondering if there's an easy way to build and run this on arch linux. I tried as much but didn't succeed.

platonvin commented 1 month ago

I could not install Vulkan (and Vulkan-sdk) on Linux (via WSL2), so i have no way to test this directly, but some other issues (primarily with Makifle) might be fixed. I'll try to get it running on another machine. Feel free to share the errors you are getting and ideas on how to make it work on Linux (do not forget to pull latest commits from repo)

ThanosFisherman commented 1 month ago

I don't know much about makefile but I'll be happy to help. I believe I have vulkan sdk installed on my arch linux. I tried the command make -j10 and got the following errors

mkdir "obj"
mkdir "obj/deb"
mkdir "obj/rel"
mkdir "shaders/compiled"
glslc -o shaders/compiled/map_unopt.spv shaders/map.comp --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/map.spv shaders/compiled/map_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/map_unopt.spv"
del "shaders/compiled\map_unopt.spv"
glslc -o shaders/compiled/perlin2_unopt.spv shaders/perlin2.comp --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/perlin2.spv shaders/compiled/perlin2_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/perlin2_unopt.spv"
del "shaders/compiled\perlin2_unopt.spv"
glslc -o shaders/compiled/perlin3_unopt.spv shaders/perlin3.comp --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/perlin3.spv shaders/compiled/perlin3_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/perlin3_unopt.spv"
del "shaders/compiled\perlin3_unopt.spv"
glslc -o shaders/compiled/radiance_unopt.spv shaders/radiance.comp --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/radiance.spv shaders/compiled/radiance_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/radiance_unopt.spv"
del "shaders/compiled\radiance_unopt.spv"
glslc -o shaders/compiled/updateGrass_unopt.spv shaders/updateGrass.comp --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/updateGrass.spv shaders/compiled/updateGrass_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/updateGrass_unopt.spv"
del "shaders/compiled\updateGrass_unopt.spv"
glslc -o shaders/compiled/updateWater_unopt.spv shaders/updateWater.comp --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/updateWater.spv shaders/compiled/updateWater_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/updateWater_unopt.spv"
del "shaders/compiled\updateWater_unopt.spv"
glslc -o shaders/compiled/fillStencilSmokeVert_unopt.spv shaders/fillStencilSmoke.vert --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/fillStencilSmokeVert.spv shaders/compiled/fillStencilSmokeVert_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/fillStencilSmokeVert_unopt.spv"
del "shaders/compiled\fillStencilSmokeVert_unopt.spv"
glslc -o shaders/compiled/fullscreenTriagVert_unopt.spv shaders/fullscreenTriag.vert --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/fullscreenTriagVert.spv shaders/compiled/fullscreenTriagVert_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/fullscreenTriagVert_unopt.spv"
del "shaders/compiled\fullscreenTriagVert_unopt.spv"
glslc -o shaders/compiled/grassVert_unopt.spv shaders/grass.vert --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/grassVert.spv shaders/compiled/grassVert_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/grassVert_unopt.spv"
del "shaders/compiled\grassVert_unopt.spv"
glslc -o shaders/compiled/lightmapBlocksVert_unopt.spv shaders/lightmapBlocks.vert --target-env=vulkan1.1 -g -O
spirv-opt -o shaders/compiled/lightmapBlocksVert.spv shaders/compiled/lightmapBlocksVert_unopt.spv --target-env=vulkan1.1
del "shaders/compiled/lightmapBlocksVert_unopt.spv"
del "shaders/compiled\lightmapBlocksVert_unopt.spv"
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:129: shaders/compiled/lightmapBlocksVert.spv] Error 127
make: *** Waiting for unfinished jobs....
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:124: shaders/compiled/updateGrass.spv] Error 127
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:124: shaders/compiled/radiance.spv] Error 127
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:129: shaders/compiled/fullscreenTriagVert.spv] Error 127
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:124: shaders/compiled/perlin2.spv] Error 127
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:129: shaders/compiled/fillStencilSmokeVert.spv] Error 127
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:124: shaders/compiled/map.spv] Error 127
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:124: shaders/compiled/updateWater.spv] Error 127
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:129: shaders/compiled/grassVert.spv] Error 127
/bin/sh: line 3: del: command not found
/bin/sh: line 4: del: command not found
make: *** [Makefile:124: shaders/compiled/perlin3.spv] Error 127
platonvin commented 1 month ago

Try now (just for safity, delete whole obj/ directory). I'm pretty sure it builds on latest Ubuntu (tested in github workflow, check badge in readme) and my local WSL, but unfortunately neither support "graphics" so run sudo apt install libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev pkg-config build-essential, then vcpkg install (might take a while), then make.

ThanosFisherman commented 1 month ago

I tried again. I'm not sure what's wrong with vcpkg in my machine but I got this error

error: building rmlui:x64-linux failed with: BUILD_FAILED
See https://learn.microsoft.com/vcpkg/troubleshoot/build-failures?WT.mc_id=vcpkg_inproduct_cli for more information.
Elapsed time to handle rmlui:x64-linux: 6.4 s
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+rmlui
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?title=[rmlui]+Build+error+on+x64-linux&body=Copy+issue+body+from+%2Fhome%2Fthanos%2FCLionProjects%2Flum%2Fvcpkg_installed%2Fvcpkg%2Fissue_body.md

hitting make afterwards anyway also gave me the following

mkdir -p obj
mkdir -p obj/deb
mkdir -p obj/rel
/glslc -o shaders/compiled/map.spv shaders/map.comp --target-env=vulkan1.1 -g -O
make: /glslc: No such file or directory
make: *** [Makefile:128: shaders/compiled/map.spv] Error 127
platonvin commented 1 month ago

assuming you did not forget to git pull check your compiler version (for g++ and clang it would be g++ -v and clang -v), update vcpkg itself if installation is old, and try running it with specific triplet (e.g.: vcpkg install --triplet=x64-linux-release --host-triplet=x64-linux-release). From waht i see, problem is somewhere in building RmlUi - it might be C/C++ compiler, CMake or something else. make failed because it didnt find glslc (GLSL to SPIR-V) compiler, which is installed via Vcpkg (and make looks for glslc compiler in every triplet directory) maybe reinstall everything. Also, please provide more logs (from terminal / log file, there is probably path to it somewhere in terminal)

btw, i got Lum actually running (with all the graphics) on Ubuntu 22.04 with AMD Ryzen 5 5600U (Vega gpu) and AMDGPU drivers

ThanosFisherman commented 1 month ago

I reinstalled everything including cloning vcpkg again. I got the same error. I also tried with the triplet thing you suggested but no luck. I'm not sure how to find the terminal logs on Arch but I've attached the whole output of vcpkg install command. vcpkglog.txt

g++ -v gives the following

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/pkg/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://github.com/CachyOS/CachyOS-PKGBUILDS/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.1 20240805 (GCC) 

And clang -v gives

clang version 18.1.8
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/14.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

I'm not sure If I can help more. I'm not very familiar with C/C++ in general.

platonvin commented 1 month ago

is there /home/thanos/.vcpkg-clion/vcpkg/buildtrees/rmlui/install-x64-linux-dbg-out.log file? Seems like it is CMake building log that will explain what happened. also, try updating CMake and Ninja if not already

ThanosFisherman commented 1 month ago

Yeap here it is install-x64-linux-dbg-out.log

platonvin commented 1 month ago

Try now, current (5.1 => 5.1#1) RmlUi version seems to fix this problem (it is surely fixed in 6.0, but 6.0 changes api, and 5.1#1 seems like a version presented to fix exactly this isssue). In theory vcpkg installin /lum is enough (ofcourse after git pull)

ThanosFisherman commented 1 month ago

At last! Everything seems to complete sucessfuly with vcpkg install I have no idea what the issue was with RmlUi but no errors this time.

Nevertheless I was naive to think that C++ code would build as easily as my Java code :P I've got brand new error after issuing make the binary seemed to build fine though but when I executed client I got a glimpse of the demo followed by a crash. Here's the output of make and client execution. clienterror.txt

platonvin commented 1 month ago

Dont worry, i did not forget about this issue. It looks like internal Lum error (me being bad with command buffers), but i could not reproduce it on any of my devices. I was busy extracting (and improving) code that does Vulkan from Lum (lum-al) I believe you can do following (literally simple printf debugging): make cleanr make release_p and then send me client execution output again

Java code is not easy to build, it is all hard work of your build system. I do not like existing systems so i stick to barebone Make. And most of the problems were in different slashes on Windows/Linux, not shipped stdfloat (idk why), different content of Vulkan-sdk for different platforms, different default package versions on Vcpkg, different commands for same things in make for Linux and Windows, Linux relations with static linking and other problems that imho should not even exist. I guess if you decide to use notepad as editor and Zig as build system you will have some problems too.

Sorry for inconvenience and thanks that you are still trying to build my voxel demo :)

ThanosFisherman commented 1 month ago

That's true. Build systems do all the heavy lifting in Java. They have drawbacks but with time I've grown accustomed to Gradle and I am able to do some cool things. Even cross compile C/C++ libraries. But I do understand your point about notepad and zig. Vulkan stuff is uncharted waters for me.

Anyway Here's the output of the make command make_release.txt and don't worry I have an innate curiosity tinkering with such things even though they are outside of my expertise.

platonvin commented 1 month ago

Seems like Vulkan-Loader abort()'ed due to invalid command buffer handle (~pointer to driver-side struct). I could not reproduce it. What is your Vulkan driver? Is it lavapipe? Anyways, i fixed all validation layer errors i was getting and added few more runtime checks. Next step would be to move Lum to Lum-al and work on runtime validation there. so try following (and send me the output): git pull make clean (debug build with validation layers enabled and println logging) make debug args=-D_PRINTLINE (release build with validation layers disabled and println logging) make release args=-D_PRINTLINE

seems like we did not try your validation layers yet, it might be helpful

ThanosFisherman commented 4 weeks ago

I've attached the logs and the output of vulkaninfo command in case you are interested. I've no idea If I'm running lavapipe or not to be honest.

debugvalidation.txt releasevalidation.txt vulkaninfo.txt

platonvin commented 3 weeks ago

The last time i messed up a little bit with git and fix was not actually delivered to you. Lum is now built on top of Lum- al. Instructions are as follows: git pull make update - runs vcpkg install for Lum and it's (auto-installed) submodule Lum-al make release - is expected to work, but if it does not, please send output of (same command as previous) make debug args=-D_PRINTLINE and make release args=-D_PRINTLINE It builds on github ubuntu-latest and both builds and runs on that Ubuntu 22.04 AMD this time there is like 50 runtime checks more. Hopefully it will catch release segfault. debug's "Layer not found" should also be fixed (layer for monitoring fps now is now only enabled if supported)

ThanosFisherman commented 2 weeks ago

Finally I'm able to see something in the screen! No crashes this time! A sidenote. make update will throw an error if the obj directory is not present already. One more sidenote. The demo appears darker to me than in the pics but I can't complain.

Many thanks for the support!